]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/uapi/scsi/cxlflash_ioctl.h
UBUNTU: Ubuntu-4.13.0-45.50
[mirror_ubuntu-artful-kernel.git] / include / uapi / scsi / cxlflash_ioctl.h
1 /*
2 * CXL Flash Device Driver
3 *
4 * Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
5 * Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
6 *
7 * Copyright (C) 2015 IBM Corporation
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15 #ifndef _CXLFLASH_IOCTL_H
16 #define _CXLFLASH_IOCTL_H
17
18 #include <linux/types.h>
19
20 /*
21 * Structure and definitions for all CXL Flash ioctls
22 */
23 #define CXLFLASH_WWID_LEN 16
24
25 /*
26 * Structure and flag definitions CXL Flash superpipe ioctls
27 */
28
29 #define DK_CXLFLASH_VERSION_0 0
30
31 struct dk_cxlflash_hdr {
32 __u16 version; /* Version data */
33 __u16 rsvd[3]; /* Reserved for future use */
34 __u64 flags; /* Input flags */
35 __u64 return_flags; /* Returned flags */
36 };
37
38 /*
39 * Return flag definitions available to all superpipe ioctls
40 *
41 * Similar to the input flags, these are grown from the bottom-up with the
42 * intention that ioctl-specific return flag definitions would grow from the
43 * top-down, allowing the two sets to co-exist. While not required/enforced
44 * at this time, this provides future flexibility.
45 */
46 #define DK_CXLFLASH_ALL_PORTS_ACTIVE 0x0000000000000001ULL
47 #define DK_CXLFLASH_APP_CLOSE_ADAP_FD 0x0000000000000002ULL
48 #define DK_CXLFLASH_CONTEXT_SQ_CMD_MODE 0x0000000000000004ULL
49
50 /*
51 * General Notes:
52 * -------------
53 * The 'context_id' field of all ioctl structures contains the context
54 * identifier for a context in the lower 32-bits (upper 32-bits are not
55 * to be used when identifying a context to the AFU). That said, the value
56 * in its entirety (all 64-bits) is to be treated as an opaque cookie and
57 * should be presented as such when issuing ioctls.
58 */
59
60 /*
61 * DK_CXLFLASH_ATTACH Notes:
62 * ------------------------
63 * Read/write access permissions are specified via the O_RDONLY, O_WRONLY,
64 * and O_RDWR flags defined in the fcntl.h header file.
65 *
66 * A valid adapter file descriptor (fd >= 0) is only returned on the initial
67 * attach (successful) of a context. When a context is shared(reused), the user
68 * is expected to already 'know' the adapter file descriptor associated with the
69 * context.
70 */
71 #define DK_CXLFLASH_ATTACH_REUSE_CONTEXT 0x8000000000000000ULL
72
73 struct dk_cxlflash_attach {
74 struct dk_cxlflash_hdr hdr; /* Common fields */
75 __u64 num_interrupts; /* Requested number of interrupts */
76 __u64 context_id; /* Returned context */
77 __u64 mmio_size; /* Returned size of MMIO area */
78 __u64 block_size; /* Returned block size, in bytes */
79 __u64 adap_fd; /* Returned adapter file descriptor */
80 __u64 last_lba; /* Returned last LBA on the device */
81 __u64 max_xfer; /* Returned max transfer size, blocks */
82 __u64 reserved[8]; /* Reserved for future use */
83 };
84
85 struct dk_cxlflash_detach {
86 struct dk_cxlflash_hdr hdr; /* Common fields */
87 __u64 context_id; /* Context to detach */
88 __u64 reserved[8]; /* Reserved for future use */
89 };
90
91 struct dk_cxlflash_udirect {
92 struct dk_cxlflash_hdr hdr; /* Common fields */
93 __u64 context_id; /* Context to own physical resources */
94 __u64 rsrc_handle; /* Returned resource handle */
95 __u64 last_lba; /* Returned last LBA on the device */
96 __u64 reserved[8]; /* Reserved for future use */
97 };
98
99 #define DK_CXLFLASH_UVIRTUAL_NEED_WRITE_SAME 0x8000000000000000ULL
100
101 struct dk_cxlflash_uvirtual {
102 struct dk_cxlflash_hdr hdr; /* Common fields */
103 __u64 context_id; /* Context to own virtual resources */
104 __u64 lun_size; /* Requested size, in 4K blocks */
105 __u64 rsrc_handle; /* Returned resource handle */
106 __u64 last_lba; /* Returned last LBA of LUN */
107 __u64 reserved[8]; /* Reserved for future use */
108 };
109
110 struct dk_cxlflash_release {
111 struct dk_cxlflash_hdr hdr; /* Common fields */
112 __u64 context_id; /* Context owning resources */
113 __u64 rsrc_handle; /* Resource handle to release */
114 __u64 reserved[8]; /* Reserved for future use */
115 };
116
117 struct dk_cxlflash_resize {
118 struct dk_cxlflash_hdr hdr; /* Common fields */
119 __u64 context_id; /* Context owning resources */
120 __u64 rsrc_handle; /* Resource handle of LUN to resize */
121 __u64 req_size; /* New requested size, in 4K blocks */
122 __u64 last_lba; /* Returned last LBA of LUN */
123 __u64 reserved[8]; /* Reserved for future use */
124 };
125
126 struct dk_cxlflash_clone {
127 struct dk_cxlflash_hdr hdr; /* Common fields */
128 __u64 context_id_src; /* Context to clone from */
129 __u64 context_id_dst; /* Context to clone to */
130 __u64 adap_fd_src; /* Source context adapter fd */
131 __u64 reserved[8]; /* Reserved for future use */
132 };
133
134 #define DK_CXLFLASH_VERIFY_SENSE_LEN 18
135 #define DK_CXLFLASH_VERIFY_HINT_SENSE 0x8000000000000000ULL
136
137 struct dk_cxlflash_verify {
138 struct dk_cxlflash_hdr hdr; /* Common fields */
139 __u64 context_id; /* Context owning resources to verify */
140 __u64 rsrc_handle; /* Resource handle of LUN */
141 __u64 hint; /* Reasons for verify */
142 __u64 last_lba; /* Returned last LBA of device */
143 __u8 sense_data[DK_CXLFLASH_VERIFY_SENSE_LEN]; /* SCSI sense data */
144 __u8 pad[6]; /* Pad to next 8-byte boundary */
145 __u64 reserved[8]; /* Reserved for future use */
146 };
147
148 #define DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET 0x8000000000000000ULL
149
150 struct dk_cxlflash_recover_afu {
151 struct dk_cxlflash_hdr hdr; /* Common fields */
152 __u64 reason; /* Reason for recovery request */
153 __u64 context_id; /* Context to recover / updated ID */
154 __u64 mmio_size; /* Returned size of MMIO area */
155 __u64 adap_fd; /* Returned adapter file descriptor */
156 __u64 reserved[8]; /* Reserved for future use */
157 };
158
159 #define DK_CXLFLASH_MANAGE_LUN_WWID_LEN CXLFLASH_WWID_LEN
160 #define DK_CXLFLASH_MANAGE_LUN_ENABLE_SUPERPIPE 0x8000000000000000ULL
161 #define DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE 0x4000000000000000ULL
162 #define DK_CXLFLASH_MANAGE_LUN_ALL_PORTS_ACCESSIBLE 0x2000000000000000ULL
163
164 struct dk_cxlflash_manage_lun {
165 struct dk_cxlflash_hdr hdr; /* Common fields */
166 __u8 wwid[DK_CXLFLASH_MANAGE_LUN_WWID_LEN]; /* Page83 WWID, NAA-6 */
167 __u64 reserved[8]; /* Rsvd, future use */
168 };
169
170 union cxlflash_ioctls {
171 struct dk_cxlflash_attach attach;
172 struct dk_cxlflash_detach detach;
173 struct dk_cxlflash_udirect udirect;
174 struct dk_cxlflash_uvirtual uvirtual;
175 struct dk_cxlflash_release release;
176 struct dk_cxlflash_resize resize;
177 struct dk_cxlflash_clone clone;
178 struct dk_cxlflash_verify verify;
179 struct dk_cxlflash_recover_afu recover_afu;
180 struct dk_cxlflash_manage_lun manage_lun;
181 };
182
183 #define MAX_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ioctls))
184
185 #define CXL_MAGIC 0xCA
186 #define CXL_IOWR(_n, _s) _IOWR(CXL_MAGIC, _n, struct _s)
187
188 /*
189 * CXL Flash superpipe ioctls start at base of the reserved CXL_MAGIC
190 * region (0x80) and grow upwards.
191 */
192 #define DK_CXLFLASH_ATTACH CXL_IOWR(0x80, dk_cxlflash_attach)
193 #define DK_CXLFLASH_USER_DIRECT CXL_IOWR(0x81, dk_cxlflash_udirect)
194 #define DK_CXLFLASH_RELEASE CXL_IOWR(0x82, dk_cxlflash_release)
195 #define DK_CXLFLASH_DETACH CXL_IOWR(0x83, dk_cxlflash_detach)
196 #define DK_CXLFLASH_VERIFY CXL_IOWR(0x84, dk_cxlflash_verify)
197 #define DK_CXLFLASH_RECOVER_AFU CXL_IOWR(0x85, dk_cxlflash_recover_afu)
198 #define DK_CXLFLASH_MANAGE_LUN CXL_IOWR(0x86, dk_cxlflash_manage_lun)
199 #define DK_CXLFLASH_USER_VIRTUAL CXL_IOWR(0x87, dk_cxlflash_uvirtual)
200 #define DK_CXLFLASH_VLUN_RESIZE CXL_IOWR(0x88, dk_cxlflash_resize)
201 #define DK_CXLFLASH_VLUN_CLONE CXL_IOWR(0x89, dk_cxlflash_clone)
202
203 /*
204 * Structure and flag definitions CXL Flash host ioctls
205 */
206
207 #define HT_CXLFLASH_VERSION_0 0
208
209 struct ht_cxlflash_hdr {
210 __u16 version; /* Version data */
211 __u16 subcmd; /* Sub-command */
212 __u16 rsvd[2]; /* Reserved for future use */
213 __u64 flags; /* Input flags */
214 __u64 return_flags; /* Returned flags */
215 };
216
217 /*
218 * Input flag definitions available to all host ioctls
219 *
220 * These are grown from the bottom-up with the intention that ioctl-specific
221 * input flag definitions would grow from the top-down, allowing the two sets
222 * to co-exist. While not required/enforced at this time, this provides future
223 * flexibility.
224 */
225 #define HT_CXLFLASH_HOST_READ 0x0000000000000000ULL
226 #define HT_CXLFLASH_HOST_WRITE 0x0000000000000001ULL
227
228 #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_CREATE_LUN 0x0001
229 #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_DELETE_LUN 0x0002
230 #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_QUERY_PORT 0x0003
231
232 struct ht_cxlflash_lun_provision {
233 struct ht_cxlflash_hdr hdr; /* Common fields */
234 __u16 port; /* Target port for provision request */
235 __u16 reserved16[3]; /* Reserved for future use */
236 __u64 size; /* Size of LUN (4K blocks) */
237 __u64 lun_id; /* SCSI LUN ID */
238 __u8 wwid[CXLFLASH_WWID_LEN];/* Page83 WWID, NAA-6 */
239 __u64 max_num_luns; /* Maximum number of LUNs provisioned */
240 __u64 cur_num_luns; /* Current number of LUNs provisioned */
241 __u64 max_cap_port; /* Total capacity for port (4K blocks) */
242 __u64 cur_cap_port; /* Current capacity for port (4K blocks) */
243 __u64 reserved[8]; /* Reserved for future use */
244 };
245
246 #define HT_CXLFLASH_AFU_DEBUG_MAX_DATA_LEN 262144 /* 256K */
247 #define HT_CXLFLASH_AFU_DEBUG_SUBCMD_LEN 12
248 struct ht_cxlflash_afu_debug {
249 struct ht_cxlflash_hdr hdr; /* Common fields */
250 __u8 reserved8[4]; /* Reserved for future use */
251 __u8 afu_subcmd[HT_CXLFLASH_AFU_DEBUG_SUBCMD_LEN]; /* AFU subcommand,
252 * (pass through)
253 */
254 __u64 data_ea; /* Data buffer effective address */
255 __u32 data_len; /* Data buffer length */
256 __u32 reserved32; /* Reserved for future use */
257 __u64 reserved[8]; /* Reserved for future use */
258 };
259
260 union cxlflash_ht_ioctls {
261 struct ht_cxlflash_lun_provision lun_provision;
262 struct ht_cxlflash_afu_debug afu_debug;
263 };
264
265 #define MAX_HT_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ht_ioctls))
266
267 /*
268 * CXL Flash host ioctls start at the top of the reserved CXL_MAGIC
269 * region (0xBF) and grow downwards.
270 */
271 #define HT_CXLFLASH_LUN_PROVISION CXL_IOWR(0xBF, ht_cxlflash_lun_provision)
272 #define HT_CXLFLASH_AFU_DEBUG CXL_IOWR(0xBE, ht_cxlflash_afu_debug)
273
274
275 #endif /* ifndef _CXLFLASH_IOCTL_H */