1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2010 Emulex.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _EMLXS_IOCB_H
28 #define	_EMLXS_IOCB_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /* ==== IOCB Commands ==== */
35 
36 #define	CMD_RCV_SEQUENCE_CX	0x01
37 #define	CMD_XMIT_SEQUENCE_CR	0x02
38 #define	CMD_XMIT_SEQUENCE_CX	0x03
39 #define	CMD_XMIT_BCAST_CN	0x04
40 #define	CMD_XMIT_BCAST_CX	0x05
41 #define	CMD_QUE_RING_BUF_CN	0x06
42 #define	CMD_QUE_XRI_BUF_CX	0x07
43 #define	CMD_IOCB_CONTINUE_CN	0x08
44 #define	CMD_RET_XRI_BUF_CX	0x09
45 #define	CMD_ELS_REQUEST_CR	0x0A
46 #define	CMD_ELS_REQUEST_CX	0x0B
47 #define	CMD_RCV_ELS_REQ_CX	0x0D
48 #define	CMD_ABORT_XRI_CN	0x0E
49 #define	CMD_ABORT_XRI_CX	0x0F
50 #define	CMD_CLOSE_XRI_CN	0x10
51 #define	CMD_CLOSE_XRI_CX	0x11
52 #define	CMD_CREATE_XRI_CR	0x12
53 #define	CMD_CREATE_XRI_CX	0x13
54 #define	CMD_GET_RPI_CN		0x14
55 #define	CMD_XMIT_ELS_RSP_CX	0x15
56 #define	CMD_GET_RPI_CR		0x16
57 #define	CMD_XRI_ABORTED_CX	0x17
58 #define	CMD_FCP_IWRITE_CR	0x18
59 #define	CMD_FCP_IWRITE_CX	0x19
60 #define	CMD_FCP_IREAD_CR	0x1A
61 #define	CMD_FCP_IREAD_CX	0x1B
62 #define	CMD_FCP_ICMND_CR	0x1C
63 #define	CMD_FCP_ICMND_CX	0x1D
64 #define	CMD_FCP_TSEND_CX	0x1F	/* FCP_TARGET_MODE */
65 #define	CMD_ADAPTER_MSG		0x20
66 #define	CMD_FCP_TRECEIVE_CX	0x21	/* FCP_TARGET_MODE */
67 #define	CMD_ADAPTER_DUMP	0x22
68 #define	CMD_FCP_TRSP_CX		0x23	/* FCP_TARGET_MODE */
69 #define	CMD_FCP_AUTO_TRSP_CX	0x29	/* FCP_TARGET_MODE */
70 
71 /* LP3000 gasket IOCB Command Set */
72 
73 #define	CMD_BPL_IWRITE_CR	0x48
74 #define	CMD_BPL_IWRITE_CX	0x49
75 #define	CMD_BPL_IREAD_CR	0x4A
76 #define	CMD_BPL_IREAD_CX	0x4B
77 #define	CMD_BPL_ICMND_CR	0x4C
78 #define	CMD_BPL_ICMND_CX	0x4D
79 
80 #define	CMD_ASYNC_STATUS	0x7C
81 
82 /* SLI_2 IOCB Command Set */
83 #define	CMD_RCV_SEQUENCE64_CX	0x81
84 #define	CMD_XMIT_SEQUENCE64_CR	0x82
85 #define	CMD_XMIT_SEQUENCE64_CX	0x83
86 #define	CMD_XMIT_BCAST64_CN	0x84
87 #define	CMD_XMIT_BCAST64_CX	0x85
88 #define	CMD_QUE_RING_BUF64_CN	0x86
89 #define	CMD_QUE_XRI_BUF64_CX	0x87
90 #define	CMD_IOCB_CONTINUE64_CN	0x88
91 #define	CMD_RET_XRI_BUF64_CX	0x89
92 #define	CMD_ELS_REQUEST64_CR	0x8A
93 #define	CMD_ELS_REQUEST64_CX	0x8B
94 #define	CMD_RCV_ELS_REQ64_CX	0x8D
95 #define	CMD_XMIT_ELS_RSP64_CX	0x95
96 #define	CMD_XMIT_BLS_RSP64_CX	0x97
97 #define	CMD_FCP_IWRITE64_CR	0x98
98 #define	CMD_FCP_IWRITE64_CX	0x99
99 #define	CMD_FCP_IREAD64_CR	0x9A
100 #define	CMD_FCP_IREAD64_CX	0x9B
101 #define	CMD_FCP_ICMND64_CR	0x9C
102 #define	CMD_FCP_ICMND64_CX	0x9D
103 #define	CMD_FCP_TSEND64_CX	0x9F	/* FCP_TARGET_MODE */
104 #define	CMD_FCP_TRECEIVE64_CX	0xA1	/* FCP_TARGET_MODE */
105 #define	CMD_FCP_TRSP64_CX	0xA3	/* FCP_TARGET_MODE */
106 #define	CMD_RCV_SEQ64_CX	0xB5	/* SLI3 */
107 #define	CMD_RCV_ELS64_CX	0xB7	/* SLI3 */
108 #define	CMD_RCV_CONT64_CX	0xBB	/* SLI3 */
109 #define	CMD_RCV_SEQ_LIST64_CX	0xC1
110 #define	CMD_GEN_REQUEST64_CR	0xC2
111 #define	CMD_GEN_REQUEST64_CX	0xC3
112 #define	CMD_QUE_RING_LIST64_CN	0xC6
113 
114 
115 /*
116  * Begin Structure Definitions for IOCB Commands
117  */
118 
119 typedef struct
120 {
121 #ifdef EMLXS_BIG_ENDIAN
122 	uint8_t		statAction;
123 	uint8_t		statRsn;
124 	uint8_t		statBaExp;
125 	uint8_t		statLocalError;
126 #endif
127 #ifdef EMLXS_LITTLE_ENDIAN
128 	uint8_t		statLocalError;
129 	uint8_t		statBaExp;
130 	uint8_t		statRsn;
131 	uint8_t		statAction;
132 #endif
133 	/* statAction  FBSY reason codes */
134 #define	FBSY_RSN_MASK	0xF0	/* Rsn stored in upper nibble */
135 #define	FBSY_FABRIC_BSY	0x10	/* F_bsy due to Fabric BSY */
136 #define	FBSY_NPORT_BSY	0x30	/* F_bsy due to N_port BSY */
137 
138 	/* statAction  PBSY action codes */
139 #define	PBSY_ACTION1	0x01	/* Sequence terminated - retry */
140 #define	PBSY_ACTION2	0x02	/* Sequence active - retry */
141 
142 	/* statAction  P/FRJT action codes */
143 #define	RJT_RETRYABLE	0x01	/* Retryable class of error */
144 #define	RJT_NO_RETRY	0x02	/* Non-Retryable class of error */
145 
146 	/* statRsn  LS_RJT reason codes defined in LS_RJT structure */
147 
148 	/* statRsn  P_BSY reason codes */
149 #define	PBSY_NPORT_BSY	0x01	/* Physical N_port BSY */
150 #define	PBSY_RESRCE_BSY	0x03	/* N_port resource BSY */
151 #define	PBSY_VU_BSY	0xFF	/* See VU field for rsn */
152 
153 	/* statRsn  P/F_RJT reason codes */
154 #define	RJT_BAD_D_ID		0x01	/* Invalid D_ID field */
155 #define	RJT_BAD_S_ID		0x02	/* Invalid S_ID field */
156 #define	RJT_UNAVAIL_TEMP	0x03	/* N_Port unavailable temp. */
157 #define	RJT_UNAVAIL_PERM	0x04	/* N_Port unavailable perm. */
158 #define	RJT_UNSUP_CLASS		0x05	/* Class not supported */
159 #define	RJT_DELIM_ERR		0x06	/* Delimiter usage error */
160 #define	RJT_UNSUP_TYPE		0x07	/* Type not supported */
161 #define	RJT_BAD_CONTROL		0x08	/* Invalid link conrtol */
162 #define	RJT_BAD_RCTL		0x09	/* R_CTL invalid */
163 #define	RJT_BAD_FCTL		0x0A	/* F_CTL invalid */
164 #define	RJT_BAD_OXID		0x0B	/* OX_ID invalid */
165 #define	RJT_BAD_RXID		0x0C	/* RX_ID invalid */
166 #define	RJT_BAD_SEQID		0x0D	/* SEQ_ID invalid */
167 #define	RJT_BAD_DFCTL		0x0E	/* DF_CTL invalid */
168 #define	RJT_BAD_SEQCNT		0x0F	/* SEQ_CNT invalid */
169 #define	RJT_BAD_PARM		0x10	/* Param. field invalid */
170 #define	RJT_XCHG_ERR		0x11	/* Exchange error */
171 #define	RJT_PROT_ERR		0x12	/* Protocol error */
172 #define	RJT_BAD_LENGTH		0x13	/* Invalid Length */
173 #define	RJT_UNEXPECTED_ACK	0x14	/* Unexpected ACK */
174 #define	RJT_LOGIN_REQUIRED	0x16	/* Login required */
175 #define	RJT_TOO_MANY_SEQ	0x17	/* Excessive sequences */
176 #define	RJT_XCHG_NOT_STRT	0x18	/* Exchange not started */
177 #define	RJT_UNSUP_SEC_HDR	0x19	/* Security hdr not supported */
178 #define	RJT_UNAVAIL_PATH	0x1A	/* Fabric Path not available */
179 #define	RJT_VENDOR_UNIQUE	0xFF	/* Vendor unique error */
180 
181 	/* statRsn  BA_RJT reason codes */
182 #define	BARJT_BAD_CMD_CODE	0x01	/* Invalid command code */
183 #define	BARJT_LOGICAL_ERR	0x03	/* Logical error */
184 #define	BARJT_LOGICAL_BSY	0x05	/* Logical busy */
185 #define	BARJT_PROTOCOL_ERR	0x07	/* Protocol error */
186 #define	BARJT_VU_ERR		0xFF	/* Vendor unique error */
187 
188 	/* LS_RJT reason explanation defined in LS_RJT structure */
189 
190 	/* BA_RJT reason explanation */
191 #define	BARJT_EXP_INVALID_ID	0x01	/* Invalid OX_ID/RX_ID */
192 #define	BARJT_EXP_ABORT_SEQ	0x05	/* Abort SEQ, no more info */
193 
194 	/* Local Reject errors */
195 #define	IOERR_SUCCESS			0x00
196 #define	IOERR_MISSING_CONTINUE		0x01
197 #define	IOERR_SEQUENCE_TIMEOUT		0x02
198 #define	IOERR_INTERNAL_ERROR		0x03
199 #define	IOERR_INVALID_RPI		0x04
200 #define	IOERR_NO_XRI			0x05
201 #define	IOERR_ILLEGAL_COMMAND		0x06
202 #define	IOERR_XCHG_DROPPED		0x07
203 #define	IOERR_ILLEGAL_FIELD		0x08
204 /* RESERVED 0x09 */
205 /* RESERVED 0x0A */
206 #define	IOERR_RCV_BUFFER_WAITING	0x0B
207 /* RESERVED 0x0C */
208 #define	IOERR_TX_DMA_FAILED		0x0D
209 #define	IOERR_RX_DMA_FAILED		0x0E
210 #define	IOERR_ILLEGAL_FRAME		0x0F
211 
212 /* RESERVED 0x10 */
213 #define	IOERR_NO_RESOURCES		0x11
214 /* RESERVED 0x12 */
215 #define	IOERR_ILLEGAL_LENGTH		0x13
216 #define	IOERR_UNSUPPORTED_FEATURE	0x14
217 #define	IOERR_ABORT_IN_PROGRESS		0x15
218 #define	IOERR_ABORT_REQUESTED		0x16
219 #define	IOERR_RCV_BUFFER_TIMEOUT	0x17
220 #define	IOERR_LOOP_OPEN_FAILURE		0x18
221 #define	IOERR_RING_RESET		0x19
222 #define	IOERR_LINK_DOWN			0x1A
223 #define	IOERR_CORRUPTED_DATA		0x1B
224 #define	IOERR_CORRUPTED_RPI		0x1C
225 #define	IOERR_OUT_OF_ORDER_DATA		0x1D
226 #define	IOERR_OUT_OF_ORDER_ACK		0x1E
227 #define	IOERR_DUP_FRAME			0x1F
228 
229 #define	IOERR_LINK_CONTROL_FRAME	0x20	/* ACK_N received */
230 #define	IOERR_BAD_HOST_ADDRESS		0x21
231 #define	IOERR_RCV_HDRBUF_WAITING	0x22
232 #define	IOERR_MISSING_HDR_BUFFER	0x23
233 #define	IOERR_MSEQ_CHAIN_CORRUPTED	0x24
234 #define	IOERR_ABORTMULT_REQUESTED	0x25
235 /* RESERVED 0x26 */
236 /* RESERVED 0x27 */
237 #define	IOERR_BUFFER_SHORTAGE		0x28
238 #define	IOERR_XRIBUF_WAITING		0x29
239 /* RESERVED 0x2A */
240 #define	IOERR_MISSING_HBQ_ENTRY		0x2B
241 #define	IOERR_ABORT_EXT_REQ		0x2C
242 #define	IOERR_CLOSE_EXT_REQ		0x2D
243 /* RESERVED 0x2E */
244 /* RESERVED 0x2F */
245 
246 #define	IOERR_XRIBUF_MISSING		0x30
247 #define	IOERR_ASSI_RSP_SUPPRESSED	0x31
248 /* RESERVED 0x32 - 0x3F */
249 
250 #define	IOERR_ROFFSET_INVAL		0x40
251 #define	IOERR_ROFFSET_MISSING		0x41
252 #define	IOERR_INSUF_BUFFER		0x42
253 #define	IOERR_MISSING_SI		0x43
254 #define	IOERR_MISSING_ES		0x44
255 #define	IOERR_INCOMP_XFER		0x45
256 /* RESERVED 0x46 - 0xFF */
257 
258 	/* Driver defined */
259 #define	IOERR_ABORT_TIMEOUT		0xF0
260 } PARM_ERR;
261 
262 typedef union
263 {
264 	struct
265 	{
266 #ifdef EMLXS_BIG_ENDIAN
267 		uint8_t		Rctl;	/* R_CTL field */
268 		uint8_t		Type;	/* TYPE field */
269 		uint8_t		Dfctl;	/* DF_CTL field */
270 		uint8_t		Fctl;	/* Bits 0-7 of IOCB word 5 */
271 #endif
272 #ifdef EMLXS_LITTLE_ENDIAN
273 		uint8_t		Fctl;	/* Bits 0-7 of IOCB word 5 */
274 		uint8_t		Dfctl;	/* DF_CTL field */
275 		uint8_t		Type;	/* TYPE field */
276 		uint8_t		Rctl;	/* R_CTL field */
277 #endif
278 #define	FCP_RTYPE	0x08	/* FCP_TARGET_MODE Type - Rctl */
279 
280 #define	BC		0x02	/* Broadcast Received  - Fctl */
281 #define	SI		0x04	/* Sequence Initiative */
282 #define	LA		0x08	/* Ignore Link Attention state */
283 #define	FSEQ		0x40	/* First Sequence */
284 #define	LSEQ		0x80	/* Last Sequence */
285 	} hcsw;
286 	uint32_t	reserved;
287 } WORD5;
288 
289 
290 /* IOCB Command template for a generic response */
291 typedef struct
292 {
293 	uint32_t	reserved[4];
294 	PARM_ERR	perr;
295 } GENERIC_RSP;
296 
297 
298 /* IOCB Command template for XMIT / XMIT_BCAST / RCV_SEQUENCE / XMIT_ELS */
299 typedef struct
300 {
301 	ULP_BDE		xrsqbde[2];
302 	uint32_t	xrsqRo;		/* Starting Relative Offset */
303 	WORD5		w5;		/* Header control/status word */
304 } XR_SEQ_FIELDS;
305 
306 /* IOCB Command template for ELS_REQUEST */
307 typedef struct
308 {
309 	ULP_BDE		elsReq;
310 	ULP_BDE		elsRsp;
311 #ifdef EMLXS_BIG_ENDIAN
312 	uint32_t	word4Rsvd:7;
313 	uint32_t	fl:1;
314 	uint32_t	myID:24;
315 
316 	uint32_t	word5Rsvd:8;
317 	uint32_t	remoteID:24;
318 #endif
319 #ifdef EMLXS_LITTLE_ENDIAN
320 	uint32_t	myID:24;
321 	uint32_t	fl:1;
322 	uint32_t	word4Rsvd:7;
323 
324 	uint32_t	remoteID:24;
325 	uint32_t	word5Rsvd:8;
326 #endif
327 } ELS_REQUEST;
328 
329 /* IOCB Command template for RCV_ELS_REQ */
330 typedef struct
331 {
332 	ULP_BDE		elsReq[2];
333 	uint32_t	parmRo;
334 #ifdef EMLXS_BIG_ENDIAN
335 	uint32_t	word5Rsvd:8;
336 	uint32_t	remoteID:24;
337 #endif
338 #ifdef EMLXS_LITTLE_ENDIAN
339 	uint32_t	remoteID:24;
340 	uint32_t	word5Rsvd:8;
341 #endif
342 } RCV_ELS_REQ;
343 
344 /* IOCB Command template for ABORT / CLOSE_XRI */
345 typedef struct
346 {
347 	uint32_t	rsvd[3];
348 	uint32_t	abortType;
349 #define	ABORT_TYPE_ABTX		0x00000000
350 #define	ABORT_TYPE_ABTS		0x00000001
351 	uint32_t	parm;
352 #ifdef EMLXS_BIG_ENDIAN
353 	uint16_t	abortContextTag;	/* ulpContext from command to */
354 						/* abort/close */
355 	uint16_t	abortIoTag;		/* ulpIoTag from command to */
356 						/* abort/close */
357 #endif
358 #ifdef EMLXS_LITTLE_ENDIAN
359 	uint16_t	abortIoTag;		/* ulpIoTag from command to */
360 						/* abort/close */
361 	uint16_t	abortContextTag;	/* ulpContext from command to */
362 						/* abort/close */
363 #endif
364 } AC_XRI;
365 
366 /* IOCB Command template for GET_RPI */
367 typedef struct
368 {
369 	uint32_t	rsvd[4];
370 	uint32_t	parmRo;
371 #ifdef EMLXS_BIG_ENDIAN
372 	uint32_t	word5Rsvd:8;
373 	uint32_t	remoteID:24;
374 #endif
375 #ifdef EMLXS_LITTLE_ENDIAN
376 	uint32_t	remoteID:24;
377 	uint32_t	word5Rsvd:8;
378 #endif
379 } GET_RPI;
380 
381 /* IOCB Command template for all FCP Initiator commands */
382 typedef struct
383 {
384 	ULP_BDE		fcpi_cmnd;	/* FCP_CMND payload descriptor */
385 	ULP_BDE		fcpi_rsp;	/* Rcv buffer */
386 	uint32_t	fcpi_parm;
387 	uint32_t	fcpi_XRdy;	/* transfer ready for IWRITE */
388 } FCPI_FIELDS;
389 
390 /* IOCB Command template for all FCP Target commands */
391 typedef struct
392 {
393 	ULP_BDE		fcpt_Buffer[2];	/* FCP_CMND payload descriptor */
394 	uint32_t	fcpt_Offset;
395 	uint32_t	fcpt_Length;	/* transfer ready for IWRITE */
396 } FCPT_FIELDS;
397 
398 /* SLI-2 IOCB structure definitions */
399 
400 /* IOCB Command template for 64 bit XMIT / XMIT_BCAST / XMIT_ELS */
401 typedef struct
402 {
403 	ULP_BDL		bdl;
404 	uint32_t	xrsqRo;	/* Starting Relative Offset */
405 	WORD5		w5;	/* Header control/status word */
406 } XMT_SEQ_FIELDS64;
407 
408 
409 /* IOCB Command template for 64 bit RCV_SEQUENCE64 */
410 typedef struct
411 {
412 	ULP_BDE64	rcvBde;
413 	uint32_t	rsvd1;
414 	uint32_t	xrsqRo;	/* Starting Relative Offset */
415 	WORD5		w5;	/* Header control/status word */
416 } RCV_SEQ_FIELDS64;
417 
418 /* IOCB Command template for ELS_REQUEST64 */
419 typedef struct
420 {
421 	ULP_BDL		bdl;
422 #ifdef EMLXS_BIG_ENDIAN
423 	uint32_t	word4Rsvd:7;
424 	uint32_t	fl:1;
425 	uint32_t	myID:24;
426 
427 	uint32_t	word5Rsvd:8;
428 	uint32_t	remoteID:24;
429 #endif
430 #ifdef EMLXS_LITTLE_ENDIAN
431 	uint32_t	myID:24;
432 	uint32_t	fl:1;
433 	uint32_t	word4Rsvd:7;
434 
435 	uint32_t	remoteID:24;
436 	uint32_t	word5Rsvd:8;
437 #endif
438 } ELS_REQUEST64;
439 
440 
441 /* IOCB Command template for ASYNC_STATUS */
442 typedef struct
443 {
444 	ULP_BDL		resv;
445 	uint32_t	parameter;
446 #ifdef EMLXS_BIG_ENDIAN
447 	uint16_t	EventCode;
448 	uint16_t	SubContext;
449 #endif
450 #ifdef EMLXS_LITTLE_ENDIAN
451 	uint16_t	SubContext;
452 	uint16_t	EventCode;
453 #endif
454 } ASYNC_STATUS;
455 
456 
457 /* IOCB Command template for QUE_RING_LIST64 */
458 typedef struct
459 {
460 	ULP_BDL		bdl;
461 	uint32_t	rsvd1;
462 	uint32_t	rsvd2;
463 } QUE_RING_LIST64;
464 
465 
466 /* IOCB Command template for GEN_REQUEST64 */
467 typedef struct
468 {
469 	ULP_BDL		bdl;
470 	uint32_t	param;	/* Starting Relative Offset */
471 	WORD5		w5;	/* Header control/status word */
472 } GEN_REQUEST64;
473 
474 /* IOCB Command template for RCV_ELS_REQ64 */
475 typedef struct
476 {
477 	ULP_BDE64	elsReq;
478 	uint32_t	rsvd1;
479 	uint32_t	parmRo;
480 #ifdef EMLXS_BIG_ENDIAN
481 	uint32_t	word5Rsvd:8;
482 	uint32_t	remoteID:24;
483 #endif
484 #ifdef EMLXS_LITTLE_ENDIAN
485 	uint32_t	remoteID:24;
486 	uint32_t	word5Rsvd:8;
487 #endif
488 } RCV_ELS_REQ64;
489 
490 /* IOCB Command template for all 64 bit FCP Initiator commands */
491 typedef struct
492 {
493 	ULP_BDL		bdl;
494 	uint32_t	fcpi_parm;
495 	uint32_t	fcpi_XRdy;	/* transfer ready for IWRITE */
496 } FCPI_FIELDS64;
497 
498 /* IOCB Command template for all 64 bit FCP Target commands */
499 typedef struct
500 {
501 	ULP_BDL		bdl;
502 	uint32_t	fcpt_Offset;
503 	uint32_t	fcpt_Length;	/* transfer ready for IWRITE */
504 } FCPT_FIELDS64;
505 
506 /* IOCB Command template for all 64 bit FCP Target commands */
507 typedef struct
508 {
509 	uint32_t	rsp_length;
510 	uint32_t	rsvd1;
511 	uint32_t	rsvd2;
512 	uint32_t	iotag32;
513 	uint32_t	status;
514 #ifdef EMLXS_BIG_ENDIAN
515 	uint32_t	rsvd:30;
516 	uint32_t	lnk:1;
517 #endif /* EMLXS_BIG_ENDIAN */
518 
519 #ifdef EMLXS_LITTLE_ENDIAN
520 	uint32_t	lnk:1;
521 	uint32_t	rsvd:30;
522 #endif /* EMLXS_LITTLE_ENDIAN */
523 } AUTO_TRSP;
524 
525 
526 typedef struct
527 {
528 	uint32_t	io_tag64_low;	/* Word 8 */
529 	uint32_t	io_tag64_high;	/* Word 9 */
530 #ifdef EMLXS_BIG_ENDIAN
531 	uint32_t	cs_ctl:8;	/* Word 10, bit 31:24 */
532 	uint32_t	cs_en:1;	/* Word 10, bit 23 */
533 	uint32_t	rsv:15;		/* Word 10, bit 22:8 */
534 	uint32_t	ebde_count:8;	/* Word 10, bit 7:0 */
535 #endif
536 #ifdef EMLXS_LITTLE_ENDIAN
537 	uint32_t	ebde_count:8;	/* Word 10, bit 7:0 */
538 	uint32_t	rsv:15;		/* Word 10, bit 22:8 */
539 	uint32_t	cs_en:1;	/* Word 10, bit 23 */
540 	uint32_t	cs_ctl:8;	/* Word 10, bit 31:24 */
541 #endif
542 	uint32_t	rsplen;		/* Word 11 */
543 	ULP_BDE64	ebde1;		/* Word 12:14 */
544 	ULP_BDE64	ebde2;		/* Word 15:17 */
545 	ULP_BDE64	ebde3;		/* Word 18:20 */
546 	ULP_BDE64	ebde4;		/* Word 21:23 */
547 	ULP_BDE64	ebde5;		/* Word 24:26 */
548 	ULP_BDE64	ebde6;		/* Word 27:29 */
549 } GENERIC_EXT_IOCB;
550 
551 /*
552  * IOCB Command Extension template for
553  * CMD_RCV_ELS64_CX (0xB7) or CMD_RCV_SEQ64_CX (0xB5)
554  */
555 
556 typedef struct
557 {
558 	uint32_t	hdr3;		/* word 8 */
559 #ifdef EMLXS_BIG_ENDIAN
560 	uint16_t	vpi;		/* word 9 */
561 	uint16_t	buddy_xri;
562 
563 	uint32_t	ccp:8;		/* word 10 */
564 	uint32_t	ccpe:1;
565 	uint32_t	rsvd:23;
566 #endif
567 #ifdef EMLXS_LITTLE_ENDIAN
568 	uint16_t	buddy_xri;	/* word 9 */
569 	uint16_t	vpi;
570 
571 	uint32_t	rsvd:23;	/* word 10 */
572 	uint32_t	ccpe:1;
573 	uint32_t	ccp:8;
574 #endif
575 	uint32_t	seq_len;	/* received sequence length */
576 	ULP_BDL		bde2;		/* total 4 words */
577 } RCV_SEQ_ELS_64_SLI3_EXT;
578 
579 
580 
581 typedef volatile struct emlxs_iocb
582 { /* IOCB structure */
583 	union
584 	{
585 		GENERIC_RSP		grsp;		/* Generic response */
586 		XR_SEQ_FIELDS		xrseq;		/* XMIT/BCAST/RCV_SEQ */
587 		ULP_BDE			cont[3];	/* up to 3 cont BDEs */
588 		ELS_REQUEST		elsreq;		/* ELS_REQ template */
589 		RCV_ELS_REQ		rcvels;		/* RCV_ELS_REQ */
590 							/* template */
591 		AC_XRI			acxri;		/* ABORT/CLOSE_XRI */
592 							/* template */
593 		GET_RPI			getrpi;		/* GET_RPI template */
594 		FCPI_FIELDS		fcpi;		/* FCP Initiator */
595 							/* template */
596 		FCPT_FIELDS		fcpt;		/* FCP target */
597 							/* template */
598 
599 		/* SLI-2 structures */
600 
601 		ULP_BDE64		cont64[2];	/* up to 2 64 bit */
602 							/* cont BDE_64s */
603 		ELS_REQUEST64		elsreq64;	/* ELS_REQ64 template */
604 		QUE_RING_LIST64		qringlist64;	/* QUE RING LIST64 */
605 							/* template */
606 		GEN_REQUEST64		genreq64;	/* GEN_REQUEST64 */
607 							/* template */
608 		RCV_ELS_REQ64		rcvels64;	/* RCV_ELS_REQ */
609 							/* template */
610 		XMT_SEQ_FIELDS64	xseq64;		/* XMIT / BCAST cmd */
611 		FCPI_FIELDS64		fcpi64;		/* FCP 64 bit */
612 							/* Initiator template */
613 		FCPT_FIELDS64		fcpt64;		/* FCP 64 bit target */
614 							/* template */
615 		AUTO_TRSP		atrsp;		/* FCP 64 bit target */
616 							/* template */
617 
618 		RCV_SEQ_FIELDS64	rcvseq64;
619 		ASYNC_STATUS		astat;
620 
621 		uint32_t		ulpWord[6];	/* generic 6 'words' */
622 	} un;
623 	union
624 	{
625 		struct
626 		{
627 #ifdef EMLXS_BIG_ENDIAN
628 			uint16_t	ulpContext;	/* High order bits */
629 							/* word6 */
630 			uint16_t	ulpIoTag;	/* Low order bits */
631 							/* word6 */
632 #endif
633 #ifdef EMLXS_LITTLE_ENDIAN
634 			uint16_t	ulpIoTag;	/* Low order bits */
635 							/* word6 */
636 			uint16_t	ulpContext;	/* High order bits */
637 							/* word6 */
638 #endif
639 		} t1;
640 		struct
641 		{
642 #ifdef EMLXS_BIG_ENDIAN
643 			uint16_t	ulpContext;	/* High order bits */
644 							/* word6 */
645 			uint16_t	ulpIoTag1:2;	/* Low order bits */
646 							/* word6 */
647 			uint16_t	ulpIoTag0:14;	/* Low order bits */
648 							/* word6 */
649 #endif
650 #ifdef EMLXS_LITTLE_ENDIAN
651 			uint16_t	ulpIoTag0:14;	/* Low order bits */
652 							/* word6 */
653 			uint16_t	ulpIoTag1:2;	/* Low order bits */
654 							/* word6 */
655 			uint16_t	ulpContext;	/* High order bits */
656 							/* word6 */
657 #endif
658 		} t2;
659 
660 		uint32_t	ulpWord;
661 	} un1;
662 #define	ULPCONTEXT	un1.t1.ulpContext
663 #define	ULPIOTAG	un1.t1.ulpIoTag
664 #define	ULPIOTAG0	un1.t2.ulpIoTag0
665 #define	ULPDELAYXMIT	un1.t2.ulpIoTag1
666 
667 #define	IOCB_DELAYXMIT_MSK 0x3000
668 
669 
670 	union
671 	{
672 		struct
673 		{
674 #ifdef EMLXS_BIG_ENDIAN
675 			uint32_t	ulpRsvdByte:8;
676 			uint32_t	ulpXS:1;
677 			uint32_t	ulpFCP2Rcvy:1;
678 			uint32_t	ulpPU:2;
679 			uint32_t	ulpIr:1;
680 			uint32_t	ulpClass:3;
681 			uint32_t	ulpCommand:8;
682 			uint32_t	ulpStatus:4;
683 			uint32_t	ulpBdeCount:2;
684 			uint32_t	ulpLe:1;
685 			uint32_t	ulpOwner:1;	/* Low order bit */
686 							/* word 7 */
687 #endif
688 #ifdef EMLXS_LITTLE_ENDIAN
689 			uint32_t	ulpOwner:1;	/* Low order bit */
690 							/* word 7 */
691 			uint32_t	ulpLe:1;
692 			uint32_t	ulpBdeCount:2;
693 			uint32_t	ulpStatus:4;
694 			uint32_t	ulpCommand:8;
695 			uint32_t	ulpClass:3;
696 			uint32_t	ulpIr:1;
697 			uint32_t	ulpPU:2;
698 			uint32_t	ulpFCP2Rcvy:1;
699 			uint32_t	ulpXS:1;
700 			uint32_t	ulpRsvdByte:8;
701 #endif
702 		} t1;
703 
704 		struct
705 		{
706 #ifdef EMLXS_BIG_ENDIAN
707 			uint32_t	ulpRsvdByte:8;
708 			uint32_t	ulpCT:2;
709 			uint32_t	ulpPU:2;
710 			uint32_t	ulpIr:1;
711 			uint32_t	ulpClass:3;
712 			uint32_t	ulpCommand:8;
713 			uint32_t	ulpStatus:4;
714 			uint32_t	ulpBdeCount:2;
715 			uint32_t	ulpLe:1;
716 			uint32_t	ulpOwner:1;	/* Low order bit */
717 							/* word 7 */
718 #endif
719 #ifdef EMLXS_LITTLE_ENDIAN
720 			uint32_t	ulpOwner:1;	/* Low order bit */
721 							/* word 7 */
722 			uint32_t	ulpLe:1;
723 			uint32_t	ulpBdeCount:2;
724 			uint32_t	ulpStatus:4;
725 			uint32_t	ulpCommand:8;
726 			uint32_t	ulpClass:3;
727 			uint32_t	ulpIr:1;
728 			uint32_t	ulpPU:2;
729 			uint32_t	ulpCT:2;
730 			uint32_t	ulpRsvdByte:8;
731 #endif
732 		} t2;
733 
734 		uint32_t	ulpWord;
735 	} un2;
736 
737 #define	ULPCT		un2.t2.ulpCT
738 #define	ULPRSVDBYTE	un2.t1.ulpRsvdByte
739 #define	ULPXS		un2.t1.ulpXS
740 #define	ULPFCP2RCVY	un2.t1.ulpFCP2Rcvy
741 #define	ULPPU		un2.t1.ulpPU
742 #define	ULPIR		un2.t1.ulpIr
743 #define	ULPCLASS	un2.t1.ulpClass
744 #define	ULPCOMMAND	un2.t1.ulpCommand
745 #define	ULPSTATUS	un2.t1.ulpStatus
746 #define	ULPBDECOUNT	un2.t1.ulpBdeCount
747 #define	ULPLE		un2.t1.ulpLe
748 #define	ULPOWNER	un2.t1.ulpOwner
749 	/* 32 bytes at this point */
750 
751 /* SLI4 */
752 #define	RXFCHDR		un.ulpWord
753 #define	RXSEQCNT	un1.ulpWord
754 #define	RXSEQLEN	un2.ulpWord
755 
756 	union
757 	{
758 		GENERIC_EXT_IOCB	ext_iocb;
759 		RCV_SEQ_ELS_64_SLI3_EXT	ext_rcv;
760 		uint32_t		sli3Words[24];	/* 96 extra bytes */
761 							/* for SLI-3 */
762 	} unsli3;
763 	/* 128 bytes at this point */
764 
765 #define	IOCB_FCP		1	/* IOCB is used for */
766 					/* FCP ELS cmds - ulpRsvByte */
767 #define	IOCB_IP			2	/* IOCB is used for IP ELS cmds */
768 #define	PARM_UNUSED		0	/* PU field (Word 4) not used */
769 #define	PARM_REL_OFF		1	/* PU field (Word 4) = R. O. */
770 #define	PARM_READ_CHECK		2	/* PU field (Word 4) = Data Xfer Len */
771 #define	CLASS1			0	/* Class 1 */
772 #define	CLASS2			1	/* Class 2 */
773 #define	CLASS3			2	/* Class 3 */
774 #define	CLASS_FCP_INTERMIX	7	/* FCP Data->Cls 1, all else->Cls 2 */
775 
776 #define	IOSTAT_SUCCESS			0x0	/* ulpStatus */
777 #define	IOSTAT_FCP_RSP_ERROR		0x1
778 #define	IOSTAT_REMOTE_STOP		0x2
779 #define	IOSTAT_LOCAL_REJECT		0x3
780 #define	IOSTAT_NPORT_RJT		0x4
781 #define	IOSTAT_FABRIC_RJT		0x5
782 #define	IOSTAT_NPORT_BSY		0x6
783 #define	IOSTAT_FABRIC_BSY		0x7
784 #define	IOSTAT_INTERMED_RSP		0x8
785 #define	IOSTAT_LS_RJT			0x9
786 #define	IOSTAT_RESERVED_A		0xA
787 #define	IOSTAT_CMD_REJECT		0xB
788 #define	IOSTAT_FCP_TGT_LENCHK		0xC
789 #define	IOSTAT_RESERVED_D		0xD
790 #define	IOSTAT_RESERVED_E		0xE
791 #define	IOSTAT_NEED_BUFF_ENTRY		0xF
792 
793 /* Special error codes */
794 #define	IOSTAT_DATA_OVERRUN		0x10	/* Added for resid handling */
795 #define	IOSTAT_DATA_UNDERRUN		0x11	/* Added for resid handling */
796 } emlxs_iocb_t;
797 typedef emlxs_iocb_t IOCB;
798 
799 
800 typedef struct emlxs_iocbq
801 {
802 	emlxs_iocb_t		iocb;
803 	emlxs_wqe_t		wqe; /* SLI4 */
804 
805 	struct emlxs_iocbq	*next;
806 
807 	void			*bp;	/* ptr to data buffer structure */
808 	void			*port;	/* Board info pointer */
809 	void			*channel; /* IO Channel pointer */
810 	void			*node;	/* Node pointer */
811 	void			*sbp;	/* Pkt pointer */
812 	uint32_t		flag;
813 
814 #define	IOCB_POOL_ALLOCATED	0x00000001
815 #define	IOCB_PRIORITY		0x00000002
816 #define	IOCB_SPECIAL		0x00000004
817 #define	IOCB_FCP_CMD		0x00000008
818 #define	IOCB_FCT_DATA		0x00000020	/* tgt-mode */
819 
820 } emlxs_iocbq_t;
821 typedef emlxs_iocbq_t IOCBQ;
822 
823 
824 #ifdef	__cplusplus
825 }
826 #endif
827 
828 #endif	/* _EMLXS_IOCB_H */
829