Skip to content

Commit

Permalink
net: enetc: correct rx_bytes statistics of XDP
Browse files Browse the repository at this point in the history
[ Upstream commit fdebd85 ]

The rx_bytes statistics of XDP are always zero, because rx_byte_cnt
is not updated after it is initialized to 0. So fix it.

Fixes: d1b1510 ("net: enetc: add support for XDP_DROP and XDP_PASS")
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 b3fc768 commit a22c0a0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/net/ethernet/freescale/enetc/enetc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,14 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,
enetc_build_xdp_buff(rx_ring, bd_status, &rxbd, &i,
&cleaned_cnt, &xdp_buff);

/* 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 += xdp_get_buff_len(&xdp_buff);

xdp_act = bpf_prog_run_xdp(prog, &xdp_buff);

switch (xdp_act) {
Expand Down

0 comments on commit a22c0a0

Please sign in to comment.