blob: a9e6b52372e308e43eec5cc6cc3d503523accf8d [file] [log] [blame]
Christopher Ferris8b7fdc92023-02-21 13:36:32 -08001/****************************************************************************
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 _UAPI_IOMMUFD_H
20#define _UAPI_IOMMUFD_H
21#include <linux/types.h>
22#include <linux/ioctl.h>
23#define IOMMUFD_TYPE (';')
24enum {
25 IOMMUFD_CMD_BASE = 0x80,
26 IOMMUFD_CMD_DESTROY = IOMMUFD_CMD_BASE,
27 IOMMUFD_CMD_IOAS_ALLOC,
28 IOMMUFD_CMD_IOAS_ALLOW_IOVAS,
29 IOMMUFD_CMD_IOAS_COPY,
30 IOMMUFD_CMD_IOAS_IOVA_RANGES,
31 IOMMUFD_CMD_IOAS_MAP,
32 IOMMUFD_CMD_IOAS_UNMAP,
33 IOMMUFD_CMD_OPTION,
34 IOMMUFD_CMD_VFIO_IOAS,
Christopher Ferris67d1e5e2023-10-31 13:36:37 -070035 IOMMUFD_CMD_HWPT_ALLOC,
36 IOMMUFD_CMD_GET_HW_INFO,
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080037};
38struct iommu_destroy {
39 __u32 size;
40 __u32 id;
41};
42#define IOMMU_DESTROY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_DESTROY)
43struct iommu_ioas_alloc {
44 __u32 size;
45 __u32 flags;
46 __u32 out_ioas_id;
47};
48#define IOMMU_IOAS_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOC)
49struct iommu_iova_range {
50 __aligned_u64 start;
51 __aligned_u64 last;
52};
53struct iommu_ioas_iova_ranges {
54 __u32 size;
55 __u32 ioas_id;
56 __u32 num_iovas;
57 __u32 __reserved;
58 __aligned_u64 allowed_iovas;
59 __aligned_u64 out_iova_alignment;
60};
61#define IOMMU_IOAS_IOVA_RANGES _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_IOVA_RANGES)
62struct iommu_ioas_allow_iovas {
63 __u32 size;
64 __u32 ioas_id;
65 __u32 num_iovas;
66 __u32 __reserved;
67 __aligned_u64 allowed_iovas;
68};
69#define IOMMU_IOAS_ALLOW_IOVAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOW_IOVAS)
70enum iommufd_ioas_map_flags {
71 IOMMU_IOAS_MAP_FIXED_IOVA = 1 << 0,
72 IOMMU_IOAS_MAP_WRITEABLE = 1 << 1,
73 IOMMU_IOAS_MAP_READABLE = 1 << 2,
74};
75struct iommu_ioas_map {
76 __u32 size;
77 __u32 flags;
78 __u32 ioas_id;
79 __u32 __reserved;
80 __aligned_u64 user_va;
81 __aligned_u64 length;
82 __aligned_u64 iova;
83};
84#define IOMMU_IOAS_MAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP)
85struct iommu_ioas_copy {
86 __u32 size;
87 __u32 flags;
88 __u32 dst_ioas_id;
89 __u32 src_ioas_id;
90 __aligned_u64 length;
91 __aligned_u64 dst_iova;
92 __aligned_u64 src_iova;
93};
94#define IOMMU_IOAS_COPY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_COPY)
95struct iommu_ioas_unmap {
96 __u32 size;
97 __u32 ioas_id;
98 __aligned_u64 iova;
99 __aligned_u64 length;
100};
101#define IOMMU_IOAS_UNMAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_UNMAP)
102enum iommufd_option {
103 IOMMU_OPTION_RLIMIT_MODE = 0,
104 IOMMU_OPTION_HUGE_PAGES = 1,
105};
106enum iommufd_option_ops {
107 IOMMU_OPTION_OP_SET = 0,
108 IOMMU_OPTION_OP_GET = 1,
109};
110struct iommu_option {
111 __u32 size;
112 __u32 option_id;
113 __u16 op;
114 __u16 __reserved;
115 __u32 object_id;
116 __aligned_u64 val64;
117};
118#define IOMMU_OPTION _IO(IOMMUFD_TYPE, IOMMUFD_CMD_OPTION)
119enum iommufd_vfio_ioas_op {
120 IOMMU_VFIO_IOAS_GET = 0,
121 IOMMU_VFIO_IOAS_SET = 1,
122 IOMMU_VFIO_IOAS_CLEAR = 2,
123};
124struct iommu_vfio_ioas {
125 __u32 size;
126 __u32 ioas_id;
127 __u16 op;
128 __u16 __reserved;
129};
130#define IOMMU_VFIO_IOAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VFIO_IOAS)
Christopher Ferris67d1e5e2023-10-31 13:36:37 -0700131struct iommu_hwpt_alloc {
132 __u32 size;
133 __u32 flags;
134 __u32 dev_id;
135 __u32 pt_id;
136 __u32 out_hwpt_id;
137 __u32 __reserved;
138};
139#define IOMMU_HWPT_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_ALLOC)
140struct iommu_hw_info_vtd {
141 __u32 flags;
142 __u32 __reserved;
143 __aligned_u64 cap_reg;
144 __aligned_u64 ecap_reg;
145};
146enum iommu_hw_info_type {
147 IOMMU_HW_INFO_TYPE_NONE,
148 IOMMU_HW_INFO_TYPE_INTEL_VTD,
149};
150struct iommu_hw_info {
151 __u32 size;
152 __u32 flags;
153 __u32 dev_id;
154 __u32 data_len;
155 __aligned_u64 data_uptr;
156 __u32 out_data_type;
157 __u32 __reserved;
158};
159#define IOMMU_GET_HW_INFO _IO(IOMMUFD_TYPE, IOMMUFD_CMD_GET_HW_INFO)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800160#endif