Skip to contentSkip to conversation

vhost-vfio: introduce mdev based HW vhost backend

RFC In review Xiao Wang 3 participants 10 messages Oct 16, 2018 – Nov 9, 2018 Networking

lore
Share & tools
lore

Xiao Wang

author
#0 lore raw

cover vhost-vfio: introduce mdev based HW vhost backend

What's this
===========
Following the patch (vhost: introduce mdev based hardware vhost backend)
https://lwn.net/Articles/750770/, which defines a generic mdev device for vhost data path acceleration (aliased as vDPA mdev below), this patch set introduces a new net client type: vhost-vfio.

Currently we have 2 types of vhost backends in QEMU: vhost kernel (tap) and vhost-user (e.g. DPDK vhost), in order to have a kernel space HW vhost acceleration framework, the vDPA mdev device works as a generic configuring channel. It exposes to user space a non-vendor-specific configuration interface for setting up a vhost HW accelerator, based on this, this patch set introduces a third vhost backend called vhost-vfio.

How does it work
================
The vDPA mdev defines 2 BAR regions, BAR0 and BAR1. BAR0 is the main device interface, vhost messages can be written to or read from this region following below format. All the regular vhost messages about vring addr, negotiated features, etc., are written to this region directly.

struct vhost_vfio_op {
	__u64 request;
	__u32 flags;
	/* Flag values: */
#define VHOST_VFIO_NEED_REPLY 0x1 /* Whether need reply */
	__u32 size;
	union {
		__u64 u64;
		struct vhost_vring_state state;
		struct vhost_vring_addr addr;
		struct vhost_memory memory;
	} payload;
};

BAR1 is defined to be a region of doorbells, QEMU can use this region as host notifier for virtio. To optimize virtio notify, vhost-vfio trys to mmap the corresponding page on BAR1 for each queue and leverage EPT to let guest virtio driver kick vDPA device doorbell directly. For virtio 0.95 case in which we cannot set host notifier memory region, QEMU will help to relay the notify to vDPA device.

Note: EPT mapping requires each queue's notify address locates at the beginning of a separate page, parameter "page-per-vq=on" could help.

For interrupt setting, vDPA mdev device leverages existing VFIO API to enable interrupt config in user space. In this way, KVM's irqfd for virtio can be set to mdev device by QEMU using ioctl().

vhost-vfio net client will set up a vDPA mdev device which is specified by a "sysfsdev" parameter, during the net client init, the device will be opened and parsed using VFIO API, the VFIO device fd and device BAR region offset will be kept in a VhostVFIO structure, this initialization provides a channel to configure vhost information to the vDPA device driver.

To do later
===========
1. The net client initialization uses raw VFIO API to open vDPA mdev device, it's better to provide a set of helpers in hw/vfio/common.c to help vhost-vfio initialize device easily.

2. For device DMA mapping, QEMU passes memory region info to mdev device and let kernel parent device driver program IOMMU. This is a temporary implementation, for future when IOMMU driver supports mdev bus, we can use VFIO API to program IOMMU directly for parent device. Refer to the patch (vfio/mdev: IOMMU aware mediated device):
https://lkml.org/lkml/2018/10/12/225

Vhost-vfio usage
================
# Query the number of available mdev instances

$ cat /sys/class/mdev_bus/0000:84:00.3/mdev_supported_types/ifcvf_vdpa-vdpa_virtio/available_instances

# Create a mdev instance

$ echo $UUID > /sys/class/mdev_bus/0000:84:00.3/mdev_supported_types/ifcvf_vdpa-vdpa_virtio/create

# Launch QEMU with a virtio-net device

    qemu-system-x86_64 -cpu host -enable-kvm \
    <snip>
    -mem-prealloc \
    -netdev type=vhost-vfio,sysfsdev=/sys/bus/mdev/devices/$UUID,id=mynet\
    -device virtio-net-pci,netdv=mynet,page-per-vq=on \

-------- END --------

Xiao Wang (2):
vhost-vfio: introduce vhost-vfio net client
vhost-vfio: implement vhost-vfio backend

 hw/net/vhost_net.c                |  56 ++++-
 hw/vfio/common.c                  |   3 +-
 hw/virtio/Makefile.objs           |   2 +-
 hw/virtio/vhost-backend.c         |   3 +
 hw/virtio/vhost-vfio.c            | 501 ++++++++++++++++++++++++++++++++++++++
 hw/virtio/vhost.c                 |  15 ++
 include/hw/virtio/vhost-backend.h |   7 +-
 include/hw/virtio/vhost-vfio.h    |  35 +++
 include/hw/virtio/vhost.h         |   2 +
 include/net/vhost-vfio.h          |  17 ++
 linux-headers/linux/vhost.h       |   9 +
 net/Makefile.objs                 |   1 +
 net/clients.h                     |   3 +
 net/net.c                         |   1 +
 net/vhost-vfio.c                  | 327 +++++++++++++++++++++++++
 qapi/net.json                     |  22 +-
 16 files changed, 996 insertions(+), 8 deletions(-)
 create mode 100644 hw/virtio/vhost-vfio.c
 create mode 100644 include/hw/virtio/vhost-vfio.h
 create mode 100644 include/net/vhost-vfio.h
 create mode 100644 net/vhost-vfio.c
Signature · 1 line
2.15.1
author
#1 lore raw

RFC 1/2 vhost-vfio: introduce vhost-vfio net client

Following the patch (vhost: introduce mdev based hardware vhost backend)
https://lwn.net/Articles/750770/, which defines a generic mdev device for vDPA (vhost data path acceleration), this patch set introduces a new net client type: vhost-vfio.

Currently we have 2 types of vhost backends in QEMU: vhost kernel and vhost-user. To implement a kernel space HW vhost, the above patch provides a generic mdev device for vDPA purpose, this vDPA mdev device exposes to user space a non-vendor-specific configuration interface for setting up a vhost HW accelerator, this patch set introduces a third vhost backend called vhost-vfio based on the vDPA mdev interface.

vhost-vfio net client will set up a vDPA mdev device which is specified by a "sysfsdev" parameter, during the net client init, the device will be opened and parsed using VFIO API, the VFIO device fd and device BAR region pointers for BAR0 and BAR1 will be kept in a VhostVFIO structure.

This device initialization will provide a channel for the next patch to pass vhost messages to vDPA kernel driver.

