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