net: fec: correct rx_bytes statistic for the case SHIFT16 is set
Wei Fang
maintainerPATCH 1/1 net: fec: correct rx_bytes statistic for the case SHIFT16 is set
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.
--- drivers/net/ethernet/freescale/fec_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +2 -0
@@ -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;
Signature · 1 line
2.34.1
Quoted 6 lines · Wei Fang
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_lento correct the statistic ofrx_bytes.Fixes 3ac72b7b63d5 ("net: fec: align IP header in hardware")Signed-off-by Wei Fang <[email protected]>
Quoted 20 lines
--- drivers/net/ethernet/freescale/fec_main.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/ethernet/freescale/fec_main.c +2
-1@@ -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
Jakub Kicinski
maintainerdrivers/net/ethernet/freescale/fec_main.c fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget) · line 1839
Quoted 3 lines · On Thu, 6 Nov 2025 10:14:21 +0800 Wei Fang wrote:
drivers/net/ethernet/freescale/fec_main.c +2
-0ndev->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?
Wei Fang
maintainerQuoted 10 lines
Subject: Re: [PATCH net] net: fec: correct
rx_bytesstatistic for the case SHIFT16 is setdrivers/net/ethernet/freescale/fec_main.c fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget) · line 1839
Quoted 3 lines · On Thu, 6 Nov 2025 10:14:21 +0800 Wei Fang wrote:
drivers/net/ethernet/freescale/fec_main.c +2
-0ndev->stats.rx_bytes += pkt_len; +if (fep->quirks &FEC_QUIRK_HAS_RACC ) + ndev->stats.rx_bytes -=2 ;Orthogonal to this patch, but why not:
Quoted 3 lines
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.
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · 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_lento correct the statistic ofrx_bytes.Fixes 3ac72b7b63d5 ("net: fec: align IP header in hardware")Signed-off-by Wei Fang <[email protected]>[...]
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html