Vhost-vfio usage:

    qemu-system-x86_64 -cpu host -enable-kvm \
    <snip>
    -mem-prealloc \
    -netdev type=vhost-vfio,sysfsdev=/sys/bus/mdev/devices/$UUID,id=mynet\
    -device virtio-net-pci,netdv=mynet,page-per-vq=on \
---
 hw/net/vhost_net.c                |  56 ++++++-
 hw/virtio/vhost.c                 |  15 ++
 include/hw/virtio/vhost-backend.h |   6 +-
 include/hw/virtio/vhost-vfio.h    |  35 ++++
 include/hw/virtio/vhost.h         |   2 +
 include/net/vhost-vfio.h          |  17 ++
 linux-headers/linux/vhost.h       |   9 ++
 net/Makefile.objs                 |   1 +
 net/clients.h                     |   3 +
 net/net.c                         |   1 +
 net/vhost-vfio.c                  | 327 ++++++++++++++++++++++++++++++++++++++
 qapi/net.json                     |  22 ++-
 12 files changed, 488 insertions(+), 6 deletions(-)
 create mode 100644 include/hw/virtio/vhost-vfio.h
 create mode 100644 include/net/vhost-vfio.h
 create mode 100644 net/vhost-vfio.c
hw/net/vhost_net.c +53 -3
index e037db63..76ba8a32 100644
@@ -17,6 +17,7 @@
 #include "net/net.h"
 #include "net/tap.h"
 #include "net/vhost-user.h"
+#include "net/vhost-vfio.h"
 
 #include "hw/virtio/virtio-net.h"
 #include "net/vhost_net.h"
@@ -87,6 +88,37 @@ static const int user_feature_bits[] = {
     VHOST_INVALID_FEATURE_BIT
 };
 
+/* Features supported by vhost vfio. */
+static const int vfio_feature_bits[] = {
+    VIRTIO_F_NOTIFY_ON_EMPTY,
+    VIRTIO_RING_F_INDIRECT_DESC,
+    VIRTIO_RING_F_EVENT_IDX,
+
+    VIRTIO_F_ANY_LAYOUT,
+    VIRTIO_F_VERSION_1,
+    VIRTIO_NET_F_CSUM,
+    VIRTIO_NET_F_GUEST_CSUM,
+    VIRTIO_NET_F_GSO,
+    VIRTIO_NET_F_GUEST_TSO4,
+    VIRTIO_NET_F_GUEST_TSO6,
+    VIRTIO_NET_F_GUEST_ECN,
+    VIRTIO_NET_F_GUEST_UFO,
+    VIRTIO_NET_F_HOST_TSO4,
+    VIRTIO_NET_F_HOST_TSO6,
+    VIRTIO_NET_F_HOST_ECN,
+    VIRTIO_NET_F_HOST_UFO,
+    VIRTIO_NET_F_MRG_RXBUF,
+    VIRTIO_NET_F_MTU,
+    VIRTIO_F_IOMMU_PLATFORM,
+
+    /* This bit implies RARP isn't sent by QEMU out of band */
+    VIRTIO_NET_F_GUEST_ANNOUNCE,
+
+    VIRTIO_NET_F_MQ,
+
+    VHOST_INVALID_FEATURE_BIT
+};
+
 static const int *vhost_net_get_feature_bits(struct vhost_net *net)
 {
     const int *feature_bits = 0;
@@ -98,6 +130,9 @@ static const int *vhost_net_get_feature_bits(struct vhost_net *net)
     case NET_CLIENT_DRIVER_VHOST_USER:
         feature_bits = user_feature_bits;
         break;
+    case NET_CLIENT_DRIVER_VHOST_VFIO:
+        feature_bits = vfio_feature_bits;
+        break;
     default:
         error_report("Feature bits not defined for this type: %d",
                 net->nc->info->type);
@@ -296,6 +331,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
     BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(dev)));
     VirtioBusState *vbus = VIRTIO_BUS(qbus);
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
+    struct vhost_net *net;
     int r, e, i;
 
     if (!k->set_guest_notifiers) {
@@ -304,8 +340,6 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
     }
 
     for (i = 0; i < total_queues; i++) {
-        struct vhost_net *net;
-
         net = get_vhost_net(ncs[i].peer);
         vhost_net_set_vq_index(net, i * 2);
 
@@ -341,6 +375,11 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs,
         }
     }
 
+    net = get_vhost_net(ncs[0].peer);
+    if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_VFIO) {
+        r = vhost_set_state(&net->dev, VHOST_DEVICE_S_RUNNING);
+    }         // FIXME: support other device type too
+
     return 0;
 
 err_start:
@@ -362,8 +401,14 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs,
     BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(dev)));
     VirtioBusState *vbus = VIRTIO_BUS(qbus);
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
+    struct vhost_net *net;
     int i, r;
 
+    net = get_vhost_net(ncs[0].peer);
+    if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_VFIO) {
+        r = vhost_set_state(&net->dev, VHOST_DEVICE_S_STOPPED);
+    }
+
     for (i = 0; i < total_queues; i++) {
         vhost_net_stop_one(get_vhost_net(ncs[i].peer), dev);
     }
@@ -385,7 +430,8 @@ int vhost_net_notify_migration_done(struct vhost_net *net, char* mac_addr)
 {
     const VhostOps *vhost_ops = net->dev.vhost_ops;
 
-    assert(vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
+    assert(vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER ||
+		    vhost_ops->backend_type == VHOST_BACKEND_TYPE_VFIO);
     assert(vhost_ops->vhost_migration_done);
 
     return vhost_ops->vhost_migration_done(&net->dev, mac_addr);
@@ -418,6 +464,10 @@ VHostNetState *get_vhost_net(NetClientState *nc)
         vhost_net = vhost_user_get_vhost_net(nc);
         assert(vhost_net);
         break;
+    case NET_CLIENT_DRIVER_VHOST_VFIO:
+        vhost_net = vhost_vfio_get_vhost_net(nc);
+        assert(vhost_net);
+        break;
     default:
         break;
     }
hw/virtio/vhost.c +15 -0
index d4cb5894..269cd498 100644
@@ -1598,3 +1598,18 @@ int vhost_net_set_backend(struct vhost_dev *hdev,
 
     return -1;
 }
+
+/*
+ * XXX:
+ * state:
+ * 0 - stop
+ * 1 - start
+ */
+int vhost_set_state(struct vhost_dev *hdev, int state)
+{
+    if (hdev->vhost_ops->vhost_set_state) {
+        return hdev->vhost_ops->vhost_set_state(hdev, state);
+    }
+
+    return -1;
+}
include/hw/virtio/vhost-backend.h +5 -1
index 81283ec5..89590ae6 100644
@@ -17,7 +17,8 @@ typedef enum VhostBackendType {
     VHOST_BACKEND_TYPE_NONE = 0,
     VHOST_BACKEND_TYPE_KERNEL = 1,
     VHOST_BACKEND_TYPE_USER = 2,
-    VHOST_BACKEND_TYPE_MAX = 3,
+    VHOST_BACKEND_TYPE_VFIO = 3,
+    VHOST_BACKEND_TYPE_MAX = 4,
 } VhostBackendType;
 
 typedef enum VhostSetConfigType {
@@ -104,6 +105,8 @@ typedef int (*vhost_crypto_close_session_op)(struct vhost_dev *dev,
 typedef bool (*vhost_backend_mem_section_filter_op)(struct vhost_dev *dev,
                                                 MemoryRegionSection *section);
 
+typedef int (*vhost_set_state_op)(struct vhost_dev *dev, int state);
+
 typedef struct VhostOps {
     VhostBackendType backend_type;
     vhost_backend_init vhost_backend_init;
@@ -142,6 +145,7 @@ typedef struct VhostOps {
     vhost_crypto_create_session_op vhost_crypto_create_session;
     vhost_crypto_close_session_op vhost_crypto_close_session;
     vhost_backend_mem_section_filter_op vhost_backend_mem_section_filter;
+    vhost_set_state_op vhost_set_state;
 } VhostOps;
 
 extern const VhostOps user_ops;
include/hw/virtio/vhost-vfio.h new file +35 -0
new file mode 100644
index 00000000..3ec0dfe2
@@ -0,0 +1,35 @@
+/*
+ * vhost-vfio
+ *
+ *  Copyright(c) 2017-2018 Intel Corporation. All rights reserved.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef HW_VIRTIO_VHOST_VFIO_H
+#define HW_VIRTIO_VHOST_VFIO_H
+
+#include "hw/virtio/virtio.h"
+
+typedef struct VhostVFIONotifyCtx {
+    int qid;
+    int kick_fd;
+    void *addr;
+    MemoryRegion mr;
+} VhostVFIONotifyCtx;
+
+typedef struct VhostVFIO {
+    uint64_t bar0_offset;
+    uint64_t bar0_size;
+    uint64_t bar1_offset;
+    uint64_t bar1_size;
+    int device_fd;
+    int group_fd;
+    int container_fd;
+
+    VhostVFIONotifyCtx notify[VIRTIO_QUEUE_MAX];
+} VhostVFIO;
+
+#endif
include/hw/virtio/vhost.h +2 -0
index a7f449fa..db202d1d 100644
@@ -111,6 +111,8 @@ bool vhost_has_free_slot(void);
 int vhost_net_set_backend(struct vhost_dev *hdev,
                           struct vhost_vring_file *file);
 
+int vhost_set_state(struct vhost_dev *hdev, int state);
+
 int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write);
 int vhost_dev_get_config(struct vhost_dev *dev, uint8_t *config,
                          uint32_t config_len);
include/net/vhost-vfio.h new file +17 -0
new file mode 100644
index 00000000..6d757284
@@ -0,0 +1,17 @@
+/*
+ * vhost-vfio.h
+ *
+ * Copyright(c) 2017-2018 Intel Corporation. All rights reserved.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef VHOST_VFIO_H
+#define VHOST_VFIO_H
+
+struct vhost_net;
+struct vhost_net *vhost_vfio_get_vhost_net(NetClientState *nc);
+
+#endif /* VHOST_VFIO_H */
linux-headers/linux/vhost.h +9 -0
index e336395d..289f46a4 100644
@@ -207,4 +207,13 @@ struct vhost_scsi_target {
 #define VHOST_VSOCK_SET_GUEST_CID	_IOW(VHOST_VIRTIO, 0x60, __u64)
 #define VHOST_VSOCK_SET_RUNNING		_IOW(VHOST_VIRTIO, 0x61, int)
 
+
+/* VHOST_DEVICE specific defines */
+
+#define VHOST_DEVICE_SET_STATE _IOW(VHOST_VIRTIO, 0x70, __u64)
+
+#define VHOST_DEVICE_S_STOPPED 0
+#define VHOST_DEVICE_S_RUNNING 1
+#define VHOST_DEVICE_S_MAX     2
+
 #endif
net/Makefile.objs +1 -0
index b2bf88a0..94f1e9dd 100644
@@ -4,6 +4,7 @@ common-obj-y += dump.o
 common-obj-y += eth.o
 common-obj-$(CONFIG_L2TPV3) += l2tpv3.o
 common-obj-$(CONFIG_POSIX) += vhost-user.o
+common-obj-$(CONFIG_LINUX) += vhost-vfio.o
 common-obj-$(CONFIG_SLIRP) += slirp.o
 common-obj-$(CONFIG_VDE) += vde.o
 common-obj-$(CONFIG_NETMAP) += netmap.o
net/clients.h +3 -0
index a6ef267e..7b3cbb4e 100644
@@ -61,4 +61,7 @@ int net_init_netmap(const Netdev *netdev, const char *name,
 int net_init_vhost_user(const Netdev *netdev, const char *name,
                         NetClientState *peer, Error **errp);
 
+int net_init_vhost_vfio(const Netdev *netdev, const char *name,
+                        NetClientState *peer, Error **errp);
+
 #endif /* QEMU_NET_CLIENTS_H */
net/net.c +1 -0
index 2a313399..5430ab38 100644
@@ -952,6 +952,7 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
         [NET_CLIENT_DRIVER_HUBPORT]   = net_init_hubport,
 #ifdef CONFIG_VHOST_NET_USED
         [NET_CLIENT_DRIVER_VHOST_USER] = net_init_vhost_user,
+        [NET_CLIENT_DRIVER_VHOST_VFIO] = net_init_vhost_vfio,
 #endif
 #ifdef CONFIG_L2TPV3
         [NET_CLIENT_DRIVER_L2TPV3]    = net_init_l2tpv3,
net/vhost-vfio.c new file +327 -0

327 lines not on this page · raw message

qapi/net.json +20 -2
index c86f3511..65c77c45 100644
@@ -437,6 +437,23 @@
     '*vhostforce':    'bool',
     '*queues':        'int' } }
 
+##
+# @NetdevVhostVFIOOptions:
+#
+# Vhost-vfio network backend
+#
+# @sysfsdev: name of a mdev dev path in sysfs
+#
+# @queues: number of queues to be created for multiqueue vhost-vfio
+#          (default: 1) (Since 2.11)
+#
+# Since: 2.11
+##
+{ 'struct': 'NetdevVhostVFIOOptions',
+  'data': {
+    '*sysfsdev':     'str',
+    '*queues':       'int' } }
+
 ##
 # @NetClientDriver:
 #
@@ -448,7 +465,7 @@
 ##
 { 'enum': 'NetClientDriver',
   'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
-            'bridge', 'hubport', 'netmap', 'vhost-user' ] }
+            'bridge', 'hubport', 'netmap', 'vhost-user', 'vhost-vfio' ] }
 
 ##
 # @Netdev:
@@ -476,7 +493,8 @@
     'bridge':   'NetdevBridgeOptions',
     'hubport':  'NetdevHubPortOptions',
     'netmap':   'NetdevNetmapOptions',
-    'vhost-user': 'NetdevVhostUserOptions' } }
+    'vhost-user': 'NetdevVhostUserOptions',
+    'vhost-vfio': 'NetdevVhostVFIOOptions' } }
 
 ##
 # @NetLegacy:
