1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef _CXLFLASH_IOCTL_H
16#define _CXLFLASH_IOCTL_H
17
18#include <linux/types.h>
19
20
21
22
23
24#define DK_CXLFLASH_VERSION_0 0
25
26struct dk_cxlflash_hdr {
27 __u16 version;
28 __u16 rsvd[3];
29 __u64 flags;
30 __u64 return_flags;
31};
32
33
34
35
36
37
38
39
40
41#define DK_CXLFLASH_ALL_PORTS_ACTIVE 0x0000000000000001ULL
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56#define DK_CXLFLASH_ATTACH_REUSE_CONTEXT 0x8000000000000000ULL
57
58struct dk_cxlflash_attach {
59 struct dk_cxlflash_hdr hdr;
60 __u64 num_interrupts;
61 __u64 context_id;
62 __u64 mmio_size;
63 __u64 block_size;
64 __u64 adap_fd;
65 __u64 last_lba;
66 __u64 max_xfer;
67 __u64 reserved[8];
68};
69
70struct dk_cxlflash_detach {
71 struct dk_cxlflash_hdr hdr;
72 __u64 context_id;
73 __u64 reserved[8];
74};
75
76struct dk_cxlflash_udirect {
77 struct dk_cxlflash_hdr hdr;
78 __u64 context_id;
79 __u64 rsrc_handle;
80 __u64 last_lba;
81 __u64 reserved[8];
82};
83
84#define DK_CXLFLASH_UVIRTUAL_NEED_WRITE_SAME 0x8000000000000000ULL
85
86struct dk_cxlflash_uvirtual {
87 struct dk_cxlflash_hdr hdr;
88 __u64 context_id;
89 __u64 lun_size;
90 __u64 rsrc_handle;
91 __u64 last_lba;
92 __u64 reserved[8];
93};
94
95struct dk_cxlflash_release {
96 struct dk_cxlflash_hdr hdr;
97 __u64 context_id;
98 __u64 rsrc_handle;
99 __u64 reserved[8];
100};
101
102struct dk_cxlflash_resize {
103 struct dk_cxlflash_hdr hdr;
104 __u64 context_id;
105 __u64 rsrc_handle;
106 __u64 req_size;
107 __u64 last_lba;
108 __u64 reserved[8];
109};
110
111struct dk_cxlflash_clone {
112 struct dk_cxlflash_hdr hdr;
113 __u64 context_id_src;
114 __u64 context_id_dst;
115 __u64 adap_fd_src;
116 __u64 reserved[8];
117};
118
119#define DK_CXLFLASH_VERIFY_SENSE_LEN 18
120#define DK_CXLFLASH_VERIFY_HINT_SENSE 0x8000000000000000ULL
121
122struct dk_cxlflash_verify {
123 struct dk_cxlflash_hdr hdr;
124 __u64 context_id;
125 __u64 rsrc_handle;
126 __u64 hint;
127 __u64 last_lba;
128 __u8 sense_data[DK_CXLFLASH_VERIFY_SENSE_LEN];
129 __u8 pad[6];
130 __u64 reserved[8];
131};
132
133#define DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET 0x8000000000000000ULL
134
135struct dk_cxlflash_recover_afu {
136 struct dk_cxlflash_hdr hdr;
137 __u64 reason;
138 __u64 context_id;
139 __u64 mmio_size;
140 __u64 adap_fd;
141 __u64 reserved[8];
142};
143
144#define DK_CXLFLASH_MANAGE_LUN_WWID_LEN 16
145#define DK_CXLFLASH_MANAGE_LUN_ENABLE_SUPERPIPE 0x8000000000000000ULL
146#define DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE 0x4000000000000000ULL
147#define DK_CXLFLASH_MANAGE_LUN_ALL_PORTS_ACCESSIBLE 0x2000000000000000ULL
148
149struct dk_cxlflash_manage_lun {
150 struct dk_cxlflash_hdr hdr;
151 __u8 wwid[DK_CXLFLASH_MANAGE_LUN_WWID_LEN];
152 __u64 reserved[8];
153};
154
155union cxlflash_ioctls {
156 struct dk_cxlflash_attach attach;
157 struct dk_cxlflash_detach detach;
158 struct dk_cxlflash_udirect udirect;
159 struct dk_cxlflash_uvirtual uvirtual;
160 struct dk_cxlflash_release release;
161 struct dk_cxlflash_resize resize;
162 struct dk_cxlflash_clone clone;
163 struct dk_cxlflash_verify verify;
164 struct dk_cxlflash_recover_afu recover_afu;
165 struct dk_cxlflash_manage_lun manage_lun;
166};
167
168#define MAX_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ioctls))
169
170#define CXL_MAGIC 0xCA
171#define CXL_IOWR(_n, _s) _IOWR(CXL_MAGIC, _n, struct _s)
172
173#define DK_CXLFLASH_ATTACH CXL_IOWR(0x80, dk_cxlflash_attach)
174#define DK_CXLFLASH_USER_DIRECT CXL_IOWR(0x81, dk_cxlflash_udirect)
175#define DK_CXLFLASH_RELEASE CXL_IOWR(0x82, dk_cxlflash_release)
176#define DK_CXLFLASH_DETACH CXL_IOWR(0x83, dk_cxlflash_detach)
177#define DK_CXLFLASH_VERIFY CXL_IOWR(0x84, dk_cxlflash_verify)
178#define DK_CXLFLASH_RECOVER_AFU CXL_IOWR(0x85, dk_cxlflash_recover_afu)
179#define DK_CXLFLASH_MANAGE_LUN CXL_IOWR(0x86, dk_cxlflash_manage_lun)
180#define DK_CXLFLASH_USER_VIRTUAL CXL_IOWR(0x87, dk_cxlflash_uvirtual)
181#define DK_CXLFLASH_VLUN_RESIZE CXL_IOWR(0x88, dk_cxlflash_resize)
182#define DK_CXLFLASH_VLUN_CLONE CXL_IOWR(0x89, dk_cxlflash_clone)
183
184#endif
185