]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
virtio_net: ensure netdev_tx_reset_queue is called on tx ring resize
authorKoichiro Den <koichiro.den@canonical.com>
Fri, 6 Dec 2024 01:10:45 +0000 (10:10 +0900)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 10 Dec 2024 10:22:21 +0000 (11:22 +0100)
virtnet_tx_resize() flushes remaining tx skbs, requiring DQL counters to
be reset when flushing has actually occurred. Add
virtnet_sq_free_unused_buf_done() as a callback for virtqueue_reset() to
handle this.

Fixes: c8bd1f7f3e61 ("virtio_net: add support for Byte Queue Limits")
Cc: <stable@vger.kernel.org> # v6.11+
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/virtio_net.c

index e10bc9e6b0722cf1ea41b2eaf4d665ce04174902..3a0341cc60854654f6ea2ca7f08f49f65c41c8df 100644 (file)
@@ -503,6 +503,7 @@ struct virtio_net_common_hdr {
 static struct virtio_net_common_hdr xsk_hdr;
 
 static void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf);
+static void virtnet_sq_free_unused_buf_done(struct virtqueue *vq);
 static int virtnet_xdp_handler(struct bpf_prog *xdp_prog, struct xdp_buff *xdp,
                               struct net_device *dev,
                               unsigned int *xdp_xmit,
@@ -3394,7 +3395,8 @@ static int virtnet_tx_resize(struct virtnet_info *vi, struct send_queue *sq,
 
        virtnet_tx_pause(vi, sq);
 
-       err = virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf, NULL);
+       err = virtqueue_resize(sq->vq, ring_num, virtnet_sq_free_unused_buf,
+                              virtnet_sq_free_unused_buf_done);
        if (err)
                netdev_err(vi->dev, "resize tx fail: tx queue index: %d err: %d\n", qindex, err);
 
@@ -6233,6 +6235,14 @@ static void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf)
        }
 }
 
+static void virtnet_sq_free_unused_buf_done(struct virtqueue *vq)
+{
+       struct virtnet_info *vi = vq->vdev->priv;
+       int i = vq2txq(vq);
+
+       netdev_tx_reset_queue(netdev_get_tx_queue(vi->dev, i));
+}
+
 static void free_unused_bufs(struct virtnet_info *vi)
 {
        void *buf;