• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This header was generated from the Linux kernel headers by update_headers.py,
3  * to provide necessary information from kernel to userspace, such as constants,
4  * structures, and macros, and thus, contains no copyrightable information.
5  */
6 #ifndef _UAPIVFIO_H
7 #define _UAPIVFIO_H
8 #include <linux/types.h>
9 #include <linux/ioctl.h>
10 #define VFIO_API_VERSION	0
11 #define VFIO_TYPE1_IOMMU		1
12 #define VFIO_SPAPR_TCE_IOMMU		2
13 #define VFIO_TYPE1v2_IOMMU		3
14 #define VFIO_DMA_CC_IOMMU		4
15 #define VFIO_EEH			5
16 #define VFIO_TYPE1_NESTING_IOMMU	6
17 #define VFIO_SPAPR_TCE_v2_IOMMU		7
18 #define VFIO_NOIOMMU_IOMMU		8
19 #define VFIO_TYPE	(';')
20 #define VFIO_BASE	100
21 struct vfio_info_cap_header {
22 	__u16	id;
23 	__u16	version;
24 	__u32	next;
25 };
26 #define VFIO_GET_API_VERSION		_IO(VFIO_TYPE, VFIO_BASE + 0)
27 #define VFIO_CHECK_EXTENSION		_IO(VFIO_TYPE, VFIO_BASE + 1)
28 #define VFIO_SET_IOMMU			_IO(VFIO_TYPE, VFIO_BASE + 2)
29 struct vfio_group_status {
30 	__u32	argsz;
31 	__u32	flags;
32 #define VFIO_GROUP_FLAGS_VIABLE		(1 << 0)
33 #define VFIO_GROUP_FLAGS_CONTAINER_SET	(1 << 1)
34 };
35 #define VFIO_GROUP_GET_STATUS		_IO(VFIO_TYPE, VFIO_BASE + 3)
36 #define VFIO_GROUP_SET_CONTAINER	_IO(VFIO_TYPE, VFIO_BASE + 4)
37 #define VFIO_GROUP_UNSET_CONTAINER	_IO(VFIO_TYPE, VFIO_BASE + 5)
38 #define VFIO_GROUP_GET_DEVICE_FD	_IO(VFIO_TYPE, VFIO_BASE + 6)
39 struct vfio_device_info {
40 	__u32	argsz;
41 	__u32	flags;
42 #define VFIO_DEVICE_FLAGS_RESET	(1 << 0)
43 #define VFIO_DEVICE_FLAGS_PCI	(1 << 1)
44 #define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2)
45 #define VFIO_DEVICE_FLAGS_AMBA  (1 << 3)
46 #define VFIO_DEVICE_FLAGS_CCW	(1 << 4)
47 	__u32	num_regions;
48 	__u32	num_irqs;
49 };
50 #define VFIO_DEVICE_GET_INFO		_IO(VFIO_TYPE, VFIO_BASE + 7)
51 #define VFIO_DEVICE_API_PCI_STRING		"vfio-pci"
52 #define VFIO_DEVICE_API_PLATFORM_STRING		"vfio-platform"
53 #define VFIO_DEVICE_API_AMBA_STRING		"vfio-amba"
54 #define VFIO_DEVICE_API_CCW_STRING		"vfio-ccw"
55 struct vfio_region_info {
56 	__u32	argsz;
57 	__u32	flags;
58 #define VFIO_REGION_INFO_FLAG_READ	(1 << 0)
59 #define VFIO_REGION_INFO_FLAG_WRITE	(1 << 1)
60 #define VFIO_REGION_INFO_FLAG_MMAP	(1 << 2)
61 #define VFIO_REGION_INFO_FLAG_CAPS	(1 << 3)
62 	__u32	index;
63 	__u32	cap_offset;
64 	__u64	size;
65 	__u64	offset;
66 };
67 #define VFIO_DEVICE_GET_REGION_INFO	_IO(VFIO_TYPE, VFIO_BASE + 8)
68 #define VFIO_REGION_INFO_CAP_SPARSE_MMAP	1
69 struct vfio_region_sparse_mmap_area {
70 	__u64	offset;
71 	__u64	size;
72 };
73 struct vfio_region_info_cap_sparse_mmap {
74 	struct vfio_info_cap_header header;
75 	__u32	nr_areas;
76 	__u32	reserved;
77 	struct vfio_region_sparse_mmap_area areas[];
78 };
79 #define VFIO_REGION_INFO_CAP_TYPE	2
80 struct vfio_region_info_cap_type {
81 	struct vfio_info_cap_header header;
82 	__u32 type;
83 	__u32 subtype;
84 };
85 #define VFIO_REGION_TYPE_PCI_VENDOR_TYPE	(1 << 31)
86 #define VFIO_REGION_TYPE_PCI_VENDOR_MASK	(0xffff)
87 #define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION	(1)
88 #define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG	(2)
89 #define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG	(3)
90 #define VFIO_REGION_INFO_CAP_MSIX_MAPPABLE	3
91 struct vfio_irq_info {
92 	__u32	argsz;
93 	__u32	flags;
94 #define VFIO_IRQ_INFO_EVENTFD		(1 << 0)
95 #define VFIO_IRQ_INFO_MASKABLE		(1 << 1)
96 #define VFIO_IRQ_INFO_AUTOMASKED	(1 << 2)
97 #define VFIO_IRQ_INFO_NORESIZE		(1 << 3)
98 	__u32	index;
99 	__u32	count;
100 };
101 #define VFIO_DEVICE_GET_IRQ_INFO	_IO(VFIO_TYPE, VFIO_BASE + 9)
102 struct vfio_irq_set {
103 	__u32	argsz;
104 	__u32	flags;
105 #define VFIO_IRQ_SET_DATA_NONE		(1 << 0)
106 #define VFIO_IRQ_SET_DATA_BOOL		(1 << 1)
107 #define VFIO_IRQ_SET_DATA_EVENTFD	(1 << 2)
108 #define VFIO_IRQ_SET_ACTION_MASK	(1 << 3)
109 #define VFIO_IRQ_SET_ACTION_UNMASK	(1 << 4)
110 #define VFIO_IRQ_SET_ACTION_TRIGGER	(1 << 5)
111 	__u32	index;
112 	__u32	start;
113 	__u32	count;
114 	__u8	data[];
115 };
116 #define VFIO_DEVICE_SET_IRQS		_IO(VFIO_TYPE, VFIO_BASE + 10)
117 #define VFIO_IRQ_SET_DATA_TYPE_MASK	(VFIO_IRQ_SET_DATA_NONE | \
118 					 VFIO_IRQ_SET_DATA_BOOL | \
119 					 VFIO_IRQ_SET_DATA_EVENTFD)
120 #define VFIO_IRQ_SET_ACTION_TYPE_MASK	(VFIO_IRQ_SET_ACTION_MASK | \
121 					 VFIO_IRQ_SET_ACTION_UNMASK | \
122 					 VFIO_IRQ_SET_ACTION_TRIGGER)
123 #define VFIO_DEVICE_RESET		_IO(VFIO_TYPE, VFIO_BASE + 11)
124 enum {
125 	VFIO_PCI_BAR0_REGION_INDEX,
126 	VFIO_PCI_BAR1_REGION_INDEX,
127 	VFIO_PCI_BAR2_REGION_INDEX,
128 	VFIO_PCI_BAR3_REGION_INDEX,
129 	VFIO_PCI_BAR4_REGION_INDEX,
130 	VFIO_PCI_BAR5_REGION_INDEX,
131 	VFIO_PCI_ROM_REGION_INDEX,
132 	VFIO_PCI_CONFIG_REGION_INDEX,
133 
134 	VFIO_PCI_VGA_REGION_INDEX,
135 	VFIO_PCI_NUM_REGIONS = 9
136 
137 };
138 enum {
139 	VFIO_PCI_INTX_IRQ_INDEX,
140 	VFIO_PCI_MSI_IRQ_INDEX,
141 	VFIO_PCI_MSIX_IRQ_INDEX,
142 	VFIO_PCI_ERR_IRQ_INDEX,
143 	VFIO_PCI_REQ_IRQ_INDEX,
144 	VFIO_PCI_NUM_IRQS
145 };
146 enum {
147 	VFIO_CCW_CONFIG_REGION_INDEX,
148 	VFIO_CCW_NUM_REGIONS
149 };
150 enum {
151 	VFIO_CCW_IO_IRQ_INDEX,
152 	VFIO_CCW_NUM_IRQS
153 };
154 struct vfio_pci_dependent_device {
155 	__u32	group_id;
156 	__u16	segment;
157 	__u8	bus;
158 	__u8	devfn;
159 };
160 struct vfio_pci_hot_reset_info {
161 	__u32	argsz;
162 	__u32	flags;
163 	__u32	count;
164 	struct vfio_pci_dependent_device	devices[];
165 };
166 #define VFIO_DEVICE_GET_PCI_HOT_RESET_INFO	_IO(VFIO_TYPE, VFIO_BASE + 12)
167 struct vfio_pci_hot_reset {
168 	__u32	argsz;
169 	__u32	flags;
170 	__u32	count;
171 	__s32	group_fds[];
172 };
173 #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE + 13)
174 struct vfio_device_gfx_plane_info {
175 	__u32 argsz;
176 	__u32 flags;
177 #define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0)
178 #define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1)
179 #define VFIO_GFX_PLANE_TYPE_REGION (1 << 2)
180 
181 	__u32 drm_plane_type;
182 
183 	__u32 drm_format;
184 	__u64 drm_format_mod;
185 	__u32 width;
186 	__u32 height;
187 	__u32 stride;
188 	__u32 size;
189 	__u32 x_pos;
190 	__u32 y_pos;
191 	__u32 x_hot;
192 	__u32 y_hot;
193 	union {
194 		__u32 region_index;
195 		__u32 dmabuf_id;
196 	};
197 };
198 #define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14)
199 #define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15)
200 struct vfio_device_ioeventfd {
201 	__u32	argsz;
202 	__u32	flags;
203 #define VFIO_DEVICE_IOEVENTFD_8		(1 << 0)
204 #define VFIO_DEVICE_IOEVENTFD_16	(1 << 1)
205 #define VFIO_DEVICE_IOEVENTFD_32	(1 << 2)
206 #define VFIO_DEVICE_IOEVENTFD_64	(1 << 3)
207 #define VFIO_DEVICE_IOEVENTFD_SIZE_MASK	(0xf)
208 	__u64	offset;
209 	__u64	data;
210 	__s32	fd;
211 };
212 #define VFIO_DEVICE_IOEVENTFD		_IO(VFIO_TYPE, VFIO_BASE + 16)
213 struct vfio_iommu_type1_info {
214 	__u32	argsz;
215 	__u32	flags;
216 #define VFIO_IOMMU_INFO_PGSIZES (1 << 0)
217 	__u64	iova_pgsizes;
218 };
219 #define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
220 struct vfio_iommu_type1_dma_map {
221 	__u32	argsz;
222 	__u32	flags;
223 #define VFIO_DMA_MAP_FLAG_READ (1 << 0)
224 #define VFIO_DMA_MAP_FLAG_WRITE (1 << 1)
225 	__u64	vaddr;
226 	__u64	iova;
227 	__u64	size;
228 };
229 #define VFIO_IOMMU_MAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 13)
230 struct vfio_iommu_type1_dma_unmap {
231 	__u32	argsz;
232 	__u32	flags;
233 	__u64	iova;
234 	__u64	size;
235 };
236 #define VFIO_IOMMU_UNMAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 14)
237 #define VFIO_IOMMU_ENABLE	_IO(VFIO_TYPE, VFIO_BASE + 15)
238 #define VFIO_IOMMU_DISABLE	_IO(VFIO_TYPE, VFIO_BASE + 16)
239 struct vfio_iommu_spapr_tce_ddw_info {
240 	__u64 pgsizes;
241 	__u32 max_dynamic_windows_supported;
242 	__u32 levels;
243 };
244 struct vfio_iommu_spapr_tce_info {
245 	__u32 argsz;
246 	__u32 flags;
247 #define VFIO_IOMMU_SPAPR_INFO_DDW	(1 << 0)
248 	__u32 dma32_window_start;
249 	__u32 dma32_window_size;
250 	struct vfio_iommu_spapr_tce_ddw_info ddw;
251 };
252 #define VFIO_IOMMU_SPAPR_TCE_GET_INFO	_IO(VFIO_TYPE, VFIO_BASE + 12)
253 struct vfio_eeh_pe_err {
254 	__u32 type;
255 	__u32 func;
256 	__u64 addr;
257 	__u64 mask;
258 };
259 struct vfio_eeh_pe_op {
260 	__u32 argsz;
261 	__u32 flags;
262 	__u32 op;
263 	union {
264 		struct vfio_eeh_pe_err err;
265 	};
266 };
267 #define VFIO_EEH_PE_DISABLE		0
268 #define VFIO_EEH_PE_ENABLE		1
269 #define VFIO_EEH_PE_UNFREEZE_IO		2
270 #define VFIO_EEH_PE_UNFREEZE_DMA	3
271 #define VFIO_EEH_PE_GET_STATE		4
272 #define  VFIO_EEH_PE_STATE_NORMAL	0
273 #define  VFIO_EEH_PE_STATE_RESET	1
274 #define  VFIO_EEH_PE_STATE_STOPPED	2
275 #define  VFIO_EEH_PE_STATE_STOPPED_DMA	4
276 #define  VFIO_EEH_PE_STATE_UNAVAIL	5
277 #define VFIO_EEH_PE_RESET_DEACTIVATE	5
278 #define VFIO_EEH_PE_RESET_HOT		6
279 #define VFIO_EEH_PE_RESET_FUNDAMENTAL	7
280 #define VFIO_EEH_PE_CONFIGURE		8
281 #define VFIO_EEH_PE_INJECT_ERR		9
282 #define VFIO_EEH_PE_OP			_IO(VFIO_TYPE, VFIO_BASE + 21)
283 struct vfio_iommu_spapr_register_memory {
284 	__u32	argsz;
285 	__u32	flags;
286 	__u64	vaddr;
287 	__u64	size;
288 };
289 #define VFIO_IOMMU_SPAPR_REGISTER_MEMORY	_IO(VFIO_TYPE, VFIO_BASE + 17)
290 #define VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY	_IO(VFIO_TYPE, VFIO_BASE + 18)
291 struct vfio_iommu_spapr_tce_create {
292 	__u32 argsz;
293 	__u32 flags;
294 
295 	__u32 page_shift;
296 	__u32 __resv1;
297 	__u64 window_size;
298 	__u32 levels;
299 	__u32 __resv2;
300 
301 	__u64 start_addr;
302 };
303 #define VFIO_IOMMU_SPAPR_TCE_CREATE	_IO(VFIO_TYPE, VFIO_BASE + 19)
304 struct vfio_iommu_spapr_tce_remove {
305 	__u32 argsz;
306 	__u32 flags;
307 
308 	__u64 start_addr;
309 };
310 #define VFIO_IOMMU_SPAPR_TCE_REMOVE	_IO(VFIO_TYPE, VFIO_BASE + 20)
311 #endif
312