]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - drivers/scsi/cxlflash/sislite.h
scsi: cxlflash: Support up to 4 ports
[mirror_ubuntu-zesty-kernel.git] / drivers / scsi / cxlflash / sislite.h
CommitLineData
c21e0bbf
MO
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 _SISLITE_H
16#define _SISLITE_H
17
18#include <linux/types.h>
19
20typedef u16 ctx_hndl_t;
21typedef u32 res_hndl_t;
22
23#define SIZE_4K 4096
24#define SIZE_64K 65536
25
26/*
27 * IOARCB: 64 bytes, min 16 byte alignment required, host native endianness
28 * except for SCSI CDB which remains big endian per SCSI standards.
29 */
30struct sisl_ioarcb {
31 u16 ctx_id; /* ctx_hndl_t */
32 u16 req_flags;
33#define SISL_REQ_FLAGS_RES_HNDL 0x8000U /* bit 0 (MSB) */
34#define SISL_REQ_FLAGS_PORT_LUN_ID 0x0000U
35
36#define SISL_REQ_FLAGS_SUP_UNDERRUN 0x4000U /* bit 1 */
37
38#define SISL_REQ_FLAGS_TIMEOUT_SECS 0x0000U /* bits 8,9 */
39#define SISL_REQ_FLAGS_TIMEOUT_MSECS 0x0040U
40#define SISL_REQ_FLAGS_TIMEOUT_USECS 0x0080U
41#define SISL_REQ_FLAGS_TIMEOUT_CYCLES 0x00C0U
42
43#define SISL_REQ_FLAGS_TMF_CMD 0x0004u /* bit 13 */
44
45#define SISL_REQ_FLAGS_AFU_CMD 0x0002U /* bit 14 */
46
47#define SISL_REQ_FLAGS_HOST_WRITE 0x0001U /* bit 15 (LSB) */
48#define SISL_REQ_FLAGS_HOST_READ 0x0000U
49
50 union {
51 u32 res_hndl; /* res_hndl_t */
52 u32 port_sel; /* this is a selection mask:
53 * 0x1 -> port#0 can be selected,
54 * 0x2 -> port#1 can be selected.
55 * Can be bitwise ORed.
56 */
57 };
58 u64 lun_id;
59 u32 data_len; /* 4K for read/write */
60 u32 ioadl_len;
61 union {
62 u64 data_ea; /* min 16 byte aligned */
63 u64 ioadl_ea;
64 };
65 u8 msi; /* LISN to send on RRQ write */
66#define SISL_MSI_CXL_PFAULT 0 /* reserved for CXL page faults */
67#define SISL_MSI_SYNC_ERROR 1 /* recommended for AFU sync error */
68#define SISL_MSI_RRQ_UPDATED 2 /* recommended for IO completion */
69#define SISL_MSI_ASYNC_ERROR 3 /* master only - for AFU async error */
70
71 u8 rrq; /* 0 for a single RRQ */
72 u16 timeout; /* in units specified by req_flags */
73 u32 rsvd1;
74 u8 cdb[16]; /* must be in big endian */
bae0ac69
MO
75 union {
76 u64 reserved; /* Reserved for IOARRIN mode */
77 struct sisl_ioasa *ioasa; /* IOASA EA for SQ Mode */
78 };
c21e0bbf
MO
79} __packed;
80
81struct sisl_rc {
82 u8 flags;
83#define SISL_RC_FLAGS_SENSE_VALID 0x80U
84#define SISL_RC_FLAGS_FCP_RSP_CODE_VALID 0x40U
85#define SISL_RC_FLAGS_OVERRUN 0x20U
86#define SISL_RC_FLAGS_UNDERRUN 0x10U
87
88 u8 afu_rc;
89#define SISL_AFU_RC_RHT_INVALID 0x01U /* user error */
90#define SISL_AFU_RC_RHT_UNALIGNED 0x02U /* should never happen */
91#define SISL_AFU_RC_RHT_OUT_OF_BOUNDS 0x03u /* user error */
92#define SISL_AFU_RC_RHT_DMA_ERR 0x04u /* see afu_extra
93 may retry if afu_retry is off
94 possible on master exit
95 */
96#define SISL_AFU_RC_RHT_RW_PERM 0x05u /* no RW perms, user error */
97#define SISL_AFU_RC_LXT_UNALIGNED 0x12U /* should never happen */
98#define SISL_AFU_RC_LXT_OUT_OF_BOUNDS 0x13u /* user error */
99#define SISL_AFU_RC_LXT_DMA_ERR 0x14u /* see afu_extra
100 may retry if afu_retry is off
101 possible on master exit
102 */
103#define SISL_AFU_RC_LXT_RW_PERM 0x15u /* no RW perms, user error */
104
105#define SISL_AFU_RC_NOT_XLATE_HOST 0x1au /* possible if master exited */
106
107 /* NO_CHANNELS means the FC ports selected by dest_port in
108 * IOARCB or in the LXT entry are down when the AFU tried to select
109 * a FC port. If the port went down on an active IO, it will set
110 * fc_rc to =0x54(NOLOGI) or 0x57(LINKDOWN) instead.
111 */
112#define SISL_AFU_RC_NO_CHANNELS 0x20U /* see afu_extra, may retry */
113#define SISL_AFU_RC_CAP_VIOLATION 0x21U /* either user error or
114 afu reset/master restart
115 */
116#define SISL_AFU_RC_OUT_OF_DATA_BUFS 0x30U /* always retry */
117#define SISL_AFU_RC_DATA_DMA_ERR 0x31U /* see afu_extra
118 may retry if afu_retry is off
119 */
120
121 u8 scsi_rc; /* SCSI status byte, retry as appropriate */
122#define SISL_SCSI_RC_CHECK 0x02U
123#define SISL_SCSI_RC_BUSY 0x08u
124
125 u8 fc_rc; /* retry */
126 /*
127 * We should only see fc_rc=0x57 (LINKDOWN) or 0x54(NOLOGI) for
128 * commands that are in flight when a link goes down or is logged out.
129 * If the link is down or logged out before AFU selects the port, either
130 * it will choose the other port or we will get afu_rc=0x20 (no_channel)
131 * if there is no valid port to use.
132 *
133 * ABORTPEND/ABORTOK/ABORTFAIL/TGTABORT can be retried, typically these
134 * would happen if a frame is dropped and something times out.
135 * NOLOGI or LINKDOWN can be retried if the other port is up.
136 * RESIDERR can be retried as well.
137 *
138 * ABORTFAIL might indicate that lots of frames are getting CRC errors.
139 * So it maybe retried once and reset the link if it happens again.
140 * The link can also be reset on the CRC error threshold interrupt.
141 */
142#define SISL_FC_RC_ABORTPEND 0x52 /* exchange timeout or abort request */
143#define SISL_FC_RC_WRABORTPEND 0x53 /* due to write XFER_RDY invalid */
144#define SISL_FC_RC_NOLOGI 0x54 /* port not logged in, in-flight cmds */
145#define SISL_FC_RC_NOEXP 0x55 /* FC protocol error or HW bug */
146#define SISL_FC_RC_INUSE 0x56 /* tag already in use, HW bug */
147#define SISL_FC_RC_LINKDOWN 0x57 /* link down, in-flight cmds */
148#define SISL_FC_RC_ABORTOK 0x58 /* pending abort completed w/success */
149#define SISL_FC_RC_ABORTFAIL 0x59 /* pending abort completed w/fail */
150#define SISL_FC_RC_RESID 0x5A /* ioasa underrun/overrun flags set */
151#define SISL_FC_RC_RESIDERR 0x5B /* actual data len does not match SCSI
f15fbf8d 152 reported len, possibly due to dropped
c21e0bbf
MO
153 frames */
154#define SISL_FC_RC_TGTABORT 0x5C /* command aborted by target */
155};
156
157#define SISL_SENSE_DATA_LEN 20 /* Sense data length */
158
159/*
160 * IOASA: 64 bytes & must follow IOARCB, min 16 byte alignment required,
161 * host native endianness
162 */
163struct sisl_ioasa {
164 union {
165 struct sisl_rc rc;
166 u32 ioasc;
167#define SISL_IOASC_GOOD_COMPLETION 0x00000000U
168 };
169 u32 resid;
170 u8 port;
171 u8 afu_extra;
172 /* when afu_rc=0x04, 0x14, 0x31 (_xxx_DMA_ERR):
173 * afu_exta contains PSL response code. Useful codes are:
174 */
175#define SISL_AFU_DMA_ERR_PAGE_IN 0x0A /* AFU_retry_on_pagein Action
176 * Enabled N/A
177 * Disabled retry
178 */
179#define SISL_AFU_DMA_ERR_INVALID_EA 0x0B /* this is a hard error
180 * afu_rc Implies
181 * 0x04, 0x14 master exit.
182 * 0x31 user error.
183 */
184 /* when afu rc=0x20 (no channels):
185 * afu_extra bits [4:5]: available portmask, [6:7]: requested portmask.
186 */
187#define SISL_AFU_NO_CLANNELS_AMASK(afu_extra) (((afu_extra) & 0x0C) >> 2)
188#define SISL_AFU_NO_CLANNELS_RMASK(afu_extra) ((afu_extra) & 0x03)
189
190 u8 scsi_extra;
191 u8 fc_extra;
192 u8 sense_data[SISL_SENSE_DATA_LEN];
193
194 /* These fields are defined by the SISlite architecture for the
195 * host to use as they see fit for their implementation.
196 */
197 union {
198 u64 host_use[4];
199 u8 host_use_b[32];
200 };
201} __packed;
202
203#define SISL_RESP_HANDLE_T_BIT 0x1ULL /* Toggle bit */
204
205/* MMIO space is required to support only 64-bit access */
206
207/*
208 * This AFU has two mechanisms to deal with endian-ness.
209 * One is a global configuration (in the afu_config) register
210 * below that specifies the endian-ness of the host.
211 * The other is a per context (i.e. application) specification
212 * controlled by the endian_ctrl field here. Since the master
213 * context is one such application the master context's
214 * endian-ness is set to be the same as the host.
215 *
216 * As per the SISlite spec, the MMIO registers are always
217 * big endian.
218 */
219#define SISL_ENDIAN_CTRL_BE 0x8000000000000080ULL
220#define SISL_ENDIAN_CTRL_LE 0x0000000000000000ULL
221
222#ifdef __BIG_ENDIAN
223#define SISL_ENDIAN_CTRL SISL_ENDIAN_CTRL_BE
224#else
225#define SISL_ENDIAN_CTRL SISL_ENDIAN_CTRL_LE
226#endif
227
228/* per context host transport MMIO */
229struct sisl_host_map {
230 __be64 endian_ctrl; /* Per context Endian Control. The AFU will
231 * operate on whatever the context is of the
232 * host application.
233 */
234
235 __be64 intr_status; /* this sends LISN# programmed in ctx_ctrl.
236 * Only recovery in a PERM_ERR is a context
237 * exit since there is no way to tell which
238 * command caused the error.
239 */
240#define SISL_ISTATUS_PERM_ERR_CMDROOM 0x0010ULL /* b59, user error */
241#define SISL_ISTATUS_PERM_ERR_RCB_READ 0x0008ULL /* b60, user error */
242#define SISL_ISTATUS_PERM_ERR_SA_WRITE 0x0004ULL /* b61, user error */
243#define SISL_ISTATUS_PERM_ERR_RRQ_WRITE 0x0002ULL /* b62, user error */
244 /* Page in wait accessing RCB/IOASA/RRQ is reported in b63.
245 * Same error in data/LXT/RHT access is reported via IOASA.
246 */
247#define SISL_ISTATUS_TEMP_ERR_PAGEIN 0x0001ULL /* b63, can be generated
248 * only when AFU auto
249 * retry is disabled.
250 * If user can determine
251 * the command that
252 * caused the error, it
253 * can be retried.
254 */
255#define SISL_ISTATUS_UNMASK (0x001FULL) /* 1 means unmasked */
256#define SISL_ISTATUS_MASK ~(SISL_ISTATUS_UNMASK) /* 1 means masked */
257
258 __be64 intr_clear;
259 __be64 intr_mask;
260 __be64 ioarrin; /* only write what cmd_room permits */
261 __be64 rrq_start; /* start & end are both inclusive */
262 __be64 rrq_end; /* write sequence: start followed by end */
263 __be64 cmd_room;
f15fbf8d 264 __be64 ctx_ctrl; /* least significant byte or b56:63 is LISN# */
c21e0bbf 265 __be64 mbox_w; /* restricted use */
bae0ac69
MO
266 __be64 sq_start; /* Submission Queue (R/W): write sequence and */
267 __be64 sq_end; /* inclusion semantics are the same as RRQ */
268 __be64 sq_head; /* Submission Queue Head (R): for debugging */
269 __be64 sq_tail; /* Submission Queue TAIL (R/W): next IOARCB */
270 __be64 sq_ctx_reset; /* Submission Queue Context Reset (R/W) */
c21e0bbf
MO
271};
272
273/* per context provisioning & control MMIO */
274struct sisl_ctrl_map {
275 __be64 rht_start;
276 __be64 rht_cnt_id;
277 /* both cnt & ctx_id args must be ULL */
278#define SISL_RHT_CNT_ID(cnt, ctx_id) (((cnt) << 48) | ((ctx_id) << 32))
279
280 __be64 ctx_cap; /* afu_rc below is when the capability is violated */
281#define SISL_CTX_CAP_PROXY_ISSUE 0x8000000000000000ULL /* afu_rc 0x21 */
282#define SISL_CTX_CAP_REAL_MODE 0x4000000000000000ULL /* afu_rc 0x21 */
283#define SISL_CTX_CAP_HOST_XLATE 0x2000000000000000ULL /* afu_rc 0x1a */
284#define SISL_CTX_CAP_PROXY_TARGET 0x1000000000000000ULL /* afu_rc 0x21 */
285#define SISL_CTX_CAP_AFU_CMD 0x0000000000000008ULL /* afu_rc 0x21 */
286#define SISL_CTX_CAP_GSCSI_CMD 0x0000000000000004ULL /* afu_rc 0x21 */
287#define SISL_CTX_CAP_WRITE_CMD 0x0000000000000002ULL /* afu_rc 0x21 */
288#define SISL_CTX_CAP_READ_CMD 0x0000000000000001ULL /* afu_rc 0x21 */
289 __be64 mbox_r;
290};
291
292/* single copy global regs */
293struct sisl_global_regs {
294 __be64 aintr_status;
a290b480
MO
295 /*
296 * In cxlflash, FC port/link are arranged in port pairs, each
297 * gets a byte of status:
298 *
299 * *_OTHER: other err, FC_ERRCAP[31:20]
300 * *_LOGO: target sent FLOGI/PLOGI/LOGO while logged in
301 * *_CRC_T: CRC threshold exceeded
302 * *_LOGI_R: login state machine timed out and retrying
303 * *_LOGI_F: login failed, FC_ERROR[19:0]
304 * *_LOGI_S: login succeeded
305 * *_LINK_DN: link online to offline
306 * *_LINK_UP: link offline to online
307 */
308#define SISL_ASTATUS_FC2_OTHER 0x80000000ULL /* b32 */
309#define SISL_ASTATUS_FC2_LOGO 0x40000000ULL /* b33 */
310#define SISL_ASTATUS_FC2_CRC_T 0x20000000ULL /* b34 */
311#define SISL_ASTATUS_FC2_LOGI_R 0x10000000ULL /* b35 */
312#define SISL_ASTATUS_FC2_LOGI_F 0x08000000ULL /* b36 */
313#define SISL_ASTATUS_FC2_LOGI_S 0x04000000ULL /* b37 */
314#define SISL_ASTATUS_FC2_LINK_DN 0x02000000ULL /* b38 */
315#define SISL_ASTATUS_FC2_LINK_UP 0x01000000ULL /* b39 */
316
317#define SISL_ASTATUS_FC3_OTHER 0x00800000ULL /* b40 */
318#define SISL_ASTATUS_FC3_LOGO 0x00400000ULL /* b41 */
319#define SISL_ASTATUS_FC3_CRC_T 0x00200000ULL /* b42 */
320#define SISL_ASTATUS_FC3_LOGI_R 0x00100000ULL /* b43 */
321#define SISL_ASTATUS_FC3_LOGI_F 0x00080000ULL /* b44 */
322#define SISL_ASTATUS_FC3_LOGI_S 0x00040000ULL /* b45 */
323#define SISL_ASTATUS_FC3_LINK_DN 0x00020000ULL /* b46 */
324#define SISL_ASTATUS_FC3_LINK_UP 0x00010000ULL /* b47 */
325
326#define SISL_ASTATUS_FC0_OTHER 0x00008000ULL /* b48 */
327#define SISL_ASTATUS_FC0_LOGO 0x00004000ULL /* b49 */
328#define SISL_ASTATUS_FC0_CRC_T 0x00002000ULL /* b50 */
329#define SISL_ASTATUS_FC0_LOGI_R 0x00001000ULL /* b51 */
330#define SISL_ASTATUS_FC0_LOGI_F 0x00000800ULL /* b52 */
331#define SISL_ASTATUS_FC0_LOGI_S 0x00000400ULL /* b53 */
332#define SISL_ASTATUS_FC0_LINK_DN 0x00000200ULL /* b54 */
333#define SISL_ASTATUS_FC0_LINK_UP 0x00000100ULL /* b55 */
334
335#define SISL_ASTATUS_FC1_OTHER 0x00000080ULL /* b56 */
336#define SISL_ASTATUS_FC1_LOGO 0x00000040ULL /* b57 */
337#define SISL_ASTATUS_FC1_CRC_T 0x00000020ULL /* b58 */
338#define SISL_ASTATUS_FC1_LOGI_R 0x00000010ULL /* b59 */
339#define SISL_ASTATUS_FC1_LOGI_F 0x00000008ULL /* b60 */
340#define SISL_ASTATUS_FC1_LOGI_S 0x00000004ULL /* b61 */
341#define SISL_ASTATUS_FC1_LINK_DN 0x00000002ULL /* b62 */
342#define SISL_ASTATUS_FC1_LINK_UP 0x00000001ULL /* b63 */
c21e0bbf
MO
343
344#define SISL_FC_INTERNAL_UNMASK 0x0000000300000000ULL /* 1 means unmasked */
345#define SISL_FC_INTERNAL_MASK ~(SISL_FC_INTERNAL_UNMASK)
346#define SISL_FC_INTERNAL_SHIFT 32
347
704c4b0d
UK
348#define SISL_FC_SHUTDOWN_NORMAL 0x0000000000000010ULL
349#define SISL_FC_SHUTDOWN_ABRUPT 0x0000000000000020ULL
350
351#define SISL_STATUS_SHUTDOWN_ACTIVE 0x0000000000000010ULL
352#define SISL_STATUS_SHUTDOWN_COMPLETE 0x0000000000000020ULL
353
a290b480 354#define SISL_ASTATUS_UNMASK 0xFFFFFFFFULL /* 1 means unmasked */
c21e0bbf
MO
355#define SISL_ASTATUS_MASK ~(SISL_ASTATUS_UNMASK) /* 1 means masked */
356
357 __be64 aintr_clear;
358 __be64 aintr_mask;
359 __be64 afu_ctrl;
360 __be64 afu_hb;
361 __be64 afu_scratch_pad;
362 __be64 afu_port_sel;
363#define SISL_AFUCONF_AR_IOARCB 0x4000ULL
364#define SISL_AFUCONF_AR_LXT 0x2000ULL
365#define SISL_AFUCONF_AR_RHT 0x1000ULL
366#define SISL_AFUCONF_AR_DATA 0x0800ULL
367#define SISL_AFUCONF_AR_RSRC 0x0400ULL
368#define SISL_AFUCONF_AR_IOASA 0x0200ULL
369#define SISL_AFUCONF_AR_RRQ 0x0100ULL
370/* Aggregate all Auto Retry Bits */
371#define SISL_AFUCONF_AR_ALL (SISL_AFUCONF_AR_IOARCB|SISL_AFUCONF_AR_LXT| \
372 SISL_AFUCONF_AR_RHT|SISL_AFUCONF_AR_DATA| \
373 SISL_AFUCONF_AR_RSRC|SISL_AFUCONF_AR_IOASA| \
374 SISL_AFUCONF_AR_RRQ)
375#ifdef __BIG_ENDIAN
376#define SISL_AFUCONF_ENDIAN 0x0000ULL
377#else
378#define SISL_AFUCONF_ENDIAN 0x0020ULL
379#endif
380#define SISL_AFUCONF_MBOX_CLR_READ 0x0010ULL
381 __be64 afu_config;
382 __be64 rsvd[0xf8];
e5ce067b 383 __le64 afu_version;
c21e0bbf 384 __be64 interface_version;
bae0ac69
MO
385#define SISL_INTVER_CAP_SHIFT 16
386#define SISL_INTVER_MAJ_SHIFT 8
387#define SISL_INTVER_CAP_MASK 0xFFFFFFFF00000000ULL
388#define SISL_INTVER_MAJ_MASK 0x00000000FFFF0000ULL
389#define SISL_INTVER_MIN_MASK 0x000000000000FFFFULL
390#define SISL_INTVER_CAP_IOARRIN_CMD_MODE 0x800000000000ULL
391#define SISL_INTVER_CAP_SQ_CMD_MODE 0x400000000000ULL
392#define SISL_INTVER_CAP_RESERVED_CMD_MODE_A 0x200000000000ULL
393#define SISL_INTVER_CAP_RESERVED_CMD_MODE_B 0x100000000000ULL
c21e0bbf
MO
394};
395
a290b480 396#define CXLFLASH_NUM_FC_PORTS_PER_BANK 2 /* fixed # of ports per bank */
bdcff1c5 397#define CXLFLASH_MAX_FC_BANKS 2 /* max # of banks supported */
a290b480
MO
398#define CXLFLASH_MAX_FC_PORTS (CXLFLASH_NUM_FC_PORTS_PER_BANK * \
399 CXLFLASH_MAX_FC_BANKS)
400#define CXLFLASH_MAX_CONTEXT 512 /* number of contexts per AFU */
401#define CXLFLASH_NUM_VLUNS 512 /* number of vluns per AFU/port */
402#define CXLFLASH_NUM_REGS 512 /* number of registers per port */
403
404struct fc_port_bank {
405 __be64 fc_port_regs[CXLFLASH_NUM_FC_PORTS_PER_BANK][CXLFLASH_NUM_REGS];
406 __be64 fc_port_luns[CXLFLASH_NUM_FC_PORTS_PER_BANK][CXLFLASH_NUM_VLUNS];
407};
c21e0bbf
MO
408
409struct sisl_global_map {
410 union {
411 struct sisl_global_regs regs;
412 char page0[SIZE_4K]; /* page 0 */
413 };
414
415 char page1[SIZE_4K]; /* page 1 */
416
bdcff1c5 417 struct fc_port_bank bank[CXLFLASH_MAX_FC_BANKS]; /* pages 2 - 9 */
c21e0bbf 418
bdcff1c5 419 /* pages 10 - 15 are reserved */
c21e0bbf
MO
420
421};
422
423/*
424 * CXL Flash Memory Map
425 *
426 * +-------------------------------+
427 * | 512 * 64 KB User MMIO |
428 * | (per context) |
429 * | User Accessible |
430 * +-------------------------------+
431 * | 512 * 128 B per context |
432 * | Provisioning and Control |
433 * | Trusted Process accessible |
434 * +-------------------------------+
435 * | 64 KB Global |
436 * | Trusted Process accessible |
437 * +-------------------------------+
438*/
439struct cxlflash_afu_map {
440 union {
441 struct sisl_host_map host;
442 char harea[SIZE_64K]; /* 64KB each */
443 } hosts[CXLFLASH_MAX_CONTEXT];
444
445 union {
446 struct sisl_ctrl_map ctrl;
447 char carea[cache_line_size()]; /* 128B each */
448 } ctrls[CXLFLASH_MAX_CONTEXT];
449
450 union {
451 struct sisl_global_map global;
452 char garea[SIZE_64K]; /* 64KB single block */
453 };
454};
455
2cb79266
MO
456/*
457 * LXT - LBA Translation Table
458 * LXT control blocks
459 */
c21e0bbf
MO
460struct sisl_lxt_entry {
461 u64 rlba_base; /* bits 0:47 is base
2cb79266
MO
462 * b48:55 is lun index
463 * b58:59 is write & read perms
464 * (if no perm, afu_rc=0x15)
465 * b60:63 is port_sel mask
466 */
c21e0bbf
MO
467};
468
65be2c79
MO
469/*
470 * RHT - Resource Handle Table
471 * Per the SISlite spec, RHT entries are to be 16-byte aligned
472 */
c21e0bbf
MO
473struct sisl_rht_entry {
474 struct sisl_lxt_entry *lxt_start;
475 u32 lxt_cnt;
476 u16 rsvd;
477 u8 fp; /* format & perm nibbles.
478 * (if no perm, afu_rc=0x05)
479 */
480 u8 nmask;
481} __packed __aligned(16);
482
483struct sisl_rht_entry_f1 {
484 u64 lun_id;
485 union {
486 struct {
487 u8 valid;
488 u8 rsvd[5];
489 u8 fp;
490 u8 port_sel;
491 };
492
493 u64 dw;
494 };
495} __packed __aligned(16);
496
497/* make the fp byte */
498#define SISL_RHT_FP(fmt, perm) (((fmt) << 4) | (perm))
499
500/* make the fp byte for a clone from a source fp and clone flags
501 * flags must be only 2 LSB bits.
502 */
503#define SISL_RHT_FP_CLONE(src_fp, cln_flags) ((src_fp) & (0xFC | (cln_flags)))
504
505#define RHT_PERM_READ 0x01U
506#define RHT_PERM_WRITE 0x02U
507#define RHT_PERM_RW (RHT_PERM_READ | RHT_PERM_WRITE)
508
509/* extract the perm bits from a fp */
510#define SISL_RHT_PERM(fp) ((fp) & RHT_PERM_RW)
511
512#define PORT0 0x01U
513#define PORT1 0x02U
a290b480
MO
514#define PORT2 0x04U
515#define PORT3 0x08U
e8e17ea6 516#define PORT_MASK(_n) ((1 << (_n)) - 1)
c21e0bbf
MO
517
518/* AFU Sync Mode byte */
519#define AFU_LW_SYNC 0x0U
520#define AFU_HW_SYNC 0x1U
521#define AFU_GSYNC 0x2U
522
523/* Special Task Management Function CDB */
524#define TMF_LUN_RESET 0x1U
525#define TMF_CLEAR_ACA 0x2U
526
2cb79266
MO
527
528#define SISLITE_MAX_WS_BLOCKS 512
529
c21e0bbf 530#endif /* _SISLITE_H */