ispmbox.h revision 1.29 1 /* $NetBSD: ispmbox.h,v 1.29 2001/01/09 18:56:06 mjacob Exp $ */
2 /*
3 * This driver, which is contained in NetBSD in the files:
4 *
5 * sys/dev/ic/isp.c
6 * sys/dev/ic/isp_inline.h
7 * sys/dev/ic/isp_netbsd.c
8 * sys/dev/ic/isp_netbsd.h
9 * sys/dev/ic/isp_target.c
10 * sys/dev/ic/isp_target.h
11 * sys/dev/ic/isp_tpublic.h
12 * sys/dev/ic/ispmbox.h
13 * sys/dev/ic/ispreg.h
14 * sys/dev/ic/ispvar.h
15 * sys/microcode/isp/asm_sbus.h
16 * sys/microcode/isp/asm_1040.h
17 * sys/microcode/isp/asm_1080.h
18 * sys/microcode/isp/asm_12160.h
19 * sys/microcode/isp/asm_2100.h
20 * sys/microcode/isp/asm_2200.h
21 * sys/pci/isp_pci.c
22 * sys/sbus/isp_sbus.c
23 *
24 * Is being actively maintained by Matthew Jacob (mjacob (at) netbsd.org).
25 * This driver also is shared source with FreeBSD, OpenBSD, Linux, Solaris,
26 * Linux versions. This tends to be an interesting maintenance problem.
27 *
28 * Please coordinate with Matthew Jacob on changes you wish to make here.
29 */
30 /*
31 * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
32 * All rights reserved.
33 *
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
36 * are met:
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. The name of the author may not be used to endorse or promote products
43 * derived from this software without specific prior written permission
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */
56
57 /*
58 * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters.
59 * <mjacob (at) nas.nasa.gov>
60 */
61 #ifndef _ISPMBOX_H
62 #define _ISPMBOX_H
63
64 /*
65 * Mailbox Command Opcodes
66 */
67
68 #define MBOX_NO_OP 0x0000
69 #define MBOX_LOAD_RAM 0x0001
70 #define MBOX_EXEC_FIRMWARE 0x0002
71 #define MBOX_DUMP_RAM 0x0003
72 #define MBOX_WRITE_RAM_WORD 0x0004
73 #define MBOX_READ_RAM_WORD 0x0005
74 #define MBOX_MAILBOX_REG_TEST 0x0006
75 #define MBOX_VERIFY_CHECKSUM 0x0007
76 #define MBOX_ABOUT_FIRMWARE 0x0008
77 /* 9 */
78 /* a */
79 /* b */
80 /* c */
81 /* d */
82 #define MBOX_CHECK_FIRMWARE 0x000e
83 /* f */
84 #define MBOX_INIT_REQ_QUEUE 0x0010
85 #define MBOX_INIT_RES_QUEUE 0x0011
86 #define MBOX_EXECUTE_IOCB 0x0012
87 #define MBOX_WAKE_UP 0x0013
88 #define MBOX_STOP_FIRMWARE 0x0014
89 #define MBOX_ABORT 0x0015
90 #define MBOX_ABORT_DEVICE 0x0016
91 #define MBOX_ABORT_TARGET 0x0017
92 #define MBOX_BUS_RESET 0x0018
93 #define MBOX_STOP_QUEUE 0x0019
94 #define MBOX_START_QUEUE 0x001a
95 #define MBOX_SINGLE_STEP_QUEUE 0x001b
96 #define MBOX_ABORT_QUEUE 0x001c
97 #define MBOX_GET_DEV_QUEUE_STATUS 0x001d
98 /* 1e */
99 #define MBOX_GET_FIRMWARE_STATUS 0x001f
100 #define MBOX_GET_INIT_SCSI_ID 0x0020
101 #define MBOX_GET_SELECT_TIMEOUT 0x0021
102 #define MBOX_GET_RETRY_COUNT 0x0022
103 #define MBOX_GET_TAG_AGE_LIMIT 0x0023
104 #define MBOX_GET_CLOCK_RATE 0x0024
105 #define MBOX_GET_ACT_NEG_STATE 0x0025
106 #define MBOX_GET_ASYNC_DATA_SETUP_TIME 0x0026
107 #define MBOX_GET_SBUS_PARAMS 0x0027
108 #define MBOX_GET_TARGET_PARAMS 0x0028
109 #define MBOX_GET_DEV_QUEUE_PARAMS 0x0029
110 #define MBOX_GET_RESET_DELAY_PARAMS 0x002a
111 /* 2b */
112 /* 2c */
113 /* 2d */
114 /* 2e */
115 /* 2f */
116 #define MBOX_SET_INIT_SCSI_ID 0x0030
117 #define MBOX_SET_SELECT_TIMEOUT 0x0031
118 #define MBOX_SET_RETRY_COUNT 0x0032
119 #define MBOX_SET_TAG_AGE_LIMIT 0x0033
120 #define MBOX_SET_CLOCK_RATE 0x0034
121 #define MBOX_SET_ACT_NEG_STATE 0x0035
122 #define MBOX_SET_ASYNC_DATA_SETUP_TIME 0x0036
123 #define MBOX_SET_SBUS_CONTROL_PARAMS 0x0037
124 #define MBOX_SET_PCI_PARAMETERS 0x0037
125 #define MBOX_SET_TARGET_PARAMS 0x0038
126 #define MBOX_SET_DEV_QUEUE_PARAMS 0x0039
127 #define MBOX_SET_RESET_DELAY_PARAMS 0x003a
128 /* 3b */
129 /* 3c */
130 /* 3d */
131 /* 3e */
132 /* 3f */
133 #define MBOX_RETURN_BIOS_BLOCK_ADDR 0x0040
134 #define MBOX_WRITE_FOUR_RAM_WORDS 0x0041
135 #define MBOX_EXEC_BIOS_IOCB 0x0042
136 #define MBOX_SET_FW_FEATURES 0x004a
137 #define MBOX_GET_FW_FEATURES 0x004b
138 #define FW_FEATURE_LVD_NOTIFY 0x2
139 #define FW_FEATURE_FAST_POST 0x1
140
141 #define MBOX_ENABLE_TARGET_MODE 0x55
142 #define ENABLE_TARGET_FLAG 0x8000
143
144 /* These are for the ISP2100 FC cards */
145 #define MBOX_GET_LOOP_ID 0x20
146 #define MBOX_GET_RESOURCE_COUNT 0x42
147 #define MBOX_EXEC_COMMAND_IOCB_A64 0x54
148 #define MBOX_INIT_FIRMWARE 0x60
149 #define MBOX_GET_INIT_CONTROL_BLOCK 0x61
150 #define MBOX_INIT_LIP 0x62
151 #define MBOX_GET_FC_AL_POSITION_MAP 0x63
152 #define MBOX_GET_PORT_DB 0x64
153 #define MBOX_CLEAR_ACA 0x65
154 #define MBOX_TARGET_RESET 0x66
155 #define MBOX_CLEAR_TASK_SET 0x67
156 #define MBOX_ABORT_TASK_SET 0x68
157 #define MBOX_GET_FW_STATE 0x69
158 #define MBOX_GET_PORT_NAME 0x6a
159 #define MBOX_GET_LINK_STATUS 0x6b
160 #define MBOX_INIT_LIP_RESET 0x6c
161 #define MBOX_SEND_SNS 0x6e
162 #define MBOX_FABRIC_LOGIN 0x6f
163 #define MBOX_SEND_CHANGE_REQUEST 0x70
164 #define MBOX_FABRIC_LOGOUT 0x71
165 #define MBOX_INIT_LIP_LOGIN 0x72
166
167 #define ISP2100_SET_PCI_PARAM 0x00ff
168
169 #define MBOX_BUSY 0x04
170
171 typedef struct {
172 u_int16_t param[8];
173 } mbreg_t;
174
175 /*
176 * Mailbox Command Complete Status Codes
177 */
178 #define MBOX_COMMAND_COMPLETE 0x4000
179 #define MBOX_INVALID_COMMAND 0x4001
180 #define MBOX_HOST_INTERFACE_ERROR 0x4002
181 #define MBOX_TEST_FAILED 0x4003
182 #define MBOX_COMMAND_ERROR 0x4005
183 #define MBOX_COMMAND_PARAM_ERROR 0x4006
184 #define MBOX_PORT_ID_USED 0x4007
185 #define MBOX_LOOP_ID_USED 0x4008
186 #define MBOX_ALL_IDS_USED 0x4009
187 #define MBOX_NOT_LOGGED_IN 0x400A
188 #define MBLOGALL 0x000f
189 #define MBLOGNONE 0x0000
190 #define MBLOGMASK(x) ((x) & 0xf)
191
192 /*
193 * Asynchronous event status codes
194 */
195 #define ASYNC_BUS_RESET 0x8001
196 #define ASYNC_SYSTEM_ERROR 0x8002
197 #define ASYNC_RQS_XFER_ERR 0x8003
198 #define ASYNC_RSP_XFER_ERR 0x8004
199 #define ASYNC_QWAKEUP 0x8005
200 #define ASYNC_TIMEOUT_RESET 0x8006
201 #define ASYNC_DEVICE_RESET 0x8007
202 #define ASYNC_EXTMSG_UNDERRUN 0x800A
203 #define ASYNC_SCAM_INT 0x800B
204 #define ASYNC_HUNG_SCSI 0x800C
205 #define ASYNC_KILLED_BUS 0x800D
206 #define ASYNC_BUS_TRANSIT 0x800E /* LVD -> HVD, eg. */
207 #define ASYNC_CMD_CMPLT 0x8020
208 #define ASYNC_CTIO_DONE 0x8021
209
210 /* for ISP2100 only */
211 #define ASYNC_LIP_OCCURRED 0x8010
212 #define ASYNC_LOOP_UP 0x8011
213 #define ASYNC_LOOP_DOWN 0x8012
214 #define ASYNC_LOOP_RESET 0x8013
215 #define ASYNC_PDB_CHANGED 0x8014
216 #define ASYNC_CHANGE_NOTIFY 0x8015
217
218 /* for ISP2200 only */
219 #define ASYNC_PTPMODE 0x8030
220 #define ASYNC_CONNMODE 0x8036
221 #define ISP_CONN_LOOP 1
222 #define ISP_CONN_PTP 2
223 #define ISP_CONN_BADLIP 3
224 #define ISP_CONN_FATAL 4
225 #define ISP_CONN_LOOPBACK 5
226
227 /*
228 * Command Structure Definitions
229 */
230
231 typedef struct {
232 u_int32_t ds_base;
233 u_int32_t ds_count;
234 } ispds_t;
235
236 #define _ISP_SWAP8(a, b) { \
237 u_int8_t tmp; \
238 tmp = a; \
239 a = b; \
240 b = tmp; \
241 }
242
243 /*
244 * These elements get swizzled around for SBus instances.
245 */
246 typedef struct {
247 u_int8_t rqs_entry_type;
248 u_int8_t rqs_entry_count;
249 u_int8_t rqs_seqno;
250 u_int8_t rqs_flags;
251 } isphdr_t;
252 /*
253 * There are no (for all intents and purposes) non-sparc SBus machines
254 */
255 #ifdef __sparc__
256 #define ISP_SBUSIFY_ISPHDR(isp, hdrp) \
257 if ((isp)->isp_bustype == ISP_BT_SBUS) { \
258 _ISP_SWAP8((hdrp)->rqs_entry_count, (hdrp)->rqs_entry_type); \
259 _ISP_SWAP8((hdrp)->rqs_flags, (hdrp)->rqs_seqno); \
260 }
261 #else
262 #define ISP_SBUSIFY_ISPHDR(a, b)
263 #endif
264
265 /* RQS Flag definitions */
266 #define RQSFLAG_CONTINUATION 0x01
267 #define RQSFLAG_FULL 0x02
268 #define RQSFLAG_BADHEADER 0x04
269 #define RQSFLAG_BADPACKET 0x08
270
271 /* RQS entry_type definitions */
272 #define RQSTYPE_REQUEST 0x01
273 #define RQSTYPE_DATASEG 0x02
274 #define RQSTYPE_RESPONSE 0x03
275 #define RQSTYPE_MARKER 0x04
276 #define RQSTYPE_CMDONLY 0x05
277 #define RQSTYPE_ATIO 0x06 /* Target Mode */
278 #define RQSTYPE_CTIO 0x07 /* Target Mode */
279 #define RQSTYPE_SCAM 0x08
280 #define RQSTYPE_A64 0x09
281 #define RQSTYPE_A64_CONT 0x0a
282 #define RQSTYPE_ENABLE_LUN 0x0b /* Target Mode */
283 #define RQSTYPE_MODIFY_LUN 0x0c /* Target Mode */
284 #define RQSTYPE_NOTIFY 0x0d /* Target Mode */
285 #define RQSTYPE_NOTIFY_ACK 0x0e /* Target Mode */
286 #define RQSTYPE_CTIO1 0x0f /* Target Mode */
287 #define RQSTYPE_STATUS_CONT 0x10
288 #define RQSTYPE_T2RQS 0x11
289
290 #define RQSTYPE_T4RQS 0x15
291 #define RQSTYPE_ATIO2 0x16
292 #define RQSTYPE_CTIO2 0x17
293 #define RQSTYPE_CSET0 0x18
294 #define RQSTYPE_T3RQS 0x19
295
296 #define RQSTYPE_CTIO3 0x1f
297
298
299 #define ISP_RQDSEG 4
300 typedef struct {
301 isphdr_t req_header;
302 u_int32_t req_handle;
303 u_int8_t req_lun_trn;
304 u_int8_t req_target;
305 u_int16_t req_cdblen;
306 #define req_modifier req_cdblen /* marker packet */
307 u_int16_t req_flags;
308 u_int16_t req_reserved;
309 u_int16_t req_time;
310 u_int16_t req_seg_count;
311 u_int8_t req_cdb[12];
312 ispds_t req_dataseg[ISP_RQDSEG];
313 } ispreq_t;
314
315 /*
316 * A request packet can also be a marker packet.
317 */
318 #define SYNC_DEVICE 0
319 #define SYNC_TARGET 1
320 #define SYNC_ALL 2
321
322 /*
323 * There are no (for all intents and purposes) non-sparc SBus machines
324 */
325 #ifdef __sparc__
326 #define ISP_SBUSIFY_ISPREQ(isp, rqp) \
327 if ((isp)->isp_bustype == ISP_BT_SBUS) { \
328 _ISP_SWAP8((rqp)->req_target, (rqp)->req_lun_trn); \
329 }
330 #else
331 #define ISP_SBUSIFY_ISPREQ(a, b)
332 #endif
333
334 #define ISP_RQDSEG_T2 3
335 typedef struct {
336 isphdr_t req_header;
337 u_int32_t req_handle;
338 u_int8_t req_lun_trn;
339 u_int8_t req_target;
340 u_int16_t req_scclun;
341 u_int16_t req_flags;
342 u_int16_t _res2;
343 u_int16_t req_time;
344 u_int16_t req_seg_count;
345 u_int32_t req_cdb[4];
346 u_int32_t req_totalcnt;
347 ispds_t req_dataseg[ISP_RQDSEG_T2];
348 } ispreqt2_t;
349
350 /* req_flag values */
351 #define REQFLAG_NODISCON 0x0001
352 #define REQFLAG_HTAG 0x0002
353 #define REQFLAG_OTAG 0x0004
354 #define REQFLAG_STAG 0x0008
355 #define REQFLAG_TARGET_RTN 0x0010
356
357 #define REQFLAG_NODATA 0x0000
358 #define REQFLAG_DATA_IN 0x0020
359 #define REQFLAG_DATA_OUT 0x0040
360 #define REQFLAG_DATA_UNKNOWN 0x0060
361
362 #define REQFLAG_DISARQ 0x0100
363 #define REQFLAG_FRC_ASYNC 0x0200
364 #define REQFLAG_FRC_SYNC 0x0400
365 #define REQFLAG_FRC_WIDE 0x0800
366 #define REQFLAG_NOPARITY 0x1000
367 #define REQFLAG_STOPQ 0x2000
368 #define REQFLAG_XTRASNS 0x4000
369 #define REQFLAG_PRIORITY 0x8000
370
371 typedef struct {
372 isphdr_t req_header;
373 u_int32_t req_handle;
374 u_int8_t req_lun_trn;
375 u_int8_t req_target;
376 u_int16_t req_cdblen;
377 u_int16_t req_flags;
378 u_int16_t _res1;
379 u_int16_t req_time;
380 u_int16_t req_seg_count;
381 u_int8_t req_cdb[44];
382 } ispextreq_t;
383
384 #define ISP_CDSEG 7
385 typedef struct {
386 isphdr_t req_header;
387 u_int32_t _res1;
388 ispds_t req_dataseg[ISP_CDSEG];
389 } ispcontreq_t;
390
391 typedef struct {
392 isphdr_t req_header;
393 u_int32_t req_handle;
394 u_int16_t req_scsi_status;
395 u_int16_t req_completion_status;
396 u_int16_t req_state_flags;
397 u_int16_t req_status_flags;
398 u_int16_t req_time;
399 #define req_response_len req_time /* FC only */
400 u_int16_t req_sense_len;
401 u_int32_t req_resid;
402 u_int8_t req_response[8]; /* FC only */
403 u_int8_t req_sense_data[32];
404 } ispstatusreq_t;
405
406 /*
407 * For Qlogic 2X00, the high order byte of SCSI status has
408 * additional meaning.
409 */
410 #define RQCS_RU 0x800 /* Residual Under */
411 #define RQCS_RO 0x400 /* Residual Over */
412 #define RQCS_RESID (RQCS_RU|RQCS_RO)
413 #define RQCS_SV 0x200 /* Sense Length Valid */
414 #define RQCS_RV 0x100 /* FCP Response Length Valid */
415
416 /*
417 * Completion Status Codes.
418 */
419 #define RQCS_COMPLETE 0x0000
420 #define RQCS_DMA_ERROR 0x0002
421 #define RQCS_RESET_OCCURRED 0x0004
422 #define RQCS_ABORTED 0x0005
423 #define RQCS_TIMEOUT 0x0006
424 #define RQCS_DATA_OVERRUN 0x0007
425 #define RQCS_DATA_UNDERRUN 0x0015
426 #define RQCS_QUEUE_FULL 0x001C
427
428 /* 1X00 Only Completion Codes */
429 #define RQCS_INCOMPLETE 0x0001
430 #define RQCS_TRANSPORT_ERROR 0x0003
431 #define RQCS_COMMAND_OVERRUN 0x0008
432 #define RQCS_STATUS_OVERRUN 0x0009
433 #define RQCS_BAD_MESSAGE 0x000a
434 #define RQCS_NO_MESSAGE_OUT 0x000b
435 #define RQCS_EXT_ID_FAILED 0x000c
436 #define RQCS_IDE_MSG_FAILED 0x000d
437 #define RQCS_ABORT_MSG_FAILED 0x000e
438 #define RQCS_REJECT_MSG_FAILED 0x000f
439 #define RQCS_NOP_MSG_FAILED 0x0010
440 #define RQCS_PARITY_ERROR_MSG_FAILED 0x0011
441 #define RQCS_DEVICE_RESET_MSG_FAILED 0x0012
442 #define RQCS_ID_MSG_FAILED 0x0013
443 #define RQCS_UNEXP_BUS_FREE 0x0014
444 #define RQCS_XACT_ERR1 0x0018
445 #define RQCS_XACT_ERR2 0x0019
446 #define RQCS_XACT_ERR3 0x001A
447 #define RQCS_BAD_ENTRY 0x001B
448 #define RQCS_PHASE_SKIPPED 0x001D
449 #define RQCS_ARQS_FAILED 0x001E
450 #define RQCS_WIDE_FAILED 0x001F
451 #define RQCS_SYNCXFER_FAILED 0x0020
452 #define RQCS_LVD_BUSERR 0x0021
453
454 /* 2X00 Only Completion Codes */
455 #define RQCS_PORT_UNAVAILABLE 0x0028
456 #define RQCS_PORT_LOGGED_OUT 0x0029
457 #define RQCS_PORT_CHANGED 0x002A
458 #define RQCS_PORT_BUSY 0x002B
459
460 /*
461 * 1X00 specific State Flags
462 */
463 #define RQSF_GOT_BUS 0x0100
464 #define RQSF_GOT_TARGET 0x0200
465 #define RQSF_SENT_CDB 0x0400
466 #define RQSF_XFRD_DATA 0x0800
467 #define RQSF_GOT_STATUS 0x1000
468 #define RQSF_GOT_SENSE 0x2000
469 #define RQSF_XFER_COMPLETE 0x4000
470
471 /*
472 * 2X00 specific State Flags
473 * (same as 1X00 except RQSF_GOT_BUS/RQSF_GOT_TARGET are not available)
474 */
475 #define RQSF_DATA_IN 0x0020
476 #define RQSF_DATA_OUT 0x0040
477 #define RQSF_STAG 0x0008
478 #define RQSF_OTAG 0x0004
479 #define RQSF_HTAG 0x0002
480 /*
481 * 1X00 Status Flags
482 */
483 #define RQSTF_DISCONNECT 0x0001
484 #define RQSTF_SYNCHRONOUS 0x0002
485 #define RQSTF_PARITY_ERROR 0x0004
486 #define RQSTF_BUS_RESET 0x0008
487 #define RQSTF_DEVICE_RESET 0x0010
488 #define RQSTF_ABORTED 0x0020
489 #define RQSTF_TIMEOUT 0x0040
490 #define RQSTF_NEGOTIATION 0x0080
491
492 /*
493 * 2X00 specific state flags
494 */
495 /* RQSF_SENT_CDB */
496 /* RQSF_XFRD_DATA */
497 /* RQSF_GOT_STATUS */
498 /* RQSF_XFER_COMPLETE */
499
500 /*
501 * 2X00 specific status flags
502 */
503 /* RQSTF_ABORTED */
504 /* RQSTF_TIMEOUT */
505 #define RQSTF_DMA_ERROR 0x0080
506 #define RQSTF_LOGOUT 0x2000
507
508 /*
509 * Miscellaneous
510 */
511 #ifndef ISP_EXEC_THROTTLE
512 #define ISP_EXEC_THROTTLE 16
513 #endif
514
515 /*
516 * FC (ISP2100) specific data structures
517 */
518
519 /*
520 * Initialization Control Block
521 *
522 * Version One (prime) format.
523 */
524 typedef struct isp_icb {
525 u_int8_t icb_version;
526 u_int8_t _reserved0;
527 u_int16_t icb_fwoptions;
528 u_int16_t icb_maxfrmlen;
529 u_int16_t icb_maxalloc;
530 u_int16_t icb_execthrottle;
531 u_int8_t icb_retry_count;
532 u_int8_t icb_retry_delay;
533 u_int8_t icb_portname[8];
534 u_int16_t icb_hardaddr;
535 u_int8_t icb_iqdevtype;
536 u_int8_t icb_logintime;
537 u_int8_t icb_nodename[8];
538 u_int16_t icb_rqstout;
539 u_int16_t icb_rspnsin;
540 u_int16_t icb_rqstqlen;
541 u_int16_t icb_rsltqlen;
542 u_int16_t icb_rqstaddr[4];
543 u_int16_t icb_respaddr[4];
544 u_int16_t icb_lunenables;
545 u_int8_t icb_ccnt;
546 u_int8_t icb_icnt;
547 u_int16_t icb_lunetimeout;
548 u_int16_t _reserved1;
549 u_int16_t icb_xfwoptions;
550 u_int8_t icb_racctimer;
551 u_int8_t icb_idelaytimer;
552 u_int16_t icb_zfwoptions;
553 u_int16_t _reserved2[13];
554 } isp_icb_t;
555 #define ICB_VERSION1 1
556
557 #define ICBOPT_HARD_ADDRESS 0x0001
558 #define ICBOPT_FAIRNESS 0x0002
559 #define ICBOPT_FULL_DUPLEX 0x0004
560 #define ICBOPT_FAST_POST 0x0008
561 #define ICBOPT_TGT_ENABLE 0x0010
562 #define ICBOPT_INI_DISABLE 0x0020
563 #define ICBOPT_INI_ADISC 0x0040
564 #define ICBOPT_INI_TGTTYPE 0x0080
565 #define ICBOPT_PDBCHANGE_AE 0x0100
566 #define ICBOPT_NOLIP 0x0200
567 #define ICBOPT_SRCHDOWN 0x0400
568 #define ICBOPT_PREVLOOP 0x0800
569 #define ICBOPT_STOP_ON_QFULL 0x1000
570 #define ICBOPT_FULL_LOGIN 0x2000
571 #define ICBOPT_USE_PORTNAME 0x4000
572 #define ICBOPT_EXTENDED 0x8000
573
574 #define ICBXOPT_CLASS2_ACK0 0x0200
575 #define ICBXOPT_CLASS2 0x0100
576 #define ICBXOPT_LOOP_ONLY (0 << 4)
577 #define ICBXOPT_PTP_ONLY (1 << 4)
578 #define ICBXOPT_LOOP_2_PTP (2 << 4)
579 #define ICBXOPT_PTP_2_LOOP (3 << 4)
580
581 #define ICBXOPT_RIO_OFF 0
582 #define ICBXOPT_RIO_16BIT 1
583 #define ICBXOPT_RIO_32BIT 2
584 #define ICBXOPT_RIO_16BIT_DELAY 3
585 #define ICBXOPT_RIO_32BIT_DELAY 4
586
587
588
589 #define ICB_MIN_FRMLEN 256
590 #define ICB_MAX_FRMLEN 2112
591 #define ICB_DFLT_FRMLEN 1024
592 #define ICB_DFLT_ALLOC 256
593 #define ICB_DFLT_THROTTLE 16
594 #define ICB_DFLT_RDELAY 5
595 #define ICB_DFLT_RCOUNT 3
596
597
598 #define RQRSP_ADDR0015 0
599 #define RQRSP_ADDR1631 1
600 #define RQRSP_ADDR3247 2
601 #define RQRSP_ADDR4863 3
602
603
604 #define ICB_NNM0 7
605 #define ICB_NNM1 6
606 #define ICB_NNM2 5
607 #define ICB_NNM3 4
608 #define ICB_NNM4 3
609 #define ICB_NNM5 2
610 #define ICB_NNM6 1
611 #define ICB_NNM7 0
612
613 #define MAKE_NODE_NAME_FROM_WWN(array, wwn) \
614 array[ICB_NNM0] = (u_int8_t) ((wwn >> 0) & 0xff), \
615 array[ICB_NNM1] = (u_int8_t) ((wwn >> 8) & 0xff), \
616 array[ICB_NNM2] = (u_int8_t) ((wwn >> 16) & 0xff), \
617 array[ICB_NNM3] = (u_int8_t) ((wwn >> 24) & 0xff), \
618 array[ICB_NNM4] = (u_int8_t) ((wwn >> 32) & 0xff), \
619 array[ICB_NNM5] = (u_int8_t) ((wwn >> 40) & 0xff), \
620 array[ICB_NNM6] = (u_int8_t) ((wwn >> 48) & 0xff), \
621 array[ICB_NNM7] = (u_int8_t) ((wwn >> 56) & 0xff)
622
623 /*
624 * Port Data Base Element
625 */
626
627 typedef struct {
628 u_int16_t pdb_options;
629 u_int8_t pdb_mstate;
630 u_int8_t pdb_sstate;
631 #define BITS2WORD(x) ((x)[0] << 16 | (x)[3] << 8 | (x)[2])
632 u_int8_t pdb_hardaddr_bits[4];
633 u_int8_t pdb_portid_bits[4];
634 u_int8_t pdb_nodename[8];
635 u_int8_t pdb_portname[8];
636 u_int16_t pdb_execthrottle;
637 u_int16_t pdb_exec_count;
638 u_int8_t pdb_retry_count;
639 u_int8_t pdb_retry_delay;
640 u_int16_t pdb_resalloc;
641 u_int16_t pdb_curalloc;
642 u_int16_t pdb_qhead;
643 u_int16_t pdb_qtail;
644 u_int16_t pdb_tl_next;
645 u_int16_t pdb_tl_last;
646 u_int16_t pdb_features; /* PLOGI, Common Service */
647 u_int16_t pdb_pconcurrnt; /* PLOGI, Common Service */
648 u_int16_t pdb_roi; /* PLOGI, Common Service */
649 u_int8_t pdb_target;
650 u_int8_t pdb_initiator; /* PLOGI, Class 3 Control Flags */
651 u_int16_t pdb_rdsiz; /* PLOGI, Class 3 */
652 u_int16_t pdb_ncseq; /* PLOGI, Class 3 */
653 u_int16_t pdb_noseq; /* PLOGI, Class 3 */
654 u_int16_t pdb_labrtflg;
655 u_int16_t pdb_lstopflg;
656 u_int16_t pdb_sqhead;
657 u_int16_t pdb_sqtail;
658 u_int16_t pdb_ptimer;
659 u_int16_t pdb_nxt_seqid;
660 u_int16_t pdb_fcount;
661 u_int16_t pdb_prli_len;
662 u_int16_t pdb_prli_svc0;
663 u_int16_t pdb_prli_svc3;
664 u_int16_t pdb_loopid;
665 u_int16_t pdb_il_ptr;
666 u_int16_t pdb_sl_ptr;
667 } isp_pdb_t;
668
669 #define PDB_OPTIONS_XMITTING (1<<11)
670 #define PDB_OPTIONS_LNKXMIT (1<<10)
671 #define PDB_OPTIONS_ABORTED (1<<9)
672 #define PDB_OPTIONS_ADISC (1<<1)
673
674 #define PDB_STATE_DISCOVERY 0
675 #define PDB_STATE_WDISC_ACK 1
676 #define PDB_STATE_PLOGI 2
677 #define PDB_STATE_PLOGI_ACK 3
678 #define PDB_STATE_PRLI 4
679 #define PDB_STATE_PRLI_ACK 5
680 #define PDB_STATE_LOGGED_IN 6
681 #define PDB_STATE_PORT_UNAVAIL 7
682 #define PDB_STATE_PRLO 8
683 #define PDB_STATE_PRLO_ACK 9
684 #define PDB_STATE_PLOGO 10
685 #define PDB_STATE_PLOG_ACK 11
686
687 #define SVC3_TGT_ROLE 0x10
688 #define SVC3_INI_ROLE 0x20
689 #define SVC3_ROLE_MASK 0x30
690 #define SVC3_ROLE_SHIFT 4
691
692 #define SNS_GAN 0x100
693 #define SNS_GP3 0x171
694 #define SNS_RFT 0x217
695 typedef struct {
696 u_int16_t snscb_rblen; /* response buffer length (words) */
697 u_int16_t snscb_res0;
698 u_int16_t snscb_addr[4]; /* response buffer address */
699 u_int16_t snscb_sblen; /* subcommand buffer length (words) */
700 u_int16_t snscb_res1;
701 u_int16_t snscb_data[1]; /* variable data */
702 } sns_screq_t; /* Subcommand Request Structure */
703 #define SNS_GAN_REQ_SIZE (sizeof (sns_screq_t)+(5*(sizeof (u_int16_t))))
704 #define SNS_GP3_REQ_SIZE (sizeof (sns_screq_t)+(5*(sizeof (u_int16_t))))
705 #define SNS_RFT_REQ_SIZE (sizeof (sns_screq_t)+(21*(sizeof (u_int16_t))))
706
707 typedef struct {
708 u_int8_t snscb_cthdr[16];
709 u_int8_t snscb_port_type;
710 u_int8_t snscb_port_id[3];
711 u_int8_t snscb_portname[8];
712 u_int16_t snscb_data[1]; /* variable data */
713 } sns_scrsp_t; /* Subcommand Response Structure */
714 #define SNS_GAN_RESP_SIZE 608 /* Maximum response size (bytes) */
715 #define SNS_GP3_RESP_SIZE 532 /* XXX: For 128 ports */
716 #define SNS_RFT_RESP_SIZE 16
717
718 typedef struct {
719 u_int8_t snscb_cthdr[16];
720 u_int8_t snscb_port_type;
721 u_int8_t snscb_port_id[3];
722 u_int8_t snscb_portname[8];
723 u_int8_t snscb_pnlen; /* symbolic port name length */
724 u_int8_t snscb_pname[255]; /* symbolic port name */
725 u_int8_t snscb_nodename[8];
726 u_int8_t snscb_nnlen; /* symbolic node name length */
727 u_int8_t snscb_nname[255]; /* symbolic node name */
728 u_int8_t snscb_ipassoc[8];
729 u_int8_t snscb_ipaddr[16];
730 u_int8_t snscb_svc_class[4];
731 u_int8_t snscb_fc4_types[32];
732 u_int8_t snscb_fpname[8];
733 u_int8_t snscb_reserved;
734 u_int8_t snscb_hardaddr[3];
735 } sns_ganrsp_t; /* Subcommand Response Structure */
736
737 #endif /* _ISPMBOX_H */
738