1
2
3
4
5
6
7
8
9
10
11 #ifndef _SISLITE_H
12 #define _SISLITE_H
13
14 #include <linux/types.h>
15
16 typedef u16 ctx_hndl_t;
17 typedef u32 res_hndl_t;
18
19 #define SIZE_4K 4096
20 #define SIZE_64K 65536
21
22
23
24
25
26 struct sisl_ioarcb {
27 u16 ctx_id;
28 u16 req_flags;
29 #define SISL_REQ_FLAGS_RES_HNDL 0x8000U
30 #define SISL_REQ_FLAGS_PORT_LUN_ID 0x0000U
31
32 #define SISL_REQ_FLAGS_SUP_UNDERRUN 0x4000U
33
34 #define SISL_REQ_FLAGS_TIMEOUT_SECS 0x0000U
35 #define SISL_REQ_FLAGS_TIMEOUT_MSECS 0x0040U
36 #define SISL_REQ_FLAGS_TIMEOUT_USECS 0x0080U
37 #define SISL_REQ_FLAGS_TIMEOUT_CYCLES 0x00C0U
38
39 #define SISL_REQ_FLAGS_TMF_CMD 0x0004u
40
41 #define SISL_REQ_FLAGS_AFU_CMD 0x0002U
42
43 #define SISL_REQ_FLAGS_HOST_WRITE 0x0001U
44 #define SISL_REQ_FLAGS_HOST_READ 0x0000U
45
46 union {
47 u32 res_hndl;
48 u32 port_sel;
49
50
51
52
53 };
54 u64 lun_id;
55 u32 data_len;
56 u32 ioadl_len;
57 union {
58 u64 data_ea;
59 u64 ioadl_ea;
60 };
61 u8 msi;
62 #define SISL_MSI_CXL_PFAULT 0
63 #define SISL_MSI_SYNC_ERROR 1
64 #define SISL_MSI_RRQ_UPDATED 2
65 #define SISL_MSI_ASYNC_ERROR 3
66
67 u8 rrq;
68 u16 timeout;
69 u32 rsvd1;
70 u8 cdb[16];
71 #define SISL_AFU_CMD_SYNC 0xC0
72 #define SISL_AFU_CMD_LUN_PROVISION 0xD0
73 #define SISL_AFU_CMD_DEBUG 0xE0
74
75 #define SISL_AFU_LUN_PROVISION_CREATE 0x00
76 #define SISL_AFU_LUN_PROVISION_DELETE 0x01
77
78 union {
79 u64 reserved;
80 struct sisl_ioasa *ioasa;
81 };
82 } __packed;
83
84 struct sisl_rc {
85 u8 flags;
86 #define SISL_RC_FLAGS_SENSE_VALID 0x80U
87 #define SISL_RC_FLAGS_FCP_RSP_CODE_VALID 0x40U
88 #define SISL_RC_FLAGS_OVERRUN 0x20U
89 #define SISL_RC_FLAGS_UNDERRUN 0x10U
90
91 u8 afu_rc;
92 #define SISL_AFU_RC_RHT_INVALID 0x01U
93 #define SISL_AFU_RC_RHT_UNALIGNED 0x02U
94 #define SISL_AFU_RC_RHT_OUT_OF_BOUNDS 0x03u
95 #define SISL_AFU_RC_RHT_DMA_ERR 0x04u
96
97
98
99 #define SISL_AFU_RC_RHT_RW_PERM 0x05u
100 #define SISL_AFU_RC_LXT_UNALIGNED 0x12U
101 #define SISL_AFU_RC_LXT_OUT_OF_BOUNDS 0x13u
102 #define SISL_AFU_RC_LXT_DMA_ERR 0x14u
103
104
105
106 #define SISL_AFU_RC_LXT_RW_PERM 0x15u
107
108 #define SISL_AFU_RC_NOT_XLATE_HOST 0x1au
109
110
111
112
113
114
115 #define SISL_AFU_RC_NO_CHANNELS 0x20U
116 #define SISL_AFU_RC_CAP_VIOLATION 0x21U
117
118
119 #define SISL_AFU_RC_OUT_OF_DATA_BUFS 0x30U
120 #define SISL_AFU_RC_DATA_DMA_ERR 0x31U
121
122
123
124 u8 scsi_rc;
125 #define SISL_SCSI_RC_CHECK 0x02U
126 #define SISL_SCSI_RC_BUSY 0x08u
127
128 u8 fc_rc;
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145 #define SISL_FC_RC_ABORTPEND 0x52
146 #define SISL_FC_RC_WRABORTPEND 0x53
147 #define SISL_FC_RC_NOLOGI 0x54
148 #define SISL_FC_RC_NOEXP 0x55
149 #define SISL_FC_RC_INUSE 0x56
150 #define SISL_FC_RC_LINKDOWN 0x57
151 #define SISL_FC_RC_ABORTOK 0x58
152 #define SISL_FC_RC_ABORTFAIL 0x59
153 #define SISL_FC_RC_RESID 0x5A
154 #define SISL_FC_RC_RESIDERR 0x5B
155
156
157
158 #define SISL_FC_RC_TGTABORT 0x5C
159 };
160
161 #define SISL_SENSE_DATA_LEN 20
162 #define SISL_WWID_DATA_LEN 16
163
164
165
166
167
168 struct sisl_ioasa {
169 union {
170 struct sisl_rc rc;
171 u32 ioasc;
172 #define SISL_IOASC_GOOD_COMPLETION 0x00000000U
173 };
174
175 union {
176 u32 resid;
177 u32 lunid_hi;
178 };
179
180 u8 port;
181 u8 afu_extra;
182
183
184
185 #define SISL_AFU_DMA_ERR_PAGE_IN 0x0A
186
187
188
189 #define SISL_AFU_DMA_ERR_INVALID_EA 0x0B
190
191
192
193
194
195
196
197 #define SISL_AFU_NO_CLANNELS_AMASK(afu_extra) (((afu_extra) & 0x0C) >> 2)
198 #define SISL_AFU_NO_CLANNELS_RMASK(afu_extra) ((afu_extra) & 0x03)
199
200 u8 scsi_extra;
201 u8 fc_extra;
202
203 union {
204 u8 sense_data[SISL_SENSE_DATA_LEN];
205 struct {
206 u32 lunid_lo;
207 u8 wwid[SISL_WWID_DATA_LEN];
208 };
209 };
210
211
212
213
214 union {
215 u64 host_use[4];
216 u8 host_use_b[32];
217 };
218 } __packed;
219
220 #define SISL_RESP_HANDLE_T_BIT 0x1ULL
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236 #define SISL_ENDIAN_CTRL_BE 0x8000000000000080ULL
237 #define SISL_ENDIAN_CTRL_LE 0x0000000000000000ULL
238
239 #ifdef __BIG_ENDIAN
240 #define SISL_ENDIAN_CTRL SISL_ENDIAN_CTRL_BE
241 #else
242 #define SISL_ENDIAN_CTRL SISL_ENDIAN_CTRL_LE
243 #endif
244
245
246 struct sisl_host_map {
247 __be64 endian_ctrl;
248
249
250
251
252 __be64 intr_status;
253
254
255
256
257 #define SISL_ISTATUS_PERM_ERR_LISN_3_EA 0x0400ULL
258 #define SISL_ISTATUS_PERM_ERR_LISN_2_EA 0x0200ULL
259 #define SISL_ISTATUS_PERM_ERR_LISN_1_EA 0x0100ULL
260 #define SISL_ISTATUS_PERM_ERR_LISN_3_PASID 0x0080ULL
261 #define SISL_ISTATUS_PERM_ERR_LISN_2_PASID 0x0040ULL
262 #define SISL_ISTATUS_PERM_ERR_LISN_1_PASID 0x0020ULL
263 #define SISL_ISTATUS_PERM_ERR_CMDROOM 0x0010ULL
264 #define SISL_ISTATUS_PERM_ERR_RCB_READ 0x0008ULL
265 #define SISL_ISTATUS_PERM_ERR_SA_WRITE 0x0004ULL
266 #define SISL_ISTATUS_PERM_ERR_RRQ_WRITE 0x0002ULL
267
268
269
270 #define SISL_ISTATUS_TEMP_ERR_PAGEIN 0x0001ULL
271
272
273
274
275
276
277
278
279 #define SISL_ISTATUS_UNMASK (0x07FFULL)
280 #define SISL_ISTATUS_MASK ~(SISL_ISTATUS_UNMASK)
281
282 __be64 intr_clear;
283 __be64 intr_mask;
284 __be64 ioarrin;
285 __be64 rrq_start;
286 __be64 rrq_end;
287 __be64 cmd_room;
288 __be64 ctx_ctrl;
289 #define SISL_CTX_CTRL_UNMAP_SECTOR 0x8000000000000000ULL
290 #define SISL_CTX_CTRL_LISN_MASK (0xFFULL)
291 __be64 mbox_w;
292 __be64 sq_start;
293 __be64 sq_end;
294 __be64 sq_head;
295 __be64 sq_tail;
296 __be64 sq_ctx_reset;
297 };
298
299
300 struct sisl_ctrl_map {
301 __be64 rht_start;
302 __be64 rht_cnt_id;
303
304 #define SISL_RHT_CNT_ID(cnt, ctx_id) (((cnt) << 48) | ((ctx_id) << 32))
305
306 __be64 ctx_cap;
307 #define SISL_CTX_CAP_PROXY_ISSUE 0x8000000000000000ULL
308 #define SISL_CTX_CAP_REAL_MODE 0x4000000000000000ULL
309 #define SISL_CTX_CAP_HOST_XLATE 0x2000000000000000ULL
310 #define SISL_CTX_CAP_PROXY_TARGET 0x1000000000000000ULL
311 #define SISL_CTX_CAP_AFU_CMD 0x0000000000000008ULL
312 #define SISL_CTX_CAP_GSCSI_CMD 0x0000000000000004ULL
313 #define SISL_CTX_CAP_WRITE_CMD 0x0000000000000002ULL
314 #define SISL_CTX_CAP_READ_CMD 0x0000000000000001ULL
315 __be64 mbox_r;
316 __be64 lisn_pasid[2];
317
318 #define SISL_LISN_PASID(_a, _b) (((_a) << 32) | (_b))
319 __be64 lisn_ea[3];
320 };
321
322
323 struct sisl_global_regs {
324 __be64 aintr_status;
325
326
327
328
329
330
331
332
333
334
335
336
337
338 #define SISL_ASTATUS_FC2_OTHER 0x80000000ULL
339 #define SISL_ASTATUS_FC2_LOGO 0x40000000ULL
340 #define SISL_ASTATUS_FC2_CRC_T 0x20000000ULL
341 #define SISL_ASTATUS_FC2_LOGI_R 0x10000000ULL
342 #define SISL_ASTATUS_FC2_LOGI_F 0x08000000ULL
343 #define SISL_ASTATUS_FC2_LOGI_S 0x04000000ULL
344 #define SISL_ASTATUS_FC2_LINK_DN 0x02000000ULL
345 #define SISL_ASTATUS_FC2_LINK_UP 0x01000000ULL
346
347 #define SISL_ASTATUS_FC3_OTHER 0x00800000ULL
348 #define SISL_ASTATUS_FC3_LOGO 0x00400000ULL
349 #define SISL_ASTATUS_FC3_CRC_T 0x00200000ULL
350 #define SISL_ASTATUS_FC3_LOGI_R 0x00100000ULL
351 #define SISL_ASTATUS_FC3_LOGI_F 0x00080000ULL
352 #define SISL_ASTATUS_FC3_LOGI_S 0x00040000ULL
353 #define SISL_ASTATUS_FC3_LINK_DN 0x00020000ULL
354 #define SISL_ASTATUS_FC3_LINK_UP 0x00010000ULL
355
356 #define SISL_ASTATUS_FC0_OTHER 0x00008000ULL
357 #define SISL_ASTATUS_FC0_LOGO 0x00004000ULL
358 #define SISL_ASTATUS_FC0_CRC_T 0x00002000ULL
359 #define SISL_ASTATUS_FC0_LOGI_R 0x00001000ULL
360 #define SISL_ASTATUS_FC0_LOGI_F 0x00000800ULL
361 #define SISL_ASTATUS_FC0_LOGI_S 0x00000400ULL
362 #define SISL_ASTATUS_FC0_LINK_DN 0x00000200ULL
363 #define SISL_ASTATUS_FC0_LINK_UP 0x00000100ULL
364
365 #define SISL_ASTATUS_FC1_OTHER 0x00000080ULL
366 #define SISL_ASTATUS_FC1_LOGO 0x00000040ULL
367 #define SISL_ASTATUS_FC1_CRC_T 0x00000020ULL
368 #define SISL_ASTATUS_FC1_LOGI_R 0x00000010ULL
369 #define SISL_ASTATUS_FC1_LOGI_F 0x00000008ULL
370 #define SISL_ASTATUS_FC1_LOGI_S 0x00000004ULL
371 #define SISL_ASTATUS_FC1_LINK_DN 0x00000002ULL
372 #define SISL_ASTATUS_FC1_LINK_UP 0x00000001ULL
373
374 #define SISL_FC_INTERNAL_UNMASK 0x0000000300000000ULL
375 #define SISL_FC_INTERNAL_MASK ~(SISL_FC_INTERNAL_UNMASK)
376 #define SISL_FC_INTERNAL_SHIFT 32
377
378 #define SISL_FC_SHUTDOWN_NORMAL 0x0000000000000010ULL
379 #define SISL_FC_SHUTDOWN_ABRUPT 0x0000000000000020ULL
380
381 #define SISL_STATUS_SHUTDOWN_ACTIVE 0x0000000000000010ULL
382 #define SISL_STATUS_SHUTDOWN_COMPLETE 0x0000000000000020ULL
383
384 #define SISL_ASTATUS_UNMASK 0xFFFFFFFFULL
385 #define SISL_ASTATUS_MASK ~(SISL_ASTATUS_UNMASK)
386
387 __be64 aintr_clear;
388 __be64 aintr_mask;
389 __be64 afu_ctrl;
390 __be64 afu_hb;
391 __be64 afu_scratch_pad;
392 __be64 afu_port_sel;
393 #define SISL_AFUCONF_AR_IOARCB 0x4000ULL
394 #define SISL_AFUCONF_AR_LXT 0x2000ULL
395 #define SISL_AFUCONF_AR_RHT 0x1000ULL
396 #define SISL_AFUCONF_AR_DATA 0x0800ULL
397 #define SISL_AFUCONF_AR_RSRC 0x0400ULL
398 #define SISL_AFUCONF_AR_IOASA 0x0200ULL
399 #define SISL_AFUCONF_AR_RRQ 0x0100ULL
400
401 #define SISL_AFUCONF_AR_ALL (SISL_AFUCONF_AR_IOARCB|SISL_AFUCONF_AR_LXT| \
402 SISL_AFUCONF_AR_RHT|SISL_AFUCONF_AR_DATA| \
403 SISL_AFUCONF_AR_RSRC|SISL_AFUCONF_AR_IOASA| \
404 SISL_AFUCONF_AR_RRQ)
405 #ifdef __BIG_ENDIAN
406 #define SISL_AFUCONF_ENDIAN 0x0000ULL
407 #else
408 #define SISL_AFUCONF_ENDIAN 0x0020ULL
409 #endif
410 #define SISL_AFUCONF_MBOX_CLR_READ 0x0010ULL
411 __be64 afu_config;
412 __be64 rsvd[0xf8];
413 __le64 afu_version;
414 __be64 interface_version;
415 #define SISL_INTVER_CAP_SHIFT 16
416 #define SISL_INTVER_MAJ_SHIFT 8
417 #define SISL_INTVER_CAP_MASK 0xFFFFFFFF00000000ULL
418 #define SISL_INTVER_MAJ_MASK 0x00000000FFFF0000ULL
419 #define SISL_INTVER_MIN_MASK 0x000000000000FFFFULL
420 #define SISL_INTVER_CAP_IOARRIN_CMD_MODE 0x800000000000ULL
421 #define SISL_INTVER_CAP_SQ_CMD_MODE 0x400000000000ULL
422 #define SISL_INTVER_CAP_RESERVED_CMD_MODE_A 0x200000000000ULL
423 #define SISL_INTVER_CAP_RESERVED_CMD_MODE_B 0x100000000000ULL
424 #define SISL_INTVER_CAP_LUN_PROVISION 0x080000000000ULL
425 #define SISL_INTVER_CAP_AFU_DEBUG 0x040000000000ULL
426 #define SISL_INTVER_CAP_OCXL_LISN 0x020000000000ULL
427 };
428
429 #define CXLFLASH_NUM_FC_PORTS_PER_BANK 2
430 #define CXLFLASH_MAX_FC_BANKS 2
431 #define CXLFLASH_MAX_FC_PORTS (CXLFLASH_NUM_FC_PORTS_PER_BANK * \
432 CXLFLASH_MAX_FC_BANKS)
433 #define CXLFLASH_MAX_CONTEXT 512
434 #define CXLFLASH_NUM_VLUNS 512
435 #define CXLFLASH_NUM_REGS 512
436
437 struct fc_port_bank {
438 __be64 fc_port_regs[CXLFLASH_NUM_FC_PORTS_PER_BANK][CXLFLASH_NUM_REGS];
439 __be64 fc_port_luns[CXLFLASH_NUM_FC_PORTS_PER_BANK][CXLFLASH_NUM_VLUNS];
440 };
441
442 struct sisl_global_map {
443 union {
444 struct sisl_global_regs regs;
445 char page0[SIZE_4K];
446 };
447
448 char page1[SIZE_4K];
449
450 struct fc_port_bank bank[CXLFLASH_MAX_FC_BANKS];
451
452
453
454 };
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472 struct cxlflash_afu_map {
473 union {
474 struct sisl_host_map host;
475 char harea[SIZE_64K];
476 } hosts[CXLFLASH_MAX_CONTEXT];
477
478 union {
479 struct sisl_ctrl_map ctrl;
480 char carea[cache_line_size()];
481 } ctrls[CXLFLASH_MAX_CONTEXT];
482
483 union {
484 struct sisl_global_map global;
485 char garea[SIZE_64K];
486 };
487 };
488
489
490
491
492
493 struct sisl_lxt_entry {
494 u64 rlba_base;
495
496
497
498
499
500 };
501
502
503
504
505
506 struct sisl_rht_entry {
507 struct sisl_lxt_entry *lxt_start;
508 u32 lxt_cnt;
509 u16 rsvd;
510 u8 fp;
511
512
513 u8 nmask;
514 } __packed __aligned(16);
515
516 struct sisl_rht_entry_f1 {
517 u64 lun_id;
518 union {
519 struct {
520 u8 valid;
521 u8 rsvd[5];
522 u8 fp;
523 u8 port_sel;
524 };
525
526 u64 dw;
527 };
528 } __packed __aligned(16);
529
530
531 #define SISL_RHT_FP(fmt, perm) (((fmt) << 4) | (perm))
532
533
534
535
536 #define SISL_RHT_FP_CLONE(src_fp, cln_flags) ((src_fp) & (0xFC | (cln_flags)))
537
538 #define RHT_PERM_READ 0x01U
539 #define RHT_PERM_WRITE 0x02U
540 #define RHT_PERM_RW (RHT_PERM_READ | RHT_PERM_WRITE)
541
542
543 #define SISL_RHT_PERM(fp) ((fp) & RHT_PERM_RW)
544
545 #define PORT0 0x01U
546 #define PORT1 0x02U
547 #define PORT2 0x04U
548 #define PORT3 0x08U
549 #define PORT_MASK(_n) ((1 << (_n)) - 1)
550
551
552 #define AFU_LW_SYNC 0x0U
553 #define AFU_HW_SYNC 0x1U
554 #define AFU_GSYNC 0x2U
555
556
557 #define TMF_LUN_RESET 0x1U
558 #define TMF_CLEAR_ACA 0x2U
559
560 #endif