Skip to content

Commit

Permalink
virtio_net: ensure netdev_tx_reset_queue is called on tx ring resize
Browse files Browse the repository at this point in the history
commit 1480f0f upstream.

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: c8bd1f7 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
lkpdn authored and gregkh committed Dec 19, 2024
1 parent 098b982 commit edd7766
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ struct virtio_net_common_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,
Expand Down Expand Up @@ -3228,7 +3229,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);

Expand Down Expand Up @@ -5996,6 +5998,14 @@ static void virtnet_sq_free_unused_buf(struct virtqueue *vq, void *buf)
xdp_return_frame(ptr_to_xdp(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;
Expand Down

0 comments on commit edd7766

Please sign in to comment.