diff mbox series

[RFC,2/6] vdpa: add should_enable op

Message ID 20230706191227.835526-3-eperezma@redhat.com
State New
Headers show
Series Enable vdpa net migration with features depending on CVQ | expand

Commit Message

Eugenio Perez Martin July 6, 2023, 7:12 p.m. UTC
To restore the device at the destination of a live migration we send the
commands through control virtqueue.  For a device to read CVQ it must
have received the DRIVER_OK status bit.

However this opens a window where the device could start receiving
packets in rx queue 0 before it receives the RSS configuration.  To
avoid that, we will not send vring_enable until all configuration is
used by the device.

As a first step, enable a new vitio ops per vhost_vdpa device to know if
we should enable a virtqueue or not.  This srtuct can be reused in the
future to add more actions to vhost_vdpa that depend on the virtIO kind
of device.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 include/hw/virtio/vhost-vdpa.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Jason Wang July 10, 2023, 3:46 a.m. UTC | #1
On Fri, Jul 7, 2023 at 3:12 AM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> To restore the device at the destination of a live migration we send the
> commands through control virtqueue.  For a device to read CVQ it must
> have received the DRIVER_OK status bit.
>
> However this opens a window where the device could start receiving
> packets in rx queue 0 before it receives the RSS configuration.

I think this can also happen in the case of automatic steering.

> To
> avoid that, we will not send vring_enable until all configuration is
> used by the device.
>
> As a first step, enable a new vitio ops per vhost_vdpa device to know if
> we should enable a virtqueue or not.  This srtuct can be reused in the

typo.

Thanks

> future to add more actions to vhost_vdpa that depend on the virtIO kind
> of device.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
>  include/hw/virtio/vhost-vdpa.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
> index 5407d54fd7..3d330d439a 100644
> --- a/include/hw/virtio/vhost-vdpa.h
> +++ b/include/hw/virtio/vhost-vdpa.h
> @@ -30,6 +30,13 @@ typedef struct VhostVDPAHostNotifier {
>      void *addr;
>  } VhostVDPAHostNotifier;
>
> +struct vhost_vdpa;
> +typedef bool (*vhost_vdpa_virtio_should_enable_op)(const struct vhost_vdpa *v);
> +
> +typedef struct VhostVDPAVirtIOOps {
> +    vhost_vdpa_virtio_should_enable_op should_enable;
> +} VhostVDPAVirtIOOps;
> +
>  typedef struct vhost_vdpa {
>      int device_fd;
>      int index;
> @@ -48,6 +55,7 @@ typedef struct vhost_vdpa {
>      VhostIOVATree *iova_tree;
>      GPtrArray *shadow_vqs;
>      const VhostShadowVirtqueueOps *shadow_vq_ops;
> +    const VhostVDPAVirtIOOps *virtio_ops;
>      void *shadow_vq_ops_opaque;
>      struct vhost_dev *dev;
>      Error *migration_blocker;
> --
> 2.39.3
>
diff mbox series

Patch

diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h
index 5407d54fd7..3d330d439a 100644
--- a/include/hw/virtio/vhost-vdpa.h
+++ b/include/hw/virtio/vhost-vdpa.h
@@ -30,6 +30,13 @@  typedef struct VhostVDPAHostNotifier {
     void *addr;
 } VhostVDPAHostNotifier;
 
+struct vhost_vdpa;
+typedef bool (*vhost_vdpa_virtio_should_enable_op)(const struct vhost_vdpa *v);
+
+typedef struct VhostVDPAVirtIOOps {
+    vhost_vdpa_virtio_should_enable_op should_enable;
+} VhostVDPAVirtIOOps;
+
 typedef struct vhost_vdpa {
     int device_fd;
     int index;
@@ -48,6 +55,7 @@  typedef struct vhost_vdpa {
     VhostIOVATree *iova_tree;
     GPtrArray *shadow_vqs;
     const VhostShadowVirtqueueOps *shadow_vq_ops;
+    const VhostVDPAVirtIOOps *virtio_ops;
     void *shadow_vq_ops_opaque;
     struct vhost_dev *dev;
     Error *migration_blocker;