Skip to content

Commit

Permalink
net: enetc: correct the statistics of rx bytes
Browse files Browse the repository at this point in the history
[ Upstream commit 7190d0f ]

The rx_bytes of struct net_device_stats should count the length of
ethernet frames excluding the FCS. However, there are two problems
with the rx_bytes statistics of the current enetc driver. one is
that the length of VLAN header is not counted if the VLAN extraction
feature is enabled. The other is that the length of L2 header is not
counted, because eth_type_trans() is invoked before updating rx_bytes
which will subtract the length of L2 header from skb->len.
BTW, the rx_bytes statistics of XDP path also have similar problem,
I will fix it in another patch.

Fixes: a800abd ("net: enetc: move skb creation into enetc_build_skb")
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Wei Fang authored and gregkh committed Jun 14, 2023
1 parent d3aea02 commit 5062df8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/net/ethernet/freescale/enetc/enetc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,13 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring,
if (!skb)
break;

rx_byte_cnt += skb->len;
/* When set, the outer VLAN header is extracted and reported
* in the receive buffer descriptor. So rx_byte_cnt should
* add the length of the extracted VLAN header.
*/
if (bd_status & ENETC_RXBD_FLAG_VLAN)
rx_byte_cnt += VLAN_HLEN;
rx_byte_cnt += skb->len + ETH_HLEN;
rx_frm_cnt++;

napi_gro_receive(napi, skb);
Expand Down

0 comments on commit 5062df8

Please sign in to comment.