FILE
vhost_types.h
File preview with syntax highlighting.
linux-6.19.14/include/uapi/linux/vhost_types.h
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2#ifndef _LINUX_VHOST_TYPES_H 3#define _LINUX_VHOST_TYPES_H 4/* Userspace interface for in-kernel virtio accelerators. */ 5 6/* vhost is used to reduce the number of system calls involved in virtio. 7 * 8 * Existing virtio net code is used in the guest without modification. 9 * 10 * This header includes interface used by userspace hypervisor for 11 * device configuration. 12 */ 13 14#include <linux/types.h> 15#include <linux/compiler.h> 16#include <linux/virtio_config.h> 17#include <linux/virtio_ring.h> 18 19struct vhost_vring_state { 20 unsigned int index; 21 unsigned int num; 22}; 23 24struct vhost_vring_file { 25 unsigned int index; 26 int fd; /* Pass -1 to unbind from file. */ 27 28}; 29 30struct vhost_vring_addr { 31 unsigned int index; 32 /* Option flags. */ 33 unsigned int flags; 34 /* Flag values: */ 35 /* Whether log address is valid. If set enables logging. */ 36#define VHOST_VRING_F_LOG 0 37 38 /* Start of array of descriptors (virtually contiguous) */ 39 __u64 desc_user_addr; 40 /* Used structure address. Must be 32 bit aligned */ 41 __u64 used_user_addr; 42 /* Available structure address. Must be 16 bit aligned */ 43 __u64 avail_user_addr; 44 /* Logging support. */ 45 /* Log writes to used structure, at offset calculated from specified 46 * address. Address must be 32 bit aligned. */ 47 __u64 log_guest_addr; 48}; 49 50struct vhost_worker_state { 51 /* 52 * For VHOST_NEW_WORKER the kernel will return the new vhost_worker id. 53 * For VHOST_FREE_WORKER this must be set to the id of the vhost_worker 54 * to free. 55 */ 56 unsigned int worker_id; 57}; 58 59struct vhost_vring_worker { 60 /* vring index */ 61 unsigned int index; 62 /* The id of the vhost_worker returned from VHOST_NEW_WORKER */ 63 unsigned int worker_id; 64}; 65 66/* no alignment requirement */ 67struct vhost_iotlb_msg { 68 __u64 iova; 69 __u64 size; 70 __u64 uaddr; 71#define VHOST_ACCESS_RO 0x1 72#define VHOST_ACCESS_WO 0x2 73#define VHOST_ACCESS_RW 0x3 74 __u8 perm; 75#define VHOST_IOTLB_MISS 1 76#define VHOST_IOTLB_UPDATE 2 77#define VHOST_IOTLB_INVALIDATE 3 78#define VHOST_IOTLB_ACCESS_FAIL 4 79/* 80 * VHOST_IOTLB_BATCH_BEGIN and VHOST_IOTLB_BATCH_END allow modifying 81 * multiple mappings in one go: beginning with 82 * VHOST_IOTLB_BATCH_BEGIN, followed by any number of 83 * VHOST_IOTLB_UPDATE messages, and ending with VHOST_IOTLB_BATCH_END. 84 * When one of these two values is used as the message type, the rest 85 * of the fields in the message are ignored. There's no guarantee that 86 * these changes take place automatically in the device. 87 */ 88#define VHOST_IOTLB_BATCH_BEGIN 5 89#define VHOST_IOTLB_BATCH_END 6 90 __u8 type; 91}; 92 93#define VHOST_IOTLB_MSG 0x1 94#define VHOST_IOTLB_MSG_V2 0x2 95 96struct vhost_msg { 97 int type; 98 union { 99 struct vhost_iotlb_msg iotlb; 100 __u8 padding[64]; 101 }; 102}; 103 104struct vhost_msg_v2 { 105 __u32 type; 106 __u32 asid; 107 union { 108 struct vhost_iotlb_msg iotlb; 109 __u8 padding[64]; 110 }; 111}; 112 113struct vhost_features_array { 114 __u64 count; /* number of entries present in features array */ 115 __u64 features[] __counted_by(count); 116}; 117 118struct vhost_memory_region { 119 __u64 guest_phys_addr; 120 __u64 memory_size; /* bytes */ 121 __u64 userspace_addr; 122 __u64 flags_padding; /* No flags are currently specified. */ 123}; 124 125/* All region addresses and sizes must be 4K aligned. */ 126#define VHOST_PAGE_SIZE 0x1000 127 128struct vhost_memory { 129 __u32 nregions; 130 __u32 padding; 131 struct vhost_memory_region regions[]; 132}; 133 134/* VHOST_SCSI specific definitions */ 135 136/* 137 * Used by QEMU userspace to ensure a consistent vhost-scsi ABI. 138 * 139 * ABI Rev 0: July 2012 version starting point for v3.6-rc merge candidate + 140 * RFC-v2 vhost-scsi userspace. Add GET_ABI_VERSION ioctl usage 141 * ABI Rev 1: January 2013. Ignore vhost_tpgt field in struct vhost_scsi_target. 142 * All the targets under vhost_wwpn can be seen and used by guset. 143 */ 144 145#define VHOST_SCSI_ABI_VERSION 1 146 147struct vhost_scsi_target { 148 int abi_version; 149 char vhost_wwpn[224]; /* TRANSPORT_IQN_LEN */ 150 unsigned short vhost_tpgt; 151 unsigned short reserved; 152}; 153 154/* VHOST_VDPA specific definitions */ 155 156struct vhost_vdpa_config { 157 __u32 off; 158 __u32 len; 159 __u8 buf[]; 160}; 161 162/* vhost vdpa IOVA range 163 * @first: First address that can be mapped by vhost-vDPA 164 * @last: Last address that can be mapped by vhost-vDPA 165 */ 166struct vhost_vdpa_iova_range { 167 __u64 first; 168 __u64 last; 169}; 170 171/* Feature bits */ 172/* Log all write descriptors. Can be changed while device is active. */ 173#define VHOST_F_LOG_ALL 26 174/* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */ 175#define VHOST_NET_F_VIRTIO_NET_HDR 27 176 177/* Use message type V2 */ 178#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 179/* IOTLB can accept batching hints */ 180#define VHOST_BACKEND_F_IOTLB_BATCH 0x2 181/* IOTLB can accept address space identifier through V2 type of IOTLB 182 * message 183 */ 184#define VHOST_BACKEND_F_IOTLB_ASID 0x3 185/* Device can be suspended */ 186#define VHOST_BACKEND_F_SUSPEND 0x4 187/* Device can be resumed */ 188#define VHOST_BACKEND_F_RESUME 0x5 189/* Device supports the driver enabling virtqueues both before and after 190 * DRIVER_OK 191 */ 192#define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK 0x6 193/* Device may expose the virtqueue's descriptor area, driver area and 194 * device area to a different group for ASID binding than where its 195 * buffers may reside. Requires VHOST_BACKEND_F_IOTLB_ASID. 196 */ 197#define VHOST_BACKEND_F_DESC_ASID 0x7 198/* IOTLB don't flush memory mapping across device reset */ 199#define VHOST_BACKEND_F_IOTLB_PERSIST 0x8 200 201#endif
~/
Read-only file preview.