isp_target.h revision 120016
155372Smjacob/* $FreeBSD: head/sys/dev/isp/isp_target.h 120016 2003-09-13 01:58:26Z mjacob $ */ 255372Smjacob/* 355372Smjacob * Qlogic Target Mode Structure and Flag Definitions 455372Smjacob * 555372Smjacob * Copyright (c) 1997, 1998 655372Smjacob * Patrick Stirling 755372Smjacob * pms@psconsult.com 855372Smjacob * All rights reserved. 955372Smjacob * 1073319Smjacob * Additional Copyright (c) 1999, 2000, 2001 1155372Smjacob * Matthew Jacob 1255372Smjacob * mjacob@feral.com 1355372Smjacob * All rights reserved. 1455372Smjacob * 1555372Smjacob * 1655372Smjacob * Redistribution and use in source and binary forms, with or without 1755372Smjacob * modification, are permitted provided that the following conditions 1855372Smjacob * are met: 1955372Smjacob * 1. Redistributions of source code must retain the above copyright 2055372Smjacob * notice immediately at the beginning of the file, without modification, 2155372Smjacob * this list of conditions, and the following disclaimer. 2266189Smjacob * 2. The name of the author may not be used to endorse or promote products 2355372Smjacob * derived from this software without specific prior written permission. 2455372Smjacob * 2555372Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2655372Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2755372Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2855372Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 2955372Smjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3055372Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3155372Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3255372Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3355372Smjacob * SUCH DAMAGE. 3455372Smjacob * 3555372Smjacob */ 3674231Smjacob#ifndef _ISP_TARGET_H 3774231Smjacob#define _ISP_TARGET_H 3855372Smjacob 39120016Smjacob#define QLTM_SENSELEN 18 /* non-FC cards only */ 4055372Smjacob#define QLTM_SVALID 0x80 4155372Smjacob 4255372Smjacob/* 4355372Smjacob * Structure for Enable Lun and Modify Lun queue entries 4455372Smjacob */ 4555372Smjacobtypedef struct { 4655372Smjacob isphdr_t le_header; 4755372Smjacob u_int32_t le_reserved; 4855372Smjacob u_int8_t le_lun; 4955372Smjacob u_int8_t le_rsvd; 5055372Smjacob u_int8_t le_ops; /* Modify LUN only */ 5155372Smjacob u_int8_t le_tgt; /* Not for FC */ 5255372Smjacob u_int32_t le_flags; /* Not for FC */ 5355372Smjacob u_int8_t le_status; 5455372Smjacob u_int8_t le_reserved2; 5555372Smjacob u_int8_t le_cmd_count; 5655372Smjacob u_int8_t le_in_count; 5755372Smjacob u_int8_t le_cdb6len; /* Not for FC */ 5855372Smjacob u_int8_t le_cdb7len; /* Not for FC */ 5955372Smjacob u_int16_t le_timeout; 6055372Smjacob u_int16_t le_reserved3[20]; 6155372Smjacob} lun_entry_t; 6255372Smjacob 6355372Smjacob/* 6455372Smjacob * le_flags values 6555372Smjacob */ 6675195Smjacob#define LUN_TQAE 0x00000002 /* bit1 Tagged Queue Action Enable */ 6755372Smjacob#define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */ 6861771Smjacob#define LUN_DISAD 0x02000000 /* bit25 Disable autodisconnect */ 6955372Smjacob#define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */ 7055372Smjacob 7155372Smjacob/* 7255372Smjacob * le_ops values 7355372Smjacob */ 7455372Smjacob#define LUN_CCINCR 0x01 /* increment command count */ 7555372Smjacob#define LUN_CCDECR 0x02 /* decrement command count */ 7655372Smjacob#define LUN_ININCR 0x40 /* increment immed. notify count */ 7755372Smjacob#define LUN_INDECR 0x80 /* decrement immed. notify count */ 7855372Smjacob 7955372Smjacob/* 8055372Smjacob * le_status values 8155372Smjacob */ 8255372Smjacob#define LUN_OK 0x01 /* we be rockin' */ 8355372Smjacob#define LUN_ERR 0x04 /* request completed with error */ 8455372Smjacob#define LUN_INVAL 0x06 /* invalid request */ 8555372Smjacob#define LUN_NOCAP 0x16 /* can't provide requested capability */ 8655372Smjacob#define LUN_ENABLED 0x3E /* LUN already enabled */ 8755372Smjacob 8855372Smjacob/* 8955372Smjacob * Immediate Notify Entry structure 9055372Smjacob */ 9155372Smjacob#define IN_MSGLEN 8 /* 8 bytes */ 9255372Smjacob#define IN_RSVDLEN 8 /* 8 words */ 9355372Smjacobtypedef struct { 9455372Smjacob isphdr_t in_header; 9555372Smjacob u_int32_t in_reserved; 9655372Smjacob u_int8_t in_lun; /* lun */ 9755372Smjacob u_int8_t in_iid; /* initiator */ 9855372Smjacob u_int8_t in_reserved2; 9955372Smjacob u_int8_t in_tgt; /* target */ 10055372Smjacob u_int32_t in_flags; 10155372Smjacob u_int8_t in_status; 10255372Smjacob u_int8_t in_rsvd2; 10355372Smjacob u_int8_t in_tag_val; /* tag value */ 10455372Smjacob u_int8_t in_tag_type; /* tag type */ 10555372Smjacob u_int16_t in_seqid; /* sequence id */ 10655372Smjacob u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */ 10755372Smjacob u_int16_t in_reserved3[IN_RSVDLEN]; 10855372Smjacob u_int8_t in_sense[QLTM_SENSELEN];/* suggested sense data */ 10955372Smjacob} in_entry_t; 11055372Smjacob 11155372Smjacobtypedef struct { 11255372Smjacob isphdr_t in_header; 11355372Smjacob u_int32_t in_reserved; 11455372Smjacob u_int8_t in_lun; /* lun */ 11555372Smjacob u_int8_t in_iid; /* initiator */ 11655372Smjacob u_int16_t in_scclun; 11755372Smjacob u_int32_t in_reserved2; 11855372Smjacob u_int16_t in_status; 11955372Smjacob u_int16_t in_task_flags; 12055372Smjacob u_int16_t in_seqid; /* sequence id */ 12155372Smjacob} in_fcentry_t; 12255372Smjacob 12355372Smjacob/* 12455372Smjacob * Values for the in_status field 12555372Smjacob */ 12663390Smjacob#define IN_REJECT 0x0D /* Message Reject message received */ 12755372Smjacob#define IN_RESET 0x0E /* Bus Reset occurred */ 12855372Smjacob#define IN_NO_RCAP 0x16 /* requested capability not available */ 12955372Smjacob#define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */ 13055372Smjacob#define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */ 13155372Smjacob#define IN_MSG_RECEIVED 0x36 /* SCSI message received */ 13255372Smjacob#define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */ 13355372Smjacob#define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */ 13455372Smjacob#define IN_PORT_CHANGED 0x2A /* port changed */ 13555372Smjacob#define IN_GLOBAL_LOGO 0x2E /* all ports logged out */ 13663390Smjacob#define IN_NO_NEXUS 0x3B /* Nexus not established */ 13755372Smjacob 13855372Smjacob/* 13955372Smjacob * Values for the in_task_flags field- should only get one at a time! 14055372Smjacob */ 141120016Smjacob#define TASK_FLAGS_CLEAR_ACA (1<<14) 142120016Smjacob#define TASK_FLAGS_TARGET_RESET (1<<13) 143120016Smjacob#define TASK_FLAGS_LUN_RESET (1<<12) 14455372Smjacob#define TASK_FLAGS_CLEAR_TASK_SET (1<<10) 145120016Smjacob#define TASK_FLAGS_ABORT_TASK_SET (1<<9) 14655372Smjacob 147120016Smjacob#ifndef MSG_ABORT 148120016Smjacob#define MSG_ABORT 0x06 149120016Smjacob#endif 150120016Smjacob#ifndef MSG_BUS_DEV_RESET 151120016Smjacob#define MSG_BUS_DEV_RESET 0x0c 152120016Smjacob#endif 15355372Smjacob#ifndef MSG_ABORT_TAG 154120016Smjacob#define MSG_ABORT_TAG 0x0d 15555372Smjacob#endif 15655372Smjacob#ifndef MSG_CLEAR_QUEUE 15755372Smjacob#define MSG_CLEAR_QUEUE 0x0e 15855372Smjacob#endif 15955372Smjacob#ifndef MSG_REL_RECOVERY 16055372Smjacob#define MSG_REL_RECOVERY 0x10 16155372Smjacob#endif 16255372Smjacob#ifndef MSG_TERM_IO_PROC 16355372Smjacob#define MSG_TERM_IO_PROC 0x11 16455372Smjacob#endif 165120016Smjacob#ifndef MSG_LUN_RESET 166120016Smjacob#define MSG_LUN_RESET 0x17 167120016Smjacob#endif 16855372Smjacob 16955372Smjacob/* 17055372Smjacob * Notify Acknowledge Entry structure 17155372Smjacob */ 17255372Smjacob#define NA_RSVDLEN 22 17355372Smjacobtypedef struct { 17455372Smjacob isphdr_t na_header; 17555372Smjacob u_int32_t na_reserved; 17655372Smjacob u_int8_t na_lun; /* lun */ 17755372Smjacob u_int8_t na_iid; /* initiator */ 17855372Smjacob u_int8_t na_reserved2; 17955372Smjacob u_int8_t na_tgt; /* target */ 18055372Smjacob u_int32_t na_flags; 18155372Smjacob u_int8_t na_status; 18255372Smjacob u_int8_t na_event; 18355372Smjacob u_int16_t na_seqid; /* sequence id */ 18455372Smjacob u_int16_t na_reserved3[NA_RSVDLEN]; 18555372Smjacob} na_entry_t; 18655372Smjacob 18755372Smjacob/* 18855372Smjacob * Value for the na_event field 18955372Smjacob */ 19055372Smjacob#define NA_RST_CLRD 0x80 /* Clear an async event notification */ 19159453Smjacob#define NA_OK 0x01 /* Notify Acknowledge Succeeded */ 19259453Smjacob#define NA_INVALID 0x06 /* Invalid Notify Acknowledge */ 19355372Smjacob 19455372Smjacob#define NA2_RSVDLEN 21 19555372Smjacobtypedef struct { 19655372Smjacob isphdr_t na_header; 19755372Smjacob u_int32_t na_reserved; 19855372Smjacob u_int8_t na_lun; /* lun */ 19955372Smjacob u_int8_t na_iid; /* initiator */ 20055372Smjacob u_int16_t na_scclun; 20155372Smjacob u_int16_t na_flags; 20255372Smjacob u_int16_t na_reserved2; 20355372Smjacob u_int16_t na_status; 20455372Smjacob u_int16_t na_task_flags; 20555372Smjacob u_int16_t na_seqid; /* sequence id */ 20655372Smjacob u_int16_t na_reserved3[NA2_RSVDLEN]; 20755372Smjacob} na_fcentry_t; 20855372Smjacob#define NAFC_RCOUNT 0x80 /* increment resource count */ 20955372Smjacob#define NAFC_RST_CLRD 0x20 /* Clear LIP Reset */ 21055372Smjacob/* 21155372Smjacob * Accept Target I/O Entry structure 21255372Smjacob */ 21355372Smjacob#define ATIO_CDBLEN 26 21455372Smjacob 21555372Smjacobtypedef struct { 21655372Smjacob isphdr_t at_header; 21773319Smjacob u_int16_t at_reserved; 21873319Smjacob u_int16_t at_handle; 21955372Smjacob u_int8_t at_lun; /* lun */ 22055372Smjacob u_int8_t at_iid; /* initiator */ 22155372Smjacob u_int8_t at_cdblen; /* cdb length */ 22255372Smjacob u_int8_t at_tgt; /* target */ 22355372Smjacob u_int32_t at_flags; 22455372Smjacob u_int8_t at_status; /* firmware status */ 22555372Smjacob u_int8_t at_scsi_status; /* scsi status */ 22655372Smjacob u_int8_t at_tag_val; /* tag value */ 22755372Smjacob u_int8_t at_tag_type; /* tag type */ 22855372Smjacob u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */ 22955372Smjacob u_int8_t at_sense[QLTM_SENSELEN];/* suggested sense data */ 23055372Smjacob} at_entry_t; 23155372Smjacob 23255372Smjacob/* 23355372Smjacob * at_flags values 23455372Smjacob */ 23555372Smjacob#define AT_NODISC 0x00008000 /* disconnect disabled */ 23675195Smjacob#define AT_TQAE 0x00000002 /* Tagged Queue Action enabled */ 23755372Smjacob 23855372Smjacob/* 23955372Smjacob * at_status values 24055372Smjacob */ 24155372Smjacob#define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */ 24255372Smjacob#define AT_RESET 0x0E /* SCSI Bus Reset Occurred */ 24355372Smjacob#define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 24455372Smjacob#define AT_NOCAP 0x16 /* Requested capability not available */ 24555372Smjacob#define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 24655372Smjacob#define AT_CDB 0x3D /* CDB received */ 24755372Smjacob 24855372Smjacob/* 24975195Smjacob * Macros to create and fetch and test concatenated handle and tag value macros 25075195Smjacob */ 25175195Smjacob 25275195Smjacob#define AT_MAKE_TAGID(tid, aep) \ 25375195Smjacob tid = ((aep)->at_handle << 16); \ 25475195Smjacob if ((aep)->at_flags & AT_TQAE) \ 25575195Smjacob (tid) |= ((aep)->at_tag_val + 1) 25675195Smjacob 25775195Smjacob#define CT_MAKE_TAGID(tid, ct) \ 25875195Smjacob tid = ((ct)->ct_fwhandle << 16); \ 25975195Smjacob if ((ct)->ct_flags & CT_TQAE) \ 26075195Smjacob (tid) |= ((ct)->ct_tag_val + 1) 26175195Smjacob 26275195Smjacob#define AT_HAS_TAG(val) ((val) & 0xffff) 26375195Smjacob#define AT_GET_TAG(val) AT_HAS_TAG(val) - 1 26475195Smjacob#define AT_GET_HANDLE(val) ((val) >> 16) 26575195Smjacob 26675195Smjacob/* 26755372Smjacob * Accept Target I/O Entry structure, Type 2 26855372Smjacob */ 26955372Smjacob#define ATIO2_CDBLEN 16 27055372Smjacob 27155372Smjacobtypedef struct { 27255372Smjacob isphdr_t at_header; 27355372Smjacob u_int32_t at_reserved; 27455372Smjacob u_int8_t at_lun; /* lun or reserved */ 27555372Smjacob u_int8_t at_iid; /* initiator */ 27655372Smjacob u_int16_t at_rxid; /* response ID */ 27755372Smjacob u_int16_t at_flags; 27855372Smjacob u_int16_t at_status; /* firmware status */ 279120016Smjacob u_int8_t at_crn; /* command reference number */ 28055372Smjacob u_int8_t at_taskcodes; 28155372Smjacob u_int8_t at_taskflags; 28255372Smjacob u_int8_t at_execodes; 28355372Smjacob u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ 28455372Smjacob u_int32_t at_datalen; /* allocated data len */ 28590224Smjacob u_int16_t at_scclun; /* SCC Lun or reserved */ 28690224Smjacob u_int16_t at_wwpn[4]; /* WWPN of initiator */ 28790224Smjacob u_int16_t at_reserved2[6]; 28873115Smjacob u_int16_t at_oxid; 28955372Smjacob} at2_entry_t; 29055372Smjacob 29170457Smjacob#define ATIO2_WWPN_OFFSET 0x2A 29270457Smjacob#define ATIO2_OXID_OFFSET 0x3E 29370457Smjacob 29455372Smjacob#define ATIO2_TC_ATTR_MASK 0x7 29555372Smjacob#define ATIO2_TC_ATTR_SIMPLEQ 0 29655372Smjacob#define ATIO2_TC_ATTR_HEADOFQ 1 29755372Smjacob#define ATIO2_TC_ATTR_ORDERED 2 29855372Smjacob#define ATIO2_TC_ATTR_ACAQ 4 29955372Smjacob#define ATIO2_TC_ATTR_UNTAGGED 5 30055372Smjacob 301120016Smjacob#define ATIO2_EX_WRITE 0x1 302120016Smjacob#define ATIO2_EX_READ 0x2 303120016Smjacob 30455372Smjacob/* 30555372Smjacob * Continue Target I/O Entry structure 30655372Smjacob * Request from driver. The response from the 30755372Smjacob * ISP firmware is the same except that the last 18 30855372Smjacob * bytes are overwritten by suggested sense data if 30955372Smjacob * the 'autosense valid' bit is set in the status byte. 31055372Smjacob */ 31155372Smjacobtypedef struct { 31255372Smjacob isphdr_t ct_header; 31373319Smjacob u_int16_t ct_reserved; 31473319Smjacob#define ct_syshandle ct_reserved /* we use this */ 31573319Smjacob u_int16_t ct_fwhandle; /* required by f/w */ 31655372Smjacob u_int8_t ct_lun; /* lun */ 31755372Smjacob u_int8_t ct_iid; /* initiator id */ 31855372Smjacob u_int8_t ct_reserved2; 31955372Smjacob u_int8_t ct_tgt; /* our target id */ 32055372Smjacob u_int32_t ct_flags; 32155372Smjacob u_int8_t ct_status; /* isp status */ 32255372Smjacob u_int8_t ct_scsi_status; /* scsi status */ 32355372Smjacob u_int8_t ct_tag_val; /* tag value */ 32455372Smjacob u_int8_t ct_tag_type; /* tag type */ 32555372Smjacob u_int32_t ct_xfrlen; /* transfer length */ 32655372Smjacob u_int32_t ct_resid; /* residual length */ 32755372Smjacob u_int16_t ct_timeout; 32855372Smjacob u_int16_t ct_seg_count; 32987635Smjacob /* 33087635Smjacob * This is so we can share tag name space with 33187635Smjacob * CTIO{2,3,4} with the minimum of pain. 33287635Smjacob */ 33387635Smjacob union { 33487635Smjacob ispds_t ct_a[ISP_RQDSEG]; 33587635Smjacob } _u; 33687635Smjacob#define ct_dataseg _u.ct_a 33755372Smjacob} ct_entry_t; 33855372Smjacob 33955372Smjacob/* 34056005Smjacob * For some of the dual port SCSI adapters, port (bus #) is reported 34156005Smjacob * in the MSbit of ct_iid. Bit fields are a bit too awkward here. 34256005Smjacob * 34356005Smjacob * Note that this does not apply to FC adapters at all which can and 34456005Smjacob * do report IIDs between 129 && 255 (these represent devices that have 34556005Smjacob * logged in across a SCSI fabric). 34656005Smjacob */ 34756005Smjacob#define GET_IID_VAL(x) (x & 0x3f) 34856005Smjacob#define GET_BUS_VAL(x) ((x >> 7) & 0x1) 34983005Smjacob#define SET_IID_VAL(y, x) y = ((y & ~0x3f) | (x & 0x3f)) 35083005Smjacob#define SET_BUS_VAL(y, x) y = ((y & 0x3f) | ((x & 0x1) << 7)) 35156005Smjacob 35256005Smjacob/* 35355372Smjacob * ct_flags values 35455372Smjacob */ 35575195Smjacob#define CT_TQAE 0x00000002 /* bit 1, Tagged Queue Action enable */ 35655372Smjacob#define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */ 35755372Smjacob#define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */ 35855372Smjacob#define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */ 35955372Smjacob#define CT_CCINCR 0x00000100 /* bit 8, autoincrement atio count */ 36055372Smjacob#define CT_DATAMASK 0x000000C0 /* bits 6&7, Data direction */ 36163390Smjacob#define CT_INISYNCWIDE 0x00004000 /* bit 14, Do Sync/Wide Negotiation */ 36255372Smjacob#define CT_NODISC 0x00008000 /* bit 15, Disconnects disabled */ 36355372Smjacob#define CT_DSDP 0x01000000 /* bit 24, Disable Save Data Pointers */ 36455372Smjacob#define CT_SENDRDP 0x04000000 /* bit 26, Send Restore Pointers msg */ 36555372Smjacob#define CT_SENDSTATUS 0x80000000 /* bit 31, Send SCSI status byte */ 36655372Smjacob 36755372Smjacob/* 36855372Smjacob * ct_status values 36955372Smjacob * - set by the firmware when it returns the CTIO 37055372Smjacob */ 37155372Smjacob#define CT_OK 0x01 /* completed without error */ 37255372Smjacob#define CT_ABORTED 0x02 /* aborted by host */ 37355372Smjacob#define CT_ERR 0x04 /* see sense data for error */ 37455372Smjacob#define CT_INVAL 0x06 /* request for disabled lun */ 37555372Smjacob#define CT_NOPATH 0x07 /* invalid ITL nexus */ 37655372Smjacob#define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */ 37777365Smjacob#define CT_DATA_OVER 0x09 /* (FC only) Data Overrun */ 37855372Smjacob#define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */ 37955372Smjacob#define CT_TIMEOUT 0x0B /* timed out */ 38055372Smjacob#define CT_RESET 0x0E /* SCSI Bus Reset occurred */ 38163390Smjacob#define CT_PARITY 0x0F /* Uncorrectable Parity Error */ 38277365Smjacob#define CT_BUS_ERROR 0x10 /* (FC Only) DMA PCI Error */ 38363390Smjacob#define CT_PANIC 0x13 /* Unrecoverable Error */ 38455372Smjacob#define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 38555372Smjacob#define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 38677365Smjacob#define CT_DATA_UNDER 0x15 /* (FC only) Data Underrun */ 38755372Smjacob#define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ 38855372Smjacob#define CT_PORTNOTAVAIL 0x28 /* port not available */ 38955372Smjacob#define CT_LOGOUT 0x29 /* port logout */ 39055372Smjacob#define CT_PORTCHANGED 0x2A /* port changed */ 39163390Smjacob#define CT_IDE 0x33 /* Initiator Detected Error */ 39255372Smjacob#define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */ 39355372Smjacob 39455372Smjacob/* 39555372Smjacob * When the firmware returns a CTIO entry, it may overwrite the last 39655372Smjacob * part of the structure with sense data. This starts at offset 0x2E 39755372Smjacob * into the entry, which is in the middle of ct_dataseg[1]. Rather 39855372Smjacob * than define a new struct for this, I'm just using the sense data 39955372Smjacob * offset. 40055372Smjacob */ 40155372Smjacob#define CTIO_SENSE_OFFSET 0x2E 40255372Smjacob 40355372Smjacob/* 40455372Smjacob * Entry length in u_longs. All entries are the same size so 40555372Smjacob * any one will do as the numerator. 40655372Smjacob */ 40755372Smjacob#define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t)) 40855372Smjacob 40955372Smjacob/* 41055372Smjacob * QLA2100 CTIO (type 2) entry 41155372Smjacob */ 41255372Smjacob#define MAXRESPLEN 26 41355372Smjacobtypedef struct { 41455372Smjacob isphdr_t ct_header; 41573319Smjacob u_int16_t ct_reserved; 41673319Smjacob u_int16_t ct_fwhandle; /* just to match CTIO */ 41792893Smjacob u_int8_t ct_lun; /* lun */ 41892893Smjacob u_int8_t ct_iid; /* initiator id */ 41992893Smjacob u_int16_t ct_rxid; /* response ID */ 42055372Smjacob u_int16_t ct_flags; 42155372Smjacob u_int16_t ct_status; /* isp status */ 42255372Smjacob u_int16_t ct_timeout; 42355372Smjacob u_int16_t ct_seg_count; 42455372Smjacob u_int32_t ct_reloff; /* relative offset */ 42556005Smjacob int32_t ct_resid; /* residual length */ 42655372Smjacob union { 42755372Smjacob /* 42855372Smjacob * The three different modes that the target driver 42987635Smjacob * can set the CTIO{2,3,4} up as. 43055372Smjacob * 43155372Smjacob * The first is for sending FCP_DATA_IUs as well as 43255372Smjacob * (optionally) sending a terminal SCSI status FCP_RSP_IU. 43355372Smjacob * 43455372Smjacob * The second is for sending SCSI sense data in an FCP_RSP_IU. 43555372Smjacob * Note that no FCP_DATA_IUs will be sent. 43655372Smjacob * 43755372Smjacob * The third is for sending FCP_RSP_IUs as built specifically 43855372Smjacob * in system memory as located by the isp_dataseg. 43955372Smjacob */ 44055372Smjacob struct { 44155372Smjacob u_int32_t _reserved; 44255372Smjacob u_int16_t _reserved2; 44355372Smjacob u_int16_t ct_scsi_status; 44455372Smjacob u_int32_t ct_xfrlen; 44587635Smjacob union { 44687635Smjacob ispds_t ct_a[ISP_RQDSEG_T2]; /* CTIO2 */ 44787635Smjacob ispds64_t ct_b[ISP_RQDSEG_T3]; /* CTIO3 */ 44887635Smjacob ispdslist_t ct_c; /* CTIO4 */ 44987635Smjacob } _u; 45087635Smjacob#define ct_dataseg _u.ct_a 45187635Smjacob#define ct_dataseg64 _u.ct_b 45287635Smjacob#define ct_dslist _u.ct_c 45355372Smjacob } m0; 45455372Smjacob struct { 45555372Smjacob u_int16_t _reserved; 45655372Smjacob u_int16_t _reserved2; 45755372Smjacob u_int16_t ct_senselen; 45855372Smjacob u_int16_t ct_scsi_status; 45955372Smjacob u_int16_t ct_resplen; 46055372Smjacob u_int8_t ct_resp[MAXRESPLEN]; 46155372Smjacob } m1; 46255372Smjacob struct { 46355372Smjacob u_int32_t _reserved; 46455372Smjacob u_int16_t _reserved2; 46555372Smjacob u_int16_t _reserved3; 46655372Smjacob u_int32_t ct_datalen; 46755372Smjacob ispds_t ct_fcp_rsp_iudata; 46855372Smjacob } m2; 46955372Smjacob } rsp; 47055372Smjacob} ct2_entry_t; 47155372Smjacob 47255372Smjacob/* 47355372Smjacob * ct_flags values for CTIO2 47455372Smjacob */ 47555372Smjacob#define CT2_FLAG_MMASK 0x0003 47655372Smjacob#define CT2_FLAG_MODE0 0x0000 47755372Smjacob#define CT2_FLAG_MODE1 0x0001 47855372Smjacob#define CT2_FLAG_MODE2 0x0002 47955372Smjacob#define CT2_DATA_IN CT_DATA_IN 48055372Smjacob#define CT2_DATA_OUT CT_DATA_OUT 48155372Smjacob#define CT2_NO_DATA CT_NO_DATA 48255372Smjacob#define CT2_DATAMASK CT_DATAMASK 48355372Smjacob#define CT2_CCINCR 0x0100 48455372Smjacob#define CT2_FASTPOST 0x0200 485120016Smjacob#define CT2_TERMINATE 0x4000 48655372Smjacob#define CT2_SENDSTATUS 0x8000 48755372Smjacob 48855372Smjacob/* 48955372Smjacob * ct_status values are (mostly) the same as that for ct_entry. 49055372Smjacob */ 49155372Smjacob 49255372Smjacob/* 49355372Smjacob * ct_scsi_status values- the low 8 bits are the normal SCSI status 49455372Smjacob * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU 49555372Smjacob * fields. 49655372Smjacob */ 49755372Smjacob#define CT2_RSPLEN_VALID 0x0100 49855372Smjacob#define CT2_SNSLEN_VALID 0x0200 49955372Smjacob#define CT2_DATA_OVER 0x0400 50055372Smjacob#define CT2_DATA_UNDER 0x0800 50155372Smjacob 50255372Smjacob/* 50355372Smjacob * Debug macros 50455372Smjacob */ 50555372Smjacob 50655372Smjacob#define ISP_TDQE(isp, msg, idx, arg) \ 50764089Smjacob if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg) 50855372Smjacob 50987635Smjacob#ifdef ISP_TARGET_FUNCTIONS 51055372Smjacob/* 51187635Smjacob * The functions below are for the publicly available 51287635Smjacob * target mode functions that are internal to the Qlogic driver. 51355372Smjacob */ 51455372Smjacob 51555372Smjacob/* 51655372Smjacob * This function handles new response queue entry appropriate for target mode. 51755372Smjacob */ 51875195Smjacobint isp_target_notify(struct ispsoftc *, void *, u_int16_t *); 51955372Smjacob 52055372Smjacob/* 52155372Smjacob * Enable/Disable/Modify a logical unit. 52277365Smjacob * (softc, cmd, bus, tgt, lun, cmd_cnt, inotify_cnt, opaque) 52355372Smjacob */ 52498283Smjacob#define DFLT_CMND_CNT 0xfe /* unmonitored */ 52598283Smjacob#define DFLT_INOT_CNT 16 52677365Smjacobint isp_lun_cmd(struct ispsoftc *, int, int, int, int, int, int, u_int32_t); 52755372Smjacob 52855372Smjacob/* 52955372Smjacob * General request queue 'put' routine for target mode entries. 53055372Smjacob */ 53175195Smjacobint isp_target_put_entry(struct ispsoftc *isp, void *); 53255372Smjacob 53355372Smjacob/* 53455372Smjacob * General routine to put back an ATIO entry- 53555372Smjacob * used for replenishing f/w resource counts. 53675195Smjacob * The argument is a pointer to a source ATIO 53775195Smjacob * or ATIO2. 53855372Smjacob */ 53975195Smjacobint isp_target_put_atio(struct ispsoftc *, void *); 54055372Smjacob 54155372Smjacob/* 54255372Smjacob * General routine to send a final CTIO for a command- used mostly for 54355372Smjacob * local responses. 54455372Smjacob */ 54575195Smjacobint isp_endcmd(struct ispsoftc *, void *, u_int32_t, u_int16_t); 54656005Smjacob#define ECMD_SVALID 0x100 54755372Smjacob 54855372Smjacob/* 54955372Smjacob * Handle an asynchronous event 55098283Smjacob * 55198283Smjacob * Return nonzero if the interrupt that generated this event has been dismissed. 55255372Smjacob */ 55355372Smjacob 55498283Smjacobint isp_target_async(struct ispsoftc *, int, int); 55587635Smjacob#endif 55674231Smjacob#endif /* _ISP_TARGET_H */ 557