[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <96d1fe97-2e8a-ae8a-a35f-bba2ce0f44b4@redhat.com>
Date: Wed, 13 Apr 2022 16:06:33 +0800
From: Jason Wang <jasowang@...hat.com>
To: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
virtualization@...ts.linux-foundation.org
Cc: Jeff Dike <jdike@...toit.com>, Richard Weinberger <richard@....at>,
Anton Ivanov <anton.ivanov@...bridgegreys.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Hans de Goede <hdegoede@...hat.com>,
Mark Gross <markgross@...nel.org>,
Vadim Pasternak <vadimp@...dia.com>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Mathieu Poirier <mathieu.poirier@...aro.org>,
Cornelia Huck <cohuck@...hat.com>,
Halil Pasic <pasic@...ux.ibm.com>,
Heiko Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
Johannes Berg <johannes.berg@...el.com>,
Vincent Whitchurch <vincent.whitchurch@...s.com>,
linux-um@...ts.infradead.org, netdev@...r.kernel.org,
platform-driver-x86@...r.kernel.org,
linux-remoteproc@...r.kernel.org, linux-s390@...r.kernel.org,
kvm@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH v9 32/32] virtio_net: support set_ringparam
在 2022/4/6 上午11:43, Xuan Zhuo 写道:
> Support set_ringparam based on virtio queue reset.
>
> Users can use ethtool -G eth0 <ring_num> to modify the ring size of
> virtio-net.
>
> Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
Acked-by: Jason Wang <jasowang@...hat.com>
(One thing that I see is that, when resize fails, the param reported via
get_ringparam might be wrong, this is a corner case but might worth to
fix in the future).
> ---
> drivers/net/virtio_net.c | 47 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index ba6859f305f7..37e4e27f1e4e 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -2264,6 +2264,52 @@ static void virtnet_get_ringparam(struct net_device *dev,
> ring->tx_pending = virtqueue_get_vring_size(vi->sq[0].vq);
> }
>
> +static int virtnet_set_ringparam(struct net_device *dev,
> + struct ethtool_ringparam *ring,
> + struct kernel_ethtool_ringparam *kernel_ring,
> + struct netlink_ext_ack *extack)
> +{
> + struct virtnet_info *vi = netdev_priv(dev);
> + u32 rx_pending, tx_pending;
> + struct receive_queue *rq;
> + struct send_queue *sq;
> + int i, err;
> +
> + if (ring->rx_mini_pending || ring->rx_jumbo_pending)
> + return -EINVAL;
> +
> + rx_pending = virtqueue_get_vring_size(vi->rq[0].vq);
> + tx_pending = virtqueue_get_vring_size(vi->sq[0].vq);
> +
> + if (ring->rx_pending == rx_pending &&
> + ring->tx_pending == tx_pending)
> + return 0;
> +
> + if (ring->rx_pending > virtqueue_get_vring_max_size(vi->rq[0].vq))
> + return -EINVAL;
> +
> + if (ring->tx_pending > virtqueue_get_vring_max_size(vi->sq[0].vq))
> + return -EINVAL;
> +
> + for (i = 0; i < vi->max_queue_pairs; i++) {
> + rq = vi->rq + i;
> + sq = vi->sq + i;
> +
> + if (ring->tx_pending != tx_pending) {
> + err = virtnet_tx_resize(vi, sq, ring->tx_pending);
> + if (err)
> + return err;
> + }
> +
> + if (ring->rx_pending != rx_pending) {
> + err = virtnet_rx_resize(vi, rq, ring->rx_pending);
> + if (err)
> + return err;
> + }
> + }
> +
> + return 0;
> +}
>
> static void virtnet_get_drvinfo(struct net_device *dev,
> struct ethtool_drvinfo *info)
> @@ -2497,6 +2543,7 @@ static const struct ethtool_ops virtnet_ethtool_ops = {
> .get_drvinfo = virtnet_get_drvinfo,
> .get_link = ethtool_op_get_link,
> .get_ringparam = virtnet_get_ringparam,
> + .set_ringparam = virtnet_set_ringparam,
> .get_strings = virtnet_get_strings,
> .get_sset_count = virtnet_get_sset_count,
> .get_ethtool_stats = virtnet_get_ethtool_stats,
Powered by blists - more mailing lists