blob: 5910e409917965114a8bcc9b1167b3561baa8565 [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Ben Cheng655a7c02013-10-16 16:09:24 -07007#ifndef _UAPIVFIO_H
8#define _UAPIVFIO_H
9#include <linux/types.h>
10#include <linux/ioctl.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070011#define VFIO_API_VERSION 0
12#define VFIO_TYPE1_IOMMU 1
Christopher Ferris38062f92014-07-09 15:33:25 -070013#define VFIO_SPAPR_TCE_IOMMU 2
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070014#define VFIO_TYPE1v2_IOMMU 3
Christopher Ferrisba8d4f42014-09-03 19:56:49 -070015#define VFIO_DMA_CC_IOMMU 4
Christopher Ferris82d75042015-01-26 10:57:07 -080016#define VFIO_EEH 5
17#define VFIO_TYPE1_NESTING_IOMMU 6
Christopher Ferris05d08e92016-02-04 13:16:38 -080018#define VFIO_SPAPR_TCE_v2_IOMMU 7
Christopher Ferris106b3a82016-08-24 12:15:38 -070019#define VFIO_NOIOMMU_IOMMU 8
Christopher Ferrisa9750ed2021-05-03 14:02:49 -070020#define VFIO_UNMAP_ALL 9
21#define VFIO_UPDATE_VADDR 10
Christopher Ferris05d08e92016-02-04 13:16:38 -080022#define VFIO_TYPE (';')
Christopher Ferris38062f92014-07-09 15:33:25 -070023#define VFIO_BASE 100
Christopher Ferris106b3a82016-08-24 12:15:38 -070024struct vfio_info_cap_header {
Christopher Ferris106b3a82016-08-24 12:15:38 -070025 __u16 id;
26 __u16 version;
27 __u32 next;
28};
Ben Cheng655a7c02013-10-16 16:09:24 -070029#define VFIO_GET_API_VERSION _IO(VFIO_TYPE, VFIO_BASE + 0)
30#define VFIO_CHECK_EXTENSION _IO(VFIO_TYPE, VFIO_BASE + 1)
Christopher Ferris05d08e92016-02-04 13:16:38 -080031#define VFIO_SET_IOMMU _IO(VFIO_TYPE, VFIO_BASE + 2)
Christopher Ferris38062f92014-07-09 15:33:25 -070032struct vfio_group_status {
Tao Baod7db5942015-01-28 10:07:51 -080033 __u32 argsz;
34 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -080035#define VFIO_GROUP_FLAGS_VIABLE (1 << 0)
Christopher Ferris38062f92014-07-09 15:33:25 -070036#define VFIO_GROUP_FLAGS_CONTAINER_SET (1 << 1)
Ben Cheng655a7c02013-10-16 16:09:24 -070037};
38#define VFIO_GROUP_GET_STATUS _IO(VFIO_TYPE, VFIO_BASE + 3)
Christopher Ferris05d08e92016-02-04 13:16:38 -080039#define VFIO_GROUP_SET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 4)
Christopher Ferris38062f92014-07-09 15:33:25 -070040#define VFIO_GROUP_UNSET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 5)
Ben Cheng655a7c02013-10-16 16:09:24 -070041#define VFIO_GROUP_GET_DEVICE_FD _IO(VFIO_TYPE, VFIO_BASE + 6)
42struct vfio_device_info {
Christopher Ferris05d08e92016-02-04 13:16:38 -080043 __u32 argsz;
Tao Baod7db5942015-01-28 10:07:51 -080044 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -070045#define VFIO_DEVICE_FLAGS_RESET (1 << 0)
46#define VFIO_DEVICE_FLAGS_PCI (1 << 1)
Christopher Ferris05d08e92016-02-04 13:16:38 -080047#define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2)
48#define VFIO_DEVICE_FLAGS_AMBA (1 << 3)
Christopher Ferris525ce912017-07-26 13:12:53 -070049#define VFIO_DEVICE_FLAGS_CCW (1 << 4)
Christopher Ferris86a48372019-01-10 14:14:59 -080050#define VFIO_DEVICE_FLAGS_AP (1 << 5)
Christopher Ferris32ff3f82020-12-14 13:10:04 -080051#define VFIO_DEVICE_FLAGS_FSL_MC (1 << 6)
52#define VFIO_DEVICE_FLAGS_CAPS (1 << 7)
Christopher Ferris8666d042023-09-06 14:55:31 -070053#define VFIO_DEVICE_FLAGS_CDX (1 << 8)
Christopher Ferris05d08e92016-02-04 13:16:38 -080054 __u32 num_regions;
Tao Baod7db5942015-01-28 10:07:51 -080055 __u32 num_irqs;
Christopher Ferris32ff3f82020-12-14 13:10:04 -080056 __u32 cap_offset;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -070057 __u32 pad;
Ben Cheng655a7c02013-10-16 16:09:24 -070058};
59#define VFIO_DEVICE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 7)
Christopher Ferris48af7cb2017-02-21 12:35:09 -080060#define VFIO_DEVICE_API_PCI_STRING "vfio-pci"
61#define VFIO_DEVICE_API_PLATFORM_STRING "vfio-platform"
62#define VFIO_DEVICE_API_AMBA_STRING "vfio-amba"
Christopher Ferris525ce912017-07-26 13:12:53 -070063#define VFIO_DEVICE_API_CCW_STRING "vfio-ccw"
Christopher Ferris86a48372019-01-10 14:14:59 -080064#define VFIO_DEVICE_API_AP_STRING "vfio-ap"
Christopher Ferris32ff3f82020-12-14 13:10:04 -080065#define VFIO_DEVICE_INFO_CAP_ZPCI_BASE 1
66#define VFIO_DEVICE_INFO_CAP_ZPCI_GROUP 2
67#define VFIO_DEVICE_INFO_CAP_ZPCI_UTIL 3
68#define VFIO_DEVICE_INFO_CAP_ZPCI_PFIP 4
Christopher Ferris8666d042023-09-06 14:55:31 -070069#define VFIO_DEVICE_INFO_CAP_PCI_ATOMIC_COMP 5
70struct vfio_device_info_cap_pci_atomic_comp {
71 struct vfio_info_cap_header header;
72 __u32 flags;
73#define VFIO_PCI_ATOMIC_COMP32 (1 << 0)
74#define VFIO_PCI_ATOMIC_COMP64 (1 << 1)
75#define VFIO_PCI_ATOMIC_COMP128 (1 << 2)
76 __u32 reserved;
77};
Ben Cheng655a7c02013-10-16 16:09:24 -070078struct vfio_region_info {
Tao Baod7db5942015-01-28 10:07:51 -080079 __u32 argsz;
80 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -070081#define VFIO_REGION_INFO_FLAG_READ (1 << 0)
82#define VFIO_REGION_INFO_FLAG_WRITE (1 << 1)
Christopher Ferris38062f92014-07-09 15:33:25 -070083#define VFIO_REGION_INFO_FLAG_MMAP (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -070084#define VFIO_REGION_INFO_FLAG_CAPS (1 << 3)
Tao Baod7db5942015-01-28 10:07:51 -080085 __u32 index;
Christopher Ferris106b3a82016-08-24 12:15:38 -070086 __u32 cap_offset;
Christopher Ferris0f795212024-01-17 14:17:28 -080087 __aligned_u64 size;
88 __aligned_u64 offset;
Ben Cheng655a7c02013-10-16 16:09:24 -070089};
Christopher Ferris106b3a82016-08-24 12:15:38 -070090#define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8)
91#define VFIO_REGION_INFO_CAP_SPARSE_MMAP 1
92struct vfio_region_sparse_mmap_area {
Christopher Ferris0f795212024-01-17 14:17:28 -080093 __aligned_u64 offset;
94 __aligned_u64 size;
Christopher Ferris106b3a82016-08-24 12:15:38 -070095};
96struct vfio_region_info_cap_sparse_mmap {
97 struct vfio_info_cap_header header;
Christopher Ferris106b3a82016-08-24 12:15:38 -070098 __u32 nr_areas;
99 __u32 reserved;
100 struct vfio_region_sparse_mmap_area areas[];
101};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700102#define VFIO_REGION_INFO_CAP_TYPE 2
103struct vfio_region_info_cap_type {
104 struct vfio_info_cap_header header;
105 __u32 type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700106 __u32 subtype;
107};
108#define VFIO_REGION_TYPE_PCI_VENDOR_TYPE (1 << 31)
109#define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800110#define VFIO_REGION_TYPE_GFX (1)
111#define VFIO_REGION_TYPE_CCW (2)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700112#define VFIO_REGION_TYPE_MIGRATION_DEPRECATED (3)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700113#define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION (1)
114#define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2)
115#define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800116#define VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM (1)
117#define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD (1)
Christopher Ferris86a48372019-01-10 14:14:59 -0800118#define VFIO_REGION_SUBTYPE_GFX_EDID (1)
119struct vfio_region_gfx_edid {
120 __u32 edid_offset;
121 __u32 edid_max_size;
122 __u32 edid_size;
123 __u32 max_xres;
124 __u32 max_yres;
125 __u32 link_state;
126#define VFIO_DEVICE_GFX_LINK_STATE_UP 1
127#define VFIO_DEVICE_GFX_LINK_STATE_DOWN 2
128};
Christopher Ferrisaeddbcf2019-07-08 12:45:46 -0700129#define VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD (1)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700130#define VFIO_REGION_SUBTYPE_CCW_SCHIB (2)
131#define VFIO_REGION_SUBTYPE_CCW_CRW (3)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700132#define VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED (1)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700133struct vfio_device_migration_info {
134 __u32 device_state;
Christopher Ferris10a76e62022-06-08 13:31:52 -0700135#define VFIO_DEVICE_STATE_V1_STOP (0)
136#define VFIO_DEVICE_STATE_V1_RUNNING (1 << 0)
137#define VFIO_DEVICE_STATE_V1_SAVING (1 << 1)
138#define VFIO_DEVICE_STATE_V1_RESUMING (1 << 2)
139#define VFIO_DEVICE_STATE_MASK (VFIO_DEVICE_STATE_V1_RUNNING | VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING)
140#define VFIO_DEVICE_STATE_VALID(state) (state & VFIO_DEVICE_STATE_V1_RESUMING ? (state & VFIO_DEVICE_STATE_MASK) == VFIO_DEVICE_STATE_V1_RESUMING : 1)
141#define VFIO_DEVICE_STATE_IS_ERROR(state) ((state & VFIO_DEVICE_STATE_MASK) == (VFIO_DEVICE_STATE_V1_SAVING | VFIO_DEVICE_STATE_V1_RESUMING))
142#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 -0700143 __u32 reserved;
Christopher Ferris0f795212024-01-17 14:17:28 -0800144 __aligned_u64 pending_bytes;
145 __aligned_u64 data_offset;
146 __aligned_u64 data_size;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700147};
Christopher Ferris76a1d452018-06-27 14:12:29 -0700148#define VFIO_REGION_INFO_CAP_MSIX_MAPPABLE 3
Christopher Ferrisd842e432019-03-07 10:21:59 -0800149#define VFIO_REGION_INFO_CAP_NVLINK2_SSATGT 4
150struct vfio_region_info_cap_nvlink2_ssatgt {
151 struct vfio_info_cap_header header;
Christopher Ferris0f795212024-01-17 14:17:28 -0800152 __aligned_u64 tgt;
Christopher Ferrisd842e432019-03-07 10:21:59 -0800153};
154#define VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD 5
155struct vfio_region_info_cap_nvlink2_lnkspd {
156 struct vfio_info_cap_header header;
157 __u32 link_speed;
158 __u32 __pad;
159};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700160struct vfio_irq_info {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700161 __u32 argsz;
Tao Baod7db5942015-01-28 10:07:51 -0800162 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700163#define VFIO_IRQ_INFO_EVENTFD (1 << 0)
164#define VFIO_IRQ_INFO_MASKABLE (1 << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700165#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2)
Ben Cheng655a7c02013-10-16 16:09:24 -0700166#define VFIO_IRQ_INFO_NORESIZE (1 << 3)
Tao Baod7db5942015-01-28 10:07:51 -0800167 __u32 index;
168 __u32 count;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700169};
Ben Cheng655a7c02013-10-16 16:09:24 -0700170#define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE + 9)
171struct vfio_irq_set {
Tao Baod7db5942015-01-28 10:07:51 -0800172 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700173 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700174#define VFIO_IRQ_SET_DATA_NONE (1 << 0)
175#define VFIO_IRQ_SET_DATA_BOOL (1 << 1)
176#define VFIO_IRQ_SET_DATA_EVENTFD (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700177#define VFIO_IRQ_SET_ACTION_MASK (1 << 3)
Ben Cheng655a7c02013-10-16 16:09:24 -0700178#define VFIO_IRQ_SET_ACTION_UNMASK (1 << 4)
179#define VFIO_IRQ_SET_ACTION_TRIGGER (1 << 5)
Tao Baod7db5942015-01-28 10:07:51 -0800180 __u32 index;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700181 __u32 start;
Tao Baod7db5942015-01-28 10:07:51 -0800182 __u32 count;
183 __u8 data[];
Ben Cheng655a7c02013-10-16 16:09:24 -0700184};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700185#define VFIO_DEVICE_SET_IRQS _IO(VFIO_TYPE, VFIO_BASE + 10)
Tao Baod7db5942015-01-28 10:07:51 -0800186#define VFIO_IRQ_SET_DATA_TYPE_MASK (VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_DATA_BOOL | VFIO_IRQ_SET_DATA_EVENTFD)
187#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 -0700188#define VFIO_DEVICE_RESET _IO(VFIO_TYPE, VFIO_BASE + 11)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700189enum {
Tao Baod7db5942015-01-28 10:07:51 -0800190 VFIO_PCI_BAR0_REGION_INDEX,
191 VFIO_PCI_BAR1_REGION_INDEX,
192 VFIO_PCI_BAR2_REGION_INDEX,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700193 VFIO_PCI_BAR3_REGION_INDEX,
Tao Baod7db5942015-01-28 10:07:51 -0800194 VFIO_PCI_BAR4_REGION_INDEX,
195 VFIO_PCI_BAR5_REGION_INDEX,
196 VFIO_PCI_ROM_REGION_INDEX,
Tao Baod7db5942015-01-28 10:07:51 -0800197 VFIO_PCI_CONFIG_REGION_INDEX,
198 VFIO_PCI_VGA_REGION_INDEX,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700199 VFIO_PCI_NUM_REGIONS = 9
Ben Cheng655a7c02013-10-16 16:09:24 -0700200};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700201enum {
Tao Baod7db5942015-01-28 10:07:51 -0800202 VFIO_PCI_INTX_IRQ_INDEX,
203 VFIO_PCI_MSI_IRQ_INDEX,
204 VFIO_PCI_MSIX_IRQ_INDEX,
Christopher Ferris106b3a82016-08-24 12:15:38 -0700205 VFIO_PCI_ERR_IRQ_INDEX,
Christopher Ferris05d08e92016-02-04 13:16:38 -0800206 VFIO_PCI_REQ_IRQ_INDEX,
Tao Baod7db5942015-01-28 10:07:51 -0800207 VFIO_PCI_NUM_IRQS
Ben Cheng655a7c02013-10-16 16:09:24 -0700208};
Christopher Ferris525ce912017-07-26 13:12:53 -0700209enum {
210 VFIO_CCW_CONFIG_REGION_INDEX,
211 VFIO_CCW_NUM_REGIONS
212};
213enum {
214 VFIO_CCW_IO_IRQ_INDEX,
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700215 VFIO_CCW_CRW_IRQ_INDEX,
Christopher Ferris05667cd2021-02-16 16:01:34 -0800216 VFIO_CCW_REQ_IRQ_INDEX,
Christopher Ferris525ce912017-07-26 13:12:53 -0700217 VFIO_CCW_NUM_IRQS
218};
Christopher Ferris8666d042023-09-06 14:55:31 -0700219enum {
220 VFIO_AP_REQ_IRQ_INDEX,
221 VFIO_AP_NUM_IRQS
222};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700223struct vfio_pci_dependent_device {
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700224 union {
225 __u32 group_id;
226 __u32 devid;
227#define VFIO_PCI_DEVID_OWNED 0
228#define VFIO_PCI_DEVID_NOT_OWNED - 1
229 };
Tao Baod7db5942015-01-28 10:07:51 -0800230 __u16 segment;
231 __u8 bus;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700232 __u8 devfn;
Christopher Ferris38062f92014-07-09 15:33:25 -0700233};
234struct vfio_pci_hot_reset_info {
Tao Baod7db5942015-01-28 10:07:51 -0800235 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700236 __u32 flags;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700237#define VFIO_PCI_HOT_RESET_FLAG_DEV_ID (1 << 0)
238#define VFIO_PCI_HOT_RESET_FLAG_DEV_ID_OWNED (1 << 1)
Tao Baod7db5942015-01-28 10:07:51 -0800239 __u32 count;
240 struct vfio_pci_dependent_device devices[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700241};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700242#define VFIO_DEVICE_GET_PCI_HOT_RESET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
Christopher Ferris38062f92014-07-09 15:33:25 -0700243struct vfio_pci_hot_reset {
Tao Baod7db5942015-01-28 10:07:51 -0800244 __u32 argsz;
245 __u32 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700246 __u32 count;
Tao Baod7db5942015-01-28 10:07:51 -0800247 __s32 group_fds[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700248};
249#define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700250struct vfio_device_gfx_plane_info {
251 __u32 argsz;
252 __u32 flags;
253#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0)
254#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1)
255#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2)
256 __u32 drm_plane_type;
257 __u32 drm_format;
Christopher Ferris0f795212024-01-17 14:17:28 -0800258 __aligned_u64 drm_format_mod;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700259 __u32 width;
260 __u32 height;
261 __u32 stride;
262 __u32 size;
263 __u32 x_pos;
264 __u32 y_pos;
265 __u32 x_hot;
266 __u32 y_hot;
267 union {
268 __u32 region_index;
269 __u32 dmabuf_id;
270 };
Christopher Ferris0f795212024-01-17 14:17:28 -0800271 __u32 reserved;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700272};
273#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14)
274#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15)
275struct vfio_device_ioeventfd {
276 __u32 argsz;
277 __u32 flags;
278#define VFIO_DEVICE_IOEVENTFD_8 (1 << 0)
279#define VFIO_DEVICE_IOEVENTFD_16 (1 << 1)
280#define VFIO_DEVICE_IOEVENTFD_32 (1 << 2)
281#define VFIO_DEVICE_IOEVENTFD_64 (1 << 3)
282#define VFIO_DEVICE_IOEVENTFD_SIZE_MASK (0xf)
Christopher Ferris0f795212024-01-17 14:17:28 -0800283 __aligned_u64 offset;
284 __aligned_u64 data;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700285 __s32 fd;
Christopher Ferris0f795212024-01-17 14:17:28 -0800286 __u32 reserved;
Christopher Ferris76a1d452018-06-27 14:12:29 -0700287};
288#define VFIO_DEVICE_IOEVENTFD _IO(VFIO_TYPE, VFIO_BASE + 16)
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700289struct vfio_device_feature {
290 __u32 argsz;
291 __u32 flags;
292#define VFIO_DEVICE_FEATURE_MASK (0xffff)
293#define VFIO_DEVICE_FEATURE_GET (1 << 16)
294#define VFIO_DEVICE_FEATURE_SET (1 << 17)
295#define VFIO_DEVICE_FEATURE_PROBE (1 << 18)
296 __u8 data[];
297};
298#define VFIO_DEVICE_FEATURE _IO(VFIO_TYPE, VFIO_BASE + 17)
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700299struct vfio_device_bind_iommufd {
300 __u32 argsz;
301 __u32 flags;
302 __s32 iommufd;
303 __u32 out_devid;
304};
305#define VFIO_DEVICE_BIND_IOMMUFD _IO(VFIO_TYPE, VFIO_BASE + 18)
306struct vfio_device_attach_iommufd_pt {
307 __u32 argsz;
308 __u32 flags;
309 __u32 pt_id;
310};
311#define VFIO_DEVICE_ATTACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 19)
312struct vfio_device_detach_iommufd_pt {
313 __u32 argsz;
314 __u32 flags;
315};
316#define VFIO_DEVICE_DETACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 20)
Christopher Ferrisaf09c702020-06-01 20:29:29 -0700317#define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN (0)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700318struct vfio_device_feature_migration {
319 __aligned_u64 flags;
320#define VFIO_MIGRATION_STOP_COPY (1 << 0)
321#define VFIO_MIGRATION_P2P (1 << 1)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800322#define VFIO_MIGRATION_PRE_COPY (1 << 2)
Christopher Ferris10a76e62022-06-08 13:31:52 -0700323};
324#define VFIO_DEVICE_FEATURE_MIGRATION 1
325struct vfio_device_feature_mig_state {
326 __u32 device_state;
327 __s32 data_fd;
328};
329#define VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE 2
330enum vfio_device_mig_state {
331 VFIO_DEVICE_STATE_ERROR = 0,
332 VFIO_DEVICE_STATE_STOP = 1,
333 VFIO_DEVICE_STATE_RUNNING = 2,
334 VFIO_DEVICE_STATE_STOP_COPY = 3,
335 VFIO_DEVICE_STATE_RESUMING = 4,
336 VFIO_DEVICE_STATE_RUNNING_P2P = 5,
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800337 VFIO_DEVICE_STATE_PRE_COPY = 6,
338 VFIO_DEVICE_STATE_PRE_COPY_P2P = 7,
Christopher Ferrisb830ddf2024-03-28 11:48:08 -0700339 VFIO_DEVICE_STATE_NR,
Christopher Ferris10a76e62022-06-08 13:31:52 -0700340};
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800341struct vfio_precopy_info {
342 __u32 argsz;
343 __u32 flags;
344 __aligned_u64 initial_bytes;
345 __aligned_u64 dirty_bytes;
346};
347#define VFIO_MIG_GET_PRECOPY_INFO _IO(VFIO_TYPE, VFIO_BASE + 21)
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000348#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY 3
349struct vfio_device_low_power_entry_with_wakeup {
350 __s32 wakeup_eventfd;
351 __u32 reserved;
352};
353#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP 4
354#define VFIO_DEVICE_FEATURE_LOW_POWER_EXIT 5
355struct vfio_device_feature_dma_logging_control {
356 __aligned_u64 page_size;
357 __u32 num_ranges;
358 __u32 __reserved;
359 __aligned_u64 ranges;
360};
361struct vfio_device_feature_dma_logging_range {
362 __aligned_u64 iova;
363 __aligned_u64 length;
364};
365#define VFIO_DEVICE_FEATURE_DMA_LOGGING_START 6
366#define VFIO_DEVICE_FEATURE_DMA_LOGGING_STOP 7
367struct vfio_device_feature_dma_logging_report {
368 __aligned_u64 iova;
369 __aligned_u64 length;
370 __aligned_u64 page_size;
371 __aligned_u64 bitmap;
372};
373#define VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT 8
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800374struct vfio_device_feature_mig_data_size {
375 __aligned_u64 stop_copy_length;
376};
377#define VFIO_DEVICE_FEATURE_MIG_DATA_SIZE 9
Christopher Ferris0f795212024-01-17 14:17:28 -0800378struct vfio_device_feature_bus_master {
379 __u32 op;
380#define VFIO_DEVICE_FEATURE_CLEAR_MASTER 0
381#define VFIO_DEVICE_FEATURE_SET_MASTER 1
382};
383#define VFIO_DEVICE_FEATURE_BUS_MASTER 10
Christopher Ferris106b3a82016-08-24 12:15:38 -0700384struct vfio_iommu_type1_info {
Tao Baod7db5942015-01-28 10:07:51 -0800385 __u32 argsz;
386 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700387#define VFIO_IOMMU_INFO_PGSIZES (1 << 0)
Christopher Ferris9584fa42019-12-09 15:36:13 -0800388#define VFIO_IOMMU_INFO_CAPS (1 << 1)
Christopher Ferris0f795212024-01-17 14:17:28 -0800389 __aligned_u64 iova_pgsizes;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800390 __u32 cap_offset;
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700391 __u32 pad;
Christopher Ferris9584fa42019-12-09 15:36:13 -0800392};
393#define VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE 1
394struct vfio_iova_range {
395 __u64 start;
396 __u64 end;
397};
398struct vfio_iommu_type1_info_cap_iova_range {
399 struct vfio_info_cap_header header;
400 __u32 nr_iovas;
401 __u32 reserved;
402 struct vfio_iova_range iova_ranges[];
Christopher Ferris38062f92014-07-09 15:33:25 -0700403};
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700404#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 2
405struct vfio_iommu_type1_info_cap_migration {
406 struct vfio_info_cap_header header;
407 __u32 flags;
408 __u64 pgsize_bitmap;
409 __u64 max_dirty_bitmap_size;
410};
Christopher Ferris32ff3f82020-12-14 13:10:04 -0800411#define VFIO_IOMMU_TYPE1_INFO_DMA_AVAIL 3
412struct vfio_iommu_type1_info_dma_avail {
413 struct vfio_info_cap_header header;
414 __u32 avail;
415};
Ben Cheng655a7c02013-10-16 16:09:24 -0700416#define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
417struct vfio_iommu_type1_dma_map {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700418 __u32 argsz;
Tao Baod7db5942015-01-28 10:07:51 -0800419 __u32 flags;
Ben Cheng655a7c02013-10-16 16:09:24 -0700420#define VFIO_DMA_MAP_FLAG_READ (1 << 0)
421#define VFIO_DMA_MAP_FLAG_WRITE (1 << 1)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700422#define VFIO_DMA_MAP_FLAG_VADDR (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700423 __u64 vaddr;
Tao Baod7db5942015-01-28 10:07:51 -0800424 __u64 iova;
425 __u64 size;
Ben Cheng655a7c02013-10-16 16:09:24 -0700426};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700427#define VFIO_IOMMU_MAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 13)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700428struct vfio_bitmap {
429 __u64 pgsize;
430 __u64 size;
Elliott Hughes0f0c18f2023-03-29 15:53:31 -0700431 __u64 * data;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700432};
Christopher Ferris38062f92014-07-09 15:33:25 -0700433struct vfio_iommu_type1_dma_unmap {
Tao Baod7db5942015-01-28 10:07:51 -0800434 __u32 argsz;
435 __u32 flags;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700436#define VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP (1 << 0)
Christopher Ferrisa9750ed2021-05-03 14:02:49 -0700437#define VFIO_DMA_UNMAP_FLAG_ALL (1 << 1)
438#define VFIO_DMA_UNMAP_FLAG_VADDR (1 << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700439 __u64 iova;
Tao Baod7db5942015-01-28 10:07:51 -0800440 __u64 size;
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700441 __u8 data[];
Ben Cheng655a7c02013-10-16 16:09:24 -0700442};
443#define VFIO_IOMMU_UNMAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 14)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700444#define VFIO_IOMMU_ENABLE _IO(VFIO_TYPE, VFIO_BASE + 15)
Christopher Ferris38062f92014-07-09 15:33:25 -0700445#define VFIO_IOMMU_DISABLE _IO(VFIO_TYPE, VFIO_BASE + 16)
Christopher Ferris8177cdf2020-08-03 11:53:55 -0700446struct vfio_iommu_type1_dirty_bitmap {
447 __u32 argsz;
448 __u32 flags;
449#define VFIO_IOMMU_DIRTY_PAGES_FLAG_START (1 << 0)
450#define VFIO_IOMMU_DIRTY_PAGES_FLAG_STOP (1 << 1)
451#define VFIO_IOMMU_DIRTY_PAGES_FLAG_GET_BITMAP (1 << 2)
452 __u8 data[];
453};
454struct vfio_iommu_type1_dirty_bitmap_get {
455 __u64 iova;
456 __u64 size;
457 struct vfio_bitmap bitmap;
458};
459#define VFIO_IOMMU_DIRTY_PAGES _IO(VFIO_TYPE, VFIO_BASE + 17)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800460struct vfio_iommu_spapr_tce_ddw_info {
461 __u64 pgsizes;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700462 __u32 max_dynamic_windows_supported;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800463 __u32 levels;
464};
Christopher Ferris38062f92014-07-09 15:33:25 -0700465struct vfio_iommu_spapr_tce_info {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700466 __u32 argsz;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800467 __u32 flags;
468#define VFIO_IOMMU_SPAPR_INFO_DDW (1 << 0)
Tao Baod7db5942015-01-28 10:07:51 -0800469 __u32 dma32_window_start;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700470 __u32 dma32_window_size;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800471 struct vfio_iommu_spapr_tce_ddw_info ddw;
Christopher Ferris38062f92014-07-09 15:33:25 -0700472};
473#define VFIO_IOMMU_SPAPR_TCE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700474struct vfio_eeh_pe_err {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800475 __u32 type;
476 __u32 func;
477 __u64 addr;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700478 __u64 mask;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800479};
Christopher Ferris82d75042015-01-26 10:57:07 -0800480struct vfio_eeh_pe_op {
Tao Baod7db5942015-01-28 10:07:51 -0800481 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700482 __u32 flags;
Tao Baod7db5942015-01-28 10:07:51 -0800483 __u32 op;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800484 union {
485 struct vfio_eeh_pe_err err;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700486 };
Christopher Ferris82d75042015-01-26 10:57:07 -0800487};
488#define VFIO_EEH_PE_DISABLE 0
489#define VFIO_EEH_PE_ENABLE 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700490#define VFIO_EEH_PE_UNFREEZE_IO 2
Christopher Ferris82d75042015-01-26 10:57:07 -0800491#define VFIO_EEH_PE_UNFREEZE_DMA 3
492#define VFIO_EEH_PE_GET_STATE 4
493#define VFIO_EEH_PE_STATE_NORMAL 0
Christopher Ferris106b3a82016-08-24 12:15:38 -0700494#define VFIO_EEH_PE_STATE_RESET 1
Christopher Ferris82d75042015-01-26 10:57:07 -0800495#define VFIO_EEH_PE_STATE_STOPPED 2
496#define VFIO_EEH_PE_STATE_STOPPED_DMA 4
497#define VFIO_EEH_PE_STATE_UNAVAIL 5
Christopher Ferris106b3a82016-08-24 12:15:38 -0700498#define VFIO_EEH_PE_RESET_DEACTIVATE 5
Christopher Ferris82d75042015-01-26 10:57:07 -0800499#define VFIO_EEH_PE_RESET_HOT 6
500#define VFIO_EEH_PE_RESET_FUNDAMENTAL 7
501#define VFIO_EEH_PE_CONFIGURE 8
Christopher Ferris106b3a82016-08-24 12:15:38 -0700502#define VFIO_EEH_PE_INJECT_ERR 9
Christopher Ferris82d75042015-01-26 10:57:07 -0800503#define VFIO_EEH_PE_OP _IO(VFIO_TYPE, VFIO_BASE + 21)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800504struct vfio_iommu_spapr_register_memory {
505 __u32 argsz;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700506 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800507 __u64 vaddr;
508 __u64 size;
509};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700510#define VFIO_IOMMU_SPAPR_REGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 17)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800511#define VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 18)
512struct vfio_iommu_spapr_tce_create {
513 __u32 argsz;
514 __u32 flags;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800515 __u32 page_shift;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700516 __u32 __resv1;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800517 __u64 window_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700518 __u32 levels;
519 __u32 __resv2;
520 __u64 start_addr;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800521};
522#define VFIO_IOMMU_SPAPR_TCE_CREATE _IO(VFIO_TYPE, VFIO_BASE + 19)
523struct vfio_iommu_spapr_tce_remove {
524 __u32 argsz;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800525 __u32 flags;
526 __u64 start_addr;
527};
528#define VFIO_IOMMU_SPAPR_TCE_REMOVE _IO(VFIO_TYPE, VFIO_BASE + 20)
Ben Cheng655a7c02013-10-16 16:09:24 -0700529#endif