Netdev List
 help / color / mirror / Atom feed
From: Joe Damato <jdamato@fastly.com>
To: Justin Lai <justinlai0215@realtek.com>
Cc: "kuba@kernel.org" <kuba@kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"edumazet@google.com" <edumazet@google.com>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"andrew@lunn.ch" <andrew@lunn.ch>,
	"jiri@resnulli.us" <jiri@resnulli.us>,
	"horms@kernel.org" <horms@kernel.org>,
	"rkannoth@marvell.com" <rkannoth@marvell.com>,
	Ping-Ke Shih <pkshih@realtek.com>,
	Larry Chiu <larry.chiu@realtek.com>
Subject: Re: [PATCH net-next v25 08/13] rtase: Implement net_device_ops
Date: Mon, 29 Jul 2024 12:56:06 +0100	[thread overview]
Message-ID: <ZqeDVl5rGXfEjv4m@LQ3V64L9R2> (raw)
In-Reply-To: <f55076d3231f40dead386fe6d7de58c9@realtek.com>

On Mon, Jul 29, 2024 at 11:39:03AM +0000, Justin Lai wrote:
> > On Mon, Jul 29, 2024 at 02:21:16PM +0800, Justin Lai wrote:
> > > 1. Implement .ndo_set_rx_mode so that the device can change address
> > > list filtering.
> > > 2. Implement .ndo_set_mac_address so that mac address can be changed.
> > > 3. Implement .ndo_change_mtu so that mtu can be changed.
> > > 4. Implement .ndo_tx_timeout to perform related processing when the
> > > transmitter does not make any progress.
> > > 5. Implement .ndo_get_stats64 to provide statistics that are called
> > > when the user wants to get network device usage.
> > > 6. Implement .ndo_vlan_rx_add_vid to register VLAN ID when the device
> > > supports VLAN filtering.
> > > 7. Implement .ndo_vlan_rx_kill_vid to unregister VLAN ID when the
> > > device supports VLAN filtering.
> > > 8. Implement the .ndo_setup_tc to enable setting any "tc" scheduler,
> > > classifier or action on dev.
> > > 9. Implement .ndo_fix_features enables adjusting requested feature
> > > flags based on device-specific constraints.
> > > 10. Implement .ndo_set_features enables updating device configuration
> > > to new features.
> > >
> > > Signed-off-by: Justin Lai <justinlai0215@realtek.com>
> > > ---
> > >  .../net/ethernet/realtek/rtase/rtase_main.c   | 235 ++++++++++++++++++
> > >  1 file changed, 235 insertions(+)
> > >
> > > diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > > b/drivers/net/ethernet/realtek/rtase/rtase_main.c
> > > index 8fd69d96219f..80673fa1e9a3 100644
> > 
> > [...]
> > 
> > > +static void rtase_dump_state(const struct net_device *dev) {
> > 
> > [...]
> > 
> > > +
> > > +     netdev_err(dev, "tx_packets %lld\n",
> > > +                le64_to_cpu(counters->tx_packets));
> > > +     netdev_err(dev, "rx_packets %lld\n",
> > > +                le64_to_cpu(counters->rx_packets));
> > > +     netdev_err(dev, "tx_errors %lld\n",
> > > +                le64_to_cpu(counters->tx_errors));
> > > +     netdev_err(dev, "rx_errors %d\n",
> > > +                le32_to_cpu(counters->rx_errors));
> > > +     netdev_err(dev, "rx_missed %d\n",
> > > +                le16_to_cpu(counters->rx_missed));
> > > +     netdev_err(dev, "align_errors %d\n",
> > > +                le16_to_cpu(counters->align_errors));
> > > +     netdev_err(dev, "tx_one_collision %d\n",
> > > +                le32_to_cpu(counters->tx_one_collision));
> > > +     netdev_err(dev, "tx_multi_collision %d\n",
> > > +                le32_to_cpu(counters->tx_multi_collision));
> > > +     netdev_err(dev, "rx_unicast %lld\n",
> > > +                le64_to_cpu(counters->rx_unicast));
> > > +     netdev_err(dev, "rx_broadcast %lld\n",
> > > +                le64_to_cpu(counters->rx_broadcast));
> > > +     netdev_err(dev, "rx_multicast %d\n",
> > > +                le32_to_cpu(counters->rx_multicast));
> > > +     netdev_err(dev, "tx_aborted %d\n",
> > > +                le16_to_cpu(counters->tx_aborted));
> > > +     netdev_err(dev, "tx_underun %d\n",
> > > +                le16_to_cpu(counters->tx_underun));
> > 
> > You use le64/32/16_to_cpu here for all stats, but below in rtase_get_stats64, it
> > is only used for tx_errors.
> > 
> > The code should probably be consistent? Either you do or don't need to use
> > them?
> > 
> > > +}
> > > +
> > [...]
> > > +
> > > +static void rtase_get_stats64(struct net_device *dev,
> > > +                           struct rtnl_link_stats64 *stats) {
> > > +     const struct rtase_private *tp = netdev_priv(dev);
> > > +     const struct rtase_counters *counters;
> > > +
> > > +     counters = tp->tally_vaddr;
> > > +
> > > +     dev_fetch_sw_netstats(stats, dev->tstats);
> > > +
> > > +     /* fetch additional counter values missing in stats collected by driver
> > > +      * from tally counter
> > > +      */
> > > +     rtase_dump_tally_counter(tp);
> > > +     stats->rx_errors = tp->stats.rx_errors;
> > > +     stats->tx_errors = le64_to_cpu(counters->tx_errors);
> > > +     stats->rx_dropped = tp->stats.rx_dropped;
> > > +     stats->tx_dropped = tp->stats.tx_dropped;
> > > +     stats->multicast = tp->stats.multicast;
> > > +     stats->rx_length_errors = tp->stats.rx_length_errors;
> > 
> > See above; le64_to_cpu for tx_errors, but not the rest of the stats. Why?
> 
> The rtase_dump_state() function is primarily used to dump certain hardware
> information. Following discussions with Jakub, it was suggested that we
> should design functions to accumulate the 16-bit and 32-bit counter values
> to prevent potential overflow issues due to the limited size of the
> counters. However, the final decision was to temporarily refrain from
> reporting 16-bit and 32-bit counter information. Additionally, since
> tx_packet and rx_packet data are already provided through tstat, we
> ultimately opted to modify it to the current rtase_get_stats64() function.

Your response was a bit confusing, but after re-reading the code I
think I understand now that I misread the code above.

The answer seems to be that tx_errors is accumulated in
rtase_counters (which needs le*_to_cpu), but the other counters are
accumulated in tp->stats which do not need le*_to_cpu because they
are already being accounted in whatever endianness the CPU uses.

OK.

  reply	other threads:[~2024-07-29 11:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29  6:21 [PATCH net-next v25 00/13] Add Realtek automotive PCIe driver Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 01/13] rtase: Add support for a pci table in this module Justin Lai
2024-07-29  9:33   ` Markus Elfring
2024-07-29 11:31     ` Justin Lai
2024-07-29 13:00     ` Andrew Lunn
2024-07-29 16:44       ` Markus Elfring
2024-07-29  6:21 ` [PATCH net-next v25 02/13] rtase: Implement the .ndo_open function Justin Lai
2024-07-30  2:15   ` Jakub Kicinski
2024-07-30  9:24     ` Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 03/13] rtase: Implement the rtase_down function Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 04/13] rtase: Implement the interrupt routine and rtase_poll Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 05/13] rtase: Implement hardware configuration function Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 06/13] rtase: Implement .ndo_start_xmit function Justin Lai
2024-07-30  2:14   ` Jakub Kicinski
2024-07-30  9:27     ` Justin Lai
2024-07-30 14:12       ` Jakub Kicinski
2024-07-30 19:34       ` Heiner Kallweit
2024-07-29  6:21 ` [PATCH net-next v25 07/13] rtase: Implement a function to receive packets Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 08/13] rtase: Implement net_device_ops Justin Lai
2024-07-29 10:29   ` Joe Damato
2024-07-29 11:39     ` Justin Lai
2024-07-29 11:56       ` Joe Damato [this message]
2024-07-29 12:26         ` Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 09/13] rtase: Implement pci_driver suspend and resume function Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 10/13] rtase: Implement ethtool function Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 11/13] rtase: Add a Makefile in the rtase folder Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 12/13] realtek: Update the Makefile and Kconfig in the realtek folder Justin Lai
2024-07-29  6:21 ` [PATCH net-next v25 13/13] MAINTAINERS: Add the rtase ethernet driver entry Justin Lai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZqeDVl5rGXfEjv4m@LQ3V64L9R2 \
    --to=jdamato@fastly.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=justinlai0215@realtek.com \
    --cc=kuba@kernel.org \
    --cc=larry.chiu@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pkshih@realtek.com \
    --cc=rkannoth@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox