diff mbox series

[v2,1/2] vhost: Add worker backend callouts

Message ID 20231127002834.8670-2-michael.christie@oracle.com (mailing list archive)
State New, archived
Headers show
Series vhost-scsi: Support worker ioctls | expand

Commit Message

Mike Christie Nov. 27, 2023, 12:28 a.m. UTC
This adds the vhost backend callouts for the worker ioctls added in the
6.4 linux kernel commit:

c1ecd8e95007 ("vhost: allow userspace to create workers")

Signed-off-by: Mike Christie <michael.christie@oracle.com>
---
 hw/virtio/vhost-backend.c         | 28 ++++++++++++++++++++++++++++
 include/hw/virtio/vhost-backend.h | 14 ++++++++++++++
 2 files changed, 42 insertions(+)

Comments

Stefano Garzarella Nov. 29, 2023, 9:26 a.m. UTC | #1
On Sun, Nov 26, 2023 at 06:28:33PM -0600, Mike Christie wrote:
>This adds the vhost backend callouts for the worker ioctls added in the
>6.4 linux kernel commit:
>
>c1ecd8e95007 ("vhost: allow userspace to create workers")
>
>Signed-off-by: Mike Christie <michael.christie@oracle.com>
>---
> hw/virtio/vhost-backend.c         | 28 ++++++++++++++++++++++++++++
> include/hw/virtio/vhost-backend.h | 14 ++++++++++++++
> 2 files changed, 42 insertions(+)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
>index 17f3fc6a0823..833804dd40f2 100644
>--- a/hw/virtio/vhost-backend.c
>+++ b/hw/virtio/vhost-backend.c
>@@ -158,6 +158,30 @@ static int vhost_kernel_set_vring_busyloop_timeout(struct vhost_dev *dev,
>     return vhost_kernel_call(dev, VHOST_SET_VRING_BUSYLOOP_TIMEOUT, s);
> }
>
>+static int vhost_kernel_new_worker(struct vhost_dev *dev,
>+                                   struct vhost_worker_state *worker)
>+{
>+    return vhost_kernel_call(dev, VHOST_NEW_WORKER, worker);
>+}
>+
>+static int vhost_kernel_free_worker(struct vhost_dev *dev,
>+                                    struct vhost_worker_state *worker)
>+{
>+    return vhost_kernel_call(dev, VHOST_FREE_WORKER, worker);
>+}
>+
>+static int vhost_kernel_attach_vring_worker(struct vhost_dev *dev,
>+                                            struct vhost_vring_worker *worker)
>+{
>+    return vhost_kernel_call(dev, VHOST_ATTACH_VRING_WORKER, worker);
>+}
>+
>+static int vhost_kernel_get_vring_worker(struct vhost_dev *dev,
>+                                         struct vhost_vring_worker *worker)
>+{
>+    return vhost_kernel_call(dev, VHOST_GET_VRING_WORKER, worker);
>+}
>+
> static int vhost_kernel_set_features(struct vhost_dev *dev,
>                                      uint64_t features)
> {
>@@ -313,6 +337,10 @@ const VhostOps kernel_ops = {
>         .vhost_set_vring_err = vhost_kernel_set_vring_err,
>         .vhost_set_vring_busyloop_timeout =
>                                 vhost_kernel_set_vring_busyloop_timeout,
>+        .vhost_get_vring_worker = vhost_kernel_get_vring_worker,
>+        .vhost_attach_vring_worker = vhost_kernel_attach_vring_worker,
>+        .vhost_new_worker = vhost_kernel_new_worker,
>+        .vhost_free_worker = vhost_kernel_free_worker,
>         .vhost_set_features = vhost_kernel_set_features,
>         .vhost_get_features = vhost_kernel_get_features,
>         .vhost_set_backend_cap = vhost_kernel_set_backend_cap,
>diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
>index 96ccc18cd33b..9f16d0884e8f 100644
>--- a/include/hw/virtio/vhost-backend.h
>+++ b/include/hw/virtio/vhost-backend.h
>@@ -33,6 +33,8 @@ struct vhost_memory;
> struct vhost_vring_file;
> struct vhost_vring_state;
> struct vhost_vring_addr;
>+struct vhost_vring_worker;
>+struct vhost_worker_state;
> struct vhost_scsi_target;
> struct vhost_iotlb_msg;
> struct vhost_virtqueue;
>@@ -73,6 +75,14 @@ typedef int (*vhost_set_vring_err_op)(struct vhost_dev *dev,
>                                       struct vhost_vring_file *file);
> typedef int (*vhost_set_vring_busyloop_timeout_op)(struct vhost_dev *dev,
>                                                    struct vhost_vring_state *r);
>+typedef int (*vhost_attach_vring_worker_op)(struct vhost_dev *dev,
>+                                            struct vhost_vring_worker *worker);
>+typedef int (*vhost_get_vring_worker_op)(struct vhost_dev *dev,
>+                                         struct vhost_vring_worker *worker);
>+typedef int (*vhost_new_worker_op)(struct vhost_dev *dev,
>+                                   struct vhost_worker_state *worker);
>+typedef int (*vhost_free_worker_op)(struct vhost_dev *dev,
>+                                    struct vhost_worker_state *worker);
> typedef int (*vhost_set_features_op)(struct vhost_dev *dev,
>                                      uint64_t features);
> typedef int (*vhost_get_features_op)(struct vhost_dev *dev,
>@@ -151,6 +161,10 @@ typedef struct VhostOps {
>     vhost_set_vring_call_op vhost_set_vring_call;
>     vhost_set_vring_err_op vhost_set_vring_err;
>     vhost_set_vring_busyloop_timeout_op vhost_set_vring_busyloop_timeout;
>+    vhost_new_worker_op vhost_new_worker;
>+    vhost_free_worker_op vhost_free_worker;
>+    vhost_get_vring_worker_op vhost_get_vring_worker;
>+    vhost_attach_vring_worker_op vhost_attach_vring_worker;
>     vhost_set_features_op vhost_set_features;
>     vhost_get_features_op vhost_get_features;
>     vhost_set_backend_cap_op vhost_set_backend_cap;
>-- 
>2.34.1
>
diff mbox series

Patch

diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 17f3fc6a0823..833804dd40f2 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -158,6 +158,30 @@  static int vhost_kernel_set_vring_busyloop_timeout(struct vhost_dev *dev,
     return vhost_kernel_call(dev, VHOST_SET_VRING_BUSYLOOP_TIMEOUT, s);
 }
 
+static int vhost_kernel_new_worker(struct vhost_dev *dev,
+                                   struct vhost_worker_state *worker)
+{
+    return vhost_kernel_call(dev, VHOST_NEW_WORKER, worker);
+}
+
+static int vhost_kernel_free_worker(struct vhost_dev *dev,
+                                    struct vhost_worker_state *worker)
+{
+    return vhost_kernel_call(dev, VHOST_FREE_WORKER, worker);
+}
+
+static int vhost_kernel_attach_vring_worker(struct vhost_dev *dev,
+                                            struct vhost_vring_worker *worker)
+{
+    return vhost_kernel_call(dev, VHOST_ATTACH_VRING_WORKER, worker);
+}
+
+static int vhost_kernel_get_vring_worker(struct vhost_dev *dev,
+                                         struct vhost_vring_worker *worker)
+{
+    return vhost_kernel_call(dev, VHOST_GET_VRING_WORKER, worker);
+}
+
 static int vhost_kernel_set_features(struct vhost_dev *dev,
                                      uint64_t features)
 {
@@ -313,6 +337,10 @@  const VhostOps kernel_ops = {
         .vhost_set_vring_err = vhost_kernel_set_vring_err,
         .vhost_set_vring_busyloop_timeout =
                                 vhost_kernel_set_vring_busyloop_timeout,
+        .vhost_get_vring_worker = vhost_kernel_get_vring_worker,
+        .vhost_attach_vring_worker = vhost_kernel_attach_vring_worker,
+        .vhost_new_worker = vhost_kernel_new_worker,
+        .vhost_free_worker = vhost_kernel_free_worker,
         .vhost_set_features = vhost_kernel_set_features,
         .vhost_get_features = vhost_kernel_get_features,
         .vhost_set_backend_cap = vhost_kernel_set_backend_cap,
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index 96ccc18cd33b..9f16d0884e8f 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -33,6 +33,8 @@  struct vhost_memory;
 struct vhost_vring_file;
 struct vhost_vring_state;
 struct vhost_vring_addr;
+struct vhost_vring_worker;
+struct vhost_worker_state;
 struct vhost_scsi_target;
 struct vhost_iotlb_msg;
 struct vhost_virtqueue;
@@ -73,6 +75,14 @@  typedef int (*vhost_set_vring_err_op)(struct vhost_dev *dev,
                                       struct vhost_vring_file *file);
 typedef int (*vhost_set_vring_busyloop_timeout_op)(struct vhost_dev *dev,
                                                    struct vhost_vring_state *r);
+typedef int (*vhost_attach_vring_worker_op)(struct vhost_dev *dev,
+                                            struct vhost_vring_worker *worker);
+typedef int (*vhost_get_vring_worker_op)(struct vhost_dev *dev,
+                                         struct vhost_vring_worker *worker);
+typedef int (*vhost_new_worker_op)(struct vhost_dev *dev,
+                                   struct vhost_worker_state *worker);
+typedef int (*vhost_free_worker_op)(struct vhost_dev *dev,
+                                    struct vhost_worker_state *worker);
 typedef int (*vhost_set_features_op)(struct vhost_dev *dev,
                                      uint64_t features);
 typedef int (*vhost_get_features_op)(struct vhost_dev *dev,
@@ -151,6 +161,10 @@  typedef struct VhostOps {
     vhost_set_vring_call_op vhost_set_vring_call;
     vhost_set_vring_err_op vhost_set_vring_err;
     vhost_set_vring_busyloop_timeout_op vhost_set_vring_busyloop_timeout;
+    vhost_new_worker_op vhost_new_worker;
+    vhost_free_worker_op vhost_free_worker;
+    vhost_get_vring_worker_op vhost_get_vring_worker;
+    vhost_attach_vring_worker_op vhost_attach_vring_worker;
     vhost_set_features_op vhost_set_features;
     vhost_get_features_op vhost_get_features;
     vhost_set_backend_cap_op vhost_set_backend_cap;