* [PATCH net] net: fec: correct rx_bytes statistic for the case SHIFT16 is set
@ 2025-11-06 2:14 Wei Fang
2025-11-06 16:19 ` Frank Li
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wei Fang @ 2025-11-06 2:14 UTC (permalink / raw)
To: shenwei.wang, xiaoning.wang, andrew+netdev, davem, edumazet, kuba,
pabeni, eric
Cc: imx, netdev, linux-kernel
Two additional bytes in front of each frame received into the RX FIFO if
SHIFT16 is set, so we need to subtract the extra two bytes from pkt_len
to correct the statistic of rx_bytes.
Fixes: 3ac72b7b63d5 ("net: fec: align IP header in hardware")
Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
drivers/net/ethernet/freescale/fec_main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 1edcfaee6819..3222359ac15b 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1835,6 +1835,8 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
ndev->stats.rx_packets++;
pkt_len = fec16_to_cpu(bdp->cbd_datlen);
ndev->stats.rx_bytes += pkt_len;
+ if (fep->quirks & FEC_QUIRK_HAS_RACC)
+ ndev->stats.rx_bytes -= 2;
index = fec_enet_get_bd_index(bdp, &rxq->bd);
page = rxq->rx_skb_info[index].page;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: fec: correct rx_bytes statistic for the case SHIFT16 is set
2025-11-06 2:14 [PATCH net] net: fec: correct rx_bytes statistic for the case SHIFT16 is set Wei Fang
@ 2025-11-06 16:19 ` Frank Li
2025-11-08 2:59 ` Jakub Kicinski
2025-11-08 3:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2025-11-06 16:19 UTC (permalink / raw)
To: Wei Fang
Cc: shenwei.wang, xiaoning.wang, andrew+netdev, davem, edumazet, kuba,
pabeni, eric, imx, netdev, linux-kernel
On Thu, Nov 06, 2025 at 10:14:21AM +0800, Wei Fang wrote:
> Two additional bytes in front of each frame received into the RX FIFO if
> SHIFT16 is set, so we need to subtract the extra two bytes from pkt_len
> to correct the statistic of rx_bytes.
>
> Fixes: 3ac72b7b63d5 ("net: fec: align IP header in hardware")
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/net/ethernet/freescale/fec_main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 1edcfaee6819..3222359ac15b 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1835,6 +1835,8 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
> ndev->stats.rx_packets++;
> pkt_len = fec16_to_cpu(bdp->cbd_datlen);
> ndev->stats.rx_bytes += pkt_len;
> + if (fep->quirks & FEC_QUIRK_HAS_RACC)
> + ndev->stats.rx_bytes -= 2;
>
> index = fec_enet_get_bd_index(bdp, &rxq->bd);
> page = rxq->rx_skb_info[index].page;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: fec: correct rx_bytes statistic for the case SHIFT16 is set
2025-11-06 2:14 [PATCH net] net: fec: correct rx_bytes statistic for the case SHIFT16 is set Wei Fang
2025-11-06 16:19 ` Frank Li
@ 2025-11-08 2:59 ` Jakub Kicinski
2025-11-10 6:51 ` Wei Fang
2025-11-08 3:00 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2025-11-08 2:59 UTC (permalink / raw)
To: Wei Fang
Cc: shenwei.wang, xiaoning.wang, andrew+netdev, davem, edumazet,
pabeni, eric, imx, netdev, linux-kernel
On Thu, 6 Nov 2025 10:14:21 +0800 Wei Fang wrote:
> ndev->stats.rx_bytes += pkt_len;
> + if (fep->quirks & FEC_QUIRK_HAS_RACC)
> + ndev->stats.rx_bytes -= 2;
Orthogonal to this patch, but why not:
ndev->stats.rx_bytes += pkt_len - sub_len;
? Is this driver intentionally counting FCS as bytes?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: fec: correct rx_bytes statistic for the case SHIFT16 is set
2025-11-06 2:14 [PATCH net] net: fec: correct rx_bytes statistic for the case SHIFT16 is set Wei Fang
2025-11-06 16:19 ` Frank Li
2025-11-08 2:59 ` Jakub Kicinski
@ 2025-11-08 3:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-08 3:00 UTC (permalink / raw)
To: Wei Fang
Cc: shenwei.wang, xiaoning.wang, andrew+netdev, davem, edumazet, kuba,
pabeni, eric, imx, netdev, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 6 Nov 2025 10:14:21 +0800 you wrote:
> Two additional bytes in front of each frame received into the RX FIFO if
> SHIFT16 is set, so we need to subtract the extra two bytes from pkt_len
> to correct the statistic of rx_bytes.
>
> Fixes: 3ac72b7b63d5 ("net: fec: align IP header in hardware")
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
>
> [...]
Here is the summary with links:
- [net] net: fec: correct rx_bytes statistic for the case SHIFT16 is set
https://git.kernel.org/netdev/net/c/ad17e7e92a7c
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] 5+ messages in thread
* RE: [PATCH net] net: fec: correct rx_bytes statistic for the case SHIFT16 is set
2025-11-08 2:59 ` Jakub Kicinski
@ 2025-11-10 6:51 ` Wei Fang
0 siblings, 0 replies; 5+ messages in thread
From: Wei Fang @ 2025-11-10 6:51 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Shenwei Wang, Clark Wang, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
eric@nelint.com, imx@lists.linux.dev, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
> Subject: Re: [PATCH net] net: fec: correct rx_bytes statistic for the case SHIFT16
> is set
>
> On Thu, 6 Nov 2025 10:14:21 +0800 Wei Fang wrote:
> > ndev->stats.rx_bytes += pkt_len;
> > + if (fep->quirks & FEC_QUIRK_HAS_RACC)
> > + ndev->stats.rx_bytes -= 2;
>
> Orthogonal to this patch, but why not:
>
> ndev->stats.rx_bytes += pkt_len - sub_len;
>
> ? Is this driver intentionally counting FCS as bytes?
Yes, the FEC hardware does not remove the FCS from the frame, so the
frame received by the driver contains the FCS and will be included in the
statistics.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-10 6:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-06 2:14 [PATCH net] net: fec: correct rx_bytes statistic for the case SHIFT16 is set Wei Fang
2025-11-06 16:19 ` Frank Li
2025-11-08 2:59 ` Jakub Kicinski
2025-11-10 6:51 ` Wei Fang
2025-11-08 3:00 ` 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;
as well as URLs for NNTP newsgroup(s).