Skip to content

Commit 4c8cf31

Browse files
Tiwei Biemstsirkin
authored andcommitted
vhost: introduce vDPA-based backend
This patch introduces a vDPA-based vhost backend. This backend is built on top of the same interface defined in virtio-vDPA and provides a generic vhost interface for userspace to accelerate the virtio devices in guest. This backend is implemented as a vDPA device driver on top of the same ops used in virtio-vDPA. It will create char device entry named vhost-vdpa-$index for userspace to use. Userspace can use vhost ioctls on top of this char device to setup the backend. Vhost ioctls are extended to make it type agnostic and behave like a virtio device, this help to eliminate type specific API like what vhost_net/scsi/vsock did: - VHOST_VDPA_GET_DEVICE_ID: get the virtio device ID which is defined by virtio specification to differ from different type of devices - VHOST_VDPA_GET_VRING_NUM: get the maximum size of virtqueue supported by the vDPA device - VHSOT_VDPA_SET/GET_STATUS: set and get virtio status of vDPA device - VHOST_VDPA_SET/GET_CONFIG: access virtio config space - VHOST_VDPA_SET_VRING_ENABLE: enable a specific virtqueue For memory mapping, IOTLB API is mandated for vhost-vDPA which means userspace drivers are required to use VHOST_IOTLB_UPDATE/VHOST_IOTLB_INVALIDATE to add or remove mapping for a specific userspace memory region. The vhost-vDPA API is designed to be type agnostic, but it allows net device only in current stage. Due to the lacking of control virtqueue support, some features were filter out by vhost-vdpa. We will enable more features and devices in the near future. Signed-off-by: Tiwei Bie <[email protected]> Signed-off-by: Eugenio Pérez <[email protected]> Signed-off-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent c043b4a commit 4c8cf31

File tree

5 files changed

+930
-0
lines changed

5 files changed

+930
-0
lines changed

drivers/vhost/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ config VHOST_VSOCK
5959
To compile this driver as a module, choose M here: the module will be called
6060
vhost_vsock.
6161

62+
config VHOST_VDPA
63+
tristate "Vhost driver for vDPA-based backend"
64+
depends on EVENTFD
65+
select VHOST
66+
select VDPA
67+
help
68+
This kernel module can be loaded in host kernel to accelerate
69+
guest virtio devices with the vDPA-based backends.
70+
71+
To compile this driver as a module, choose M here: the module
72+
will be called vhost_vdpa.
73+
6274
config VHOST_CROSS_ENDIAN_LEGACY
6375
bool "Cross-endian support for vhost"
6476
default n

drivers/vhost/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ vhost_vsock-y := vsock.o
1010

1111
obj-$(CONFIG_VHOST_RING) += vringh.o
1212

13+
obj-$(CONFIG_VHOST_VDPA) += vhost_vdpa.o
14+
vhost_vdpa-y := vdpa.o
15+
1316
obj-$(CONFIG_VHOST) += vhost.o
1417

1518
obj-$(CONFIG_VHOST_IOTLB) += vhost_iotlb.o

0 commit comments

Comments
 (0)