Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 1 | /**************************************************************************** |
| 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 Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 23 | #define VFIO_API_VERSION 0 |
| 24 | #define VFIO_TYPE1_IOMMU 1 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 25 | #define VFIO_SPAPR_TCE_IOMMU 2 |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 26 | #define VFIO_TYPE1v2_IOMMU 3 |
Christopher Ferris | ba8d4f4 | 2014-09-03 19:56:49 -0700 | [diff] [blame] | 27 | #define VFIO_DMA_CC_IOMMU 4 |
Christopher Ferris | 82d7504 | 2015-01-26 10:57:07 -0800 | [diff] [blame] | 28 | #define VFIO_EEH 5 |
| 29 | #define VFIO_TYPE1_NESTING_IOMMU 6 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 30 | #define VFIO_SPAPR_TCE_v2_IOMMU 7 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 31 | #define VFIO_NOIOMMU_IOMMU 8 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 32 | #define VFIO_TYPE (';') |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 33 | #define VFIO_BASE 100 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 34 | struct vfio_info_cap_header { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 35 | __u16 id; |
| 36 | __u16 version; |
| 37 | __u32 next; |
| 38 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 39 | #define VFIO_GET_API_VERSION _IO(VFIO_TYPE, VFIO_BASE + 0) |
| 40 | #define VFIO_CHECK_EXTENSION _IO(VFIO_TYPE, VFIO_BASE + 1) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 41 | #define VFIO_SET_IOMMU _IO(VFIO_TYPE, VFIO_BASE + 2) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 42 | struct vfio_group_status { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 43 | __u32 argsz; |
| 44 | __u32 flags; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 45 | #define VFIO_GROUP_FLAGS_VIABLE (1 << 0) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 46 | #define VFIO_GROUP_FLAGS_CONTAINER_SET (1 << 1) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 47 | }; |
| 48 | #define VFIO_GROUP_GET_STATUS _IO(VFIO_TYPE, VFIO_BASE + 3) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 49 | #define VFIO_GROUP_SET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 4) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 50 | #define VFIO_GROUP_UNSET_CONTAINER _IO(VFIO_TYPE, VFIO_BASE + 5) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 51 | #define VFIO_GROUP_GET_DEVICE_FD _IO(VFIO_TYPE, VFIO_BASE + 6) |
| 52 | struct vfio_device_info { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 53 | __u32 argsz; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 54 | __u32 flags; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 55 | #define VFIO_DEVICE_FLAGS_RESET (1 << 0) |
| 56 | #define VFIO_DEVICE_FLAGS_PCI (1 << 1) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 57 | #define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2) |
| 58 | #define VFIO_DEVICE_FLAGS_AMBA (1 << 3) |
Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 59 | #define VFIO_DEVICE_FLAGS_CCW (1 << 4) |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 60 | #define VFIO_DEVICE_FLAGS_AP (1 << 5) |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 61 | #define VFIO_DEVICE_FLAGS_FSL_MC (1 << 6) |
| 62 | #define VFIO_DEVICE_FLAGS_CAPS (1 << 7) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 63 | __u32 num_regions; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 64 | __u32 num_irqs; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 65 | __u32 cap_offset; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 66 | }; |
| 67 | #define VFIO_DEVICE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 7) |
Christopher Ferris | 48af7cb | 2017-02-21 12:35:09 -0800 | [diff] [blame] | 68 | #define VFIO_DEVICE_API_PCI_STRING "vfio-pci" |
| 69 | #define VFIO_DEVICE_API_PLATFORM_STRING "vfio-platform" |
| 70 | #define VFIO_DEVICE_API_AMBA_STRING "vfio-amba" |
Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 71 | #define VFIO_DEVICE_API_CCW_STRING "vfio-ccw" |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 72 | #define VFIO_DEVICE_API_AP_STRING "vfio-ap" |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 73 | #define VFIO_DEVICE_INFO_CAP_ZPCI_BASE 1 |
| 74 | #define VFIO_DEVICE_INFO_CAP_ZPCI_GROUP 2 |
| 75 | #define VFIO_DEVICE_INFO_CAP_ZPCI_UTIL 3 |
| 76 | #define VFIO_DEVICE_INFO_CAP_ZPCI_PFIP 4 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 77 | struct vfio_region_info { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 78 | __u32 argsz; |
| 79 | __u32 flags; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 80 | #define VFIO_REGION_INFO_FLAG_READ (1 << 0) |
| 81 | #define VFIO_REGION_INFO_FLAG_WRITE (1 << 1) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 82 | #define VFIO_REGION_INFO_FLAG_MMAP (1 << 2) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 83 | #define VFIO_REGION_INFO_FLAG_CAPS (1 << 3) |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 84 | __u32 index; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 85 | __u32 cap_offset; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 86 | __u64 size; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 87 | __u64 offset; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 88 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 89 | #define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8) |
| 90 | #define VFIO_REGION_INFO_CAP_SPARSE_MMAP 1 |
| 91 | struct vfio_region_sparse_mmap_area { |
| 92 | __u64 offset; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 93 | __u64 size; |
| 94 | }; |
| 95 | struct vfio_region_info_cap_sparse_mmap { |
| 96 | struct vfio_info_cap_header header; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 97 | __u32 nr_areas; |
| 98 | __u32 reserved; |
| 99 | struct vfio_region_sparse_mmap_area areas[]; |
| 100 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 101 | #define VFIO_REGION_INFO_CAP_TYPE 2 |
| 102 | struct vfio_region_info_cap_type { |
| 103 | struct vfio_info_cap_header header; |
| 104 | __u32 type; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 105 | __u32 subtype; |
| 106 | }; |
| 107 | #define VFIO_REGION_TYPE_PCI_VENDOR_TYPE (1 << 31) |
| 108 | #define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff) |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 109 | #define VFIO_REGION_TYPE_GFX (1) |
| 110 | #define VFIO_REGION_TYPE_CCW (2) |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 111 | #define VFIO_REGION_TYPE_MIGRATION (3) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 112 | #define VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION (1) |
| 113 | #define VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG (2) |
| 114 | #define VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG (3) |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 115 | #define VFIO_REGION_SUBTYPE_NVIDIA_NVLINK2_RAM (1) |
| 116 | #define VFIO_REGION_SUBTYPE_IBM_NVLINK2_ATSD (1) |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 117 | #define VFIO_REGION_SUBTYPE_GFX_EDID (1) |
| 118 | struct vfio_region_gfx_edid { |
| 119 | __u32 edid_offset; |
| 120 | __u32 edid_max_size; |
| 121 | __u32 edid_size; |
| 122 | __u32 max_xres; |
| 123 | __u32 max_yres; |
| 124 | __u32 link_state; |
| 125 | #define VFIO_DEVICE_GFX_LINK_STATE_UP 1 |
| 126 | #define VFIO_DEVICE_GFX_LINK_STATE_DOWN 2 |
| 127 | }; |
Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 128 | #define VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD (1) |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 129 | #define VFIO_REGION_SUBTYPE_CCW_SCHIB (2) |
| 130 | #define VFIO_REGION_SUBTYPE_CCW_CRW (3) |
| 131 | #define VFIO_REGION_SUBTYPE_MIGRATION (1) |
| 132 | struct vfio_device_migration_info { |
| 133 | __u32 device_state; |
| 134 | #define VFIO_DEVICE_STATE_STOP (0) |
| 135 | #define VFIO_DEVICE_STATE_RUNNING (1 << 0) |
| 136 | #define VFIO_DEVICE_STATE_SAVING (1 << 1) |
| 137 | #define VFIO_DEVICE_STATE_RESUMING (1 << 2) |
| 138 | #define VFIO_DEVICE_STATE_MASK (VFIO_DEVICE_STATE_RUNNING | VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING) |
| 139 | #define VFIO_DEVICE_STATE_VALID(state) (state & VFIO_DEVICE_STATE_RESUMING ? (state & VFIO_DEVICE_STATE_MASK) == VFIO_DEVICE_STATE_RESUMING : 1) |
| 140 | #define VFIO_DEVICE_STATE_IS_ERROR(state) ((state & VFIO_DEVICE_STATE_MASK) == (VFIO_DEVICE_STATE_SAVING | VFIO_DEVICE_STATE_RESUMING)) |
| 141 | #define VFIO_DEVICE_STATE_SET_ERROR(state) ((state & ~VFIO_DEVICE_STATE_MASK) | VFIO_DEVICE_SATE_SAVING | VFIO_DEVICE_STATE_RESUMING) |
| 142 | __u32 reserved; |
| 143 | __u64 pending_bytes; |
| 144 | __u64 data_offset; |
| 145 | __u64 data_size; |
| 146 | }; |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 147 | #define VFIO_REGION_INFO_CAP_MSIX_MAPPABLE 3 |
Christopher Ferris | d842e43 | 2019-03-07 10:21:59 -0800 | [diff] [blame] | 148 | #define VFIO_REGION_INFO_CAP_NVLINK2_SSATGT 4 |
| 149 | struct vfio_region_info_cap_nvlink2_ssatgt { |
| 150 | struct vfio_info_cap_header header; |
| 151 | __u64 tgt; |
| 152 | }; |
| 153 | #define VFIO_REGION_INFO_CAP_NVLINK2_LNKSPD 5 |
| 154 | struct vfio_region_info_cap_nvlink2_lnkspd { |
| 155 | struct vfio_info_cap_header header; |
| 156 | __u32 link_speed; |
| 157 | __u32 __pad; |
| 158 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 159 | struct vfio_irq_info { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 160 | __u32 argsz; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 161 | __u32 flags; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 162 | #define VFIO_IRQ_INFO_EVENTFD (1 << 0) |
| 163 | #define VFIO_IRQ_INFO_MASKABLE (1 << 1) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 164 | #define VFIO_IRQ_INFO_AUTOMASKED (1 << 2) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 165 | #define VFIO_IRQ_INFO_NORESIZE (1 << 3) |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 166 | __u32 index; |
| 167 | __u32 count; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 168 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 169 | #define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE + 9) |
| 170 | struct vfio_irq_set { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 171 | __u32 argsz; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 172 | __u32 flags; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 173 | #define VFIO_IRQ_SET_DATA_NONE (1 << 0) |
| 174 | #define VFIO_IRQ_SET_DATA_BOOL (1 << 1) |
| 175 | #define VFIO_IRQ_SET_DATA_EVENTFD (1 << 2) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 176 | #define VFIO_IRQ_SET_ACTION_MASK (1 << 3) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 177 | #define VFIO_IRQ_SET_ACTION_UNMASK (1 << 4) |
| 178 | #define VFIO_IRQ_SET_ACTION_TRIGGER (1 << 5) |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 179 | __u32 index; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 180 | __u32 start; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 181 | __u32 count; |
| 182 | __u8 data[]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 183 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 184 | #define VFIO_DEVICE_SET_IRQS _IO(VFIO_TYPE, VFIO_BASE + 10) |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 185 | #define VFIO_IRQ_SET_DATA_TYPE_MASK (VFIO_IRQ_SET_DATA_NONE | VFIO_IRQ_SET_DATA_BOOL | VFIO_IRQ_SET_DATA_EVENTFD) |
| 186 | #define VFIO_IRQ_SET_ACTION_TYPE_MASK (VFIO_IRQ_SET_ACTION_MASK | VFIO_IRQ_SET_ACTION_UNMASK | VFIO_IRQ_SET_ACTION_TRIGGER) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 187 | #define VFIO_DEVICE_RESET _IO(VFIO_TYPE, VFIO_BASE + 11) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 188 | enum { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 189 | VFIO_PCI_BAR0_REGION_INDEX, |
| 190 | VFIO_PCI_BAR1_REGION_INDEX, |
| 191 | VFIO_PCI_BAR2_REGION_INDEX, |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 192 | VFIO_PCI_BAR3_REGION_INDEX, |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 193 | VFIO_PCI_BAR4_REGION_INDEX, |
| 194 | VFIO_PCI_BAR5_REGION_INDEX, |
| 195 | VFIO_PCI_ROM_REGION_INDEX, |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 196 | VFIO_PCI_CONFIG_REGION_INDEX, |
| 197 | VFIO_PCI_VGA_REGION_INDEX, |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 198 | VFIO_PCI_NUM_REGIONS = 9 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 199 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 200 | enum { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 201 | VFIO_PCI_INTX_IRQ_INDEX, |
| 202 | VFIO_PCI_MSI_IRQ_INDEX, |
| 203 | VFIO_PCI_MSIX_IRQ_INDEX, |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 204 | VFIO_PCI_ERR_IRQ_INDEX, |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 205 | VFIO_PCI_REQ_IRQ_INDEX, |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 206 | VFIO_PCI_NUM_IRQS |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 207 | }; |
Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 208 | enum { |
| 209 | VFIO_CCW_CONFIG_REGION_INDEX, |
| 210 | VFIO_CCW_NUM_REGIONS |
| 211 | }; |
| 212 | enum { |
| 213 | VFIO_CCW_IO_IRQ_INDEX, |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 214 | VFIO_CCW_CRW_IRQ_INDEX, |
Christopher Ferris | 05667cd | 2021-02-16 16:01:34 -0800 | [diff] [blame] | 215 | VFIO_CCW_REQ_IRQ_INDEX, |
Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 216 | VFIO_CCW_NUM_IRQS |
| 217 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 218 | struct vfio_pci_dependent_device { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 219 | __u32 group_id; |
| 220 | __u16 segment; |
| 221 | __u8 bus; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 222 | __u8 devfn; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 223 | }; |
| 224 | struct vfio_pci_hot_reset_info { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 225 | __u32 argsz; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 226 | __u32 flags; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 227 | __u32 count; |
| 228 | struct vfio_pci_dependent_device devices[]; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 229 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 230 | #define VFIO_DEVICE_GET_PCI_HOT_RESET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 231 | struct vfio_pci_hot_reset { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 232 | __u32 argsz; |
| 233 | __u32 flags; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 234 | __u32 count; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 235 | __s32 group_fds[]; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 236 | }; |
| 237 | #define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) |
Christopher Ferris | 76a1d45 | 2018-06-27 14:12:29 -0700 | [diff] [blame] | 238 | struct vfio_device_gfx_plane_info { |
| 239 | __u32 argsz; |
| 240 | __u32 flags; |
| 241 | #define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0) |
| 242 | #define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1) |
| 243 | #define VFIO_GFX_PLANE_TYPE_REGION (1 << 2) |
| 244 | __u32 drm_plane_type; |
| 245 | __u32 drm_format; |
| 246 | __u64 drm_format_mod; |
| 247 | __u32 width; |
| 248 | __u32 height; |
| 249 | __u32 stride; |
| 250 | __u32 size; |
| 251 | __u32 x_pos; |
| 252 | __u32 y_pos; |
| 253 | __u32 x_hot; |
| 254 | __u32 y_hot; |
| 255 | union { |
| 256 | __u32 region_index; |
| 257 | __u32 dmabuf_id; |
| 258 | }; |
| 259 | }; |
| 260 | #define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14) |
| 261 | #define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15) |
| 262 | struct vfio_device_ioeventfd { |
| 263 | __u32 argsz; |
| 264 | __u32 flags; |
| 265 | #define VFIO_DEVICE_IOEVENTFD_8 (1 << 0) |
| 266 | #define VFIO_DEVICE_IOEVENTFD_16 (1 << 1) |
| 267 | #define VFIO_DEVICE_IOEVENTFD_32 (1 << 2) |
| 268 | #define VFIO_DEVICE_IOEVENTFD_64 (1 << 3) |
| 269 | #define VFIO_DEVICE_IOEVENTFD_SIZE_MASK (0xf) |
| 270 | __u64 offset; |
| 271 | __u64 data; |
| 272 | __s32 fd; |
| 273 | }; |
| 274 | #define VFIO_DEVICE_IOEVENTFD _IO(VFIO_TYPE, VFIO_BASE + 16) |
Christopher Ferris | af09c70 | 2020-06-01 20:29:29 -0700 | [diff] [blame] | 275 | struct vfio_device_feature { |
| 276 | __u32 argsz; |
| 277 | __u32 flags; |
| 278 | #define VFIO_DEVICE_FEATURE_MASK (0xffff) |
| 279 | #define VFIO_DEVICE_FEATURE_GET (1 << 16) |
| 280 | #define VFIO_DEVICE_FEATURE_SET (1 << 17) |
| 281 | #define VFIO_DEVICE_FEATURE_PROBE (1 << 18) |
| 282 | __u8 data[]; |
| 283 | }; |
| 284 | #define VFIO_DEVICE_FEATURE _IO(VFIO_TYPE, VFIO_BASE + 17) |
| 285 | #define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN (0) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 286 | struct vfio_iommu_type1_info { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 287 | __u32 argsz; |
| 288 | __u32 flags; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 289 | #define VFIO_IOMMU_INFO_PGSIZES (1 << 0) |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 290 | #define VFIO_IOMMU_INFO_CAPS (1 << 1) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 291 | __u64 iova_pgsizes; |
Christopher Ferris | 9584fa4 | 2019-12-09 15:36:13 -0800 | [diff] [blame] | 292 | __u32 cap_offset; |
| 293 | }; |
| 294 | #define VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE 1 |
| 295 | struct vfio_iova_range { |
| 296 | __u64 start; |
| 297 | __u64 end; |
| 298 | }; |
| 299 | struct vfio_iommu_type1_info_cap_iova_range { |
| 300 | struct vfio_info_cap_header header; |
| 301 | __u32 nr_iovas; |
| 302 | __u32 reserved; |
| 303 | struct vfio_iova_range iova_ranges[]; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 304 | }; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 305 | #define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 2 |
| 306 | struct vfio_iommu_type1_info_cap_migration { |
| 307 | struct vfio_info_cap_header header; |
| 308 | __u32 flags; |
| 309 | __u64 pgsize_bitmap; |
| 310 | __u64 max_dirty_bitmap_size; |
| 311 | }; |
Christopher Ferris | 32ff3f8 | 2020-12-14 13:10:04 -0800 | [diff] [blame] | 312 | #define VFIO_IOMMU_TYPE1_INFO_DMA_AVAIL 3 |
| 313 | struct vfio_iommu_type1_info_dma_avail { |
| 314 | struct vfio_info_cap_header header; |
| 315 | __u32 avail; |
| 316 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 317 | #define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) |
| 318 | struct vfio_iommu_type1_dma_map { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 319 | __u32 argsz; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 320 | __u32 flags; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 321 | #define VFIO_DMA_MAP_FLAG_READ (1 << 0) |
| 322 | #define VFIO_DMA_MAP_FLAG_WRITE (1 << 1) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 323 | __u64 vaddr; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 324 | __u64 iova; |
| 325 | __u64 size; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 326 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 327 | #define VFIO_IOMMU_MAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 13) |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 328 | struct vfio_bitmap { |
| 329 | __u64 pgsize; |
| 330 | __u64 size; |
| 331 | __u64 __user * data; |
| 332 | }; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 333 | struct vfio_iommu_type1_dma_unmap { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 334 | __u32 argsz; |
| 335 | __u32 flags; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 336 | #define VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP (1 << 0) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 337 | __u64 iova; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 338 | __u64 size; |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 339 | __u8 data[]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 340 | }; |
| 341 | #define VFIO_IOMMU_UNMAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 14) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 342 | #define VFIO_IOMMU_ENABLE _IO(VFIO_TYPE, VFIO_BASE + 15) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 343 | #define VFIO_IOMMU_DISABLE _IO(VFIO_TYPE, VFIO_BASE + 16) |
Christopher Ferris | 8177cdf | 2020-08-03 11:53:55 -0700 | [diff] [blame] | 344 | struct vfio_iommu_type1_dirty_bitmap { |
| 345 | __u32 argsz; |
| 346 | __u32 flags; |
| 347 | #define VFIO_IOMMU_DIRTY_PAGES_FLAG_START (1 << 0) |
| 348 | #define VFIO_IOMMU_DIRTY_PAGES_FLAG_STOP (1 << 1) |
| 349 | #define VFIO_IOMMU_DIRTY_PAGES_FLAG_GET_BITMAP (1 << 2) |
| 350 | __u8 data[]; |
| 351 | }; |
| 352 | struct vfio_iommu_type1_dirty_bitmap_get { |
| 353 | __u64 iova; |
| 354 | __u64 size; |
| 355 | struct vfio_bitmap bitmap; |
| 356 | }; |
| 357 | #define VFIO_IOMMU_DIRTY_PAGES _IO(VFIO_TYPE, VFIO_BASE + 17) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 358 | struct vfio_iommu_spapr_tce_ddw_info { |
| 359 | __u64 pgsizes; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 360 | __u32 max_dynamic_windows_supported; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 361 | __u32 levels; |
| 362 | }; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 363 | struct vfio_iommu_spapr_tce_info { |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 364 | __u32 argsz; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 365 | __u32 flags; |
| 366 | #define VFIO_IOMMU_SPAPR_INFO_DDW (1 << 0) |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 367 | __u32 dma32_window_start; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 368 | __u32 dma32_window_size; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 369 | struct vfio_iommu_spapr_tce_ddw_info ddw; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 370 | }; |
| 371 | #define VFIO_IOMMU_SPAPR_TCE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 372 | struct vfio_eeh_pe_err { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 373 | __u32 type; |
| 374 | __u32 func; |
| 375 | __u64 addr; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 376 | __u64 mask; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 377 | }; |
Christopher Ferris | 82d7504 | 2015-01-26 10:57:07 -0800 | [diff] [blame] | 378 | struct vfio_eeh_pe_op { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 379 | __u32 argsz; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 380 | __u32 flags; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 381 | __u32 op; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 382 | union { |
| 383 | struct vfio_eeh_pe_err err; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 384 | }; |
Christopher Ferris | 82d7504 | 2015-01-26 10:57:07 -0800 | [diff] [blame] | 385 | }; |
| 386 | #define VFIO_EEH_PE_DISABLE 0 |
| 387 | #define VFIO_EEH_PE_ENABLE 1 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 388 | #define VFIO_EEH_PE_UNFREEZE_IO 2 |
Christopher Ferris | 82d7504 | 2015-01-26 10:57:07 -0800 | [diff] [blame] | 389 | #define VFIO_EEH_PE_UNFREEZE_DMA 3 |
| 390 | #define VFIO_EEH_PE_GET_STATE 4 |
| 391 | #define VFIO_EEH_PE_STATE_NORMAL 0 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 392 | #define VFIO_EEH_PE_STATE_RESET 1 |
Christopher Ferris | 82d7504 | 2015-01-26 10:57:07 -0800 | [diff] [blame] | 393 | #define VFIO_EEH_PE_STATE_STOPPED 2 |
| 394 | #define VFIO_EEH_PE_STATE_STOPPED_DMA 4 |
| 395 | #define VFIO_EEH_PE_STATE_UNAVAIL 5 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 396 | #define VFIO_EEH_PE_RESET_DEACTIVATE 5 |
Christopher Ferris | 82d7504 | 2015-01-26 10:57:07 -0800 | [diff] [blame] | 397 | #define VFIO_EEH_PE_RESET_HOT 6 |
| 398 | #define VFIO_EEH_PE_RESET_FUNDAMENTAL 7 |
| 399 | #define VFIO_EEH_PE_CONFIGURE 8 |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 400 | #define VFIO_EEH_PE_INJECT_ERR 9 |
Christopher Ferris | 82d7504 | 2015-01-26 10:57:07 -0800 | [diff] [blame] | 401 | #define VFIO_EEH_PE_OP _IO(VFIO_TYPE, VFIO_BASE + 21) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 402 | struct vfio_iommu_spapr_register_memory { |
| 403 | __u32 argsz; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 404 | __u32 flags; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 405 | __u64 vaddr; |
| 406 | __u64 size; |
| 407 | }; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 408 | #define VFIO_IOMMU_SPAPR_REGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 17) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 409 | #define VFIO_IOMMU_SPAPR_UNREGISTER_MEMORY _IO(VFIO_TYPE, VFIO_BASE + 18) |
| 410 | struct vfio_iommu_spapr_tce_create { |
| 411 | __u32 argsz; |
| 412 | __u32 flags; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 413 | __u32 page_shift; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 414 | __u32 __resv1; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 415 | __u64 window_size; |
Christopher Ferris | 106b3a8 | 2016-08-24 12:15:38 -0700 | [diff] [blame] | 416 | __u32 levels; |
| 417 | __u32 __resv2; |
| 418 | __u64 start_addr; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 419 | }; |
| 420 | #define VFIO_IOMMU_SPAPR_TCE_CREATE _IO(VFIO_TYPE, VFIO_BASE + 19) |
| 421 | struct vfio_iommu_spapr_tce_remove { |
| 422 | __u32 argsz; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 423 | __u32 flags; |
| 424 | __u64 start_addr; |
| 425 | }; |
| 426 | #define VFIO_IOMMU_SPAPR_TCE_REMOVE _IO(VFIO_TYPE, VFIO_BASE + 20) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 427 | #endif |