Re: [PATCH net-next v5 2/9] virtio_net: virtnet_send_command supports command-specific-result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 10 Apr 2024 14:09:11 +0800, Jason Wang <jasowang@xxxxxxxxxx> wrote:
> On Mon, Mar 18, 2024 at 7:06 PM Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxx>
> > ---
> >  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
>





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux