isp_target.h revision 55372
1221828Sgrehan/* $FreeBSD: head/sys/dev/isp/isp_target.h 55372 2000-01-03 23:58:41Z mjacob $ */ 2221828Sgrehan/* 3221828Sgrehan * Qlogic Target Mode Structure and Flag Definitions 4221828Sgrehan * 5221828Sgrehan * Copyright (c) 1997, 1998 6221828Sgrehan * Patrick Stirling 7221828Sgrehan * pms@psconsult.com 8221828Sgrehan * All rights reserved. 9221828Sgrehan * 10221828Sgrehan * Additional Copyright (c) 1999 11221828Sgrehan * Matthew Jacob 12221828Sgrehan * mjacob@feral.com 13221828Sgrehan * All rights reserved. 14221828Sgrehan * 15221828Sgrehan * 16221828Sgrehan * Redistribution and use in source and binary forms, with or without 17221828Sgrehan * modification, are permitted provided that the following conditions 18221828Sgrehan * are met: 19221828Sgrehan * 1. Redistributions of source code must retain the above copyright 20221828Sgrehan * notice immediately at the beginning of the file, without modification, 21221828Sgrehan * this list of conditions, and the following disclaimer. 22221828Sgrehan * 2. Redistributions in binary form must reproduce the above copyright 23221828Sgrehan * notice, this list of conditions and the following disclaimer in the 24221828Sgrehan * documentation and/or other materials provided with the distribution. 25221828Sgrehan * 3. The name of the author may not be used to endorse or promote products 26245678Sneel * derived from this software without specific prior written permission. 27221828Sgrehan * 28221828Sgrehan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 29221828Sgrehan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30221828Sgrehan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31221828Sgrehan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 32221828Sgrehan * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33221828Sgrehan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34221828Sgrehan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35221828Sgrehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36221828Sgrehan * SUCH DAMAGE. 37262506Sneel * 38221828Sgrehan */ 39221828Sgrehan#ifndef _ISPTARGET_H 40221828Sgrehan#define _ISPTARGET_H 41221828Sgrehan 42258579Sneel/* 43258075Sneel * Defines for all entry types 44221828Sgrehan */ 45256072Sneel#define QLTM_SVALID 0x80 46256072Sneel#define QLTM_SENSELEN 18 47256072Sneel 48221828Sgrehan/* 49240922Sneel * Structure for Enable Lun and Modify Lun queue entries 50240922Sneel */ 51260466Sneeltypedef struct { 52221828Sgrehan isphdr_t le_header; 53259782Sjhb u_int32_t le_reserved; 54256072Sneel u_int8_t le_lun; 55256072Sneel u_int8_t le_rsvd; 56263780Sneel u_int8_t le_ops; /* Modify LUN only */ 57263780Sneel u_int8_t le_tgt; /* Not for FC */ 58221828Sgrehan u_int32_t le_flags; /* Not for FC */ 59221828Sgrehan u_int8_t le_status; 60221828Sgrehan u_int8_t le_reserved2; 61221828Sgrehan u_int8_t le_cmd_count; 62221828Sgrehan u_int8_t le_in_count; 63221828Sgrehan u_int8_t le_cdb6len; /* Not for FC */ 64221828Sgrehan u_int8_t le_cdb7len; /* Not for FC */ 65221828Sgrehan u_int16_t le_timeout; 66221828Sgrehan u_int16_t le_reserved3[20]; 67221828Sgrehan} lun_entry_t; 68221828Sgrehan 69256072Sneel/* 70256072Sneel * le_flags values 71259863Sneel */ 72259863Sneel#define LUN_TQAE 0x00000001 /* bit1 Tagged Queue Action Enable */ 73221828Sgrehan#define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */ 74221828Sgrehan#define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */ 75221828Sgrehan 76221828Sgrehan/* 77259782Sjhb * le_ops values 78221828Sgrehan */ 79221828Sgrehan#define LUN_CCINCR 0x01 /* increment command count */ 80221828Sgrehan#define LUN_CCDECR 0x02 /* decrement command count */ 81221828Sgrehan#define LUN_ININCR 0x40 /* increment immed. notify count */ 82221828Sgrehan#define LUN_INDECR 0x80 /* decrement immed. notify count */ 83221828Sgrehan 84221828Sgrehan/* 85221828Sgrehan * le_status values 86221828Sgrehan */ 87221828Sgrehan#define LUN_OK 0x01 /* we be rockin' */ 88256072Sneel#define LUN_ERR 0x04 /* request completed with error */ 89256072Sneel#define LUN_INVAL 0x06 /* invalid request */ 90259863Sneel#define LUN_NOCAP 0x16 /* can't provide requested capability */ 91259863Sneel#define LUN_ENABLED 0x3E /* LUN already enabled */ 92221828Sgrehan 93221828Sgrehan/* 94221828Sgrehan * Immediate Notify Entry structure 95221828Sgrehan */ 96221828Sgrehan#define IN_MSGLEN 8 /* 8 bytes */ 97249396Sneel#define IN_RSVDLEN 8 /* 8 words */ 98221828Sgrehantypedef struct { 99221828Sgrehan isphdr_t in_header; 100241041Sneel u_int32_t in_reserved; 101221828Sgrehan u_int8_t in_lun; /* lun */ 102221828Sgrehan u_int8_t in_iid; /* initiator */ 103256072Sneel u_int8_t in_reserved2; 104256072Sneel u_int8_t in_tgt; /* target */ 105256072Sneel u_int32_t in_flags; 106221828Sgrehan u_int8_t in_status; 107221828Sgrehan u_int8_t in_rsvd2; 108256072Sneel u_int8_t in_tag_val; /* tag value */ 109256072Sneel u_int8_t in_tag_type; /* tag type */ 110256072Sneel u_int16_t in_seqid; /* sequence id */ 111221828Sgrehan u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */ 112221828Sgrehan u_int16_t in_reserved3[IN_RSVDLEN]; 113221828Sgrehan u_int8_t in_sense[QLTM_SENSELEN];/* suggested sense data */ 114221828Sgrehan} in_entry_t; 115221828Sgrehan 116221828Sgrehantypedef struct { 117221828Sgrehan isphdr_t in_header; 118263780Sneel u_int32_t in_reserved; 119221828Sgrehan u_int8_t in_lun; /* lun */ 120241982Sneel u_int8_t in_iid; /* initiator */ 121241982Sneel u_int16_t in_scclun; 122263211Stychon u_int32_t in_reserved2; 123263211Stychon u_int16_t in_status; 124263211Stychon u_int16_t in_task_flags; 125221828Sgrehan u_int16_t in_seqid; /* sequence id */ 126221828Sgrehan} in_fcentry_t; 127258075Sneel 128258579Sneel/* 129221828Sgrehan * Values for the in_status field 130221828Sgrehan */ 131240922Sneel#define IN_RESET 0x0E /* Bus Reset occurred */ 132240922Sneel#define IN_NO_RCAP 0x16 /* requested capability not available */ 133258075Sneel#define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */ 134221828Sgrehan#define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */ 135223621Sgrehan#define IN_MSG_RECEIVED 0x36 /* SCSI message received */ 136240894Sneel#define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */ 137221828Sgrehan#define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */ 138221828Sgrehan#define IN_PORT_CHANGED 0x2A /* port changed */ 139260619Sneel#define IN_GLOBAL_LOGO 0x2E /* all ports logged out */ 140260619Sneel 141260619Sneel/* 142260619Sneel * Values for the in_task_flags field- should only get one at a time! 143260619Sneel */ 144260619Sneel#define TASK_FLAGS_ABORT_TASK (1<<9) 145260619Sneel#define TASK_FLAGS_CLEAR_TASK_SET (1<<10) 146260619Sneel#define TASK_FLAGS_TARGET_RESET (1<<13) 147260619Sneel#define TASK_FLAGS_CLEAR_ACA (1<<14) 148260619Sneel#define TASK_FLAGS_TERMINATE_TASK (1<<15) 149260619Sneel 150260619Sneel#ifndef MSG_ABORT_TAG 151260619Sneel#define MSG_ABORT_TAG 0x06 152260619Sneel#endif 153260619Sneel#ifndef MSG_CLEAR_QUEUE 154260619Sneel#define MSG_CLEAR_QUEUE 0x0e 155260619Sneel#endif 156260619Sneel#ifndef MSG_BUS_DEV_RESET 157260619Sneel#define MSG_BUS_DEV_RESET 0x0b 158260619Sneel#endif 159260619Sneel#ifndef MSG_REL_RECOVERY 160260619Sneel#define MSG_REL_RECOVERY 0x10 161260619Sneel#endif 162260619Sneel#ifndef MSG_TERM_IO_PROC 163263780Sneel#define MSG_TERM_IO_PROC 0x11 164263780Sneel#endif 165263780Sneel 166263780Sneel 167263780Sneel/* 168263780Sneel * Notify Acknowledge Entry structure 169263780Sneel */ 170260619Sneel#define NA_RSVDLEN 22 171221828Sgrehantypedef struct { 172221828Sgrehan isphdr_t na_header; 173221828Sgrehan u_int32_t na_reserved; 174221828Sgrehan u_int8_t na_lun; /* lun */ 175221828Sgrehan u_int8_t na_iid; /* initiator */ 176221828Sgrehan u_int8_t na_reserved2; 177221828Sgrehan u_int8_t na_tgt; /* target */ 178221828Sgrehan u_int32_t na_flags; 179221828Sgrehan u_int8_t na_status; 180241489Sneel u_int8_t na_event; 181241489Sneel u_int16_t na_seqid; /* sequence id */ 182256072Sneel u_int16_t na_reserved3[NA_RSVDLEN]; 183241489Sneel} na_entry_t; 184256072Sneel 185241489Sneel/* 186221828Sgrehan * Value for the na_event field 187259737Sneel */ 188259737Sneel#define NA_RST_CLRD 0x80 /* Clear an async event notification */ 189249879Sgrehan 190221828Sgrehan#define NA2_RSVDLEN 21 191221828Sgrehantypedef struct { 192249879Sgrehan isphdr_t na_header; 193221828Sgrehan u_int32_t na_reserved; 194249879Sgrehan u_int8_t na_lun; /* lun */ 195221828Sgrehan u_int8_t na_iid; /* initiator */ 196221828Sgrehan u_int16_t na_scclun; 197241489Sneel u_int16_t na_flags; 198259863Sneel u_int16_t na_reserved2; 199256072Sneel u_int16_t na_status; 200256072Sneel u_int16_t na_task_flags; 201256072Sneel u_int16_t na_seqid; /* sequence id */ 202263035Stychon u_int16_t na_reserved3[NA2_RSVDLEN]; 203263744Stychon} na_fcentry_t; 204262506Sneel#define NAFC_RCOUNT 0x80 /* increment resource count */ 205262506Sneel#define NAFC_RST_CLRD 0x20 /* Clear LIP Reset */ 206262506Sneel/* 207262506Sneel * Accept Target I/O Entry structure 208262506Sneel */ 209262506Sneel#define ATIO_CDBLEN 26 210262506Sneel 211262506Sneeltypedef struct { 212262506Sneel isphdr_t at_header; 213262506Sneel u_int32_t at_reserved; 214262506Sneel u_int8_t at_lun; /* lun */ 215262506Sneel u_int8_t at_iid; /* initiator */ 216262506Sneel u_int8_t at_cdblen; /* cdb length */ 217262506Sneel u_int8_t at_tgt; /* target */ 218262506Sneel u_int32_t at_flags; 219262506Sneel u_int8_t at_status; /* firmware status */ 220262506Sneel u_int8_t at_scsi_status; /* scsi status */ 221262506Sneel u_int8_t at_tag_val; /* tag value */ 222262506Sneel u_int8_t at_tag_type; /* tag type */ 223262506Sneel u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */ 224262506Sneel u_int8_t at_sense[QLTM_SENSELEN];/* suggested sense data */ 225262506Sneel} at_entry_t; 226262506Sneel 227262506Sneel/* 228262506Sneel * at_flags values 229262506Sneel */ 230262506Sneel#define AT_NODISC 0x00008000 /* disconnect disabled */ 231221828Sgrehan#define AT_TQAE 0x00000001 /* Tagged Queue Action enabled */ 232221828Sgrehan 233243640Sneel/* 234243640Sneel * at_status values 235255438Sgrehan */ 236221828Sgrehan#define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */ 237221828Sgrehan#define AT_RESET 0x0E /* SCSI Bus Reset Occurred */ 238221828Sgrehan#define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 239221828Sgrehan#define AT_NOCAP 0x16 /* Requested capability not available */ 240221828Sgrehan#define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 241221828Sgrehan#define AT_CDB 0x3D /* CDB received */ 242221828Sgrehan 243221828Sgrehan/* 244221828Sgrehan * Accept Target I/O Entry structure, Type 2 245221828Sgrehan */ 246221828Sgrehan#define ATIO2_CDBLEN 16 247221828Sgrehan 248221828Sgrehantypedef struct { 249221828Sgrehan isphdr_t at_header; 250221828Sgrehan u_int32_t at_reserved; 251221828Sgrehan u_int8_t at_lun; /* lun or reserved */ 252221828Sgrehan u_int8_t at_iid; /* initiator */ 253221828Sgrehan u_int16_t at_rxid; /* response ID */ 254221828Sgrehan u_int16_t at_flags; 255221828Sgrehan u_int16_t at_status; /* firmware status */ 256221828Sgrehan u_int8_t at_reserved1; 257221828Sgrehan u_int8_t at_taskcodes; 258221828Sgrehan u_int8_t at_taskflags; 259221828Sgrehan u_int8_t at_execodes; 260221828Sgrehan u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ 261221828Sgrehan u_int32_t at_datalen; /* allocated data len */ 262221828Sgrehan u_int16_t at_scclun; /* SCC Lun or reserved */ 263221828Sgrehan u_int16_t at_reserved2; 264221828Sgrehan u_int16_t at_scsi_status; 265221828Sgrehan u_int8_t at_sense[QLTM_SENSELEN]; 266221828Sgrehan} at2_entry_t; 267221828Sgrehan 268221828Sgrehan#define ATIO2_TC_ATTR_MASK 0x7 269221828Sgrehan#define ATIO2_TC_ATTR_SIMPLEQ 0 270221828Sgrehan#define ATIO2_TC_ATTR_HEADOFQ 1 271221828Sgrehan#define ATIO2_TC_ATTR_ORDERED 2 272221828Sgrehan#define ATIO2_TC_ATTR_ACAQ 4 273221828Sgrehan#define ATIO2_TC_ATTR_UNTAGGED 5 274221828Sgrehan 275221828Sgrehan/* 276221828Sgrehan * Continue Target I/O Entry structure 277221828Sgrehan * Request from driver. The response from the 278221828Sgrehan * ISP firmware is the same except that the last 18 279221828Sgrehan * bytes are overwritten by suggested sense data if 280221828Sgrehan * the 'autosense valid' bit is set in the status byte. 281221828Sgrehan */ 282221828Sgrehantypedef struct { 283221828Sgrehan isphdr_t ct_header; 284221828Sgrehan u_int32_t ct_reserved; 285256645Sneel u_int8_t ct_lun; /* lun */ 286221828Sgrehan u_int8_t ct_iid; /* initiator id */ 287221828Sgrehan u_int8_t ct_reserved2; 288221828Sgrehan u_int8_t ct_tgt; /* our target id */ 289240922Sneel u_int32_t ct_flags; 290262236Sneel u_int8_t ct_status; /* isp status */ 291240922Sneel u_int8_t ct_scsi_status; /* scsi status */ 292240922Sneel u_int8_t ct_tag_val; /* tag value */ 293240922Sneel u_int8_t ct_tag_type; /* tag type */ 294240922Sneel u_int32_t ct_xfrlen; /* transfer length */ 295221828Sgrehan u_int32_t ct_resid; /* residual length */ 296221828Sgrehan u_int16_t ct_timeout; 297221828Sgrehan u_int16_t ct_seg_count; 298221828Sgrehan ispds_t ct_dataseg[ISP_RQDSEG]; 299221828Sgrehan} ct_entry_t; 300221828Sgrehan 301221828Sgrehan/* 302221828Sgrehan * ct_flags values 303221828Sgrehan */ 304221828Sgrehan#define CT_TQAE 0x00000001 /* bit 1, Tagged Queue Action enable */ 305221828Sgrehan#define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */ 306221828Sgrehan#define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */ 307221828Sgrehan#define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */ 308221828Sgrehan#define CT_CCINCR 0x00000100 /* bit 8, autoincrement atio count */ 309221828Sgrehan#define CT_DATAMASK 0x000000C0 /* bits 6&7, Data direction */ 310221828Sgrehan#define CT_NODISC 0x00008000 /* bit 15, Disconnects disabled */ 311221828Sgrehan#define CT_DSDP 0x01000000 /* bit 24, Disable Save Data Pointers */ 312221828Sgrehan#define CT_SENDRDP 0x04000000 /* bit 26, Send Restore Pointers msg */ 313221828Sgrehan#define CT_SENDSTATUS 0x80000000 /* bit 31, Send SCSI status byte */ 314221828Sgrehan 315221828Sgrehan/* 316221828Sgrehan * ct_status values 317234761Sgrehan * - set by the firmware when it returns the CTIO 318256072Sneel */ 319240912Sneel#define CT_OK 0x01 /* completed without error */ 320259081Sneel#define CT_ABORTED 0x02 /* aborted by host */ 321260619Sneel#define CT_ERR 0x04 /* see sense data for error */ 322261170Sneel#define CT_INVAL 0x06 /* request for disabled lun */ 323263780Sneel#define CT_NOPATH 0x07 /* invalid ITL nexus */ 324234761Sgrehan#define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */ 325221828Sgrehan#define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */ 326221828Sgrehan#define CT_TIMEOUT 0x0B /* timed out */ 327221828Sgrehan#define CT_RESET 0x0E /* SCSI Bus Reset occurred */ 328221828Sgrehan#define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 329221828Sgrehan#define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 330221828Sgrehan#define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ 331221828Sgrehan#define CT_PORTNOTAVAIL 0x28 /* port not available */ 332221828Sgrehan#define CT_LOGOUT 0x29 /* port logout */ 333221828Sgrehan#define CT_PORTCHANGED 0x2A /* port changed */ 334221828Sgrehan#define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */ 335221828Sgrehan 336221828Sgrehan/* 337221828Sgrehan * When the firmware returns a CTIO entry, it may overwrite the last 338221828Sgrehan * part of the structure with sense data. This starts at offset 0x2E 339221828Sgrehan * into the entry, which is in the middle of ct_dataseg[1]. Rather 340234761Sgrehan * than define a new struct for this, I'm just using the sense data 341241497Sgrehan * offset. 342256072Sneel */ 343256072Sneel#define CTIO_SENSE_OFFSET 0x2E 344256072Sneel 345256072Sneel/* 346256072Sneel * Entry length in u_longs. All entries are the same size so 347256072Sneel * any one will do as the numerator. 348261504Sjhb */ 349261504Sjhb#define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t)) 350243640Sneel 351256072Sneel/* 352221828Sgrehan * QLA2100 CTIO (type 2) entry 353221828Sgrehan */ 354221828Sgrehan#define MAXRESPLEN 26 355221828Sgrehantypedef struct { 356221828Sgrehan isphdr_t ct_header; 357260167Sneel u_int32_t ct_reserved; 358260167Sneel u_int8_t ct_lun; /* lun */ 359260167Sneel u_int8_t ct_iid; /* initiator id */ 360260167Sneel u_int16_t ct_rxid; /* response ID */ 361260167Sneel u_int16_t ct_flags; 362221828Sgrehan u_int16_t ct_status; /* isp status */ 363221828Sgrehan u_int16_t ct_timeout; 364260167Sneel u_int16_t ct_seg_count; 365260167Sneel u_int32_t ct_reloff; /* relative offset */ 366260167Sneel u_int32_t ct_resid; /* residual length */ 367260167Sneel union { 368260167Sneel /* 369260167Sneel * The three different modes that the target driver 370221828Sgrehan * can set the CTIO2 up as. 371221828Sgrehan * 372221828Sgrehan * The first is for sending FCP_DATA_IUs as well as 373221828Sgrehan * (optionally) sending a terminal SCSI status FCP_RSP_IU. 374221828Sgrehan * 375240912Sneel * The second is for sending SCSI sense data in an FCP_RSP_IU. 376240912Sneel * Note that no FCP_DATA_IUs will be sent. 377240912Sneel * 378240912Sneel * The third is for sending FCP_RSP_IUs as built specifically 379259081Sneel * in system memory as located by the isp_dataseg. 380259081Sneel */ 381259081Sneel struct { 382261170Sneel u_int32_t _reserved; 383261170Sneel u_int16_t _reserved2; 384261170Sneel u_int16_t ct_scsi_status; 385221828Sgrehan u_int32_t ct_xfrlen; 386221828Sgrehan ispds_t ct_dataseg[ISP_RQDSEG_T2]; 387221828Sgrehan } m0; 388221828Sgrehan struct { 389 u_int16_t _reserved; 390 u_int16_t _reserved2; 391 u_int16_t ct_senselen; 392 u_int16_t ct_scsi_status; 393 u_int16_t ct_resplen; 394 u_int8_t ct_resp[MAXRESPLEN]; 395 } m1; 396 struct { 397 u_int32_t _reserved; 398 u_int16_t _reserved2; 399 u_int16_t _reserved3; 400 u_int32_t ct_datalen; 401 ispds_t ct_fcp_rsp_iudata; 402 } m2; 403 /* 404 * CTIO2 returned from F/W... 405 */ 406 struct { 407 u_int32_t _reserved[4]; 408 u_int16_t ct_scsi_status; 409 u_int8_t ct_sense[QLTM_SENSELEN]; 410 } fw; 411 } rsp; 412} ct2_entry_t; 413 414/* 415 * ct_flags values for CTIO2 416 */ 417#define CT2_FLAG_MMASK 0x0003 418#define CT2_FLAG_MODE0 0x0000 419#define CT2_FLAG_MODE1 0x0001 420#define CT2_FLAG_MODE2 0x0002 421#define CT2_DATA_IN CT_DATA_IN 422#define CT2_DATA_OUT CT_DATA_OUT 423#define CT2_NO_DATA CT_NO_DATA 424#define CT2_DATAMASK CT_DATAMASK 425#define CT2_CCINCR 0x0100 426#define CT2_FASTPOST 0x0200 427#define CT2_SENDSTATUS 0x8000 428 429/* 430 * ct_status values are (mostly) the same as that for ct_entry. 431 */ 432 433/* 434 * ct_scsi_status values- the low 8 bits are the normal SCSI status 435 * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU 436 * fields. 437 */ 438#define CT2_RSPLEN_VALID 0x0100 439#define CT2_SNSLEN_VALID 0x0200 440#define CT2_DATA_OVER 0x0400 441#define CT2_DATA_UNDER 0x0800 442 443/* 444 * Macros for packing/unpacking the above structures 445 */ 446 447#ifdef __sparc__ 448#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \ 449 if (isp->isp_bus == ISP_SBUS) { \ 450 source -> taga = dest -> tagb; \ 451 source -> tagb = dest -> taga; \ 452 } else { \ 453 source -> taga = dest -> taga; \ 454 source -> tagb = dest -> taga; \ 455 } 456#else 457#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \ 458 source -> taga = dest -> taga; \ 459 source -> tagb = dest -> taga; 460#endif 461 462/* This is really only for SBus cards on a sparc */ 463#ifdef __sparc__ 464#define ISP_SWIZ_ATIO(isp, dest, vsrc) \ 465{ \ 466 at_entry_t *source = (at_entry_t *) vsrc; \ 467 dest->at_header = source->at_header; \ 468 dest->at_reserved2 = source->at_reserved2; \ 469 ISP_SBUS_SWOZZLE(isp, source, dest, at_lun, at_iid); \ 470 ISP_SBUS_SWOZZLE(isp, source, dest, at_cdblen, at_tgt); \ 471 dest->at_flags = source->at_flags; \ 472 ISP_SBUS_SWOZZLE(isp, source, dest, at_status, at_scsi_status); \ 473 ISP_SBUS_SWOZZLE(isp, source, dest, at_tag_val, at_tag_type); \ 474 MEMCPY(dest->at_cdb, source->at_cdb, ATIO_CDBLEN); \ 475 MEMCPY(dest->at_sense, source->at_sense, QLTM_SENSELEN); \ 476} 477 478#define ISP_SWIZ_CTIO(isp, dest, vsrc) \ 479{ \ 480 ct_entry_t *source = (ct_entry-t *) vsrc; \ 481 dest->ct_header = source->ct_header; \ 482 dest->ct_reserved = source->ct_reserved; \ 483 ISP_SBUS_SWOZZLE(isp, source, dest, ct_lun, ct_iid); \ 484 ISP_SBUS_SWOZZLE(isp, source, dest, ct_rsvd, ct_tgt); \ 485 dest->ct_flags = source->ct_flags; \ 486 ISP_SBUS_SWOZZLE(isp, source, dest, ct_status, ct_scsi_status); \ 487 ISP_SBUS_SWOZZLE(isp, source, dest, ct_tag_val, ct_tag_type); \ 488 dest->ct_xfrlen = source->ct_xfrlen; \ 489 dest->ct_resid = source->ct_resid; \ 490 dest->ct_timeout = source->ct_timeout; \ 491 dest->ct_seg_count = source->ct_seg_count; \ 492 MEMCPY(dest->ct_cdb, source->ct_cdb, ATIO_CDBLEN); \ 493 MEMCPY(dest->ct_sense, source->ct_sense, QLTM_SENSELEN); \ 494 dest->ct_dataseg = source->ct_dataseg; \ 495} 496#define ISP_SWIZ_ENABLE_LUN(isp, dest, vsrc) \ 497{ \ 498 lun_entry_t *source = (lun_entry_t *)vsrc; \ 499 dest->le_header = source->le_header; \ 500 dest->le_reserved2 = source->le_reserved2; \ 501 ISP_SBUS_SWOZZLE(isp, source, dest, le_lun, le_rsvd); \ 502 ISP_SBUS_SWOZZLE(isp, source, dest, le_ops, le_tgt); \ 503 dest->le_flags = source->le_flags; \ 504 ISP_SBUS_SWOZZLE(isp, source, dest, le_status, le_rsvd2); \ 505 ISP_SBUS_SWOZZLE(isp, source, dest, le_cmd_count, le_in_count); \ 506 ISP_SBUS_SWOZZLE(isp, source, dest, le_cdb6len, le_cdb7len); \ 507 dest->le_timeout = source->le_timeout; \ 508 dest->le_reserved = source->le_reserved; \ 509} 510#define ISP_SWIZ_NOTIFY(isp, dest, vsrc) \ 511{ \ 512 in_entry_type *source = (in_entry_t *)vsrc; \ 513 dest->in_header = source->in_header; \ 514 dest->in_reserved2 = source->in_reserved2; \ 515 ISP_SBUS_SWOZZLE(isp, source, dest, in_lun, in_iid); \ 516 ISP_SBUS_SWOZZLE(isp, source, dest, in_rsvd, in_tgt); \ 517 dest->in_flags = source->in_flags; \ 518 ISP_SBUS_SWOZZLE(isp, source, dest, in_status, in_rsvd2); \ 519 ISP_SBUS_SWOZZLE(isp, source, dest, in_tag_val, in_tag_type); \ 520 dest->in_seqid = source->in_seqid; \ 521 MEMCPY(dest->in_msg, source->in_msg, IN_MSGLEN); \ 522 MEMCPY(dest->in_reserved, source->in_reserved, IN_RESERVED); \ 523 MEMCPY(dest->in_sense, source->in_sense, QLTM_SENSELEN); \ 524} 525#define ISP_SWIZ_NOT_ACK(isp, dest) \ 526{ \ 527 na_entry_t *source = (na_entry_t *)vsrc; \ 528 dest->na_header = source->na_header; \ 529 dest->na_reserved2 = source->na_reserved2; \ 530 ISP_SBUS_SWOZZLE(isp, source, dest, na_lun, na_iid); \ 531 ISP_SBUS_SWOZZLE(isp, source, dest, na_rsvd, na_tgt); \ 532 dest->na_flags = source->na_flags; \ 533 ISP_SBUS_SWOZZLE(isp, source, dest, na_status, na_event); \ 534 dest->na_seqid = source->na_seqid; \ 535 MEMCPY(dest->na_reserved, source->na_reserved, NA_RSVDLEN); \ 536} 537#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 538#else 539#define ISP_SWIZ_ATIO(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 540#define ISP_SWIZ_CTIO(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 541#define ISP_SWIZ_ENABLE_LUN(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 542#define ISP_SWIZ_NOTIFY(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 543#define ISP_SWIZ_NOT_ACK(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 544#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 545#endif 546#define ISP_SWIZ_ATIO2(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 547#define ISP_SWIZ_CTIO2(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 548 549/* 550 * Debug macros 551 */ 552 553extern int isp_tdebug; 554#define ISP_TDQE(isp, msg, idx, arg) \ 555 if (isp_tdebug > 3) isp_print_qentry(isp, msg, idx, arg) 556 557#define ITDEBUG(level, msg) if (level > isp_tdebug) PRINTF msg 558 559/* 560 * Common (for all platfoms) software SCSI msg/event structures. 561 */ 562 563typedef struct { 564 u_int8_t nt_iid; /* inititator id */ 565 u_int8_t nt_tgt; /* target id */ 566 u_int16_t nt_lun; /* logical unit */ 567 u_int8_t nt_bus; /* bus */ 568 u_int8_t nt_tagtype; /* tag type */ 569 u_int16_t nt_tagval; /* tag value */ 570 u_int8_t nt_msg[IN_MSGLEN]; /* message content */ 571} tmd_msg_t; 572 573typedef struct { 574 u_int16_t ev_bus; /* bus */ 575 u_int16_t ev_event; /* type of async event */ 576} tmd_event_t; 577 578/* 579 * Target Mode functions 580 */ 581 582/* 583 * This function handles new response queue entry appropriate for target mode. 584 */ 585int isp_target_notify __P((struct ispsoftc *, void *, u_int16_t *)); 586 587/* 588 * Enable/Disable/Modify a logical unit. 589 */ 590#define DFLT_CMD_CNT (RESULT_QUEUE_LEN >> 1) 591#define DFLT_INOTIFY (4) 592int isp_lun_cmd __P((struct ispsoftc *isp, int, int, int, int, u_int32_t)); 593 594/* 595 * General request queue 'put' routine for target mode entries. 596 */ 597int isp_target_put_entry __P((struct ispsoftc *isp, void *)); 598 599/* 600 * General routine to put back an ATIO entry- 601 * used for replenishing f/w resource counts. 602 */ 603int 604isp_target_put_atio __P((struct ispsoftc *isp, int, int, int, int, int)); 605 606/* 607 * General routine to send a final CTIO for a command- used mostly for 608 * local responses. 609 */ 610int 611isp_endcmd __P((struct ispsoftc *isp, void *, u_int32_t, u_int32_t)); 612 613/* 614 * Handle an asynchronous event 615 */ 616 617void isp_target_async __P((struct ispsoftc *, int, int)); 618 619#endif /* _ISPTARGET_H */ 620