1/*
2 * This header was generated from the Linux kernel headers by update_headers.py,
3 * to provide necessary information from kernel to userspace, such as constants,
4 * structures, and macros, and thus, contains no copyrightable information.
5 */
6#ifndef _CXLFLASH_IOCTL_H
7#define _CXLFLASH_IOCTL_H
8#include <linux/types.h>
9#define CXLFLASH_WWID_LEN		16
10#define DK_CXLFLASH_VERSION_0	0
11struct dk_cxlflash_hdr {
12	__u16 version;
13	__u16 rsvd[3];
14	__u64 flags;
15	__u64 return_flags;
16};
17#define DK_CXLFLASH_ALL_PORTS_ACTIVE	0x0000000000000001ULL
18#define DK_CXLFLASH_APP_CLOSE_ADAP_FD	0x0000000000000002ULL
19#define DK_CXLFLASH_CONTEXT_SQ_CMD_MODE	0x0000000000000004ULL
20#define DK_CXLFLASH_ATTACH_REUSE_CONTEXT	0x8000000000000000ULL
21struct dk_cxlflash_attach {
22	struct dk_cxlflash_hdr hdr;
23	__u64 num_interrupts;
24	__u64 context_id;
25	__u64 mmio_size;
26	__u64 block_size;
27	__u64 adap_fd;
28	__u64 last_lba;
29	__u64 max_xfer;
30	__u64 reserved[8];
31};
32struct dk_cxlflash_detach {
33	struct dk_cxlflash_hdr hdr;
34	__u64 context_id;
35	__u64 reserved[8];
36};
37struct dk_cxlflash_udirect {
38	struct dk_cxlflash_hdr hdr;
39	__u64 context_id;
40	__u64 rsrc_handle;
41	__u64 last_lba;
42	__u64 reserved[8];
43};
44#define DK_CXLFLASH_UVIRTUAL_NEED_WRITE_SAME	0x8000000000000000ULL
45struct dk_cxlflash_uvirtual {
46	struct dk_cxlflash_hdr hdr;
47	__u64 context_id;
48	__u64 lun_size;
49	__u64 rsrc_handle;
50	__u64 last_lba;
51	__u64 reserved[8];
52};
53struct dk_cxlflash_release {
54	struct dk_cxlflash_hdr hdr;
55	__u64 context_id;
56	__u64 rsrc_handle;
57	__u64 reserved[8];
58};
59struct dk_cxlflash_resize {
60	struct dk_cxlflash_hdr hdr;
61	__u64 context_id;
62	__u64 rsrc_handle;
63	__u64 req_size;
64	__u64 last_lba;
65	__u64 reserved[8];
66};
67struct dk_cxlflash_clone {
68	struct dk_cxlflash_hdr hdr;
69	__u64 context_id_src;
70	__u64 context_id_dst;
71	__u64 adap_fd_src;
72	__u64 reserved[8];
73};
74#define DK_CXLFLASH_VERIFY_SENSE_LEN	18
75#define DK_CXLFLASH_VERIFY_HINT_SENSE	0x8000000000000000ULL
76struct dk_cxlflash_verify {
77	struct dk_cxlflash_hdr hdr;
78	__u64 context_id;
79	__u64 rsrc_handle;
80	__u64 hint;
81	__u64 last_lba;
82	__u8 sense_data[DK_CXLFLASH_VERIFY_SENSE_LEN];
83	__u8 pad[6];
84	__u64 reserved[8];
85};
86#define DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET	0x8000000000000000ULL
87struct dk_cxlflash_recover_afu {
88	struct dk_cxlflash_hdr hdr;
89	__u64 reason;
90	__u64 context_id;
91	__u64 mmio_size;
92	__u64 adap_fd;
93	__u64 reserved[8];
94};
95#define DK_CXLFLASH_MANAGE_LUN_WWID_LEN			CXLFLASH_WWID_LEN
96#define DK_CXLFLASH_MANAGE_LUN_ENABLE_SUPERPIPE		0x8000000000000000ULL
97#define DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE	0x4000000000000000ULL
98#define DK_CXLFLASH_MANAGE_LUN_ALL_PORTS_ACCESSIBLE	0x2000000000000000ULL
99struct dk_cxlflash_manage_lun {
100	struct dk_cxlflash_hdr hdr;
101	__u8 wwid[DK_CXLFLASH_MANAGE_LUN_WWID_LEN];
102	__u64 reserved[8];
103};
104union cxlflash_ioctls {
105	struct dk_cxlflash_attach attach;
106	struct dk_cxlflash_detach detach;
107	struct dk_cxlflash_udirect udirect;
108	struct dk_cxlflash_uvirtual uvirtual;
109	struct dk_cxlflash_release release;
110	struct dk_cxlflash_resize resize;
111	struct dk_cxlflash_clone clone;
112	struct dk_cxlflash_verify verify;
113	struct dk_cxlflash_recover_afu recover_afu;
114	struct dk_cxlflash_manage_lun manage_lun;
115};
116#define MAX_CXLFLASH_IOCTL_SZ	(sizeof(union cxlflash_ioctls))
117#define CXL_MAGIC 0xCA
118#define CXL_IOWR(_n, _s)	_IOWR(CXL_MAGIC, _n, struct _s)
119#define DK_CXLFLASH_ATTACH		CXL_IOWR(0x80, dk_cxlflash_attach)
120#define DK_CXLFLASH_USER_DIRECT		CXL_IOWR(0x81, dk_cxlflash_udirect)
121#define DK_CXLFLASH_RELEASE		CXL_IOWR(0x82, dk_cxlflash_release)
122#define DK_CXLFLASH_DETACH		CXL_IOWR(0x83, dk_cxlflash_detach)
123#define DK_CXLFLASH_VERIFY		CXL_IOWR(0x84, dk_cxlflash_verify)
124#define DK_CXLFLASH_RECOVER_AFU		CXL_IOWR(0x85, dk_cxlflash_recover_afu)
125#define DK_CXLFLASH_MANAGE_LUN		CXL_IOWR(0x86, dk_cxlflash_manage_lun)
126#define DK_CXLFLASH_USER_VIRTUAL	CXL_IOWR(0x87, dk_cxlflash_uvirtual)
127#define DK_CXLFLASH_VLUN_RESIZE		CXL_IOWR(0x88, dk_cxlflash_resize)
128#define DK_CXLFLASH_VLUN_CLONE		CXL_IOWR(0x89, dk_cxlflash_clone)
129#define HT_CXLFLASH_VERSION_0  0
130struct ht_cxlflash_hdr {
131	__u16 version;
132	__u16 subcmd;
133	__u16 rsvd[2];
134	__u64 flags;
135	__u64 return_flags;
136};
137#define HT_CXLFLASH_HOST_READ				0x0000000000000000ULL
138#define HT_CXLFLASH_HOST_WRITE				0x0000000000000001ULL
139#define HT_CXLFLASH_LUN_PROVISION_SUBCMD_CREATE_LUN	0x0001
140#define HT_CXLFLASH_LUN_PROVISION_SUBCMD_DELETE_LUN	0x0002
141#define HT_CXLFLASH_LUN_PROVISION_SUBCMD_QUERY_PORT	0x0003
142struct ht_cxlflash_lun_provision {
143	struct ht_cxlflash_hdr hdr;
144	__u16 port;
145	__u16 reserved16[3];
146	__u64 size;
147	__u64 lun_id;
148	__u8 wwid[CXLFLASH_WWID_LEN];
149	__u64 max_num_luns;
150	__u64 cur_num_luns;
151	__u64 max_cap_port;
152	__u64 cur_cap_port;
153	__u64 reserved[8];
154};
155#define	HT_CXLFLASH_AFU_DEBUG_MAX_DATA_LEN		262144
156#define HT_CXLFLASH_AFU_DEBUG_SUBCMD_LEN		12
157struct ht_cxlflash_afu_debug {
158	struct ht_cxlflash_hdr hdr;
159	__u8 reserved8[4];
160	__u8 afu_subcmd[HT_CXLFLASH_AFU_DEBUG_SUBCMD_LEN];
161	__u64 data_ea;
162	__u32 data_len;
163	__u32 reserved32;
164	__u64 reserved[8];
165};
166union cxlflash_ht_ioctls {
167	struct ht_cxlflash_lun_provision lun_provision;
168	struct ht_cxlflash_afu_debug afu_debug;
169};
170#define MAX_HT_CXLFLASH_IOCTL_SZ	(sizeof(union cxlflash_ht_ioctls))
171#define HT_CXLFLASH_LUN_PROVISION CXL_IOWR(0xBF, ht_cxlflash_lun_provision)
172#define HT_CXLFLASH_AFU_DEBUG	  CXL_IOWR(0xBE, ht_cxlflash_afu_debug)
173#endif
174