isp_target.h revision 64089
1/* $FreeBSD: head/sys/dev/isp/isp_target.h 64089 2000-08-01 06:23:24Z mjacob $ */ 2/* 3 * Qlogic Target Mode Structure and Flag Definitions 4 * 5 * Copyright (c) 1997, 1998 6 * Patrick Stirling 7 * pms@psconsult.com 8 * All rights reserved. 9 * 10 * Additional Copyright (c) 1999 11 * Matthew Jacob 12 * mjacob@feral.com 13 * All rights reserved. 14 * 15 * 16 * Redistribution and use in source and binary forms, with or without 17 * modification, are permitted provided that the following conditions 18 * are met: 19 * 1. Redistributions of source code must retain the above copyright 20 * notice immediately at the beginning of the file, without modification, 21 * this list of conditions, and the following disclaimer. 22 * 2. Redistributions in binary form must reproduce the above copyright 23 * notice, this list of conditions and the following disclaimer in the 24 * documentation and/or other materials provided with the distribution. 25 * 3. The name of the author may not be used to endorse or promote products 26 * derived from this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 */ 39#ifndef _ISPTARGET_H 40#define _ISPTARGET_H 41 42/* 43 * Defines for all entry types 44 */ 45#define QLTM_SVALID 0x80 46#define QLTM_SENSELEN 18 47 48/* 49 * Structure for Enable Lun and Modify Lun queue entries 50 */ 51typedef struct { 52 isphdr_t le_header; 53 u_int32_t le_reserved; 54 u_int8_t le_lun; 55 u_int8_t le_rsvd; 56 u_int8_t le_ops; /* Modify LUN only */ 57 u_int8_t le_tgt; /* Not for FC */ 58 u_int32_t le_flags; /* Not for FC */ 59 u_int8_t le_status; 60 u_int8_t le_reserved2; 61 u_int8_t le_cmd_count; 62 u_int8_t le_in_count; 63 u_int8_t le_cdb6len; /* Not for FC */ 64 u_int8_t le_cdb7len; /* Not for FC */ 65 u_int16_t le_timeout; 66 u_int16_t le_reserved3[20]; 67} lun_entry_t; 68 69/* 70 * le_flags values 71 */ 72#define LUN_TQAE 0x00000001 /* bit1 Tagged Queue Action Enable */ 73#define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */ 74#define LUN_DISAD 0x02000000 /* bit25 Disable autodisconnect */ 75#define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */ 76 77/* 78 * le_ops values 79 */ 80#define LUN_CCINCR 0x01 /* increment command count */ 81#define LUN_CCDECR 0x02 /* decrement command count */ 82#define LUN_ININCR 0x40 /* increment immed. notify count */ 83#define LUN_INDECR 0x80 /* decrement immed. notify count */ 84 85/* 86 * le_status values 87 */ 88#define LUN_OK 0x01 /* we be rockin' */ 89#define LUN_ERR 0x04 /* request completed with error */ 90#define LUN_INVAL 0x06 /* invalid request */ 91#define LUN_NOCAP 0x16 /* can't provide requested capability */ 92#define LUN_ENABLED 0x3E /* LUN already enabled */ 93 94/* 95 * Immediate Notify Entry structure 96 */ 97#define IN_MSGLEN 8 /* 8 bytes */ 98#define IN_RSVDLEN 8 /* 8 words */ 99typedef struct { 100 isphdr_t in_header; 101 u_int32_t in_reserved; 102 u_int8_t in_lun; /* lun */ 103 u_int8_t in_iid; /* initiator */ 104 u_int8_t in_reserved2; 105 u_int8_t in_tgt; /* target */ 106 u_int32_t in_flags; 107 u_int8_t in_status; 108 u_int8_t in_rsvd2; 109 u_int8_t in_tag_val; /* tag value */ 110 u_int8_t in_tag_type; /* tag type */ 111 u_int16_t in_seqid; /* sequence id */ 112 u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */ 113 u_int16_t in_reserved3[IN_RSVDLEN]; 114 u_int8_t in_sense[QLTM_SENSELEN];/* suggested sense data */ 115} in_entry_t; 116 117typedef struct { 118 isphdr_t in_header; 119 u_int32_t in_reserved; 120 u_int8_t in_lun; /* lun */ 121 u_int8_t in_iid; /* initiator */ 122 u_int16_t in_scclun; 123 u_int32_t in_reserved2; 124 u_int16_t in_status; 125 u_int16_t in_task_flags; 126 u_int16_t in_seqid; /* sequence id */ 127} in_fcentry_t; 128 129/* 130 * Values for the in_status field 131 */ 132#define IN_REJECT 0x0D /* Message Reject message received */ 133#define IN_RESET 0x0E /* Bus Reset occurred */ 134#define IN_NO_RCAP 0x16 /* requested capability not available */ 135#define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */ 136#define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */ 137#define IN_MSG_RECEIVED 0x36 /* SCSI message received */ 138#define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */ 139#define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */ 140#define IN_PORT_CHANGED 0x2A /* port changed */ 141#define IN_GLOBAL_LOGO 0x2E /* all ports logged out */ 142#define IN_NO_NEXUS 0x3B /* Nexus not established */ 143 144/* 145 * Values for the in_task_flags field- should only get one at a time! 146 */ 147#define TASK_FLAGS_ABORT_TASK (1<<9) 148#define TASK_FLAGS_CLEAR_TASK_SET (1<<10) 149#define TASK_FLAGS_TARGET_RESET (1<<13) 150#define TASK_FLAGS_CLEAR_ACA (1<<14) 151#define TASK_FLAGS_TERMINATE_TASK (1<<15) 152 153#ifndef MSG_ABORT_TAG 154#define MSG_ABORT_TAG 0x06 155#endif 156#ifndef MSG_CLEAR_QUEUE 157#define MSG_CLEAR_QUEUE 0x0e 158#endif 159#ifndef MSG_BUS_DEV_RESET 160#define MSG_BUS_DEV_RESET 0x0b 161#endif 162#ifndef MSG_REL_RECOVERY 163#define MSG_REL_RECOVERY 0x10 164#endif 165#ifndef MSG_TERM_IO_PROC 166#define MSG_TERM_IO_PROC 0x11 167#endif 168 169 170/* 171 * Notify Acknowledge Entry structure 172 */ 173#define NA_RSVDLEN 22 174typedef struct { 175 isphdr_t na_header; 176 u_int32_t na_reserved; 177 u_int8_t na_lun; /* lun */ 178 u_int8_t na_iid; /* initiator */ 179 u_int8_t na_reserved2; 180 u_int8_t na_tgt; /* target */ 181 u_int32_t na_flags; 182 u_int8_t na_status; 183 u_int8_t na_event; 184 u_int16_t na_seqid; /* sequence id */ 185 u_int16_t na_reserved3[NA_RSVDLEN]; 186} na_entry_t; 187 188/* 189 * Value for the na_event field 190 */ 191#define NA_RST_CLRD 0x80 /* Clear an async event notification */ 192#define NA_OK 0x01 /* Notify Acknowledge Succeeded */ 193#define NA_INVALID 0x06 /* Invalid Notify Acknowledge */ 194 195#define NA2_RSVDLEN 21 196typedef struct { 197 isphdr_t na_header; 198 u_int32_t na_reserved; 199 u_int8_t na_lun; /* lun */ 200 u_int8_t na_iid; /* initiator */ 201 u_int16_t na_scclun; 202 u_int16_t na_flags; 203 u_int16_t na_reserved2; 204 u_int16_t na_status; 205 u_int16_t na_task_flags; 206 u_int16_t na_seqid; /* sequence id */ 207 u_int16_t na_reserved3[NA2_RSVDLEN]; 208} na_fcentry_t; 209#define NAFC_RCOUNT 0x80 /* increment resource count */ 210#define NAFC_RST_CLRD 0x20 /* Clear LIP Reset */ 211/* 212 * Accept Target I/O Entry structure 213 */ 214#define ATIO_CDBLEN 26 215 216typedef struct { 217 isphdr_t at_header; 218 u_int32_t at_reserved; 219 u_int8_t at_lun; /* lun */ 220 u_int8_t at_iid; /* initiator */ 221 u_int8_t at_cdblen; /* cdb length */ 222 u_int8_t at_tgt; /* target */ 223 u_int32_t at_flags; 224 u_int8_t at_status; /* firmware status */ 225 u_int8_t at_scsi_status; /* scsi status */ 226 u_int8_t at_tag_val; /* tag value */ 227 u_int8_t at_tag_type; /* tag type */ 228 u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */ 229 u_int8_t at_sense[QLTM_SENSELEN];/* suggested sense data */ 230} at_entry_t; 231 232/* 233 * at_flags values 234 */ 235#define AT_NODISC 0x00008000 /* disconnect disabled */ 236#define AT_TQAE 0x00000001 /* Tagged Queue Action enabled */ 237 238/* 239 * at_status values 240 */ 241#define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */ 242#define AT_RESET 0x0E /* SCSI Bus Reset Occurred */ 243#define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 244#define AT_NOCAP 0x16 /* Requested capability not available */ 245#define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 246#define AT_CDB 0x3D /* CDB received */ 247 248/* 249 * Accept Target I/O Entry structure, Type 2 250 */ 251#define ATIO2_CDBLEN 16 252 253typedef struct { 254 isphdr_t at_header; 255 u_int32_t at_reserved; 256 u_int8_t at_lun; /* lun or reserved */ 257 u_int8_t at_iid; /* initiator */ 258 u_int16_t at_rxid; /* response ID */ 259 u_int16_t at_flags; 260 u_int16_t at_status; /* firmware status */ 261 u_int8_t at_reserved1; 262 u_int8_t at_taskcodes; 263 u_int8_t at_taskflags; 264 u_int8_t at_execodes; 265 u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ 266 u_int32_t at_datalen; /* allocated data len */ 267 u_int16_t at_scclun; /* SCC Lun or reserved */ 268 u_int16_t at_reserved2; 269 u_int16_t at_scsi_status; 270 u_int8_t at_sense[QLTM_SENSELEN]; 271} at2_entry_t; 272 273#define ATIO2_TC_ATTR_MASK 0x7 274#define ATIO2_TC_ATTR_SIMPLEQ 0 275#define ATIO2_TC_ATTR_HEADOFQ 1 276#define ATIO2_TC_ATTR_ORDERED 2 277#define ATIO2_TC_ATTR_ACAQ 4 278#define ATIO2_TC_ATTR_UNTAGGED 5 279 280/* 281 * Continue Target I/O Entry structure 282 * Request from driver. The response from the 283 * ISP firmware is the same except that the last 18 284 * bytes are overwritten by suggested sense data if 285 * the 'autosense valid' bit is set in the status byte. 286 */ 287typedef struct { 288 isphdr_t ct_header; 289 u_int32_t ct_reserved; 290 u_int8_t ct_lun; /* lun */ 291 u_int8_t ct_iid; /* initiator id */ 292 u_int8_t ct_reserved2; 293 u_int8_t ct_tgt; /* our target id */ 294 u_int32_t ct_flags; 295 u_int8_t ct_status; /* isp status */ 296 u_int8_t ct_scsi_status; /* scsi status */ 297 u_int8_t ct_tag_val; /* tag value */ 298 u_int8_t ct_tag_type; /* tag type */ 299 u_int32_t ct_xfrlen; /* transfer length */ 300 u_int32_t ct_resid; /* residual length */ 301 u_int16_t ct_timeout; 302 u_int16_t ct_seg_count; 303 ispds_t ct_dataseg[ISP_RQDSEG]; 304} ct_entry_t; 305 306/* 307 * For some of the dual port SCSI adapters, port (bus #) is reported 308 * in the MSbit of ct_iid. Bit fields are a bit too awkward here. 309 * 310 * Note that this does not apply to FC adapters at all which can and 311 * do report IIDs between 129 && 255 (these represent devices that have 312 * logged in across a SCSI fabric). 313 */ 314#define GET_IID_VAL(x) (x & 0x3f) 315#define GET_BUS_VAL(x) ((x >> 7) & 0x1) 316#define SET_IID_VAL(y, x) (y | (x & 0x3f)) 317#define SET_BUS_VAL(y, x) (y | ((x & 0x1) << 7)) 318 319/* 320 * ct_flags values 321 */ 322#define CT_TQAE 0x00000001 /* bit 1, Tagged Queue Action enable */ 323#define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */ 324#define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */ 325#define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */ 326#define CT_CCINCR 0x00000100 /* bit 8, autoincrement atio count */ 327#define CT_DATAMASK 0x000000C0 /* bits 6&7, Data direction */ 328#define CT_INISYNCWIDE 0x00004000 /* bit 14, Do Sync/Wide Negotiation */ 329#define CT_NODISC 0x00008000 /* bit 15, Disconnects disabled */ 330#define CT_DSDP 0x01000000 /* bit 24, Disable Save Data Pointers */ 331#define CT_SENDRDP 0x04000000 /* bit 26, Send Restore Pointers msg */ 332#define CT_SENDSTATUS 0x80000000 /* bit 31, Send SCSI status byte */ 333 334/* 335 * ct_status values 336 * - set by the firmware when it returns the CTIO 337 */ 338#define CT_OK 0x01 /* completed without error */ 339#define CT_ABORTED 0x02 /* aborted by host */ 340#define CT_ERR 0x04 /* see sense data for error */ 341#define CT_INVAL 0x06 /* request for disabled lun */ 342#define CT_NOPATH 0x07 /* invalid ITL nexus */ 343#define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */ 344#define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */ 345#define CT_TIMEOUT 0x0B /* timed out */ 346#define CT_RESET 0x0E /* SCSI Bus Reset occurred */ 347#define CT_PARITY 0x0F /* Uncorrectable Parity Error */ 348#define CT_PANIC 0x13 /* Unrecoverable Error */ 349#define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 350#define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 351#define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ 352#define CT_PORTNOTAVAIL 0x28 /* port not available */ 353#define CT_LOGOUT 0x29 /* port logout */ 354#define CT_PORTCHANGED 0x2A /* port changed */ 355#define CT_IDE 0x33 /* Initiator Detected Error */ 356#define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */ 357 358/* 359 * When the firmware returns a CTIO entry, it may overwrite the last 360 * part of the structure with sense data. This starts at offset 0x2E 361 * into the entry, which is in the middle of ct_dataseg[1]. Rather 362 * than define a new struct for this, I'm just using the sense data 363 * offset. 364 */ 365#define CTIO_SENSE_OFFSET 0x2E 366 367/* 368 * Entry length in u_longs. All entries are the same size so 369 * any one will do as the numerator. 370 */ 371#define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t)) 372 373/* 374 * QLA2100 CTIO (type 2) entry 375 */ 376#define MAXRESPLEN 26 377typedef struct { 378 isphdr_t ct_header; 379 u_int32_t ct_reserved; 380 u_int8_t ct_lun; /* lun */ 381 u_int8_t ct_iid; /* initiator id */ 382 u_int16_t ct_rxid; /* response ID */ 383 u_int16_t ct_flags; 384 u_int16_t ct_status; /* isp status */ 385 u_int16_t ct_timeout; 386 u_int16_t ct_seg_count; 387 u_int32_t ct_reloff; /* relative offset */ 388 int32_t ct_resid; /* residual length */ 389 union { 390 /* 391 * The three different modes that the target driver 392 * can set the CTIO2 up as. 393 * 394 * The first is for sending FCP_DATA_IUs as well as 395 * (optionally) sending a terminal SCSI status FCP_RSP_IU. 396 * 397 * The second is for sending SCSI sense data in an FCP_RSP_IU. 398 * Note that no FCP_DATA_IUs will be sent. 399 * 400 * The third is for sending FCP_RSP_IUs as built specifically 401 * in system memory as located by the isp_dataseg. 402 */ 403 struct { 404 u_int32_t _reserved; 405 u_int16_t _reserved2; 406 u_int16_t ct_scsi_status; 407 u_int32_t ct_xfrlen; 408 ispds_t ct_dataseg[ISP_RQDSEG_T2]; 409 } m0; 410 struct { 411 u_int16_t _reserved; 412 u_int16_t _reserved2; 413 u_int16_t ct_senselen; 414 u_int16_t ct_scsi_status; 415 u_int16_t ct_resplen; 416 u_int8_t ct_resp[MAXRESPLEN]; 417 } m1; 418 struct { 419 u_int32_t _reserved; 420 u_int16_t _reserved2; 421 u_int16_t _reserved3; 422 u_int32_t ct_datalen; 423 ispds_t ct_fcp_rsp_iudata; 424 } m2; 425 /* 426 * CTIO2 returned from F/W... 427 */ 428 struct { 429 u_int32_t _reserved[4]; 430 u_int16_t ct_scsi_status; 431 u_int8_t ct_sense[QLTM_SENSELEN]; 432 } fw; 433 } rsp; 434} ct2_entry_t; 435 436/* 437 * ct_flags values for CTIO2 438 */ 439#define CT2_FLAG_MMASK 0x0003 440#define CT2_FLAG_MODE0 0x0000 441#define CT2_FLAG_MODE1 0x0001 442#define CT2_FLAG_MODE2 0x0002 443#define CT2_DATA_IN CT_DATA_IN 444#define CT2_DATA_OUT CT_DATA_OUT 445#define CT2_NO_DATA CT_NO_DATA 446#define CT2_DATAMASK CT_DATAMASK 447#define CT2_CCINCR 0x0100 448#define CT2_FASTPOST 0x0200 449#define CT2_SENDSTATUS 0x8000 450 451/* 452 * ct_status values are (mostly) the same as that for ct_entry. 453 */ 454 455/* 456 * ct_scsi_status values- the low 8 bits are the normal SCSI status 457 * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU 458 * fields. 459 */ 460#define CT2_RSPLEN_VALID 0x0100 461#define CT2_SNSLEN_VALID 0x0200 462#define CT2_DATA_OVER 0x0400 463#define CT2_DATA_UNDER 0x0800 464 465/* 466 * Macros for packing/unpacking the above structures 467 */ 468 469#ifdef __sparc__ 470#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \ 471 if (isp->isp_bus == ISP_SBUS) { \ 472 source -> taga = dest -> tagb; \ 473 source -> tagb = dest -> taga; \ 474 } else { \ 475 source -> taga = dest -> taga; \ 476 source -> tagb = dest -> taga; \ 477 } 478#else 479#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \ 480 source -> taga = dest -> taga; \ 481 source -> tagb = dest -> taga; 482#endif 483 484#define MCIDF(d, s) if ((void *) d != (void *)s) MEMCPY(d, s, QENTRY_LEN) 485 486/* This is really only for SBus cards on a sparc */ 487#ifdef __sparc__ 488#define ISP_SWIZ_ATIO(isp, dest, vsrc) \ 489{ \ 490 at_entry_t *source = (at_entry_t *) vsrc; \ 491 at_entry_t local, *vdst; \ 492 if ((void *)dest == (void *)vsrc) { \ 493 MEMCPY(vsrc, &local, sizeof (at_entry_t)); \ 494 vdst = &local; \ 495 } else { \ 496 vdst = dest; \ 497 } \ 498 vdst->at_header = source->at_header; \ 499 vdst->at_reserved2 = source->at_reserved2; \ 500 ISP_SBUS_SWOZZLE(isp, source, vdst, at_lun, at_iid); \ 501 ISP_SBUS_SWOZZLE(isp, source, vdst, at_cdblen, at_tgt); \ 502 vdst->at_flags = source->at_flags; \ 503 ISP_SBUS_SWOZZLE(isp, source, vdst, at_status, at_scsi_status); \ 504 ISP_SBUS_SWOZZLE(isp, source, vdst, at_tag_val, at_tag_type); \ 505 MEMCPY(vdst->at_cdb, source->at_cdb, ATIO_CDBLEN); \ 506 MEMCPY(vdst->at_sense, source->at_sense, QLTM_SENSELEN); \ 507} 508 509#define ISP_SWIZ_CTIO(isp, dest, vsrc) \ 510{ \ 511 ct_entry_t *source = (ct_entry_t *) vsrc; \ 512 ct_entry_t *local, *vdst; \ 513 if ((void *)dest == (void *)vsrc) { \ 514 MEMCPY(vsrc, &local, sizeof (ct_entry_t)); \ 515 vdst = &local; \ 516 } else { \ 517 vdst = dest; \ 518 } \ 519 vdst->ct_header = source->ct_header; \ 520 vdst->ct_reserved = source->ct_reserved; \ 521 ISP_SBUS_SWOZZLE(isp, source, vdst, ct_lun, ct_iid); \ 522 ISP_SBUS_SWOZZLE(isp, source, vdst, ct_rsvd, ct_tgt); \ 523 vdst->ct_flags = source->ct_flags; \ 524 ISP_SBUS_SWOZZLE(isp, source, vdst, ct_status, ct_scsi_status); \ 525 ISP_SBUS_SWOZZLE(isp, source, vdst, ct_tag_val, ct_tag_type); \ 526 vdst->ct_xfrlen = source->ct_xfrlen; \ 527 vdst->ct_resid = source->ct_resid; \ 528 vdst->ct_timeout = source->ct_timeout; \ 529 vdst->ct_seg_count = source->ct_seg_count; \ 530 MEMCPY(vdst->ct_cdb, source->ct_cdb, ATIO_CDBLEN); \ 531 MEMCPY(vdst->ct_sense, source->ct_sense, QLTM_SENSELEN); \ 532 vdst->ct_dataseg = source->ct_dataseg; \ 533} 534#define ISP_SWIZ_ENABLE_LUN(isp, dest, vsrc) \ 535{ \ 536 lun_entry_t *source = (lun_entry_t *)vsrc; \ 537 lun_entry_t *local, *vdst; \ 538 if ((void *)dest == (void *)vsrc) { \ 539 MEMCPY(vsrc, &local, sizeof (lun_entry_t)); \ 540 vdst = &local; \ 541 } else { \ 542 vdst = dest; \ 543 } \ 544 vdst->le_header = source->le_header; \ 545 vdst->le_reserved2 = source->le_reserved2; \ 546 ISP_SBUS_SWOZZLE(isp, source, vdst, le_lun, le_rsvd); \ 547 ISP_SBUS_SWOZZLE(isp, source, vdst, le_ops, le_tgt); \ 548 vdst->le_flags = source->le_flags; \ 549 ISP_SBUS_SWOZZLE(isp, source, vdst, le_status, le_rsvd2); \ 550 ISP_SBUS_SWOZZLE(isp, source, vdst, le_cmd_count, le_in_count); \ 551 ISP_SBUS_SWOZZLE(isp, source, vdst, le_cdb6len, le_cdb7len); \ 552 vdst->le_timeout = source->le_timeout; \ 553 vdst->le_reserved = source->le_reserved; \ 554} 555#define ISP_SWIZ_NOTIFY(isp, dest, vsrc) \ 556{ \ 557 in_entry_type *source = (in_entry_t *)vsrc; \ 558 in_entry_t *local, *vdst; \ 559 if ((void *)dest == (void *)vsrc) { \ 560 MEMCPY(vsrc, &local, sizeof (in_entry_t)); \ 561 vdst = &local; \ 562 } else { \ 563 vdst = dest; \ 564 } \ 565 vdst->in_header = source->in_header; \ 566 vdst->in_reserved2 = source->in_reserved2; \ 567 ISP_SBUS_SWOZZLE(isp, source, vdst, in_lun, in_iid); \ 568 ISP_SBUS_SWOZZLE(isp, source, vdst, in_rsvd, in_tgt); \ 569 vdst->in_flags = source->in_flags; \ 570 ISP_SBUS_SWOZZLE(isp, source, vdst, in_status, in_rsvd2); \ 571 ISP_SBUS_SWOZZLE(isp, source, vdst, in_tag_val, in_tag_type); \ 572 vdst->in_seqid = source->in_seqid; \ 573 MEMCPY(vdst->in_msg, source->in_msg, IN_MSGLEN); \ 574 MEMCPY(vdst->in_reserved, source->in_reserved, IN_RESERVED); \ 575 MEMCPY(vdst->in_sense, source->in_sense, QLTM_SENSELEN); \ 576} 577#define ISP_SWIZ_NOT_ACK(isp, dest) \ 578{ \ 579 na_entry_t *source = (na_entry_t *)vsrc; \ 580 na_entry_t *local, *vdst; \ 581 if ((void *)dest == (void *)vsrc) { \ 582 MEMCPY(vsrc, &local, sizeof (na_entry_t)); \ 583 vdst = &local; \ 584 } else { \ 585 vdst = dest; \ 586 } \ 587 vdst->na_header = source->na_header; \ 588 vdst->na_reserved2 = source->na_reserved2; \ 589 ISP_SBUS_SWOZZLE(isp, source, vdst, na_lun, na_iid); \ 590 ISP_SBUS_SWOZZLE(isp, source, vdst, na_rsvd, na_tgt); \ 591 vdst->na_flags = source->na_flags; \ 592 ISP_SBUS_SWOZZLE(isp, source, vdst, na_status, na_event); \ 593 vdst->na_seqid = source->na_seqid; \ 594 MEMCPY(vdst->na_reserved, source->na_reserved, NA_RSVDLEN); \ 595} 596#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MCIDF(d, s) 597#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s) 598#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s) 599#else 600#define ISP_SWIZ_ATIO(isp, d, s) MCIDF(d, s) 601#define ISP_SWIZ_CTIO(isp, d, s) MCIDF(d, s) 602#define ISP_SWIZ_ENABLE_LUN(isp, d, s) MCIDF(d, s) 603#define ISP_SWIZ_NOTIFY(isp, d, s) MCIDF(d, s) 604#define ISP_SWIZ_NOT_ACK(isp, d, s) MCIDF(d, s) 605#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MCIDF(d, s) 606#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s) 607#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s) 608#endif 609 610/* 611 * Debug macros 612 */ 613 614#define ISP_TDQE(isp, msg, idx, arg) \ 615 if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg) 616 617/* 618 * The functions below are target mode functions that 619 * are generally internal to the Qlogic driver. 620 */ 621 622/* 623 * This function handles new response queue entry appropriate for target mode. 624 */ 625int isp_target_notify __P((struct ispsoftc *, void *, u_int16_t *)); 626 627/* 628 * Enable/Disable/Modify a logical unit. 629 */ 630#define DFLT_CMD_CNT 32 /* XX */ 631#define DFLT_INOTIFY (4) 632int isp_lun_cmd __P((struct ispsoftc *, int, int, int, int, u_int32_t)); 633 634/* 635 * General request queue 'put' routine for target mode entries. 636 */ 637int isp_target_put_entry __P((struct ispsoftc *isp, void *)); 638 639/* 640 * General routine to put back an ATIO entry- 641 * used for replenishing f/w resource counts. 642 */ 643int 644isp_target_put_atio __P((struct ispsoftc *, int, int, int, int, int)); 645 646/* 647 * General routine to send a final CTIO for a command- used mostly for 648 * local responses. 649 */ 650int 651isp_endcmd __P((struct ispsoftc *, void *, u_int32_t, u_int32_t)); 652#define ECMD_SVALID 0x100 653 654/* 655 * Handle an asynchronous event 656 */ 657 658void isp_target_async __P((struct ispsoftc *, int, int)); 659 660#endif /* _ISPTARGET_H */ 661