[PATCH net-next v2 15/21] virtio_net: xsk: tx: virtnet_sq_free_unused_buf() check xsk buffer

Xuan Zhuo
Tue, 07 Nov 2023 03:12:21 -0000

virtnet_sq_free_unused_buf() check xsk buffer.

Signed-off-by: Xuan Zhuo <xuanzhuo at linux.alibaba.com>
Acked-by: Jason Wang <jasowang at redhat.com>
---
 drivers/net/virtio/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/main.c b/drivers/net/virtio/main.c
index 6a5e74c482f3..6210a6e37396 100644
--- a/drivers/net/virtio/main.c
+++ b/drivers/net/virtio/main.c
@@ -3919,16 +3919,18 @@ void virtnet_sq_free_unused_buf(struct virtqueue *vq,
void *buf)

 	sq = &vi->sq[i];

-	if (!virtnet_is_xdp_frame(buf)) {
+	if (virtnet_is_skb_ptr(buf)) {
 		if (sq->do_dma)
 			buf = virtnet_sq_unmap(sq, buf);

 		dev_kfree_skb(buf);
-	} else {
+	} else if (virtnet_is_xdp_frame(buf)) {
 		if (sq->do_dma)
 			buf = virtnet_sq_unmap(sq, buf);

 		xdp_return_frame(virtnet_ptr_to_xdp(buf));
+	} else {
+		xsk_tx_completed(sq->xsk.pool, 1);
 	}
 }

--
2.32.0.3.g01195cf9f