1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #ifndef _CXLFLASH_IOCTL_H
17 #define _CXLFLASH_IOCTL_H
18
19 #include <linux/types.h>
20
21
22
23
24 #define CXLFLASH_WWID_LEN 16
25
26
27
28
29
30 #define DK_CXLFLASH_VERSION_0 0
31
32 struct dk_cxlflash_hdr {
33 __u16 version;
34 __u16 rsvd[3];
35 __u64 flags;
36 __u64 return_flags;
37 };
38
39
40
41
42
43
44
45
46
47 #define DK_CXLFLASH_ALL_PORTS_ACTIVE 0x0000000000000001ULL
48 #define DK_CXLFLASH_APP_CLOSE_ADAP_FD 0x0000000000000002ULL
49 #define DK_CXLFLASH_CONTEXT_SQ_CMD_MODE 0x0000000000000004ULL
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 #define DK_CXLFLASH_ATTACH_REUSE_CONTEXT 0x8000000000000000ULL
73
74 struct dk_cxlflash_attach {
75 struct dk_cxlflash_hdr hdr;
76 __u64 num_interrupts;
77 __u64 context_id;
78 __u64 mmio_size;
79 __u64 block_size;
80 __u64 adap_fd;
81 __u64 last_lba;
82 __u64 max_xfer;
83 __u64 reserved[8];
84 };
85
86 struct dk_cxlflash_detach {
87 struct dk_cxlflash_hdr hdr;
88 __u64 context_id;
89 __u64 reserved[8];
90 };
91
92 struct dk_cxlflash_udirect {
93 struct dk_cxlflash_hdr hdr;
94 __u64 context_id;
95 __u64 rsrc_handle;
96 __u64 last_lba;
97 __u64 reserved[8];
98 };
99
100 #define DK_CXLFLASH_UVIRTUAL_NEED_WRITE_SAME 0x8000000000000000ULL
101
102 struct dk_cxlflash_uvirtual {
103 struct dk_cxlflash_hdr hdr;
104 __u64 context_id;
105 __u64 lun_size;
106 __u64 rsrc_handle;
107 __u64 last_lba;
108 __u64 reserved[8];
109 };
110
111 struct dk_cxlflash_release {
112 struct dk_cxlflash_hdr hdr;
113 __u64 context_id;
114 __u64 rsrc_handle;
115 __u64 reserved[8];
116 };
117
118 struct dk_cxlflash_resize {
119 struct dk_cxlflash_hdr hdr;
120 __u64 context_id;
121 __u64 rsrc_handle;
122 __u64 req_size;
123 __u64 last_lba;
124 __u64 reserved[8];
125 };
126
127 struct dk_cxlflash_clone {
128 struct dk_cxlflash_hdr hdr;
129 __u64 context_id_src;
130 __u64 context_id_dst;
131 __u64 adap_fd_src;
132 __u64 reserved[8];
133 };
134
135 #define DK_CXLFLASH_VERIFY_SENSE_LEN 18
136 #define DK_CXLFLASH_VERIFY_HINT_SENSE 0x8000000000000000ULL
137
138 struct dk_cxlflash_verify {
139 struct dk_cxlflash_hdr hdr;
140 __u64 context_id;
141 __u64 rsrc_handle;
142 __u64 hint;
143 __u64 last_lba;
144 __u8 sense_data[DK_CXLFLASH_VERIFY_SENSE_LEN];
145 __u8 pad[6];
146 __u64 reserved[8];
147 };
148
149 #define DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET 0x8000000000000000ULL
150
151 struct dk_cxlflash_recover_afu {
152 struct dk_cxlflash_hdr hdr;
153 __u64 reason;
154 __u64 context_id;
155 __u64 mmio_size;
156 __u64 adap_fd;
157 __u64 reserved[8];
158 };
159
160 #define DK_CXLFLASH_MANAGE_LUN_WWID_LEN CXLFLASH_WWID_LEN
161 #define DK_CXLFLASH_MANAGE_LUN_ENABLE_SUPERPIPE 0x8000000000000000ULL
162 #define DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE 0x4000000000000000ULL
163 #define DK_CXLFLASH_MANAGE_LUN_ALL_PORTS_ACCESSIBLE 0x2000000000000000ULL
164
165 struct dk_cxlflash_manage_lun {
166 struct dk_cxlflash_hdr hdr;
167 __u8 wwid[DK_CXLFLASH_MANAGE_LUN_WWID_LEN];
168 __u64 reserved[8];
169 };
170
171 union cxlflash_ioctls {
172 struct dk_cxlflash_attach attach;
173 struct dk_cxlflash_detach detach;
174 struct dk_cxlflash_udirect udirect;
175 struct dk_cxlflash_uvirtual uvirtual;
176 struct dk_cxlflash_release release;
177 struct dk_cxlflash_resize resize;
178 struct dk_cxlflash_clone clone;
179 struct dk_cxlflash_verify verify;
180 struct dk_cxlflash_recover_afu recover_afu;
181 struct dk_cxlflash_manage_lun manage_lun;
182 };
183
184 #define MAX_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ioctls))
185
186 #define CXL_MAGIC 0xCA
187 #define CXL_IOWR(_n, _s) _IOWR(CXL_MAGIC, _n, struct _s)
188
189
190
191
192
193 #define DK_CXLFLASH_ATTACH CXL_IOWR(0x80, dk_cxlflash_attach)
194 #define DK_CXLFLASH_USER_DIRECT CXL_IOWR(0x81, dk_cxlflash_udirect)
195 #define DK_CXLFLASH_RELEASE CXL_IOWR(0x82, dk_cxlflash_release)
196 #define DK_CXLFLASH_DETACH CXL_IOWR(0x83, dk_cxlflash_detach)
197 #define DK_CXLFLASH_VERIFY CXL_IOWR(0x84, dk_cxlflash_verify)
198 #define DK_CXLFLASH_RECOVER_AFU CXL_IOWR(0x85, dk_cxlflash_recover_afu)
199 #define DK_CXLFLASH_MANAGE_LUN CXL_IOWR(0x86, dk_cxlflash_manage_lun)
200 #define DK_CXLFLASH_USER_VIRTUAL CXL_IOWR(0x87, dk_cxlflash_uvirtual)
201 #define DK_CXLFLASH_VLUN_RESIZE CXL_IOWR(0x88, dk_cxlflash_resize)
202 #define DK_CXLFLASH_VLUN_CLONE CXL_IOWR(0x89, dk_cxlflash_clone)
203
204
205
206
207
208 #define HT_CXLFLASH_VERSION_0 0
209
210 struct ht_cxlflash_hdr {
211 __u16 version;
212 __u16 subcmd;
213 __u16 rsvd[2];
214 __u64 flags;
215 __u64 return_flags;
216 };
217
218
219
220
221
222
223
224
225
226 #define HT_CXLFLASH_HOST_READ 0x0000000000000000ULL
227 #define HT_CXLFLASH_HOST_WRITE 0x0000000000000001ULL
228
229 #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_CREATE_LUN 0x0001
230 #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_DELETE_LUN 0x0002
231 #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_QUERY_PORT 0x0003
232
233 struct ht_cxlflash_lun_provision {
234 struct ht_cxlflash_hdr hdr;
235 __u16 port;
236 __u16 reserved16[3];
237 __u64 size;
238 __u64 lun_id;
239 __u8 wwid[CXLFLASH_WWID_LEN];
240 __u64 max_num_luns;
241 __u64 cur_num_luns;
242 __u64 max_cap_port;
243 __u64 cur_cap_port;
244 __u64 reserved[8];
245 };
246
247 #define HT_CXLFLASH_AFU_DEBUG_MAX_DATA_LEN 262144
248 #define HT_CXLFLASH_AFU_DEBUG_SUBCMD_LEN 12
249 struct ht_cxlflash_afu_debug {
250 struct ht_cxlflash_hdr hdr;
251 __u8 reserved8[4];
252 __u8 afu_subcmd[HT_CXLFLASH_AFU_DEBUG_SUBCMD_LEN];
253
254
255 __u64 data_ea;
256 __u32 data_len;
257 __u32 reserved32;
258 __u64 reserved[8];
259 };
260
261 union cxlflash_ht_ioctls {
262 struct ht_cxlflash_lun_provision lun_provision;
263 struct ht_cxlflash_afu_debug afu_debug;
264 };
265
266 #define MAX_HT_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ht_ioctls))
267
268
269
270
271
272 #define HT_CXLFLASH_LUN_PROVISION CXL_IOWR(0xBF, ht_cxlflash_lun_provision)
273 #define HT_CXLFLASH_AFU_DEBUG CXL_IOWR(0xBE, ht_cxlflash_afu_debug)
274
275
276 #endif