isp_target.h revision 55372
155372Smjacob/* $FreeBSD: head/sys/dev/isp/isp_target.h 55372 2000-01-03 23:58:41Z 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 */ 18955372Smjacob 19055372Smjacob#define NA2_RSVDLEN 21 19155372Smjacobtypedef struct { 19255372Smjacob isphdr_t na_header; 19355372Smjacob u_int32_t na_reserved; 19455372Smjacob u_int8_t na_lun; /* lun */ 19555372Smjacob u_int8_t na_iid; /* initiator */ 19655372Smjacob u_int16_t na_scclun; 19755372Smjacob u_int16_t na_flags; 19855372Smjacob u_int16_t na_reserved2; 19955372Smjacob u_int16_t na_status; 20055372Smjacob u_int16_t na_task_flags; 20155372Smjacob u_int16_t na_seqid; /* sequence id */ 20255372Smjacob u_int16_t na_reserved3[NA2_RSVDLEN]; 20355372Smjacob} na_fcentry_t; 20455372Smjacob#define NAFC_RCOUNT 0x80 /* increment resource count */ 20555372Smjacob#define NAFC_RST_CLRD 0x20 /* Clear LIP Reset */ 20655372Smjacob/* 20755372Smjacob * Accept Target I/O Entry structure 20855372Smjacob */ 20955372Smjacob#define ATIO_CDBLEN 26 21055372Smjacob 21155372Smjacobtypedef struct { 21255372Smjacob isphdr_t at_header; 21355372Smjacob u_int32_t at_reserved; 21455372Smjacob u_int8_t at_lun; /* lun */ 21555372Smjacob u_int8_t at_iid; /* initiator */ 21655372Smjacob u_int8_t at_cdblen; /* cdb length */ 21755372Smjacob u_int8_t at_tgt; /* target */ 21855372Smjacob u_int32_t at_flags; 21955372Smjacob u_int8_t at_status; /* firmware status */ 22055372Smjacob u_int8_t at_scsi_status; /* scsi status */ 22155372Smjacob u_int8_t at_tag_val; /* tag value */ 22255372Smjacob u_int8_t at_tag_type; /* tag type */ 22355372Smjacob u_int8_t at_cdb[ATIO_CDBLEN]; /* received CDB */ 22455372Smjacob u_int8_t at_sense[QLTM_SENSELEN];/* suggested sense data */ 22555372Smjacob} at_entry_t; 22655372Smjacob 22755372Smjacob/* 22855372Smjacob * at_flags values 22955372Smjacob */ 23055372Smjacob#define AT_NODISC 0x00008000 /* disconnect disabled */ 23155372Smjacob#define AT_TQAE 0x00000001 /* Tagged Queue Action enabled */ 23255372Smjacob 23355372Smjacob/* 23455372Smjacob * at_status values 23555372Smjacob */ 23655372Smjacob#define AT_PATH_INVALID 0x07 /* ATIO sent to firmware for disabled lun */ 23755372Smjacob#define AT_RESET 0x0E /* SCSI Bus Reset Occurred */ 23855372Smjacob#define AT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 23955372Smjacob#define AT_NOCAP 0x16 /* Requested capability not available */ 24055372Smjacob#define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 24155372Smjacob#define AT_CDB 0x3D /* CDB received */ 24255372Smjacob 24355372Smjacob/* 24455372Smjacob * Accept Target I/O Entry structure, Type 2 24555372Smjacob */ 24655372Smjacob#define ATIO2_CDBLEN 16 24755372Smjacob 24855372Smjacobtypedef struct { 24955372Smjacob isphdr_t at_header; 25055372Smjacob u_int32_t at_reserved; 25155372Smjacob u_int8_t at_lun; /* lun or reserved */ 25255372Smjacob u_int8_t at_iid; /* initiator */ 25355372Smjacob u_int16_t at_rxid; /* response ID */ 25455372Smjacob u_int16_t at_flags; 25555372Smjacob u_int16_t at_status; /* firmware status */ 25655372Smjacob u_int8_t at_reserved1; 25755372Smjacob u_int8_t at_taskcodes; 25855372Smjacob u_int8_t at_taskflags; 25955372Smjacob u_int8_t at_execodes; 26055372Smjacob u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ 26155372Smjacob u_int32_t at_datalen; /* allocated data len */ 26255372Smjacob u_int16_t at_scclun; /* SCC Lun or reserved */ 26355372Smjacob u_int16_t at_reserved2; 26455372Smjacob u_int16_t at_scsi_status; 26555372Smjacob u_int8_t at_sense[QLTM_SENSELEN]; 26655372Smjacob} at2_entry_t; 26755372Smjacob 26855372Smjacob#define ATIO2_TC_ATTR_MASK 0x7 26955372Smjacob#define ATIO2_TC_ATTR_SIMPLEQ 0 27055372Smjacob#define ATIO2_TC_ATTR_HEADOFQ 1 27155372Smjacob#define ATIO2_TC_ATTR_ORDERED 2 27255372Smjacob#define ATIO2_TC_ATTR_ACAQ 4 27355372Smjacob#define ATIO2_TC_ATTR_UNTAGGED 5 27455372Smjacob 27555372Smjacob/* 27655372Smjacob * Continue Target I/O Entry structure 27755372Smjacob * Request from driver. The response from the 27855372Smjacob * ISP firmware is the same except that the last 18 27955372Smjacob * bytes are overwritten by suggested sense data if 28055372Smjacob * the 'autosense valid' bit is set in the status byte. 28155372Smjacob */ 28255372Smjacobtypedef struct { 28355372Smjacob isphdr_t ct_header; 28455372Smjacob u_int32_t ct_reserved; 28555372Smjacob u_int8_t ct_lun; /* lun */ 28655372Smjacob u_int8_t ct_iid; /* initiator id */ 28755372Smjacob u_int8_t ct_reserved2; 28855372Smjacob u_int8_t ct_tgt; /* our target id */ 28955372Smjacob u_int32_t ct_flags; 29055372Smjacob u_int8_t ct_status; /* isp status */ 29155372Smjacob u_int8_t ct_scsi_status; /* scsi status */ 29255372Smjacob u_int8_t ct_tag_val; /* tag value */ 29355372Smjacob u_int8_t ct_tag_type; /* tag type */ 29455372Smjacob u_int32_t ct_xfrlen; /* transfer length */ 29555372Smjacob u_int32_t ct_resid; /* residual length */ 29655372Smjacob u_int16_t ct_timeout; 29755372Smjacob u_int16_t ct_seg_count; 29855372Smjacob ispds_t ct_dataseg[ISP_RQDSEG]; 29955372Smjacob} ct_entry_t; 30055372Smjacob 30155372Smjacob/* 30255372Smjacob * ct_flags values 30355372Smjacob */ 30455372Smjacob#define CT_TQAE 0x00000001 /* bit 1, Tagged Queue Action enable */ 30555372Smjacob#define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */ 30655372Smjacob#define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */ 30755372Smjacob#define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */ 30855372Smjacob#define CT_CCINCR 0x00000100 /* bit 8, autoincrement atio count */ 30955372Smjacob#define CT_DATAMASK 0x000000C0 /* bits 6&7, Data direction */ 31055372Smjacob#define CT_NODISC 0x00008000 /* bit 15, Disconnects disabled */ 31155372Smjacob#define CT_DSDP 0x01000000 /* bit 24, Disable Save Data Pointers */ 31255372Smjacob#define CT_SENDRDP 0x04000000 /* bit 26, Send Restore Pointers msg */ 31355372Smjacob#define CT_SENDSTATUS 0x80000000 /* bit 31, Send SCSI status byte */ 31455372Smjacob 31555372Smjacob/* 31655372Smjacob * ct_status values 31755372Smjacob * - set by the firmware when it returns the CTIO 31855372Smjacob */ 31955372Smjacob#define CT_OK 0x01 /* completed without error */ 32055372Smjacob#define CT_ABORTED 0x02 /* aborted by host */ 32155372Smjacob#define CT_ERR 0x04 /* see sense data for error */ 32255372Smjacob#define CT_INVAL 0x06 /* request for disabled lun */ 32355372Smjacob#define CT_NOPATH 0x07 /* invalid ITL nexus */ 32455372Smjacob#define CT_INVRXID 0x08 /* (FC only) Invalid RX_ID */ 32555372Smjacob#define CT_RSELTMO 0x0A /* reselection timeout after 2 tries */ 32655372Smjacob#define CT_TIMEOUT 0x0B /* timed out */ 32755372Smjacob#define CT_RESET 0x0E /* SCSI Bus Reset occurred */ 32855372Smjacob#define CT_PHASE_ERROR 0x14 /* Bus phase sequence error */ 32955372Smjacob#define CT_BDR_MSG 0x17 /* Bus Device Reset msg received */ 33055372Smjacob#define CT_TERMINATED 0x19 /* due to Terminate Transfer mbox cmd */ 33155372Smjacob#define CT_PORTNOTAVAIL 0x28 /* port not available */ 33255372Smjacob#define CT_LOGOUT 0x29 /* port logout */ 33355372Smjacob#define CT_PORTCHANGED 0x2A /* port changed */ 33455372Smjacob#define CT_NOACK 0x35 /* Outstanding Immed. Notify. entry */ 33555372Smjacob 33655372Smjacob/* 33755372Smjacob * When the firmware returns a CTIO entry, it may overwrite the last 33855372Smjacob * part of the structure with sense data. This starts at offset 0x2E 33955372Smjacob * into the entry, which is in the middle of ct_dataseg[1]. Rather 34055372Smjacob * than define a new struct for this, I'm just using the sense data 34155372Smjacob * offset. 34255372Smjacob */ 34355372Smjacob#define CTIO_SENSE_OFFSET 0x2E 34455372Smjacob 34555372Smjacob/* 34655372Smjacob * Entry length in u_longs. All entries are the same size so 34755372Smjacob * any one will do as the numerator. 34855372Smjacob */ 34955372Smjacob#define UINT32_ENTRY_SIZE (sizeof(at_entry_t)/sizeof(u_int32_t)) 35055372Smjacob 35155372Smjacob/* 35255372Smjacob * QLA2100 CTIO (type 2) entry 35355372Smjacob */ 35455372Smjacob#define MAXRESPLEN 26 35555372Smjacobtypedef struct { 35655372Smjacob isphdr_t ct_header; 35755372Smjacob u_int32_t ct_reserved; 35855372Smjacob u_int8_t ct_lun; /* lun */ 35955372Smjacob u_int8_t ct_iid; /* initiator id */ 36055372Smjacob u_int16_t ct_rxid; /* response ID */ 36155372Smjacob u_int16_t ct_flags; 36255372Smjacob u_int16_t ct_status; /* isp status */ 36355372Smjacob u_int16_t ct_timeout; 36455372Smjacob u_int16_t ct_seg_count; 36555372Smjacob u_int32_t ct_reloff; /* relative offset */ 36655372Smjacob u_int32_t ct_resid; /* residual length */ 36755372Smjacob union { 36855372Smjacob /* 36955372Smjacob * The three different modes that the target driver 37055372Smjacob * can set the CTIO2 up as. 37155372Smjacob * 37255372Smjacob * The first is for sending FCP_DATA_IUs as well as 37355372Smjacob * (optionally) sending a terminal SCSI status FCP_RSP_IU. 37455372Smjacob * 37555372Smjacob * The second is for sending SCSI sense data in an FCP_RSP_IU. 37655372Smjacob * Note that no FCP_DATA_IUs will be sent. 37755372Smjacob * 37855372Smjacob * The third is for sending FCP_RSP_IUs as built specifically 37955372Smjacob * in system memory as located by the isp_dataseg. 38055372Smjacob */ 38155372Smjacob struct { 38255372Smjacob u_int32_t _reserved; 38355372Smjacob u_int16_t _reserved2; 38455372Smjacob u_int16_t ct_scsi_status; 38555372Smjacob u_int32_t ct_xfrlen; 38655372Smjacob ispds_t ct_dataseg[ISP_RQDSEG_T2]; 38755372Smjacob } m0; 38855372Smjacob struct { 38955372Smjacob u_int16_t _reserved; 39055372Smjacob u_int16_t _reserved2; 39155372Smjacob u_int16_t ct_senselen; 39255372Smjacob u_int16_t ct_scsi_status; 39355372Smjacob u_int16_t ct_resplen; 39455372Smjacob u_int8_t ct_resp[MAXRESPLEN]; 39555372Smjacob } m1; 39655372Smjacob struct { 39755372Smjacob u_int32_t _reserved; 39855372Smjacob u_int16_t _reserved2; 39955372Smjacob u_int16_t _reserved3; 40055372Smjacob u_int32_t ct_datalen; 40155372Smjacob ispds_t ct_fcp_rsp_iudata; 40255372Smjacob } m2; 40355372Smjacob /* 40455372Smjacob * CTIO2 returned from F/W... 40555372Smjacob */ 40655372Smjacob struct { 40755372Smjacob u_int32_t _reserved[4]; 40855372Smjacob u_int16_t ct_scsi_status; 40955372Smjacob u_int8_t ct_sense[QLTM_SENSELEN]; 41055372Smjacob } fw; 41155372Smjacob } rsp; 41255372Smjacob} ct2_entry_t; 41355372Smjacob 41455372Smjacob/* 41555372Smjacob * ct_flags values for CTIO2 41655372Smjacob */ 41755372Smjacob#define CT2_FLAG_MMASK 0x0003 41855372Smjacob#define CT2_FLAG_MODE0 0x0000 41955372Smjacob#define CT2_FLAG_MODE1 0x0001 42055372Smjacob#define CT2_FLAG_MODE2 0x0002 42155372Smjacob#define CT2_DATA_IN CT_DATA_IN 42255372Smjacob#define CT2_DATA_OUT CT_DATA_OUT 42355372Smjacob#define CT2_NO_DATA CT_NO_DATA 42455372Smjacob#define CT2_DATAMASK CT_DATAMASK 42555372Smjacob#define CT2_CCINCR 0x0100 42655372Smjacob#define CT2_FASTPOST 0x0200 42755372Smjacob#define CT2_SENDSTATUS 0x8000 42855372Smjacob 42955372Smjacob/* 43055372Smjacob * ct_status values are (mostly) the same as that for ct_entry. 43155372Smjacob */ 43255372Smjacob 43355372Smjacob/* 43455372Smjacob * ct_scsi_status values- the low 8 bits are the normal SCSI status 43555372Smjacob * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU 43655372Smjacob * fields. 43755372Smjacob */ 43855372Smjacob#define CT2_RSPLEN_VALID 0x0100 43955372Smjacob#define CT2_SNSLEN_VALID 0x0200 44055372Smjacob#define CT2_DATA_OVER 0x0400 44155372Smjacob#define CT2_DATA_UNDER 0x0800 44255372Smjacob 44355372Smjacob/* 44455372Smjacob * Macros for packing/unpacking the above structures 44555372Smjacob */ 44655372Smjacob 44755372Smjacob#ifdef __sparc__ 44855372Smjacob#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \ 44955372Smjacob if (isp->isp_bus == ISP_SBUS) { \ 45055372Smjacob source -> taga = dest -> tagb; \ 45155372Smjacob source -> tagb = dest -> taga; \ 45255372Smjacob } else { \ 45355372Smjacob source -> taga = dest -> taga; \ 45455372Smjacob source -> tagb = dest -> taga; \ 45555372Smjacob } 45655372Smjacob#else 45755372Smjacob#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \ 45855372Smjacob source -> taga = dest -> taga; \ 45955372Smjacob source -> tagb = dest -> taga; 46055372Smjacob#endif 46155372Smjacob 46255372Smjacob/* This is really only for SBus cards on a sparc */ 46355372Smjacob#ifdef __sparc__ 46455372Smjacob#define ISP_SWIZ_ATIO(isp, dest, vsrc) \ 46555372Smjacob{ \ 46655372Smjacob at_entry_t *source = (at_entry_t *) vsrc; \ 46755372Smjacob dest->at_header = source->at_header; \ 46855372Smjacob dest->at_reserved2 = source->at_reserved2; \ 46955372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, at_lun, at_iid); \ 47055372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, at_cdblen, at_tgt); \ 47155372Smjacob dest->at_flags = source->at_flags; \ 47255372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, at_status, at_scsi_status); \ 47355372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, at_tag_val, at_tag_type); \ 47455372Smjacob MEMCPY(dest->at_cdb, source->at_cdb, ATIO_CDBLEN); \ 47555372Smjacob MEMCPY(dest->at_sense, source->at_sense, QLTM_SENSELEN); \ 47655372Smjacob} 47755372Smjacob 47855372Smjacob#define ISP_SWIZ_CTIO(isp, dest, vsrc) \ 47955372Smjacob{ \ 48055372Smjacob ct_entry_t *source = (ct_entry-t *) vsrc; \ 48155372Smjacob dest->ct_header = source->ct_header; \ 48255372Smjacob dest->ct_reserved = source->ct_reserved; \ 48355372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, ct_lun, ct_iid); \ 48455372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, ct_rsvd, ct_tgt); \ 48555372Smjacob dest->ct_flags = source->ct_flags; \ 48655372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, ct_status, ct_scsi_status); \ 48755372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, ct_tag_val, ct_tag_type); \ 48855372Smjacob dest->ct_xfrlen = source->ct_xfrlen; \ 48955372Smjacob dest->ct_resid = source->ct_resid; \ 49055372Smjacob dest->ct_timeout = source->ct_timeout; \ 49155372Smjacob dest->ct_seg_count = source->ct_seg_count; \ 49255372Smjacob MEMCPY(dest->ct_cdb, source->ct_cdb, ATIO_CDBLEN); \ 49355372Smjacob MEMCPY(dest->ct_sense, source->ct_sense, QLTM_SENSELEN); \ 49455372Smjacob dest->ct_dataseg = source->ct_dataseg; \ 49555372Smjacob} 49655372Smjacob#define ISP_SWIZ_ENABLE_LUN(isp, dest, vsrc) \ 49755372Smjacob{ \ 49855372Smjacob lun_entry_t *source = (lun_entry_t *)vsrc; \ 49955372Smjacob dest->le_header = source->le_header; \ 50055372Smjacob dest->le_reserved2 = source->le_reserved2; \ 50155372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, le_lun, le_rsvd); \ 50255372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, le_ops, le_tgt); \ 50355372Smjacob dest->le_flags = source->le_flags; \ 50455372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, le_status, le_rsvd2); \ 50555372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, le_cmd_count, le_in_count); \ 50655372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, le_cdb6len, le_cdb7len); \ 50755372Smjacob dest->le_timeout = source->le_timeout; \ 50855372Smjacob dest->le_reserved = source->le_reserved; \ 50955372Smjacob} 51055372Smjacob#define ISP_SWIZ_NOTIFY(isp, dest, vsrc) \ 51155372Smjacob{ \ 51255372Smjacob in_entry_type *source = (in_entry_t *)vsrc; \ 51355372Smjacob dest->in_header = source->in_header; \ 51455372Smjacob dest->in_reserved2 = source->in_reserved2; \ 51555372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, in_lun, in_iid); \ 51655372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, in_rsvd, in_tgt); \ 51755372Smjacob dest->in_flags = source->in_flags; \ 51855372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, in_status, in_rsvd2); \ 51955372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, in_tag_val, in_tag_type); \ 52055372Smjacob dest->in_seqid = source->in_seqid; \ 52155372Smjacob MEMCPY(dest->in_msg, source->in_msg, IN_MSGLEN); \ 52255372Smjacob MEMCPY(dest->in_reserved, source->in_reserved, IN_RESERVED); \ 52355372Smjacob MEMCPY(dest->in_sense, source->in_sense, QLTM_SENSELEN); \ 52455372Smjacob} 52555372Smjacob#define ISP_SWIZ_NOT_ACK(isp, dest) \ 52655372Smjacob{ \ 52755372Smjacob na_entry_t *source = (na_entry_t *)vsrc; \ 52855372Smjacob dest->na_header = source->na_header; \ 52955372Smjacob dest->na_reserved2 = source->na_reserved2; \ 53055372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, na_lun, na_iid); \ 53155372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, na_rsvd, na_tgt); \ 53255372Smjacob dest->na_flags = source->na_flags; \ 53355372Smjacob ISP_SBUS_SWOZZLE(isp, source, dest, na_status, na_event); \ 53455372Smjacob dest->na_seqid = source->na_seqid; \ 53555372Smjacob MEMCPY(dest->na_reserved, source->na_reserved, NA_RSVDLEN); \ 53655372Smjacob} 53755372Smjacob#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 53855372Smjacob#else 53955372Smjacob#define ISP_SWIZ_ATIO(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 54055372Smjacob#define ISP_SWIZ_CTIO(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 54155372Smjacob#define ISP_SWIZ_ENABLE_LUN(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 54255372Smjacob#define ISP_SWIZ_NOTIFY(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 54355372Smjacob#define ISP_SWIZ_NOT_ACK(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 54455372Smjacob#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 54555372Smjacob#endif 54655372Smjacob#define ISP_SWIZ_ATIO2(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 54755372Smjacob#define ISP_SWIZ_CTIO2(isp, d, s) MEMCPY((void *)d, (void *)s, QENTRY_LEN) 54855372Smjacob 54955372Smjacob/* 55055372Smjacob * Debug macros 55155372Smjacob */ 55255372Smjacob 55355372Smjacobextern int isp_tdebug; 55455372Smjacob#define ISP_TDQE(isp, msg, idx, arg) \ 55555372Smjacob if (isp_tdebug > 3) isp_print_qentry(isp, msg, idx, arg) 55655372Smjacob 55755372Smjacob#define ITDEBUG(level, msg) if (level > isp_tdebug) PRINTF msg 55855372Smjacob 55955372Smjacob/* 56055372Smjacob * Common (for all platfoms) software SCSI msg/event structures. 56155372Smjacob */ 56255372Smjacob 56355372Smjacobtypedef struct { 56455372Smjacob u_int8_t nt_iid; /* inititator id */ 56555372Smjacob u_int8_t nt_tgt; /* target id */ 56655372Smjacob u_int16_t nt_lun; /* logical unit */ 56755372Smjacob u_int8_t nt_bus; /* bus */ 56855372Smjacob u_int8_t nt_tagtype; /* tag type */ 56955372Smjacob u_int16_t nt_tagval; /* tag value */ 57055372Smjacob u_int8_t nt_msg[IN_MSGLEN]; /* message content */ 57155372Smjacob} tmd_msg_t; 57255372Smjacob 57355372Smjacobtypedef struct { 57455372Smjacob u_int16_t ev_bus; /* bus */ 57555372Smjacob u_int16_t ev_event; /* type of async event */ 57655372Smjacob} tmd_event_t; 57755372Smjacob 57855372Smjacob/* 57955372Smjacob * Target Mode functions 58055372Smjacob */ 58155372Smjacob 58255372Smjacob/* 58355372Smjacob * This function handles new response queue entry appropriate for target mode. 58455372Smjacob */ 58555372Smjacobint isp_target_notify __P((struct ispsoftc *, void *, u_int16_t *)); 58655372Smjacob 58755372Smjacob/* 58855372Smjacob * Enable/Disable/Modify a logical unit. 58955372Smjacob */ 59055372Smjacob#define DFLT_CMD_CNT (RESULT_QUEUE_LEN >> 1) 59155372Smjacob#define DFLT_INOTIFY (4) 59255372Smjacobint isp_lun_cmd __P((struct ispsoftc *isp, int, int, int, int, u_int32_t)); 59355372Smjacob 59455372Smjacob/* 59555372Smjacob * General request queue 'put' routine for target mode entries. 59655372Smjacob */ 59755372Smjacobint isp_target_put_entry __P((struct ispsoftc *isp, void *)); 59855372Smjacob 59955372Smjacob/* 60055372Smjacob * General routine to put back an ATIO entry- 60155372Smjacob * used for replenishing f/w resource counts. 60255372Smjacob */ 60355372Smjacobint 60455372Smjacobisp_target_put_atio __P((struct ispsoftc *isp, int, int, int, int, int)); 60555372Smjacob 60655372Smjacob/* 60755372Smjacob * General routine to send a final CTIO for a command- used mostly for 60855372Smjacob * local responses. 60955372Smjacob */ 61055372Smjacobint 61155372Smjacobisp_endcmd __P((struct ispsoftc *isp, void *, u_int32_t, u_int32_t)); 61255372Smjacob 61355372Smjacob/* 61455372Smjacob * Handle an asynchronous event 61555372Smjacob */ 61655372Smjacob 61755372Smjacobvoid isp_target_async __P((struct ispsoftc *, int, int)); 61855372Smjacob 61955372Smjacob#endif /* _ISPTARGET_H */ 620