| .. | .. |
|---|
| 11 | 11 | * device configuration. |
|---|
| 12 | 12 | */ |
|---|
| 13 | 13 | |
|---|
| 14 | +#include <linux/vhost_types.h> |
|---|
| 14 | 15 | #include <linux/types.h> |
|---|
| 15 | | -#include <linux/compiler.h> |
|---|
| 16 | 16 | #include <linux/ioctl.h> |
|---|
| 17 | | -#include <linux/virtio_config.h> |
|---|
| 18 | | -#include <linux/virtio_ring.h> |
|---|
| 19 | 17 | |
|---|
| 20 | | -struct vhost_vring_state { |
|---|
| 21 | | - unsigned int index; |
|---|
| 22 | | - unsigned int num; |
|---|
| 23 | | -}; |
|---|
| 24 | | - |
|---|
| 25 | | -struct vhost_vring_file { |
|---|
| 26 | | - unsigned int index; |
|---|
| 27 | | - int fd; /* Pass -1 to unbind from file. */ |
|---|
| 28 | | - |
|---|
| 29 | | -}; |
|---|
| 30 | | - |
|---|
| 31 | | -struct vhost_vring_addr { |
|---|
| 32 | | - unsigned int index; |
|---|
| 33 | | - /* Option flags. */ |
|---|
| 34 | | - unsigned int flags; |
|---|
| 35 | | - /* Flag values: */ |
|---|
| 36 | | - /* Whether log address is valid. If set enables logging. */ |
|---|
| 37 | | -#define VHOST_VRING_F_LOG 0 |
|---|
| 38 | | - |
|---|
| 39 | | - /* Start of array of descriptors (virtually contiguous) */ |
|---|
| 40 | | - __u64 desc_user_addr; |
|---|
| 41 | | - /* Used structure address. Must be 32 bit aligned */ |
|---|
| 42 | | - __u64 used_user_addr; |
|---|
| 43 | | - /* Available structure address. Must be 16 bit aligned */ |
|---|
| 44 | | - __u64 avail_user_addr; |
|---|
| 45 | | - /* Logging support. */ |
|---|
| 46 | | - /* Log writes to used structure, at offset calculated from specified |
|---|
| 47 | | - * address. Address must be 32 bit aligned. */ |
|---|
| 48 | | - __u64 log_guest_addr; |
|---|
| 49 | | -}; |
|---|
| 50 | | - |
|---|
| 51 | | -/* no alignment requirement */ |
|---|
| 52 | | -struct vhost_iotlb_msg { |
|---|
| 53 | | - __u64 iova; |
|---|
| 54 | | - __u64 size; |
|---|
| 55 | | - __u64 uaddr; |
|---|
| 56 | | -#define VHOST_ACCESS_RO 0x1 |
|---|
| 57 | | -#define VHOST_ACCESS_WO 0x2 |
|---|
| 58 | | -#define VHOST_ACCESS_RW 0x3 |
|---|
| 59 | | - __u8 perm; |
|---|
| 60 | | -#define VHOST_IOTLB_MISS 1 |
|---|
| 61 | | -#define VHOST_IOTLB_UPDATE 2 |
|---|
| 62 | | -#define VHOST_IOTLB_INVALIDATE 3 |
|---|
| 63 | | -#define VHOST_IOTLB_ACCESS_FAIL 4 |
|---|
| 64 | | - __u8 type; |
|---|
| 65 | | -}; |
|---|
| 66 | | - |
|---|
| 67 | | -#define VHOST_IOTLB_MSG 0x1 |
|---|
| 68 | | -#define VHOST_IOTLB_MSG_V2 0x2 |
|---|
| 69 | | - |
|---|
| 70 | | -struct vhost_msg { |
|---|
| 71 | | - int type; |
|---|
| 72 | | - union { |
|---|
| 73 | | - struct vhost_iotlb_msg iotlb; |
|---|
| 74 | | - __u8 padding[64]; |
|---|
| 75 | | - }; |
|---|
| 76 | | -}; |
|---|
| 77 | | - |
|---|
| 78 | | -struct vhost_msg_v2 { |
|---|
| 79 | | - __u32 type; |
|---|
| 80 | | - __u32 reserved; |
|---|
| 81 | | - union { |
|---|
| 82 | | - struct vhost_iotlb_msg iotlb; |
|---|
| 83 | | - __u8 padding[64]; |
|---|
| 84 | | - }; |
|---|
| 85 | | -}; |
|---|
| 86 | | - |
|---|
| 87 | | -struct vhost_memory_region { |
|---|
| 88 | | - __u64 guest_phys_addr; |
|---|
| 89 | | - __u64 memory_size; /* bytes */ |
|---|
| 90 | | - __u64 userspace_addr; |
|---|
| 91 | | - __u64 flags_padding; /* No flags are currently specified. */ |
|---|
| 92 | | -}; |
|---|
| 93 | | - |
|---|
| 94 | | -/* All region addresses and sizes must be 4K aligned. */ |
|---|
| 95 | | -#define VHOST_PAGE_SIZE 0x1000 |
|---|
| 96 | | - |
|---|
| 97 | | -struct vhost_memory { |
|---|
| 98 | | - __u32 nregions; |
|---|
| 99 | | - __u32 padding; |
|---|
| 100 | | - struct vhost_memory_region regions[0]; |
|---|
| 101 | | -}; |
|---|
| 18 | +#define VHOST_FILE_UNBIND -1 |
|---|
| 102 | 19 | |
|---|
| 103 | 20 | /* ioctls */ |
|---|
| 104 | 21 | |
|---|
| .. | .. |
|---|
| 174 | 91 | |
|---|
| 175 | 92 | /* Use message type V2 */ |
|---|
| 176 | 93 | #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 |
|---|
| 94 | +/* IOTLB can accept batching hints */ |
|---|
| 95 | +#define VHOST_BACKEND_F_IOTLB_BATCH 0x2 |
|---|
| 177 | 96 | |
|---|
| 178 | 97 | #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) |
|---|
| 179 | 98 | #define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) |
|---|
| .. | .. |
|---|
| 186 | 105 | * device. This can be used to stop the ring (e.g. for migration). */ |
|---|
| 187 | 106 | #define VHOST_NET_SET_BACKEND _IOW(VHOST_VIRTIO, 0x30, struct vhost_vring_file) |
|---|
| 188 | 107 | |
|---|
| 189 | | -/* Feature bits */ |
|---|
| 190 | | -/* Log all write descriptors. Can be changed while device is active. */ |
|---|
| 191 | | -#define VHOST_F_LOG_ALL 26 |
|---|
| 192 | | -/* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */ |
|---|
| 193 | | -#define VHOST_NET_F_VIRTIO_NET_HDR 27 |
|---|
| 194 | | - |
|---|
| 195 | | -/* VHOST_SCSI specific definitions */ |
|---|
| 196 | | - |
|---|
| 197 | | -/* |
|---|
| 198 | | - * Used by QEMU userspace to ensure a consistent vhost-scsi ABI. |
|---|
| 199 | | - * |
|---|
| 200 | | - * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate + |
|---|
| 201 | | - * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage |
|---|
| 202 | | - * ABI Rev 1: January 2013. Ignore vhost_tpgt filed in struct vhost_scsi_target. |
|---|
| 203 | | - * All the targets under vhost_wwpn can be seen and used by guset. |
|---|
| 204 | | - */ |
|---|
| 205 | | - |
|---|
| 206 | | -#define VHOST_SCSI_ABI_VERSION 1 |
|---|
| 207 | | - |
|---|
| 208 | | -struct vhost_scsi_target { |
|---|
| 209 | | - int abi_version; |
|---|
| 210 | | - char vhost_wwpn[224]; /* TRANSPORT_IQN_LEN */ |
|---|
| 211 | | - unsigned short vhost_tpgt; |
|---|
| 212 | | - unsigned short reserved; |
|---|
| 213 | | -}; |
|---|
| 108 | +/* VHOST_SCSI specific defines */ |
|---|
| 214 | 109 | |
|---|
| 215 | 110 | #define VHOST_SCSI_SET_ENDPOINT _IOW(VHOST_VIRTIO, 0x40, struct vhost_scsi_target) |
|---|
| 216 | 111 | #define VHOST_SCSI_CLEAR_ENDPOINT _IOW(VHOST_VIRTIO, 0x41, struct vhost_scsi_target) |
|---|
| .. | .. |
|---|
| 225 | 120 | #define VHOST_VSOCK_SET_GUEST_CID _IOW(VHOST_VIRTIO, 0x60, __u64) |
|---|
| 226 | 121 | #define VHOST_VSOCK_SET_RUNNING _IOW(VHOST_VIRTIO, 0x61, int) |
|---|
| 227 | 122 | |
|---|
| 123 | +/* VHOST_VDPA specific defines */ |
|---|
| 124 | + |
|---|
| 125 | +/* Get the device id. The device ids follow the same definition of |
|---|
| 126 | + * the device id defined in virtio-spec. |
|---|
| 127 | + */ |
|---|
| 128 | +#define VHOST_VDPA_GET_DEVICE_ID _IOR(VHOST_VIRTIO, 0x70, __u32) |
|---|
| 129 | +/* Get and set the status. The status bits follow the same definition |
|---|
| 130 | + * of the device status defined in virtio-spec. |
|---|
| 131 | + */ |
|---|
| 132 | +#define VHOST_VDPA_GET_STATUS _IOR(VHOST_VIRTIO, 0x71, __u8) |
|---|
| 133 | +#define VHOST_VDPA_SET_STATUS _IOW(VHOST_VIRTIO, 0x72, __u8) |
|---|
| 134 | +/* Get and set the device config. The device config follows the same |
|---|
| 135 | + * definition of the device config defined in virtio-spec. |
|---|
| 136 | + */ |
|---|
| 137 | +#define VHOST_VDPA_GET_CONFIG _IOR(VHOST_VIRTIO, 0x73, \ |
|---|
| 138 | + struct vhost_vdpa_config) |
|---|
| 139 | +#define VHOST_VDPA_SET_CONFIG _IOW(VHOST_VIRTIO, 0x74, \ |
|---|
| 140 | + struct vhost_vdpa_config) |
|---|
| 141 | +/* Enable/disable the ring. */ |
|---|
| 142 | +#define VHOST_VDPA_SET_VRING_ENABLE _IOW(VHOST_VIRTIO, 0x75, \ |
|---|
| 143 | + struct vhost_vring_state) |
|---|
| 144 | +/* Get the max ring size. */ |
|---|
| 145 | +#define VHOST_VDPA_GET_VRING_NUM _IOR(VHOST_VIRTIO, 0x76, __u16) |
|---|
| 146 | + |
|---|
| 147 | +/* Set event fd for config interrupt*/ |
|---|
| 148 | +#define VHOST_VDPA_SET_CONFIG_CALL _IOW(VHOST_VIRTIO, 0x77, int) |
|---|
| 149 | + |
|---|
| 150 | +/* Get the valid iova range */ |
|---|
| 151 | +#define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \ |
|---|
| 152 | + struct vhost_vdpa_iova_range) |
|---|
| 228 | 153 | #endif |
|---|