xref: /titanic_44/usr/src/uts/common/sys/fibre-channel/fca/qlc/ql_iocb.h (revision f885d00f4e3c96a769ce0228a732da31ad9d0b78)
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 /* Copyright 2010 QLogic Corporation */
23 
24 /*
25  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
26  */
27 
28 #ifndef	_QL_IOCB_H
29 #define	_QL_IOCB_H
30 
31 /*
32  * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver header file.
33  *
34  * ***********************************************************************
35  * *									**
36  * *				NOTICE					**
37  * *		COPYRIGHT (C) 1996-2010 QLOGIC CORPORATION		**
38  * *			ALL RIGHTS RESERVED				**
39  * *									**
40  * ***********************************************************************
41  *
42  */
43 
44 #ifdef	__cplusplus
45 extern "C" {
46 #endif
47 
48 #define	INVALID_ENTRY_TYPE	0
49 
50 /*
51  * ISP queue -	32-Bit DMA addressing command with extended LUN support
52  *		entry structure definition.
53  */
54 #define	IOCB_CMD_TYPE_2		0x11	/* Command entry */
55 #define	MAX_CMDSZ		16	/* SCSI maximum CDB size. */
56 #define	CMD_TYPE_2_DATA_SEGMENTS	3	/* Number of data segments. */
57 typedef struct cmd_entry {
58 	uint8_t  entry_type;		/* Entry type. */
59 	uint8_t  entry_count;		/* Entry count. */
60 	uint8_t  sys_define;		/* System defined. */
61 	uint8_t  entry_status;		/* Entry Status. */
62 	uint32_t handle;		/* System handle */
63 	uint8_t  target_l;		/* SCSI ID - LSB */
64 	uint8_t  target_h;		/* SCSI ID - MSB */
65 	uint8_t  lun_l;			/* SCSI LUN - LSB */
66 	uint8_t  lun_h;			/* SCSI LUN - MSB */
67 	uint8_t  control_flags_l;	/* Control flags - LSB. */
68 	uint8_t  control_flags_h;	/* Control flags - MSB. */
69 	uint8_t  reserved_1[2];
70 	uint16_t timeout;		/* Command timeout. */
71 	uint16_t dseg_count;		/* Data segment count - LSB. */
72 	uint8_t  scsi_cdb[MAX_CMDSZ];	/* SCSI command words. */
73 	uint32_t byte_count;		/* Total byte count. */
74 	uint32_t dseg_0_address;	/* Data segment 0 address. */
75 	uint32_t dseg_0_length;		/* Data segment 0 length. */
76 	uint32_t dseg_1_address;	/* Data segment 1 address. */
77 	uint32_t dseg_1_length;		/* Data segment 1 length. */
78 	uint32_t dseg_2_address;	/* Data segment 2 address. */
79 	uint32_t dseg_2_length;		/* Data segment 2 length. */
80 } cmd_entry_t, request_t;
81 
82 /*
83  * Command entry control flags least significant byte.
84  */
85 #define	CF_HTAG		BIT_1
86 #define	CF_OTAG		BIT_2
87 #define	CF_STAG		BIT_3
88 #define	CF_DATA_IN	BIT_5
89 #define	CF_DATA_OUT	BIT_6
90 
91 /*
92  * ISP24xx queue - Command IOCB structure definition.
93  */
94 #define	IOCB_CMD_TYPE_7		0x18
95 #define	CMD_TYPE_7_DATA_SEGMENTS   1	/* Number of 64 bit data segments. */
96 typedef struct cmd7_24xx_entry {
97 	uint8_t  entry_type;		/* Entry type. */
98 	uint8_t  entry_count;		/* Entry count. */
99 	uint8_t  sys_define;		/* System defined. */
100 	uint8_t  entry_status;		/* Entry Status. */
101 	uint32_t handle;		/* System handle */
102 	uint16_t n_port_hdl;
103 	uint16_t timeout;		/* Command timeout. */
104 	uint16_t dseg_count;
105 	uint8_t  reserved_1[2];
106 	uint8_t  fcp_lun[8];		/* SCSI LUN ID. */
107 	uint8_t  control_flags;
108 	uint8_t  task_mgmt;		/* Task management flags. */
109 	uint8_t  task;			/* Task Attributes Values. */
110 	uint8_t  crn;			/* Command reference number. */
111 	uint8_t  scsi_cdb[MAX_CMDSZ];	/* SCSI command bytes. */
112 	uint32_t total_byte_count;
113 	uint8_t  target_id[3];		/* SCSI Target ID */
114 	uint8_t  vp_index;
115 	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
116 	uint32_t dseg_0_length;		/* Data segment 0 length. */
117 } cmd7_24xx_entry_t;
118 
119 /*
120  * ISP24xx queue - Command IOCB structure definition.
121  */
122 #define	IOCB_CMD_TYPE_6		0x48
123 #define	CMD_TYPE_6_DATA_SEGMENTS   1	/* Number of 64 bit data segments. */
124 typedef struct cmd6_24xx_entry {
125 	uint8_t  entry_type;		/* Entry type. */
126 	uint8_t  entry_count;		/* Entry count. */
127 	uint8_t  sys_define;		/* System defined. */
128 	uint8_t  entry_status;		/* Entry Status. */
129 	uint32_t handle;		/* System handle */
130 	uint16_t n_port_hdl;
131 	uint16_t timeout;		/* Command timeout. */
132 	uint16_t dseg_count;
133 	uint16_t rsp_length;
134 	uint8_t  fcp_lun[8];		/* SCSI LUN ID. */
135 	uint16_t control_flags;
136 	uint16_t cmnd_length;
137 	uint32_t cmnd_address[2];
138 	uint32_t rsp_address[2];	/* Data segment 0 address. */
139 	uint32_t total_byte_count;
140 	uint8_t  target_id[3];		/* SCSI Target ID */
141 	uint8_t  vp_index;
142 	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
143 	uint32_t dseg_0_length;		/* Data segment 0 length. */
144 } cmd6_24xx_entry_t;
145 
146 typedef struct fcp_cmnd {
147 	uint8_t		fcp_lun[8];		/* SCSI LUN ID. */
148 	uint8_t		crn;			/* Command reference number. */
149 	uint8_t		task;			/* Task Attributes Values. */
150 	uint8_t		task_mgmt;		/* Task management flags. */
151 	uint8_t		control_flags;		/* Plus additional cdb length */
152 	uint8_t		scsi_cdb[MAX_CMDSZ];
153 	uint32_t	dl;
154 } fcp_cmnd_t;
155 
156 typedef struct cmd6_2400_dma {
157 	fcp_cmnd_t	cmd;
158 	uint32_t	cookie_list[QL_DMA_SG_LIST_LENGTH + 1][3];
159 } cmd6_2400_dma_t;
160 
161 /*
162  * Task Management Flags.
163  */
164 #define	TF_TARGET_RESET		BIT_13
165 #define	TF_LUN_RESET		BIT_12
166 #define	TF_CLEAR_TASK_SET	BIT_10
167 #define	TF_ABORT_TASK_SET	BIT_9
168 
169 /*
170  * Task Attributes Values.
171  */
172 #define	TA_STAG		0
173 #define	TA_HTAG		1
174 #define	TA_OTAG		2
175 #define	TA_ACA		4
176 #define	TA_UNTAGGED	5
177 
178 /*
179  * Control Flags.
180  */
181 #define	CF_DSD_PTR	BIT_2
182 #define	CF_RD		BIT_1
183 #define	CF_WR		BIT_0
184 
185 /*
186  * ISP queue -	64-Bit DMA addressing command with extended LUN support
187  *		entry structure definition.
188  */
189 #define	IOCB_CMD_TYPE_3		0x19	/* Command Type 3 entry (64 bit) */
190 #define	CMD_TYPE_3_DATA_SEGMENTS   2	/* Number of 64 bit data segments. */
191 typedef struct cmd_3_entry {
192 	uint8_t  entry_type;		/* Entry type. */
193 	uint8_t  entry_count;		/* Entry count. */
194 	uint8_t  sys_define;		/* System defined. */
195 	uint8_t  entry_status;		/* Entry Status. */
196 	uint32_t handle;		/* System handle */
197 	uint8_t  target_l;		/* SCSI ID - LSB */
198 	uint8_t  target_h;		/* SCSI ID - MSB */
199 	uint8_t  lun_l;			/* SCSI LUN - LSB */
200 	uint8_t  lun_h;			/* SCSI LUN - MSB */
201 	uint8_t  control_flags_l;	/* Control flags - LSB. */
202 	uint8_t  control_flags_h;	/* Control flags - MSB. */
203 	uint8_t  reserved_1[2];
204 	uint16_t timeout;		/* Command timeout. */
205 	uint16_t dseg_count;		/* Data segment count - LSB. */
206 	uint8_t  scsi_cdb[MAX_CMDSZ];	/* SCSI command words. */
207 	uint32_t byte_count;		/* Total byte count. */
208 	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
209 	uint32_t dseg_0_length;		/* Data segment 0 length. */
210 	uint32_t dseg_1_address[2];	/* Data segment 1 address. */
211 	uint32_t dseg_1_length;		/* Data segment 1 length. */
212 } cmd_3_entry_t;
213 
214 /*
215  * ISP queue -	Command type 4 DSD list pointer structure definition.
216  */
217 #define	COMMAND_CHAINING_TYPE	0x15
218 typedef struct cmd_chaining_entry {
219 	uint8_t  entry_type;		/* Entry type. */
220 	uint8_t  entry_count;		/* Entry count. */
221 	uint8_t  sys_define;		/* System defined. */
222 	uint8_t  entry_status;		/* Entry Status. */
223 	uint32_t handle;		/* System handle */
224 	uint8_t  reserved;
225 	uint8_t  target;		/* SCSI ID */
226 	uint8_t  lun_l;			/* SCSI LUN - LSB */
227 	uint8_t  lun_h;			/* SCSI LUN - MSB */
228 	uint8_t  control_flags_l;	/* Control flags - LSB. */
229 	uint8_t  control_flags_h;	/* Control flags - MSB. */
230 	uint8_t  crn;
231 	uint8_t  vp_index;
232 	uint8_t  timeout_l;		/* Command timeout - LSB. */
233 	uint8_t  timeout_h;		/* Command timeout - MSB. */
234 	uint8_t  dseg_count_l;		/* Data segment count - LSB. */
235 	uint8_t  dseg_count_h;		/* Data segment count - MSB. */
236 	uint8_t  scsi_cdb[MAX_CMDSZ];	/* SCSI command words. */
237 	uint32_t byte_count;		/* Total byte count. */
238 	uint16_t list_type;		/* 0 = 32bit, 1 = 64bit. */
239 	uint16_t base_address[2];
240 	uint16_t list_address[4];
241 	uint8_t reserved_2[10];
242 } cmd_chaining_entry_t;
243 
244 /*
245  * ISP queue - continuation entry structure definition.
246  */
247 #define	CONTINUATION_TYPE_0	0x02	/* Continuation entry. */
248 #define	CONT_TYPE_0_DATA_SEGMENTS  7	/* Number of 32 bit data segments. */
249 typedef struct cont_entry {
250 	uint8_t entry_type;		/* Entry type. */
251 	uint8_t entry_count;		/* Entry count. */
252 	uint8_t sys_define;		/* System defined. */
253 	uint8_t entry_status;		/* Entry Status. */
254 	uint32_t reserved;
255 	uint32_t dseg_0_address;	/* Data segment 0 address. */
256 	uint32_t dseg_0_length;		/* Data segment 0 length. */
257 	uint32_t dseg_1_address;	/* Data segment 1 address. */
258 	uint32_t dseg_1_length;		/* Data segment 1 length. */
259 	uint32_t dseg_2_address;	/* Data segment 2 address. */
260 	uint32_t dseg_2_length;		/* Data segment 2 length. */
261 	uint32_t dseg_3_address;	/* Data segment 3 address. */
262 	uint32_t dseg_3_length;		/* Data segment 3 length. */
263 	uint32_t dseg_4_address;	/* Data segment 4 address. */
264 	uint32_t dseg_4_length;		/* Data segment 4 length. */
265 	uint32_t dseg_5_address;	/* Data segment 5 address. */
266 	uint32_t dseg_5_length;		/* Data segment 5 length. */
267 	uint32_t dseg_6_address;	/* Data segment 6 address. */
268 	uint32_t dseg_6_length;		/* Data segment 6 length. */
269 } cont_entry_t;
270 
271 /*
272  * ISP queue - 64-Bit addressing, continuation entry structure definition.
273  */
274 #define	CONTINUATION_TYPE_1	0x0A	/* Continuation Type 1 entry. */
275 #define	CONT_TYPE_1_DATA_SEGMENTS  5	/* Number of 64 bit data segments. */
276 typedef struct cont_type_1_entry {
277 	uint8_t entry_type;		/* Entry type. */
278 	uint8_t entry_count;		/* Entry count. */
279 	uint8_t sys_define;		/* System defined. */
280 	uint8_t entry_status;		/* Entry Status. */
281 	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
282 	uint32_t dseg_0_length;		/* Data segment 0 length. */
283 	uint32_t dseg_1_address[2];	/* Data segment 1 address. */
284 	uint32_t dseg_1_length;		/* Data segment 1 length. */
285 	uint32_t dseg_2_address[2];	/* Data segment 2 address. */
286 	uint32_t dseg_2_length;		/* Data segment 2 length. */
287 	uint32_t dseg_3_address[2];	/* Data segment 3 address. */
288 	uint32_t dseg_3_length;		/* Data segment 3 length. */
289 	uint32_t dseg_4_address[2];	/* Data segment 4 address. */
290 	uint32_t dseg_4_length;		/* Data segment 4 length. */
291 } cont_type_1_entry_t;
292 
293 /*
294  * ISP queue - status entry structure definition.
295  */
296 #define	STATUS_TYPE	0x03		/* Status entry. */
297 typedef struct sts_entry {
298 	uint8_t  entry_type;		/* Entry type. */
299 	uint8_t  entry_count;		/* Entry count. */
300 	uint8_t  sys_define;		/* System defined. */
301 	uint8_t  entry_status;		/* Entry Status. */
302 	uint32_t handle;		/* System handle. */
303 	uint8_t  scsi_status_l;		/* SCSI status - LSB. */
304 	uint8_t  scsi_status_h;		/* SCSI status - MSB. */
305 	uint16_t comp_status;		/* Completion status. */
306 	uint8_t  state_flags_l;		/* State flags - LSB. */
307 	uint8_t  state_flags_h;		/* State flags. */
308 	uint8_t  status_flags_l;	/* Status flags. */
309 	uint8_t  status_flags_h;	/* Status flags - MSB. */
310 	uint16_t rsp_info_length;	/* Response Info Length. */
311 	uint16_t req_sense_length;	/* Request sense data length. */
312 	uint32_t residual_length;	/* Residual transfer length. */
313 	uint8_t  rsp_info[8];		/* FCP response information. */
314 	uint8_t  req_sense_data[32];	/* Request sense data. */
315 } sts_entry_t, response_t;
316 
317 /*
318  * Status entry entry status
319  */
320 #define	RF_INV_E_ORDER	BIT_5		/* Invalid entry order. */
321 #define	RF_INV_E_COUNT  BIT_4		/* Invalid entry count. */
322 #define	RF_INV_E_PARAM  BIT_3		/* Invalid entry parameter. */
323 #define	RF_INV_E_TYPE   BIT_2		/* Invalid entry type. */
324 #define	RF_BUSY		BIT_1		/* Busy */
325 
326 /*
327  * Status entry SCSI status most significant byte.
328  */
329 #define	FCP_CONF_REQ		BIT_4
330 #define	FCP_RESID_UNDER		BIT_3
331 #define	FCP_RESID_OVER		BIT_2
332 #define	FCP_SNS_LEN_VALID	BIT_1
333 #define	FCP_RSP_LEN_VALID	BIT_0
334 #define	FCP_RSP_MASK		(FCP_RESID_UNDER | FCP_RESID_OVER | \
335 				FCP_RSP_LEN_VALID)
336 
337 /*
338  * Status entry state flag most significant byte.
339  * Not used in by ISP24xx
340  */
341 #define	SF_ARQ_DONE		BIT_5
342 #define	SF_GOT_STATUS		BIT_4
343 #define	SF_XFERRED_DATA		BIT_3
344 #define	SF_SENT_CMD		BIT_2
345 #define	SF_GOT_TARGET		BIT_1
346 #define	SF_GOT_BUS		BIT_0
347 
348 /*
349  * Status entry state flag least significant byte.
350  * Not used in by ISP24xx
351  */
352 #define	SF_NO_FAST_POST		BIT_7
353 #define	SF_DATA_OUT		BIT_6
354 #define	SF_DATA_IN		BIT_5
355 
356 #define	SF_SIMPLE_Q		BIT_3
357 #define	SF_ORDERED_Q		BIT_2
358 #define	SF_HEAD_OF_Q		BIT_1
359 #define	SF_ACA_Q		BIT_0
360 
361 /*
362  * Status entry completion status definitions.
363  */
364 #define	CS_COMPLETE		0x0	/* No errors */
365 #define	CS_INCOMPLETE		0x1	/* Incomplete transfer of cmd. */
366 #define	CS_DMA_ERROR		0x2	/* A DMA direction error. */
367 #define	CS_PORT_ID_CHANGE	0x2	/* The port ID has changed. */
368 #define	CS_TRANSPORT		0x3	/* Transport error. */
369 #define	CS_RESET		0x4	/* SCSI bus reset occurred */
370 #define	CS_ABORTED		0x5	/* System aborted command. */
371 #define	CS_TIMEOUT		0x6	/* Timeout error. */
372 #define	CS_DATA_OVERRUN		0x7	/* Data overrun. */
373 #define	CS_INVALID_RX_ID	0x8	/* Invalid RX_ID. */
374 #define	CS_DATA_REASSEM_ERROR	0x11	/* Data reassembly error. */
375 #define	CS_ABTS_REC		0x13	/* ABTS from target. */
376 #define	CS_DATA_UNDERRUN	0x15	/* Data Underrun. */
377 #define	CS_QUEUE_FULL		0x1C	/* Queue Full. */
378 #define	CS_PORT_UNAVAILABLE	0x28	/* Port unavailable */
379 					/* (selection timeout) */
380 #define	CS_PORT_LOGGED_OUT	0x29	/* Port Logged Out */
381 #define	CS_PORT_CONFIG_CHG	0x2A	/* Port Configuration Changed */
382 #define	CS_PORT_BUSY		0x2B	/* Port Busy */
383 #define	CS_RESOUCE_UNAVAILABLE	0x2C	/* Frimware resource unavailable. */
384 #define	CS_TASK_MGMT_OVERRUN	0x30	/* Task management overrun. */
385 #define	CS_LOGIN_LOGOUT_ERROR	0x31	/* login/logout IOCB error. */
386 #define	CS_SEQ_COMPLETE		0x40	/* Sequence Complete. */
387 #define	CS_ABORTED_SEQ_REC	0x47	/* Abort sequence was received. */
388 #define	CS_INVALID_PARAMETER	0x102	/* IP invalid_parameter. */
389 #define	CS_ERROR_RESOURCE	0x103	/* IP insufficient resources. */
390 #define	CS_IP_NOT_INITIALIZED	0x104	/* IP not_initialized. */
391 
392 #define	CS_BAD_PAYLOAD		0x180	/* Driver defined */
393 #define	CS_UNKNOWN		0x181	/* Driver defined */
394 #define	CS_CMD_FAILED		0x182	/* Driver defined */
395 #define	CS_LOOP_DOWN_ABORT	0x183	/* Driver defined */
396 #define	CS_FCP_RESPONSE_ERROR	0x184	/* Driver defined */
397 #define	CS_DEVICE_UNAVAILABLE	0x185	/* Driver defined */
398 /*
399  * ISP24xx queue - Status IOCB structure definition.
400  */
401 typedef struct sts_24xx_entry {
402 	uint8_t  entry_type;		/* Entry type. */
403 	uint8_t  entry_count;		/* Entry count. */
404 	uint8_t  sys_define;		/* System defined. */
405 	uint8_t  entry_status;		/* Entry Status. */
406 	uint32_t handle;		/* System handle. */
407 	uint16_t comp_status;		/* Completion status. */
408 	uint16_t ox_id;
409 	uint32_t residual_length;	/* Residual transfer length. */
410 	uint16_t reserved;
411 	uint8_t	 state_flags_l;		/* State flags. */
412 	uint8_t	 state_flags_h;
413 	uint16_t reserved_1;
414 	uint8_t  scsi_status_l;		/* SCSI status - LSB. */
415 	uint8_t  scsi_status_h;		/* SCSI status - MSB. */
416 	uint32_t fcp_rsp_residual_count;
417 	uint32_t fcp_sense_length;
418 	uint32_t fcp_rsp_data_length;	/* Response Info Length. */
419 	uint8_t  rsp_sense_data[28];	/* FCP response and/or sense data. */
420 } sts_24xx_entry_t;
421 
422 /*
423  * ISP queue - status continuation entry structure definition.
424  */
425 #define	STATUS_CONT_TYPE	0x10	/* Status continuation entry. */
426 typedef struct sts_cont_entry {
427 	uint8_t  entry_type;		/* Entry type. */
428 	uint8_t  entry_count;		/* Entry count. */
429 	uint8_t  sys_define;		/* System defined. */
430 	uint8_t  entry_status;		/* Entry Status. */
431 	uint8_t  req_sense_data[60];	/* Request sense data. */
432 } sts_cont_entry_t;
433 
434 /*
435  * ISP queue -	marker with extended LUN support
436  *		entry structure definition.
437  */
438 #define	MARKER_TYPE	0x04		/* Marker entry. */
439 typedef struct mrk_entry {
440 	uint8_t  entry_type;		/* Entry type. */
441 	uint8_t  entry_count;		/* Entry count. */
442 	uint8_t  sys_define;		/* System defined. */
443 	uint8_t  entry_status;		/* Entry Status. */
444 	uint32_t sys_define_2;		/* System defined. */
445 	uint8_t  target_l;		/* SCSI ID - LSB */
446 	uint8_t  target_h;		/* SCSI ID - MSB */
447 	uint8_t  modifier;		/* Modifier (7-0). */
448 	uint8_t  reserved_1;
449 	uint8_t  sequence_number[2];	/* Sequence number of event. */
450 	uint8_t  lun_l;			/* SCSI LUN - LSB */
451 	uint8_t  lun_h;			/* SCSI LUN - MSB */
452 	uint8_t  reserved_2[48];
453 } mrk_entry_t;
454 
455 /*
456  * Marker modifiers
457  */
458 #define	MK_SYNC_ID_LUN	0		/* Synchronize ID/LUN */
459 #define	MK_SYNC_ID	1		/* Synchronize ID */
460 #define	MK_SYNC_ALL	2		/* Synchronize all ID/LUN */
461 #define	MK_SYNC_LIP	3		/* Synchronize all ID/LUN, */
462 					/* clear port changed, */
463 					/* use sequence number. */
464 /*
465  * ISP24xx queue - Marker IOCB structure definition.
466  */
467 typedef struct marker_24xx_entry {
468 	uint8_t  entry_type;		/* Entry type. */
469 	uint8_t  entry_count;		/* Entry count. */
470 	uint8_t  sys_define;		/* System defined. */
471 	uint8_t  entry_status;		/* Entry Status. */
472 	uint32_t handle;		/* System handle */
473 	uint16_t n_port_hdl;
474 	uint8_t  modifier;		/* Modifier */
475 	uint8_t  reserved[2];
476 	uint8_t  vp_index;
477 	uint8_t  reserved_1[2];
478 	uint8_t  fcp_lun[8];		/* SCSI LUN ID. */
479 	uint8_t  reserved_2[40];
480 } marker_24xx_entry_t;
481 
482 /*
483  * ISP queue -	Management Server entry structure definition.
484  */
485 #define	MS_TYPE			0x29
486 #define	MS_DATA_SEGMENTS	1	/* Number of data segments. */
487 typedef struct ms_entry {
488 	uint8_t  entry_type;		/* Entry type. */
489 	uint8_t  entry_count;		/* Entry count. */
490 	uint8_t  sys_define;		/* System defined. */
491 	uint8_t  entry_status;		/* Entry Status. */
492 	uint32_t handle;		/* System handle */
493 	uint8_t  loop_id_l;		/* device id - LSB */
494 	uint8_t  loop_id_h;		/* device id - MSB */
495 	uint16_t comp_status;		/* Completion status */
496 	uint8_t  control_flags_l;	/* Control flags - LSB. */
497 	uint8_t  control_flags_h;	/* Control flags - MSB. */
498 	uint8_t  reserved_1[2];
499 	uint16_t timeout;		/* Command timeout. */
500 	uint8_t  cmd_dseg_count_l;	/* CMD segment count - LSB. */
501 	uint8_t  cmd_dseg_count_h;	/* CMD segment count - MSB. */
502 	uint16_t total_dseg_count;	/* CMD + RESP segment count. */
503 	uint8_t	 reserved_2[10];
504 	uint32_t resp_byte_count;	/* Response byte count */
505 	uint32_t cmd_byte_count;	/* Command byte count */
506 	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
507 	uint32_t dseg_0_length;		/* Data segment 0 length. */
508 	uint32_t dseg_1_address[2];	/* Data segment 1 address. */
509 	uint32_t dseg_1_length;		/* Data segment 1 length. */
510 } ms_entry_t;
511 
512 /*
513  * ISP24xx queue - CT Pass-Through IOCB structure definition.
514  */
515 #define	CT_PASSTHRU_TYPE		0x29
516 #define	CT_PASSTHRU_DATA_SEGMENTS	1	/* Number of data segments. */
517 typedef struct ct_passthru_entry {
518 	uint8_t  entry_type;		/* Entry type. */
519 	uint8_t  entry_count;		/* Entry count. */
520 	uint8_t  sys_define;		/* System defined. */
521 	uint8_t  entry_status;		/* Entry Status. */
522 	uint32_t handle;		/* System handle */
523 	uint16_t status;
524 	uint16_t n_port_hdl;
525 	uint16_t cmd_dseg_count;
526 	uint8_t  vp_index;
527 	uint8_t  reserved;
528 	uint16_t timeout;
529 	uint16_t reserved_1;
530 	uint16_t resp_dseg_count;
531 	uint8_t  reserved_2[10];
532 	uint32_t resp_byte_count;
533 	uint32_t cmd_byte_count;
534 	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
535 	uint32_t dseg_0_length;		/* Data segment 0 length. */
536 	uint32_t dseg_1_address[2];	/* Data segment 1 address. */
537 	uint32_t dseg_1_length;		/* Data segment 1 length. */
538 } ct_passthru_entry_t;
539 
540 /*
541  * ISP24xx queue - ELS Pass-Through IOCB structure definition.
542  */
543 #define	ELS_PASSTHRU_TYPE		0x53
544 typedef struct els_passthru_entry {
545 	uint8_t  entry_type;		/* Entry type. */
546 	uint8_t  entry_count;		/* Entry count. */
547 	uint8_t  sys_define;		/* System defined. */
548 	uint8_t  entry_status;		/* Entry Status. */
549 	uint32_t handle;		/* System handle */
550 	uint16_t reserved_8_9;
551 	uint16_t n_port_hdl;
552 	uint16_t xmt_dseg_count;	/* Only one allowed */
553 	uint8_t  vp_index;
554 	uint8_t  sof_type;
555 	uint32_t rcv_exch_address;
556 	uint16_t rcv_dseg_count;
557 	uint8_t  els_cmd_opcode;
558 	uint8_t  reserved_17;
559 	uint8_t  d_id_7_0;
560 	uint8_t  d_id_15_8;
561 	uint8_t  d_id_23_16;
562 	uint8_t  s_id_23_16;
563 	uint8_t  s_id_7_0;
564 	uint8_t  s_id_15_8;
565 	uint16_t control_flags;
566 	uint32_t rcv_payld_data_bcnt;
567 	uint32_t xmt_payld_data_bcnt;
568 	uint32_t xmt_dseg_0_address[2];	/* Tx Data segment 0 address. */
569 	uint32_t xmt_dseg_0_length;	/* Tx Data segment 0 length.  */
570 	uint32_t rcv_dseg_0_address[2];	/* Rx Data segment 0 address. */
571 	uint32_t rcv_dseg_0_length;	/* Rx Data segment 0 length.  */
572 } els_passthru_entry_t;
573 
574 /*
575  * ISP24x queue - ELS Pass-Through IOCB response.
576  */
577 typedef struct els_passthru_entry_rsp {
578 	uint8_t  entry_type;		/* Entry type. */
579 	uint8_t  entry_count;		/* Entry count. */
580 	uint8_t  sys_define;		/* System defined. */
581 	uint8_t  entry_status;		/* Entry Status. */
582 	uint32_t handle;		/* System handle */
583 	uint16_t comp_status;
584 	uint16_t n_port_hdl;
585 	uint16_t reserved_c_d;
586 	uint8_t  vp_index;
587 	uint8_t  sof_type;
588 	uint32_t rcv_exch_addr;
589 	uint16_t reserved_14_15;
590 	uint8_t  els_cmd_opcode;
591 	uint8_t  reserved_17;
592 	uint8_t  d_id_7_0;
593 	uint8_t  d_id_15_8;
594 	uint8_t  d_id_23_16;
595 	uint8_t  s_id_23_16;
596 	uint8_t  s_id_7_0;
597 	uint8_t  s_id_15_8;
598 	uint16_t control_flags;
599 	uint32_t total_data_bcnt;
600 	uint32_t error_subcode1;
601 	uint32_t error_subcode2;
602 	uint8_t  reserved_2c_3f[20];
603 } els_passthru_entry_rsp_t;
604 
605 /*
606  * ISP24xx queue - Task Management IOCB structure definition.
607  */
608 #define	TASK_MGMT_TYPE		0x14
609 typedef struct task_mgmt_entry {
610 	uint8_t  entry_type;		/* Entry type. */
611 	uint8_t  entry_count;		/* Entry count. */
612 	uint8_t  sys_define;		/* System defined. */
613 	uint8_t  entry_status;		/* Entry Status. */
614 	uint32_t handle;		/* System handle */
615 	uint16_t n_port_hdl;
616 	uint16_t reserved;
617 	uint16_t delay;
618 	uint16_t timeout;
619 	uint8_t  fcp_lun[8];		/* SCSI LUN ID. */
620 	uint32_t control_flags;
621 	uint8_t  reserved_1[20];
622 	uint8_t  target_id[3];		/* SCSI Target ID */
623 	uint8_t  vp_index;
624 	uint8_t  reserved_2[12];
625 } task_mgmt_entry_t;
626 
627 /*
628  * Control Flags.
629  */
630 #define	CF_DO_NOT_SEND		BIT_31
631 #define	CF_LUN_RESET		BIT_4
632 #define	CF_ABORT_TASK_SET	BIT_3
633 #define	CF_CLEAR_TASK_SET	BIT_2
634 #define	CF_TARGET_RESET		BIT_1
635 #define	CF_CLEAR_ACA		BIT_0
636 
637 /*
638  * ISP24xx queue - Abort I/O IOCB structure definition.
639  */
640 #define	ABORT_CMD_TYPE		0x33
641 typedef struct abort_cmd_entry {
642 	uint8_t  entry_type;		/* Entry type. */
643 	uint8_t  entry_count;		/* Entry count. */
644 	uint8_t  sys_define;		/* System defined. */
645 	uint8_t  entry_status;		/* Entry Status. */
646 	uint32_t handle;		/* System handle */
647 	uint16_t n_port_hdl;		/* also comp_status */
648 	uint8_t  options;
649 	uint8_t  options_h;
650 	uint32_t cmd_handle;
651 	uint8_t  reserved[32];
652 	uint8_t  target_id[3];		/* Port ID */
653 	uint8_t  vp_index;
654 	uint8_t  reserved_1[12];
655 } abort_cmd_entry_t;
656 
657 /*
658  * Option Flags.
659  */
660 #define	AF_NO_ABTS		BIT_0
661 
662 /*
663  * ISP24xx queue - Login/Logout Port IOCB structure definition.
664  */
665 #define	LOG_TYPE		0x52
666 typedef struct log_entry {
667 	uint8_t  entry_type;		/* Entry type. */
668 	uint8_t  entry_count;		/* Entry count. */
669 	uint8_t  sys_define;		/* System defined. */
670 	uint8_t  entry_status;		/* Entry Status. */
671 	uint32_t handle;		/* System handle */
672 	uint16_t status;
673 	uint16_t n_port_hdl;
674 	uint16_t control_flags;
675 	uint8_t  vp_index;
676 	uint8_t  reserved;
677 	uint8_t  port_id[3];
678 	uint8_t  rsp_size;
679 	uint32_t io_param[11];
680 } log_entry_t;
681 
682 /*
683  * ISP24xx control flag commands
684  */
685 #define	CF_CMD_PLOGI	0x00
686 #define	CF_CMD_PRLI	0x01
687 #define	CF_CMD_PDISC	0x02
688 #define	CF_CMD_ADISC	0x03
689 #define	CF_CMD_LOGO	0x08
690 #define	CF_CMD_PRLO	0x09
691 #define	CF_CMD_TPRLO	0x0A
692 
693 /*
694  * ISP24xx control flag command options
695  */
696 #define	CFO_COND_PLOGI		BIT_4
697 #define	CFO_SKIP_PRLI		BIT_5
698 #define	CFO_COMMON_FEATURES	BIT_7
699 #define	CFO_CLASS_2		BIT_8
700 #define	CFO_FCP_2_OVR		BIT_9
701 
702 #define	CFO_IMPLICIT_LOGO	BIT_4
703 #define	CFO_IMPLICIT_LOGO_ALL	BIT_5
704 #define	CFO_EXPLICIT_LOGO	BIT_6
705 #define	CFO_FREE_N_PORT_HANDLE	BIT_7
706 
707 #define	CFO_IMPLICIT_PRLO	BIT_4
708 
709 /*
710  * ISP24xx Login/Logout Status Sub Codes in in I/O Parameter 0 field.
711  */
712 #define	CS0_NO_LINK			0x01
713 #define	CS0_NO_IOCB			0x02
714 #define	CS0_NO_EXCH_CTRL_BLK		0x03
715 #define	CS0_COMMAND_FAILED		0x04
716 #define	CS0_NO_FABRIC_PRESENT		0x05
717 #define	CS0_FIRMWARE_NOT_READY		0x07
718 #define	CS0_PORT_NOT_LOGGED_IN		0x09
719 #define	CS0_NO_PCB_ALLOCATED		0x0A
720 #define	CS0_ELS_REJECT_RECEIVED		0x18
721 #define	CS0_CMD_PARAMETER_ERROR		0x19
722 #define	CS0_PORT_ID_USED		0x1A
723 #define	CS0_N_PORT_HANDLE_USED		0x1B
724 #define	CS0_NO_N_PORT_HANDLE_AVAILABLE	0x1C
725 #define	CS0_NO_FLOGI_ACC		0x1F
726 
727 /*
728  * ISP24xx Login/Logout Status Sub Codes in in I/O Parameter 1 field.
729  */
730 #define	CS1_PLOGI_FAILED		0x02
731 #define	CS1_PLOGI_RESPONSE_FAILED	0x03
732 #define	CS1_PRLI_FAILED			0x04
733 #define	CS1_PRLI_RESPONSE_FAILED	0x05
734 #define	CS1_COMMAND_LOGGED_OUT		0x07
735 
736 /*
737  * ISP queue -	Enable LUN with extended LUN support
738  *		entry structure definition.
739  */
740 #define	ENABLE_LUN_TYPE	0xB		/* Enable LUN entry */
741 typedef struct enable_lun_entry {
742 	uint8_t  entry_type;		/* Entry type. */
743 	uint8_t  entry_count;		/* Entry count. */
744 	uint8_t  sys_define;		/* System defined. */
745 	uint8_t  entry_status;		/* Entry Status. */
746 	uint32_t handle;		/* System handle */
747 	uint8_t  reserved[8];
748 	uint8_t  status;
749 	uint8_t  reserved_1;
750 	uint8_t  command_count;
751 	uint8_t  immediate_notify_count;
752 	uint8_t  reserved_2[2];
753 	uint8_t  timeout_l;		/* Timeout - LSB. */
754 	uint8_t  timeout_h;		/* Timeout - MSB. */
755 	uint8_t  reserved_3[40];
756 } enable_lun_entry_t;
757 
758 /*
759  * ISP queue -	Modify LUN with extended LUN support
760  *		entry structure definition.
761  */
762 #define	MODIFY_LUN_TYPE	0xC		/* Modify LUN entry */
763 typedef struct modify_lun_entry {
764 	uint8_t  entry_type;		/* Entry type. */
765 	uint8_t  entry_count;		/* Entry count. */
766 	uint8_t  sys_define;		/* System defined. */
767 	uint8_t  entry_status;		/* Entry Status. */
768 	uint32_t handle;		/* System handle */
769 	uint8_t  reserved[2];
770 	uint8_t  operators;
771 	uint8_t  reserved_1[5];
772 	uint8_t  status;
773 	uint8_t  reserved_2;
774 	uint8_t  command_count;
775 	uint8_t  immediate_notify_count;
776 	uint8_t  reserved_3[2];
777 	uint8_t  timeout_l;		/* Timeout - LSB. */
778 	uint8_t  timeout_h;		/* Timeout - MSB. */
779 	uint8_t  reserved_4[40];
780 } modify_lun_entry_t;
781 
782 /*
783  * ISP queue -	Immediate Notify with extended LUN support
784  *		entry structure definition.
785  */
786 #define	IMMEDIATE_NOTIFY_TYPE	0xD	/* Immediate notify entry */
787 typedef struct immediate_notify_entry {
788 	uint8_t  entry_type;		/* Entry type. */
789 	uint8_t  entry_count;		/* Entry count. */
790 	uint8_t  sys_define;		/* System defined. */
791 	uint8_t  entry_status;		/* Entry Status. */
792 	uint32_t handle;		/* System handle */
793 	uint8_t  initiator_id_l;
794 	uint8_t  initiator_id_h;
795 	uint8_t  lun_l;
796 	uint8_t  lun_h;
797 	uint8_t  reserved_1[4];
798 	uint16_t status;
799 	uint8_t  task_flags_l;
800 	uint8_t  task_flags_h;
801 	uint16_t sequence_id;
802 	uint8_t  reserved_3[40];
803 	uint16_t ox_id;
804 } immediate_notify_entry_t;
805 
806 /*
807  * ISP24xx queue - Immediate Notify IOCB structure definition.
808  */
809 typedef struct immd_notify_24xx_entry {
810 	uint8_t  entry_type;		/* Entry type. */
811 	uint8_t  entry_count;		/* Entry count. */
812 	uint8_t  sys_define;		/* System defined. */
813 	uint8_t  entry_status;		/* Entry Status. */
814 	uint32_t reserved;
815 	uint16_t n_port_hdl;
816 	uint16_t reserved_1;
817 	uint16_t flags;
818 	uint16_t srr_rx_id;
819 	uint16_t status;
820 	uint8_t  status_subcode;
821 	uint8_t  reserved_2;
822 	uint32_t receive_exchange_address;
823 	uint32_t srr_relative_offset;
824 	uint16_t srr_iu;
825 	uint16_t srr_ox_id;
826 	uint8_t  reserved_3[19];
827 	uint8_t  vp_index;
828 	uint8_t  reserved_4[10];
829 	uint16_t ox_id;
830 } immd_notify_24xx_entry_t;
831 
832 /*
833  * ISP queue -	Notify Acknowledge extended LUN support
834  *		entry structure definition.
835  */
836 #define	NOTIFY_ACKNOWLEDGE_TYPE	0xE	/* Immediate notify entry */
837 typedef struct notify_acknowledge_entry {
838 	uint8_t  entry_type;		/* Entry type. */
839 	uint8_t  entry_count;		/* Entry count. */
840 	uint8_t  sys_define;		/* System defined. */
841 	uint8_t  entry_status;		/* Entry Status. */
842 	uint32_t handle;		/* System handle */
843 	uint8_t  initiator_id_l;
844 	uint8_t  initiator_id_h;
845 	uint8_t  reserved_1[2];
846 	uint8_t  flags_l;
847 	uint8_t  flags_h;
848 	uint8_t  reserved_2[2];
849 	uint16_t status;
850 	uint8_t  task_flags_l;
851 	uint8_t  task_flags_h;
852 	uint16_t sequence_id;
853 	uint8_t  reserved_3[42];
854 } notify_acknowledge_entry_t;
855 
856 /*
857  * ISP24xx queue - Notify Acknowledge IOCB structure definition.
858  */
859 typedef struct notify_ack_24xx_entry {
860 	uint8_t  entry_type;		/* Entry type. */
861 	uint8_t  entry_count;		/* Entry count. */
862 	uint8_t  sys_define;		/* System defined. */
863 	uint8_t  entry_status;		/* Entry Status. */
864 	uint32_t handle;
865 	uint16_t n_port_hdl;
866 	uint16_t reserved_1;
867 	uint16_t flags;
868 	uint16_t srr_rx_id;
869 	uint16_t status;
870 	uint8_t  status_subcode;
871 	uint8_t  reserved_2;
872 	uint32_t receive_exchange_address;
873 	uint32_t srr_relative_offset;
874 	uint16_t srr_iu;
875 	uint16_t srr_flags;
876 	uint8_t  reserved_3[19];
877 	uint8_t  vp_index;
878 	uint8_t  srr_reject_vendor_unique;
879 	uint8_t  srr_reject_code_explanation;
880 	uint8_t  srr_reject_code;
881 	uint8_t  reserved_4[7];
882 	uint16_t ox_id;
883 } notify_ack_24xx_entry_t;
884 
885 /*
886  * ISP queue -	Accept Target I/O with extended LUN support
887  *		entry structure definition.
888  */
889 #define	ATIO_TYPE	0x16			/* ATIO entry */
890 typedef struct atio_entry {
891 	uint8_t		entry_type;		/* Entry type. */
892 	uint8_t		entry_count;		/* Entry count. */
893 	uint8_t		sys_define;		/* System defined. */
894 	uint8_t		entry_status;		/* Entry Status. */
895 	uint32_t	handle;			/* System handle */
896 	uint8_t		initiator_id_l;
897 	uint8_t		initiator_id_h;
898 	uint16_t	rx_id;
899 	uint8_t		flags_l;
900 	uint8_t		flags_h;
901 	uint16_t	status;
902 	uint8_t		reserved_1;
903 	uint8_t		task_codes : 3,
904 			reserved_2 : 5;
905 	uint8_t		task_flags;
906 	uint8_t		execution_codes;
907 	uint8_t		cdb[MAX_CMDSZ];
908 	uint32_t	data_length;
909 	uint8_t		lun_l;
910 	uint8_t		lun_h;
911 	uint8_t		reserved_3[20];
912 	uint16_t	ox_id;
913 } atio_entry_t;
914 
915 /*
916  * ISP24xx queue - Accept Target I/O IOCB structure definition.
917  */
918 #define	ATIO_24xx_TYPE		0x06
919 typedef struct atio_24xx_entry {
920 	uint8_t  entry_type;		/* Entry type. */
921 	uint8_t  entry_count;		/* Entry count. */
922 	uint16_t len_attr;		/* System defined. */
923 	uint32_t receive_exchange_address;
924 	uint8_t  frame_hdr[24];
925 	uint8_t  payload[32];
926 } atio_24xx_entry_t;
927 
928 /*
929  * ISP queue -	Continue Target I/O with extended LUN support
930  *		entry structure definition.
931  */
932 #define	CTIO_TYPE_2   0x17
933 #define	CTIO_TYPE_3   0x1F
934 typedef struct ctio_entry {
935 	uint8_t  entry_type;		/* Entry type. */
936 	uint8_t  entry_count;		/* Entry count. */
937 	uint8_t  sys_define;		/* System defined. */
938 	uint8_t  entry_status;		/* Entry Status. */
939 	uint32_t handle;		/* System handle */
940 	uint8_t  initiator_id_l;
941 	uint8_t  initiator_id_h;
942 	uint16_t rx_id;
943 	uint8_t  flags_l;
944 	uint8_t  flags_h;
945 	uint16_t status;
946 	uint16_t timeout;
947 	uint8_t  dseg_count_l;
948 	uint8_t  dseg_count_h;
949 	uint32_t relative_offset;
950 	uint32_t residual_transfer_length;
951 	uint8_t  reserved_1[4];
952 
953 	union {
954 		struct {
955 			uint8_t  reserved_2[2];
956 			uint8_t  scsi_status_l;
957 			uint8_t  scsi_status_h;
958 			uint32_t byte_count;
959 			uint32_t dseg_0_address;
960 			uint32_t dseg_0_length;
961 			uint32_t dseg_1_address;
962 			uint32_t dseg_1_length;
963 			uint32_t dseg_2_address;
964 			uint32_t dseg_2_length;
965 		}s0_32bit;
966 
967 		struct {
968 			uint8_t  reserved_3[2];
969 			uint8_t  scsi_status_l;
970 			uint8_t  scsi_status_h;
971 			uint32_t byte_count;
972 			uint32_t dseg_0_address[2];
973 			uint32_t dseg_0_length;
974 			uint32_t dseg_1_address[2];
975 			uint32_t dseg_1_length;
976 		}s0_64bit;
977 
978 		struct {
979 			uint8_t  sense_length_l;
980 			uint8_t  sense_length_h;
981 			uint8_t  scsi_status_l;
982 			uint8_t  scsi_status_h;
983 			uint8_t  response_length_l;
984 			uint8_t  response_length_h;
985 			uint8_t  response_info[26];
986 		}s1;
987 
988 		struct {
989 			uint8_t  reserved_4[2];
990 			uint32_t response_length;
991 			uint32_t response_pointer;
992 			uint8_t  reserved[16];
993 		}s2;
994 	}type;
995 } ctio_entry_t;
996 
997 /*
998  * ISP24xx queue -	Continue Target I/O IOCBs from the System
999  *		Target Driver structure definition.
1000  */
1001 #define	CTIO_24xx_TYPE		0x12
1002 typedef struct ctio_snd_entry {
1003 	uint8_t  entry_type;		/* Entry type. */
1004 	uint8_t  entry_count;		/* Entry count. */
1005 	uint8_t  sys_define;		/* System defined. */
1006 	uint8_t  entry_status;		/* Entry Status. */
1007 	uint32_t handle;
1008 	uint16_t n_port_hdl;
1009 	uint16_t timeout;
1010 	uint16_t dseg_count;
1011 	uint8_t  vp_index;
1012 	uint8_t  flags;
1013 	uint8_t initiator_id[3];
1014 	uint8_t  reserved_1;
1015 	uint32_t receive_exchange_address;
1016 
1017 	union {
1018 		struct {
1019 			uint16_t reserved_2;
1020 			uint16_t flags;
1021 			uint32_t residual_length;
1022 			uint16_t ox_id;
1023 			uint16_t scsi_status;
1024 			uint32_t relative_offset;
1025 			uint32_t reserved_3;
1026 			uint32_t transfer_length;
1027 			uint32_t reserved_4;
1028 			uint32_t dseg_0_address_l;
1029 			uint32_t dseg_0_address_h;
1030 			uint32_t dseg_0_length;
1031 		}s0;
1032 
1033 		struct {
1034 			uint16_t sense_length;
1035 			uint16_t flags;
1036 			uint32_t residual_length;
1037 			uint16_t ox_id;
1038 			uint16_t scsi_status;
1039 			uint16_t response_length;
1040 			uint16_t reserved_2;
1041 			uint8_t  rsp_sense_data[24];
1042 		}s1;
1043 
1044 		struct {
1045 			uint16_t reserved_2;
1046 			uint16_t flags;
1047 			uint32_t residual_length;
1048 			uint16_t ox_id;
1049 			uint8_t  reserved_3[10];
1050 			uint32_t transfer_length;
1051 			uint32_t reserved_4;
1052 			uint32_t dseg_0_address_l;
1053 			uint32_t dseg_0_address_h;
1054 			uint32_t dseg_0_length;
1055 		}s2;
1056 	}type;
1057 } ctio_snd_entry_t;
1058 
1059 /*
1060  * ISP24xx queue -	Continue Target I/O IOCBs from the ISP24xx
1061  *		Firmware structure definition.
1062  */
1063 typedef struct ctio_rcv_entry {
1064 	uint8_t  entry_type;		/* Entry type. */
1065 	uint8_t  entry_count;		/* Entry count. */
1066 	uint8_t  sys_define;		/* System defined. */
1067 	uint8_t  entry_status;		/* Entry Status. */
1068 	uint32_t handle;
1069 	uint16_t status;
1070 	uint16_t timeout;
1071 	uint16_t dseg_count;
1072 	uint8_t  reserved[6];
1073 
1074 	uint8_t  vp_index;
1075 	uint8_t  flags;
1076 	uint8_t initiator_id[3];
1077 	uint8_t  reserved_1;
1078 	uint32_t receive_exchange_address;
1079 
1080 	union {
1081 		struct {
1082 			uint16_t reserved_2;
1083 			uint16_t flags;
1084 			uint32_t residual_length;
1085 			uint16_t ox_id;
1086 			uint16_t scsi_status;
1087 			uint32_t relative_offset;
1088 			uint32_t reserved_3;
1089 			uint32_t transfer_length;
1090 			uint32_t reserved_4;
1091 			uint32_t dseg_0_address_l;
1092 			uint32_t dseg_0_address_h;
1093 			uint32_t dseg_0_length;
1094 		}s0;
1095 
1096 		struct {
1097 			uint16_t sense_length;
1098 			uint16_t flags;
1099 			uint32_t residual_length;
1100 			uint16_t ox_id;
1101 			uint16_t scsi_status;
1102 			uint16_t response_length;
1103 			uint16_t reserved_2;
1104 			uint8_t  rsp_sense_data[24];
1105 		}s1;
1106 
1107 		struct {
1108 			uint16_t reserved_2;
1109 			uint16_t flags;
1110 			uint32_t residual_length;
1111 			uint16_t ox_id;
1112 			uint8_t  reserved_3[10];
1113 			uint32_t transfer_length;
1114 			uint32_t reserved_4;
1115 			uint32_t dseg_0_address_l;
1116 			uint32_t dseg_0_address_h;
1117 			uint32_t dseg_0_length;
1118 		}s2;
1119 	}type;
1120 } ctio_rcv_entry_t;
1121 
1122 /*
1123  * ISP queue -	32-Bit DMA addressing IP entry structure definition.
1124  */
1125 #define	IP_TYPE			0x13
1126 #define	IP_DATA_SEGMENTS	3	/* Number of data segments. */
1127 typedef struct ip_entry {
1128 	uint8_t  entry_type;		/* Entry type. */
1129 	uint8_t  entry_count;		/* Entry count. */
1130 	uint8_t  sys_define;		/* System defined. */
1131 	uint8_t  entry_status;		/* Entry Status. */
1132 	uint32_t handle;		/* System handle */
1133 	uint8_t  loop_id_l;		/* device id - LSB */
1134 	uint8_t  loop_id_h;		/* device id - MSB */
1135 	uint16_t comp_status;		/* Completion status. */
1136 	uint8_t  control_flags_l;	/* Control flags - LSB. */
1137 	uint8_t  control_flags_h;	/* Control flags - MSB. */
1138 	uint8_t  reserved_1[2];
1139 	uint16_t timeout;		/* Command timeout. */
1140 	uint16_t dseg_count;		/* Data segment count. */
1141 	uint8_t  reserved_2[16];
1142 	uint32_t byte_count;		/* Total byte count. */
1143 	uint32_t dseg_0_address;	/* Data segment 0 address. */
1144 	uint32_t dseg_0_length;		/* Data segment 0 length. */
1145 	uint32_t dseg_1_address;	/* Data segment 1 address. */
1146 	uint32_t dseg_1_length;		/* Data segment 1 length. */
1147 	uint32_t dseg_2_address;	/* Data segment 2 address. */
1148 	uint32_t dseg_2_length;		/* Data segment 2 length. */
1149 } ip_entry_t;
1150 
1151 /*
1152  * ISP queue -	64-Bit DMA addressing IP entry structure definition.
1153  */
1154 #define	IP_A64_TYPE		0x1B
1155 #define	IP_A64_DATA_SEGMENTS	2	/* Number of data segments. */
1156 typedef struct ip_a64_entry {
1157 	uint8_t  entry_type;		/* Entry type. */
1158 	uint8_t  entry_count;		/* Entry count. */
1159 	uint8_t  sys_define;		/* System defined. */
1160 	uint8_t  entry_status;		/* Entry Status. */
1161 	uint32_t handle;		/* System handle */
1162 	uint8_t  reserved;
1163 	uint8_t  loop_id;		/* Loop ID */
1164 	uint16_t comp_status;		/* Completion status. */
1165 	uint8_t  control_flags_l;	/* Control flags - LSB. */
1166 	uint8_t  control_flags_h;	/* Control flags - MSB. */
1167 	uint8_t  reserved_1[2];
1168 	uint16_t timeout;		/* Command timeout. */
1169 	uint16_t dseg_count;		/* Data segment count. */
1170 	uint8_t  reserved_2[16];
1171 	uint32_t byte_count;		/* Total byte count. */
1172 	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
1173 	uint32_t dseg_0_length;		/* Data segment 0 length. */
1174 	uint32_t dseg_1_address[2];	/* Data segment 1 address. */
1175 	uint32_t dseg_1_length;		/* Data segment 1 length. */
1176 } ip_a64_entry_t;
1177 
1178 /*
1179  * ISP24xx queue - IP command entry structure definition.
1180  */
1181 #define	IP_CMD_TYPE		0x3B
1182 #define	IP_CMD_DATA_SEGMENTS	1
1183 typedef struct ip_cmd_entry {
1184 	uint8_t  entry_type;		/* Entry type. */
1185 	uint8_t  entry_count;		/* Entry count. */
1186 	uint8_t  sys_define;		/* System defined. */
1187 	uint8_t  entry_status;		/* Entry Status. */
1188 	uint32_t handle;		/* System handle. */
1189 	uint16_t hdl_status;		/* N_port hdl or Completion status */
1190 	uint16_t timeout_hdl;		/* N_port hdl or Command timeout */
1191 	uint16_t dseg_count;		/* Data segment count. */
1192 	uint8_t  reserved_1[6];
1193 	uint32_t exch_addr;
1194 	uint16_t control_flags;
1195 	uint16_t frame_hdr_cntrl_flgs;
1196 	uint8_t  reserved_2[12];
1197 	uint32_t sys_define_2;
1198 	uint32_t byte_count;		/* Total byte count. */
1199 	uint8_t  reserved_3[4];
1200 	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
1201 	uint32_t dseg_0_length;		/* Data segment 0 length. */
1202 } ip_cmd_entry_t;
1203 
1204 /*
1205  * IP command Control Flags.
1206  */
1207 #define	IPCF_TERMINATE_EXCH	BIT_1
1208 /*
1209  * IP command Frame Header Control Flags.
1210  */
1211 #define	IPCF_FIRST_SEQ		BIT_5
1212 #define	IPCF_LAST_SEQ		BIT_4
1213 
1214 /*
1215  * ISP queue - Receive IP buffer entry structure definition.
1216  */
1217 #define	IP_RCVBUF_HANDLES	24	/* Buffer handles in entry. */
1218 #define	IP_RECEIVE_TYPE		0x23	/* IP receive entry */
1219 typedef struct ip_rcv_entry {
1220 	uint8_t  entry_type;		/* Entry type. */
1221 	uint8_t  entry_count;		/* Entry count. */
1222 	uint8_t  segment_count;		/* Segment count. */
1223 	uint8_t  entry_status;		/* Entry Status. */
1224 	uint8_t  s_id[3];		/* Source ID. */
1225 	uint8_t  reserved[2];
1226 	uint8_t  loop_id;		/* Loop ID */
1227 	uint16_t comp_status;		/* Completion status. */
1228 	uint8_t  class_of_srv_l;	/* Class of service - LSB. */
1229 	uint8_t  class_of_srv_h;	/* Class of service - MSB. */
1230 	uint16_t seq_length;		/* Sequence length. */
1231 	uint16_t buffer_handle[IP_RCVBUF_HANDLES]; /* Buffer handles. */
1232 } ip_rcv_entry_t;
1233 
1234 /*
1235  * ISP queue - Receive IP buffer continuation entry structure definition.
1236  */
1237 #define	IP_RCVBUF_CONT_HANDLES	30	/* Buffer handles in entry. */
1238 #define	IP_RECEIVE_CONT_TYPE	0x2B	/* IP receive continuation entry */
1239 typedef struct ip_rcv_cont_entry {
1240 	uint8_t  entry_type;		/* Entry type. */
1241 	uint8_t  entry_count;		/* Entry count. */
1242 	uint8_t  reserved;
1243 	uint8_t  entry_status;		/* Entry Status. */
1244 	uint16_t buffer_handle[IP_RCVBUF_CONT_HANDLES]; /* Buf handles */
1245 } ip_rcv_cont_entry_t;
1246 
1247 /*
1248  * ISP24xx queue - Receive IP buffer entry structure definition.
1249  */
1250 #define	IP_24XX_RCVBUF_HANDLES	4
1251 #define	IP_24XX_RECEIVE_TYPE	0x3c
1252 typedef struct ip_rcv_24xx_entry {
1253 	uint8_t  entry_type;		/* Entry type. */
1254 	uint8_t  entry_count;		/* Entry count. */
1255 	uint8_t  segment_count;		/* Segment count. */
1256 	uint8_t  entry_status;		/* Entry Status. */
1257 	uint8_t  s_id[3];		/* Source ID. */
1258 	uint8_t  reserved[1];
1259 	uint16_t comp_status;		/* Completion status. */
1260 	uint16_t n_port_hdl;		/* Loop ID */
1261 	uint8_t  class_of_srv_l;	/* Class of service - LSB. */
1262 	uint8_t  class_of_srv_h;	/* Class of service - MSB. */
1263 	uint16_t seq_length;		/* Sequence length. */
1264 	uint16_t buffer_handle[IP_24XX_RCVBUF_HANDLES]; /* Buffer handles. */
1265 } ip_rcv_24xx_entry_t;
1266 
1267 /*
1268  * ISP receive buffer container structure definition.
1269  */
1270 typedef struct rcvbuf {
1271 	uint32_t bufp[2];		/* Buffer pointer. */
1272 	uint16_t handle;		/* Buffer handle. */
1273 	uint16_t reserved;
1274 } rcvbuf_t;
1275 
1276 /*
1277  * ISP24xx queue - IP Load Buffer Pool entry structure definition.
1278  */
1279 #define	IP_POOL_BUFFERS		4
1280 #define	IP_BUF_POOL_TYPE	0x3d
1281 typedef struct ip_buf_pool_entry  {
1282 	uint8_t  entry_type;		/* Entry type. */
1283 	uint8_t  entry_count;		/* Entry count. */
1284 	uint8_t  sys_define;		/* System defined. */
1285 	uint8_t  entry_status;		/* Entry Status. */
1286 	uint32_t handle;		/* System handle */
1287 	uint16_t status;
1288 	uint16_t buffer_pool_id;
1289 	uint16_t option;
1290 	uint8_t  buffer_count;
1291 	uint8_t  buffer_count_h;
1292 	rcvbuf_t buffers[IP_POOL_BUFFERS];
1293 } ip_buf_pool_entry_t;
1294 /*
1295  * ISP2400 queue - Virtual Port Modify IOCB structure definition.
1296  */
1297 #define	VP_MODIFY_TYPE		0x31
1298 typedef struct vp_modify_entry {
1299 	uint8_t  entry_type;		/* Entry type. */
1300 	uint8_t  entry_count;		/* Entry count. */
1301 	uint8_t  sys_define;		/* System defined. */
1302 	uint8_t  entry_status;		/* Entry Status. */
1303 	uint32_t handle;		/* System handle */
1304 	uint16_t reserved;
1305 	uint16_t status;
1306 	uint8_t  command;
1307 	uint8_t  vp_count;
1308 	uint8_t  first_vp_index;
1309 	uint8_t  second_vp_index;
1310 	uint8_t  first_options;
1311 	uint8_t  first_hard_prev_addr;
1312 	uint8_t  reserved_2[2];
1313 	uint8_t  first_port_name[8];
1314 	uint8_t  first_node_name[8];
1315 	uint8_t  second_options;
1316 	uint8_t  second_hard_prev_addr;
1317 	uint8_t  reserved_3[2];
1318 	uint8_t  second_port_name[8];
1319 	uint8_t  second_node_name[8];
1320 	uint8_t  reserved_4[6];
1321 	uint16_t fcf_index;
1322 } vp_modify_entry_t;
1323 
1324 /*
1325  * ISP2400 VP modify commands
1326  */
1327 #define	VPM_MODIFY		0x0
1328 #define	VPM_MODIFY_ENABLE	0x1
1329 
1330 /*
1331  * ISP2400 queue - Virtual Port Control IOCB structure definition.
1332  */
1333 #define	VP_CONTROL_TYPE		0x30
1334 typedef struct vp_control_entry {
1335 	uint8_t  entry_type;		/* Entry type. */
1336 	uint8_t  entry_count;		/* Entry count. */
1337 	uint8_t  sys_define;		/* System defined. */
1338 	uint8_t  entry_status;		/* Entry Status. */
1339 	uint32_t handle;		/* System handle */
1340 	uint16_t vp_index_failed;
1341 	uint16_t status;
1342 	uint8_t  command;
1343 	uint8_t  command_h;
1344 	uint8_t  vp_count;
1345 	uint8_t  vp_count_h;
1346 	uint8_t  vp_index[16];
1347 	uint8_t  reserved[30];
1348 	uint16_t fcf_index;
1349 } vp_control_entry_t;
1350 
1351 /*
1352  * ISP2400 VP control commands
1353  */
1354 #define	VPC_ENABLE		0x0
1355 #define	VPC_DISABLE		0x8
1356 #define	VPC_DISABLE_INIT	0x9	/* Only 2400 & 2500 */
1357 #define	VPC_DISABLE_LOGOUT	0xa
1358 #define	VPC_DISABLE_LOGOUT_ALL	0xb
1359 
1360 /*
1361  * ISP2400 queue - Report ID Acquisition IOCB structure definition.
1362  */
1363 #define	REPORT_ID_TYPE		0x32
1364 typedef struct report_id_0 {
1365 	uint8_t  entry_type;		/* Entry type. */
1366 	uint8_t  entry_count;		/* Entry count. */
1367 	uint8_t  sys_define;		/* System defined. */
1368 	uint8_t  entry_status;		/* Entry Status. */
1369 	uint32_t handle;		/* System handle */
1370 	uint8_t  acq_cnt;		/* format 0 acquired, format 1 count */
1371 	uint8_t  setup;			/* format 0 */
1372 	uint8_t  reserved[2];
1373 	uint8_t  port_id[3];
1374 	uint8_t  format;
1375 	uint8_t  vp_index[16];
1376 	uint8_t  reserved_1[32];
1377 } report_id_0_t;
1378 
1379 typedef struct report_id_1 {
1380 	uint8_t  entry_type;		/* Entry type. */
1381 	uint8_t  entry_count;		/* Entry count. */
1382 	uint8_t  sys_define;		/* System defined. */
1383 	uint8_t  entry_status;		/* Entry Status. */
1384 	uint32_t handle;		/* System handle */
1385 	uint16_t vp_count;
1386 	uint8_t  vp_index;
1387 	uint8_t  status;
1388 	uint8_t  port_id[3];
1389 	uint8_t  format;
1390 	uint8_t  reserved[48];
1391 } report_id_1_t;
1392 
1393 /*
1394  * ISP2400 queue - Verify Menlo FW entry structure definition.
1395  */
1396 #define	VERIFY_MENLO_TYPE	0x1b
1397 typedef struct vfy_menlo_entry {
1398 	uint8_t  entry_type;		/* Entry type. */
1399 	uint8_t  entry_count;		/* Entry count. */
1400 	uint8_t  sys_define;		/* System defined. */
1401 	uint8_t  entry_status;		/* Entry Status. */
1402 	uint32_t handle;		/* System handle */
1403 	uint16_t options_status;
1404 	uint16_t failure_code;
1405 	uint16_t dseg_count;
1406 	uint16_t reserved_1[3];
1407 	uint32_t fw_version;
1408 	uint32_t exch_addr;
1409 	uint32_t reserved_2[3];
1410 	uint32_t fw_size;
1411 	uint32_t fw_sequence_size;
1412 	uint32_t relative_offset;
1413 	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
1414 	uint32_t dseg_0_length;		/* Data segment 0 length. */
1415 } vfy_menlo_entry_t;
1416 
1417 /*
1418  * Option Flags.
1419  */
1420 #define	VMO_DSD_CHAINING	BIT_15
1421 #define	VM_END_OF_DATA		BIT_14
1422 #define	VMF_DIAGNOSTIC_FW	BIT_3
1423 #define	VMF_DO_NOT_RESET	BIT_2
1424 #define	VMF_FORCE_UPDATE_FW	BIT_1
1425 #define	VMF_DO_NOT_UPDATE_FW	BIT_0
1426 
1427 /*
1428  * ISP2400 queue - Access Menlo Data entry structure definition.
1429  */
1430 #define	MENLO_DATA_TYPE		0x2b
1431 typedef struct menlo_data_entry {
1432 	uint8_t  entry_type;		/* Entry type. */
1433 	uint8_t  entry_count;		/* Entry count. */
1434 	uint8_t  sys_define;		/* System defined. */
1435 	uint8_t  entry_status;		/* Entry Status. */
1436 	uint32_t handle;		/* System handle */
1437 	uint16_t options_status;
1438 	uint16_t failure_code;
1439 	uint16_t dseg_count;
1440 	uint16_t reserved_1[3];
1441 	uint32_t parameter_1;
1442 	uint32_t parameter_2;
1443 	uint32_t parameter_3;
1444 	uint32_t reserved_2[3];
1445 	uint32_t total_byte_count;
1446 	uint32_t reserved_3;
1447 	uint32_t dseg_0_address[2];	/* Data segment 0 address. */
1448 	uint32_t dseg_0_length;		/* Data segment 0 length. */
1449 } menlo_data_entry_t;
1450 
1451 /*
1452  * Mailbox IOCB.
1453  */
1454 typedef union ql_mbx_iocb {
1455 	cmd_entry_t		cmd;
1456 	cmd_3_entry_t		cmd3;
1457 	cmd7_24xx_entry_t	cmd24;
1458 	ms_entry_t		ms;
1459 	ct_passthru_entry_t	ms24;
1460 	abort_cmd_entry_t	abo;
1461 	task_mgmt_entry_t	mgmt;
1462 	sts_entry_t		sts;
1463 	sts_24xx_entry_t	sts24;
1464 	log_entry_t		log;
1465 	vp_control_entry_t	vpc;
1466 	vp_modify_entry_t	vpm;
1467 	vfy_menlo_entry_t	mvfy;
1468 	menlo_data_entry_t	mdata;
1469 } ql_mbx_iocb_t;
1470 
1471 /*
1472  * Global Data in ql_iocb.c source file.
1473  */
1474 
1475 /*
1476  * Global Function Prototypes in ql_iocb.c source file.
1477  */
1478 void ql_start_iocb(ql_adapter_state_t *, ql_srb_t *);
1479 void ql_isp_cmd(ql_adapter_state_t *);
1480 int ql_marker(ql_adapter_state_t *, uint16_t, uint16_t, uint8_t);
1481 void ql_isp_rcvbuf(ql_adapter_state_t *);
1482 void ql_command_iocb(ql_adapter_state_t *, ql_srb_t *, void *);
1483 void ql_ms_iocb(ql_adapter_state_t *, ql_srb_t *, void *);
1484 void ql_ip_iocb(ql_adapter_state_t *, ql_srb_t *, void *);
1485 void ql_command_24xx_iocb(ql_adapter_state_t *, ql_srb_t *, void *);
1486 void ql_ms_24xx_iocb(ql_adapter_state_t *, ql_srb_t *, void *);
1487 void ql_ip_24xx_iocb(ql_adapter_state_t *, ql_srb_t *, void *);
1488 void ql_els_24xx_iocb(ql_adapter_state_t *, ql_srb_t *, void *);
1489 
1490 #ifdef	__cplusplus
1491 }
1492 #endif
1493 
1494 #endif /* _QL_IOCB_H */
1495