Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: socionext: netsec: fix xdp stats accounting

Increment netdev rx counters even for XDP_DROP verdict. Report even
tx bytes for xdp buffers (TYPE_NETSEC_XDP_TX or TYPE_NETSEC_XDP_NDO).
Moreover account pending buffer length in netsec_xdp_queue_one as it is
done for skb counterpart

Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Lorenzo Bianconi and committed by
David S. Miller
0c5378f9 a8c41a68

+3 -2
+3 -2
drivers/net/ethernet/socionext/netsec.c
··· 252 252 #define NETSEC_XDP_CONSUMED BIT(0) 253 253 #define NETSEC_XDP_TX BIT(1) 254 254 #define NETSEC_XDP_REDIR BIT(2) 255 - #define NETSEC_XDP_RX_OK (NETSEC_XDP_PASS | NETSEC_XDP_TX | NETSEC_XDP_REDIR) 256 255 257 256 enum ring_id { 258 257 NETSEC_RING_TX = 0, ··· 660 661 bytes += desc->skb->len; 661 662 dev_kfree_skb(desc->skb); 662 663 } else { 664 + bytes += desc->xdpf->len; 663 665 xdp_return_frame(desc->xdpf); 664 666 } 665 667 next: ··· 858 858 tx_desc.addr = xdpf->data; 859 859 tx_desc.len = xdpf->len; 860 860 861 + netdev_sent_queue(priv->ndev, xdpf->len); 861 862 netsec_set_tx_de(priv, tx_ring, &tx_ctrl, &tx_desc, xdpf); 862 863 863 864 return NETSEC_XDP_TX; ··· 1031 1030 1032 1031 next: 1033 1032 if ((skb && napi_gro_receive(&priv->napi, skb) != GRO_DROP) || 1034 - xdp_result & NETSEC_XDP_RX_OK) { 1033 + xdp_result) { 1035 1034 ndev->stats.rx_packets++; 1036 1035 ndev->stats.rx_bytes += xdp.data_end - xdp.data; 1037 1036 }