isp_target.h revision 90224
11592Srgrimes/* $FreeBSD: head/sys/dev/isp/isp_target.h 90224 2002-02-04 21:04:25Z mjacob $ */ 21592Srgrimes/* 31592Srgrimes * Qlogic Target Mode Structure and Flag Definitions 41592Srgrimes * 51592Srgrimes * Copyright (c) 1997, 1998 61592Srgrimes * Patrick Stirling 71592Srgrimes * pms@psconsult.com 81592Srgrimes * All rights reserved. 91592Srgrimes * 101592Srgrimes * Additional Copyright (c) 1999, 2000, 2001 111592Srgrimes * Matthew Jacob 121592Srgrimes * mjacob@feral.com 131592Srgrimes * All rights reserved. 141592Srgrimes * 151592Srgrimes * 161592Srgrimes * Redistribution and use in source and binary forms, with or without 171592Srgrimes * modification, are permitted provided that the following conditions 181592Srgrimes * are met: 191592Srgrimes * 1. Redistributions of source code must retain the above copyright 201592Srgrimes * notice immediately at the beginning of the file, without modification, 211592Srgrimes * this list of conditions, and the following disclaimer. 221592Srgrimes * 2. The name of the author may not be used to endorse or promote products 231592Srgrimes * derived from this software without specific prior written permission. 241592Srgrimes * 251592Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 261592Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 271592Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 281592Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 291592Srgrimes * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 301592Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 311592Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 321592Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 331592Srgrimes * SUCH DAMAGE. 341592Srgrimes * 351592Srgrimes */ 361592Srgrimes#ifndef _ISP_TARGET_H 371592Srgrimes#define _ISP_TARGET_H 381592Srgrimes 391592Srgrimes/* 401592Srgrimes * Defines for all entry types 411592Srgrimes */ 421592Srgrimes#define QLTM_SVALID 0x80 431592Srgrimes#define QLTM_SENSELEN 18 441592Srgrimes 451592Srgrimes/* 461592Srgrimes * Structure for Enable Lun and Modify Lun queue entries 471592Srgrimes */ 481592Srgrimestypedef struct { 491592Srgrimes isphdr_t le_header; 501592Srgrimes u_int32_t le_reserved; 511592Srgrimes u_int8_t le_lun; 521592Srgrimes u_int8_t le_rsvd; 531592Srgrimes u_int8_t le_ops; /* Modify LUN only */ 541592Srgrimes u_int8_t le_tgt; /* Not for FC */ 551592Srgrimes u_int32_t le_flags; /* Not for FC */ 561592Srgrimes u_int8_t le_status; 571592Srgrimes u_int8_t le_reserved2; 581592Srgrimes u_int8_t le_cmd_count; 591592Srgrimes u_int8_t le_in_count; 601592Srgrimes u_int8_t le_cdb6len; /* Not for FC */ 611592Srgrimes u_int8_t le_cdb7len; /* Not for FC */ 621592Srgrimes u_int16_t le_timeout; 631592Srgrimes u_int16_t le_reserved3[20]; 641592Srgrimes} lun_entry_t; 651592Srgrimes 661592Srgrimes/* 671592Srgrimes * le_flags values 681592Srgrimes */ 691592Srgrimes#define LUN_TQAE 0x00000002 /* bit1 Tagged Queue Action Enable */ 701592Srgrimes#define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */ 711592Srgrimes#define LUN_DISAD 0x02000000 /* bit25 Disable autodisconnect */ 721592Srgrimes#define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */ 731592Srgrimes 741592Srgrimes/* 751592Srgrimes * le_ops values 761592Srgrimes */ 771592Srgrimes#define LUN_CCINCR 0x01 /* increment command count */ 781592Srgrimes#define LUN_CCDECR 0x02 /* decrement command count */ 791592Srgrimes#define LUN_ININCR 0x40 /* increment immed. notify count */ 801592Srgrimes#define LUN_INDECR 0x80 /* decrement immed. notify count */ 811592Srgrimes 821592Srgrimes/* 831592Srgrimes * le_status values 841592Srgrimes */ 851592Srgrimes#define LUN_OK 0x01 /* we be rockin' */ 861592Srgrimes#define LUN_ERR 0x04 /* request completed with error */ 871592Srgrimes#define LUN_INVAL 0x06 /* invalid request */ 881592Srgrimes#define LUN_NOCAP 0x16 /* can't provide requested capability */ 891592Srgrimes#define LUN_ENABLED 0x3E /* LUN already enabled */ 901592Srgrimes 911592Srgrimes/* 921592Srgrimes * Immediate Notify Entry structure 931592Srgrimes */ 941592Srgrimes#define IN_MSGLEN 8 /* 8 bytes */ 951592Srgrimes#define IN_RSVDLEN 8 /* 8 words */ 961592Srgrimestypedef struct { 971592Srgrimes isphdr_t in_header; 981592Srgrimes u_int32_t in_reserved; 991592Srgrimes u_int8_t in_lun; /* lun */ 1001592Srgrimes u_int8_t in_iid; /* initiator */ 1011592Srgrimes u_int8_t in_reserved2; 1021592Srgrimes u_int8_t in_tgt; /* target */ 1031592Srgrimes u_int32_t in_flags; 1041592Srgrimes u_int8_t in_status; 1051592Srgrimes u_int8_t in_rsvd2; 1061592Srgrimes u_int8_t in_tag_val; /* tag value */ 1071592Srgrimes u_int8_t in_tag_type; /* tag type */ 1081592Srgrimes u_int16_t in_seqid; /* sequence id */ 1091592Srgrimes u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */ 1101592Srgrimes u_int16_t in_reserved3[IN_RSVDLEN]; 1111592Srgrimes u_int8_t in_sense[QLTM_SENSELEN];/* suggested sense data */ 1121592Srgrimes} in_entry_t; 1131592Srgrimes 1141592Srgrimestypedef struct { 1151592Srgrimes isphdr_t in_header; 1161592Srgrimes u_int32_t in_reserved; 1171592Srgrimes u_int8_t in_lun; /* lun */ 1181592Srgrimes u_int8_t in_iid; /* initiator */ 1191592Srgrimes u_int16_t in_scclun; 1201592Srgrimes u_int32_t in_reserved2; 1211592Srgrimes u_int16_t in_status; 1221592Srgrimes u_int16_t in_task_flags; 1231592Srgrimes u_int16_t in_seqid; /* sequence id */ 1241592Srgrimes} in_fcentry_t; 1251592Srgrimes 1261592Srgrimes/* 1271592Srgrimes * Values for the in_status field 1281592Srgrimes */ 1291592Srgrimes#define IN_REJECT 0x0D /* Message Reject message received */ 1301592Srgrimes#define IN_RESET 0x0E /* Bus Reset occurred */ 1311592Srgrimes#define IN_NO_RCAP 0x16 /* requested capability not available */ 1321592Srgrimes#define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */ 1331592Srgrimes#define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */ 1341592Srgrimes#define IN_MSG_RECEIVED 0x36 /* SCSI message received */ 1351592Srgrimes#define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */ 1361592Srgrimes#define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */ 1371592Srgrimes#define IN_PORT_CHANGED 0x2A /* port changed */ 1381592Srgrimes#define IN_GLOBAL_LOGO 0x2E /* all ports logged out */ 1391592Srgrimes#define IN_NO_NEXUS 0x3B /* Nexus not established */ 1401592Srgrimes 1411592Srgrimes/* 1421592Srgrimes * Values for the in_task_flags field- should only get one at a time! 1431592Srgrimes */ 1441592Srgrimes#define TASK_FLAGS_ABORT_TASK (1<<9) 1451592Srgrimes#define TASK_FLAGS_CLEAR_TASK_SET (1<<10) 1461592Srgrimes#define TASK_FLAGS_TARGET_RESET (1<<13) 1471592Srgrimes#define TASK_FLAGS_CLEAR_ACA (1<<14) 1481592Srgrimes#define TASK_FLAGS_TERMINATE_TASK (1<<15) 1491592Srgrimes 1501592Srgrimes#ifndef MSG_ABORT_TAG 1511592Srgrimes#define MSG_ABORT_TAG 0x06 1521592Srgrimes#endif 1531592Srgrimes#ifndef MSG_CLEAR_QUEUE 1541592Srgrimes#define MSG_CLEAR_QUEUE 0x0e 1551592Srgrimes#endif 1561592Srgrimes#ifndef MSG_BUS_DEV_RESET 1571592Srgrimes#define MSG_BUS_DEV_RESET 0x0b 1581592Srgrimes#endif 1591592Srgrimes#ifndef MSG_REL_RECOVERY 1601592Srgrimes#define MSG_REL_RECOVERY 0x10 1611592Srgrimes#endif 1621592Srgrimes#ifndef MSG_TERM_IO_PROC 1631592Srgrimes#define MSG_TERM_IO_PROC 0x11 1641592Srgrimes#endif 1651592Srgrimes 1661592Srgrimes 1671592Srgrimes/* 1681592Srgrimes * Notify Acknowledge Entry structure 1691592Srgrimes */ 1701592Srgrimes#define NA_RSVDLEN 22 1711592Srgrimestypedef struct { 1721592Srgrimes isphdr_t na_header; 1731592Srgrimes u_int32_t na_reserved; 1741592Srgrimes u_int8_t na_lun; /* lun */ 1751592Srgrimes u_int8_t na_iid; /* initiator */ 1761592Srgrimes u_int8_t na_reserved2; 1771592Srgrimes u_int8_t na_tgt; /* target */ 1781592Srgrimes u_int32_t na_flags; 1791592Srgrimes u_int8_t na_status; 1801592Srgrimes u_int8_t na_event; 1811592Srgrimes u_int16_t na_seqid; /* sequence id */ 1821592Srgrimes u_int16_t na_reserved3[NA_RSVDLEN]; 1831592Srgrimes} na_entry_t; 1841592Srgrimes 1851592Srgrimes/* 1861592Srgrimes * Value for the na_event field 1871592Srgrimes */ 1881592Srgrimes#define NA_RST_CLRD 0x80 /* Clear an async event notification */ 1891592Srgrimes#define NA_OK 0x01 /* Notify Acknowledge Succeeded */ 1901592Srgrimes#define NA_INVALID 0x06 /* Invalid Notify Acknowledge */ 1911592Srgrimes 1921592Srgrimes#define NA2_RSVDLEN 21 1931592Srgrimestypedef struct { 1941592Srgrimes isphdr_t na_header; 1951592Srgrimes u_int32_t na_reserved; 1961592Srgrimes u_int8_t na_lun; /* lun */ 1971592Srgrimes u_int8_t na_iid; /* initiator */ 1981592Srgrimes u_int16_t na_scclun; 1991592Srgrimes u_int16_t na_flags; 2001592Srgrimes u_int16_t na_reserved2; 2011592Srgrimes u_int16_t na_status; 2021592Srgrimes u_int16_t na_task_flags; 2031592Srgrimes u_int16_t na_seqid; /* sequence id */ 2041592Srgrimes u_int16_t na_reserved3[NA2_RSVDLEN]; 2051592Srgrimes} na_fcentry_t; 2061592Srgrimes#define NAFC_RCOUNT 0x80 /* increment resource count */ 2071592Srgrimes#define NAFC_RST_CLRD 0x20 /* Clear LIP Reset */ 2081592Srgrimes/* 2091592Srgrimes * Accept Target I/O Entry structure 2101592Srgrimes */ 2111592Srgrimes#define ATIO_CDBLEN 26 2121592Srgrimes 2131592Srgrimestypedef struct { 2141592Srgrimes isphdr_t at_header; 2151592Srgrimes u_int16_t at_reserved; 2161592Srgrimes u_int16_t at_handle; 2171592Srgrimes u_int8_t at_lun; /* lun */ 2181592Srgrimes u_int8_t at_iid; /* initiator */ 2191592Srgrimes u_int8_t at_cdblen; /* cdb length */ 2201592Srgrimes u_int8_t at_tgt; /* target */ 2211592Srgrimes u_int32_t at_flags; 2221592Srgrimes u_int8_t at_status; /* firmware status */ 2231592Srgrimes u_int8_t at_scsi_status; /* scsi status */ 2241592Srgrimes u_int8_t at_tag_val; /* tag value */ 2251592Srgrimes u_int8_t at_tag_type; /* tag type */ 2261592Srgrimes u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */ 2271592Srgrimes u_int8_t at_sense[QLTM_SENSELEN];/* suggested sense data */ 2281592Srgrimes} at_entry_t; 2291592Srgrimes 2301592Srgrimes/* 2311592Srgrimes * at_flags values 2321592Srgrimes */ 2331592Srgrimes#define AT_NODISC 0x00008000 /* disconnect disabled */ 2341592Srgrimes#define AT_TQAE 0x00000002 /* Tagged Queue Action enabled */ 2351592Srgrimes 2361592Srgrimes/* 2371592Srgrimes * at_status values 2381592Srgrimes */ 2391592Srgrimes#define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */ 2401592Srgrimes#define AT_RESET 0x0E /* SCSI Bus Reset Occurred */ 2411592Srgrimes#define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 2421592Srgrimes#define AT_NOCAP 0x16 /* Requested capability not available */ 2431592Srgrimes#define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 2441592Srgrimes#define AT_CDB 0x3D /* CDB received */ 2451592Srgrimes 2461592Srgrimes/* 2471592Srgrimes * Macros to create and fetch and test concatenated handle and tag value macros 2481592Srgrimes */ 2491592Srgrimes 2501592Srgrimes#define AT_MAKE_TAGID(tid, aep) \ 2511592Srgrimes tid = ((aep)->at_handle << 16); \ 2521592Srgrimes if ((aep)->at_flags & AT_TQAE) \ 2531592Srgrimes (tid) |= ((aep)->at_tag_val + 1) 2541592Srgrimes 2551592Srgrimes#define CT_MAKE_TAGID(tid, ct) \ 2561592Srgrimes tid = ((ct)->ct_fwhandle << 16); \ 2571592Srgrimes if ((ct)->ct_flags & CT_TQAE) \ 2581592Srgrimes (tid) |= ((ct)->ct_tag_val + 1) 2591592Srgrimes 2601592Srgrimes#define AT_HAS_TAG(val) ((val) & 0xffff) 2611592Srgrimes#define AT_GET_TAG(val) AT_HAS_TAG(val) - 1 2621592Srgrimes#define AT_GET_HANDLE(val) ((val) >> 16) 2631592Srgrimes 2641592Srgrimes/* 2651592Srgrimes * Accept Target I/O Entry structure, Type 2 2661592Srgrimes */ 2671592Srgrimes#define ATIO2_CDBLEN 16 2681592Srgrimes 2691592Srgrimestypedef struct { 2701592Srgrimes isphdr_t at_header; 2711592Srgrimes u_int32_t at_reserved; 2721592Srgrimes u_int8_t at_lun; /* lun or reserved */ 2731592Srgrimes u_int8_t at_iid; /* initiator */ 2741592Srgrimes u_int16_t at_rxid; /* response ID */ 2751592Srgrimes u_int16_t at_flags; 2761592Srgrimes u_int16_t at_status; /* firmware status */ 2771592Srgrimes u_int8_t at_reserved1; 2781592Srgrimes u_int8_t at_taskcodes; 2791592Srgrimes u_int8_t at_taskflags; 2801592Srgrimes u_int8_t at_execodes; 2811592Srgrimes u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ 2821592Srgrimes u_int32_t at_datalen; /* allocated data len */ 2831592Srgrimes u_int16_t at_scclun; /* SCC Lun or reserved */ 2841592Srgrimes u_int16_t at_wwpn[4]; /* WWPN of initiator */ 2851592Srgrimes u_int16_t at_reserved2[6]; 2861592Srgrimes u_int16_t at_oxid; 2871592Srgrimes} at2_entry_t; 2881592Srgrimes 2891592Srgrimes#define ATIO2_WWPN_OFFSET 0x2A 2901592Srgrimes#define ATIO2_OXID_OFFSET 0x3E 2911592Srgrimes 2921592Srgrimes#define ATIO2_TC_ATTR_MASK 0x7 2931592Srgrimes#define ATIO2_TC_ATTR_SIMPLEQ 0 2941592Srgrimes#define ATIO2_TC_ATTR_HEADOFQ 1 2951592Srgrimes#define ATIO2_TC_ATTR_ORDERED 2 2961592Srgrimes#define ATIO2_TC_ATTR_ACAQ 4 2971592Srgrimes#define ATIO2_TC_ATTR_UNTAGGED 5 2981592Srgrimes 2991592Srgrimes/* 3001592Srgrimes * Continue Target I/O Entry structure 3011592Srgrimes * Request from driver. The response from the 3021592Srgrimes * ISP firmware is the same except that the last 18 3031592Srgrimes * bytes are overwritten by suggested sense data if 3041592Srgrimes * the 'autosense valid' bit is set in the status byte. 3051592Srgrimes */ 3061592Srgrimestypedef struct { 3071592Srgrimes isphdr_t ct_header; 3081592Srgrimes u_int16_t ct_reserved; 3091592Srgrimes#define ct_syshandle ct_reserved /* we use this */ 3101592Srgrimes u_int16_t ct_fwhandle; /* required by f/w */ 3111592Srgrimes u_int8_t ct_lun; /* lun */ 3121592Srgrimes u_int8_t ct_iid; /* initiator id */ 3131592Srgrimes u_int8_t ct_reserved2; 3141592Srgrimes u_int8_t ct_tgt; /* our target id */ 3151592Srgrimes u_int32_t ct_flags; 3161592Srgrimes u_int8_t ct_status; /* isp status */ 3171592Srgrimes u_int8_t ct_scsi_status; /* scsi status */ 3181592Srgrimes u_int8_t ct_tag_val; /* tag value */ 3191592Srgrimes u_int8_t ct_tag_type; /* tag type */ 3201592Srgrimes u_int32_t ct_xfrlen; /* transfer length */ 3211592Srgrimes u_int32_t ct_resid; /* residual length */ 3221592Srgrimes u_int16_t ct_timeout; 3231592Srgrimes u_int16_t ct_seg_count; 3241592Srgrimes /* 3251592Srgrimes * This is so we can share tag name space with 3261592Srgrimes * CTIO{2,3,4} with the minimum of pain. 3271592Srgrimes */ 3281592Srgrimes union { 3291592Srgrimes ispds_t ct_a[ISP_RQDSEG]; 3301592Srgrimes } _u; 3311592Srgrimes#define ct_dataseg _u.ct_a 3321592Srgrimes} ct_entry_t; 3331592Srgrimes 3341592Srgrimes/* 3351592Srgrimes * For some of the dual port SCSI adapters, port (bus #) is reported 3361592Srgrimes * in the MSbit of ct_iid. Bit fields are a bit too awkward here. 3371592Srgrimes * 3381592Srgrimes * Note that this does not apply to FC adapters at all which can and 3391592Srgrimes * do report IIDs between 129 && 255 (these represent devices that have 3401592Srgrimes * logged in across a SCSI fabric). 3411592Srgrimes */ 3421592Srgrimes#define GET_IID_VAL(x) (x & 0x3f) 3431592Srgrimes#define GET_BUS_VAL(x) ((x >> 7) & 0x1) 3441592Srgrimes#define SET_IID_VAL(y, x) y = ((y & ~0x3f) | (x & 0x3f)) 3451592Srgrimes#define SET_BUS_VAL(y, x) y = ((y & 0x3f) | ((x & 0x1) << 7)) 3461592Srgrimes 3471592Srgrimes/* 3481592Srgrimes * ct_flags values 3491592Srgrimes */ 3501592Srgrimes#define CT_TQAE 0x00000002 /* bit 1, Tagged Queue Action enable */ 3511592Srgrimes#define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */ 3521592Srgrimes#define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */ 3531592Srgrimes#define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */ 3541592Srgrimes#define CT_CCINCR 0x00000100 /* bit 8, autoincrement atio count */ 3551592Srgrimes#define CT_DATAMASK 0x000000C0 /* bits 6&7, Data direction */ 3561592Srgrimes#define CT_INISYNCWIDE 0x00004000 /* bit 14, Do Sync/Wide Negotiation */ 3571592Srgrimes#define CT_NODISC 0x00008000 /* bit 15, Disconnects disabled */ 3581592Srgrimes#define CT_DSDP 0x01000000 /* bit 24, Disable Save Data Pointers */ 3591592Srgrimes#define CT_SENDRDP 0x04000000 /* bit 26, Send Restore Pointers msg */ 3601592Srgrimes#define CT_SENDSTATUS 0x80000000 /* bit 31, Send SCSI status byte */ 3611592Srgrimes 3621592Srgrimes/* 3631592Srgrimes * ct_status values 3641592Srgrimes * - set by the firmware when it returns the CTIO 3651592Srgrimes */ 3661592Srgrimes#define CT_OK 0x01 /* completed without error */ 3671592Srgrimes#define CT_ABORTED 0x02 /* aborted by host */ 3681592Srgrimes#define CT_ERR 0x04 /* see sense data for error */ 3691592Srgrimes#define CT_INVAL 0x06 /* request for disabled lun */ 3701592Srgrimes#define CT_NOPATH 0x07 /* invalid ITL nexus */ 3711592Srgrimes#define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */ 3721592Srgrimes#define CT_DATA_OVER 0x09 /* (FC only) Data Overrun */ 3731592Srgrimes#define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */ 3741592Srgrimes#define CT_TIMEOUT 0x0B /* timed out */ 3751592Srgrimes#define CT_RESET 0x0E /* SCSI Bus Reset occurred */ 3761592Srgrimes#define CT_PARITY 0x0F /* Uncorrectable Parity Error */ 3771592Srgrimes#define CT_BUS_ERROR 0x10 /* (FC Only) DMA PCI Error */ 3781592Srgrimes#define CT_PANIC 0x13 /* Unrecoverable Error */ 3791592Srgrimes#define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 3801592Srgrimes#define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 3811592Srgrimes#define CT_DATA_UNDER 0x15 /* (FC only) Data Underrun */ 3821592Srgrimes#define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ 3831592Srgrimes#define CT_PORTNOTAVAIL 0x28 /* port not available */ 3841592Srgrimes#define CT_LOGOUT 0x29 /* port logout */ 3851592Srgrimes#define CT_PORTCHANGED 0x2A /* port changed */ 3861592Srgrimes#define CT_IDE 0x33 /* Initiator Detected Error */ 3871592Srgrimes#define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */ 3881592Srgrimes 3891592Srgrimes/* 3901592Srgrimes * When the firmware returns a CTIO entry, it may overwrite the last 3911592Srgrimes * part of the structure with sense data. This starts at offset 0x2E 3921592Srgrimes * into the entry, which is in the middle of ct_dataseg[1]. Rather 3931592Srgrimes * than define a new struct for this, I'm just using the sense data 3941592Srgrimes * offset. 3951592Srgrimes */ 3961592Srgrimes#define CTIO_SENSE_OFFSET 0x2E 3971592Srgrimes 3981592Srgrimes/* 3991592Srgrimes * Entry length in u_longs. All entries are the same size so 4001592Srgrimes * any one will do as the numerator. 4011592Srgrimes */ 4021592Srgrimes#define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t)) 4031592Srgrimes 4041592Srgrimes/* 4051592Srgrimes * QLA2100 CTIO (type 2) entry 4061592Srgrimes */ 4071592Srgrimes#define MAXRESPLEN 26 4081592Srgrimestypedef struct { 4091592Srgrimes isphdr_t ct_header; 4101592Srgrimes u_int16_t ct_reserved; 4111592Srgrimes u_int16_t ct_fwhandle; /* just to match CTIO */ 4121592Srgrimes u_int8_t ct_lun; /* lun */ 4131592Srgrimes u_int8_t ct_iid; /* initiator id */ 4141592Srgrimes u_int16_t ct_rxid; /* response ID */ 4151592Srgrimes u_int16_t ct_flags; 4161592Srgrimes u_int16_t ct_status; /* isp status */ 4171592Srgrimes u_int16_t ct_timeout; 4181592Srgrimes u_int16_t ct_seg_count; 4191592Srgrimes u_int32_t ct_reloff; /* relative offset */ 4201592Srgrimes int32_t ct_resid; /* residual length */ 4211592Srgrimes union { 4221592Srgrimes /* 4231592Srgrimes * The three different modes that the target driver 4241592Srgrimes * can set the CTIO{2,3,4} up as. 4251592Srgrimes * 4261592Srgrimes * The first is for sending FCP_DATA_IUs as well as 4271592Srgrimes * (optionally) sending a terminal SCSI status FCP_RSP_IU. 4281592Srgrimes * 4291592Srgrimes * The second is for sending SCSI sense data in an FCP_RSP_IU. 4301592Srgrimes * Note that no FCP_DATA_IUs will be sent. 4311592Srgrimes * 4321592Srgrimes * The third is for sending FCP_RSP_IUs as built specifically 4331592Srgrimes * in system memory as located by the isp_dataseg. 4341592Srgrimes */ 4351592Srgrimes struct { 4361592Srgrimes u_int32_t _reserved; 4371592Srgrimes u_int16_t _reserved2; 4381592Srgrimes u_int16_t ct_scsi_status; 4391592Srgrimes u_int32_t ct_xfrlen; 4401592Srgrimes union { 4411592Srgrimes ispds_t ct_a[ISP_RQDSEG_T2]; /* CTIO2 */ 4421592Srgrimes ispds64_t ct_b[ISP_RQDSEG_T3]; /* CTIO3 */ 4431592Srgrimes ispdslist_t ct_c; /* CTIO4 */ 4441592Srgrimes } _u; 4451592Srgrimes#define ct_dataseg _u.ct_a 4461592Srgrimes#define ct_dataseg64 _u.ct_b 4471592Srgrimes#define ct_dslist _u.ct_c 4481592Srgrimes } m0; 4491592Srgrimes struct { 4501592Srgrimes u_int16_t _reserved; 4511592Srgrimes u_int16_t _reserved2; 4521592Srgrimes u_int16_t ct_senselen; 4531592Srgrimes u_int16_t ct_scsi_status; 4541592Srgrimes u_int16_t ct_resplen; 4551592Srgrimes u_int8_t ct_resp[MAXRESPLEN]; 4561592Srgrimes } m1; 4571592Srgrimes struct { 4581592Srgrimes u_int32_t _reserved; 4591592Srgrimes u_int16_t _reserved2; 4601592Srgrimes u_int16_t _reserved3; 4611592Srgrimes u_int32_t ct_datalen; 4621592Srgrimes ispds_t ct_fcp_rsp_iudata; 4631592Srgrimes } m2; 4641592Srgrimes /* 4651592Srgrimes * CTIO2 returned from F/W... 4661592Srgrimes */ 4671592Srgrimes struct { 4681592Srgrimes u_int32_t _reserved[4]; 4691592Srgrimes u_int16_t ct_scsi_status; 4701592Srgrimes u_int8_t ct_sense[QLTM_SENSELEN]; 4711592Srgrimes } fw; 4721592Srgrimes } rsp; 4731592Srgrimes} ct2_entry_t; 4741592Srgrimes 4751592Srgrimes/* 4761592Srgrimes * ct_flags values for CTIO2 4771592Srgrimes */ 4781592Srgrimes#define CT2_FLAG_MMASK 0x0003 4791592Srgrimes#define CT2_FLAG_MODE0 0x0000 4801592Srgrimes#define CT2_FLAG_MODE1 0x0001 4811592Srgrimes#define CT2_FLAG_MODE2 0x0002 4821592Srgrimes#define CT2_DATA_IN CT_DATA_IN 4831592Srgrimes#define CT2_DATA_OUT CT_DATA_OUT 4841592Srgrimes#define CT2_NO_DATA CT_NO_DATA 4851592Srgrimes#define CT2_DATAMASK CT_DATAMASK 4861592Srgrimes#define CT2_CCINCR 0x0100 4871592Srgrimes#define CT2_FASTPOST 0x0200 4881592Srgrimes#define CT2_SENDSTATUS 0x8000 4891592Srgrimes 4901592Srgrimes/* 4911592Srgrimes * ct_status values are (mostly) the same as that for ct_entry. 4921592Srgrimes */ 4931592Srgrimes 4941592Srgrimes/* 4951592Srgrimes * ct_scsi_status values- the low 8 bits are the normal SCSI status 4961592Srgrimes * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU 4971592Srgrimes * fields. 4981592Srgrimes */ 4991592Srgrimes#define CT2_RSPLEN_VALID 0x0100 5001592Srgrimes#define CT2_SNSLEN_VALID 0x0200 5011592Srgrimes#define CT2_DATA_OVER 0x0400 5021592Srgrimes#define CT2_DATA_UNDER 0x0800 5031592Srgrimes 5041592Srgrimes/* 5051592Srgrimes * Debug macros 5061592Srgrimes */ 5071592Srgrimes 5081592Srgrimes#define ISP_TDQE(isp, msg, idx, arg) \ 5091592Srgrimes if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg) 5101592Srgrimes 5111592Srgrimes#ifdef ISP_TARGET_FUNCTIONS 5121592Srgrimes/* 5131592Srgrimes * The functions below are for the publicly available 5141592Srgrimes * target mode functions that are internal to the Qlogic driver. 5151592Srgrimes */ 5161592Srgrimes 5171592Srgrimes/* 5181592Srgrimes * This function handles new response queue entry appropriate for target mode. 5191592Srgrimes */ 5201592Srgrimesint isp_target_notify(struct ispsoftc *, void *, u_int16_t *); 5211592Srgrimes 5221592Srgrimes/* 5231592Srgrimes * Enable/Disable/Modify a logical unit. 5241592Srgrimes * (softc, cmd, bus, tgt, lun, cmd_cnt, inotify_cnt, opaque) 5251592Srgrimes */ 5261592Srgrimes#define DFLT_CMND_CNT 32 5271592Srgrimes#define DFLT_INOT_CNT 4 5281592Srgrimesint isp_lun_cmd(struct ispsoftc *, int, int, int, int, int, int, u_int32_t); 5291592Srgrimes 5301592Srgrimes/* 5311592Srgrimes * General request queue 'put' routine for target mode entries. 5321592Srgrimes */ 5331592Srgrimesint isp_target_put_entry(struct ispsoftc *isp, void *); 5341592Srgrimes 5351592Srgrimes/* 5361592Srgrimes * General routine to put back an ATIO entry- 5371592Srgrimes * used for replenishing f/w resource counts. 5381592Srgrimes * The argument is a pointer to a source ATIO 5391592Srgrimes * or ATIO2. 5401592Srgrimes */ 5411592Srgrimesint isp_target_put_atio(struct ispsoftc *, void *); 5421592Srgrimes 5431592Srgrimes/* 5441592Srgrimes * General routine to send a final CTIO for a command- used mostly for 5451592Srgrimes * local responses. 5461592Srgrimes */ 5471592Srgrimesint isp_endcmd(struct ispsoftc *, void *, u_int32_t, u_int16_t); 5481592Srgrimes#define ECMD_SVALID 0x100 5491592Srgrimes 5501592Srgrimes/* 5511592Srgrimes * Handle an asynchronous event 5521592Srgrimes */ 5531592Srgrimes 5541592Srgrimesvoid isp_target_async(struct ispsoftc *, int, int); 5551592Srgrimes#endif 5561592Srgrimes#endif /* _ISP_TARGET_H */ 5571592Srgrimes