Signature · 1 line
2.15.1
author
#2 lore raw

RFC 2/2 vhost-vfio: implement vhost-vfio backend

In reply to Xiao Wang

This patch implements vhost ops of vhost-vfio backend.

All the regular vhost messages including vring addr, negotiated features, etc., are written to vDPA mdev device directly.

For device DMA mapping, QEMU passes memory region info to mdev device and let kernel parent device driver to program IOMMU. This is a temporary implementation, for future when IOMMU supports mdev bus, we can use VFIO API to program IOMMU directly for parent device.

For SET_VRING_KICK, vhost-vfio trys to leverage EPT to let guest virtio driver kick vDPA device doorbell directly. For virtio 0.95 case in which we cannot set host notifier memory region, QEMU will help to relay the notify to vDPA device.

For SET_VRING_CALL, vhost-vfio uses VFIO API to pass the irqfd to kernel.

---
 hw/vfio/common.c                  |   3 +-
 hw/virtio/Makefile.objs           |   2 +-
 hw/virtio/vhost-backend.c         |   3 +
 hw/virtio/vhost-vfio.c            | 501 ++++++++++++++++++++++++++++++++++++++
 include/hw/virtio/vhost-backend.h |   1 +
 5 files changed, 508 insertions(+), 2 deletions(-)
 create mode 100644 hw/virtio/vhost-vfio.c
hw/vfio/common.c +2 -1
index fb396cf0..a3b1cf86 100644
@@ -49,7 +49,8 @@ struct vfio_as_head vfio_address_spaces =
  * initialized, this file descriptor is only released on QEMU exit and
  * we'll re-use it should another vfio device be attached before then.
  */
-static int vfio_kvm_device_fd = -1;
+// XXX: Add vfio API for vDPA use case
+int vfio_kvm_device_fd = -1;
 #endif
 
 /*
hw/virtio/Makefile.objs +1 -1
index 1b2799cf..c5aa6675 100644
@@ -9,7 +9,7 @@ obj-$(CONFIG_VIRTIO_BALLOON) += virtio-balloon.o
 obj-$(CONFIG_VIRTIO_CRYPTO) += virtio-crypto.o
 obj-$(call land,$(CONFIG_VIRTIO_CRYPTO),$(CONFIG_VIRTIO_PCI)) += virtio-crypto-pci.o
 
-obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o
+obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o vhost-vfio.o
 obj-$(CONFIG_VHOST_VSOCK) += vhost-vsock.o
 endif
 
hw/virtio/vhost-backend.c +3 -0
index 7f09efab..bfe0646d 100644
@@ -277,6 +277,9 @@ int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend_type)
     case VHOST_BACKEND_TYPE_USER:
         dev->vhost_ops = &user_ops;
         break;
+    case VHOST_BACKEND_TYPE_VFIO:
+        dev->vhost_ops = &vfio_ops;
+        break;
     default:
         error_report("Unknown vhost backend type");
         r = -1;
hw/virtio/vhost-vfio.c new file +501 -0

501 lines not on this page · raw message

include/hw/virtio/vhost-backend.h +1 -0
index 89590ae6..19e3acad 100644
@@ -149,6 +149,7 @@ typedef struct VhostOps {
 } VhostOps;
 
 extern const VhostOps user_ops;
+extern const VhostOps vfio_ops;
 
 int vhost_set_backend_type(struct vhost_dev *dev,
                            VhostBackendType backend_type);
Signature · 1 line
2.15.1
#3 lore raw
In reply to Xiao Wang
Quoted 6 lines · Xiao Wang

What's this
===========
Following the patch (vhost: introduce mdev based hardware vhost backend)
https://lwn.net/Articles/750770/, which defines a generic mdev device for vhost data path acceleration (aliased as vDPA mdev below), this patch set introduces a new net client type: vhost-vfio.

Thanks a lot for a such interesting series. Some generic questions:

If we consider to use software backend (e.g vhost-kernel or a rely of virito-vhost-user or other cases) as well in the future, maybe vhost-mdev is better which mean it does not tie to VFIO anyway.

Quoted 5 lines

Currently we have 2 types of vhost backends in QEMU: vhost kernel (tap) and vhost-user (e.g. DPDK vhost), in order to have a kernel space HW vhost acceleration framework, the vDPA mdev device works as a generic configuring channel.

Does "generic" configuring channel means dpdk will also go for this way? E.g it will have a vhost mdev pmd?

Quoted 2 lines

It exposes to user space a non-vendor-specific configuration
interface for setting up a vhost HW accelerator,

Or even a software translation layer on top of exist hardware.

Quoted 9 lines

based on this, this patch
set introduces a third vhost backend called vhost-vfio.

How does it work
================
The vDPA mdev defines 2 BAR regions, BAR0 and BAR1. BAR0 is the main device interface, vhost messages can be written to or read from this region following below format. All the regular vhost messages about vring addr, negotiated features, etc., are written to this region directly.

If I understand this correctly, the mdev was not used for passed through to guest directly. So what's the reason of inventing a PCI like device here? I'm asking since:

- vhost protocol is transport indepedent, we should consider to support transport other than PCI. I know we can even do it with the exist design but it looks rather odd if we do e.g ccw device with a PCI like mediated device.

- can we try to reuse vhost-kernel ioctl? Less API means less bugs and code reusing. E.g virtio-user can benefit from the vhost kernel ioctl API almost with no changes I believe.

Quoted 22 lines
struct vhost_vfio_op {
	__u64 request;
	__u32 flags;
	/* Flag values: */
