Hi Chenbo,

Thanks for your efforts, my reply is inline.

> -----Original Message-----
> From: Xia, Chenbo <chenbo....@intel.com>
> Sent: Monday, October 17, 2022 2:34 PM
> To: Pei, Andy <andy....@intel.com>; dev@dpdk.org
> Cc: Xu, Rosen <rosen...@intel.com>; Huang, Wei <wei.hu...@intel.com>;
> Cao, Gang <gang....@intel.com>; maxime.coque...@redhat.com
> Subject: RE: [PATCH v4 7/8] vhost: vDPA blk device gets ready when any
> queue is ready
> 
> > -----Original Message-----
> > From: Pei, Andy <andy....@intel.com>
> > Sent: Thursday, October 13, 2022 4:45 PM
> > To: dev@dpdk.org
> > Cc: Xia, Chenbo <chenbo....@intel.com>; Xu, Rosen
> > <rosen...@intel.com>; Huang, Wei <wei.hu...@intel.com>; Cao, Gang
> > <gang....@intel.com>; maxime.coque...@redhat.com
> > Subject: [PATCH v4 7/8] vhost: vDPA blk device gets ready when any
> > queue is ready
> 
> This title does not match to the code. You mean first queue?
> 
Yes, I think I can make the title the first queue.
> >
> > When boot from virtio blk device, seabios in QEMU only enables one queue.
> > To work in this scenario, vDPA BLK device back-end configure device
> > when any queue is ready.
> >
> > Signed-off-by: Andy Pei <andy....@intel.com>
> > Signed-off-by: Huang Wei <wei.hu...@intel.com>
> > ---
> >  lib/vhost/vhost_user.c | 49
> > ++++++++++++++++++++++++++++++---------------
> > ----
> >  1 file changed, 30 insertions(+), 19 deletions(-)
> >
> > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index
> > cd65257..0509025 100644
> > --- a/lib/vhost/vhost_user.c
> > +++ b/lib/vhost/vhost_user.c
> > @@ -1441,9 +1441,10 @@
> >  }
> >
> >  #define VIRTIO_BUILTIN_NUM_VQS_TO_BE_READY 2u
> > +#define VIRTIO_BLK_NUM_VQS_TO_BE_READY 1u
> >
> >  static int
> > -virtio_is_ready(struct virtio_net *dev)
> > +virtio_is_ready(struct virtio_net *dev, uint32_t vdpa_type)
> 
> I agree with Maxime's v3 comment. We don't need a new parameter.
> 
OK, I will send a new version to fix this.
> Thanks,
> Chenbo
> 
> >  {
> >     struct vhost_virtqueue *vq;
> >     uint32_t i, nr_vring = dev->nr_vring; @@ -1454,13 +1455,16 @@
> >     if (!dev->nr_vring)
> >             return 0;
> >
> > -   if (dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET) {
> > -           nr_vring = VIRTIO_BUILTIN_NUM_VQS_TO_BE_READY;
> > -
> > -           if (dev->nr_vring < nr_vring)
> > -                   return 0;
> > +   if (vdpa_type == RTE_VHOST_VDPA_DEVICE_TYPE_BLK) {
> > +           nr_vring = VIRTIO_BLK_NUM_VQS_TO_BE_READY;
> > +   } else {
> > +           if (dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET)
> > +                   nr_vring =
> VIRTIO_BUILTIN_NUM_VQS_TO_BE_READY;
> >     }
> >
> > +   if (dev->nr_vring < nr_vring)
> > +           return 0;
> > +
> >     for (i = 0; i < nr_vring; i++) {
> >             vq = dev->virtqueue[i];
> >
> > @@ -2958,7 +2962,7 @@ static int is_vring_iotlb(struct virtio_net *dev,
> >     int ret;
> >     int unlock_required = 0;
> >     bool handled;
> > -   uint32_t vdpa_type = 0;
> > +   uint32_t vdpa_type = -1;
> >     uint32_t request;
> >     uint32_t i;
> >
> > @@ -3152,7 +3156,25 @@ static int is_vring_iotlb(struct virtio_net *dev,
> >     if (unlock_required)
> >             vhost_user_unlock_all_queue_pairs(dev);
> >
> > -   if (ret != 0 || !virtio_is_ready(dev))
> > +   if (ret != 0)
> > +           goto out;
> > +
> > +   vdpa_dev = dev->vdpa_dev;
> > +   if (vdpa_dev) {
> > +           if (vdpa_dev->ops->get_dev_type) {
> > +                   ret = vdpa_dev->ops->get_dev_type(vdpa_dev,
> &vdpa_type);
> > +                   if (ret) {
> > +                           VHOST_LOG_CONFIG(dev->ifname, ERR,
> > +                                   "failed to get vdpa dev type.\n");
> > +                           ret = -1;
> > +                           goto out;
> > +                   }
> > +           } else {
> > +                   vdpa_type = RTE_VHOST_VDPA_DEVICE_TYPE_NET;
> > +           }
> > +   }
> > +
> > +   if (!virtio_is_ready(dev, vdpa_type))
> >             goto out;
> >
> >     /*
> > @@ -3166,20 +3188,9 @@ static int is_vring_iotlb(struct virtio_net *dev,
> >                     dev->flags |= VIRTIO_DEV_RUNNING;
> >     }
> >
> > -   vdpa_dev = dev->vdpa_dev;
> >     if (!vdpa_dev)
> >             goto out;
> >
> > -   if (vdpa_dev->ops->get_dev_type) {
> > -           ret = vdpa_dev->ops->get_dev_type(vdpa_dev, &vdpa_type);
> > -           if (ret) {
> > -                   VHOST_LOG_CONFIG(dev->ifname, ERR, "failed to
> get vdpa
> > dev type.\n");
> > -                   ret = -1;
> > -                   goto out;
> > -           }
> > -   } else {
> > -           vdpa_type = RTE_VHOST_VDPA_DEVICE_TYPE_NET;
> > -   }
> >     if (vdpa_type == RTE_VHOST_VDPA_DEVICE_TYPE_BLK
> >             && request != VHOST_USER_SET_VRING_CALL)
> >             goto out;
> > --
> > 1.8.3.1

Reply via email to