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.
Showing the changes to include/uapi/linux (2 of 3 files). Show all
Unified · Split
| @@ -91,6 +91,8 @@ · 90 unmodified lines | ||
| 91 | 91 | |
| 92 | 92 | /* Use message type V2 */ |
| 93 | 93 | #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 |
| 94 | +/* IOTLB can accept batching hints */ | |
| 95 | +#define VHOST_BACKEND_F_IOTLB_BATCH 0x2 | |
| 94 | 96 | |
| 95 | 97 | #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) |
| 96 | 98 | #define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) |
| @@ -60,6 +60,17 @@ struct vhost_iotlb_msg { · 59 unmodified lines | ||
| 60 | 60 | #define VHOST_IOTLB_UPDATE 2 |
| 61 | 61 | #define VHOST_IOTLB_INVALIDATE 3 |
| 62 | 62 | #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 | |
| 63 | 74 | __u8 type; |
| 64 | 75 | }; |
| 65 | 76 | |