mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wu Zongyong <wuzongyong@linux.alibaba.com>
To: Jason Wang <jasowang@redhat.com>
Cc: virtualization <virtualization@lists.linux-foundation.org>,
	linux-kernel <linux-kernel@vger.kernel.org>, mst <mst@redhat.com>,
	wei.yang1@linux.alibaba.com
Subject: Re: [PATCH 5/6] vdpa: add get_vq_num_unchangeable callback in vdpa_config_ops
Date: Thu, 9 Sep 2021 17:57:26 +0800	[thread overview]
Message-ID: <20210909095726.GA17469@L-PF27918B-1352.localdomain> (raw)
In-Reply-To: <CACGkMEsnp7-axbZWuB_w7ZkSWKa0Y+Ej-Kq0QSfO2-DNN=ShVA@mail.gmail.com>

On Thu, Sep 09, 2021 at 05:28:26PM +0800, Jason Wang wrote:
> On Thu, Sep 9, 2021 at 4:02 PM Wu Zongyong <wuzongyong@linux.alibaba.com> wrote:
> >
> > On Thu, Sep 09, 2021 at 10:55:03AM +0800, Jason Wang wrote:
> > > On Wed, Sep 8, 2021 at 8:23 PM Wu Zongyong <wuzongyong@linux.alibaba.com> wrote:
> > > >
> > > > This new callback is used to indicate whether the vring size can be
> > > > change or not. It is useful when we have a legacy virtio pci device as
> > > > the vdpa device for there is no way to negotiate the vring num by the
> > > > specification.
> > >
> > > So I'm not sure it's worth bothering. E.g what if we just fail
> > > VHOST_SET_VRING_NUM it the value doesn't match what hardware has?
> > >
> > > Thanks
> > >
> > I think we should not call VHOST_SET_VRING_NUM in that case.
> >
> > If the hardware reports that the virtqueue size cannot be changed, we
> > should call VHOST_GET_VRING_NUM to get the static virtqueue size
> > firstly, then allocate the same size memory for the virtqueues and write
> > the address to hardware finally.
> >
> > For QEMU, we will ignore the properties rx/tx_queue_size and just get it
> > from the hardware if this new callback return true.
> 
> This will break live migration. My understanding is that we can
> advertise those capability/limitation via the netlink management
> protocol then management layer can choose to use the correct queue
> size.
> 
> Thanks
I agree, it is a good idea.
BTW, can we also advertise mac address of network device? I found the
mac address generated by libvirt or qemu will break the network datapath
down if I don't specify the right mac explicitly in the XML or qemu
commandline. 
> 
> >
> > What do you think?
> > > >
> > > > Signed-off-by: Wu Zongyong <wuzongyong@linux.alibaba.com>
> > > > ---
> > > >  drivers/vhost/vdpa.c         | 19 +++++++++++++++++++
> > > >  drivers/virtio/virtio_vdpa.c |  5 ++++-
> > > >  include/linux/vdpa.h         |  4 ++++
> > > >  include/uapi/linux/vhost.h   |  2 ++
> > > >  4 files changed, 29 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> > > > index 9479f7f79217..2204d27d1e5d 100644
> > > > --- a/drivers/vhost/vdpa.c
> > > > +++ b/drivers/vhost/vdpa.c
> > > > @@ -350,6 +350,22 @@ static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp)
> > > >         return 0;
> > > >  }
> > > >
> > > > +static long vhost_vdpa_get_vring_num_unchangeable(struct vhost_vdpa *v,
> > > > +                                                 u32 __user *argp)
> > > > +{
> > > > +       struct vdpa_device *vdpa = v->vdpa;
> > > > +       const struct vdpa_config_ops *ops = vdpa->config;
> > > > +       bool unchangeable = false;
> > > > +
> > > > +       if (ops->get_vq_num_unchangeable)
> > > > +               unchangeable = ops->get_vq_num_unchangeable(vdpa);
> > > > +
> > > > +       if (copy_to_user(argp, &unchangeable, sizeof(unchangeable)))
> > > > +               return -EFAULT;
> > > > +
> > > > +       return 0;
> > > > +}
> > > > +
> > > >  static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
> > > >                                    void __user *argp)
> > > >  {
> > > > @@ -487,6 +503,9 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
> > > >         case VHOST_VDPA_GET_IOVA_RANGE:
> > > >                 r = vhost_vdpa_get_iova_range(v, argp);
> > > >                 break;
> > > > +       case VHOST_VDPA_GET_VRING_NUM_UNCHANGEABLE:
> > > > +               r = vhost_vdpa_get_vring_num_unchangeable(v, argp);
> > > > +               break;
> > > >         default:
> > > >                 r = vhost_dev_ioctl(&v->vdev, cmd, argp);
> > > >                 if (r == -ENOIOCTLCMD)
> > > > diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
> > > > index 72eaef2caeb1..afb47465307a 100644
> > > > --- a/drivers/virtio/virtio_vdpa.c
> > > > +++ b/drivers/virtio/virtio_vdpa.c
> > > > @@ -146,6 +146,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
> > > >         struct vdpa_vq_state state = {0};
> > > >         unsigned long flags;
> > > >         u32 align, num;
> > > > +       bool may_reduce_num = true;
> > > >         int err;
> > > >
> > > >         if (!name)
> > > > @@ -171,8 +172,10 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
> > > >
> > > >         /* Create the vring */
> > > >         align = ops->get_vq_align(vdpa);
> > > > +       if (ops->get_vq_num_unchangeable)
> > > > +               may_reduce_num = !ops->get_vq_num_unchangeable(vdpa);
> > > >         vq = vring_create_virtqueue(index, num, align, vdev,
> > > > -                                   true, true, ctx,
> > > > +                                   true, may_reduce_num, ctx,
> > > >                                     virtio_vdpa_notify, callback, name);
> > > >         if (!vq) {
> > > >                 err = -ENOMEM;
> > > > diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
> > > > index 35648c11e312..f809b7ada00d 100644
> > > > --- a/include/linux/vdpa.h
> > > > +++ b/include/linux/vdpa.h
> > > > @@ -195,6 +195,9 @@ struct vdpa_iova_range {
> > > >   *                             @vdev: vdpa device
> > > >   *                             Returns the iova range supported by
> > > >   *                             the device.
> > > > + * @get_vq_num_unchangeable    Check if size of virtqueue is unchangeable (optional)
> > > > + *                             @vdev: vdpa device
> > > > + *                             Returns boolean: unchangeable (true) or not (false)
> > > >   * @set_map:                   Set device memory mapping (optional)
> > > >   *                             Needed for device that using device
> > > >   *                             specific DMA translation (on-chip IOMMU)
> > > > @@ -262,6 +265,7 @@ struct vdpa_config_ops {
> > > >                            const void *buf, unsigned int len);
> > > >         u32 (*get_generation)(struct vdpa_device *vdev);
> > > >         struct vdpa_iova_range (*get_iova_range)(struct vdpa_device *vdev);
> > > > +       bool (*get_vq_num_unchangeable)(struct vdpa_device *vdev);
> > > >
> > > >         /* DMA ops */
> > > >         int (*set_map)(struct vdpa_device *vdev, struct vhost_iotlb *iotlb);
> > > > diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> > > > index c998860d7bbc..184f1f7f8498 100644
> > > > --- a/include/uapi/linux/vhost.h
> > > > +++ b/include/uapi/linux/vhost.h
> > > > @@ -150,4 +150,6 @@
> > > >  /* Get the valid iova range */
> > > >  #define VHOST_VDPA_GET_IOVA_RANGE      _IOR(VHOST_VIRTIO, 0x78, \
> > > >                                              struct vhost_vdpa_iova_range)
> > > > +/* Check if the vring size can be change */
> > > > +#define VHOST_VDPA_GET_VRING_NUM_UNCHANGEABLE _IOR(VHOST_VIRTIO, 0X79, bool)
> > > >  #endif
> > > > --
> > > > 2.31.1
> > > >
> >

  reply	other threads:[~2021-09-09  9:57 UTC|newest]

Thread overview: 151+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 12:20 [PATCH 0/6] vDPA driver for legacy virtio-pci device Wu Zongyong
2021-09-08 12:20 ` [PATCH 1/6] virtio-pci: introduce legacy device module Wu Zongyong
2021-09-08 12:20 ` [PATCH 2/6] vdpa: fix typo Wu Zongyong
2021-09-08 12:20 ` [PATCH 3/6] vp_vdpa: add vq irq offloading support Wu Zongyong
2021-09-09  2:53   ` Jason Wang
2021-09-08 12:20 ` [PATCH 4/6] vp_vdpa: split out reusable and device specific codes to separate file Wu Zongyong
2021-09-08 12:20 ` [PATCH 5/6] vdpa: add get_vq_num_unchangeable callback in vdpa_config_ops Wu Zongyong
2021-09-09  2:55   ` Jason Wang
2021-09-09  8:01     ` Wu Zongyong
2021-09-09  9:28       ` Jason Wang
2021-09-09  9:57         ` Wu Zongyong [this message]
2021-09-10  1:45           ` Jason Wang
2021-09-10  7:32             ` Wu Zongyong
2021-09-10  8:25               ` Cindy Lu
2021-09-10  9:20                 ` Wu Zongyong
2021-09-10 15:10                   ` Cindy Lu
2021-09-13  1:43                     ` Jason Wang
2021-09-13  2:59                       ` Wu Zongyong
2021-09-13  3:13                         ` Jason Wang
2021-09-13  6:22                           ` Cindy Lu
2021-09-09  9:18     ` Michael S. Tsirkin
2021-09-09  9:32       ` Jason Wang
2021-09-08 12:20 ` [PATCH 6/6] vp_vdpa: introduce legacy virtio pci driver Wu Zongyong
2021-09-09 13:57   ` Michael S. Tsirkin
2021-09-10  2:28     ` Wu Zongyong
2021-09-10  9:57       ` Michael S. Tsirkin
2021-09-10 10:01         ` Wu Zongyong
2021-10-22  9:37         ` Michael S. Tsirkin
2021-09-09  3:05 ` [PATCH 0/6] vDPA driver for legacy virtio-pci device Jason Wang
2021-09-09  3:20   ` Jason Wang
2021-09-09  8:12   ` Wu Zongyong
2021-09-09  9:29     ` Jason Wang
2021-09-09  9:21   ` Michael S. Tsirkin
2021-09-09  9:31     ` Jason Wang
2021-09-09 12:53   ` Wu Zongyong
2021-09-10  1:44     ` Jason Wang
2021-09-14 12:24 ` [PATCH v2 0/5] vDPA driver for Alibaba ENI Wu Zongyong
2021-09-14 12:24   ` Wu Zongyong
2021-09-14 12:24   ` [PATCH v2 1/5] virtio-pci: introduce legacy device module Wu Zongyong
2021-09-14 22:37     ` Randy Dunlap
2021-09-14 12:24   ` [PATCH v2 2/5] vdpa: fix typo Wu Zongyong
2021-09-15  3:15     ` Jason Wang
2021-09-14 12:24   ` [PATCH v2 3/5] vp_vdpa: add vq irq offloading support Wu Zongyong
2021-09-15  3:16     ` Jason Wang
2021-09-15  3:31       ` Wu Zongyong
2021-09-15  4:13         ` Jason Wang
2021-09-14 12:24   ` [PATCH v2 4/5] vdpa: add new vdpa attribute VDPA_ATTR_DEV_F_VERSION_1 Wu Zongyong
2021-09-14 12:58     ` Michael S. Tsirkin
2021-09-15  3:18       ` Jason Wang
2021-09-15  7:38         ` Michael S. Tsirkin
2021-09-15  8:06           ` Jason Wang
2021-09-15 11:08             ` Michael S. Tsirkin
2021-09-15 12:12               ` Wu Zongyong
2021-09-16  1:11                 ` Jason Wang
2021-09-16  1:05               ` Jason Wang
2021-09-17  2:34                 ` Wu Zongyong
2021-09-17  7:51                   ` Jason Wang
2021-09-15  3:24       ` Wu Zongyong
2021-09-15  7:30         ` Michael S. Tsirkin
2021-09-15  8:05           ` Jason Wang
2021-09-15 11:10             ` Michael S. Tsirkin
2021-09-14 12:24   ` [PATCH v2 5/5] eni_vdpa: add vDPA driver for Alibaba ENI Wu Zongyong
2021-09-14 22:35     ` Randy Dunlap
2021-09-15  3:14     ` Jason Wang
2021-09-15  3:47       ` Wu Zongyong
2021-09-15 13:36     ` kernel test robot
2021-09-22 12:46   ` [PATCH v3 0/7] " Wu Zongyong
2021-09-22 12:46     ` [PATCH v3 1/7] virtio-pci: introduce legacy device module Wu Zongyong
2021-09-22 12:46     ` [PATCH v3 2/7] vdpa: fix typo Wu Zongyong
2021-09-22 12:46     ` [PATCH v3 3/7] vp_vdpa: add vq irq offloading support Wu Zongyong
2021-09-22 12:46     ` [PATCH v3 4/7] vdpa: add new callback get_vq_num_min in vdpa_config_ops Wu Zongyong
2021-09-22 12:46     ` [PATCH v3 5/7] virtio_vdpa: setup correct vq size with callbacks get_vq_num_{max,min} Wu Zongyong
2021-09-22 12:46     ` [PATCH v3 6/7] vdpa: add new attribute VDPA_ATTR_DEV_MIN_VQ_SIZE Wu Zongyong
2021-09-22 12:46     ` [PATCH v3 7/7] eni_vdpa: add vDPA driver for Alibaba ENI Wu Zongyong
2021-09-26  2:24       ` Jason Wang
2021-09-26  3:24         ` Wu Zongyong
2021-09-26  4:18           ` Jason Wang
2021-09-27 10:36             ` Michael S. Tsirkin
2021-09-28  2:17               ` Jason Wang
2021-09-26  2:26       ` Jason Wang
2021-09-26  3:27         ` Wu Zongyong
2021-09-26  4:19           ` Jason Wang
2021-09-29 12:54       ` kernel test robot
2021-09-29  6:11     ` [PATCH v4 0/7] " Wu Zongyong
2021-09-29  6:11       ` [PATCH v4 1/7] virtio-pci: introduce legacy device module Wu Zongyong
2021-10-11  3:00         ` Jason Wang
2021-10-11  3:02         ` Jason Wang
2021-09-29  6:11       ` [PATCH v4 2/7] vdpa: fix typo Wu Zongyong
2021-10-11  3:03         ` Jason Wang
2021-09-29  6:11       ` [PATCH v4 3/7] vp_vdpa: add vq irq offloading support Wu Zongyong
2021-09-29  6:11       ` [PATCH v4 4/7] vdpa: add new callback get_vq_num_min in vdpa_config_ops Wu Zongyong
2021-10-11  3:04         ` Jason Wang
2021-09-29  6:11       ` [PATCH v4 5/7] virtio_vdpa: setup correct vq size with callbacks get_vq_num_{max,min} Wu Zongyong
2021-10-11  3:06         ` Jason Wang
2021-09-29  6:11       ` [PATCH v4 6/7] vdpa: add new attribute VDPA_ATTR_DEV_MIN_VQ_SIZE Wu Zongyong
2021-10-11  3:10         ` Jason Wang
2021-09-29  6:11       ` [PATCH v4 7/7] eni_vdpa: add vDPA driver for Alibaba ENI Wu Zongyong
2021-10-11  3:18         ` Jason Wang
2021-10-15  7:14       ` [PATCH v5 0/8] " Wu Zongyong
2021-10-15  7:14         ` [PATCH v5 1/8] virtio-pci: introduce legacy device module Wu Zongyong
2021-10-15  8:22           ` Jason Wang
2021-10-15  7:14         ` [PATCH v5 2/8] vdpa: fix typo Wu Zongyong
2021-10-15  7:14         ` [PATCH v5 3/8] vp_vdpa: add vq irq offloading support Wu Zongyong
2021-10-15  7:14         ` [PATCH v5 4/8] vdpa: add new callback get_vq_num_min in vdpa_config_ops Wu Zongyong
2021-10-15  8:22           ` Jason Wang
2021-10-15  7:14         ` [PATCH v5 5/8] vdpa: min vq num of vdpa device cannot be greater than max vq num Wu Zongyong
2021-10-15  8:24           ` Jason Wang
2021-10-15  7:14         ` [PATCH v5 6/8] virtio_vdpa: setup correct vq size with callbacks get_vq_num_{max,min} Wu Zongyong
2021-10-15  8:30           ` Jason Wang
2021-10-15  7:15         ` [PATCH v5 7/8] vdpa: add new attribute VDPA_ATTR_DEV_MIN_VQ_SIZE Wu Zongyong
2021-10-15  7:15         ` [PATCH v5 8/8] eni_vdpa: add vDPA driver for Alibaba ENI Wu Zongyong
2021-10-15  8:18           ` Jason Wang
2021-10-15 19:13           ` Randy Dunlap
2021-10-22  2:44         ` [PATCH v6 0/8] " Wu Zongyong
2021-10-22  2:44           ` [PATCH v6 1/8] virtio-pci: introduce legacy device module Wu Zongyong
2021-10-25  1:30             ` Jason Wang
2021-10-22  2:44           ` [PATCH v6 2/8] vdpa: fix typo Wu Zongyong
2021-10-22  2:44           ` [PATCH v6 3/8] vp_vdpa: add vq irq offloading support Wu Zongyong
2021-10-22  2:44           ` [PATCH v6 4/8] vdpa: add new callback get_vq_num_min in vdpa_config_ops Wu Zongyong
2021-10-25  2:17             ` Jason Wang
2021-10-22  2:44           ` [PATCH v6 5/8] vdpa: min vq num of vdpa device cannot be greater than max vq num Wu Zongyong
2021-10-25  2:18             ` Jason Wang
2021-10-22  2:44           ` [PATCH v6 6/8] virtio_vdpa: setup correct vq size with callbacks get_vq_num_{max,min} Wu Zongyong
2021-10-25  2:22             ` Jason Wang
     [not found]               ` <20211025024403.GA3684@L-PF27918B-1352.localdomain>
2021-10-25  4:45                 ` Jason Wang
     [not found]                   ` <20211025062454.GA4832@L-PF27918B-1352.localdomain>
2021-10-26  4:46                     ` Jason Wang
2021-10-22  2:44           ` [PATCH v6 7/8] vdpa: add new attribute VDPA_ATTR_DEV_MIN_VQ_SIZE Wu Zongyong
2021-10-25  2:23             ` Jason Wang
2021-10-22  2:44           ` [PATCH v6 8/8] eni_vdpa: add vDPA driver for Alibaba ENI Wu Zongyong
2021-10-25  2:27             ` Jason Wang
     [not found]               ` <20211025032146.GC3684@L-PF27918B-1352.localdomain>
2021-10-25  4:40                 ` Jason Wang
2021-10-27  2:47                   ` Wu Zongyong
2021-10-27  3:55                     ` Jason Wang
2021-10-27  7:04                       ` Wu Zongyong
2021-10-29  9:14           ` [PATCH v7 0/9] " Wu Zongyong
2021-10-29  9:14             ` [PATCH v7 1/9] virtio-pci: introduce legacy device module Wu Zongyong
2021-10-29  9:14             ` [PATCH v7 2/9] vdpa: fix typo Wu Zongyong
2021-10-29  9:14             ` [PATCH v7 3/9] vp_vdpa: add vq irq offloading support Wu Zongyong
2021-10-29  9:14             ` [PATCH v7 4/9] vdpa: add new callback get_vq_num_min in vdpa_config_ops Wu Zongyong
2021-10-29  9:14             ` [PATCH v7 5/9] vdpa: min vq num of vdpa device cannot be greater than max vq num Wu Zongyong
2021-10-29  9:14             ` [PATCH v7 6/9] virtio_vdpa: setup correct vq size with callbacks get_vq_num_{max,min} Wu Zongyong
2021-10-29  9:14             ` [PATCH v7 7/9] vdpa: add new attribute VDPA_ATTR_DEV_MIN_VQ_SIZE Wu Zongyong
2021-10-29  9:14             ` [PATCH v7 8/9] eni_vdpa: add vDPA driver for Alibaba ENI Wu Zongyong
2021-10-29  9:14             ` [PATCH v7 9/9] eni_vdpa: alibaba: fix Kconfig typo Wu Zongyong
2021-11-01  8:18               ` Michael S. Tsirkin
2021-11-01  3:31             ` [PATCH v7 0/9] vDPA driver for Alibaba ENI Jason Wang
2021-11-01  6:22               ` Wu Zongyong
2021-11-01  7:02                 ` Jason Wang
2021-11-01  8:11                   ` Wu Zongyong
2021-11-01 11:12                     ` Michael S. Tsirkin
2021-11-01  8:19             ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909095726.GA17469@L-PF27918B-1352.localdomain \
    --to=wuzongyong@linux.alibaba.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wei.yang1@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®