Re: [PATCH net-next v2 5/5] net: rnpgbe: Add hardware and queue statistics
From: Yibo Dong
Date: Sun Nov 22 2026 - 21:42:11 EST
On Thu, Nov 19, 2026 at 03:09:46PM +0000, netdev-bot+sashiko@xxxxxxxxxx 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] The patch makes the device-level RX packet and byte counts in
> netdev qstats disagree with the rtnl stats64 counts, so the in-tree…
>
> --
>
> net: rnpgbe: Add hardware and queue statistics
>
> This commit adds the hardware RX CRC-error and multicast counters to
> ndo_get_stats64. It also reports per-queue RX and TX packet and byte
> counters through netdev queue statistics, 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);
>
> [ ... ]
>
> > 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]
>
> Will the qstat rx-packets and rx-bytes reported here ever match the
> rx_packets and rx_bytes that rnpgbe_get_stats64() reports?
>
> rnpgbe_get_stats64() reads queue_stats->packets and queue_stats->bytes.
> rnpgbe_clean_rx_irq() also increments those for good packets that the
> driver drops. One example is the skb build failure path:
>
> if (!skb) {
> atomic64_inc(&rx_ring->stats->skb_alloc_failures);
> ...
> if (rnpgbe_test_staterr(rx_desc, M_RXD_STAT_EOP)) {
> total_rx_bytes += size;
> total_rx_packets++;
> total_rx_dropped++;
>
> The same thing happens when a MUCSE_RX_DROP_RESOURCE frame reaches EOP,
> and when rnpgbe_cleanup_headers() fails with size >= ETH_HLEN. None of
> these paths update delivered_packets or delivered_bytes.
>
> rnpgbe_get_stats64() covers all RNPGBE_MAX_QUEUES. So do the qstat device
> totals, which pick up inactive queues through rnpgbe_get_base_stats().
> That means after the first such drop, the rtnl RX counts stay above the
> qstat RX counts for good.
>
> tools/testing/selftests/drivers/net/stats.py pkt_byte_sum() expects the
> two to match:
>
> # Compare stats, rtnl stats and qstats must match,
> ...
> if stat_cmp(rtstat, qstat) > 0:
> raise KsftFailEx("Qstats are lower, fetched later")
>
> Once any RX drop has happened, wouldn't this test fail on rnpgbe? The
> commit message describes the split: "RX queue counters cover packets
> delivered to the networking stack, while interface RX totals also include
> good packets dropped by the driver".
>
> Could both interfaces report the same packets and bytes? Alternatively,
> could driver drops be counted only in rx_dropped, and not in the rtnl
> rx_packets and rx_bytes?
>
After checking the documented semantics, I think these counters need to
remain different when the driver drops a 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 pkt_byte_sum selftest can consequently fail after such a drop. I do
not think changing the driver counters solely to satisfy that equality
would preserve the documented semantics.
> > + stats->alloc_fail = atomic64_read(&queue->page_alloc_failures) +
> > + atomic64_read(&queue->skb_alloc_failures);
> > +}
>
> [ ... ]
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/BD205A7832D36E7D%2B20261116030917.1329989-1-dong100%40mucse.com
>