virtio_net: Account for tx bytes and packets on sending xdp_frames
Previously virtnet_xdp_xmit() did not account for device tx counters, which caused confusions. To be consistent with SKBs, account them on freeing xdp_frames. Reported-by: David Ahern <dsahern@gmail.com> Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
cfe4bd7a25
commit
546f28974d
@ -503,6 +503,8 @@ static int virtnet_xdp_xmit(struct net_device *dev,
|
|||||||
struct bpf_prog *xdp_prog;
|
struct bpf_prog *xdp_prog;
|
||||||
struct send_queue *sq;
|
struct send_queue *sq;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
|
int packets = 0;
|
||||||
|
int bytes = 0;
|
||||||
int drops = 0;
|
int drops = 0;
|
||||||
int kicks = 0;
|
int kicks = 0;
|
||||||
int ret, err;
|
int ret, err;
|
||||||
@ -526,10 +528,18 @@ static int virtnet_xdp_xmit(struct net_device *dev,
|
|||||||
|
|
||||||
/* Free up any pending old buffers before queueing new ones. */
|
/* Free up any pending old buffers before queueing new ones. */
|
||||||
while ((ptr = virtqueue_get_buf(sq->vq, &len)) != NULL) {
|
while ((ptr = virtqueue_get_buf(sq->vq, &len)) != NULL) {
|
||||||
if (likely(is_xdp_frame(ptr)))
|
if (likely(is_xdp_frame(ptr))) {
|
||||||
xdp_return_frame(ptr_to_xdp(ptr));
|
struct xdp_frame *frame = ptr_to_xdp(ptr);
|
||||||
else
|
|
||||||
napi_consume_skb(ptr, false);
|
bytes += frame->len;
|
||||||
|
xdp_return_frame(frame);
|
||||||
|
} else {
|
||||||
|
struct sk_buff *skb = ptr;
|
||||||
|
|
||||||
|
bytes += skb->len;
|
||||||
|
napi_consume_skb(skb, false);
|
||||||
|
}
|
||||||
|
packets++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
@ -549,6 +559,8 @@ static int virtnet_xdp_xmit(struct net_device *dev,
|
|||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
u64_stats_update_begin(&sq->stats.syncp);
|
u64_stats_update_begin(&sq->stats.syncp);
|
||||||
|
sq->stats.bytes += bytes;
|
||||||
|
sq->stats.packets += packets;
|
||||||
sq->stats.xdp_tx += n;
|
sq->stats.xdp_tx += n;
|
||||||
sq->stats.xdp_tx_drops += drops;
|
sq->stats.xdp_tx_drops += drops;
|
||||||
sq->stats.kicks += kicks;
|
sq->stats.kicks += kicks;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user