Jesper Dangaard Brouer
2019-Feb-06 13:48 UTC
[PATCH net] virtio_net: Account for tx bytes and packets on sending xdp_frames
On Wed, 6 Feb 2019 00:06:33 +0000 Saeed Mahameed <saeedm at mellanox.com> wrote:> 3) Unrelated, In non XDP case, if skb allocation fails or driver fails > to pass the skb up to the stack for somereason, should the driver > increase rx packets ? IMHO the answer should be yes if we want to have > similar behavior between XDP and non XDP cases.I don't think "skb allocation fails" should increase rx packets counter. The difference is that these events are outside sysadm/users control, and is an error detected inside the driver. The XDP program takes a policy choice to XDP_DROP a packet, which can be accounted inside the XDP prog (as the samples show) or as we also discuss via a more generic XDP-action counters. That said, I took at quick look at driver code, and it seems this behavior differs per driver... ixgbe and mlx5 does not count "skb allocation fails" as RX-ed packets, while mlx4 seems to count them.> But this could result in netdev->stats.rx_packets + > netdev->stats.rx_dropped to be more than the actual rx-ed packets, is > this acceptable ?This is one reasons I think this is wrong. --Jesper
Jakub Kicinski
2019-Feb-06 15:52 UTC
[PATCH net] virtio_net: Account for tx bytes and packets on sending xdp_frames
On Wed, 6 Feb 2019 14:48:14 +0100, Jesper Dangaard Brouer wrote:> On Wed, 6 Feb 2019 00:06:33 +0000 > Saeed Mahameed <saeedm at mellanox.com> wrote: > > > 3) Unrelated, In non XDP case, if skb allocation fails or driver fails > > to pass the skb up to the stack for somereason, should the driver > > increase rx packets ? IMHO the answer should be yes if we want to have > > similar behavior between XDP and non XDP cases. > > I don't think "skb allocation fails" should increase rx packets > counter. The difference is that these events are outside sysadm/users > control, and is an error detected inside the driver. The XDP program > takes a policy choice to XDP_DROP a packet, which can be accounted > inside the XDP prog (as the samples show) or as we also discuss via a > more generic XDP-action counters.FWIW that's my understanding as well. My understanding of Linux stats is that they are incrementing one counter per packet. I.e. in RX direction success packets are those given to the stack, and for TX those given to the hardware. Standards (IETF/IEEE) usually count stats on the same layer boundary, but I think software generally counts when it's done with the packet. I haven't seen it documented anywhere, yet. I have tried to document it in the docs of the recent RFC: https://patchwork.ozlabs.org/patch/1032332/ Incidentally XDP_DROP may have been better named XDP_DISCARD from stats perspective ;)
Seemingly Similar Threads
- Resource management for ndo_xdp_xmit (Was: [PATCH net] virtio_net: Account for tx bytes and packets on sending xdp_frames)
- [PATCH net] virtio_net: Account for tx bytes and packets on sending xdp_frames
- Resource management for ndo_xdp_xmit (Was: [PATCH net] virtio_net: Account for tx bytes and packets on sending xdp_frames)
- [PATCH v2 -next] vdpa: mlx5: change Kconfig depends to fix build errors
- [PATCH net] virtio_net: Account for tx bytes and packets on sending xdp_frames