History

vhost-vdpa: support IOTLB batching hints

This patches extend the vhost IOTLB API to accept batch updating hints form userspace. When userspace wants update the device IOTLB in a batch, it may do: 1) Write vhost_iotlb_msg with VHOST_IOTLB_BATCH_BEGIN flag 2) Perform a batch of IOTLB updating via VHOST_IOTLB_UPDATE/INVALIDATE 3) Write vhost_iotlb_msg with VHOST_IOTLB_BATCH_END flag Vhost-vdpa may decide to batch the IOMMU/IOTLB updating in step 3 when vDPA device support set_map() ops. This is useful for the vDPA device that want to know all the mappings to tweak their own DMA translation logic. For vDPA device that doesn't require set_map(), no behavior changes. This capability is advertised via VHOST_BACKEND_F_IOTLB_BATCH capability.

Jason Wang committed 6 years ago

Commit 25abc061 parent 653055b3 files · +40 −9Browse files

Showing the changes to include/uapi/linux (2 of 3 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/vhost.h +2 −0
  2. include/uapi/linux/vhost_types.h +11 −0
include/uapi/linux/vhost.h+2−0
@@ -91,6 +91,8 @@ · 90 unmodified lines
9191
9292 /* Use message type V2 */
9393 #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
94+/* IOTLB can accept batching hints */
95+#define VHOST_BACKEND_F_IOTLB_BATCH 0x2
9496
9597 #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)
9698 #define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)
include/uapi/linux/vhost_types.h+11−0
@@ -60,6 +60,17 @@ struct vhost_iotlb_msg { · 59 unmodified lines
6060 #define VHOST_IOTLB_UPDATE 2
6161 #define VHOST_IOTLB_INVALIDATE 3
6262 #define VHOST_IOTLB_ACCESS_FAIL 4
63+/*
64+ * VHOST_IOTLB_BATCH_BEGIN and VHOST_IOTLB_BATCH_END allow modifying
65+ * multiple mappings in one go: beginning with
66+ * VHOST_IOTLB_BATCH_BEGIN, followed by any number of
67+ * VHOST_IOTLB_UPDATE messages, and ending with VHOST_IOTLB_BATCH_END.
68+ * When one of these two values is used as the message type, the rest
69+ * of the fields in the message are ignored. There's no guarantee that
70+ * these changes take place automatically in the device.
71+ */
72+#define VHOST_IOTLB_BATCH_BEGIN 5
73+#define VHOST_IOTLB_BATCH_END 6
6374 __u8 type;
6475 };
6576