All of lore.kernel.org
 help / color / mirror / Atom feed
From: willemb@google.com
To: Yibo Dong <dong100@mucse.com>, willemb@google.com
Cc: netdev-bot+sashiko@kernel.org, andrew+netdev@lunn.ch,
	davem@davemloft.net,  edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org,
	 linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	yaojun@mucse.com
Subject: Re: [PATCH net-next v3 5/5] net: rnpgbe: Add hardware and queue statistics
Date: Thu, 03 Dec 2026 23:55:41 -0500	[thread overview]
Message-ID: <willemb.2dc2ab51f64c6@google.com> (raw)
In-Reply-To: <F0B13519B379C604+20261203055054.GA838474@nic-Precision-5820-Tower>

Yibo Dong wrote:
> On Wed, Dec 02, 2026 at 11:04:19PM -0500, willemb@google.com wrote:
> > Yibo Dong wrote:
> > > On Wed, Nov 25, 2026 at 06:36:06AM +0000,  
> netdev-bot+sashiko@kernel.org
> > > wrote:
> > > > Thank you for your contribution! Sashiko AI review found 1 potential
> > > > issue(s) to consider.
> > > >
> > > > Critical: 0 · High: 0 · Medium: 1 · Low: 0
> > > >
> > > > If you believe none of the issues are legitimate, please reply to  
> each
> > > > issue of Medium severity or higher and explain why the AI is wrong.
> > > > If any of them are legitimate and you plan to respin, please let
> > > patchwork
> > > > know by including "pw-bot: cr" as a separate line at the end of your
> > > reply
> > > > (one such reply per series is enough).
> > > >
> > > > - [Medium] After this patch the driver reports two RX totals that
> > > >   disagree.
> > > >
> > > > --
> > > >
> > > > net: rnpgbe: Add hardware and queue statistics
> > > >
> > > > This commit adds hardware RX CRC-error and multicast counters to
> > > > ndo_get_stats64, accumulated from the service task. It also reports
> > > > per-queue RX/TX packet and byte counters through netdev queue  
> stats, and
> > > > exposes per-queue TX DMA mapping failures through ethtool  
> statistics.
> > > >
> > > > > diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c
> > > b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c
> > > > > index b7b0c45a0f664..fe320c4f389ba 100644
> > > > > --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c
> > > > > +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_lib.c
> > > >
> > > > [ ... ]
> > > >
> > > > > @@ -615,6 +620,8 @@ static int rnpgbe_clean_rx_irq(struct
> > > mucse_q_vector *q_vector,
> > > > >
> > > > >  		/* probably a little skewed due to removing CRC */
> > > > >  		total_rx_bytes += skb->len;
> > > > > +		delivered_bytes += skb->len;
> > > > > +		delivered_packets++;
> > > > >  		rnpgbe_process_skb_fields(rx_ring, skb);
> > > > >  		rx_desc->wb.cmd = 0;
> > > > >  		napi_gro_receive(&q_vector->napi, skb);
> > > > > @@ -626,6 +633,8 @@ static int rnpgbe_clean_rx_irq(struct
> > > mucse_q_vector *q_vector,
> > > > >  	u64_stats_update_begin(&rx_ring->stats->syncp);
> > > > >  	rx_ring->stats->packets += total_rx_packets;
> > > > >  	rx_ring->stats->bytes += total_rx_bytes;
> > > > > +	rx_ring->stats->delivered_packets += delivered_packets;
> > > > > +	rx_ring->stats->delivered_bytes += delivered_bytes;
> > > > >  	rx_ring->stats->length_errors += total_rx_length_errors;
> > > > >  	atomic64_add(total_rx_dropped, &rx_ring->stats->dropped);
> > > > >  	u64_stats_update_end(&rx_ring->stats->syncp);
> > > >
> > > > [ ... ]
> > > >
> > > > > diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_stats.c
> > > b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_stats.c
> > > > > new file mode 100644
> > > > > index 0000000000000..efd2284fd93af
> > > > > --- /dev/null
> > > > > +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_stats.c
> > > >
> > > > [ ... ]
> > > >
> > > > > +static void rnpgbe_get_queue_stats_rx(struct net_device *netdev,
> > > int idx,
> > > > > +				      struct netdev_queue_stats_rx *stats)
> > > > > +{
> > > > > +	struct mucse *mucse = netdev_priv(netdev);
> > > > > +	const struct mucse_queue_stats *queue;
> > > > > +	unsigned int start;
> > > > > +
> > > > > +	queue = &mucse->rx_stats[idx];
> > > > > +	do {
> > > > > +		start = u64_stats_fetch_begin(&queue->syncp);
> > > > > +		stats->packets = queue->delivered_packets;
> > > > > +		stats->bytes = queue->delivered_bytes;
> > > > > +	} while (u64_stats_fetch_retry(&queue->syncp, start));
> > > >
> > > > [Severity: Medium]
> > > > Can this leave the qstat RX totals permanently out of step with the  
> rtnl
> > > > RX totals?
> > > >
> > > > rnpgbe_get_stats64() adds rx_stats[i].packets and rx_stats[i].bytes  
> into
> > > > rx_packets and rx_bytes. In rnpgbe_clean_rx_irq(), the driver-drop  
> paths
> > > > increase those counters but leave delivered_packets and  
> delivered_bytes
> > > > alone. One example is the skb == NULL path at EOP:
> > > >
> > > > 	if (!skb) {
> > > > 		atomic64_inc(&rx_ring->stats->skb_alloc_failures);
> > > > 		...
> > > > 			total_rx_bytes += size;
> > > > 			total_rx_packets++;
> > > > 			total_rx_dropped++;
> > > >
> > > > The MUCSE_RX_DROP_RESOURCE EOP path and the rnpgbe_cleanup_headers()
> > > > failure path with size >= ETH_HLEN behave the same way.
> > > >
> > > > This callback reports only delivered_* as qstat rx-packets and  
> rx-bytes.
> > > > rnpgbe_get_base_stats() uses the same callback through
> > > > netdev_stat_queue_sum() for the inactive queues. So after the first
> > > > driver RX drop, the rtnl totals stay higher than the qstat totals.  
> An
> > > > skb allocation failure under memory pressure is enough to cause that
> > > > drop. Nothing resets these counters, so the gap never closes.
> > > >
> > > > The generic selftest expects the two sets of totals to match:
> > > >
> > > > tools/testing/selftests/drivers/net/stats.py:pkt_byte_sum()
> > > >     # Compare stats, rtnl stats and qstats must match,
> > > >     ...
> > > >         if stat_cmp(rtstat, qstat) > 0:
> > > >             raise KsftFailEx("Qstats are lower, fetched later")
> > > >
> > > > The commit message says the split is intentional. Even so, could  
> both
> > > > interfaces report the same packet and byte counters? One option is  
> to
> > > > use packets and bytes here. Another is to keep driver drops out of  
> the
> > > > rtnl rx_packets and rx_bytes totals.
> > > >
> > > After checking the documented semantics, I think these counters can
> > > legitimately differ when the driver drops a good received packet.
> >
> > > include/uapi/linux/if_link.h defines rx_packets as including good  
> packets
> > > received by the host but subsequently dropped, even within the driver.
> > > In contrast, Documentation/netlink/specs/netdev.yaml defines qstats
> > > rx-packets as packets successfully received and passed to the stack.
> > > The corresponding byte counters follow the same distinction.
> >
> > > The pkt_byte_sum selftest can consequently fail after such a drop.
> > > Changing either set of counters solely to satisfy that equality would
> > > conflict with its documented semantics.
> >
> > tools/testing/selftests/drivers/net/stats.py:90-125 (pkt_byte_sum)
> > explicitly tests RTNL and qstats rx_packets/rx_bytes to match. And, no
> > other in-tree driver maintains separate  
> delivered_packets/delivered_bytes
> > counters. For example, fbnic and mpnic report the same underlying
> > per-queue counter to both APIs.
> I understand that both drivers expose the same underlying counters
> through rtnl and qstats. However, their accounting for a good packet
> dropped because skb allocation failed appears to differ: fbnic
> excludes it from the packet and byte counters, while mpnic includes
> it.

> For rnpgbe, should both APIs include such packets, or should both
> exclude them, with drops still reported separately?

Exclude them from both, and continue reporting them in rx_dropped and
rx-alloc-fail.

That follows the newer qstats definition ("received and passed to the
stack"), matches fbnic (see also commit 613e9e8dcb7e ("eth: fbnic: fix
accounting of XDP packets"), which aligned both APIs on the qstats
definition) as well as other SW-counted drivers like gve and mlx5, and
also lets you simplify rnpgbe_clean_rx_irq() by removing the extra
drop_bytes and drop-path packet/byte accounting.

  reply	other threads:[~2026-12-04  4:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  6:04 [PATCH net-next v3 0/5] net: rnpgbe: Add basic management and statistics Dong Yibo
2026-11-24  6:05 ` [PATCH net-next v3 1/5] net: rnpgbe: Add basic ethtool support Dong Yibo
2026-11-24  6:05 ` [PATCH net-next v3 2/5] net: rnpgbe: Report link settings through ethtool Dong Yibo
2026-11-25  6:36   ` netdev-bot+sashiko
2026-11-25  7:09     ` Yibo Dong
2026-11-24  6:06 ` [PATCH net-next v3 3/5] net: rnpgbe: Support copper link configuration Dong Yibo
2026-11-25  6:36   ` netdev-bot+sashiko
2026-11-25  7:31     ` Yibo Dong
2026-11-24  6:06 ` [PATCH net-next v3 4/5] net: rnpgbe: Allow changing the primary MAC address Dong Yibo
2026-11-25  6:36   ` netdev-bot+sashiko
2026-11-24  6:06 ` [PATCH net-next v3 5/5] net: rnpgbe: Add hardware and queue statistics Dong Yibo
2026-11-25  6:36   ` netdev-bot+sashiko
2026-11-25  7:36     ` Yibo Dong
2026-12-03  4:04       ` willemb
2026-12-03  5:50         ` Yibo Dong
2026-12-04  4:55           ` willemb [this message]
2026-12-04  6:54             ` Yibo Dong

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=willemb.2dc2ab51f64c6@google.com \
    --to=willemb@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dong100@mucse.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yaojun@mucse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.