0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _CXLFLASH_IOCTL_H
0017 #define _CXLFLASH_IOCTL_H
0018
0019 #include <linux/types.h>
0020
0021
0022
0023
0024 #define CXLFLASH_WWID_LEN 16
0025
0026
0027
0028
0029
0030 #define DK_CXLFLASH_VERSION_0 0
0031
0032 struct dk_cxlflash_hdr {
0033 __u16 version;
0034 __u16 rsvd[3];
0035 __u64 flags;
0036 __u64 return_flags;
0037 };
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 #define DK_CXLFLASH_ALL_PORTS_ACTIVE 0x0000000000000001ULL
0048 #define DK_CXLFLASH_APP_CLOSE_ADAP_FD 0x0000000000000002ULL
0049 #define DK_CXLFLASH_CONTEXT_SQ_CMD_MODE 0x0000000000000004ULL
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 #define DK_CXLFLASH_ATTACH_REUSE_CONTEXT 0x8000000000000000ULL
0073
0074 struct dk_cxlflash_attach {
0075 struct dk_cxlflash_hdr hdr;
0076 __u64 num_interrupts;
0077 __u64 context_id;
0078 __u64 mmio_size;
0079 __u64 block_size;
0080 __u64 adap_fd;
0081 __u64 last_lba;
0082 __u64 max_xfer;
0083 __u64 reserved[8];
0084 };
0085
0086 struct dk_cxlflash_detach {
0087 struct dk_cxlflash_hdr hdr;
0088 __u64 context_id;
0089 __u64 reserved[8];
0090 };
0091
0092 struct dk_cxlflash_udirect {
0093 struct dk_cxlflash_hdr hdr;
0094 __u64 context_id;
0095 __u64 rsrc_handle;
0096 __u64 last_lba;
0097 __u64 reserved[8];
0098 };
0099
0100 #define DK_CXLFLASH_UVIRTUAL_NEED_WRITE_SAME 0x8000000000000000ULL
0101
0102 struct dk_cxlflash_uvirtual {
0103 struct dk_cxlflash_hdr hdr;
0104 __u64 context_id;
0105 __u64 lun_size;
0106 __u64 rsrc_handle;
0107 __u64 last_lba;
0108 __u64 reserved[8];
0109 };
0110
0111 struct dk_cxlflash_release {
0112 struct dk_cxlflash_hdr hdr;
0113 __u64 context_id;
0114 __u64 rsrc_handle;
0115 __u64 reserved[8];
0116 };
0117
0118 struct dk_cxlflash_resize {
0119 struct dk_cxlflash_hdr hdr;
0120 __u64 context_id;
0121 __u64 rsrc_handle;
0122 __u64 req_size;
0123 __u64 last_lba;
0124 __u64 reserved[8];
0125 };
0126
0127 struct dk_cxlflash_clone {
0128 struct dk_cxlflash_hdr hdr;
0129 __u64 context_id_src;
0130 __u64 context_id_dst;
0131 __u64 adap_fd_src;
0132 __u64 reserved[8];
0133 };
0134
0135 #define DK_CXLFLASH_VERIFY_SENSE_LEN 18
0136 #define DK_CXLFLASH_VERIFY_HINT_SENSE 0x8000000000000000ULL
0137
0138 struct dk_cxlflash_verify {
0139 struct dk_cxlflash_hdr hdr;
0140 __u64 context_id;
0141 __u64 rsrc_handle;
0142 __u64 hint;
0143 __u64 last_lba;
0144 __u8 sense_data[DK_CXLFLASH_VERIFY_SENSE_LEN];
0145 __u8 pad[6];
0146 __u64 reserved[8];
0147 };
0148
0149 #define DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET 0x8000000000000000ULL
0150
0151 struct dk_cxlflash_recover_afu {
0152 struct dk_cxlflash_hdr hdr;
0153 __u64 reason;
0154 __u64 context_id;
0155 __u64 mmio_size;
0156 __u64 adap_fd;
0157 __u64 reserved[8];
0158 };
0159
0160 #define DK_CXLFLASH_MANAGE_LUN_WWID_LEN CXLFLASH_WWID_LEN
0161 #define DK_CXLFLASH_MANAGE_LUN_ENABLE_SUPERPIPE 0x8000000000000000ULL
0162 #define DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE 0x4000000000000000ULL
0163 #define DK_CXLFLASH_MANAGE_LUN_ALL_PORTS_ACCESSIBLE 0x2000000000000000ULL
0164
0165 struct dk_cxlflash_manage_lun {
0166 struct dk_cxlflash_hdr hdr;
0167 __u8 wwid[DK_CXLFLASH_MANAGE_LUN_WWID_LEN];
0168 __u64 reserved[8];
0169 };
0170
0171 union cxlflash_ioctls {
0172 struct dk_cxlflash_attach attach;
0173 struct dk_cxlflash_detach detach;
0174 struct dk_cxlflash_udirect udirect;
0175 struct dk_cxlflash_uvirtual uvirtual;
0176 struct dk_cxlflash_release release;
0177 struct dk_cxlflash_resize resize;
0178 struct dk_cxlflash_clone clone;
0179 struct dk_cxlflash_verify verify;
0180 struct dk_cxlflash_recover_afu recover_afu;
0181 struct dk_cxlflash_manage_lun manage_lun;
0182 };
0183
0184 #define MAX_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ioctls))
0185
0186 #define CXL_MAGIC 0xCA
0187 #define CXL_IOWR(_n, _s) _IOWR(CXL_MAGIC, _n, struct _s)
0188
0189
0190
0191
0192
0193 #define DK_CXLFLASH_ATTACH CXL_IOWR(0x80, dk_cxlflash_attach)
0194 #define DK_CXLFLASH_USER_DIRECT CXL_IOWR(0x81, dk_cxlflash_udirect)
0195 #define DK_CXLFLASH_RELEASE CXL_IOWR(0x82, dk_cxlflash_release)
0196 #define DK_CXLFLASH_DETACH CXL_IOWR(0x83, dk_cxlflash_detach)
0197 #define DK_CXLFLASH_VERIFY CXL_IOWR(0x84, dk_cxlflash_verify)
0198 #define DK_CXLFLASH_RECOVER_AFU CXL_IOWR(0x85, dk_cxlflash_recover_afu)
0199 #define DK_CXLFLASH_MANAGE_LUN CXL_IOWR(0x86, dk_cxlflash_manage_lun)
0200 #define DK_CXLFLASH_USER_VIRTUAL CXL_IOWR(0x87, dk_cxlflash_uvirtual)
0201 #define DK_CXLFLASH_VLUN_RESIZE CXL_IOWR(0x88, dk_cxlflash_resize)
0202 #define DK_CXLFLASH_VLUN_CLONE CXL_IOWR(0x89, dk_cxlflash_clone)
0203
0204
0205
0206
0207
0208 #define HT_CXLFLASH_VERSION_0 0
0209
0210 struct ht_cxlflash_hdr {
0211 __u16 version;
0212 __u16 subcmd;
0213 __u16 rsvd[2];
0214 __u64 flags;
0215 __u64 return_flags;
0216 };
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226 #define HT_CXLFLASH_HOST_READ 0x0000000000000000ULL
0227 #define HT_CXLFLASH_HOST_WRITE 0x0000000000000001ULL
0228
0229 #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_CREATE_LUN 0x0001
0230 #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_DELETE_LUN 0x0002
0231 #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_QUERY_PORT 0x0003
0232
0233 struct ht_cxlflash_lun_provision {
0234 struct ht_cxlflash_hdr hdr;
0235 __u16 port;
0236 __u16 reserved16[3];
0237 __u64 size;
0238 __u64 lun_id;
0239 __u8 wwid[CXLFLASH_WWID_LEN];
0240 __u64 max_num_luns;
0241 __u64 cur_num_luns;
0242 __u64 max_cap_port;
0243 __u64 cur_cap_port;
0244 __u64 reserved[8];
0245 };
0246
0247 #define HT_CXLFLASH_AFU_DEBUG_MAX_DATA_LEN 262144
0248 #define HT_CXLFLASH_AFU_DEBUG_SUBCMD_LEN 12
0249 struct ht_cxlflash_afu_debug {
0250 struct ht_cxlflash_hdr hdr;
0251 __u8 reserved8[4];
0252 __u8 afu_subcmd[HT_CXLFLASH_AFU_DEBUG_SUBCMD_LEN];
0253
0254
0255 __u64 data_ea;
0256 __u32 data_len;
0257 __u32 reserved32;
0258 __u64 reserved[8];
0259 };
0260
0261 union cxlflash_ht_ioctls {
0262 struct ht_cxlflash_lun_provision lun_provision;
0263 struct ht_cxlflash_afu_debug afu_debug;
0264 };
0265
0266 #define MAX_HT_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ht_ioctls))
0267
0268
0269
0270
0271
0272 #define HT_CXLFLASH_LUN_PROVISION CXL_IOWR(0xBF, ht_cxlflash_lun_provision)
0273 #define HT_CXLFLASH_AFU_DEBUG CXL_IOWR(0xBE, ht_cxlflash_afu_debug)
0274
0275
0276 #endif