[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1712746219.1494555-1-xuanzhuo@linux.alibaba.com>
Date: Wed, 10 Apr 2024 18:50:19 +0800
From: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
To: Jason Wang <jasowang@...hat.com>
Cc: netdev@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
Stanislav Fomichev <sdf@...gle.com>,
Amritha Nambiar <amritha.nambiar@...el.com>,
Larysa Zaremba <larysa.zaremba@...el.com>,
Sridhar Samudrala <sridhar.samudrala@...el.com>,
Maciej Fijalkowski <maciej.fijalkowski@...el.com>,
virtualization@...ts.linux.dev,
bpf@...r.kernel.org
Subject: Re: [PATCH net-next v5 2/9] virtio_net: virtnet_send_command supports command-specific-result
On Wed, 10 Apr 2024 14:09:11 +0800, Jason Wang <jasowang@...hat.com> wrote:
> On Mon, Mar 18, 2024 at 7:06 PM Xuan Zhuo <xuanzhuo@...ux.alibaba.com> wrote:
> >
> > As the spec https://github.com/oasis-tcs/virtio-spec/commit/42f389989823039724f95bbbd243291ab0064f82
> >
> > The virtnet cvq supports to get result from the device.
> >
> > Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
> > ---
> > drivers/net/virtio_net.c | 47 +++++++++++++++++++++++-----------------
> > 1 file changed, 27 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index d7ce4a1011ea..af512d85cd5b 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -2512,10 +2512,11 @@ static int virtnet_tx_resize(struct virtnet_info *vi,
> > * never fail unless improperly formatted.
> > */
> > static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
> > - struct scatterlist *out)
> > + struct scatterlist *out,
> > + struct scatterlist *in)
> > {
> > - struct scatterlist *sgs[4], hdr, stat;
> > - unsigned out_num = 0, tmp;
> > + struct scatterlist *sgs[5], hdr, stat;
> > + u32 out_num = 0, tmp, in_num = 0;
> > int ret;
> >
> > /* Caller should know better */
> > @@ -2533,10 +2534,13 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
> >
> > /* Add return status. */
> > sg_init_one(&stat, &vi->ctrl->status, sizeof(vi->ctrl->status));
> > - sgs[out_num] = &stat;
> > + sgs[out_num + in_num++] = &stat;
> >
> > - BUG_ON(out_num + 1 > ARRAY_SIZE(sgs));
> > - ret = virtqueue_add_sgs(vi->cvq, sgs, out_num, 1, vi, GFP_ATOMIC);
> > + if (in)
> > + sgs[out_num + in_num++] = in;
> > +
> > + BUG_ON(out_num + in_num > ARRAY_SIZE(sgs));
> > + ret = virtqueue_add_sgs(vi->cvq, sgs, out_num, in_num, vi, GFP_ATOMIC);
> > if (ret < 0) {
> > dev_warn(&vi->vdev->dev,
> > "Failed to add sgs for command vq: %d\n.", ret);
> > @@ -2578,7 +2582,8 @@ static int virtnet_set_mac_address(struct net_device *dev, void *p)
> > if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR)) {
> > sg_init_one(&sg, addr->sa_data, dev->addr_len);
> > if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MAC,
> > - VIRTIO_NET_CTRL_MAC_ADDR_SET, &sg)) {
> > + VIRTIO_NET_CTRL_MAC_ADDR_SET,
> > + &sg, NULL)) {
> > dev_warn(&vdev->dev,
> > "Failed to set mac address by vq command.\n");
> > ret = -EINVAL;
> > @@ -2647,7 +2652,7 @@ static void virtnet_ack_link_announce(struct virtnet_info *vi)
> > {
> > rtnl_lock();
> > if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_ANNOUNCE,
> > - VIRTIO_NET_CTRL_ANNOUNCE_ACK, NULL))
> > + VIRTIO_NET_CTRL_ANNOUNCE_ACK, NULL, NULL))
>
> Nit: It might be better to introduce a virtnet_send_command_reply()
> and let virtnet_send_command() call it as in=NULL to simplify the
> changes.
OK.
Thanks.
>
> Others look good.
>
> Thanks
>
Powered by blists - more mailing lists