#define VHOST_VFIO_NEED_REPLY 0x1 /* Whether need reply */
	__u32 size;
	union {
		__u64 u64;
		struct vhost_vring_state state;
		struct vhost_vring_addr addr;
		struct vhost_memory memory;
	} payload;
};

BAR1 is defined to be a region of doorbells, QEMU can use this region as host notifier for virtio. To optimize virtio notify, vhost-vfio trys to mmap the corresponding page on BAR1 for each queue and leverage EPT to let guest virtio driver kick vDPA device doorbell directly. For virtio 0.95 case in which we cannot set host notifier memory region, QEMU will help to relay the notify to vDPA device.

Quoted 2 lines

Note: EPT mapping requires each queue's notify address locates at the beginning of a separate page, parameter "page-per-vq=on" could help.

I think qemu should prepare a fallback for this if page-per-vq is off.

Quoted 17 lines

For interrupt setting, vDPA mdev device leverages existing VFIO API to enable interrupt config in user space. In this way, KVM's irqfd for virtio can be set to mdev device by QEMU using ioctl().

vhost-vfio net client will set up a vDPA mdev device which is specified by a "sysfsdev" parameter, during the net client init, the device will be opened and parsed using VFIO API, the VFIO device fd and device BAR region offset will be kept in a VhostVFIO structure, this initialization provides a channel to configure vhost information to the vDPA device driver.

To do later
===========
1. The net client initialization uses raw VFIO API to open vDPA mdev device, it's better to provide a set of helpers in hw/vfio/common.c to help vhost-vfio initialize device easily.

Quoted 6 lines

2. For device DMA mapping, QEMU passes memory region info to mdev device and let kernel parent device driver program IOMMU. This is a temporary implementation, for future when IOMMU driver supports mdev bus, we can use VFIO API to program IOMMU directly for parent device. Refer to the patch (vfio/mdev: IOMMU aware mediated device):
https://lkml.org/lkml/2018/10/12/225

As Steve mentioned in the KVM forum. It's better to have at least one sample driver e.g virtio-net itself.

Then it would be more convenient for the reviewer to evaluate the whole stack.

Thanks

Quoted 44 lines

Vhost-vfio usage
================
# Query the number of available mdev instances

$ cat /sys/class/mdev_bus/0000:84:00.3/mdev_supported_types/ifcvf_vdpa-vdpa_virtio/available_instances

# Create a mdev instance

$ echo $UUID > /sys/class/mdev_bus/0000:84:00.3/mdev_supported_types/ifcvf_vdpa-vdpa_virtio/create

# Launch QEMU with a virtio-net device

     qemu-system-x86_64 -cpu host -enable-kvm \
     <snip>
     -mem-prealloc \
     -netdev type=vhost-vfio,sysfsdev=/sys/bus/mdev/devices/$UUID,id=mynet\
     -device virtio-net-pci,netdv=mynet,page-per-vq=on \

-------- END --------

Xiao Wang (2):
vhost-vfio: introduce vhost-vfio net client
vhost-vfio: implement vhost-vfio backend

  hw/net/vhost_net.c                |  56 ++++-
  hw/vfio/common.c                  |   3 +-
  hw/virtio/Makefile.objs           |   2 +-
  hw/virtio/vhost-backend.c         |   3 +
  hw/virtio/vhost-vfio.c            | 501 ++++++++++++++++++++++++++++++++++++++
  hw/virtio/vhost.c                 |  15 ++
  include/hw/virtio/vhost-backend.h |   7 +-
  include/hw/virtio/vhost-vfio.h    |  35 +++
  include/hw/virtio/vhost.h         |   2 +
  include/net/vhost-vfio.h          |  17 ++
  linux-headers/linux/vhost.h       |   9 +
  net/Makefile.objs                 |   1 +
  net/clients.h                     |   3 +
  net/net.c                         |   1 +
  net/vhost-vfio.c                  | 327 +++++++++++++++++++++++++
  qapi/net.json                     |  22 +-
  16 files changed, 996 insertions(+), 8 deletions(-)

create mode 100644 hw/virtio/vhost-vfio.c create mode 100644 include/hw/virtio/vhost-vfio.h create mode 100644 include/net/vhost-vfio.h create mode 100644 net/vhost-vfio.c

#4 lore raw
Quoted 22 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Tuesday, November 6, 2018 4:18 AM
To: Wang, Xiao W <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Liang, Cunming <[email protected]>; Ye, Xiaolong <[email protected]>; Wang, Zhihong <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [RFC 0/2] vhost-vfio: introduce mdev based HW vhost backend

Quoted 6 lines · Xiao Wang

What's this
===========
Following the patch (vhost: introduce mdev based hardware vhost backend) https://lwn.net/Articles/750770/, which defines a generic mdev device for vhost data path acceleration (aliased as vDPA mdev below), this patch set introduces a new net client type: vhost-vfio.

Quoted 6 lines

Thanks a lot for a such interesting series. Some generic questions:

If we consider to use software backend (e.g vhost-kernel or a rely of virito-vhost- user or other cases) as well in the future, maybe vhost-mdev is better which mean it does not tie to VFIO anyway.

[LC] The initial thought of using term of '-vfio' due to the VFIO UAPI being used as interface, which is the only available mdev bus driver. It causes to use the term of 'vhost-vfio' in qemu, while using term of 'vhost-mdev' which represents a helper in kernel for vhost messages via mdev.

Quoted 11 lines
Quoted 7 lines

Currently we have 2 types of vhost backends in QEMU: vhost kernel (tap) and vhost-user (e.g. DPDK vhost), in order to have a kernel space HW vhost acceleration framework, the vDPA mdev device works as a generic configuring channel.

Does "generic" configuring channel means dpdk will also go for this way? E.g it will have a vhost mdev pmd?

