Article View: linux.kernel.netdev
Article #26159Re: [PATCH net-next v3 5/5] net: rnpgbe: Add hardware and queue statistics
From: Yibo Dong
Date: Thu, 03 Dec 2026 05:50
Date: Thu, 03 Dec 2026 05:50
152 lines
15895 bytes
15895 bytes
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?
Thanks for your feedback.
Technical Details
Message-ID:
<F0B13519B379C604+20261203055054.GA838474@nic-Precision-5820-Tower>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376307-linux-kernel-netdev=dewy.ruReferences:
<DB48C65C5764A9FD+20261124060623.411536-1-dong100@mucse.com> <179558856602.3135.7505371780005583025@kernel.org> <F283E54B74613F72+20261125073614.GC752553@nic-Precision-5820-Tower> <willemb.1db2b1b74ff94@google.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376307-linux-kernel-netdev=dewy.ru From: dong100@mucse.com (Yibo Dong) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v3 5/5] net: rnpgbe: Add hardware and queue statistics Date: Thu, 3 Dec 2026 13:50:54 +0800 Organization: Usenet Network Message-ID: <F0B13519B379C604+20261203055054.GA838474@nic-Precision-5820-Tower> References: <DB48C65C5764A9FD+20261124060623.411536-1-dong100@mucse.com> <179558856602.3135.7505371780005583025@kernel.org> <F283E54B74613F72+20261125073614.GC752553@nic-Precision-5820-Tower> <willemb.1db2b1b74ff94@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2168256"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:WjnMfDAjCyI1yKK3xdT24z4BFwM= sha256:VEfzSRHmAzkpYXH5Wfx4MO5xzUHkzmhwV8fTrLyNnbQ= sha1:L2+ecjWTcHcx47Bfcw10GGR5EAY= sha256:asiKEatGRp9akxkSXEQU70yUmzITaFtP07hDlIb2dGo= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id A17EF117825; Thu, 3 Dec 2026 08:52:31 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DlwahhzNHmFO; Thu, 3 Dec 2026 08:52:22 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376307-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mucse.com X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 057D611710A; Thu, 3 Dec 2026 08:52:17 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 2551E25250; Thu, 3 Dec 2026 05:52:15 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796277131; b=hZyElwdaE96lIs4+W4l68e0xB0bxeiURqp9IShhPcRR8X06fSlWF312lB42FCAHY9hZe /mLet5AHba1oqUzVfpQwiVB9UiRn9JkOaaYRpDcpeF2/ggTxUrcvMdhIopgfA93SJogUu D7nbe/ZtjyADrjYqsUTy9DniwE8+92QeNFpaGnQ2sMdLKz7PgdPvaRosxzHdHIEHthaP1 q3jmARu7i2ETXNQppAQRH763hbC5ak0cA0NeytPx7LUSwCX0Dpqo853lD683+ccDzckeE /EHVjJ67LacgOcQ2UXQTiFlc/4DMTTigMlQOsmYxR6Cin5CS3hZ0WkTnxwxVjcSbi1w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796277131; h=X-Original-To:Received:DMARC-Filter:X-QQ-mid:X-QQ-Originating-IP: Received:X-QQ-SSF:X-QQ-GoodBg:X-BIZMAIL-ID:EX-QQ-RecipientCnt:Date: From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To:X-QQ-SENDSIZE:Feedback-ID: X-QQ-XMAILINFO:X-QQ-XMRINFO:X-QQ-RECHKSPAM; bh=sBJAtLckvZbP++52kDMQbsrTKgKIFqz7O/uhs9HxJpo=; b=bCvU6TUWdKitqa+FcK5Ncc0c0nB4TcebaQNMUI/3CIkyI5j/n+fsU0asT+mMb05xxvnl kEwgz0/YjMR7n0tKIR3DJAqZUMpyFtHH5xogcaUfYJ8K8whLNH/rN7/M65QsqOXAzI6PB +IBxsBnYSRighPhGKFWS/VFZjJ3NHeQQvu88ZMn8VD5raHWB1iTJmm4IzRhwbvDmm0KBF rJHg8kCHyUUS17AVQSNm9uHwOgWsLDdQMzSj9uNDbpq7kzuVIQHjk9gRwM33MhEAUqcvj cmh5eixdD3AWfrAxHamCWdOHYp440lwU0ubmYr1zSwLFfhRF3R+AQEohBblfarTUH6w== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=mucse.com; spf=pass smtp.mailfrom=mucse.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E41BF606A339; Thu, 3 Dec 2026 05:52:11 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.243.244.52 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796277131; b=03PTUzugelhS+PlHEDViWtcaRVfXLjlFuYGdwIO8Orbxj1zh3XqdkDWiQf3ussFtYFLZ enY3LR5QnIRLhGHcMV0lBZ3uzfzz4W6Scm7ZehhVGKNMJJL8uE1Whkj7q3ReoRk7qpvna 3umjpQ478j5euvRRkG0hvsh5B8UiVH1mELKPaEpPM/nXu1wwZULgt3CrT5afsleU2l0N5 7Uh7DaMETt1xlRni+3pxUJVSeCAhc7HvGcDi9fquUff1SUgRfF48lcivDVscfFSAT1+Fb H9tS6zWYKUWUUjJMDXyL0OTROMHdnk9JBj9nJ/hUIYZf5hOmqRMR+uPB6wdefyivVzQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796277131; h=DMARC-Filter:X-QQ-mid:X-QQ-Originating-IP:Received:X-QQ-SSF: X-QQ-GoodBg:X-BIZMAIL-ID:EX-QQ-RecipientCnt:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To:X-QQ-SENDSIZE:Feedback-ID: X-QQ-XMAILINFO:X-QQ-XMRINFO:X-QQ-RECHKSPAM; bh=sBJAtLckvZbP++52kDMQbsrTKgKIFqz7O/uhs9HxJpo=; b=QKQnmDHvAAJBS1ATzUr3zH4aUU2ZSc8IQiTmBXikxsjkzGXljwAjB2NSN+A57mTAhqBx zAPBl0GDo9/a1vePd0WFgR1anE31/Pxrei/0YXNG7qWnyVdzRuN1zsABWJrTJ9mmSfn8K 6CzhUhr9++ZseaqdIeYf5rK4hzwcaqaxyUT0roUUoXtqpDoN+NVOmh3yLQLX8x1MwbfUh yjZfkPUiKlTu2UVJN9Yvid1/p/B6ZYjKemzsjj5Lylsapd6uMvHIc08qzrri63MNSd8N+ aRDvSlbK882FwnLxa46CTbCm1RqgzdAjx/Pbrc1utEN0sJtl8xgZomNS8zjKO5hFc3w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mucse.com; spf=pass smtp.mailfrom=mucse.com; arc=none smtp.remote-ip=54.243.244.52 X-Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB817606A322; Thu, 3 Dec 2026 05:52:07 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CB817606A322 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mucse.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mucse.com X-QQ-mid: zesmtpgz5t1796277057t340b18b0 X-QQ-Originating-IP: mC/2Jp7qsgPDSc0KJqw+2mJLZd5rKEa/hbMMg6eXoDI= X-Received: from localhost ( [203.174.112.180]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 03 Dec 2026 13:50:55 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 2418263113051722510 X-EX-QQ-RecipientCnt: 11 X-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 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <willemb.1db2b1b74ff94@google.com> X-QQ-SENDSIZE: 520 X-Feedback-ID: zesmtpgz:mucse.com:qybglogicsvrgz:qybglogicsvrgz3a-1 X-QQ-XMAILINFO: M8wyAK0xhE1uXGZVn9YJPIwbBkp15Gd0LmfCJpEzlmfATfJejPacARWX aQITzSmjoin8WLLa7jlqZZNuFnvi0izB6VZkgAZ63MHrxbV5lP5rur3gXvBZ6QB+mvfSB8C MX2SQLAYU+XQdDocTLrhbFHvjZBkGLoQ3iOh6t67CDNxIkaToNnQPma7v3SrktdCp9BTei6 f5K0yO8ivVj98mVF7y1JVILzg9KRcH/bvVRrUrlzAtC+v6n3oUd+I/A9F/n4XW/YSSwg0Uu +4wo1fm+/F3yoPH98mwFQIZvxgo51FtNouEiONykWG9Wme3TQPSBdmo/of3XiE/Pgtv7g5q GdcVX+avSdMEhde2Slj84xcx+zPa/Bgq7PtMqy+say+zsKPDcXUhJ6enKHpEwxxzKBV+uuJ CwDfA2DGoI05pSWj6t4CjdC5N/1/KmHpLyKhuFNQCrDX7SCL1Q2zLQGxqby8rmzr8YkTxwf uB2N8AMchgQ7hRqXkb1I1znWsLhiNZ7dmNQDcGMKqaedPrs07Xi1SgnT65Hb1Hr2Czu08k4 TzDUuEEPowrGFcnb9SP+w8aDpkBILhu/WgddNKwVxhci0QU14nqID9HwnSGwe4WJRncaY3d m52JEnsXvlKDrstYX4I4ZgZM67GEEPICsM4qjkvy6lJM+oG5dCBK65MWyBhuOvKg4uNXpx8 ll1/ipfX631IcCv1E3MOIWLAMSHFMEYOT7rmWEcYypOB+0ABYfnaSbE4YEXOjtXxqEKyLkE H1AX09u+eizqCOfPR4Hne7Yme+32xBSSu3aGv4FckOJ4S+2elBgqdRFIMXCQyNZuyv4XxFa qZyNmdyLf2w7r0RLYL+LC4bsBZgmGZcxQgfA6L4fe7zPacCWlfpodHL+4IrTkLlF7Iy6ECI z1U6PjzK+FprKltwYxXMz81b43zdV8dPke22RZ1tuQjNoKd5UWq7aLTfvD4rJvGipVXN+TA jnm2m/gABcru6Stly/YEZgcuaycy6NAgy3GdpVvfJd5PdhYHHY55BqA5/exyOn49Kgpidak YpW1QHfjGzbEqyTYJ7nz7ugR/pxM8QCq09jLK9Mfx8J4ETJaUo1BwAsfkj7B1h6MCjh/8yy A== X-QQ-XMRINFO: NS+P29fieYNwqS3WCnRCOn9D1NpZuCnCRA== X-QQ-RECHKSPAM: 0