blob: b4042387e5b1ed13bb2a75670a7dc2341fa48e1b [file] [log] [blame]
Ben Cheng655a7c02013-10-16 16:09:24 -07001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef _UAPIVFIO_H
20#define _UAPIVFIO_H
21#include <linux/types.h>
22#include <linux/ioctl.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070023#define VFIO_API_VERSION 0
24#define VFIO_TYPE1_IOMMU 1
Christopher Ferris38062f92014-07-09 15:33:25 -070025#define VFIO_SPAPR_TCE_IOMMU 2
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070026#define VFIO_TYPE1v2_IOMMU 3
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070027#define VFIO_DMA_CC_IOMMU 4
Christopher Ferris82d75042015-01-26 10:57:07 -080028#define VFIO_EEH 5
29#define VFIO_TYPE1_NESTING_IOMMU 6
Christopher Ferris05d08e92016-02-04 13:16:38 -080030#define VFIO_SPAPR_TCE_v2_IOMMU 7
Christopher Ferris106b3a82016-08-24 12:15:38 -070031#define VFIO_NOIOMMU_IOMMU 8
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070032#define VFIO_UNMAP_ALL 9
33#define VFIO_UPDATE_VADDR 10
Christopher Ferris05d08e92016-02-04 13:16:38 -080034#define VFIO_TYPE (';')
Christopher Ferris38062f92014-07-09 15:33:25 -070035#define VFIO_BASE 100
Christopher Ferris106b3a82016-08-24 12:15:38 -070036struct vfio_info_cap_header {
Christopher Ferris106b3a82016-08-24 12:15:38 -070037 __u16 id;
38 __u16 version;
39 __u32 next;
40};
Ben Cheng655a7c02013-10-16 16:09:24 -070041#define VFIO_GET_API_VERSION _IO(VFIO_TYPE, VFIO_BASE + 0)
42#define VFIO_CHECK_EXTENSION _IO(VFIO_TYPE, VFIO_BASE + 1)
Christopher Ferris05d08e92016-02-04 13:16:38 -080043#define VFIO_SET_IOMMU _IO(VFIO_TYPE, VFIO_BASE + 2)
Christopher Ferris38062f92014-07-09 15:33:25 -070044struct vfio_group_status {
Tao Baod7db5942015-01-28 10:07:51 -080045 __u32 argsz;
46 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -080047#define VFIO_GROUP_FLAGS_VIABLE (1 << 0)
Christopher Ferris38062f92014-07-09 15:33:25 -070048#define VFIO_GROUP_FLAGS_CONTAINER_SET (1 << 1)
Ben Cheng655a7c02013-10-16 16:09:24 -070049};
50#define VFIO_GROUP_GET_STATUS _IO(VFIO_TYPE, VFIO_BASE + 3)
Christopher Ferris05d08e92016-02-04 13:16:38 -080051#define VFIO_GROUP_SET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 4)
Christopher Ferris38062f92014-07-09 15:33:25 -070052#define VFIO_GROUP_UNSET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 5)
Ben Cheng655a7c02013-10-16 16:09:24 -070053#define VFIO_GROUP_GET_DEVICE_FD _IO(VFIO_TYPE, VFIO_BASE + 6)
54struct vfio_device_info {
Christopher Ferris05d08e92016-02-04 13:16:38 -080055 __u32 argsz;
Tao Baod7db5942015-01-28 10:07:51 -080056 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -070057#define VFIO_DEVICE_FLAGS_RESET (1 << 0)
58#define VFIO_DEVICE_FLAGS_PCI (1 << 1)
Christopher Ferris05d08e92016-02-04 13:16:38 -080059#define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2)
60#define VFIO_DEVICE_FLAGS_AMBA (1 << 3)
Christopher Ferris525ce912017-07-26 13:12:53 -070061#define VFIO_DEVICE_FLAGS_CCW (1 << 4)
Christopher Ferris86a48372019-01-10 14:14:59 -080062#define VFIO_DEVICE_FLAGS_AP (1 << 5)
Christopher Ferris32ff3f82020-12-14 13:10:04 -080063#define VFIO_DEVICE_FLAGS_FSL_MC (1 << 6)
64#define VFIO_DEVICE_FLAGS_CAPS (1 << 7)
Christopher Ferris8666d042023-09-06 14:55:31 -070065#define VFIO_DEVICE_FLAGS_CDX (1 << 8)
Christopher Ferris05d08e92016-02-04 13:16:38 -080066 __u32 num_regions;
Tao Baod7db5942015-01-28 10:07:51 -080067 __u32 num_irqs;
Christopher Ferris32ff3f82020-12-14 13:10:04 -080068 __u32 cap_offset;
Ben Cheng655a7c02013-10-16 16:09:24 -070069};
70#define VFIO_DEVICE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 7)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080071#define VFIO_DEVICE_API_PCI_STRING "vfio-pci"
72#define VFIO_DEVICE_API_PLATFORM_STRING "vfio-platform"
73#define VFIO_DEVICE_API_AMBA_STRING "vfio-amba"
Christopher Ferris525ce912017-07-26 13:12:53 -070074#define VFIO_DEVICE_API_CCW_STRING "vfio-ccw"
Christopher Ferris86a48372019-01-10 14:14:59 -080075#define VFIO_DEVICE_API_AP_STRING "vfio-ap"
Christopher Ferris32ff3f82020-12-14 13:10:04 -080076#define VFIO_DEVICE_INFO_CAP_ZPCI_BASE 1
77#define VFIO_DEVICE_INFO_CAP_ZPCI_GROUP 2
78#define VFIO_DEVICE_INFO_CAP_ZPCI_UTIL 3
79#define VFIO_DEVICE_INFO_CAP_ZPCI_PFIP 4
Christopher Ferris8666d042023-09-06 14:55:31 -070080#define VFIO_DEVICE_INFO_CAP_PCI_ATOMIC_COMP 5
81struct vfio_device_info_cap_pci_atomic_comp {
82 struct vfio_info_cap_header header;
83 __u32 flags;
84#define VFIO_PCI_ATOMIC_COMP32 (1 << 0)
85#define VFIO_PCI_ATOMIC_COMP64 (1 << 1)
86#define VFIO_PCI_ATOMIC_COMP128 (1 << 2)
87 __u32 reserved;
88};
Ben Cheng655a7c02013-10-16 16:09:24 -070089struct vfio_region_info {
Tao Baod7db5942015-01-28 10:07:51 -080090 __u32 argsz;
91 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -070092#define VFIO_REGION_INFO_FLAG_READ (1 << 0)
93#define VFIO_REGION_INFO_FLAG_WRITE (1 << 1)
Christopher Ferris38062f92014-07-09 15:33:25 -070094#define VFIO_REGION_INFO_FLAG_MMAP (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -070095#define VFIO_REGION_INFO_FLAG_CAPS (1 << 3)
Tao Baod7db5942015-01-28 10:07:51 -080096 __u32 index;
Christopher Ferris106b3a82016-08-24 12:15:38 -070097 __u32 cap_offset;
Tao Baod7db5942015-01-28 10:07:51 -080098 __u64 size;
Tao Baod7db5942015-01-28 10:07:51 -080099 __u64 offset;
Ben Cheng655a7c02013-10-16 16:09:24 -0700100};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700101#define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8)
102#define VFIO_REGION_INFO_CAP_SPARSE_MMAP 1
103struct vfio_region_sparse_mmap_area {
104 __u64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700105 __u64 size;
106};
107struct vfio_region_info_cap_sparse_mmap {
108 struct vfio_info_cap_header header;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700109 __u32 nr_areas;
110 __u32 reserved;
111 struct vfio_region_sparse_mmap_area areas[];
112};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700113#define VFIO_REGION_INFO_CAP_TYPE 2
114struct vfio_region_info_cap_type {
115 struct vfio_info_cap_header header;
116 __u32 type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700117 __u32 subtype;
118};
119#define VFIO_REGION_TYPE_PCI_VENDOR_TYPE (1 << 31)
120#define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800121#define VFIO_REGION_TYPE_GFX (1)
122#define VFIO_REGION_TYPE_CCW (2)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700123#define VFIO_REGION_TYPE_MIGRATION_DEPRECATED (3)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700124#define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION (1)
125#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2)
126#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800127#define VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM (1)
128#define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD (1)
Christopher Ferris86a48372019-01-10 14:14:59 -0800129#define VFIO_REGION_SUBTYPE_GFX_EDID (1)
130struct vfio_region_gfx_edid {
131 __u32 edid_offset;
132 __u32 edid_max_size;
133 __u32 edid_size;
134 __u32 max_xres;
135 __u32 max_yres;
136 __u32 link_state;
137#define VFIO_DEVICE_GFX_LINK_STATE_UP 1
138#define VFIO_DEVICE_GFX_LINK_STATE_DOWN 2
139};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700140#define VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD (1)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700141#define VFIO_REGION_SUBTYPE_CCW_SCHIB (2)
142#define VFIO_REGION_SUBTYPE_CCW_CRW (3)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700143#define VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED (1)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700144struct vfio_device_migration_info {
145 __u32 device_state;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700146#define VFIO_DEVICE_STATE_V1_STOP (0)
147#define VFIO_DEVICE_STATE_V1_RUNNING (1 << 0)
148#define VFIO_DEVICE_STATE_V1_SAVING (1 << 1)
149#define VFIO_DEVICE_STATE_V1_RESUMING (1 << 2)
150#define VFIO_DEVICE_STATE_MASK (VFIO_DEVICE_STATE_V1_RUNNING | VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING)
151#define VFIO_DEVICE_STATE_VALID(state) (state & VFIO_DEVICE_STATE_V1_RESUMING ? (state & VFIO_DEVICE_STATE_MASK) == VFIO_DEVICE_STATE_V1_RESUMING : 1)
152#define VFIO_DEVICE_STATE_IS_ERROR(state) ((state & VFIO_DEVICE_STATE_MASK) == (VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING))
153#define VFIO_DEVICE_STATE_SET_ERROR(state) ((state & ~VFIO_DEVICE_STATE_MASK) | VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700154 __u32 reserved;
155 __u64 pending_bytes;
156 __u64 data_offset;
157 __u64 data_size;
158};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700159#define VFIO_REGION_INFO_CAP_MSIX_MAPPABLE 3
Christopher Ferrisd842e432019-03-07 10:21:59 -0800160#define VFIO_REGION_INFO_CAP_NVLINK2_SSATGT 4
161struct vfio_region_info_cap_nvlink2_ssatgt {
162 struct vfio_info_cap_header header;
163 __u64 tgt;
164};
165#define VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD 5
166struct vfio_region_info_cap_nvlink2_lnkspd {
167 struct vfio_info_cap_header header;
168 __u32 link_speed;
169 __u32 __pad;
170};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700171struct vfio_irq_info {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700172 __u32 argsz;
Tao Baod7db5942015-01-28 10:07:51 -0800173 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700174#define VFIO_IRQ_INFO_EVENTFD (1 << 0)
175#define VFIO_IRQ_INFO_MASKABLE (1 << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700176#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700177#define VFIO_IRQ_INFO_NORESIZE (1 << 3)
Tao Baod7db5942015-01-28 10:07:51 -0800178 __u32 index;
179 __u32 count;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700180};
Ben Cheng655a7c02013-10-16 16:09:24 -0700181#define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE + 9)
182struct vfio_irq_set {
Tao Baod7db5942015-01-28 10:07:51 -0800183 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700184 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700185#define VFIO_IRQ_SET_DATA_NONE (1 << 0)
186#define VFIO_IRQ_SET_DATA_BOOL (1 << 1)
187#define VFIO_IRQ_SET_DATA_EVENTFD (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700188#define VFIO_IRQ_SET_ACTION_MASK (1 << 3)
Ben Cheng655a7c02013-10-16 16:09:24 -0700189#define VFIO_IRQ_SET_ACTION_UNMASK (1 << 4)
190#define VFIO_IRQ_SET_ACTION_TRIGGER (1 << 5)
Tao Baod7db5942015-01-28 10:07:51 -0800191 __u32 index;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700192 __u32 start;
Tao Baod7db5942015-01-28 10:07:51 -0800193 __u32 count;
194 __u8 data[];
Ben Cheng655a7c02013-10-16 16:09:24 -0700195};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700196#define VFIO_DEVICE_SET_IRQS _IO(VFIO_TYPE, VFIO_BASE + 10)
Tao Baod7db5942015-01-28 10:07:51 -0800197#define VFIO_IRQ_SET_DATA_TYPE_MASK (VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_DATA_BOOL | VFIO_IRQ_SET_DATA_EVENTFD)
198#define VFIO_IRQ_SET_ACTION_TYPE_MASK (VFIO_IRQ_SET_ACTION_MASK | VFIO_IRQ_SET_ACTION_UNMASK | VFIO_IRQ_SET_ACTION_TRIGGER)
Ben Cheng655a7c02013-10-16 16:09:24 -0700199#define VFIO_DEVICE_RESET _IO(VFIO_TYPE, VFIO_BASE + 11)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700200enum {
Tao Baod7db5942015-01-28 10:07:51 -0800201 VFIO_PCI_BAR0_REGION_INDEX,
202 VFIO_PCI_BAR1_REGION_INDEX,
203 VFIO_PCI_BAR2_REGION_INDEX,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700204 VFIO_PCI_BAR3_REGION_INDEX,
Tao Baod7db5942015-01-28 10:07:51 -0800205 VFIO_PCI_BAR4_REGION_INDEX,
206 VFIO_PCI_BAR5_REGION_INDEX,
207 VFIO_PCI_ROM_REGION_INDEX,
Tao Baod7db5942015-01-28 10:07:51 -0800208 VFIO_PCI_CONFIG_REGION_INDEX,
209 VFIO_PCI_VGA_REGION_INDEX,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700210 VFIO_PCI_NUM_REGIONS = 9
Ben Cheng655a7c02013-10-16 16:09:24 -0700211};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700212enum {
Tao Baod7db5942015-01-28 10:07:51 -0800213 VFIO_PCI_INTX_IRQ_INDEX,
214 VFIO_PCI_MSI_IRQ_INDEX,
215 VFIO_PCI_MSIX_IRQ_INDEX,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700216 VFIO_PCI_ERR_IRQ_INDEX,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800217 VFIO_PCI_REQ_IRQ_INDEX,
Tao Baod7db5942015-01-28 10:07:51 -0800218 VFIO_PCI_NUM_IRQS
Ben Cheng655a7c02013-10-16 16:09:24 -0700219};
Christopher Ferris525ce912017-07-26 13:12:53 -0700220enum {
221 VFIO_CCW_CONFIG_REGION_INDEX,
222 VFIO_CCW_NUM_REGIONS
223};
224enum {
225 VFIO_CCW_IO_IRQ_INDEX,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700226 VFIO_CCW_CRW_IRQ_INDEX,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800227 VFIO_CCW_REQ_IRQ_INDEX,
Christopher Ferris525ce912017-07-26 13:12:53 -0700228 VFIO_CCW_NUM_IRQS
229};
Christopher Ferris8666d042023-09-06 14:55:31 -0700230enum {
231 VFIO_AP_REQ_IRQ_INDEX,
232 VFIO_AP_NUM_IRQS
233};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700234struct vfio_pci_dependent_device {
Tao Baod7db5942015-01-28 10:07:51 -0800235 __u32 group_id;
236 __u16 segment;
237 __u8 bus;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700238 __u8 devfn;
Christopher Ferris38062f92014-07-09 15:33:25 -0700239};
240struct vfio_pci_hot_reset_info {
Tao Baod7db5942015-01-28 10:07:51 -0800241 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700242 __u32 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800243 __u32 count;
244 struct vfio_pci_dependent_device devices[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700245};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700246#define VFIO_DEVICE_GET_PCI_HOT_RESET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
Christopher Ferris38062f92014-07-09 15:33:25 -0700247struct vfio_pci_hot_reset {
Tao Baod7db5942015-01-28 10:07:51 -0800248 __u32 argsz;
249 __u32 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700250 __u32 count;
Tao Baod7db5942015-01-28 10:07:51 -0800251 __s32 group_fds[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700252};
253#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700254struct vfio_device_gfx_plane_info {
255 __u32 argsz;
256 __u32 flags;
257#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0)
258#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1)
259#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2)
260 __u32 drm_plane_type;
261 __u32 drm_format;
262 __u64 drm_format_mod;
263 __u32 width;
264 __u32 height;
265 __u32 stride;
266 __u32 size;
267 __u32 x_pos;
268 __u32 y_pos;
269 __u32 x_hot;
270 __u32 y_hot;
271 union {
272 __u32 region_index;
273 __u32 dmabuf_id;
274 };
275};
276#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14)
277#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15)
278struct vfio_device_ioeventfd {
279 __u32 argsz;
280 __u32 flags;
281#define VFIO_DEVICE_IOEVENTFD_8 (1 << 0)
282#define VFIO_DEVICE_IOEVENTFD_16 (1 << 1)
283#define VFIO_DEVICE_IOEVENTFD_32 (1 << 2)
284#define VFIO_DEVICE_IOEVENTFD_64 (1 << 3)
285#define VFIO_DEVICE_IOEVENTFD_SIZE_MASK (0xf)
286 __u64 offset;
287 __u64 data;
288 __s32 fd;
289};
290#define VFIO_DEVICE_IOEVENTFD _IO(VFIO_TYPE, VFIO_BASE + 16)
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700291struct vfio_device_feature {
292 __u32 argsz;
293 __u32 flags;
294#define VFIO_DEVICE_FEATURE_MASK (0xffff)
295#define VFIO_DEVICE_FEATURE_GET (1 << 16)
296#define VFIO_DEVICE_FEATURE_SET (1 << 17)
297#define VFIO_DEVICE_FEATURE_PROBE (1 << 18)
298 __u8 data[];
299};
300#define VFIO_DEVICE_FEATURE _IO(VFIO_TYPE, VFIO_BASE + 17)
301#define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN (0)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700302struct vfio_device_feature_migration {
303 __aligned_u64 flags;
304#define VFIO_MIGRATION_STOP_COPY (1 << 0)
305#define VFIO_MIGRATION_P2P (1 << 1)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800306#define VFIO_MIGRATION_PRE_COPY (1 << 2)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700307};
308#define VFIO_DEVICE_FEATURE_MIGRATION 1
309struct vfio_device_feature_mig_state {
310 __u32 device_state;
311 __s32 data_fd;
312};
313#define VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE 2
314enum vfio_device_mig_state {
315 VFIO_DEVICE_STATE_ERROR = 0,
316 VFIO_DEVICE_STATE_STOP = 1,
317 VFIO_DEVICE_STATE_RUNNING = 2,
318 VFIO_DEVICE_STATE_STOP_COPY = 3,
319 VFIO_DEVICE_STATE_RESUMING = 4,
320 VFIO_DEVICE_STATE_RUNNING_P2P = 5,
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800321 VFIO_DEVICE_STATE_PRE_COPY = 6,
322 VFIO_DEVICE_STATE_PRE_COPY_P2P = 7,
Christopher Ferris10a76e62022-06-08 13:31:52 -0700323};
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800324struct vfio_precopy_info {
325 __u32 argsz;
326 __u32 flags;
327 __aligned_u64 initial_bytes;
328 __aligned_u64 dirty_bytes;
329};
330#define VFIO_MIG_GET_PRECOPY_INFO _IO(VFIO_TYPE, VFIO_BASE + 21)
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000331#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY 3
332struct vfio_device_low_power_entry_with_wakeup {
333 __s32 wakeup_eventfd;
334 __u32 reserved;
335};
336#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP 4
337#define VFIO_DEVICE_FEATURE_LOW_POWER_EXIT 5
338struct vfio_device_feature_dma_logging_control {
339 __aligned_u64 page_size;
340 __u32 num_ranges;
341 __u32 __reserved;
342 __aligned_u64 ranges;
343};
344struct vfio_device_feature_dma_logging_range {
345 __aligned_u64 iova;
346 __aligned_u64 length;
347};
348#define VFIO_DEVICE_FEATURE_DMA_LOGGING_START 6
349#define VFIO_DEVICE_FEATURE_DMA_LOGGING_STOP 7
350struct vfio_device_feature_dma_logging_report {
351 __aligned_u64 iova;
352 __aligned_u64 length;
353 __aligned_u64 page_size;
354 __aligned_u64 bitmap;
355};
356#define VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT 8
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800357struct vfio_device_feature_mig_data_size {
358 __aligned_u64 stop_copy_length;
359};
360#define VFIO_DEVICE_FEATURE_MIG_DATA_SIZE 9
Christopher Ferris106b3a82016-08-24 12:15:38 -0700361struct vfio_iommu_type1_info {
Tao Baod7db5942015-01-28 10:07:51 -0800362 __u32 argsz;
363 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700364#define VFIO_IOMMU_INFO_PGSIZES (1 << 0)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800365#define VFIO_IOMMU_INFO_CAPS (1 << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700366 __u64 iova_pgsizes;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800367 __u32 cap_offset;
368};
369#define VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE 1
370struct vfio_iova_range {
371 __u64 start;
372 __u64 end;
373};
374struct vfio_iommu_type1_info_cap_iova_range {
375 struct vfio_info_cap_header header;
376 __u32 nr_iovas;
377 __u32 reserved;
378 struct vfio_iova_range iova_ranges[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700379};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700380#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 2
381struct vfio_iommu_type1_info_cap_migration {
382 struct vfio_info_cap_header header;
383 __u32 flags;
384 __u64 pgsize_bitmap;
385 __u64 max_dirty_bitmap_size;
386};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800387#define VFIO_IOMMU_TYPE1_INFO_DMA_AVAIL 3
388struct vfio_iommu_type1_info_dma_avail {
389 struct vfio_info_cap_header header;
390 __u32 avail;
391};
Ben Cheng655a7c02013-10-16 16:09:24 -0700392#define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
393struct vfio_iommu_type1_dma_map {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700394 __u32 argsz;
Tao Baod7db5942015-01-28 10:07:51 -0800395 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700396#define VFIO_DMA_MAP_FLAG_READ (1 << 0)
397#define VFIO_DMA_MAP_FLAG_WRITE (1 << 1)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700398#define VFIO_DMA_MAP_FLAG_VADDR (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700399 __u64 vaddr;
Tao Baod7db5942015-01-28 10:07:51 -0800400 __u64 iova;
401 __u64 size;
Ben Cheng655a7c02013-10-16 16:09:24 -0700402};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700403#define VFIO_IOMMU_MAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 13)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700404struct vfio_bitmap {
405 __u64 pgsize;
406 __u64 size;
Elliott Hughes0f0c18f2023-03-29 15:53:31 -0700407 __u64 * data;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700408};
Christopher Ferris38062f92014-07-09 15:33:25 -0700409struct vfio_iommu_type1_dma_unmap {
Tao Baod7db5942015-01-28 10:07:51 -0800410 __u32 argsz;
411 __u32 flags;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700412#define VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP (1 << 0)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700413#define VFIO_DMA_UNMAP_FLAG_ALL (1 << 1)
414#define VFIO_DMA_UNMAP_FLAG_VADDR (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700415 __u64 iova;
Tao Baod7db5942015-01-28 10:07:51 -0800416 __u64 size;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700417 __u8 data[];
Ben Cheng655a7c02013-10-16 16:09:24 -0700418};
419#define VFIO_IOMMU_UNMAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 14)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700420#define VFIO_IOMMU_ENABLE _IO(VFIO_TYPE, VFIO_BASE + 15)
Christopher Ferris38062f92014-07-09 15:33:25 -0700421#define VFIO_IOMMU_DISABLE _IO(VFIO_TYPE, VFIO_BASE + 16)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700422struct vfio_iommu_type1_dirty_bitmap {
423 __u32 argsz;
424 __u32 flags;
425#define VFIO_IOMMU_DIRTY_PAGES_FLAG_START (1 << 0)
426#define VFIO_IOMMU_DIRTY_PAGES_FLAG_STOP (1 << 1)
427#define VFIO_IOMMU_DIRTY_PAGES_FLAG_GET_BITMAP (1 << 2)
428 __u8 data[];
429};
430struct vfio_iommu_type1_dirty_bitmap_get {
431 __u64 iova;
432 __u64 size;
433 struct vfio_bitmap bitmap;
434};
435#define VFIO_IOMMU_DIRTY_PAGES _IO(VFIO_TYPE, VFIO_BASE + 17)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800436struct vfio_iommu_spapr_tce_ddw_info {
437 __u64 pgsizes;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700438 __u32 max_dynamic_windows_supported;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800439 __u32 levels;
440};
Christopher Ferris38062f92014-07-09 15:33:25 -0700441struct vfio_iommu_spapr_tce_info {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700442 __u32 argsz;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800443 __u32 flags;
444#define VFIO_IOMMU_SPAPR_INFO_DDW (1 << 0)
Tao Baod7db5942015-01-28 10:07:51 -0800445 __u32 dma32_window_start;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700446 __u32 dma32_window_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800447 struct vfio_iommu_spapr_tce_ddw_info ddw;
Christopher Ferris38062f92014-07-09 15:33:25 -0700448};
449#define VFIO_IOMMU_SPAPR_TCE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700450struct vfio_eeh_pe_err {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800451 __u32 type;
452 __u32 func;
453 __u64 addr;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700454 __u64 mask;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800455};
Christopher Ferris82d75042015-01-26 10:57:07 -0800456struct vfio_eeh_pe_op {
Tao Baod7db5942015-01-28 10:07:51 -0800457 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700458 __u32 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800459 __u32 op;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800460 union {
461 struct vfio_eeh_pe_err err;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700462 };
Christopher Ferris82d75042015-01-26 10:57:07 -0800463};
464#define VFIO_EEH_PE_DISABLE 0
465#define VFIO_EEH_PE_ENABLE 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700466#define VFIO_EEH_PE_UNFREEZE_IO 2
Christopher Ferris82d75042015-01-26 10:57:07 -0800467#define VFIO_EEH_PE_UNFREEZE_DMA 3
468#define VFIO_EEH_PE_GET_STATE 4
469#define VFIO_EEH_PE_STATE_NORMAL 0
Christopher Ferris106b3a82016-08-24 12:15:38 -0700470#define VFIO_EEH_PE_STATE_RESET 1
Christopher Ferris82d75042015-01-26 10:57:07 -0800471#define VFIO_EEH_PE_STATE_STOPPED 2
472#define VFIO_EEH_PE_STATE_STOPPED_DMA 4
473#define VFIO_EEH_PE_STATE_UNAVAIL 5
Christopher Ferris106b3a82016-08-24 12:15:38 -0700474#define VFIO_EEH_PE_RESET_DEACTIVATE 5
Christopher Ferris82d75042015-01-26 10:57:07 -0800475#define VFIO_EEH_PE_RESET_HOT 6
476#define VFIO_EEH_PE_RESET_FUNDAMENTAL 7
477#define VFIO_EEH_PE_CONFIGURE 8
Christopher Ferris106b3a82016-08-24 12:15:38 -0700478#define VFIO_EEH_PE_INJECT_ERR 9
Christopher Ferris82d75042015-01-26 10:57:07 -0800479#define VFIO_EEH_PE_OP _IO(VFIO_TYPE, VFIO_BASE + 21)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800480struct vfio_iommu_spapr_register_memory {
481 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700482 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800483 __u64 vaddr;
484 __u64 size;
485};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700486#define VFIO_IOMMU_SPAPR_REGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 17)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800487#define VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 18)
488struct vfio_iommu_spapr_tce_create {
489 __u32 argsz;
490 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800491 __u32 page_shift;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700492 __u32 __resv1;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800493 __u64 window_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700494 __u32 levels;
495 __u32 __resv2;
496 __u64 start_addr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800497};
498#define VFIO_IOMMU_SPAPR_TCE_CREATE _IO(VFIO_TYPE, VFIO_BASE + 19)
499struct vfio_iommu_spapr_tce_remove {
500 __u32 argsz;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800501 __u32 flags;
502 __u64 start_addr;
503};
504#define VFIO_IOMMU_SPAPR_TCE_REMOVE _IO(VFIO_TYPE, VFIO_BASE + 20)
Ben Cheng655a7c02013-10-16 16:09:24 -0700505#endif