[LC] We don't plan to have a vhost-mdev pmd, but thinking to have consistent virtio PMD running on top of vhost-mdev. Virtio PMD supports pci bus and vdev (by virtio-user) bus today. Vhost-mdev most likely would be introduced as another bus (mdev bus) provider. mdev bus DPDK support is in backlog.

Quoted 20 lines
Quoted 4 lines

It exposes to user space a non-vendor-specific configuration
interface for setting up a vhost HW accelerator,

Or even a software translation layer on top of exist hardware.

Quoted 9 lines

based on this, this patch
set introduces a third vhost backend called vhost-vfio.

How does it work
================
The vDPA mdev defines 2 BAR regions, BAR0 and BAR1. BAR0 is the main device interface, vhost messages can be written to or read from this region following below format. All the regular vhost messages about vring addr, negotiated features, etc., are written to this region directly.

Quoted 2 lines

If I understand this correctly, the mdev was not used for passed through to guest directly. So what's the reason of inventing a PCI like device here? I'm asking since:

[LC] mdev uses mandatory attribute of 'device_api' to identify the layout. We pick up one available from pci, platform, amba and ccw. It works if defining a new one for this transport.

Quoted 8 lines

- vhost protocol is transport indepedent, we should consider to support transport other than PCI. I know we can even do it with the exist design but it looks rather odd if we do e.g ccw device with a PCI like mediated device.

- can we try to reuse vhost-kernel ioctl? Less API means less bugs and code reusing. E.g virtio-user can benefit from the vhost kernel ioctl API almost with no changes I believe.

[LC] Agreed, so it reuses CMD defined by vhost-kernel ioctl. But VFIO provides device specific things (e.g. DMAR, INTR and etc.) which is the extra APIs being introduced by this transport.

Quoted 24 lines
Quoted 24 lines


struct vhost_vfio_op {
	__u64 request;
	__u32 flags;
	/* Flag values: */
#define VHOST_VFIO_NEED_REPLY 0x1 /* Whether need reply */
	__u32 size;
	union {
		__u64 u64;
		struct vhost_vring_state state;
		struct vhost_vring_addr addr;
		struct vhost_memory memory;
	} payload;
};

BAR1 is defined to be a region of doorbells, QEMU can use this region as host notifier for virtio. To optimize virtio notify, vhost-vfio trys to mmap the corresponding page on BAR1 for each queue and leverage EPT to let guest virtio driver kick vDPA device doorbell directly. For virtio 0.95 case in which we cannot set host notifier memory region, QEMU will help to relay the notify to vDPA device.

Quoted 5 lines
Quoted 2 lines

Note: EPT mapping requires each queue's notify address locates at the beginning of a separate page, parameter "page-per-vq=on" could help.

I think qemu should prepare a fallback for this if page-per-vq is off.

[LC] Yeah, qemu does that and fallback to a syscall to vhost-mdev in kernel.

Quoted 84 lines
Quoted 7 lines

For interrupt setting, vDPA mdev device leverages existing VFIO API to enable interrupt config in user space. In this way, KVM's irqfd for virtio can be set to mdev device by QEMU using ioctl().

Quoted 5 lines

vhost-vfio net client will set up a vDPA mdev device which is specified by a "sysfsdev" parameter, during the net client init, the device will be opened and parsed using VFIO API, the VFIO device fd and device BAR region offset will be kept in a VhostVFIO structure, this initialization provides a channel to configure vhost information to the vDPA

device driver.

Quoted 7 lines

To do later
===========
1. The net client initialization uses raw VFIO API to open vDPA mdev device, it's better to provide a set of helpers in hw/vfio/common.c to help vhost-vfio initialize device easily.

Quoted 6 lines

2. For device DMA mapping, QEMU passes memory region info to mdev device and let kernel parent device driver program IOMMU. This is a temporary implementation, for future when IOMMU driver supports mdev bus, we can use VFIO API to program IOMMU directly for parent device. Refer to the patch (vfio/mdev: IOMMU aware mediated device):
https://lkml.org/lkml/2018/10/12/225

As Steve mentioned in the KVM forum. It's better to have at least one sample driver e.g virtio-net itself.

Then it would be more convenient for the reviewer to evaluate the whole stack.

Thanks

Quoted 25 lines

Vhost-vfio usage
================
# Query the number of available mdev instances $ cat /sys/class/mdev_bus/0000:84:00.3/mdev_supported_types/ifcvf_vdpa-vdpa_ virtio/available_instances

# Create a mdev instance

$ echo $UUID >
/sys/class/mdev_bus/0000:84:00.3/mdev_supported_types/ifcvf_vdpa-vdpa_
virtio/create

# Launch QEMU with a virtio-net device

     qemu-system-x86_64 -cpu host -enable-kvm \
     <snip>
     -mem-prealloc \
     -netdev type=vhost-vfio,sysfsdev=/sys/bus/mdev/devices/$UUID,id=mynet\
     -device virtio-net-pci,netdv=mynet,page-per-vq=on \

-------- END --------

Xiao Wang (2):
vhost-vfio: introduce vhost-vfio net client
vhost-vfio: implement vhost-vfio backend

Quoted 5 lines
  hw/net/vhost_net.c                |  56 ++++-
  hw/vfio/common.c                  |   3 +-
  hw/virtio/Makefile.objs           |   2 +-
  hw/virtio/vhost-backend.c         |   3 +
  hw/virtio/vhost-vfio.c            | 501

++++++++++++++++++++++++++++++++++++++

Quoted 17 lines
  hw/virtio/vhost.c                 |  15 ++
  include/hw/virtio/vhost-backend.h |   7 +-
  include/hw/virtio/vhost-vfio.h    |  35 +++
  include/hw/virtio/vhost.h         |   2 +
  include/net/vhost-vfio.h          |  17 ++
  linux-headers/linux/vhost.h       |   9 +
  net/Makefile.objs                 |   1 +
  net/clients.h                     |   3 +
  net/net.c                         |   1 +
  net/vhost-vfio.c                  | 327 +++++++++++++++++++++++++
  qapi/net.json                     |  22 +-
  16 files changed, 996 insertions(+), 8 deletions(-)

create mode 100644 hw/virtio/vhost-vfio.c create mode 100644 include/hw/virtio/vhost-vfio.h create mode 100644 include/net/vhost-vfio.h create mode 100644 net/vhost-vfio.c

