Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: stmmac: count XDP_PASS frames in rx_packets on the XSK zero-copy path
@ 2026-11-06  6:12 Anandu Padinhare
  2026-11-06  8:45 ` Lorenzo Bianconi
  2026-11-11  1:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Anandu Padinhare @ 2026-11-06  6:12 UTC (permalink / raw)
  To: maxime.chevallier@bootlin.com, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev@vger.kernel.org, Jisheng Zhang, Maxime Coquelin,
	Alexandre Torgue

In the AF_XDP zero-copy RX path, frames that the XDP program passes to
the stack are handed over by stmmac_dispatch_skb_zc(). That function
increments rx_pkt_n instead of rx_packets since
commit 133466c3bbe1 ("net: stmmac: use per-queue 64 bit statistics where necessary").

stmmac_rx_zc() already adds every processed frame to rx_pkt_n, so each
XDP_PASS frame is counted twice there, and rx_packets, which
ndo_get_stats64() reports, never counts them: on a zero-copy queue
rx_bytes grows with the passed frames while rx_packets stays still.

Count the frame in rx_packets, as the regular RX path and the code
before that commit did.

Found while testing AF_XDP zero-copy on an ADSP-SC598 (adi-dwmac,
100 Mbit/s link): rx_pkt_n grew almost twice as fast as the frames the
MAC delivered, while "ip -s link" counted almost none.

Tested on that board with a 6.18-based kernel, whose zero-copy RX
accounting matches net. An AF_XDP zero-copy socket on queue 0 received
frames of one EtherType while UDP traffic was passed to the stack. In a
run with 60 s of traffic before the change, rx_pkt_n was 1.88 times the
frames that reached the driver (MAC frames minus RX FIFO overflows) and
"ip -s link" counted 55 RX packets. In the same test with the change,
rx_pkt_n equals the frames that reached the driver and rx_packets equals
the frames passed to the stack.

Fixes: 133466c3bbe1 ("net: stmmac: use per-queue 64 bit statistics where necessary")
Signed-off-by: Anandu Padinhare <Anandu.Padinhare@electrifex.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a2177777727e..f8dceafdda2d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5587,7 +5587,7 @@ static void stmmac_dispatch_skb_zc(struct stmmac_priv *priv, u32 queue,
 	napi_gro_receive(&ch->rxtx_napi, skb);
 
 	u64_stats_update_begin(&rxq_stats->napi_syncp);
-	u64_stats_inc(&rxq_stats->napi.rx_pkt_n);
+	u64_stats_inc(&rxq_stats->napi.rx_packets);
 	u64_stats_add(&rxq_stats->napi.rx_bytes, len);
 	u64_stats_update_end(&rxq_stats->napi_syncp);
 }

base-commit: f66469d9905b39d2c260a15d7d6db450f4db67c1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: stmmac: count XDP_PASS frames in rx_packets on the XSK zero-copy path
  2026-11-06  6:12 [PATCH net] net: stmmac: count XDP_PASS frames in rx_packets on the XSK zero-copy path Anandu Padinhare
@ 2026-11-06  8:45 ` Lorenzo Bianconi
  2026-11-11  1:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2026-11-06  8:45 UTC (permalink / raw)
  To: Anandu Padinhare
  Cc: maxime.chevallier@bootlin.com, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev@vger.kernel.org,
	Jisheng Zhang, Maxime Coquelin, Alexandre Torgue

[-- Attachment #1: Type: text/plain, Size: 2533 bytes --]

> In the AF_XDP zero-copy RX path, frames that the XDP program passes to
> the stack are handed over by stmmac_dispatch_skb_zc(). That function
> increments rx_pkt_n instead of rx_packets since
> commit 133466c3bbe1 ("net: stmmac: use per-queue 64 bit statistics where necessary").
> 
> stmmac_rx_zc() already adds every processed frame to rx_pkt_n, so each
> XDP_PASS frame is counted twice there, and rx_packets, which
> ndo_get_stats64() reports, never counts them: on a zero-copy queue
> rx_bytes grows with the passed frames while rx_packets stays still.
> 
> Count the frame in rx_packets, as the regular RX path and the code
> before that commit did.
> 
> Found while testing AF_XDP zero-copy on an ADSP-SC598 (adi-dwmac,
> 100 Mbit/s link): rx_pkt_n grew almost twice as fast as the frames the
> MAC delivered, while "ip -s link" counted almost none.
> 
> Tested on that board with a 6.18-based kernel, whose zero-copy RX
> accounting matches net. An AF_XDP zero-copy socket on queue 0 received
> frames of one EtherType while UDP traffic was passed to the stack. In a
> run with 60 s of traffic before the change, rx_pkt_n was 1.88 times the
> frames that reached the driver (MAC frames minus RX FIFO overflows) and
> "ip -s link" counted 55 RX packets. In the same test with the change,
> rx_pkt_n equals the frames that reached the driver and rx_packets equals
> the frames passed to the stack.
> 
> Fixes: 133466c3bbe1 ("net: stmmac: use per-queue 64 bit statistics where necessary")
> Signed-off-by: Anandu Padinhare <Anandu.Padinhare@electrifex.com>

Reviewed-by: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>

> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index a2177777727e..f8dceafdda2d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -5587,7 +5587,7 @@ static void stmmac_dispatch_skb_zc(struct stmmac_priv *priv, u32 queue,
>  	napi_gro_receive(&ch->rxtx_napi, skb);
>  
>  	u64_stats_update_begin(&rxq_stats->napi_syncp);
> -	u64_stats_inc(&rxq_stats->napi.rx_pkt_n);
> +	u64_stats_inc(&rxq_stats->napi.rx_packets);
>  	u64_stats_add(&rxq_stats->napi.rx_bytes, len);
>  	u64_stats_update_end(&rxq_stats->napi_syncp);
>  }
> 
> base-commit: f66469d9905b39d2c260a15d7d6db450f4db67c1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: stmmac: count XDP_PASS frames in rx_packets on the XSK zero-copy path
  2026-11-06  6:12 [PATCH net] net: stmmac: count XDP_PASS frames in rx_packets on the XSK zero-copy path Anandu Padinhare
  2026-11-06  8:45 ` Lorenzo Bianconi
@ 2026-11-11  1:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-11  1:10 UTC (permalink / raw)
  To: Anandu Padinhare
  Cc: maxime.chevallier, andrew+netdev, davem, edumazet, kuba, pabeni,
	netdev, jszhang, mcoquelin.stm32, alexandre.torgue

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 6 Nov 2026 06:12:51 +0000 you wrote:
> In the AF_XDP zero-copy RX path, frames that the XDP program passes to
> the stack are handed over by stmmac_dispatch_skb_zc(). That function
> increments rx_pkt_n instead of rx_packets since
> commit 133466c3bbe1 ("net: stmmac: use per-queue 64 bit statistics where necessary").
> 
> stmmac_rx_zc() already adds every processed frame to rx_pkt_n, so each
> XDP_PASS frame is counted twice there, and rx_packets, which
> ndo_get_stats64() reports, never counts them: on a zero-copy queue
> rx_bytes grows with the passed frames while rx_packets stays still.
> 
> [...]

Here is the summary with links:
  - [net] net: stmmac: count XDP_PASS frames in rx_packets on the XSK zero-copy path
    https://git.kernel.org/netdev/net/c/070411c1590c

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-11  1:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06  6:12 [PATCH net] net: stmmac: count XDP_PASS frames in rx_packets on the XSK zero-copy path Anandu Padinhare
2026-11-06  8:45 ` Lorenzo Bianconi
2026-11-11  1:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox