ispmbox.h revision 1.50 1 /* $NetBSD: ispmbox.h,v 1.50 2007/05/24 21:30:43 mjacob Exp $ */
2 /*
3 * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
4 * All rights reserved.
5 *
6 * Additional Copyright (C) 2000-2007 by Matthew Jacob
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 /*
32 * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters.
33 */
34 #ifndef _ISPMBOX_H
35 #define _ISPMBOX_H
36
37 /*
38 * Mailbox Command Opcodes
39 */
40 #define MBOX_NO_OP 0x0000
41 #define MBOX_LOAD_RAM 0x0001
42 #define MBOX_EXEC_FIRMWARE 0x0002
43 #define MBOX_DUMP_RAM 0x0003
44 #define MBOX_WRITE_RAM_WORD 0x0004
45 #define MBOX_READ_RAM_WORD 0x0005
46 #define MBOX_MAILBOX_REG_TEST 0x0006
47 #define MBOX_VERIFY_CHECKSUM 0x0007
48 #define MBOX_ABOUT_FIRMWARE 0x0008
49 #define MBOX_LOAD_RISC_RAM_2100 0x0009
50 /* a */
51 #define MBOX_LOAD_RISC_RAM 0x000b
52 /* c */
53 #define MBOX_WRITE_RAM_WORD_EXTENDED 0x000d
54 #define MBOX_CHECK_FIRMWARE 0x000e
55 #define MBOX_READ_RAM_WORD_EXTENDED 0x000f
56 #define MBOX_INIT_REQ_QUEUE 0x0010
57 #define MBOX_INIT_RES_QUEUE 0x0011
58 #define MBOX_EXECUTE_IOCB 0x0012
59 #define MBOX_WAKE_UP 0x0013
60 #define MBOX_STOP_FIRMWARE 0x0014
61 #define MBOX_ABORT 0x0015
62 #define MBOX_ABORT_DEVICE 0x0016
63 #define MBOX_ABORT_TARGET 0x0017
64 #define MBOX_BUS_RESET 0x0018
65 #define MBOX_STOP_QUEUE 0x0019
66 #define MBOX_START_QUEUE 0x001a
67 #define MBOX_SINGLE_STEP_QUEUE 0x001b
68 #define MBOX_ABORT_QUEUE 0x001c
69 #define MBOX_GET_DEV_QUEUE_STATUS 0x001d
70 /* 1e */
71 #define MBOX_GET_FIRMWARE_STATUS 0x001f
72 #define MBOX_GET_INIT_SCSI_ID 0x0020
73 #define MBOX_GET_SELECT_TIMEOUT 0x0021
74 #define MBOX_GET_RETRY_COUNT 0x0022
75 #define MBOX_GET_TAG_AGE_LIMIT 0x0023
76 #define MBOX_GET_CLOCK_RATE 0x0024
77 #define MBOX_GET_ACT_NEG_STATE 0x0025
78 #define MBOX_GET_ASYNC_DATA_SETUP_TIME 0x0026
79 #define MBOX_GET_SBUS_PARAMS 0x0027
80 #define MBOX_GET_PCI_PARAMS MBOX_GET_SBUS_PARAMS
81 #define MBOX_GET_TARGET_PARAMS 0x0028
82 #define MBOX_GET_DEV_QUEUE_PARAMS 0x0029
83 #define MBOX_GET_RESET_DELAY_PARAMS 0x002a
84 /* 2b */
85 /* 2c */
86 /* 2d */
87 /* 2e */
88 /* 2f */
89 #define MBOX_SET_INIT_SCSI_ID 0x0030
90 #define MBOX_SET_SELECT_TIMEOUT 0x0031
91 #define MBOX_SET_RETRY_COUNT 0x0032
92 #define MBOX_SET_TAG_AGE_LIMIT 0x0033
93 #define MBOX_SET_CLOCK_RATE 0x0034
94 #define MBOX_SET_ACT_NEG_STATE 0x0035
95 #define MBOX_SET_ASYNC_DATA_SETUP_TIME 0x0036
96 #define MBOX_SET_SBUS_CONTROL_PARAMS 0x0037
97 #define MBOX_SET_PCI_PARAMETERS 0x0037
98 #define MBOX_SET_TARGET_PARAMS 0x0038
99 #define MBOX_SET_DEV_QUEUE_PARAMS 0x0039
100 #define MBOX_SET_RESET_DELAY_PARAMS 0x003a
101 /* 3b */
102 /* 3c */
103 /* 3d */
104 /* 3e */
105 /* 3f */
106 #define MBOX_RETURN_BIOS_BLOCK_ADDR 0x0040
107 #define MBOX_WRITE_FOUR_RAM_WORDS 0x0041
108 #define MBOX_EXEC_BIOS_IOCB 0x0042
109 #define MBOX_SET_FW_FEATURES 0x004a
110 #define MBOX_GET_FW_FEATURES 0x004b
111 #define FW_FEATURE_FAST_POST 0x1
112 #define FW_FEATURE_LVD_NOTIFY 0x2
113 #define FW_FEATURE_RIO_32BIT 0x4
114 #define FW_FEATURE_RIO_16BIT 0x8
115
116 #define MBOX_INIT_REQ_QUEUE_A64 0x0052
117 #define MBOX_INIT_RES_QUEUE_A64 0x0053
118
119 #define MBOX_ENABLE_TARGET_MODE 0x0055
120 #define ENABLE_TARGET_FLAG 0x8000
121 #define ENABLE_TQING_FLAG 0x0004
122 #define ENABLE_MANDATORY_DISC 0x0002
123 #define MBOX_GET_TARGET_STATUS 0x0056
124
125 /* These are for the ISP2X00 FC cards */
126 #define MBOX_GET_LOOP_ID 0x0020
127 #define MBOX_GET_FIRMWARE_OPTIONS 0x0028
128 #define MBOX_SET_FIRMWARE_OPTIONS 0x0038
129 #define MBOX_GET_RESOURCE_COUNT 0x0042
130 #define MBOX_REQUEST_OFFLINE_MODE 0x0043
131 #define MBOX_ENHANCED_GET_PDB 0x0047
132 #define MBOX_EXEC_COMMAND_IOCB_A64 0x0054
133 #define MBOX_INIT_FIRMWARE 0x0060
134 #define MBOX_GET_INIT_CONTROL_BLOCK 0x0061
135 #define MBOX_INIT_LIP 0x0062
136 #define MBOX_GET_FC_AL_POSITION_MAP 0x0063
137 #define MBOX_GET_PORT_DB 0x0064
138 #define MBOX_CLEAR_ACA 0x0065
139 #define MBOX_TARGET_RESET 0x0066
140 #define MBOX_CLEAR_TASK_SET 0x0067
141 #define MBOX_ABORT_TASK_SET 0x0068
142 #define MBOX_GET_FW_STATE 0x0069
143 #define MBOX_GET_PORT_NAME 0x006A
144 #define MBOX_GET_LINK_STATUS 0x006B
145 #define MBOX_INIT_LIP_RESET 0x006C
146 #define MBOX_SEND_SNS 0x006E
147 #define MBOX_FABRIC_LOGIN 0x006F
148 #define MBOX_SEND_CHANGE_REQUEST 0x0070
149 #define MBOX_FABRIC_LOGOUT 0x0071
150 #define MBOX_INIT_LIP_LOGIN 0x0072
151 #define MBOX_LUN_RESET 0x007E
152
153 #define MBOX_DRIVER_HEARTBEAT 0x005B
154 #define MBOX_FW_HEARTBEAT 0x005C
155
156 #define MBOX_GET_SET_DATA_RATE 0x005D /* 24XX/23XX only */
157 #define MBGSD_GET_RATE 0
158 #define MBGSD_SET_RATE 1
159 #define MBGSD_SET_RATE_NOW 2 /* 24XX only */
160 #define MBGSD_ONEGB 0
161 #define MBGSD_TWOGB 1
162 #define MBGSD_AUTO 2
163 #define MBGSD_FOURGB 3 /* 24XX only */
164
165
166 #define ISP2100_SET_PCI_PARAM 0x00ff
167
168 #define MBOX_BUSY 0x04
169
170 /*
171 * Mailbox Command Complete Status Codes
172 */
173 #define MBOX_COMMAND_COMPLETE 0x4000
174 #define MBOX_INVALID_COMMAND 0x4001
175 #define MBOX_HOST_INTERFACE_ERROR 0x4002
176 #define MBOX_TEST_FAILED 0x4003
177 #define MBOX_COMMAND_ERROR 0x4005
178 #define MBOX_COMMAND_PARAM_ERROR 0x4006
179 #define MBOX_PORT_ID_USED 0x4007
180 #define MBOX_LOOP_ID_USED 0x4008
181 #define MBOX_ALL_IDS_USED 0x4009
182 #define MBOX_NOT_LOGGED_IN 0x400A
183 /* pseudo mailbox completion codes */
184 #define MBOX_REGS_BUSY 0x6000 /* registers in use */
185 #define MBOX_TIMEOUT 0x6001 /* command timed out */
186
187 #define MBLOGALL 0x000f
188 #define MBLOGNONE 0x0000
189 #define MBLOGMASK(x) ((x) & 0xf)
190
191 /*
192 * Asynchronous event status codes
193 */
194 #define ASYNC_BUS_RESET 0x8001
195 #define ASYNC_SYSTEM_ERROR 0x8002
196 #define ASYNC_RQS_XFER_ERR 0x8003
197 #define ASYNC_RSP_XFER_ERR 0x8004
198 #define ASYNC_QWAKEUP 0x8005
199 #define ASYNC_TIMEOUT_RESET 0x8006
200 #define ASYNC_DEVICE_RESET 0x8007
201 #define ASYNC_EXTMSG_UNDERRUN 0x800A
202 #define ASYNC_SCAM_INT 0x800B
203 #define ASYNC_HUNG_SCSI 0x800C
204 #define ASYNC_KILLED_BUS 0x800D
205 #define ASYNC_BUS_TRANSIT 0x800E /* LVD -> HVD, eg. */
206 #define ASYNC_LIP_OCCURRED 0x8010
207 #define ASYNC_LOOP_UP 0x8011
208 #define ASYNC_LOOP_DOWN 0x8012
209 #define ASYNC_LOOP_RESET 0x8013
210 #define ASYNC_PDB_CHANGED 0x8014
211 #define ASYNC_CHANGE_NOTIFY 0x8015
212 #define ASYNC_LIP_F8 0x8016
213 #define ASYNC_LIP_ERROR 0x8017
214 #define ASYNC_SECURITY_UPDATE 0x801B
215 #define ASYNC_CMD_CMPLT 0x8020
216 #define ASYNC_CTIO_DONE 0x8021
217 #define ASYNC_IP_XMIT_DONE 0x8022
218 #define ASYNC_IP_RECV_DONE 0x8023
219 #define ASYNC_IP_BROADCAST 0x8024
220 #define ASYNC_IP_RCVQ_LOW 0x8025
221 #define ASYNC_IP_RCVQ_EMPTY 0x8026
222 #define ASYNC_IP_RECV_DONE_ALIGNED 0x8027
223 #define ASYNC_PTPMODE 0x8030
224 #define ASYNC_RIO1 0x8031
225 #define ASYNC_RIO2 0x8032
226 #define ASYNC_RIO3 0x8033
227 #define ASYNC_RIO4 0x8034
228 #define ASYNC_RIO5 0x8035
229 #define ASYNC_CONNMODE 0x8036
230 #define ISP_CONN_LOOP 1
231 #define ISP_CONN_PTP 2
232 #define ISP_CONN_BADLIP 3
233 #define ISP_CONN_FATAL 4
234 #define ISP_CONN_LOOPBACK 5
235 #define ASYNC_RIO_RESP 0x8040
236 #define ASYNC_RIO_COMP 0x8042
237 #define ASYNC_RCV_ERR 0x8048
238
239 /*
240 * 2.01.31 2200 Only. Need Bit 13 in Mailbox 1 for Set Firmware Options
241 * mailbox command to enable this.
242 */
243 #define ASYNC_QFULL_SENT 0x8049
244
245 /*
246 * 24XX only
247 */
248 #define ASYNC_RJT_SENT 0x8049
249
250 /*
251 * All IOCB Queue entries are this size
252 */
253 #define QENTRY_LEN 64
254
255 /*
256 * Command Structure Definitions
257 */
258
259 typedef struct {
260 uint32_t ds_base;
261 uint32_t ds_count;
262 } ispds_t;
263
264 typedef struct {
265 uint32_t ds_base;
266 uint32_t ds_basehi;
267 uint32_t ds_count;
268 } ispds64_t;
269
270 #define DSTYPE_32BIT 0
271 #define DSTYPE_64BIT 1
272 typedef struct {
273 uint16_t ds_type; /* 0-> ispds_t, 1-> ispds64_t */
274 uint32_t ds_segment; /* unused */
275 uint32_t ds_base; /* 32 bit address of DSD list */
276 } ispdslist_t;
277
278
279 /*
280 * These elements get swizzled around for SBus instances.
281 */
282 #define ISP_SWAP8(a, b) { \
283 uint8_t tmp; \
284 tmp = a; \
285 a = b; \
286 b = tmp; \
287 }
288 typedef struct {
289 uint8_t rqs_entry_type;
290 uint8_t rqs_entry_count;
291 uint8_t rqs_seqno;
292 uint8_t rqs_flags;
293 } isphdr_t;
294
295 /* RQS Flag definitions */
296 #define RQSFLAG_CONTINUATION 0x01
297 #define RQSFLAG_FULL 0x02
298 #define RQSFLAG_BADHEADER 0x04
299 #define RQSFLAG_BADPACKET 0x08
300 #define RQSFLAG_MASK 0x0f
301
302 /* RQS entry_type definitions */
303 #define RQSTYPE_REQUEST 0x01
304 #define RQSTYPE_DATASEG 0x02
305 #define RQSTYPE_RESPONSE 0x03
306 #define RQSTYPE_MARKER 0x04
307 #define RQSTYPE_CMDONLY 0x05
308 #define RQSTYPE_ATIO 0x06 /* Target Mode */
309 #define RQSTYPE_CTIO 0x07 /* Target Mode */
310 #define RQSTYPE_SCAM 0x08
311 #define RQSTYPE_A64 0x09
312 #define RQSTYPE_A64_CONT 0x0a
313 #define RQSTYPE_ENABLE_LUN 0x0b /* Target Mode */
314 #define RQSTYPE_MODIFY_LUN 0x0c /* Target Mode */
315 #define RQSTYPE_NOTIFY 0x0d /* Target Mode */
316 #define RQSTYPE_NOTIFY_ACK 0x0e /* Target Mode */
317 #define RQSTYPE_CTIO1 0x0f /* Target Mode */
318 #define RQSTYPE_STATUS_CONT 0x10
319 #define RQSTYPE_T2RQS 0x11
320 #define RQSTYPE_CTIO7 0x12
321 #define RQSTYPE_IP_XMIT 0x13
322 #define RQSTYPE_TSK_MGMT 0x14
323 #define RQSTYPE_T4RQS 0x15
324 #define RQSTYPE_ATIO2 0x16 /* Target Mode */
325 #define RQSTYPE_CTIO2 0x17 /* Target Mode */
326 #define RQSTYPE_T7RQS 0x18
327 #define RQSTYPE_T3RQS 0x19
328 #define RQSTYPE_IP_XMIT_64 0x1b
329 #define RQSTYPE_CTIO4 0x1e /* Target Mode */
330 #define RQSTYPE_CTIO3 0x1f /* Target Mode */
331 #define RQSTYPE_RIO1 0x21
332 #define RQSTYPE_RIO2 0x22
333 #define RQSTYPE_IP_RECV 0x23
334 #define RQSTYPE_IP_RECV_CONT 0x24
335 #define RQSTYPE_CT_PASSTHRU 0x29
336 #define RQSTYPE_MS_PASSTHRU 0x29
337 #define RQSTYPE_ABORT_IO 0x33
338 #define RQSTYPE_T6RQS 0x48
339 #define RQSTYPE_LOGIN 0x52
340 #define RQSTYPE_ABTS_RCVD 0x54 /* 24XX only */
341 #define RQSTYPE_ABTS_RSP 0x55 /* 24XX only */
342
343
344 #define ISP_RQDSEG 4
345 typedef struct {
346 isphdr_t req_header;
347 uint32_t req_handle;
348 uint8_t req_lun_trn;
349 uint8_t req_target;
350 uint16_t req_cdblen;
351 uint16_t req_flags;
352 uint16_t req_reserved;
353 uint16_t req_time;
354 uint16_t req_seg_count;
355 uint8_t req_cdb[12];
356 ispds_t req_dataseg[ISP_RQDSEG];
357 } ispreq_t;
358 #define ISP_RQDSEG_A64 2
359
360 typedef struct {
361 isphdr_t mrk_header;
362 uint32_t mrk_handle;
363 uint8_t mrk_reserved0;
364 uint8_t mrk_target;
365 uint16_t mrk_modifier;
366 uint16_t mrk_flags;
367 uint16_t mrk_lun;
368 uint8_t mrk_reserved1[48];
369 } isp_marker_t;
370
371 typedef struct {
372 isphdr_t mrk_header;
373 uint32_t mrk_handle;
374 uint16_t mrk_nphdl;
375 uint8_t mrk_modifier;
376 uint8_t mrk_reserved0;
377 uint8_t mrk_reserved1;
378 uint8_t mrk_vphdl;
379 uint16_t mrk_reserved2;
380 uint8_t mrk_lun[8];
381 uint8_t mrk_reserved3[40];
382 } isp_marker_24xx_t;
383
384
385 #define SYNC_DEVICE 0
386 #define SYNC_TARGET 1
387 #define SYNC_ALL 2
388 #define SYNC_LIP 3
389
390 #define ISP_RQDSEG_T2 3
391 typedef struct {
392 isphdr_t req_header;
393 uint32_t req_handle;
394 uint8_t req_lun_trn;
395 uint8_t req_target;
396 uint16_t req_scclun;
397 uint16_t req_flags;
398 uint16_t req_reserved;
399 uint16_t req_time;
400 uint16_t req_seg_count;
401 uint8_t req_cdb[16];
402 uint32_t req_totalcnt;
403 ispds_t req_dataseg[ISP_RQDSEG_T2];
404 } ispreqt2_t;
405
406 typedef struct {
407 isphdr_t req_header;
408 uint32_t req_handle;
409 uint16_t req_target;
410 uint16_t req_scclun;
411 uint16_t req_flags;
412 uint16_t req_reserved;
413 uint16_t req_time;
414 uint16_t req_seg_count;
415 uint8_t req_cdb[16];
416 uint32_t req_totalcnt;
417 ispds_t req_dataseg[ISP_RQDSEG_T2];
418 } ispreqt2e_t;
419
420 #define ISP_RQDSEG_T3 2
421 typedef struct {
422 isphdr_t req_header;
423 uint32_t req_handle;
424 uint8_t req_lun_trn;
425 uint8_t req_target;
426 uint16_t req_scclun;
427 uint16_t req_flags;
428 uint16_t req_reserved;
429 uint16_t req_time;
430 uint16_t req_seg_count;
431 uint8_t req_cdb[16];
432 uint32_t req_totalcnt;
433 ispds64_t req_dataseg[ISP_RQDSEG_T3];
434 } ispreqt3_t;
435 #define ispreq64_t ispreqt3_t /* same as.... */
436
437 typedef struct {
438 isphdr_t req_header;
439 uint32_t req_handle;
440 uint16_t req_target;
441 uint16_t req_scclun;
442 uint16_t req_flags;
443 uint16_t req_reserved;
444 uint16_t req_time;
445 uint16_t req_seg_count;
446 uint8_t req_cdb[16];
447 uint32_t req_totalcnt;
448 ispds64_t req_dataseg[ISP_RQDSEG_T3];
449 } ispreqt3e_t;
450
451 /* req_flag values */
452 #define REQFLAG_NODISCON 0x0001
453 #define REQFLAG_HTAG 0x0002
454 #define REQFLAG_OTAG 0x0004
455 #define REQFLAG_STAG 0x0008
456 #define REQFLAG_TARGET_RTN 0x0010
457
458 #define REQFLAG_NODATA 0x0000
459 #define REQFLAG_DATA_IN 0x0020
460 #define REQFLAG_DATA_OUT 0x0040
461 #define REQFLAG_DATA_UNKNOWN 0x0060
462
463 #define REQFLAG_DISARQ 0x0100
464 #define REQFLAG_FRC_ASYNC 0x0200
465 #define REQFLAG_FRC_SYNC 0x0400
466 #define REQFLAG_FRC_WIDE 0x0800
467 #define REQFLAG_NOPARITY 0x1000
468 #define REQFLAG_STOPQ 0x2000
469 #define REQFLAG_XTRASNS 0x4000
470 #define REQFLAG_PRIORITY 0x8000
471
472 typedef struct {
473 isphdr_t req_header;
474 uint32_t req_handle;
475 uint8_t req_lun_trn;
476 uint8_t req_target;
477 uint16_t req_cdblen;
478 uint16_t req_flags;
479 uint16_t req_reserved;
480 uint16_t req_time;
481 uint16_t req_seg_count;
482 uint8_t req_cdb[44];
483 } ispextreq_t;
484
485 /* 24XX only */
486 typedef struct {
487 uint16_t fcd_length;
488 uint16_t fcd_a1500;
489 uint16_t fcd_a3116;
490 uint16_t fcd_a4732;
491 uint16_t fcd_a6348;
492 } fcp_cmnd_ds_t;
493
494 typedef struct {
495 isphdr_t req_header;
496 uint32_t req_handle;
497 uint16_t req_nphdl;
498 uint16_t req_time;
499 uint16_t req_seg_count;
500 uint16_t req_fc_rsp_dsd_length;
501 uint8_t req_lun[8];
502 uint16_t req_flags;
503 uint16_t req_fc_cmnd_dsd_length;
504 uint16_t req_fc_cmnd_dsd_a1500;
505 uint16_t req_fc_cmnd_dsd_a3116;
506 uint16_t req_fc_cmnd_dsd_a4732;
507 uint16_t req_fc_cmnd_dsd_a6348;
508 uint16_t req_fc_rsp_dsd_a1500;
509 uint16_t req_fc_rsp_dsd_a3116;
510 uint16_t req_fc_rsp_dsd_a4732;
511 uint16_t req_fc_rsp_dsd_a6348;
512 uint32_t req_totalcnt;
513 uint16_t req_tidlo;
514 uint8_t req_tidhi;
515 uint8_t req_vpidx;
516 ispds64_t req_dataseg;
517 } ispreqt6_t;
518
519 typedef struct {
520 isphdr_t req_header;
521 uint32_t req_handle;
522 uint16_t req_nphdl;
523 uint16_t req_time;
524 uint16_t req_seg_count;
525 uint16_t req_reserved;
526 uint8_t req_lun[8];
527 uint8_t req_alen_datadir;
528 uint8_t req_task_management;
529 uint8_t req_task_attribute;
530 uint8_t req_crn;
531 uint8_t req_cdb[16];
532 uint32_t req_dl;
533 uint16_t req_tidlo;
534 uint8_t req_tidhi;
535 uint8_t req_vpidx;
536 ispds64_t req_dataseg;
537 } ispreqt7_t;
538
539 /* I/O Abort Structure */
540 typedef struct {
541 isphdr_t abrt_header;
542 uint32_t abrt_handle;
543 uint16_t abrt_nphdl;
544 uint16_t abrt_options;
545 uint32_t abrt_cmd_handle;
546 uint8_t abrt_reserved[32];
547 uint16_t abrt_tidlo;
548 uint8_t abrt_tidhi;
549 uint8_t abrt_vpidx;
550 uint8_t abrt_reserved1[12];
551 } isp24xx_abrt_t;
552 #define ISP24XX_ABRT_NO_ABTS 0x01 /* don't actually send an ABTS */
553 #define ISP24XX_ABRT_ENXIO 0x31 /* in nphdl on return */
554
555 #define ISP_CDSEG 7
556 typedef struct {
557 isphdr_t req_header;
558 uint32_t req_reserved;
559 ispds_t req_dataseg[ISP_CDSEG];
560 } ispcontreq_t;
561
562 #define ISP_CDSEG64 5
563 typedef struct {
564 isphdr_t req_header;
565 ispds64_t req_dataseg[ISP_CDSEG64];
566 } ispcontreq64_t;
567
568 typedef struct {
569 isphdr_t req_header;
570 uint32_t req_handle;
571 uint16_t req_scsi_status;
572 uint16_t req_completion_status;
573 uint16_t req_state_flags;
574 uint16_t req_status_flags;
575 uint16_t req_time;
576 #define req_response_len req_time /* FC only */
577 uint16_t req_sense_len;
578 uint32_t req_resid;
579 uint8_t req_response[8]; /* FC only */
580 uint8_t req_sense_data[32];
581 } ispstatusreq_t;
582
583 /*
584 * Status Continuation
585 */
586 typedef struct {
587 isphdr_t req_header;
588 uint8_t req_sense_data[60];
589 } ispstatus_cont_t;
590
591 /*
592 * 24XX Type 0 status
593 */
594 typedef struct {
595 isphdr_t req_header;
596 uint32_t req_handle;
597 uint16_t req_completion_status;
598 uint16_t req_oxid;
599 uint32_t req_resid;
600 uint16_t req_reserved0;
601 uint16_t req_state_flags;
602 uint16_t req_reserved1;
603 uint16_t req_scsi_status;
604 uint32_t req_fcp_residual;
605 uint32_t req_sense_len;
606 uint32_t req_response_len;
607 uint8_t req_rsp_sense[28];
608 } isp24xx_statusreq_t;
609
610 /*
611 * For Qlogic 2X00, the high order byte of SCSI status has
612 * additional meaning.
613 */
614 #define RQCS_RU 0x800 /* Residual Under */
615 #define RQCS_RO 0x400 /* Residual Over */
616 #define RQCS_RESID (RQCS_RU|RQCS_RO)
617 #define RQCS_SV 0x200 /* Sense Length Valid */
618 #define RQCS_RV 0x100 /* FCP Response Length Valid */
619
620 /*
621 * CT Passthru IOCB
622 */
623 typedef struct {
624 isphdr_t ctp_header;
625 uint32_t ctp_handle;
626 uint16_t ctp_status;
627 uint16_t ctp_nphdl; /* n-port handle */
628 uint16_t ctp_cmd_cnt; /* Command DSD count */
629 uint16_t ctp_vpidx; /* low 8 bits */
630 uint16_t ctp_time;
631 uint16_t ctp_reserved0;
632 uint16_t ctp_rsp_cnt; /* Response DSD count */
633 uint16_t ctp_reserved1[5];
634 uint32_t ctp_rsp_bcnt; /* Response byte count */
635 uint32_t ctp_cmd_bcnt; /* Command byte count */
636 ispds64_t ctp_dataseg[2];
637 } isp_ct_pt_t;
638
639 /*
640 * MS Passthru IOCB
641 */
642 typedef struct {
643 isphdr_t ms_header;
644 uint32_t ms_handle;
645 uint16_t ms_nphdl; /* handle in high byte for !2k f/w */
646 uint16_t ms_status;
647 uint16_t ms_flags;
648 uint16_t ms_reserved1; /* low 8 bits */
649 uint16_t ms_time;
650 uint16_t ms_cmd_cnt; /* Command DSD count */
651 uint16_t ms_tot_cnt; /* Total DSD Count */
652 uint8_t ms_type; /* MS type */
653 uint8_t ms_r_ctl; /* R_CTL */
654 uint16_t ms_rxid; /* RX_ID */
655 uint16_t ms_reserved2;
656 uint32_t ms_handle2;
657 uint32_t ms_rsp_bcnt; /* Response byte count */
658 uint32_t ms_cmd_bcnt; /* Command byte count */
659 ispds64_t ms_dataseg[2];
660 } isp_ms_t;
661
662 /*
663 * Completion Status Codes.
664 */
665 #define RQCS_COMPLETE 0x0000
666 #define RQCS_DMA_ERROR 0x0002
667 #define RQCS_RESET_OCCURRED 0x0004
668 #define RQCS_ABORTED 0x0005
669 #define RQCS_TIMEOUT 0x0006
670 #define RQCS_DATA_OVERRUN 0x0007
671 #define RQCS_DATA_UNDERRUN 0x0015
672 #define RQCS_QUEUE_FULL 0x001C
673
674 /* 1X00 Only Completion Codes */
675 #define RQCS_INCOMPLETE 0x0001
676 #define RQCS_TRANSPORT_ERROR 0x0003
677 #define RQCS_COMMAND_OVERRUN 0x0008
678 #define RQCS_STATUS_OVERRUN 0x0009
679 #define RQCS_BAD_MESSAGE 0x000a
680 #define RQCS_NO_MESSAGE_OUT 0x000b
681 #define RQCS_EXT_ID_FAILED 0x000c
682 #define RQCS_IDE_MSG_FAILED 0x000d
683 #define RQCS_ABORT_MSG_FAILED 0x000e
684 #define RQCS_REJECT_MSG_FAILED 0x000f
685 #define RQCS_NOP_MSG_FAILED 0x0010
686 #define RQCS_PARITY_ERROR_MSG_FAILED 0x0011
687 #define RQCS_DEVICE_RESET_MSG_FAILED 0x0012
688 #define RQCS_ID_MSG_FAILED 0x0013
689 #define RQCS_UNEXP_BUS_FREE 0x0014
690 #define RQCS_XACT_ERR1 0x0018
691 #define RQCS_XACT_ERR2 0x0019
692 #define RQCS_XACT_ERR3 0x001A
693 #define RQCS_BAD_ENTRY 0x001B
694 #define RQCS_PHASE_SKIPPED 0x001D
695 #define RQCS_ARQS_FAILED 0x001E
696 #define RQCS_WIDE_FAILED 0x001F
697 #define RQCS_SYNCXFER_FAILED 0x0020
698 #define RQCS_LVD_BUSERR 0x0021
699
700 /* 2X00 Only Completion Codes */
701 #define RQCS_PORT_UNAVAILABLE 0x0028
702 #define RQCS_PORT_LOGGED_OUT 0x0029
703 #define RQCS_PORT_CHANGED 0x002A
704 #define RQCS_PORT_BUSY 0x002B
705
706 /* 24XX Only Completion Codes */
707 #define RQCS_24XX_DRE 0x0011 /* data reassembly error */
708 #define RQCS_24XX_TABORT 0x0013 /* aborted by target */
709 #define RQCS_24XX_ENOMEM 0x002C /* f/w resource unavailable */
710 #define RQCS_24XX_TMO 0x0030 /* task management overrun */
711
712
713 /*
714 * 1X00 specific State Flags
715 */
716 #define RQSF_GOT_BUS 0x0100
717 #define RQSF_GOT_TARGET 0x0200
718 #define RQSF_SENT_CDB 0x0400
719 #define RQSF_XFRD_DATA 0x0800
720 #define RQSF_GOT_STATUS 0x1000
721 #define RQSF_GOT_SENSE 0x2000
722 #define RQSF_XFER_COMPLETE 0x4000
723
724 /*
725 * 2X00 specific State Flags
726 * (same as 1X00 except RQSF_GOT_BUS/RQSF_GOT_TARGET are not available)
727 */
728 #define RQSF_DATA_IN 0x0020
729 #define RQSF_DATA_OUT 0x0040
730 #define RQSF_STAG 0x0008
731 #define RQSF_OTAG 0x0004
732 #define RQSF_HTAG 0x0002
733 /*
734 * 1X00 Status Flags
735 */
736 #define RQSTF_DISCONNECT 0x0001
737 #define RQSTF_SYNCHRONOUS 0x0002
738 #define RQSTF_PARITY_ERROR 0x0004
739 #define RQSTF_BUS_RESET 0x0008
740 #define RQSTF_DEVICE_RESET 0x0010
741 #define RQSTF_ABORTED 0x0020
742 #define RQSTF_TIMEOUT 0x0040
743 #define RQSTF_NEGOTIATION 0x0080
744
745 /*
746 * 2X00 specific state flags
747 */
748 /* RQSF_SENT_CDB */
749 /* RQSF_XFRD_DATA */
750 /* RQSF_GOT_STATUS */
751 /* RQSF_XFER_COMPLETE */
752
753 /*
754 * 2X00 specific status flags
755 */
756 /* RQSTF_ABORTED */
757 /* RQSTF_TIMEOUT */
758 #define RQSTF_DMA_ERROR 0x0080
759 #define RQSTF_LOGOUT 0x2000
760
761 /*
762 * Miscellaneous
763 */
764 #ifndef ISP_EXEC_THROTTLE
765 #define ISP_EXEC_THROTTLE 16
766 #endif
767
768 /*
769 * About Firmware returns an 'attribute' word in mailbox 6.
770 * These attributes are for 2200 and 2300.
771 */
772 #define ISP_FW_ATTR_TMODE 0x01
773 #define ISP_FW_ATTR_SCCLUN 0x02
774 #define ISP_FW_ATTR_FABRIC 0x04
775 #define ISP_FW_ATTR_CLASS2 0x08
776 #define ISP_FW_ATTR_FCTAPE 0x10
777 #define ISP_FW_ATTR_IP 0x20
778 #define ISP_FW_ATTR_VI 0x40
779 #define ISP_FW_ATTR_VI_SOLARIS 0x80
780 #define ISP_FW_ATTR_2KLOGINS 0x100 /* XXX: just a guess */
781
782 /* and these are for the 2400 */
783 #define ISP2400_FW_ATTR_CLASS2 (1 << 0)
784 #define ISP2400_FW_ATTR_IP (1 << 1)
785 #define ISP2400_FW_ATTR_MULTIID (1 << 2)
786 #define ISP2400_FW_ATTR_SB2 (1 << 3)
787 #define ISP2400_FW_ATTR_T10CRC (1 << 4)
788 #define ISP2400_FW_ATTR_VI (1 << 5)
789 #define ISP2400_FW_ATTR_EXPFW (1 << 13)
790
791 /*
792 * Reduced Interrupt Operation Response Queue Entreis
793 */
794
795 typedef struct {
796 isphdr_t req_header;
797 uint32_t req_handles[15];
798 } isp_rio1_t;
799
800 typedef struct {
801 isphdr_t req_header;
802 uint16_t req_handles[30];
803 } isp_rio2_t;
804
805 /*
806 * FC (ISP2100/ISP2200/ISP2300/ISP2400) specific data structures
807 */
808
809 /*
810 * Initialization Control Block
811 *
812 * Version One (prime) format.
813 */
814 typedef struct {
815 uint8_t icb_version;
816 uint8_t icb_reserved0;
817 uint16_t icb_fwoptions;
818 uint16_t icb_maxfrmlen;
819 uint16_t icb_maxalloc;
820 uint16_t icb_execthrottle;
821 uint8_t icb_retry_count;
822 uint8_t icb_retry_delay;
823 uint8_t icb_portname[8];
824 uint16_t icb_hardaddr;
825 uint8_t icb_iqdevtype;
826 uint8_t icb_logintime;
827 uint8_t icb_nodename[8];
828 uint16_t icb_rqstout;
829 uint16_t icb_rspnsin;
830 uint16_t icb_rqstqlen;
831 uint16_t icb_rsltqlen;
832 uint16_t icb_rqstaddr[4];
833 uint16_t icb_respaddr[4];
834 uint16_t icb_lunenables;
835 uint8_t icb_ccnt;
836 uint8_t icb_icnt;
837 uint16_t icb_lunetimeout;
838 uint16_t icb_reserved1;
839 uint16_t icb_xfwoptions;
840 uint8_t icb_racctimer;
841 uint8_t icb_idelaytimer;
842 uint16_t icb_zfwoptions;
843 uint16_t icb_reserved2[13];
844 } isp_icb_t;
845
846 #define ICB_VERSION1 1
847
848 #define ICBOPT_EXTENDED 0x8000
849 #define ICBOPT_BOTH_WWNS 0x4000
850 #define ICBOPT_FULL_LOGIN 0x2000
851 #define ICBOPT_STOP_ON_QFULL 0x1000 /* 2200/2100 only */
852 #define ICBOPT_PREVLOOP 0x0800
853 #define ICBOPT_SRCHDOWN 0x0400
854 #define ICBOPT_NOLIP 0x0200
855 #define ICBOPT_PDBCHANGE_AE 0x0100
856 #define ICBOPT_INI_TGTTYPE 0x0080
857 #define ICBOPT_INI_ADISC 0x0040
858 #define ICBOPT_INI_DISABLE 0x0020
859 #define ICBOPT_TGT_ENABLE 0x0010
860 #define ICBOPT_FAST_POST 0x0008
861 #define ICBOPT_FULL_DUPLEX 0x0004
862 #define ICBOPT_FAIRNESS 0x0002
863 #define ICBOPT_HARD_ADDRESS 0x0001
864
865 #define ICBXOPT_NO_LOGOUT 0x8000 /* no logout on link failure */
866 #define ICBXOPT_FCTAPE_CCQ 0x4000 /* FC-Tape Command Queueing */
867 #define ICBXOPT_FCTAPE_CONFIRM 0x2000
868 #define ICBXOPT_FCTAPE 0x1000
869 #define ICBXOPT_CLASS2_ACK0 0x0200
870 #define ICBXOPT_CLASS2 0x0100
871 #define ICBXOPT_NO_PLAY 0x0080 /* don't play if can't get hard addr */
872 #define ICBXOPT_TOPO_MASK 0x0070
873 #define ICBXOPT_LOOP_ONLY 0x0000
874 #define ICBXOPT_PTP_ONLY 0x0010
875 #define ICBXOPT_LOOP_2_PTP 0x0020
876 #define ICBXOPT_PTP_2_LOOP 0x0030
877 /*
878 * The lower 4 bits of the xfwoptions field are the OPERATION MODE bits.
879 * RIO is not defined for the 23XX cards (just 2200)
880 */
881 #define ICBXOPT_RIO_OFF 0
882 #define ICBXOPT_RIO_16BIT 1
883 #define ICBXOPT_RIO_32BIT 2
884 #define ICBXOPT_RIO_16BIT_IOCB 3
885 #define ICBXOPT_RIO_32BIT_IOCB 4
886 #define ICBXOPT_ZIO 5
887 #define ICBXOPT_TIMER_MASK 0x7
888
889 #define ICBZOPT_RATE_MASK 0xC000
890 #define ICBZOPT_RATE_ONEGB 0x0000
891 #define ICBZOPT_RATE_AUTO 0x8000
892 #define ICBZOPT_RATE_TWOGB 0x4000
893 #define ICBZOPT_50_OHM 0x2000
894 #define ICBZOPT_ENA_OOF 0x0040 /* out of order frame handling */
895 #define ICBZOPT_RSPSZ_MASK 0x0030
896 #define ICBZOPT_RSPSZ_24 0x0000
897 #define ICBZOPT_RSPSZ_12 0x0010
898 #define ICBZOPT_RSPSZ_24A 0x0020
899 #define ICBZOPT_RSPSZ_32 0x0030
900 #define ICBZOPT_SOFTID 0x0002
901 #define ICBZOPT_ENA_RDXFR_RDY 0x0001
902
903 /* 2400 F/W options */
904 #define ICB2400_OPT1_BOTH_WWNS 0x00004000
905 #define ICB2400_OPT1_FULL_LOGIN 0x00002000
906 #define ICB2400_OPT1_PREVLOOP 0x00000800
907 #define ICB2400_OPT1_SRCHDOWN 0x00000400
908 #define ICB2400_OPT1_NOLIP 0x00000200
909 #define ICB2400_OPT1_INI_DISABLE 0x00000020
910 #define ICB2400_OPT1_TGT_ENABLE 0x00000010
911 #define ICB2400_OPT1_FULL_DUPLEX 0x00000004
912 #define ICB2400_OPT1_FAIRNESS 0x00000002
913 #define ICB2400_OPT1_HARD_ADDRESS 0x00000001
914
915 #define ICB2400_OPT2_FCTAPE 0x00001000
916 #define ICB2400_OPT2_CLASS2_ACK0 0x00000200
917 #define ICB2400_OPT2_CLASS2 0x00000100
918 #define ICB2400_OPT2_NO_PLAY 0x00000080
919 #define ICB2400_OPT2_TOPO_MASK 0x00000070
920 #define ICB2400_OPT2_LOOP_ONLY 0x00000000
921 #define ICB2400_OPT2_PTP_ONLY 0x00000010
922 #define ICB2400_OPT2_LOOP_2_PTP 0x00000020
923 #define ICB2400_OPT2_PTP_2_LOOP 0x00000030
924 #define ICB2400_OPT2_TIMER_MASK 0x00000007
925 #define ICB2400_OPT2_ZIO 0x00000005
926 #define ICB2400_OPT2_ZIO1 0x00000006
927
928 #define ICB2400_OPT3_75_OHM 0x00010000
929 #define ICB2400_OPT3_RATE_MASK 0x0000E000
930 #define ICB2400_OPT3_RATE_ONEGB 0x00000000
931 #define ICB2400_OPT3_RATE_TWOGB 0x00002000
932 #define ICB2400_OPT3_RATE_AUTO 0x00004000
933 #define ICB2400_OPT3_RATE_FOURGB 0x00006000
934 #define ICB2400_OPT3_ENA_OOF_XFRDY 0x00000200
935 #define ICB2400_OPT3_NO_LOCAL_PLOGI 0x00000080
936 #define ICB2400_OPT3_ENA_OOF 0x00000040
937 /* note that a response size flag of zero is reserved! */
938 #define ICB2400_OPT3_RSPSZ_MASK 0x00000030
939 #define ICB2400_OPT3_RSPSZ_12 0x00000010
940 #define ICB2400_OPT3_RSPSZ_24 0x00000020
941 #define ICB2400_OPT3_RSPSZ_32 0x00000030
942 #define ICB2400_OPT3_SOFTID 0x00000002
943
944 #define ICB_MIN_FRMLEN 256
945 #define ICB_MAX_FRMLEN 2112
946 #define ICB_DFLT_FRMLEN 1024
947 #define ICB_DFLT_ALLOC 256
948 #define ICB_DFLT_THROTTLE 16
949 #define ICB_DFLT_RDELAY 5
950 #define ICB_DFLT_RCOUNT 3
951
952 #define ICB_LOGIN_TOV 30
953 #define ICB_LUN_ENABLE_TOV 180
954
955
956 /*
957 * And somebody at QLogic had a great idea that you could just change
958 * the structure *and* keep the version number the same as the other cards.
959 */
960 typedef struct {
961 uint16_t icb_version;
962 uint16_t icb_reserved0;
963 uint16_t icb_maxfrmlen;
964 uint16_t icb_execthrottle;
965 uint16_t icb_xchgcnt;
966 uint16_t icb_hardaddr;
967 uint8_t icb_portname[8];
968 uint8_t icb_nodename[8];
969 uint16_t icb_rspnsin;
970 uint16_t icb_rqstout;
971 uint16_t icb_retry_count;
972 uint16_t icb_priout;
973 uint16_t icb_rsltqlen;
974 uint16_t icb_rqstqlen;
975 uint16_t icb_ldn_nols;
976 uint16_t icb_prqstqlen;
977 uint16_t icb_rqstaddr[4];
978 uint16_t icb_respaddr[4];
979 uint16_t icb_priaddr[4];
980 uint16_t icb_reserved1[4];
981 uint16_t icb_atio_in;
982 uint16_t icb_atioqlen;
983 uint16_t icb_atioqaddr[4];
984 uint16_t icb_idelaytimer;
985 uint16_t icb_logintime;
986 uint32_t icb_fwoptions1;
987 uint32_t icb_fwoptions2;
988 uint32_t icb_fwoptions3;
989 uint16_t icb_reserved2[12];
990 } isp_icb_2400_t;
991
992 #define RQRSP_ADDR0015 0
993 #define RQRSP_ADDR1631 1
994 #define RQRSP_ADDR3247 2
995 #define RQRSP_ADDR4863 3
996
997
998 #define ICB_NNM0 7
999 #define ICB_NNM1 6
1000 #define ICB_NNM2 5
1001 #define ICB_NNM3 4
1002 #define ICB_NNM4 3
1003 #define ICB_NNM5 2
1004 #define ICB_NNM6 1
1005 #define ICB_NNM7 0
1006
1007 #define MAKE_NODE_NAME_FROM_WWN(array, wwn) \
1008 array[ICB_NNM0] = (uint8_t) ((wwn >> 0) & 0xff), \
1009 array[ICB_NNM1] = (uint8_t) ((wwn >> 8) & 0xff), \
1010 array[ICB_NNM2] = (uint8_t) ((wwn >> 16) & 0xff), \
1011 array[ICB_NNM3] = (uint8_t) ((wwn >> 24) & 0xff), \
1012 array[ICB_NNM4] = (uint8_t) ((wwn >> 32) & 0xff), \
1013 array[ICB_NNM5] = (uint8_t) ((wwn >> 40) & 0xff), \
1014 array[ICB_NNM6] = (uint8_t) ((wwn >> 48) & 0xff), \
1015 array[ICB_NNM7] = (uint8_t) ((wwn >> 56) & 0xff)
1016
1017 #define MAKE_WWN_FROM_NODE_NAME(wwn, array) \
1018 wwn = ((uint64_t) array[ICB_NNM0]) | \
1019 ((uint64_t) array[ICB_NNM1] << 8) | \
1020 ((uint64_t) array[ICB_NNM2] << 16) | \
1021 ((uint64_t) array[ICB_NNM3] << 24) | \
1022 ((uint64_t) array[ICB_NNM4] << 32) | \
1023 ((uint64_t) array[ICB_NNM5] << 40) | \
1024 ((uint64_t) array[ICB_NNM6] << 48) | \
1025 ((uint64_t) array[ICB_NNM7] << 56)
1026
1027 /*
1028 * Port Data Base Element
1029 */
1030
1031 typedef struct {
1032 uint16_t pdb_options;
1033 uint8_t pdb_mstate;
1034 uint8_t pdb_sstate;
1035 uint8_t pdb_hardaddr_bits[4];
1036 uint8_t pdb_portid_bits[4];
1037 uint8_t pdb_nodename[8];
1038 uint8_t pdb_portname[8];
1039 uint16_t pdb_execthrottle;
1040 uint16_t pdb_exec_count;
1041 uint8_t pdb_retry_count;
1042 uint8_t pdb_retry_delay;
1043 uint16_t pdb_resalloc;
1044 uint16_t pdb_curalloc;
1045 uint16_t pdb_qhead;
1046 uint16_t pdb_qtail;
1047 uint16_t pdb_tl_next;
1048 uint16_t pdb_tl_last;
1049 uint16_t pdb_features; /* PLOGI, Common Service */
1050 uint16_t pdb_pconcurrnt; /* PLOGI, Common Service */
1051 uint16_t pdb_roi; /* PLOGI, Common Service */
1052 uint8_t pdb_target;
1053 uint8_t pdb_initiator; /* PLOGI, Class 3 Control Flags */
1054 uint16_t pdb_rdsiz; /* PLOGI, Class 3 */
1055 uint16_t pdb_ncseq; /* PLOGI, Class 3 */
1056 uint16_t pdb_noseq; /* PLOGI, Class 3 */
1057 uint16_t pdb_labrtflg;
1058 uint16_t pdb_lstopflg;
1059 uint16_t pdb_sqhead;
1060 uint16_t pdb_sqtail;
1061 uint16_t pdb_ptimer;
1062 uint16_t pdb_nxt_seqid;
1063 uint16_t pdb_fcount;
1064 uint16_t pdb_prli_len;
1065 uint16_t pdb_prli_svc0;
1066 uint16_t pdb_prli_svc3;
1067 uint16_t pdb_loopid;
1068 uint16_t pdb_il_ptr;
1069 uint16_t pdb_sl_ptr;
1070 } isp_pdb_21xx_t;
1071
1072 #define PDB_OPTIONS_XMITTING (1<<11)
1073 #define PDB_OPTIONS_LNKXMIT (1<<10)
1074 #define PDB_OPTIONS_ABORTED (1<<9)
1075 #define PDB_OPTIONS_ADISC (1<<1)
1076
1077 #define PDB_STATE_DISCOVERY 0
1078 #define PDB_STATE_WDISC_ACK 1
1079 #define PDB_STATE_PLOGI 2
1080 #define PDB_STATE_PLOGI_ACK 3
1081 #define PDB_STATE_PRLI 4
1082 #define PDB_STATE_PRLI_ACK 5
1083 #define PDB_STATE_LOGGED_IN 6
1084 #define PDB_STATE_PORT_UNAVAIL 7
1085 #define PDB_STATE_PRLO 8
1086 #define PDB_STATE_PRLO_ACK 9
1087 #define PDB_STATE_PLOGO 10
1088 #define PDB_STATE_PLOG_ACK 11
1089
1090 #define SVC3_TGT_ROLE 0x10
1091 #define SVC3_INI_ROLE 0x20
1092 #define SVC3_ROLE_MASK 0x30
1093 #define SVC3_ROLE_SHIFT 4
1094
1095 #define BITS2WORD(x) ((x)[0] << 16 | (x)[3] << 8 | (x)[2])
1096 #define BITS2WORD_24XX(x) ((x)[0] << 16 | (x)[1] << 8 | (x)[2])
1097
1098 /*
1099 * Port Data Base Element- 24XX cards
1100 */
1101 typedef struct {
1102 uint16_t pdb_flags;
1103 uint8_t pdb_curstate;
1104 uint8_t pdb_laststate;
1105 uint8_t pdb_hardaddr_bits[4];
1106 uint8_t pdb_portid_bits[4];
1107 #define pdb_nxt_seqid_2400 pdb_portid_bits[3]
1108 uint16_t pdb_retry_timer;
1109 uint16_t pdb_handle;
1110 uint16_t pdb_rcv_dsize;
1111 uint16_t pdb_reserved0;
1112 uint16_t pdb_prli_svc0;
1113 uint16_t pdb_prli_svc3;
1114 uint8_t pdb_portname[8];
1115 uint8_t pdb_nodename[8];
1116 uint8_t pdb_reserved1[24];
1117 } isp_pdb_24xx_t;
1118
1119 #define PDB2400_TID_SUPPORTED 0x4000
1120 #define PDB2400_FC_TAPE 0x0080
1121 #define PDB2400_CLASS2_ACK0 0x0040
1122 #define PDB2400_FCP_CONF 0x0020
1123 #define PDB2400_CLASS2 0x0010
1124 #define PDB2400_ADDR_VALID 0x0002
1125
1126 /*
1127 * Common elements from the above two structures that are actually useful to us.
1128 */
1129 typedef struct {
1130 uint16_t handle;
1131 uint16_t reserved;
1132 uint32_t s3_role : 8,
1133 portid : 24;
1134 uint8_t portname[8];
1135 uint8_t nodename[8];
1136 } isp_pdb_t;
1137
1138 /*
1139 * Genericized Port Login/Logout software structure
1140 */
1141 typedef struct {
1142 uint16_t handle;
1143 uint32_t
1144 flags : 8,
1145 portid : 24;
1146 } isp_plcmd_t;
1147 /* the flags to use are those for PLOGX_FLG_* below */
1148
1149 /*
1150 * ISP24XX- Login/Logout Port IOCB
1151 */
1152 typedef struct {
1153 isphdr_t plogx_header;
1154 uint32_t plogx_handle;
1155 uint16_t plogx_status;
1156 uint16_t plogx_nphdl;
1157 uint16_t plogx_flags;
1158 uint16_t plogx_vphdl; /* low 8 bits */
1159 uint16_t plogx_portlo; /* low 16 bits */
1160 uint16_t plogx_rspsz_porthi;
1161 struct {
1162 uint16_t lo16;
1163 uint16_t hi16;
1164 } plogx_ioparm[11];
1165 } isp_plogx_t;
1166
1167 #define PLOGX_STATUS_OK 0x00
1168 #define PLOGX_STATUS_UNAVAIL 0x28
1169 #define PLOGX_STATUS_LOGOUT 0x29
1170 #define PLOGX_STATUS_IOCBERR 0x31
1171
1172 #define PLOGX_IOCBERR_NOLINK 0x01
1173 #define PLOGX_IOCBERR_NOIOCB 0x02
1174 #define PLOGX_IOCBERR_NOXGHG 0x03
1175 #define PLOGX_IOCBERR_FAILED 0x04 /* further info in IOPARM 1 */
1176 #define PLOGX_IOCBERR_NOFABRIC 0x05
1177 #define PLOGX_IOCBERR_NOTREADY 0x07
1178 #define PLOGX_IOCBERR_NOLOGIN 0x08 /* further info in IOPARM 1 */
1179 #define PLOGX_IOCBERR_NOPCB 0x0a
1180 #define PLOGX_IOCBERR_REJECT 0x18 /* further info in IOPARM 1 */
1181 #define PLOGX_IOCBERR_EINVAL 0x19 /* further info in IOPARM 1 */
1182 #define PLOGX_IOCBERR_PORTUSED 0x1a /* further info in IOPARM 1 */
1183 #define PLOGX_IOCBERR_HNDLUSED 0x1b /* further info in IOPARM 1 */
1184 #define PLOGX_IOCBERR_NOHANDLE 0x1c
1185 #define PLOGX_IOCBERR_NOFLOGI 0x1f /* further info in IOPARM 1 */
1186
1187 #define PLOGX_FLG_CMD_MASK 0xf
1188 #define PLOGX_FLG_CMD_PLOGI 0
1189 #define PLOGX_FLG_CMD_PRLI 1
1190 #define PLOGX_FLG_CMD_PDISC 2
1191 #define PLOGX_FLG_CMD_LOGO 8
1192 #define PLOGX_FLG_CMD_PRLO 9
1193 #define PLOGX_FLG_CMD_TPRLO 10
1194
1195 #define PLOGX_FLG_COND_PLOGI 0x10 /* if with PLOGI */
1196 #define PLOGX_FLG_IMPLICIT 0x10 /* if with LOGO, PRLO, TPRLO */
1197 #define PLOGX_FLG_SKIP_PRLI 0x20 /* if with PLOGI */
1198 #define PLOGX_FLG_IMPLICIT_LOGO_ALL 0x20 /* if with LOGO */
1199 #define PLOGX_FLG_EXPLICIT_LOGO 0x40 /* if with LOGO */
1200 #define PLOGX_FLG_COMMON_FEATURES 0x80 /* if with PLOGI */
1201 #define PLOGX_FLG_FREE_NPHDL 0x80 /* if with with LOGO */
1202
1203 #define PLOGX_FLG_CLASS2 0x100 /* if with PLOGI */
1204 #define PLOGX_FLG_FCP2_OVERRIDE 0x200 /* if with PRLOG, PRLI */
1205
1206 /*
1207 * Simple Name Server Data Structures
1208 */
1209 #define SNS_GA_NXT 0x100
1210 #define SNS_GPN_ID 0x112
1211 #define SNS_GNN_ID 0x113
1212 #define SNS_GFF_ID 0x11F
1213 #define SNS_GID_FT 0x171
1214 #define SNS_RFT_ID 0x217
1215 typedef struct {
1216 uint16_t snscb_rblen; /* response buffer length (words) */
1217 uint16_t snscb_reserved0;
1218 uint16_t snscb_addr[4]; /* response buffer address */
1219 uint16_t snscb_sblen; /* subcommand buffer length (words) */
1220 uint16_t snscb_reserved1;
1221 uint16_t snscb_data[1]; /* variable data */
1222 } sns_screq_t; /* Subcommand Request Structure */
1223
1224 typedef struct {
1225 uint16_t snscb_rblen; /* response buffer length (words) */
1226 uint16_t snscb_reserved0;
1227 uint16_t snscb_addr[4]; /* response buffer address */
1228 uint16_t snscb_sblen; /* subcommand buffer length (words) */
1229 uint16_t snscb_reserved1;
1230 uint16_t snscb_cmd;
1231 uint16_t snscb_reserved2;
1232 uint32_t snscb_reserved3;
1233 uint32_t snscb_port;
1234 } sns_ga_nxt_req_t;
1235 #define SNS_GA_NXT_REQ_SIZE (sizeof (sns_ga_nxt_req_t))
1236
1237 typedef struct {
1238 uint16_t snscb_rblen; /* response buffer length (words) */
1239 uint16_t snscb_reserved0;
1240 uint16_t snscb_addr[4]; /* response buffer address */
1241 uint16_t snscb_sblen; /* subcommand buffer length (words) */
1242 uint16_t snscb_reserved1;
1243 uint16_t snscb_cmd;
1244 uint16_t snscb_reserved2;
1245 uint32_t snscb_reserved3;
1246 uint32_t snscb_portid;
1247 } sns_gxn_id_req_t;
1248 #define SNS_GXN_ID_REQ_SIZE (sizeof (sns_gxn_id_req_t))
1249
1250 typedef struct {
1251 uint16_t snscb_rblen; /* response buffer length (words) */
1252 uint16_t snscb_reserved0;
1253 uint16_t snscb_addr[4]; /* response buffer address */
1254 uint16_t snscb_sblen; /* subcommand buffer length (words) */
1255 uint16_t snscb_reserved1;
1256 uint16_t snscb_cmd;
1257 uint16_t snscb_mword_div_2;
1258 uint32_t snscb_reserved3;
1259 uint32_t snscb_fc4_type;
1260 } sns_gid_ft_req_t;
1261 #define SNS_GID_FT_REQ_SIZE (sizeof (sns_gid_ft_req_t))
1262
1263 typedef struct {
1264 uint16_t snscb_rblen; /* response buffer length (words) */
1265 uint16_t snscb_reserved0;
1266 uint16_t snscb_addr[4]; /* response buffer address */
1267 uint16_t snscb_sblen; /* subcommand buffer length (words) */
1268 uint16_t snscb_reserved1;
1269 uint16_t snscb_cmd;
1270 uint16_t snscb_reserved2;
1271 uint32_t snscb_reserved3;
1272 uint32_t snscb_port;
1273 uint32_t snscb_fc4_types[8];
1274 } sns_rft_id_req_t;
1275 #define SNS_RFT_ID_REQ_SIZE (sizeof (sns_rft_id_req_t))
1276
1277 typedef struct {
1278 ct_hdr_t snscb_cthdr;
1279 uint8_t snscb_port_type;
1280 uint8_t snscb_port_id[3];
1281 uint8_t snscb_portname[8];
1282 uint16_t snscb_data[1]; /* variable data */
1283 } sns_scrsp_t; /* Subcommand Response Structure */
1284
1285 typedef struct {
1286 ct_hdr_t snscb_cthdr;
1287 uint8_t snscb_port_type;
1288 uint8_t snscb_port_id[3];
1289 uint8_t snscb_portname[8];
1290 uint8_t snscb_pnlen; /* symbolic port name length */
1291 uint8_t snscb_pname[255]; /* symbolic port name */
1292 uint8_t snscb_nodename[8];
1293 uint8_t snscb_nnlen; /* symbolic node name length */
1294 uint8_t snscb_nname[255]; /* symbolic node name */
1295 uint8_t snscb_ipassoc[8];
1296 uint8_t snscb_ipaddr[16];
1297 uint8_t snscb_svc_class[4];
1298 uint8_t snscb_fc4_types[32];
1299 uint8_t snscb_fpname[8];
1300 uint8_t snscb_reserved;
1301 uint8_t snscb_hardaddr[3];
1302 } sns_ga_nxt_rsp_t; /* Subcommand Response Structure */
1303 #define SNS_GA_NXT_RESP_SIZE (sizeof (sns_ga_nxt_rsp_t))
1304
1305 typedef struct {
1306 ct_hdr_t snscb_cthdr;
1307 uint8_t snscb_wwn[8];
1308 } sns_gxn_id_rsp_t;
1309 #define SNS_GXN_ID_RESP_SIZE (sizeof (sns_gxn_id_rsp_t))
1310
1311 typedef struct {
1312 ct_hdr_t snscb_cthdr;
1313 uint32_t snscb_fc4_features[32];
1314 } sns_gff_id_rsp_t;
1315 #define SNS_GFF_ID_RESP_SIZE (sizeof (sns_gff_id_rsp_t))
1316
1317 typedef struct {
1318 ct_hdr_t snscb_cthdr;
1319 struct {
1320 uint8_t control;
1321 uint8_t portid[3];
1322 } snscb_ports[1];
1323 } sns_gid_ft_rsp_t;
1324 #define SNS_GID_FT_RESP_SIZE(x) ((sizeof (sns_gid_ft_rsp_t)) + ((x - 1) << 2))
1325 #define SNS_RFT_ID_RESP_SIZE (sizeof (ct_hdr_t))
1326
1327 /*
1328 * Other Misc Structures
1329 */
1330
1331 /* ELS Pass Through */
1332 typedef struct {
1333 isphdr_t els_hdr;
1334 uint32_t els_handle;
1335 uint16_t els_status;
1336 uint16_t els_nphdl;
1337 uint16_t els_xmit_dsd_count; /* outgoing only */
1338 uint8_t els_vphdl;
1339 uint8_t els_sof;
1340 uint32_t els_rxid;
1341 uint16_t els_recv_dsd_count; /* outgoing only */
1342 uint8_t els_opcode;
1343 uint8_t els_reserved1;
1344 uint8_t els_did_lo;
1345 uint8_t els_did_mid;
1346 uint8_t els_did_hi;
1347 uint8_t els_reserved2;
1348 uint16_t els_reserved3;
1349 uint16_t els_ctl_flags;
1350 union {
1351 struct {
1352 uint32_t _els_bytecnt;
1353 uint32_t _els_subcode1;
1354 uint32_t _els_subcode2;
1355 uint8_t _els_reserved4[20];
1356 } in;
1357 struct {
1358 uint32_t _els_recv_bytecnt;
1359 uint32_t _els_xmit_bytecnt;
1360 uint32_t _els_xmit_dsd_length;
1361 uint16_t _els_xmit_dsd_a1500;
1362 uint16_t _els_xmit_dsd_a3116;
1363 uint16_t _els_xmit_dsd_a4732;
1364 uint16_t _els_xmit_dsd_a6348;
1365 uint32_t _els_recv_dsd_length;
1366 uint16_t _els_recv_dsd_a1500;
1367 uint16_t _els_recv_dsd_a3116;
1368 uint16_t _els_recv_dsd_a4732;
1369 uint16_t _els_recv_dsd_a6348;
1370 } out;
1371 } inout;
1372 #define els_bytecnt inout.in._els_bytecnt
1373 #define els_subcode1 inout.in._els_subcode1
1374 #define els_subcode2 inout.in._els_subcode2
1375 #define els_reserved4 inout.in._els_reserved4
1376 #define els_recv_bytecnt inout.out._els_recv_bytecnt
1377 #define els_xmit_bytecnt inout.out._els_xmit_bytecnt
1378 #define els_xmit_dsd_length inout.out._els_xmit_dsd_length
1379 #define els_xmit_dsd_a1500 inout.out._els_xmit_dsd_a1500
1380 #define els_xmit_dsd_a3116 inout.out._els_xmit_dsd_a3116
1381 #define els_xmit_dsd_a4732 inout.out._els_xmit_dsd_a4732
1382 #define els_xmit_dsd_a6348 inout.out._els_xmit_dsd_a6348
1383 #define els_recv_dsd_length inout.out._els_recv_dsd_length
1384 #define els_recv_dsd_a1500 inout.out._els_recv_dsd_a1500
1385 #define els_recv_dsd_a3116 inout.out._els_recv_dsd_a3116
1386 #define els_recv_dsd_a4732 inout.out._els_recv_dsd_a4732
1387 #define els_recv_dsd_a6348 inout.out._els_recv_dsd_a6348
1388 } els_t;
1389
1390 /*
1391 * A handy package structure for running FC-SCSI commands via RUN IOCB A64.
1392 */
1393 typedef struct {
1394 uint16_t handle;
1395 uint16_t lun;
1396 uint32_t portid;
1397 uint32_t timeout;
1398 union {
1399 struct {
1400 uint32_t data_length;
1401 uint8_t do_read;
1402 uint8_t pad[3];
1403 uint8_t cdb[16];
1404 void *data_ptr;
1405 } beg;
1406 struct {
1407 uint32_t data_residual;
1408 uint8_t status;
1409 uint8_t pad;
1410 uint16_t sense_length;
1411 uint8_t sense_data[32];
1412 } end;
1413 } fcd;
1414 } isp_xcmd_t;
1415 #endif /* _ISPMBOX_H */
1416