#5 lore raw
Quoted 29 lines · Cunming
Quoted 20 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Tuesday, November 6, 2018 4:18 AM
To: Wang, Xiao W <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Liang, Cunming <[email protected]>; Ye, Xiaolong <[email protected]>; Wang, Zhihong <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [RFC 0/2] vhost-vfio: introduce mdev based HW vhost backend

Quoted 6 lines · Xiao Wang

What's this
===========
Following the patch (vhost: introduce mdev based hardware vhost backend) https://lwn.net/Articles/750770/, which defines a generic mdev device for vhost data path acceleration (aliased as vDPA mdev below), this patch set introduces a new net client type: vhost-vfio.

Quoted 6 lines

Thanks a lot for a such interesting series. Some generic questions:

If we consider to use software backend (e.g vhost-kernel or a rely of virito-vhost- user or other cases) as well in the future, maybe vhost-mdev is better which mean it does not tie to VFIO anyway.

[LC] The initial thought of using term of '-vfio' due to the VFIO UAPI being used as interface, which is the only available mdev bus driver. It causes to use the term of 'vhost-vfio' in qemu, while using term of 'vhost-mdev' which represents a helper in kernel for vhost messages via mdev.

Quoted 1 line
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

Currently we have 2 types of vhost backends in QEMU: vhost kernel (tap) and vhost-user (e.g. DPDK vhost), in order to have a kernel space HW vhost acceleration framework, the vDPA mdev device works as a generic configuring channel.

Does "generic" configuring channel means dpdk will also go for this way? E.g it will have a vhost mdev pmd?

[LC] We don't plan to have a vhost-mdev pmd, but thinking to have consistent virtio PMD running on top of vhost-mdev. Virtio PMD supports pci bus and vdev (by virtio-user) bus today. Vhost-mdev most likely would be introduced as another bus (mdev bus) provider.

This seems could be eliminated if you keep use the vhost-kernel ioctl API. Then you can use virtio-user.

Quoted 23 lines

mdev bus DPDK support is in backlog.

Quoted 17 lines
Quoted 3 lines

It exposes to user space a non-vendor-specific configuration
interface for setting up a vhost HW accelerator,

Or even a software translation layer on top of exist hardware.

Quoted 9 lines

based on this, this patch
set introduces a third vhost backend called vhost-vfio.

How does it work
================
The vDPA mdev defines 2 BAR regions, BAR0 and BAR1. BAR0 is the main device interface, vhost messages can be written to or read from this region following below format. All the regular vhost messages about vring addr, negotiated features, etc., are written to this region directly.

Quoted 2 lines

If I understand this correctly, the mdev was not used for passed through to guest directly. So what's the reason of inventing a PCI like device here? I'm asking since:

[LC] mdev uses mandatory attribute of 'device_api' to identify the layout. We pick up one available from pci, platform, amba and ccw. It works if defining a new one for this transport.

Quoted 8 lines
Quoted 7 lines

- vhost protocol is transport indepedent, we should consider to support transport other than PCI. I know we can even do it with the exist design but it looks rather odd if we do e.g ccw device with a PCI like mediated device.

- can we try to reuse vhost-kernel ioctl? Less API means less bugs and code reusing. E.g virtio-user can benefit from the vhost kernel ioctl API almost with no changes I believe.

[LC] Agreed, so it reuses CMD defined by vhost-kernel ioctl. But VFIO provides device specific things (e.g. DMAR, INTR and etc.) which is the extra APIs being introduced by this transport.

I'm not quite sure I understand here. I think having vhost-kernel compatible ioctl does not conflict of using VFIO ioctl like DMA or INTR?

Btw, VFIO DMA ioctl is even not a must from my point of view, vhost-mdev can forward the mem table information to device driver and let it call DMA API to map/umap pages.

Thanks

#6 lore raw
Quoted 55 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Wednesday, November 7, 2018 2:38 PM
To: Liang, Cunming <[email protected]>; Wang, Xiao W <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Ye, Xiaolong <[email protected]>; Wang, Zhihong <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [RFC 0/2] vhost-vfio: introduce mdev based HW vhost backend

Quoted 22 lines · Cunming
Quoted 22 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Tuesday, November 6, 2018 4:18 AM
To: Wang, Xiao W <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Liang, Cunming <[email protected]>; Ye, Xiaolong <[email protected]>; Wang, Zhihong <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [RFC 0/2] vhost-vfio: introduce mdev based HW vhost backend

Quoted 6 lines · Xiao Wang

What's this
===========
Following the patch (vhost: introduce mdev based hardware vhost backend) https://lwn.net/Articles/750770/, which defines a generic mdev device for vhost data path acceleration (aliased as vDPA mdev below), this patch set introduces a new net client type: vhost-vfio.

Quoted 7 lines
Quoted 6 lines

Thanks a lot for a such interesting series. Some generic questions:

If we consider to use software backend (e.g vhost-kernel or a rely of virito-vhost- user or other cases) as well in the future, maybe vhost-mdev is better which mean it does not tie to VFIO anyway.

[LC] The initial thought of using term of '-vfio' due to the VFIO UAPI being used as

interface, which is the only available mdev bus driver. It causes to use the term of 'vhost-vfio' in qemu, while using term of 'vhost-mdev' which represents a helper in kernel for vhost messages via mdev.

Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

Currently we have 2 types of vhost backends in QEMU: vhost kernel (tap) and vhost-user (e.g. DPDK vhost), in order to have a kernel space HW vhost acceleration framework, the vDPA mdev device works as a generic configuring channel.

Does "generic" configuring channel means dpdk will also go for this way? E.g it will have a vhost mdev pmd?

Quoted 8 lines
Quoted 1 line

[LC] We don't plan to have a vhost-mdev pmd, but thinking to have consistent

virtio PMD running on top of vhost-mdev. Virtio PMD supports pci bus and vdev (by virtio-user) bus today. Vhost-mdev most likely would be introduced as another bus (mdev bus) provider.

This seems could be eliminated if you keep use the vhost-kernel ioctl API. Then you can use virtio-user.

[LC] That's true.

Quoted 42 lines
Quoted 21 lines

mdev bus DPDK support is in backlog.

Quoted 17 lines
Quoted 3 lines

It exposes to user space a non-vendor-specific configuration
interface for setting up a vhost HW accelerator,

Or even a software translation layer on top of exist hardware.

Quoted 9 lines

based on this, this patch
set introduces a third vhost backend called vhost-vfio.

