isp_target.h revision 59453
155372Smjacob/* $FreeBSD: head/sys/dev/isp/isp_target.h 59453 2000-04-21 02:05:54Z 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 * 1055372Smjacob * Additional Copyright (c) 1999 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. 2255372Smjacob * 2. Redistributions in binary form must reproduce the above copyright 2355372Smjacob * notice, this list of conditions and the following disclaimer in the 2455372Smjacob * documentation and/or other materials provided with the distribution. 2555372Smjacob * 3. The name of the author may not be used to endorse or promote products 2655372Smjacob * derived from this software without specific prior written permission. 2755372Smjacob * 2855372Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2955372Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 3055372Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 3155372Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 3255372Smjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3355372Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3455372Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3555372Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3655372Smjacob * SUCH DAMAGE. 3755372Smjacob * 3855372Smjacob */ 3955372Smjacob#ifndef _ISPTARGET_H 4055372Smjacob#define _ISPTARGET_H 4155372Smjacob 4255372Smjacob/* 4355372Smjacob * Defines for all entry types 4455372Smjacob */ 4555372Smjacob#define QLTM_SVALID 0x80 4655372Smjacob#define QLTM_SENSELEN 18 4755372Smjacob 4855372Smjacob/* 4955372Smjacob * Structure for Enable Lun and Modify Lun queue entries 5055372Smjacob */ 5155372Smjacobtypedef struct { 5255372Smjacob isphdr_t le_header; 5355372Smjacob u_int32_t le_reserved; 5455372Smjacob u_int8_t le_lun; 5555372Smjacob u_int8_t le_rsvd; 5655372Smjacob u_int8_t le_ops; /* Modify LUN only */ 5755372Smjacob u_int8_t le_tgt; /* Not for FC */ 5855372Smjacob u_int32_t le_flags; /* Not for FC */ 5955372Smjacob u_int8_t le_status; 6055372Smjacob u_int8_t le_reserved2; 6155372Smjacob u_int8_t le_cmd_count; 6255372Smjacob u_int8_t le_in_count; 6355372Smjacob u_int8_t le_cdb6len; /* Not for FC */ 6455372Smjacob u_int8_t le_cdb7len; /* Not for FC */ 6555372Smjacob u_int16_t le_timeout; 6655372Smjacob u_int16_t le_reserved3[20]; 6755372Smjacob} lun_entry_t; 6855372Smjacob 6955372Smjacob/* 7055372Smjacob * le_flags values 7155372Smjacob */ 7255372Smjacob#define LUN_TQAE 0x00000001 /* bit1 Tagged Queue Action Enable */ 7355372Smjacob#define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */ 7455372Smjacob#define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */ 7555372Smjacob 7655372Smjacob/* 7755372Smjacob * le_ops values 7855372Smjacob */ 7955372Smjacob#define LUN_CCINCR 0x01 /* increment command count */ 8055372Smjacob#define LUN_CCDECR 0x02 /* decrement command count */ 8155372Smjacob#define LUN_ININCR 0x40 /* increment immed. notify count */ 8255372Smjacob#define LUN_INDECR 0x80 /* decrement immed. notify count */ 8355372Smjacob 8455372Smjacob/* 8555372Smjacob * le_status values 8655372Smjacob */ 8755372Smjacob#define LUN_OK 0x01 /* we be rockin' */ 8855372Smjacob#define LUN_ERR 0x04 /* request completed with error */ 8955372Smjacob#define LUN_INVAL 0x06 /* invalid request */ 9055372Smjacob#define LUN_NOCAP 0x16 /* can't provide requested capability */ 9155372Smjacob#define LUN_ENABLED 0x3E /* LUN already enabled */ 9255372Smjacob 9355372Smjacob/* 9455372Smjacob * Immediate Notify Entry structure 9555372Smjacob */ 9655372Smjacob#define IN_MSGLEN 8 /* 8 bytes */ 9755372Smjacob#define IN_RSVDLEN 8 /* 8 words */ 9855372Smjacobtypedef struct { 9955372Smjacob isphdr_t in_header; 10055372Smjacob u_int32_t in_reserved; 10155372Smjacob u_int8_t in_lun; /* lun */ 10255372Smjacob u_int8_t in_iid; /* initiator */ 10355372Smjacob u_int8_t in_reserved2; 10455372Smjacob u_int8_t in_tgt; /* target */ 10555372Smjacob u_int32_t in_flags; 10655372Smjacob u_int8_t in_status; 10755372Smjacob u_int8_t in_rsvd2; 10855372Smjacob u_int8_t in_tag_val; /* tag value */ 10955372Smjacob u_int8_t in_tag_type; /* tag type */ 11055372Smjacob u_int16_t in_seqid; /* sequence id */ 11155372Smjacob u_int8_t in_msg[IN_MSGLEN]; /* SCSI message bytes */ 11255372Smjacob u_int16_t in_reserved3[IN_RSVDLEN]; 11355372Smjacob u_int8_t in_sense[QLTM_SENSELEN];/* suggested sense data */ 11455372Smjacob} in_entry_t; 11555372Smjacob 11655372Smjacobtypedef struct { 11755372Smjacob isphdr_t in_header; 11855372Smjacob u_int32_t in_reserved; 11955372Smjacob u_int8_t in_lun; /* lun */ 12055372Smjacob u_int8_t in_iid; /* initiator */ 12155372Smjacob u_int16_t in_scclun; 12255372Smjacob u_int32_t in_reserved2; 12355372Smjacob u_int16_t in_status; 12455372Smjacob u_int16_t in_task_flags; 12555372Smjacob u_int16_t in_seqid; /* sequence id */ 12655372Smjacob} in_fcentry_t; 12755372Smjacob 12855372Smjacob/* 12955372Smjacob * Values for the in_status field 13055372Smjacob */ 13155372Smjacob#define IN_RESET 0x0E /* Bus Reset occurred */ 13255372Smjacob#define IN_NO_RCAP 0x16 /* requested capability not available */ 13355372Smjacob#define IN_IDE_RECEIVED 0x33 /* Initiator Detected Error msg received */ 13455372Smjacob#define IN_RSRC_UNAVAIL 0x34 /* resource unavailable */ 13555372Smjacob#define IN_MSG_RECEIVED 0x36 /* SCSI message received */ 13655372Smjacob#define IN_ABORT_TASK 0x20 /* task named in RX_ID is being aborted (FC) */ 13755372Smjacob#define IN_PORT_LOGOUT 0x29 /* port has logged out (FC) */ 13855372Smjacob#define IN_PORT_CHANGED 0x2A /* port changed */ 13955372Smjacob#define IN_GLOBAL_LOGO 0x2E /* all ports logged out */ 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; 21555372Smjacob u_int32_t at_reserved; 21655372Smjacob u_int8_t at_lun; /* lun */ 21755372Smjacob u_int8_t at_iid; /* initiator */ 21855372Smjacob u_int8_t at_cdblen; /* cdb length */ 21955372Smjacob u_int8_t at_tgt; /* target */ 22055372Smjacob u_int32_t at_flags; 22155372Smjacob u_int8_t at_status; /* firmware status */ 22255372Smjacob u_int8_t at_scsi_status; /* scsi status */ 22355372Smjacob u_int8_t at_tag_val; /* tag value */ 22455372Smjacob u_int8_t at_tag_type; /* tag type */ 22555372Smjacob u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */ 22655372Smjacob u_int8_t at_sense[QLTM_SENSELEN];/* suggested sense data */ 22755372Smjacob} at_entry_t; 22855372Smjacob 22955372Smjacob/* 23055372Smjacob * at_flags values 23155372Smjacob */ 23255372Smjacob#define AT_NODISC 0x00008000 /* disconnect disabled */ 23355372Smjacob#define AT_TQAE 0x00000001 /* Tagged Queue Action enabled */ 23455372Smjacob 23555372Smjacob/* 23655372Smjacob * at_status values 23755372Smjacob */ 23855372Smjacob#define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */ 23955372Smjacob#define AT_RESET 0x0E /* SCSI Bus Reset Occurred */ 24055372Smjacob#define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 24155372Smjacob#define AT_NOCAP 0x16 /* Requested capability not available */ 24255372Smjacob#define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 24355372Smjacob#define AT_CDB 0x3D /* CDB received */ 24455372Smjacob 24555372Smjacob/* 24655372Smjacob * Accept Target I/O Entry structure, Type 2 24755372Smjacob */ 24855372Smjacob#define ATIO2_CDBLEN 16 24955372Smjacob 25055372Smjacobtypedef struct { 25155372Smjacob isphdr_t at_header; 25255372Smjacob u_int32_t at_reserved; 25355372Smjacob u_int8_t at_lun; /* lun or reserved */ 25455372Smjacob u_int8_t at_iid; /* initiator */ 25555372Smjacob u_int16_t at_rxid; /* response ID */ 25655372Smjacob u_int16_t at_flags; 25755372Smjacob u_int16_t at_status; /* firmware status */ 25855372Smjacob u_int8_t at_reserved1; 25955372Smjacob u_int8_t at_taskcodes; 26055372Smjacob u_int8_t at_taskflags; 26155372Smjacob u_int8_t at_execodes; 26255372Smjacob u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ 26355372Smjacob u_int32_t at_datalen; /* allocated data len */ 26455372Smjacob u_int16_t at_scclun; /* SCC Lun or reserved */ 26555372Smjacob u_int16_t at_reserved2; 26655372Smjacob u_int16_t at_scsi_status; 26755372Smjacob u_int8_t at_sense[QLTM_SENSELEN]; 26855372Smjacob} at2_entry_t; 26955372Smjacob 27055372Smjacob#define ATIO2_TC_ATTR_MASK 0x7 27155372Smjacob#define ATIO2_TC_ATTR_SIMPLEQ 0 27255372Smjacob#define ATIO2_TC_ATTR_HEADOFQ 1 27355372Smjacob#define ATIO2_TC_ATTR_ORDERED 2 27455372Smjacob#define ATIO2_TC_ATTR_ACAQ 4 27555372Smjacob#define ATIO2_TC_ATTR_UNTAGGED 5 27655372Smjacob 27755372Smjacob/* 27855372Smjacob * Continue Target I/O Entry structure 27955372Smjacob * Request from driver. The response from the 28055372Smjacob * ISP firmware is the same except that the last 18 28155372Smjacob * bytes are overwritten by suggested sense data if 28255372Smjacob * the 'autosense valid' bit is set in the status byte. 28355372Smjacob */ 28455372Smjacobtypedef struct { 28555372Smjacob isphdr_t ct_header; 28655372Smjacob u_int32_t ct_reserved; 28755372Smjacob u_int8_t ct_lun; /* lun */ 28855372Smjacob u_int8_t ct_iid; /* initiator id */ 28955372Smjacob u_int8_t ct_reserved2; 29055372Smjacob u_int8_t ct_tgt; /* our target id */ 29155372Smjacob u_int32_t ct_flags; 29255372Smjacob u_int8_t ct_status; /* isp status */ 29355372Smjacob u_int8_t ct_scsi_status; /* scsi status */ 29455372Smjacob u_int8_t ct_tag_val; /* tag value */ 29555372Smjacob u_int8_t ct_tag_type; /* tag type */ 29655372Smjacob u_int32_t ct_xfrlen; /* transfer length */ 29755372Smjacob u_int32_t ct_resid; /* residual length */ 29855372Smjacob u_int16_t ct_timeout; 29955372Smjacob u_int16_t ct_seg_count; 30055372Smjacob ispds_t ct_dataseg[ISP_RQDSEG]; 30155372Smjacob} ct_entry_t; 30255372Smjacob 30355372Smjacob/* 30456005Smjacob * For some of the dual port SCSI adapters, port (bus #) is reported 30556005Smjacob * in the MSbit of ct_iid. Bit fields are a bit too awkward here. 30656005Smjacob * 30756005Smjacob * Note that this does not apply to FC adapters at all which can and 30856005Smjacob * do report IIDs between 129 && 255 (these represent devices that have 30956005Smjacob * logged in across a SCSI fabric). 31056005Smjacob */ 31156005Smjacob#define GET_IID_VAL(x) (x & 0x3f) 31256005Smjacob#define GET_BUS_VAL(x) ((x >> 7) & 0x1) 31356005Smjacob#define SET_IID_VAL(y, x) (y | (x & 0x3f)) 31456005Smjacob#define SET_BUS_VAL(y, x) (y | ((x & 0x1) << 7)) 31556005Smjacob 31656005Smjacob/* 31755372Smjacob * ct_flags values 31855372Smjacob */ 31955372Smjacob#define CT_TQAE 0x00000001 /* bit 1, Tagged Queue Action enable */ 32055372Smjacob#define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */ 32155372Smjacob#define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */ 32255372Smjacob#define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */ 32355372Smjacob#define CT_CCINCR 0x00000100 /* bit 8, autoincrement atio count */ 32455372Smjacob#define CT_DATAMASK 0x000000C0 /* bits 6&7, Data direction */ 32555372Smjacob#define CT_NODISC 0x00008000 /* bit 15, Disconnects disabled */ 32655372Smjacob#define CT_DSDP 0x01000000 /* bit 24, Disable Save Data Pointers */ 32755372Smjacob#define CT_SENDRDP 0x04000000 /* bit 26, Send Restore Pointers msg */ 32855372Smjacob#define CT_SENDSTATUS 0x80000000 /* bit 31, Send SCSI status byte */ 32955372Smjacob 33055372Smjacob/* 33155372Smjacob * ct_status values 33255372Smjacob * - set by the firmware when it returns the CTIO 33355372Smjacob */ 33455372Smjacob#define CT_OK 0x01 /* completed without error */ 33555372Smjacob#define CT_ABORTED 0x02 /* aborted by host */ 33655372Smjacob#define CT_ERR 0x04 /* see sense data for error */ 33755372Smjacob#define CT_INVAL 0x06 /* request for disabled lun */ 33855372Smjacob#define CT_NOPATH 0x07 /* invalid ITL nexus */ 33955372Smjacob#define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */ 34055372Smjacob#define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */ 34155372Smjacob#define CT_TIMEOUT 0x0B /* timed out */ 34255372Smjacob#define CT_RESET 0x0E /* SCSI Bus Reset occurred */ 34355372Smjacob#define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 34455372Smjacob#define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 34555372Smjacob#define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ 34655372Smjacob#define CT_PORTNOTAVAIL 0x28 /* port not available */ 34755372Smjacob#define CT_LOGOUT 0x29 /* port logout */ 34855372Smjacob#define CT_PORTCHANGED 0x2A /* port changed */ 34955372Smjacob#define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */ 35055372Smjacob 35155372Smjacob/* 35255372Smjacob * When the firmware returns a CTIO entry, it may overwrite the last 35355372Smjacob * part of the structure with sense data. This starts at offset 0x2E 35455372Smjacob * into the entry, which is in the middle of ct_dataseg[1]. Rather 35555372Smjacob * than define a new struct for this, I'm just using the sense data 35655372Smjacob * offset. 35755372Smjacob */ 35855372Smjacob#define CTIO_SENSE_OFFSET 0x2E 35955372Smjacob 36055372Smjacob/* 36155372Smjacob * Entry length in u_longs. All entries are the same size so 36255372Smjacob * any one will do as the numerator. 36355372Smjacob */ 36455372Smjacob#define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t)) 36555372Smjacob 36655372Smjacob/* 36755372Smjacob * QLA2100 CTIO (type 2) entry 36855372Smjacob */ 36955372Smjacob#define MAXRESPLEN 26 37055372Smjacobtypedef struct { 37155372Smjacob isphdr_t ct_header; 37255372Smjacob u_int32_t ct_reserved; 37355372Smjacob u_int8_t ct_lun; /* lun */ 37455372Smjacob u_int8_t ct_iid; /* initiator id */ 37555372Smjacob u_int16_t ct_rxid; /* response ID */ 37655372Smjacob u_int16_t ct_flags; 37755372Smjacob u_int16_t ct_status; /* isp status */ 37855372Smjacob u_int16_t ct_timeout; 37955372Smjacob u_int16_t ct_seg_count; 38055372Smjacob u_int32_t ct_reloff; /* relative offset */ 38156005Smjacob int32_t ct_resid; /* residual length */ 38255372Smjacob union { 38355372Smjacob /* 38455372Smjacob * The three different modes that the target driver 38555372Smjacob * can set the CTIO2 up as. 38655372Smjacob * 38755372Smjacob * The first is for sending FCP_DATA_IUs as well as 38855372Smjacob * (optionally) sending a terminal SCSI status FCP_RSP_IU. 38955372Smjacob * 39055372Smjacob * The second is for sending SCSI sense data in an FCP_RSP_IU. 39155372Smjacob * Note that no FCP_DATA_IUs will be sent. 39255372Smjacob * 39355372Smjacob * The third is for sending FCP_RSP_IUs as built specifically 39455372Smjacob * in system memory as located by the isp_dataseg. 39555372Smjacob */ 39655372Smjacob struct { 39755372Smjacob u_int32_t _reserved; 39855372Smjacob u_int16_t _reserved2; 39955372Smjacob u_int16_t ct_scsi_status; 40055372Smjacob u_int32_t ct_xfrlen; 40155372Smjacob ispds_t ct_dataseg[ISP_RQDSEG_T2]; 40255372Smjacob } m0; 40355372Smjacob struct { 40455372Smjacob u_int16_t _reserved; 40555372Smjacob u_int16_t _reserved2; 40655372Smjacob u_int16_t ct_senselen; 40755372Smjacob u_int16_t ct_scsi_status; 40855372Smjacob u_int16_t ct_resplen; 40955372Smjacob u_int8_t ct_resp[MAXRESPLEN]; 41055372Smjacob } m1; 41155372Smjacob struct { 41255372Smjacob u_int32_t _reserved; 41355372Smjacob u_int16_t _reserved2; 41455372Smjacob u_int16_t _reserved3; 41555372Smjacob u_int32_t ct_datalen; 41655372Smjacob ispds_t ct_fcp_rsp_iudata; 41755372Smjacob } m2; 41855372Smjacob /* 41955372Smjacob * CTIO2 returned from F/W... 42055372Smjacob */ 42155372Smjacob struct { 42255372Smjacob u_int32_t _reserved[4]; 42355372Smjacob u_int16_t ct_scsi_status; 42455372Smjacob u_int8_t ct_sense[QLTM_SENSELEN]; 42555372Smjacob } fw; 42655372Smjacob } rsp; 42755372Smjacob} ct2_entry_t; 42855372Smjacob 42955372Smjacob/* 43055372Smjacob * ct_flags values for CTIO2 43155372Smjacob */ 43255372Smjacob#define CT2_FLAG_MMASK 0x0003 43355372Smjacob#define CT2_FLAG_MODE0 0x0000 43455372Smjacob#define CT2_FLAG_MODE1 0x0001 43555372Smjacob#define CT2_FLAG_MODE2 0x0002 43655372Smjacob#define CT2_DATA_IN CT_DATA_IN 43755372Smjacob#define CT2_DATA_OUT CT_DATA_OUT 43855372Smjacob#define CT2_NO_DATA CT_NO_DATA 43955372Smjacob#define CT2_DATAMASK CT_DATAMASK 44055372Smjacob#define CT2_CCINCR 0x0100 44155372Smjacob#define CT2_FASTPOST 0x0200 44255372Smjacob#define CT2_SENDSTATUS 0x8000 44355372Smjacob 44455372Smjacob/* 44555372Smjacob * ct_status values are (mostly) the same as that for ct_entry. 44655372Smjacob */ 44755372Smjacob 44855372Smjacob/* 44955372Smjacob * ct_scsi_status values- the low 8 bits are the normal SCSI status 45055372Smjacob * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU 45155372Smjacob * fields. 45255372Smjacob */ 45355372Smjacob#define CT2_RSPLEN_VALID 0x0100 45455372Smjacob#define CT2_SNSLEN_VALID 0x0200 45555372Smjacob#define CT2_DATA_OVER 0x0400 45655372Smjacob#define CT2_DATA_UNDER 0x0800 45755372Smjacob 45855372Smjacob/* 45955372Smjacob * Macros for packing/unpacking the above structures 46055372Smjacob */ 46155372Smjacob 46255372Smjacob#ifdef __sparc__ 46355372Smjacob#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \ 46455372Smjacob if (isp->isp_bus == ISP_SBUS) { \ 46555372Smjacob source -> taga = dest -> tagb; \ 46655372Smjacob source -> tagb = dest -> taga; \ 46755372Smjacob } else { \ 46855372Smjacob source -> taga = dest -> taga; \ 46955372Smjacob source -> tagb = dest -> taga; \ 47055372Smjacob } 47155372Smjacob#else 47255372Smjacob#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \ 47355372Smjacob source -> taga = dest -> taga; \ 47455372Smjacob source -> tagb = dest -> taga; 47555372Smjacob#endif 47655372Smjacob 47756005Smjacob#define MCIDF(d, s) if ((void *) d != (void *)s) MEMCPY(d, s, QENTRY_LEN) 47856005Smjacob 47955372Smjacob/* This is really only for SBus cards on a sparc */ 48055372Smjacob#ifdef __sparc__ 48155372Smjacob#define ISP_SWIZ_ATIO(isp, dest, vsrc) \ 48255372Smjacob{ \ 48355372Smjacob at_entry_t *source = (at_entry_t *) vsrc; \ 48456005Smjacob at_entry_t local, *vdst; \ 48556005Smjacob if ((void *)dest == (void *)vsrc) { \ 48656005Smjacob MEMCPY(vsrc, &local, sizeof (at_entry_t)); \ 48756005Smjacob vdst = &local; \ 48856005Smjacob } else { \ 48956005Smjacob vdst = dest; \ 49056005Smjacob } \ 49156005Smjacob vdst->at_header = source->at_header; \ 49256005Smjacob vdst->at_reserved2 = source->at_reserved2; \ 49356005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, at_lun, at_iid); \ 49456005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, at_cdblen, at_tgt); \ 49556005Smjacob vdst->at_flags = source->at_flags; \ 49656005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, at_status, at_scsi_status); \ 49756005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, at_tag_val, at_tag_type); \ 49856005Smjacob MEMCPY(vdst->at_cdb, source->at_cdb, ATIO_CDBLEN); \ 49956005Smjacob MEMCPY(vdst->at_sense, source->at_sense, QLTM_SENSELEN); \ 50055372Smjacob} 50155372Smjacob 50255372Smjacob#define ISP_SWIZ_CTIO(isp, dest, vsrc) \ 50355372Smjacob{ \ 50455372Smjacob ct_entry_t *source = (ct_entry-t *) vsrc; \ 50556005Smjacob ct_entry_t *local, *vdst; \ 50656005Smjacob if ((void *)dest == (void *)vsrc) { \ 50756005Smjacob MEMCPY(vsrc, &local, sizeof (ct_entry_t)); \ 50856005Smjacob vdst = &local; \ 50956005Smjacob } else { \ 51056005Smjacob vdst = dest; \ 51156005Smjacob } \ 51256005Smjacob vdst->ct_header = source->ct_header; \ 51356005Smjacob vdst->ct_reserved = source->ct_reserved; \ 51456005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, ct_lun, ct_iid); \ 51556005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, ct_rsvd, ct_tgt); \ 51656005Smjacob vdst->ct_flags = source->ct_flags; \ 51756005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, ct_status, ct_scsi_status); \ 51856005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, ct_tag_val, ct_tag_type); \ 51956005Smjacob vdst->ct_xfrlen = source->ct_xfrlen; \ 52056005Smjacob vdst->ct_resid = source->ct_resid; \ 52156005Smjacob vdst->ct_timeout = source->ct_timeout; \ 52256005Smjacob vdst->ct_seg_count = source->ct_seg_count; \ 52356005Smjacob MEMCPY(vdst->ct_cdb, source->ct_cdb, ATIO_CDBLEN); \ 52456005Smjacob MEMCPY(vdst->ct_sense, source->ct_sense, QLTM_SENSELEN); \ 52556005Smjacob vdst->ct_dataseg = source->ct_dataseg; \ 52655372Smjacob} 52755372Smjacob#define ISP_SWIZ_ENABLE_LUN(isp, dest, vsrc) \ 52855372Smjacob{ \ 52955372Smjacob lun_entry_t *source = (lun_entry_t *)vsrc; \ 53056005Smjacob lun_entry_t *local, *vdst; \ 53156005Smjacob if ((void *)dest == (void *)vsrc) { \ 53256005Smjacob MEMCPY(vsrc, &local, sizeof (lun_entry_t)); \ 53356005Smjacob vdst = &local; \ 53456005Smjacob } else { \ 53556005Smjacob vdst = dest; \ 53656005Smjacob } \ 53756005Smjacob vdst->le_header = source->le_header; \ 53856005Smjacob vdst->le_reserved2 = source->le_reserved2; \ 53956005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, le_lun, le_rsvd); \ 54056005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, le_ops, le_tgt); \ 54156005Smjacob vdst->le_flags = source->le_flags; \ 54256005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, le_status, le_rsvd2); \ 54356005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, le_cmd_count, le_in_count); \ 54456005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, le_cdb6len, le_cdb7len); \ 54556005Smjacob vdst->le_timeout = source->le_timeout; \ 54656005Smjacob vdst->le_reserved = source->le_reserved; \ 54755372Smjacob} 54855372Smjacob#define ISP_SWIZ_NOTIFY(isp, dest, vsrc) \ 54955372Smjacob{ \ 55055372Smjacob in_entry_type *source = (in_entry_t *)vsrc; \ 55156005Smjacob in_entry_t *local, *vdst; \ 55256005Smjacob if ((void *)dest == (void *)vsrc) { \ 55356005Smjacob MEMCPY(vsrc, &local, sizeof (in_entry_t)); \ 55456005Smjacob vdst = &local; \ 55556005Smjacob } else { \ 55656005Smjacob vdst = dest; \ 55756005Smjacob } \ 55856005Smjacob vdst->in_header = source->in_header; \ 55956005Smjacob vdst->in_reserved2 = source->in_reserved2; \ 56056005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, in_lun, in_iid); \ 56156005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, in_rsvd, in_tgt); \ 56256005Smjacob vdst->in_flags = source->in_flags; \ 56356005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, in_status, in_rsvd2); \ 56456005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, in_tag_val, in_tag_type); \ 56556005Smjacob vdst->in_seqid = source->in_seqid; \ 56656005Smjacob MEMCPY(vdst->in_msg, source->in_msg, IN_MSGLEN); \ 56756005Smjacob MEMCPY(vdst->in_reserved, source->in_reserved, IN_RESERVED); \ 56856005Smjacob MEMCPY(vdst->in_sense, source->in_sense, QLTM_SENSELEN); \ 56955372Smjacob} 57055372Smjacob#define ISP_SWIZ_NOT_ACK(isp, dest) \ 57155372Smjacob{ \ 57255372Smjacob na_entry_t *source = (na_entry_t *)vsrc; \ 57356005Smjacob na_entry_t *local, *vdst; \ 57456005Smjacob if ((void *)dest == (void *)vsrc) { \ 57556005Smjacob MEMCPY(vsrc, &local, sizeof (na_entry_t)); \ 57656005Smjacob vdst = &local; \ 57756005Smjacob } else { \ 57856005Smjacob vdst = dest; \ 57956005Smjacob } \ 58056005Smjacob vdst->na_header = source->na_header; \ 58156005Smjacob vdst->na_reserved2 = source->na_reserved2; \ 58256005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, na_lun, na_iid); \ 58356005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, na_rsvd, na_tgt); \ 58456005Smjacob vdst->na_flags = source->na_flags; \ 58556005Smjacob ISP_SBUS_SWOZZLE(isp, source, vdst, na_status, na_event); \ 58656005Smjacob vdst->na_seqid = source->na_seqid; \ 58756005Smjacob MEMCPY(vdst->na_reserved, source->na_reserved, NA_RSVDLEN); \ 58855372Smjacob} 58956005Smjacob#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MCIDF(d, s) 59056005Smjacob#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s) 59156005Smjacob#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s) 59255372Smjacob#else 59356005Smjacob#define ISP_SWIZ_ATIO(isp, d, s) MCIDF(d, s) 59456005Smjacob#define ISP_SWIZ_CTIO(isp, d, s) MCIDF(d, s) 59556005Smjacob#define ISP_SWIZ_ENABLE_LUN(isp, d, s) MCIDF(d, s) 59656005Smjacob#define ISP_SWIZ_NOTIFY(isp, d, s) MCIDF(d, s) 59756005Smjacob#define ISP_SWIZ_NOT_ACK(isp, d, s) MCIDF(d, s) 59856005Smjacob#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MCIDF(d, s) 59956005Smjacob#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s) 60056005Smjacob#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s) 60155372Smjacob#endif 60255372Smjacob 60355372Smjacob/* 60455372Smjacob * Debug macros 60555372Smjacob */ 60655372Smjacob 60755372Smjacobextern int isp_tdebug; 60855372Smjacob#define ISP_TDQE(isp, msg, idx, arg) \ 60955372Smjacob if (isp_tdebug > 3) isp_print_qentry(isp, msg, idx, arg) 61055372Smjacob 61157217Smjacob#define ITDEBUG(level, msg) if (isp_tdebug >= level) PRINTF msg 61255372Smjacob 61355372Smjacob/* 61456005Smjacob * The functions below are target mode functions that 61556005Smjacob * are generally internal to the Qlogic driver. 61655372Smjacob */ 61755372Smjacob 61855372Smjacob/* 61955372Smjacob * This function handles new response queue entry appropriate for target mode. 62055372Smjacob */ 62155372Smjacobint isp_target_notify __P((struct ispsoftc *, void *, u_int16_t *)); 62255372Smjacob 62355372Smjacob/* 62455372Smjacob * Enable/Disable/Modify a logical unit. 62555372Smjacob */ 62655372Smjacob#define DFLT_CMD_CNT (RESULT_QUEUE_LEN >> 1) 62755372Smjacob#define DFLT_INOTIFY (4) 62859453Smjacobint isp_lun_cmd __P((struct ispsoftc *, int, int, int, int, u_int32_t)); 62955372Smjacob 63055372Smjacob/* 63155372Smjacob * General request queue 'put' routine for target mode entries. 63255372Smjacob */ 63355372Smjacobint isp_target_put_entry __P((struct ispsoftc *isp, void *)); 63455372Smjacob 63555372Smjacob/* 63655372Smjacob * General routine to put back an ATIO entry- 63755372Smjacob * used for replenishing f/w resource counts. 63855372Smjacob */ 63955372Smjacobint 64059453Smjacobisp_target_put_atio __P((struct ispsoftc *, int, int, int, int, int)); 64155372Smjacob 64255372Smjacob/* 64355372Smjacob * General routine to send a final CTIO for a command- used mostly for 64455372Smjacob * local responses. 64555372Smjacob */ 64655372Smjacobint 64759453Smjacobisp_endcmd __P((struct ispsoftc *, void *, u_int32_t, u_int32_t)); 64856005Smjacob#define ECMD_SVALID 0x100 64955372Smjacob 65055372Smjacob/* 65155372Smjacob * Handle an asynchronous event 65255372Smjacob */ 65355372Smjacob 65455372Smjacobvoid isp_target_async __P((struct ispsoftc *, int, int)); 65555372Smjacob 65655372Smjacob#endif /* _ISPTARGET_H */ 657