blob: e0f322bb0f0061e58344d9f264ae54a9a9195f64 [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 Ferris05d08e92016-02-04 13:16:38 -080065 __u32 num_regions;
Tao Baod7db5942015-01-28 10:07:51 -080066 __u32 num_irqs;
Christopher Ferris32ff3f82020-12-14 13:10:04 -080067 __u32 cap_offset;
Ben Cheng655a7c02013-10-16 16:09:24 -070068};
69#define VFIO_DEVICE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 7)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080070#define VFIO_DEVICE_API_PCI_STRING "vfio-pci"
71#define VFIO_DEVICE_API_PLATFORM_STRING "vfio-platform"
72#define VFIO_DEVICE_API_AMBA_STRING "vfio-amba"
Christopher Ferris525ce912017-07-26 13:12:53 -070073#define VFIO_DEVICE_API_CCW_STRING "vfio-ccw"
Christopher Ferris86a48372019-01-10 14:14:59 -080074#define VFIO_DEVICE_API_AP_STRING "vfio-ap"
Christopher Ferris32ff3f82020-12-14 13:10:04 -080075#define VFIO_DEVICE_INFO_CAP_ZPCI_BASE 1
76#define VFIO_DEVICE_INFO_CAP_ZPCI_GROUP 2
77#define VFIO_DEVICE_INFO_CAP_ZPCI_UTIL 3
78#define VFIO_DEVICE_INFO_CAP_ZPCI_PFIP 4
Ben Cheng655a7c02013-10-16 16:09:24 -070079struct vfio_region_info {
Tao Baod7db5942015-01-28 10:07:51 -080080 __u32 argsz;
81 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -070082#define VFIO_REGION_INFO_FLAG_READ (1 << 0)
83#define VFIO_REGION_INFO_FLAG_WRITE (1 << 1)
Christopher Ferris38062f92014-07-09 15:33:25 -070084#define VFIO_REGION_INFO_FLAG_MMAP (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -070085#define VFIO_REGION_INFO_FLAG_CAPS (1 << 3)
Tao Baod7db5942015-01-28 10:07:51 -080086 __u32 index;
Christopher Ferris106b3a82016-08-24 12:15:38 -070087 __u32 cap_offset;
Tao Baod7db5942015-01-28 10:07:51 -080088 __u64 size;
Tao Baod7db5942015-01-28 10:07:51 -080089 __u64 offset;
Ben Cheng655a7c02013-10-16 16:09:24 -070090};
Christopher Ferris106b3a82016-08-24 12:15:38 -070091#define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8)
92#define VFIO_REGION_INFO_CAP_SPARSE_MMAP 1
93struct vfio_region_sparse_mmap_area {
94 __u64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -070095 __u64 size;
96};
97struct vfio_region_info_cap_sparse_mmap {
98 struct vfio_info_cap_header header;
Christopher Ferris106b3a82016-08-24 12:15:38 -070099 __u32 nr_areas;
100 __u32 reserved;
101 struct vfio_region_sparse_mmap_area areas[];
102};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700103#define VFIO_REGION_INFO_CAP_TYPE 2
104struct vfio_region_info_cap_type {
105 struct vfio_info_cap_header header;
106 __u32 type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700107 __u32 subtype;
108};
109#define VFIO_REGION_TYPE_PCI_VENDOR_TYPE (1 << 31)
110#define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800111#define VFIO_REGION_TYPE_GFX (1)
112#define VFIO_REGION_TYPE_CCW (2)
Greg Kaiser55b56392022-05-27 20:41:14 +0000113#define VFIO_REGION_TYPE_MIGRATION (3)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700114#define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION (1)
115#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2)
116#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800117#define VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM (1)
118#define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD (1)
Christopher Ferris86a48372019-01-10 14:14:59 -0800119#define VFIO_REGION_SUBTYPE_GFX_EDID (1)
120struct vfio_region_gfx_edid {
121 __u32 edid_offset;
122 __u32 edid_max_size;
123 __u32 edid_size;
124 __u32 max_xres;
125 __u32 max_yres;
126 __u32 link_state;
127#define VFIO_DEVICE_GFX_LINK_STATE_UP 1
128#define VFIO_DEVICE_GFX_LINK_STATE_DOWN 2
129};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700130#define VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD (1)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700131#define VFIO_REGION_SUBTYPE_CCW_SCHIB (2)
132#define VFIO_REGION_SUBTYPE_CCW_CRW (3)
Greg Kaiser55b56392022-05-27 20:41:14 +0000133#define VFIO_REGION_SUBTYPE_MIGRATION (1)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700134struct vfio_device_migration_info {
135 __u32 device_state;
Greg Kaiser55b56392022-05-27 20:41:14 +0000136#define VFIO_DEVICE_STATE_STOP (0)
137#define VFIO_DEVICE_STATE_RUNNING (1 << 0)
138#define VFIO_DEVICE_STATE_SAVING (1 << 1)
139#define VFIO_DEVICE_STATE_RESUMING (1 << 2)
140#define VFIO_DEVICE_STATE_MASK (VFIO_DEVICE_STATE_RUNNING | VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING)
141#define VFIO_DEVICE_STATE_VALID(state) (state & VFIO_DEVICE_STATE_RESUMING ? (state & VFIO_DEVICE_STATE_MASK) == VFIO_DEVICE_STATE_RESUMING : 1)
142#define VFIO_DEVICE_STATE_IS_ERROR(state) ((state & VFIO_DEVICE_STATE_MASK) == (VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING))
143#define VFIO_DEVICE_STATE_SET_ERROR(state) ((state & ~VFIO_DEVICE_STATE_MASK) | VFIO_DEVICE_SATE_SAVING | VFIO_DEVICE_STATE_RESUMING)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700144 __u32 reserved;
145 __u64 pending_bytes;
146 __u64 data_offset;
147 __u64 data_size;
148};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700149#define VFIO_REGION_INFO_CAP_MSIX_MAPPABLE 3
Christopher Ferrisd842e432019-03-07 10:21:59 -0800150#define VFIO_REGION_INFO_CAP_NVLINK2_SSATGT 4
151struct vfio_region_info_cap_nvlink2_ssatgt {
152 struct vfio_info_cap_header header;
153 __u64 tgt;
154};
155#define VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD 5
156struct vfio_region_info_cap_nvlink2_lnkspd {
157 struct vfio_info_cap_header header;
158 __u32 link_speed;
159 __u32 __pad;
160};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700161struct vfio_irq_info {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700162 __u32 argsz;
Tao Baod7db5942015-01-28 10:07:51 -0800163 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700164#define VFIO_IRQ_INFO_EVENTFD (1 << 0)
165#define VFIO_IRQ_INFO_MASKABLE (1 << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700166#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700167#define VFIO_IRQ_INFO_NORESIZE (1 << 3)
Tao Baod7db5942015-01-28 10:07:51 -0800168 __u32 index;
169 __u32 count;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700170};
Ben Cheng655a7c02013-10-16 16:09:24 -0700171#define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE + 9)
172struct vfio_irq_set {
Tao Baod7db5942015-01-28 10:07:51 -0800173 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700174 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700175#define VFIO_IRQ_SET_DATA_NONE (1 << 0)
176#define VFIO_IRQ_SET_DATA_BOOL (1 << 1)
177#define VFIO_IRQ_SET_DATA_EVENTFD (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700178#define VFIO_IRQ_SET_ACTION_MASK (1 << 3)
Ben Cheng655a7c02013-10-16 16:09:24 -0700179#define VFIO_IRQ_SET_ACTION_UNMASK (1 << 4)
180#define VFIO_IRQ_SET_ACTION_TRIGGER (1 << 5)
Tao Baod7db5942015-01-28 10:07:51 -0800181 __u32 index;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700182 __u32 start;
Tao Baod7db5942015-01-28 10:07:51 -0800183 __u32 count;
184 __u8 data[];
Ben Cheng655a7c02013-10-16 16:09:24 -0700185};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700186#define VFIO_DEVICE_SET_IRQS _IO(VFIO_TYPE, VFIO_BASE + 10)
Tao Baod7db5942015-01-28 10:07:51 -0800187#define VFIO_IRQ_SET_DATA_TYPE_MASK (VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_DATA_BOOL | VFIO_IRQ_SET_DATA_EVENTFD)
188#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 -0700189#define VFIO_DEVICE_RESET _IO(VFIO_TYPE, VFIO_BASE + 11)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700190enum {
Tao Baod7db5942015-01-28 10:07:51 -0800191 VFIO_PCI_BAR0_REGION_INDEX,
192 VFIO_PCI_BAR1_REGION_INDEX,
193 VFIO_PCI_BAR2_REGION_INDEX,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700194 VFIO_PCI_BAR3_REGION_INDEX,
Tao Baod7db5942015-01-28 10:07:51 -0800195 VFIO_PCI_BAR4_REGION_INDEX,
196 VFIO_PCI_BAR5_REGION_INDEX,
197 VFIO_PCI_ROM_REGION_INDEX,
Tao Baod7db5942015-01-28 10:07:51 -0800198 VFIO_PCI_CONFIG_REGION_INDEX,
199 VFIO_PCI_VGA_REGION_INDEX,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700200 VFIO_PCI_NUM_REGIONS = 9
Ben Cheng655a7c02013-10-16 16:09:24 -0700201};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700202enum {
Tao Baod7db5942015-01-28 10:07:51 -0800203 VFIO_PCI_INTX_IRQ_INDEX,
204 VFIO_PCI_MSI_IRQ_INDEX,
205 VFIO_PCI_MSIX_IRQ_INDEX,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700206 VFIO_PCI_ERR_IRQ_INDEX,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800207 VFIO_PCI_REQ_IRQ_INDEX,
Tao Baod7db5942015-01-28 10:07:51 -0800208 VFIO_PCI_NUM_IRQS
Ben Cheng655a7c02013-10-16 16:09:24 -0700209};
Christopher Ferris525ce912017-07-26 13:12:53 -0700210enum {
211 VFIO_CCW_CONFIG_REGION_INDEX,
212 VFIO_CCW_NUM_REGIONS
213};
214enum {
215 VFIO_CCW_IO_IRQ_INDEX,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700216 VFIO_CCW_CRW_IRQ_INDEX,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800217 VFIO_CCW_REQ_IRQ_INDEX,
Christopher Ferris525ce912017-07-26 13:12:53 -0700218 VFIO_CCW_NUM_IRQS
219};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700220struct vfio_pci_dependent_device {
Tao Baod7db5942015-01-28 10:07:51 -0800221 __u32 group_id;
222 __u16 segment;
223 __u8 bus;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700224 __u8 devfn;
Christopher Ferris38062f92014-07-09 15:33:25 -0700225};
226struct vfio_pci_hot_reset_info {
Tao Baod7db5942015-01-28 10:07:51 -0800227 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700228 __u32 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800229 __u32 count;
230 struct vfio_pci_dependent_device devices[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700231};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700232#define VFIO_DEVICE_GET_PCI_HOT_RESET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
Christopher Ferris38062f92014-07-09 15:33:25 -0700233struct vfio_pci_hot_reset {
Tao Baod7db5942015-01-28 10:07:51 -0800234 __u32 argsz;
235 __u32 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700236 __u32 count;
Tao Baod7db5942015-01-28 10:07:51 -0800237 __s32 group_fds[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700238};
239#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700240struct vfio_device_gfx_plane_info {
241 __u32 argsz;
242 __u32 flags;
243#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0)
244#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1)
245#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2)
246 __u32 drm_plane_type;
247 __u32 drm_format;
248 __u64 drm_format_mod;
249 __u32 width;
250 __u32 height;
251 __u32 stride;
252 __u32 size;
253 __u32 x_pos;
254 __u32 y_pos;
255 __u32 x_hot;
256 __u32 y_hot;
257 union {
258 __u32 region_index;
259 __u32 dmabuf_id;
260 };
261};
262#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14)
263#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15)
264struct vfio_device_ioeventfd {
265 __u32 argsz;
266 __u32 flags;
267#define VFIO_DEVICE_IOEVENTFD_8 (1 << 0)
268#define VFIO_DEVICE_IOEVENTFD_16 (1 << 1)
269#define VFIO_DEVICE_IOEVENTFD_32 (1 << 2)
270#define VFIO_DEVICE_IOEVENTFD_64 (1 << 3)
271#define VFIO_DEVICE_IOEVENTFD_SIZE_MASK (0xf)
272 __u64 offset;
273 __u64 data;
274 __s32 fd;
275};
276#define VFIO_DEVICE_IOEVENTFD _IO(VFIO_TYPE, VFIO_BASE + 16)
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700277struct vfio_device_feature {
278 __u32 argsz;
279 __u32 flags;
280#define VFIO_DEVICE_FEATURE_MASK (0xffff)
281#define VFIO_DEVICE_FEATURE_GET (1 << 16)
282#define VFIO_DEVICE_FEATURE_SET (1 << 17)
283#define VFIO_DEVICE_FEATURE_PROBE (1 << 18)
284 __u8 data[];
285};
286#define VFIO_DEVICE_FEATURE _IO(VFIO_TYPE, VFIO_BASE + 17)
287#define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN (0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700288struct vfio_iommu_type1_info {
Tao Baod7db5942015-01-28 10:07:51 -0800289 __u32 argsz;
290 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700291#define VFIO_IOMMU_INFO_PGSIZES (1 << 0)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800292#define VFIO_IOMMU_INFO_CAPS (1 << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700293 __u64 iova_pgsizes;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800294 __u32 cap_offset;
295};
296#define VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE 1
297struct vfio_iova_range {
298 __u64 start;
299 __u64 end;
300};
301struct vfio_iommu_type1_info_cap_iova_range {
302 struct vfio_info_cap_header header;
303 __u32 nr_iovas;
304 __u32 reserved;
305 struct vfio_iova_range iova_ranges[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700306};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700307#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 2
308struct vfio_iommu_type1_info_cap_migration {
309 struct vfio_info_cap_header header;
310 __u32 flags;
311 __u64 pgsize_bitmap;
312 __u64 max_dirty_bitmap_size;
313};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800314#define VFIO_IOMMU_TYPE1_INFO_DMA_AVAIL 3
315struct vfio_iommu_type1_info_dma_avail {
316 struct vfio_info_cap_header header;
317 __u32 avail;
318};
Ben Cheng655a7c02013-10-16 16:09:24 -0700319#define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
320struct vfio_iommu_type1_dma_map {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700321 __u32 argsz;
Tao Baod7db5942015-01-28 10:07:51 -0800322 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700323#define VFIO_DMA_MAP_FLAG_READ (1 << 0)
324#define VFIO_DMA_MAP_FLAG_WRITE (1 << 1)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700325#define VFIO_DMA_MAP_FLAG_VADDR (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700326 __u64 vaddr;
Tao Baod7db5942015-01-28 10:07:51 -0800327 __u64 iova;
328 __u64 size;
Ben Cheng655a7c02013-10-16 16:09:24 -0700329};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700330#define VFIO_IOMMU_MAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 13)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700331struct vfio_bitmap {
332 __u64 pgsize;
333 __u64 size;
334 __u64 __user * data;
335};
Christopher Ferris38062f92014-07-09 15:33:25 -0700336struct vfio_iommu_type1_dma_unmap {
Tao Baod7db5942015-01-28 10:07:51 -0800337 __u32 argsz;
338 __u32 flags;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700339#define VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP (1 << 0)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700340#define VFIO_DMA_UNMAP_FLAG_ALL (1 << 1)
341#define VFIO_DMA_UNMAP_FLAG_VADDR (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700342 __u64 iova;
Tao Baod7db5942015-01-28 10:07:51 -0800343 __u64 size;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700344 __u8 data[];
Ben Cheng655a7c02013-10-16 16:09:24 -0700345};
346#define VFIO_IOMMU_UNMAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 14)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700347#define VFIO_IOMMU_ENABLE _IO(VFIO_TYPE, VFIO_BASE + 15)
Christopher Ferris38062f92014-07-09 15:33:25 -0700348#define VFIO_IOMMU_DISABLE _IO(VFIO_TYPE, VFIO_BASE + 16)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700349struct vfio_iommu_type1_dirty_bitmap {
350 __u32 argsz;
351 __u32 flags;
352#define VFIO_IOMMU_DIRTY_PAGES_FLAG_START (1 << 0)
353#define VFIO_IOMMU_DIRTY_PAGES_FLAG_STOP (1 << 1)
354#define VFIO_IOMMU_DIRTY_PAGES_FLAG_GET_BITMAP (1 << 2)
355 __u8 data[];
356};
357struct vfio_iommu_type1_dirty_bitmap_get {
358 __u64 iova;
359 __u64 size;
360 struct vfio_bitmap bitmap;
361};
362#define VFIO_IOMMU_DIRTY_PAGES _IO(VFIO_TYPE, VFIO_BASE + 17)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800363struct vfio_iommu_spapr_tce_ddw_info {
364 __u64 pgsizes;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700365 __u32 max_dynamic_windows_supported;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800366 __u32 levels;
367};
Christopher Ferris38062f92014-07-09 15:33:25 -0700368struct vfio_iommu_spapr_tce_info {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700369 __u32 argsz;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800370 __u32 flags;
371#define VFIO_IOMMU_SPAPR_INFO_DDW (1 << 0)
Tao Baod7db5942015-01-28 10:07:51 -0800372 __u32 dma32_window_start;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700373 __u32 dma32_window_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800374 struct vfio_iommu_spapr_tce_ddw_info ddw;
Christopher Ferris38062f92014-07-09 15:33:25 -0700375};
376#define VFIO_IOMMU_SPAPR_TCE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700377struct vfio_eeh_pe_err {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800378 __u32 type;
379 __u32 func;
380 __u64 addr;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700381 __u64 mask;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800382};
Christopher Ferris82d75042015-01-26 10:57:07 -0800383struct vfio_eeh_pe_op {
Tao Baod7db5942015-01-28 10:07:51 -0800384 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700385 __u32 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800386 __u32 op;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800387 union {
388 struct vfio_eeh_pe_err err;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700389 };
Christopher Ferris82d75042015-01-26 10:57:07 -0800390};
391#define VFIO_EEH_PE_DISABLE 0
392#define VFIO_EEH_PE_ENABLE 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700393#define VFIO_EEH_PE_UNFREEZE_IO 2
Christopher Ferris82d75042015-01-26 10:57:07 -0800394#define VFIO_EEH_PE_UNFREEZE_DMA 3
395#define VFIO_EEH_PE_GET_STATE 4
396#define VFIO_EEH_PE_STATE_NORMAL 0
Christopher Ferris106b3a82016-08-24 12:15:38 -0700397#define VFIO_EEH_PE_STATE_RESET 1
Christopher Ferris82d75042015-01-26 10:57:07 -0800398#define VFIO_EEH_PE_STATE_STOPPED 2
399#define VFIO_EEH_PE_STATE_STOPPED_DMA 4
400#define VFIO_EEH_PE_STATE_UNAVAIL 5
Christopher Ferris106b3a82016-08-24 12:15:38 -0700401#define VFIO_EEH_PE_RESET_DEACTIVATE 5
Christopher Ferris82d75042015-01-26 10:57:07 -0800402#define VFIO_EEH_PE_RESET_HOT 6
403#define VFIO_EEH_PE_RESET_FUNDAMENTAL 7
404#define VFIO_EEH_PE_CONFIGURE 8
Christopher Ferris106b3a82016-08-24 12:15:38 -0700405#define VFIO_EEH_PE_INJECT_ERR 9
Christopher Ferris82d75042015-01-26 10:57:07 -0800406#define VFIO_EEH_PE_OP _IO(VFIO_TYPE, VFIO_BASE + 21)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800407struct vfio_iommu_spapr_register_memory {
408 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700409 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800410 __u64 vaddr;
411 __u64 size;
412};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700413#define VFIO_IOMMU_SPAPR_REGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 17)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800414#define VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 18)
415struct vfio_iommu_spapr_tce_create {
416 __u32 argsz;
417 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800418 __u32 page_shift;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700419 __u32 __resv1;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800420 __u64 window_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700421 __u32 levels;
422 __u32 __resv2;
423 __u64 start_addr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800424};
425#define VFIO_IOMMU_SPAPR_TCE_CREATE _IO(VFIO_TYPE, VFIO_BASE + 19)
426struct vfio_iommu_spapr_tce_remove {
427 __u32 argsz;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800428 __u32 flags;
429 __u64 start_addr;
430};
431#define VFIO_IOMMU_SPAPR_TCE_REMOVE _IO(VFIO_TYPE, VFIO_BASE + 20)
Ben Cheng655a7c02013-10-16 16:09:24 -0700432#endif