Re: [PATCH net-next v3 5/5] net: rnpgbe: Add hardware and queue statistics

From: Yibo Dong

Date: Wed Nov 25 2026 - 02:38:06 EST


On Wed, Nov 25, 2026 at 06:36:06AM +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] 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.
> > + 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/6C54E9FB2E95869E%2B20261124060436.410989-1-dong100%40mucse.com
>