isp_target.h revision 87635
155372Smjacob/* $FreeBSD: head/sys/dev/isp/isp_target.h 87635 2001-12-11 00:18:45Z 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 3955372Smjacob/* 4055372Smjacob * Defines for all entry types 4155372Smjacob */ 4255372Smjacob#define QLTM_SVALID 0x80 4355372Smjacob#define QLTM_SENSELEN 18 4455372Smjacob 4555372Smjacob/* 4655372Smjacob * Structure for Enable Lun and Modify Lun queue entries 4755372Smjacob */ 4855372Smjacobtypedef struct { 4955372Smjacob isphdr_t le_header; 5055372Smjacob u_int32_t le_reserved; 5155372Smjacob u_int8_t le_lun; 5255372Smjacob u_int8_t le_rsvd; 5355372Smjacob u_int8_t le_ops; /* Modify LUN only */ 5455372Smjacob u_int8_t le_tgt; /* Not for FC */ 5555372Smjacob u_int32_t le_flags; /* Not for FC */ 5655372Smjacob u_int8_t le_status; 5755372Smjacob u_int8_t le_reserved2; 5855372Smjacob u_int8_t le_cmd_count; 5955372Smjacob u_int8_t le_in_count; 6055372Smjacob u_int8_t le_cdb6len; /* Not for FC */ 6155372Smjacob u_int8_t le_cdb7len; /* Not for FC */ 6255372Smjacob u_int16_t le_timeout; 6355372Smjacob u_int16_t le_reserved3[20]; 6455372Smjacob} lun_entry_t; 6555372Smjacob 6655372Smjacob/* 6755372Smjacob * le_flags values 6855372Smjacob */ 6975195Smjacob#define LUN_TQAE 0x00000002 /* bit1 Tagged Queue Action Enable */ 7055372Smjacob#define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */ 7161771Smjacob#define LUN_DISAD 0x02000000 /* bit25 Disable autodisconnect */ 7255372Smjacob#define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */ 7355372Smjacob 7455372Smjacob/* 7555372Smjacob * le_ops values 7655372Smjacob */ 7755372Smjacob#define LUN_CCINCR 0x01 /* increment command count */ 7855372Smjacob#define LUN_CCDECR 0x02 /* decrement command count */ 7955372Smjacob#define LUN_ININCR 0x40 /* increment immed. notify count */ 8055372Smjacob#define LUN_INDECR 0x80 /* decrement immed. notify count */ 8155372Smjacob 8255372Smjacob/* 8355372Smjacob * le_status values 8455372Smjacob */ 8555372Smjacob#define LUN_OK 0x01 /* we be rockin' */ 8655372Smjacob#define LUN_ERR 0x04 /* request completed with error */ 8755372Smjacob#define LUN_INVAL 0x06 /* invalid request */ 8855372Smjacob#define LUN_NOCAP 0x16 /* can't provide requested capability */ 8955372Smjacob#define LUN_ENABLED 0x3E /* LUN already enabled */ 9055372Smjacob 9155372Smjacob/* 9255372Smjacob * Immediate Notify Entry structure 9355372Smjacob */ 9455372Smjacob#define IN_MSGLEN 8 /* 8 bytes */ 9555372Smjacob#define IN_RSVDLEN 8 /* 8 words */ 9655372Smjacobtypedef struct { 9755372Smjacob isphdr_t in_header; 9855372Smjacob u_int32_t in_reserved; 9955372Smjacob u_int8_t in_lun; /* lun */ 10055372Smjacob u_int8_t in_iid; /* initiator */ 10155372Smjacob u_int8_t in_reserved2; 10255372Smjacob u_int8_t in_tgt; /* target */ 10355372Smjacob u_int32_t in_flags; 10455372Smjacob u_int8_t in_status; 10555372Smjacob u_int8_t in_rsvd2; 10655372Smjacob u_int8_t in_tag_val; /* tag value */ 10755372Smjacob u_int8_t in_tag_type; /* tag type */ 10855372Smjacob u_int16_t in_seqid; /* sequence id */ 10955372Smjacob u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */ 11055372Smjacob u_int16_t in_reserved3[IN_RSVDLEN]; 11155372Smjacob u_int8_t in_sense[QLTM_SENSELEN];/* suggested sense data */ 11255372Smjacob} in_entry_t; 11355372Smjacob 11455372Smjacobtypedef struct { 11555372Smjacob isphdr_t in_header; 11655372Smjacob u_int32_t in_reserved; 11755372Smjacob u_int8_t in_lun; /* lun */ 11855372Smjacob u_int8_t in_iid; /* initiator */ 11955372Smjacob u_int16_t in_scclun; 12055372Smjacob u_int32_t in_reserved2; 12155372Smjacob u_int16_t in_status; 12255372Smjacob u_int16_t in_task_flags; 12355372Smjacob u_int16_t in_seqid; /* sequence id */ 12455372Smjacob} in_fcentry_t; 12555372Smjacob 12655372Smjacob/* 12755372Smjacob * Values for the in_status field 12855372Smjacob */ 12963390Smjacob#define IN_REJECT 0x0D /* Message Reject message received */ 13055372Smjacob#define IN_RESET 0x0E /* Bus Reset occurred */ 13155372Smjacob#define IN_NO_RCAP 0x16 /* requested capability not available */ 13255372Smjacob#define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */ 13355372Smjacob#define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */ 13455372Smjacob#define IN_MSG_RECEIVED 0x36 /* SCSI message received */ 13555372Smjacob#define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */ 13655372Smjacob#define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */ 13755372Smjacob#define IN_PORT_CHANGED 0x2A /* port changed */ 13855372Smjacob#define IN_GLOBAL_LOGO 0x2E /* all ports logged out */ 13963390Smjacob#define IN_NO_NEXUS 0x3B /* Nexus not established */ 14055372Smjacob 14155372Smjacob/* 14255372Smjacob * Values for the in_task_flags field- should only get one at a time! 14355372Smjacob */ 14455372Smjacob#define TASK_FLAGS_ABORT_TASK (1<<9) 14555372Smjacob#define TASK_FLAGS_CLEAR_TASK_SET (1<<10) 14655372Smjacob#define TASK_FLAGS_TARGET_RESET (1<<13) 14755372Smjacob#define TASK_FLAGS_CLEAR_ACA (1<<14) 14855372Smjacob#define TASK_FLAGS_TERMINATE_TASK (1<<15) 14955372Smjacob 15055372Smjacob#ifndef MSG_ABORT_TAG 15155372Smjacob#define MSG_ABORT_TAG 0x06 15255372Smjacob#endif 15355372Smjacob#ifndef MSG_CLEAR_QUEUE 15455372Smjacob#define MSG_CLEAR_QUEUE 0x0e 15555372Smjacob#endif 15655372Smjacob#ifndef MSG_BUS_DEV_RESET 15755372Smjacob#define MSG_BUS_DEV_RESET 0x0b 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 16555372Smjacob 16655372Smjacob 16755372Smjacob/* 16855372Smjacob * Notify Acknowledge Entry structure 16955372Smjacob */ 17055372Smjacob#define NA_RSVDLEN 22 17155372Smjacobtypedef struct { 17255372Smjacob isphdr_t na_header; 17355372Smjacob u_int32_t na_reserved; 17455372Smjacob u_int8_t na_lun; /* lun */ 17555372Smjacob u_int8_t na_iid; /* initiator */ 17655372Smjacob u_int8_t na_reserved2; 17755372Smjacob u_int8_t na_tgt; /* target */ 17855372Smjacob u_int32_t na_flags; 17955372Smjacob u_int8_t na_status; 18055372Smjacob u_int8_t na_event; 18155372Smjacob u_int16_t na_seqid; /* sequence id */ 18255372Smjacob u_int16_t na_reserved3[NA_RSVDLEN]; 18355372Smjacob} na_entry_t; 18455372Smjacob 18555372Smjacob/* 18655372Smjacob * Value for the na_event field 18755372Smjacob */ 18855372Smjacob#define NA_RST_CLRD 0x80 /* Clear an async event notification */ 18959453Smjacob#define NA_OK 0x01 /* Notify Acknowledge Succeeded */ 19059453Smjacob#define NA_INVALID 0x06 /* Invalid Notify Acknowledge */ 19155372Smjacob 19255372Smjacob#define NA2_RSVDLEN 21 19355372Smjacobtypedef struct { 19455372Smjacob isphdr_t na_header; 19555372Smjacob u_int32_t na_reserved; 19655372Smjacob u_int8_t na_lun; /* lun */ 19755372Smjacob u_int8_t na_iid; /* initiator */ 19855372Smjacob u_int16_t na_scclun; 19955372Smjacob u_int16_t na_flags; 20055372Smjacob u_int16_t na_reserved2; 20155372Smjacob u_int16_t na_status; 20255372Smjacob u_int16_t na_task_flags; 20355372Smjacob u_int16_t na_seqid; /* sequence id */ 20455372Smjacob u_int16_t na_reserved3[NA2_RSVDLEN]; 20555372Smjacob} na_fcentry_t; 20655372Smjacob#define NAFC_RCOUNT 0x80 /* increment resource count */ 20755372Smjacob#define NAFC_RST_CLRD 0x20 /* Clear LIP Reset */ 20855372Smjacob/* 20955372Smjacob * Accept Target I/O Entry structure 21055372Smjacob */ 21155372Smjacob#define ATIO_CDBLEN 26 21255372Smjacob 21355372Smjacobtypedef struct { 21455372Smjacob isphdr_t at_header; 21573319Smjacob u_int16_t at_reserved; 21673319Smjacob u_int16_t at_handle; 21755372Smjacob u_int8_t at_lun; /* lun */ 21855372Smjacob u_int8_t at_iid; /* initiator */ 21955372Smjacob u_int8_t at_cdblen; /* cdb length */ 22055372Smjacob u_int8_t at_tgt; /* target */ 22155372Smjacob u_int32_t at_flags; 22255372Smjacob u_int8_t at_status; /* firmware status */ 22355372Smjacob u_int8_t at_scsi_status; /* scsi status */ 22455372Smjacob u_int8_t at_tag_val; /* tag value */ 22555372Smjacob u_int8_t at_tag_type; /* tag type */ 22655372Smjacob u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */ 22755372Smjacob u_int8_t at_sense[QLTM_SENSELEN];/* suggested sense data */ 22855372Smjacob} at_entry_t; 22955372Smjacob 23055372Smjacob/* 23155372Smjacob * at_flags values 23255372Smjacob */ 23355372Smjacob#define AT_NODISC 0x00008000 /* disconnect disabled */ 23475195Smjacob#define AT_TQAE 0x00000002 /* Tagged Queue Action enabled */ 23555372Smjacob 23655372Smjacob/* 23755372Smjacob * at_status values 23855372Smjacob */ 23955372Smjacob#define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */ 24055372Smjacob#define AT_RESET 0x0E /* SCSI Bus Reset Occurred */ 24155372Smjacob#define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 24255372Smjacob#define AT_NOCAP 0x16 /* Requested capability not available */ 24355372Smjacob#define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 24455372Smjacob#define AT_CDB 0x3D /* CDB received */ 24555372Smjacob 24655372Smjacob/* 24775195Smjacob * Macros to create and fetch and test concatenated handle and tag value macros 24875195Smjacob */ 24975195Smjacob 25075195Smjacob#define AT_MAKE_TAGID(tid, aep) \ 25175195Smjacob tid = ((aep)->at_handle << 16); \ 25275195Smjacob if ((aep)->at_flags & AT_TQAE) \ 25375195Smjacob (tid) |= ((aep)->at_tag_val + 1) 25475195Smjacob 25575195Smjacob#define CT_MAKE_TAGID(tid, ct) \ 25675195Smjacob tid = ((ct)->ct_fwhandle << 16); \ 25775195Smjacob if ((ct)->ct_flags & CT_TQAE) \ 25875195Smjacob (tid) |= ((ct)->ct_tag_val + 1) 25975195Smjacob 26075195Smjacob#define AT_HAS_TAG(val) ((val) & 0xffff) 26175195Smjacob#define AT_GET_TAG(val) AT_HAS_TAG(val) - 1 26275195Smjacob#define AT_GET_HANDLE(val) ((val) >> 16) 26375195Smjacob 26475195Smjacob/* 26555372Smjacob * Accept Target I/O Entry structure, Type 2 26655372Smjacob */ 26755372Smjacob#define ATIO2_CDBLEN 16 26855372Smjacob 26955372Smjacobtypedef struct { 27055372Smjacob isphdr_t at_header; 27155372Smjacob u_int32_t at_reserved; 27255372Smjacob u_int8_t at_lun; /* lun or reserved */ 27355372Smjacob u_int8_t at_iid; /* initiator */ 27455372Smjacob u_int16_t at_rxid; /* response ID */ 27555372Smjacob u_int16_t at_flags; 27655372Smjacob u_int16_t at_status; /* firmware status */ 27755372Smjacob u_int8_t at_reserved1; 27855372Smjacob u_int8_t at_taskcodes; 27955372Smjacob u_int8_t at_taskflags; 28055372Smjacob u_int8_t at_execodes; 28155372Smjacob u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ 28255372Smjacob u_int32_t at_datalen; /* allocated data len */ 28355372Smjacob u_int16_t at_scclun; /* SCC Lun or reserved */ 28473115Smjacob u_int16_t at_reserved2[10]; 28573115Smjacob u_int16_t at_oxid; 28655372Smjacob} at2_entry_t; 28755372Smjacob 28870457Smjacob#define ATIO2_WWPN_OFFSET 0x2A 28970457Smjacob#define ATIO2_OXID_OFFSET 0x3E 29070457Smjacob 29155372Smjacob#define ATIO2_TC_ATTR_MASK 0x7 29255372Smjacob#define ATIO2_TC_ATTR_SIMPLEQ 0 29355372Smjacob#define ATIO2_TC_ATTR_HEADOFQ 1 29455372Smjacob#define ATIO2_TC_ATTR_ORDERED 2 29555372Smjacob#define ATIO2_TC_ATTR_ACAQ 4 29655372Smjacob#define ATIO2_TC_ATTR_UNTAGGED 5 29755372Smjacob 29855372Smjacob/* 29955372Smjacob * Continue Target I/O Entry structure 30055372Smjacob * Request from driver. The response from the 30155372Smjacob * ISP firmware is the same except that the last 18 30255372Smjacob * bytes are overwritten by suggested sense data if 30355372Smjacob * the 'autosense valid' bit is set in the status byte. 30455372Smjacob */ 30555372Smjacobtypedef struct { 30655372Smjacob isphdr_t ct_header; 30773319Smjacob u_int16_t ct_reserved; 30873319Smjacob#define ct_syshandle ct_reserved /* we use this */ 30973319Smjacob u_int16_t ct_fwhandle; /* required by f/w */ 31055372Smjacob u_int8_t ct_lun; /* lun */ 31155372Smjacob u_int8_t ct_iid; /* initiator id */ 31255372Smjacob u_int8_t ct_reserved2; 31355372Smjacob u_int8_t ct_tgt; /* our target id */ 31455372Smjacob u_int32_t ct_flags; 31555372Smjacob u_int8_t ct_status; /* isp status */ 31655372Smjacob u_int8_t ct_scsi_status; /* scsi status */ 31755372Smjacob u_int8_t ct_tag_val; /* tag value */ 31855372Smjacob u_int8_t ct_tag_type; /* tag type */ 31955372Smjacob u_int32_t ct_xfrlen; /* transfer length */ 32055372Smjacob u_int32_t ct_resid; /* residual length */ 32155372Smjacob u_int16_t ct_timeout; 32255372Smjacob u_int16_t ct_seg_count; 32387635Smjacob /* 32487635Smjacob * This is so we can share tag name space with 32587635Smjacob * CTIO{2,3,4} with the minimum of pain. 32687635Smjacob */ 32787635Smjacob union { 32887635Smjacob ispds_t ct_a[ISP_RQDSEG]; 32987635Smjacob } _u; 33087635Smjacob#define ct_dataseg _u.ct_a 33155372Smjacob} ct_entry_t; 33255372Smjacob 33355372Smjacob/* 33456005Smjacob * For some of the dual port SCSI adapters, port (bus #) is reported 33556005Smjacob * in the MSbit of ct_iid. Bit fields are a bit too awkward here. 33656005Smjacob * 33756005Smjacob * Note that this does not apply to FC adapters at all which can and 33856005Smjacob * do report IIDs between 129 && 255 (these represent devices that have 33956005Smjacob * logged in across a SCSI fabric). 34056005Smjacob */ 34156005Smjacob#define GET_IID_VAL(x) (x & 0x3f) 34256005Smjacob#define GET_BUS_VAL(x) ((x >> 7) & 0x1) 34383005Smjacob#define SET_IID_VAL(y, x) y = ((y & ~0x3f) | (x & 0x3f)) 34483005Smjacob#define SET_BUS_VAL(y, x) y = ((y & 0x3f) | ((x & 0x1) << 7)) 34556005Smjacob 34656005Smjacob/* 34755372Smjacob * ct_flags values 34855372Smjacob */ 34975195Smjacob#define CT_TQAE 0x00000002 /* bit 1, Tagged Queue Action enable */ 35055372Smjacob#define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */ 35155372Smjacob#define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */ 35255372Smjacob#define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */ 35355372Smjacob#define CT_CCINCR 0x00000100 /* bit 8, autoincrement atio count */ 35455372Smjacob#define CT_DATAMASK 0x000000C0 /* bits 6&7, Data direction */ 35563390Smjacob#define CT_INISYNCWIDE 0x00004000 /* bit 14, Do Sync/Wide Negotiation */ 35655372Smjacob#define CT_NODISC 0x00008000 /* bit 15, Disconnects disabled */ 35755372Smjacob#define CT_DSDP 0x01000000 /* bit 24, Disable Save Data Pointers */ 35855372Smjacob#define CT_SENDRDP 0x04000000 /* bit 26, Send Restore Pointers msg */ 35955372Smjacob#define CT_SENDSTATUS 0x80000000 /* bit 31, Send SCSI status byte */ 36055372Smjacob 36155372Smjacob/* 36255372Smjacob * ct_status values 36355372Smjacob * - set by the firmware when it returns the CTIO 36455372Smjacob */ 36555372Smjacob#define CT_OK 0x01 /* completed without error */ 36655372Smjacob#define CT_ABORTED 0x02 /* aborted by host */ 36755372Smjacob#define CT_ERR 0x04 /* see sense data for error */ 36855372Smjacob#define CT_INVAL 0x06 /* request for disabled lun */ 36955372Smjacob#define CT_NOPATH 0x07 /* invalid ITL nexus */ 37055372Smjacob#define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */ 37177365Smjacob#define CT_DATA_OVER 0x09 /* (FC only) Data Overrun */ 37255372Smjacob#define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */ 37355372Smjacob#define CT_TIMEOUT 0x0B /* timed out */ 37455372Smjacob#define CT_RESET 0x0E /* SCSI Bus Reset occurred */ 37563390Smjacob#define CT_PARITY 0x0F /* Uncorrectable Parity Error */ 37677365Smjacob#define CT_BUS_ERROR 0x10 /* (FC Only) DMA PCI Error */ 37763390Smjacob#define CT_PANIC 0x13 /* Unrecoverable Error */ 37855372Smjacob#define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 37955372Smjacob#define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 38077365Smjacob#define CT_DATA_UNDER 0x15 /* (FC only) Data Underrun */ 38155372Smjacob#define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ 38255372Smjacob#define CT_PORTNOTAVAIL 0x28 /* port not available */ 38355372Smjacob#define CT_LOGOUT 0x29 /* port logout */ 38455372Smjacob#define CT_PORTCHANGED 0x2A /* port changed */ 38563390Smjacob#define CT_IDE 0x33 /* Initiator Detected Error */ 38655372Smjacob#define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */ 38755372Smjacob 38855372Smjacob/* 38955372Smjacob * When the firmware returns a CTIO entry, it may overwrite the last 39055372Smjacob * part of the structure with sense data. This starts at offset 0x2E 39155372Smjacob * into the entry, which is in the middle of ct_dataseg[1]. Rather 39255372Smjacob * than define a new struct for this, I'm just using the sense data 39355372Smjacob * offset. 39455372Smjacob */ 39555372Smjacob#define CTIO_SENSE_OFFSET 0x2E 39655372Smjacob 39755372Smjacob/* 39855372Smjacob * Entry length in u_longs. All entries are the same size so 39955372Smjacob * any one will do as the numerator. 40055372Smjacob */ 40155372Smjacob#define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t)) 40255372Smjacob 40355372Smjacob/* 40455372Smjacob * QLA2100 CTIO (type 2) entry 40555372Smjacob */ 40655372Smjacob#define MAXRESPLEN 26 40755372Smjacobtypedef struct { 40855372Smjacob isphdr_t ct_header; 40973319Smjacob u_int16_t ct_reserved; 41073319Smjacob u_int16_t ct_fwhandle; /* just to match CTIO */ 41155372Smjacob u_int8_t ct_lun; /* lun */ 41255372Smjacob u_int8_t ct_iid; /* initiator id */ 41355372Smjacob u_int16_t ct_rxid; /* response ID */ 41455372Smjacob u_int16_t ct_flags; 41555372Smjacob u_int16_t ct_status; /* isp status */ 41655372Smjacob u_int16_t ct_timeout; 41755372Smjacob u_int16_t ct_seg_count; 41855372Smjacob u_int32_t ct_reloff; /* relative offset */ 41956005Smjacob int32_t ct_resid; /* residual length */ 42055372Smjacob union { 42155372Smjacob /* 42255372Smjacob * The three different modes that the target driver 42387635Smjacob * can set the CTIO{2,3,4} up as. 42455372Smjacob * 42555372Smjacob * The first is for sending FCP_DATA_IUs as well as 42655372Smjacob * (optionally) sending a terminal SCSI status FCP_RSP_IU. 42755372Smjacob * 42855372Smjacob * The second is for sending SCSI sense data in an FCP_RSP_IU. 42955372Smjacob * Note that no FCP_DATA_IUs will be sent. 43055372Smjacob * 43155372Smjacob * The third is for sending FCP_RSP_IUs as built specifically 43255372Smjacob * in system memory as located by the isp_dataseg. 43355372Smjacob */ 43455372Smjacob struct { 43555372Smjacob u_int32_t _reserved; 43655372Smjacob u_int16_t _reserved2; 43755372Smjacob u_int16_t ct_scsi_status; 43855372Smjacob u_int32_t ct_xfrlen; 43987635Smjacob union { 44087635Smjacob ispds_t ct_a[ISP_RQDSEG_T2]; /* CTIO2 */ 44187635Smjacob ispds64_t ct_b[ISP_RQDSEG_T3]; /* CTIO3 */ 44287635Smjacob ispdslist_t ct_c; /* CTIO4 */ 44387635Smjacob } _u; 44487635Smjacob#define ct_dataseg _u.ct_a 44587635Smjacob#define ct_dataseg64 _u.ct_b 44687635Smjacob#define ct_dslist _u.ct_c 44755372Smjacob } m0; 44855372Smjacob struct { 44955372Smjacob u_int16_t _reserved; 45055372Smjacob u_int16_t _reserved2; 45155372Smjacob u_int16_t ct_senselen; 45255372Smjacob u_int16_t ct_scsi_status; 45355372Smjacob u_int16_t ct_resplen; 45455372Smjacob u_int8_t ct_resp[MAXRESPLEN]; 45555372Smjacob } m1; 45655372Smjacob struct { 45755372Smjacob u_int32_t _reserved; 45855372Smjacob u_int16_t _reserved2; 45955372Smjacob u_int16_t _reserved3; 46055372Smjacob u_int32_t ct_datalen; 46155372Smjacob ispds_t ct_fcp_rsp_iudata; 46255372Smjacob } m2; 46355372Smjacob /* 46455372Smjacob * CTIO2 returned from F/W... 46555372Smjacob */ 46655372Smjacob struct { 46755372Smjacob u_int32_t _reserved[4]; 46855372Smjacob u_int16_t ct_scsi_status; 46955372Smjacob u_int8_t ct_sense[QLTM_SENSELEN]; 47055372Smjacob } fw; 47155372Smjacob } rsp; 47255372Smjacob} ct2_entry_t; 47355372Smjacob 47455372Smjacob/* 47555372Smjacob * ct_flags values for CTIO2 47655372Smjacob */ 47755372Smjacob#define CT2_FLAG_MMASK 0x0003 47855372Smjacob#define CT2_FLAG_MODE0 0x0000 47955372Smjacob#define CT2_FLAG_MODE1 0x0001 48055372Smjacob#define CT2_FLAG_MODE2 0x0002 48155372Smjacob#define CT2_DATA_IN CT_DATA_IN 48255372Smjacob#define CT2_DATA_OUT CT_DATA_OUT 48355372Smjacob#define CT2_NO_DATA CT_NO_DATA 48455372Smjacob#define CT2_DATAMASK CT_DATAMASK 48555372Smjacob#define CT2_CCINCR 0x0100 48655372Smjacob#define CT2_FASTPOST 0x0200 48755372Smjacob#define CT2_SENDSTATUS 0x8000 48855372Smjacob 48955372Smjacob/* 49055372Smjacob * ct_status values are (mostly) the same as that for ct_entry. 49155372Smjacob */ 49255372Smjacob 49355372Smjacob/* 49455372Smjacob * ct_scsi_status values- the low 8 bits are the normal SCSI status 49555372Smjacob * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU 49655372Smjacob * fields. 49755372Smjacob */ 49855372Smjacob#define CT2_RSPLEN_VALID 0x0100 49955372Smjacob#define CT2_SNSLEN_VALID 0x0200 50055372Smjacob#define CT2_DATA_OVER 0x0400 50155372Smjacob#define CT2_DATA_UNDER 0x0800 50255372Smjacob 50355372Smjacob/* 50455372Smjacob * Debug macros 50555372Smjacob */ 50655372Smjacob 50755372Smjacob#define ISP_TDQE(isp, msg, idx, arg) \ 50864089Smjacob if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg) 50955372Smjacob 51087635Smjacob#ifdef ISP_TARGET_FUNCTIONS 51155372Smjacob/* 51287635Smjacob * The functions below are for the publicly available 51387635Smjacob * target mode functions that are internal to the Qlogic driver. 51455372Smjacob */ 51555372Smjacob 51655372Smjacob/* 51755372Smjacob * This function handles new response queue entry appropriate for target mode. 51855372Smjacob */ 51975195Smjacobint isp_target_notify(struct ispsoftc *, void *, u_int16_t *); 52055372Smjacob 52155372Smjacob/* 52255372Smjacob * Enable/Disable/Modify a logical unit. 52377365Smjacob * (softc, cmd, bus, tgt, lun, cmd_cnt, inotify_cnt, opaque) 52455372Smjacob */ 52577365Smjacob#define DFLT_CMND_CNT 32 52677365Smjacob#define DFLT_INOT_CNT 4 52777365Smjacobint isp_lun_cmd(struct ispsoftc *, int, int, int, int, int, int, u_int32_t); 52855372Smjacob 52955372Smjacob/* 53055372Smjacob * General request queue 'put' routine for target mode entries. 53155372Smjacob */ 53275195Smjacobint isp_target_put_entry(struct ispsoftc *isp, void *); 53355372Smjacob 53455372Smjacob/* 53555372Smjacob * General routine to put back an ATIO entry- 53655372Smjacob * used for replenishing f/w resource counts. 53775195Smjacob * The argument is a pointer to a source ATIO 53875195Smjacob * or ATIO2. 53955372Smjacob */ 54075195Smjacobint isp_target_put_atio(struct ispsoftc *, void *); 54155372Smjacob 54255372Smjacob/* 54355372Smjacob * General routine to send a final CTIO for a command- used mostly for 54455372Smjacob * local responses. 54555372Smjacob */ 54675195Smjacobint isp_endcmd(struct ispsoftc *, void *, u_int32_t, u_int16_t); 54756005Smjacob#define ECMD_SVALID 0x100 54855372Smjacob 54955372Smjacob/* 55055372Smjacob * Handle an asynchronous event 55155372Smjacob */ 55255372Smjacob 55375195Smjacobvoid isp_target_async(struct ispsoftc *, int, int); 55487635Smjacob#endif 55574231Smjacob#endif /* _ISP_TARGET_H */ 556