1 /* $FreeBSD$ */ 2 /* 3 * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters. 4 * 5 *--------------------------------------- 6 * Copyright (c) 1997, 1998, 1999 by Matthew Jacob 7 * NASA/Ames Research Center 8 * All rights reserved. 9 *--------------------------------------- 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice immediately at the beginning of the file, without modification, 16 * this list of conditions, and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 */ 36 #ifndef _ISPMBOX_H 37 #define _ISPMBOX_H 38 39 /* 40 * Mailbox Command Opcodes 41 */ 42 43 #define MBOX_NO_OP 0x0000 44 #define MBOX_LOAD_RAM 0x0001 45 #define MBOX_EXEC_FIRMWARE 0x0002 46 #define MBOX_DUMP_RAM 0x0003 47 #define MBOX_WRITE_RAM_WORD 0x0004 48 #define MBOX_READ_RAM_WORD 0x0005 49 #define MBOX_MAILBOX_REG_TEST 0x0006 50 #define MBOX_VERIFY_CHECKSUM 0x0007 51 #define MBOX_ABOUT_FIRMWARE 0x0008 52 /* 9 */ 53 /* a */ 54 /* b */ 55 /* c */ 56 /* d */ 57 #define MBOX_CHECK_FIRMWARE 0x000e 58 /* f */ 59 #define MBOX_INIT_REQ_QUEUE 0x0010 60 #define MBOX_INIT_RES_QUEUE 0x0011 61 #define MBOX_EXECUTE_IOCB 0x0012 62 #define MBOX_WAKE_UP 0x0013 63 #define MBOX_STOP_FIRMWARE 0x0014 64 #define MBOX_ABORT 0x0015 65 #define MBOX_ABORT_DEVICE 0x0016 66 #define MBOX_ABORT_TARGET 0x0017 67 #define MBOX_BUS_RESET 0x0018 68 #define MBOX_STOP_QUEUE 0x0019 69 #define MBOX_START_QUEUE 0x001a 70 #define MBOX_SINGLE_STEP_QUEUE 0x001b 71 #define MBOX_ABORT_QUEUE 0x001c 72 #define MBOX_GET_DEV_QUEUE_STATUS 0x001d 73 /* 1e */ 74 #define MBOX_GET_FIRMWARE_STATUS 0x001f 75 #define MBOX_GET_INIT_SCSI_ID 0x0020 76 #define MBOX_GET_SELECT_TIMEOUT 0x0021 77 #define MBOX_GET_RETRY_COUNT 0x0022 78 #define MBOX_GET_TAG_AGE_LIMIT 0x0023 79 #define MBOX_GET_CLOCK_RATE 0x0024 80 #define MBOX_GET_ACT_NEG_STATE 0x0025 81 #define MBOX_GET_ASYNC_DATA_SETUP_TIME 0x0026 82 #define MBOX_GET_SBUS_PARAMS 0x0027 83 #define MBOX_GET_TARGET_PARAMS 0x0028 84 #define MBOX_GET_DEV_QUEUE_PARAMS 0x0029 85 #define MBOX_GET_RESET_DELAY_PARAMS 0x002a 86 /* 2b */ 87 /* 2c */ 88 /* 2d */ 89 /* 2e */ 90 /* 2f */ 91 #define MBOX_SET_INIT_SCSI_ID 0x0030 92 #define MBOX_SET_SELECT_TIMEOUT 0x0031 93 #define MBOX_SET_RETRY_COUNT 0x0032 94 #define MBOX_SET_TAG_AGE_LIMIT 0x0033 95 #define MBOX_SET_CLOCK_RATE 0x0034 96 #define MBOX_SET_ACT_NEG_STATE 0x0035 97 #define MBOX_SET_ASYNC_DATA_SETUP_TIME 0x0036 98 #define MBOX_SET_SBUS_CONTROL_PARAMS 0x0037 99 #define MBOX_SET_PCI_PARAMETERS 0x0037 100 #define MBOX_SET_TARGET_PARAMS 0x0038 101 #define MBOX_SET_DEV_QUEUE_PARAMS 0x0039 102 #define MBOX_SET_RESET_DELAY_PARAMS 0x003a 103 /* 3b */ 104 /* 3c */ 105 /* 3d */ 106 /* 3e */ 107 /* 3f */ 108 #define MBOX_RETURN_BIOS_BLOCK_ADDR 0x0040 109 #define MBOX_WRITE_FOUR_RAM_WORDS 0x0041 110 #define MBOX_EXEC_BIOS_IOCB 0x0042 111 #define MBOX_SET_FW_FEATURES 0x004a 112 #define MBOX_GET_FW_FEATURES 0x004b 113 #define FW_FEATURE_LVD_NOTIFY 0x2 114 #define FW_FEATURE_FAST_POST 0x1 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 /* 183 * Command Structure Definitions 184 */ 185 186 typedef struct { 187 u_int32_t ds_base; 188 u_int32_t ds_count; 189 } ispds_t; 190 191 #define _ISP_SWAP8(a, b) { \ 192 u_int8_t tmp; \ 193 tmp = a; \ 194 a = b; \ 195 b = tmp; \ 196 } 197 198 /* 199 * These elements get swizzled around for SBus instances. 200 */ 201 typedef struct { 202 u_int8_t rqs_entry_type; 203 u_int8_t rqs_entry_count; 204 u_int8_t rqs_seqno; 205 u_int8_t rqs_flags; 206 } isphdr_t; 207 /* 208 * There are no (for all intents and purposes) non-sparc SBus machines 209 */ 210 #ifdef __sparc__ 211 #define ISP_SBUSIFY_ISPHDR(isp, hdrp) \ 212 if ((isp)->isp_bustype == ISP_BT_SBUS) { \ 213 _ISP_SWAP8((hdrp)->rqs_entry_count, (hdrp)->rqs_entry_type); \ 214 _ISP_SWAP8((hdrp)->rqs_flags, (hdrp)->rqs_seqno); \ 215 } 216 #else 217 #define ISP_SBUSIFY_ISPHDR(a, b) 218 #endif 219 220 /* RQS Flag definitions */ 221 #define RQSFLAG_CONTINUATION 0x01 222 #define RQSFLAG_FULL 0x02 223 #define RQSFLAG_BADHEADER 0x04 224 #define RQSFLAG_BADPACKET 0x08 225 226 /* RQS entry_type definitions */ 227 #define RQSTYPE_REQUEST 0x01 228 #define RQSTYPE_DATASEG 0x02 229 #define RQSTYPE_RESPONSE 0x03 230 #define RQSTYPE_MARKER 0x04 231 #define RQSTYPE_CMDONLY 0x05 232 #define RQSTYPE_ATIO 0x06 /* Target Mode */ 233 #define RQSTYPE_CTIO0 0x07 /* Target Mode */ 234 #define RQSTYPE_SCAM 0x08 235 #define RQSTYPE_A64 0x09 236 #define RQSTYPE_A64_CONT 0x0a 237 #define RQSTYPE_ENABLE_LUN 0x0b /* Target Mode */ 238 #define RQSTYPE_MODIFY_LUN 0x0c /* Target Mode */ 239 #define RQSTYPE_NOTIFY 0x0d /* Target Mode */ 240 #define RQSTYPE_NOTIFY_ACK 0x0e /* Target Mode */ 241 #define RQSTYPE_CTIO1 0x0f /* Target Mode */ 242 #define RQSTYPE_STATUS_CONT 0x10 243 #define RQSTYPE_T2RQS 0x11 244 245 #define RQSTYPE_T4RQS 0x15 246 #define RQSTYPE_ATIO2 0x16 247 #define RQSTYPE_CTIO2 0x17 248 #define RQSTYPE_CSET0 0x18 249 #define RQSTYPE_T3RQS 0x19 250 251 #define RQSTYPE_CTIO3 0x1f 252 253 254 #define ISP_RQDSEG 4 255 typedef struct { 256 isphdr_t req_header; 257 u_int32_t req_handle; 258 u_int8_t req_lun_trn; 259 u_int8_t req_target; 260 u_int16_t req_cdblen; 261 #define req_modifier req_cdblen /* marker packet */ 262 u_int16_t req_flags; 263 u_int16_t req_reserved; 264 u_int16_t req_time; 265 u_int16_t req_seg_count; 266 u_int8_t req_cdb[12]; 267 ispds_t req_dataseg[ISP_RQDSEG]; 268 } ispreq_t; 269 270 /* 271 * A request packet can also be a marker packet. 272 */ 273 #define SYNC_DEVICE 0 274 #define SYNC_TARGET 1 275 #define SYNC_ALL 2 276 277 /* 278 * There are no (for all intents and purposes) non-sparc SBus machines 279 */ 280 #ifdef __sparc__ 281 #define ISP_SBUSIFY_ISPREQ(isp, rqp) \ 282 if ((isp)->isp_bustype == ISP_BT_SBUS) { \ 283 _ISP_SWAP8((rqp)->req_target, (rqp)->req_lun_trn); \ 284 } 285 #else 286 #define ISP_SBUSIFY_ISPREQ(a, b) 287 #endif 288 289 #define ISP_RQDSEG_T2 3 290 typedef struct { 291 isphdr_t req_header; 292 u_int32_t req_handle; 293 u_int8_t req_lun_trn; 294 u_int8_t req_target; 295 u_int16_t req_scclun; 296 u_int16_t req_flags; 297 u_int16_t _res2; 298 u_int16_t req_time; 299 u_int16_t req_seg_count; 300 u_int32_t req_cdb[4]; 301 u_int32_t req_totalcnt; 302 ispds_t req_dataseg[ISP_RQDSEG_T2]; 303 } ispreqt2_t; 304 305 /* req_flag values */ 306 #define REQFLAG_NODISCON 0x0001 307 #define REQFLAG_HTAG 0x0002 308 #define REQFLAG_OTAG 0x0004 309 #define REQFLAG_STAG 0x0008 310 #define REQFLAG_TARGET_RTN 0x0010 311 312 #define REQFLAG_NODATA 0x0000 313 #define REQFLAG_DATA_IN 0x0020 314 #define REQFLAG_DATA_OUT 0x0040 315 #define REQFLAG_DATA_UNKNOWN 0x0060 316 317 #define REQFLAG_DISARQ 0x0100 318 #define REQFLAG_FRC_ASYNC 0x0200 319 #define REQFLAG_FRC_SYNC 0x0400 320 #define REQFLAG_FRC_WIDE 0x0800 321 #define REQFLAG_NOPARITY 0x1000 322 #define REQFLAG_STOPQ 0x2000 323 #define REQFLAG_XTRASNS 0x4000 324 #define REQFLAG_PRIORITY 0x8000 325 326 typedef struct { 327 isphdr_t req_header; 328 u_int32_t req_handle; 329 u_int8_t req_lun_trn; 330 u_int8_t req_target; 331 u_int16_t req_cdblen; 332 u_int16_t req_flags; 333 u_int16_t _res1; 334 u_int16_t req_time; 335 u_int16_t req_seg_count; 336 u_int8_t req_cdb[44]; 337 } ispextreq_t; 338 339 #define ISP_CDSEG 7 340 typedef struct { 341 isphdr_t req_header; 342 u_int32_t _res1; 343 ispds_t req_dataseg[ISP_CDSEG]; 344 } ispcontreq_t; 345 346 typedef struct { 347 isphdr_t req_header; 348 u_int32_t req_handle; 349 u_int16_t req_scsi_status; 350 u_int16_t req_completion_status; 351 u_int16_t req_state_flags; 352 u_int16_t req_status_flags; 353 u_int16_t req_time; 354 u_int16_t req_sense_len; 355 u_int32_t req_resid; 356 u_int8_t _res1[8]; 357 u_int8_t req_sense_data[32]; 358 } ispstatusreq_t; 359 360 /* 361 * For Qlogic 2100, the high order byte of SCSI status has 362 * additional meaning. 363 */ 364 #define RQCS_RU 0x800 /* Residual Under */ 365 #define RQCS_RO 0x400 /* Residual Over */ 366 #define RQCS_SV 0x200 /* Sense Length Valid */ 367 #define RQCS_RV 0x100 /* Residual Valid */ 368 369 /* 370 * Completion Status Codes. 371 */ 372 #define RQCS_COMPLETE 0x0000 373 #define RQCS_INCOMPLETE 0x0001 374 #define RQCS_DMA_ERROR 0x0002 375 #define RQCS_TRANSPORT_ERROR 0x0003 376 #define RQCS_RESET_OCCURRED 0x0004 377 #define RQCS_ABORTED 0x0005 378 #define RQCS_TIMEOUT 0x0006 379 #define RQCS_DATA_OVERRUN 0x0007 380 #define RQCS_COMMAND_OVERRUN 0x0008 381 #define RQCS_STATUS_OVERRUN 0x0009 382 #define RQCS_BAD_MESSAGE 0x000a 383 #define RQCS_NO_MESSAGE_OUT 0x000b 384 #define RQCS_EXT_ID_FAILED 0x000c 385 #define RQCS_IDE_MSG_FAILED 0x000d 386 #define RQCS_ABORT_MSG_FAILED 0x000e 387 #define RQCS_REJECT_MSG_FAILED 0x000f 388 #define RQCS_NOP_MSG_FAILED 0x0010 389 #define RQCS_PARITY_ERROR_MSG_FAILED 0x0011 390 #define RQCS_DEVICE_RESET_MSG_FAILED 0x0012 391 #define RQCS_ID_MSG_FAILED 0x0013 392 #define RQCS_UNEXP_BUS_FREE 0x0014 393 #define RQCS_DATA_UNDERRUN 0x0015 394 #define RQCS_XACT_ERR1 0x0018 395 #define RQCS_XACT_ERR2 0x0019 396 #define RQCS_XACT_ERR3 0x001A 397 #define RQCS_BAD_ENTRY 0x001B 398 #define RQCS_QUEUE_FULL 0x001C 399 #define RQCS_PHASE_SKIPPED 0x001D 400 #define RQCS_ARQS_FAILED 0x001E 401 #define RQCS_WIDE_FAILED 0x001F 402 #define RQCS_SYNCXFER_FAILED 0x0020 403 #define RQCS_LVD_BUSERR 0x0021 404 405 /* 2100 Only Completion Codes */ 406 #define RQCS_PORT_UNAVAILABLE 0x0028 407 #define RQCS_PORT_LOGGED_OUT 0x0029 408 #define RQCS_PORT_CHANGED 0x002A 409 #define RQCS_PORT_BUSY 0x002B 410 411 /* 412 * State Flags (not applicable to 2100) 413 */ 414 #define RQSF_GOT_BUS 0x0100 415 #define RQSF_GOT_TARGET 0x0200 416 #define RQSF_SENT_CDB 0x0400 417 #define RQSF_XFRD_DATA 0x0800 418 #define RQSF_GOT_STATUS 0x1000 419 #define RQSF_GOT_SENSE 0x2000 420 #define RQSF_XFER_COMPLETE 0x4000 421 422 /* 423 * Status Flags (not applicable to 2100) 424 */ 425 #define RQSTF_DISCONNECT 0x0001 426 #define RQSTF_SYNCHRONOUS 0x0002 427 #define RQSTF_PARITY_ERROR 0x0004 428 #define RQSTF_BUS_RESET 0x0008 429 #define RQSTF_DEVICE_RESET 0x0010 430 #define RQSTF_ABORTED 0x0020 431 #define RQSTF_TIMEOUT 0x0040 432 #define RQSTF_NEGOTIATION 0x0080 433 434 /* 435 * FC (ISP2100) specific data structures 436 */ 437 438 /* 439 * Initialization Control Block 440 * 441 * Version One (prime) format. 442 */ 443 typedef struct isp_icb { 444 u_int8_t icb_version; 445 u_int8_t _reserved0; 446 u_int16_t icb_fwoptions; 447 u_int16_t icb_maxfrmlen; 448 u_int16_t icb_maxalloc; 449 u_int16_t icb_execthrottle; 450 u_int8_t icb_retry_count; 451 u_int8_t icb_retry_delay; 452 u_int8_t icb_portname[8]; 453 u_int16_t icb_hardaddr; 454 u_int8_t icb_iqdevtype; 455 u_int8_t icb_logintime; 456 u_int8_t icb_nodename[8]; 457 u_int16_t icb_rqstout; 458 u_int16_t icb_rspnsin; 459 u_int16_t icb_rqstqlen; 460 u_int16_t icb_rsltqlen; 461 u_int16_t icb_rqstaddr[4]; 462 u_int16_t icb_respaddr[4]; 463 u_int16_t icb_lunenables; 464 u_int8_t icb_ccnt; 465 u_int8_t icb_icnt; 466 u_int16_t icb_lunetimeout; 467 u_int16_t _reserved1; 468 u_int16_t icb_xfwoptions; 469 u_int8_t icb_racctimer; 470 u_int8_t icb_idelaytimer; 471 u_int16_t icb_zfwoptions; 472 u_int16_t _reserved2[13]; 473 } isp_icb_t; 474 #define ICB_VERSION1 1 475 476 #define ICBOPT_HARD_ADDRESS 0x0001 477 #define ICBOPT_FAIRNESS 0x0002 478 #define ICBOPT_FULL_DUPLEX 0x0004 479 #define ICBOPT_FAST_POST 0x0008 480 #define ICBOPT_TGT_ENABLE 0x0010 481 #define ICBOPT_INI_DISABLE 0x0020 482 #define ICBOPT_INI_ADISC 0x0040 483 #define ICBOPT_INI_TGTTYPE 0x0080 484 #define ICBOPT_PDBCHANGE_AE 0x0100 485 #define ICBOPT_NOLIP 0x0200 486 #define ICBOPT_SRCHDOWN 0x0400 487 #define ICBOPT_PREVLOOP 0x0800 488 #define ICBOPT_STOP_ON_QFULL 0x1000 489 #define ICBOPT_FULL_LOGIN 0x2000 490 #define ICBOPT_USE_PORTNAME 0x4000 491 #define ICBOPT_EXTENDED 0x8000 492 493 494 #define ICB_MIN_FRMLEN 256 495 #define ICB_MAX_FRMLEN 2112 496 #define ICB_DFLT_FRMLEN 1024 497 #define ICB_DFLT_ALLOC 256 498 #define ICB_DFLT_THROTTLE 16 499 #define ICB_DFLT_RDELAY 5 500 #define ICB_DFLT_RCOUNT 3 501 502 503 #define RQRSP_ADDR0015 0 504 #define RQRSP_ADDR1631 1 505 #define RQRSP_ADDR3247 2 506 #define RQRSP_ADDR4863 3 507 508 509 #define ICB_NNM0 7 510 #define ICB_NNM1 6 511 #define ICB_NNM2 5 512 #define ICB_NNM3 4 513 #define ICB_NNM4 3 514 #define ICB_NNM5 2 515 #define ICB_NNM6 1 516 #define ICB_NNM7 0 517 518 #define MAKE_NODE_NAME_FROM_WWN(array, wwn) \ 519 array[ICB_NNM0] = (u_int8_t) ((wwn >> 0) & 0xff), \ 520 array[ICB_NNM1] = (u_int8_t) ((wwn >> 8) & 0xff), \ 521 array[ICB_NNM2] = (u_int8_t) ((wwn >> 16) & 0xff), \ 522 array[ICB_NNM3] = (u_int8_t) ((wwn >> 24) & 0xff), \ 523 array[ICB_NNM4] = (u_int8_t) ((wwn >> 32) & 0xff), \ 524 array[ICB_NNM5] = (u_int8_t) ((wwn >> 40) & 0xff), \ 525 array[ICB_NNM6] = (u_int8_t) ((wwn >> 48) & 0xff), \ 526 array[ICB_NNM7] = (u_int8_t) ((wwn >> 56) & 0xff) 527 528 /* 529 * Port Data Base Element 530 */ 531 532 typedef struct { 533 u_int16_t pdb_options; 534 u_int8_t pdb_mstate; 535 u_int8_t pdb_sstate; 536 #define BITS2WORD(x) (x)[0] << 16 | (x)[3] << 8 | (x)[2] 537 u_int8_t pdb_hardaddr_bits[4]; 538 u_int8_t pdb_portid_bits[4]; 539 u_int8_t pdb_nodename[8]; 540 u_int8_t pdb_portname[8]; 541 u_int16_t pdb_execthrottle; 542 u_int16_t pdb_exec_count; 543 u_int8_t pdb_retry_count; 544 u_int8_t pdb_retry_delay; 545 u_int16_t pdb_resalloc; 546 u_int16_t pdb_curalloc; 547 u_int16_t pdb_qhead; 548 u_int16_t pdb_qtail; 549 u_int16_t pdb_tl_next; 550 u_int16_t pdb_tl_last; 551 u_int16_t pdb_features; /* PLOGI, Common Service */ 552 u_int16_t pdb_pconcurrnt; /* PLOGI, Common Service */ 553 u_int16_t pdb_roi; /* PLOGI, Common Service */ 554 u_int8_t pdb_target; 555 u_int8_t pdb_initiator; /* PLOGI, Class 3 Control Flags */ 556 u_int16_t pdb_rdsiz; /* PLOGI, Class 3 */ 557 u_int16_t pdb_ncseq; /* PLOGI, Class 3 */ 558 u_int16_t pdb_noseq; /* PLOGI, Class 3 */ 559 u_int16_t pdb_labrtflg; 560 u_int16_t pdb_lstopflg; 561 u_int16_t pdb_sqhead; 562 u_int16_t pdb_sqtail; 563 u_int16_t pdb_ptimer; 564 u_int16_t pdb_nxt_seqid; 565 u_int16_t pdb_fcount; 566 u_int16_t pdb_prli_len; 567 u_int16_t pdb_prli_svc0; 568 u_int16_t pdb_prli_svc3; 569 u_int16_t pdb_loopid; 570 u_int16_t pdb_il_ptr; 571 u_int16_t pdb_sl_ptr; 572 } isp_pdb_t; 573 574 #define PDB_OPTIONS_XMITTING (1<<11) 575 #define PDB_OPTIONS_LNKXMIT (1<<10) 576 #define PDB_OPTIONS_ABORTED (1<<9) 577 #define PDB_OPTIONS_ADISC (1<<1) 578 579 #define PDB_STATE_DISCOVERY 0 580 #define PDB_STATE_WDISC_ACK 1 581 #define PDB_STATE_PLOGI 2 582 #define PDB_STATE_PLOGI_ACK 3 583 #define PDB_STATE_PRLI 4 584 #define PDB_STATE_PRLI_ACK 5 585 #define PDB_STATE_LOGGED_IN 6 586 #define PDB_STATE_PORT_UNAVAIL 7 587 #define PDB_STATE_PRLO 8 588 #define PDB_STATE_PRLO_ACK 9 589 #define PDB_STATE_PLOGO 10 590 #define PDB_STATE_PLOG_ACK 11 591 592 #define SVC3_TGT_ROLE 0x10 593 #define SVC3_INI_ROLE 0x20 594 #define SVC3_ROLE_MASK 0x30 595 #define SVC3_ROLE_SHIFT 4 596 597 #define SNS_GAN 0x100 598 #define SNS_GP3 0x171 599 typedef struct { 600 u_int16_t snscb_rblen; /* response buffer length (words) */ 601 u_int16_t snscb_res0; 602 u_int16_t snscb_addr[4]; /* response buffer address */ 603 u_int16_t snscb_sblen; /* subcommand buffer length (words) */ 604 u_int16_t snscb_res1; 605 u_int16_t snscb_data[1]; /* variable data */ 606 } sns_screq_t; /* Subcommand Request Structure */ 607 #define SNS_GAN_REQ_SIZE (sizeof (sns_screq_t)+(5*(sizeof (u_int16_t)))) 608 #define SNS_GP3_REQ_SIZE (sizeof (sns_screq_t)+(5*(sizeof (u_int16_t)))) 609 610 typedef struct { 611 u_int8_t snscb_cthdr[16]; 612 u_int8_t snscb_port_type; 613 u_int8_t snscb_port_id[3]; 614 u_int8_t snscb_portname[8]; 615 u_int16_t snscb_data[1]; /* variable data */ 616 } sns_scrsp_t; /* Subcommand Response Structure */ 617 #define SNS_GAN_RESP_SIZE 608 /* Maximum response size (bytes) */ 618 #define SNS_GP3_RESP_SIZE 532 /* XXX: For 128 ports */ 619 620 /* 621 * Target Mode Structures 622 */ 623 #define TGTSVALID 0x80 /* scsi status & sense data valid */ 624 #define SUGGSENSELEN 18 625 626 /* 627 * Structure for Enable Lun and Modify Lun queue entries 628 */ 629 typedef struct { 630 isphdr_t le_header; 631 u_int32_t le_reserved2; 632 u_int8_t le_lun; 633 u_int8_t le_rsvd; 634 u_int8_t le_ops; /* Modify LUN only */ 635 u_int8_t le_tgt; /* Not for FC */ 636 u_int32_t le_flags; /* Not for FC */ 637 u_int8_t le_status; 638 u_int8_t le_rsvd2; 639 u_int8_t le_cmd_count; 640 u_int8_t le_in_count; 641 u_int8_t le_cdb6len; /* Not for FC */ 642 u_int8_t le_cdb7len; /* Not for FC */ 643 u_int16_t le_timeout; 644 u_int16_t le_reserved[20]; 645 } lun_entry_t; 646 647 /* 648 * le_flags values 649 */ 650 #define LUN_TQAE 0x00000001 /* Tagged Queue Action Enable */ 651 #define LUN_DSSM 0x01000000 /* Disable Sending SDP Message */ 652 #define LUN_DM 0x40000000 /* Disconnects Mandatory */ 653 654 /* 655 * le_ops values 656 */ 657 #define LUN_CCINCR 0x01 /* increment command count */ 658 #define LUN_CCDECR 0x02 /* decrement command count */ 659 #define LUN_ININCR 0x40 /* increment immed. notify count */ 660 #define LUN_INDECR 0x80 /* decrement immed. notify count */ 661 662 /* 663 * le_status values 664 */ 665 #define LUN_ERR 0x04 /* request completed with error */ 666 #define LUN_INVAL 0x06 /* invalid request */ 667 #define LUN_NOCAP 0x16 /* can't provide requested capability */ 668 #define LUN_ENABLED 0x3E /* LUN already enabled */ 669 670 /* 671 * Immediate Notify Entry structure 672 */ 673 #define IN_MSGLEN 8 /* 8 bytes */ 674 #define IN_RSVDLEN 8 /* 8 words */ 675 typedef struct { 676 isphdr_t in_header; 677 u_int32_t in_reserved2; 678 u_int8_t in_lun; /* lun */ 679 u_int8_t in_iid; /* initiator */ 680 u_int8_t in_rsvd; 681 u_int8_t in_tgt; /* target */ 682 u_int32_t in_flags; 683 u_int8_t in_status; 684 u_int8_t in_rsvd2; 685 u_int8_t in_tag_val; /* tag value */ 686 u_int8_t in_tag_type; /* tag type */ 687 u_int16_t in_seqid; /* sequence id */ 688 u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */ 689 u_int16_t in_reserved[IN_RSVDLEN]; 690 u_int8_t in_sense[SUGGSENSELEN]; /* suggested sense data */ 691 } in_entry_t; 692 693 typedef struct { 694 isphdr_t in_header; 695 u_int32_t in_reserved2; 696 u_int8_t in_lun; /* lun */ 697 u_int8_t in_iid; /* initiator */ 698 u_int16_t in_rsvd; 699 u_int32_t in_rsvd2; 700 u_int16_t in_status; 701 u_int16_t in_task_flags; 702 u_int16_t in_seqid; /* sequence id */ 703 } in_fcentry_t; 704 705 /* 706 * Values for the in_status field 707 */ 708 #define IN_NO_RCAP 0x16 /* requested capability not available */ 709 #define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */ 710 #define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */ 711 #define IN_MSG_RECEIVED 0x36 /* SCSI message received */ 712 #define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */ 713 #define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */ 714 715 /* 716 * Notify Acknowledge Entry structure 717 */ 718 #define NA_RSVDLEN 22 719 typedef struct { 720 isphdr_t na_header; 721 u_int32_t na_reserved2; 722 u_int8_t na_lun; /* lun */ 723 u_int8_t na_iid; /* initiator */ 724 u_int8_t na_rsvd; 725 u_int8_t na_tgt; /* target */ 726 u_int32_t na_flags; 727 u_int8_t na_status; 728 u_int8_t na_event; 729 u_int16_t na_seqid; /* sequence id */ 730 u_int16_t na_reserved[NA_RSVDLEN]; 731 } na_entry_t; 732 733 /* 734 * Value for the na_event field 735 */ 736 #define NA_RST_CLRD 0x80 /* Clear an async event notification */ 737 738 #define NA2_RSVDLEN 21 739 typedef struct { 740 isphdr_t na_header; 741 u_int32_t na_reserved2; 742 u_int8_t na_lun; /* lun */ 743 u_int8_t na_iid; /* initiator */ 744 u_int16_t na_rsvd; 745 u_int16_t na_flags; 746 u_int16_t na_rsvd2; 747 u_int16_t na_status; 748 u_int16_t na_task_flags; 749 u_int16_t na_seqid; /* sequence id */ 750 u_int16_t na_reserved[NA2_RSVDLEN]; 751 } na_fcentry_t; 752 #define NAFC_RST_CLRD 0x40 753 754 /* 755 * Value for the na_event field 756 */ 757 #define NA_RST_CLRD 0x80 /* Clear an async event notification */ 758 /* 759 * Accept Target I/O Entry structure 760 */ 761 #define ATIO_CDBLEN 26 762 763 typedef struct { 764 isphdr_t at_header; 765 u_int32_t at_reserved2; 766 u_int8_t at_lun; /* lun */ 767 u_int8_t at_iid; /* initiator */ 768 u_int8_t at_cdblen; /* cdb length */ 769 u_int8_t at_tgt; /* target */ 770 u_int32_t at_flags; 771 u_int8_t at_status; /* firmware status */ 772 u_int8_t at_scsi_status; /* scsi status */ 773 u_int8_t at_tag_val; /* tag value */ 774 u_int8_t at_tag_type; /* tag type */ 775 u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */ 776 u_int8_t at_sense[SUGGSENSELEN]; /* suggested sense data */ 777 } at_entry_t; 778 779 /* 780 * at_flags values 781 */ 782 #define AT_NODISC 0x00008000 /* disconnect disabled */ 783 #define AT_TQAE 0x00000001 /* Tagged Queue Action enabled */ 784 785 /* 786 * at_status values 787 */ 788 #define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */ 789 #define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 790 #define AT_NOCAP 0x16 /* Requested capability not available */ 791 #define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 792 #define AT_CDB 0x3D /* CDB received */ 793 794 /* 795 * Accept Target I/O Entry structure, Type 2 796 */ 797 #define ATIO2_CDBLEN 16 798 799 typedef struct { 800 isphdr_t at_header; 801 u_int32_t at_reserved2; 802 u_int8_t at_lun; /* lun */ 803 u_int8_t at_iid; /* initiator */ 804 u_int16_t at_rxid; /* response ID */ 805 u_int16_t at_flags; 806 u_int16_t at_status; /* firmware status */ 807 u_int8_t at_reserved1; 808 u_int8_t at_taskcodes; 809 u_int8_t at_taskflags; 810 u_int8_t at_execodes; 811 u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ 812 u_int32_t at_datalen; /* allocated data len */ 813 u_int16_t at_scclun; 814 u_int16_t at_reserved3; 815 u_int16_t at_scsi_status; 816 u_int8_t at_sense[SUGGSENSELEN]; /* suggested sense data */ 817 } at2_entry_t; 818 819 #define ATIO2_TC_ATTR_MASK 0x7 820 #define ATIO2_TC_ATTR_SIMPLEQ 0 821 #define ATIO2_TC_ATTR_HEADOFQ 1 822 #define ATIO2_TC_ATTR_ORDERED 2 823 #define ATIO2_TC_ATTR_ACAQ 4 824 #define ATIO2_TC_ATTR_UNTAGGED 5 825 #define TC2TT(code) \ 826 (((code) == ATIO2_TC_ATTR_SIMPLEQ)? 0x20 : \ 827 (((code) == ATIO2_TC_ATTR_HEADOFQ)? 0x21 : \ 828 (((code) == ATIO2_TC_ATTR_ORDERED)? 0x22 : \ 829 (((code) == ATIO2_TC_ATTR_ACAQ)? 0x24 : 0)))) 830 831 832 /* 833 * Continue Target I/O Entry structure 834 * Request from driver. The response from the 835 * ISP firmware is the same except that the last 18 836 * bytes are overwritten by suggested sense data if 837 * the 'autosense valid' bit is set in the status byte. 838 */ 839 typedef struct { 840 isphdr_t ct_header; 841 u_int32_t ct_reserved; 842 u_int8_t ct_lun; /* lun */ 843 u_int8_t ct_iid; /* initiator id */ 844 u_int8_t ct_rsvd; 845 u_int8_t ct_tgt; /* our target id */ 846 u_int32_t ct_flags; 847 u_int8_t ct_status; /* isp status */ 848 u_int8_t ct_scsi_status; /* scsi status */ 849 u_int8_t ct_tag_val; /* tag value */ 850 u_int8_t ct_tag_type; /* tag type */ 851 u_int32_t ct_xfrlen; /* transfer length */ 852 u_int32_t ct_resid; /* residual length */ 853 u_int16_t ct_timeout; 854 u_int16_t ct_seg_count; 855 ispds_t ct_dataseg[ISP_RQDSEG]; 856 } ct_entry_t; 857 858 /* 859 * ct_flags values 860 */ 861 #define CT_TQAE 0x00000001 /* Tagged Queue Action enable */ 862 #define CT_DATA_IN 0x00000040 /* Data direction */ 863 #define CT_DATA_OUT 0x00000080 /* Data direction */ 864 #define CT_NO_DATA 0x000000C0 /* Data direction */ 865 #define CT_DATAMASK 0x000000C0 /* Data direction */ 866 #define CT_NODISC 0x00008000 /* Disconnects disabled */ 867 #define CT_DSDP 0x01000000 /* Disable Save Data Pointers */ 868 #define CT_SENDRDP 0x04000000 /* Send Restore Pointers msg */ 869 #define CT_SENDSTATUS 0x80000000 /* Send SCSI status byte */ 870 871 /* 872 * ct_status values 873 * - set by the firmware when it returns the CTIO 874 */ 875 #define CT_OK 0x01 /* completed without error */ 876 #define CT_ABORTED 0x02 /* aborted by host */ 877 #define CT_ERR 0x04 /* see sense data for error */ 878 #define CT_INVAL 0x06 /* request for disabled lun */ 879 #define CT_NOPATH 0x07 /* invalid ITL nexus */ 880 #define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */ 881 #define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */ 882 #define CT_TIMEOUT 0x0B /* timed out */ 883 #define CT_RESET 0x0E /* SCSI Bus Reset occurred */ 884 #define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 885 #define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 886 #define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ 887 #define CT_LOGOUT 0x29 /* port logout not acknowledged yet */ 888 #define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */ 889 890 /* 891 * When the firmware returns a CTIO entry, it may overwrite the last 892 * part of the structure with sense data. This starts at offset 0x2E 893 * into the entry, which is in the middle of ct_dataseg[1]. Rather 894 * than define a new struct for this, I'm just using the sense data 895 * offset. 896 */ 897 #define CTIO_SENSE_OFFSET 0x2E 898 899 /* 900 * Entry length in u_longs. All entries are the same size so 901 * any one will do as the numerator. 902 */ 903 #define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t)) 904 905 /* 906 * QLA2100 CTIO (type 2) entry 907 */ 908 #define MAXRESPLEN 26 909 typedef struct { 910 isphdr_t ct_header; 911 u_int32_t ct_reserved; 912 u_int8_t ct_lun; /* lun */ 913 u_int8_t ct_iid; /* initiator id */ 914 u_int16_t ct_rxid; /* response ID */ 915 u_int16_t ct_flags; 916 u_int16_t ct_status; /* isp status */ 917 u_int16_t ct_timeout; 918 u_int16_t ct_seg_count; 919 u_int32_t ct_reloff; /* relative offset */ 920 u_int32_t ct_resid; /* residual length */ 921 union { 922 /* 923 * The three different modes that the target driver 924 * can set the CTIO2 up as. 925 * 926 * The first is for sending FCP_DATA_IUs as well as 927 * (optionally) sending a terminal SCSI status FCP_RSP_IU. 928 * 929 * The second is for sending SCSI sense data in an FCP_RSP_IU. 930 * Note that no FCP_DATA_IUs will be sent. 931 * 932 * The third is for sending FCP_RSP_IUs as built specifically 933 * in system memory as located by the isp_dataseg. 934 */ 935 struct { 936 u_int32_t _reserved; 937 u_int16_t _reserved2; 938 u_int16_t ct_scsi_status; 939 u_int32_t ct_xfrlen; 940 ispds_t ct_dataseg[ISP_RQDSEG_T2]; 941 } m0; 942 struct { 943 u_int16_t _reserved; 944 u_int16_t _reserved2; 945 u_int16_t ct_senselen; 946 u_int16_t ct_scsi_status; 947 u_int16_t ct_resplen; 948 u_int8_t ct_resp[MAXRESPLEN]; 949 } m1; 950 struct { 951 u_int32_t _reserved; 952 u_int16_t _reserved2; 953 u_int16_t _reserved3; 954 u_int32_t ct_datalen; 955 ispds_t ct_fcp_rsp_iudata; 956 } m2; 957 /* 958 * CTIO2 returned from F/W... 959 */ 960 struct { 961 u_int32_t _reserved[4]; 962 u_int16_t ct_scsi_status; 963 u_int8_t ct_sense[SUGGSENSELEN]; 964 } fw; 965 } rsp; 966 } ct2_entry_t; 967 /* 968 * ct_flags values for CTIO2 969 */ 970 #define CT2_FLAG_MMASK 0x0003 971 #define CT2_FLAG_MODE0 0x0000 972 #define CT2_FLAG_MODE1 0x0001 973 #define CT2_FLAG_MODE2 0x0002 974 #define CT2_DATA_IN CT_DATA_IN 975 #define CT2_DATA_OUT CT_DATA_OUT 976 #define CT2_NO_DATA CT_NO_DATA 977 #define CT2_DATAMASK CT_DATA_MASK 978 #define CT2_CCINCR 0x0100 979 #define CT2_FASTPOST 0x0200 980 #define CT2_SENDSTATUS 0x8000 981 982 /* 983 * ct_status values are (mostly) the same as that for ct_entry. 984 */ 985 986 /* 987 * ct_scsi_status values- the low 8 bits are the normal SCSI status 988 * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU 989 * fields. 990 */ 991 #define CT2_RSPLEN_VALID 0x0100 992 #define CT2_SNSLEN_VALID 0x0200 993 #define CT2_DATA_OVER 0x0400 994 #define CT2_DATA_UNDER 0x0800 995 996 #endif /* _ISPMBOX_H */ 997