How does it work
================
The vDPA mdev defines 2 BAR regions, BAR0 and BAR1. BAR0 is the main device interface, vhost messages can be written to or read from this region following below format. All the regular vhost messages about vring addr, negotiated features, etc., are written to this region directly.

Quoted 3 lines
Quoted 2 lines

If I understand this correctly, the mdev was not used for passed through to guest directly. So what's the reason of inventing a PCI like device here? I'm asking since:

[LC] mdev uses mandatory attribute of 'device_api' to identify the layout. We pick

up one available from pci, platform, amba and ccw. It works if defining a new one for this transport.

Quoted 3 lines
Quoted 3 lines

- vhost protocol is transport indepedent, we should consider to support transport other than PCI. I know we can even do it with the exist design but it looks rather

odd

Quoted 3 lines
Quoted 3 lines

if we do e.g ccw device with a PCI like mediated device.

- can we try to reuse vhost-kernel ioctl? Less API means less bugs and code

reusing.

Quoted 1 line
Quoted 1 line

E.g virtio-user can benefit from the vhost kernel ioctl API almost with no changes

I

Quoted 2 lines
Quoted 1 line

believe.

[LC] Agreed, so it reuses CMD defined by vhost-kernel ioctl. But VFIO provides

device specific things (e.g. DMAR, INTR and etc.) which is the extra APIs being introduced by this transport.

Quoted 6 lines

I'm not quite sure I understand here. I think having vhost-kernel compatible ioctl does not conflict of using VFIO ioctl like DMA or INTR?

Btw, VFIO DMA ioctl is even not a must from my point of view, vhost-mdev can forward the mem table information to device driver and let it call DMA API to map/umap pages.

[LC] If not regarding vhost-mdev as a device, then forward mem table won't be a concern.
If introducing a new mdev bus driver (vhost-mdev) which allows mdev instance to be a new type of provider for vhost-kernel. It becomes a pretty good alternative to fully leverage vhost-kernel ioctl. I'm not sure it's the same view as yours when you says reusing vhost-kernel ioctl.

Quoted 2 lines

Thanks

#7 lore raw
Quoted 9 lines · Cunming
Quoted 9 lines
Quoted 2 lines
Quoted 1 line

believe.

[LC] Agreed, so it reuses CMD defined by vhost-kernel ioctl. But VFIO provides

device specific things (e.g. DMAR, INTR and etc.) which is the extra APIs being introduced by this transport.

I'm not quite sure I understand here. I think having vhost-kernel compatible ioctl does not conflict of using VFIO ioctl like DMA or INTR?

Quoted 7 lines
Quoted 3 lines

Btw, VFIO DMA ioctl is even not a must from my point of view, vhost-mdev can forward the mem table information to device driver and let it call DMA API to map/umap pages.

[LC] If not regarding vhost-mdev as a device, then forward mem table won't be a concern.
If introducing a new mdev bus driver (vhost-mdev) which allows mdev instance to be a new type of provider for vhost-kernel. It becomes a pretty good alternative to fully leverage vhost-kernel ioctl. I'm not sure it's the same view as yours when you says reusing vhost-kernel ioctl.

Yes it is.

Thanks

#8 lore raw
Quoted 28 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Thursday, November 8, 2018 2:16 AM
To: Liang, Cunming <[email protected]>; Wang, Xiao W <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; Bie, Tiwei <[email protected]>; Ye, Xiaolong <[email protected]>; Wang, Zhihong <[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [RFC 0/2] vhost-vfio: introduce mdev based HW vhost backend

Quoted 7 lines · Cunming
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

believe.

[LC] Agreed, so it reuses CMD defined by vhost-kernel ioctl. But VFIO provides

device specific things (e.g. DMAR, INTR and etc.) which is the extra APIs being introduced by this transport.

Quoted 7 lines
Quoted 6 lines

I'm not quite sure I understand here. I think having vhost-kernel compatible ioctl does not conflict of using VFIO ioctl like DMA or INTR?

Btw, VFIO DMA ioctl is even not a must from my point of view, vhost-mdev can forward the mem table information to device driver and let it call DMA API to map/umap pages.

[LC] If not regarding vhost-mdev as a device, then forward mem table won't be a

Quoted 8 lines

concern.

Quoted 1 line

If introducing a new mdev bus driver (vhost-mdev) which allows mdev instance to

be a new type of provider for vhost-kernel. It becomes a pretty good alternative to fully leverage vhost-kernel ioctl.

Quoted 2 lines

I'm not sure it's the same view as yours when you says reusing vhost-kernel ioctl.

Yes it is.

[LC] It sounds a pretty good idea to me. Let us spend some time to figure out the next level detail, and sync-up further plan in community call. :)

Quoted 2 lines

Thanks

#9 lore raw
Quoted 26 lines · Cunming
Quoted 26 lines

-----Original Message-----
From: Jason Wang [mailto:[email protected]]
Sent: Thursday, November 8, 2018 2:16 AM
To: Liang, Cunming<[email protected]>; Wang, Xiao W <[email protected]>;[email protected];[email protected] Cc:[email protected]; Bie, Tiwei<[email protected]>; Ye, Xiaolong <[email protected]>; Wang, Zhihong<[email protected]>; Daly, Dan <[email protected]>
Subject: Re: [RFC 0/2] vhost-vfio: introduce mdev based HW vhost backend

Quoted 14 lines · Cunming
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

believe.

[LC] Agreed, so it reuses CMD defined by vhost-kernel ioctl. But VFIO provides

device specific things (e.g. DMAR, INTR and etc.) which is the extra APIs being introduced by this transport.

Quoted 6 lines

I'm not quite sure I understand here. I think having vhost-kernel compatible ioctl does not conflict of using VFIO ioctl like DMA or INTR?

Btw, VFIO DMA ioctl is even not a must from my point of view, vhost-mdev can forward the mem table information to device driver and let it call DMA API to map/umap pages.

[LC] If not regarding vhost-mdev as a device, then forward mem table won't be a

Quoted 9 lines
Quoted 7 lines

concern.

Quoted 1 line

If introducing a new mdev bus driver (vhost-mdev) which allows mdev instance to

be a new type of provider for vhost-kernel. It becomes a pretty good alternative to fully leverage vhost-kernel ioctl.

Quoted 2 lines

I'm not sure it's the same view as yours when you says reusing vhost-kernel ioctl.

Yes it is.

[LC] It sounds a pretty good idea to me. Let us spend some time to figure out the next level detail, and sync-up further plan in community call.:)

Cool, thanks.