Home | History | Annotate | Line # | Download | only in ic
isp_target.h revision 1.24
      1  1.24  mjacob /* $NetBSD: isp_target.h,v 1.24 2007/05/24 21:30:43 mjacob Exp $ */
      2   1.8  mjacob /*
      3  1.24  mjacob  * Copyright (c) 1997-2006 by Matthew Jacob
      4   1.1  mjacob  * All rights reserved.
      5   1.1  mjacob  *
      6   1.1  mjacob  * Redistribution and use in source and binary forms, with or without
      7   1.1  mjacob  * modification, are permitted provided that the following conditions
      8   1.1  mjacob  * are met:
      9  1.24  mjacob  *
     10   1.1  mjacob  * 1. Redistributions of source code must retain the above copyright
     11  1.24  mjacob  *    notice, this list of conditions and the following disclaimer.
     12  1.24  mjacob  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.24  mjacob  *    notice, this list of conditions and the following disclaimer in the
     14  1.24  mjacob  *    documentation and/or other materials provided with the distribution.
     15  1.24  mjacob  *
     16  1.24  mjacob  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17   1.1  mjacob  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18   1.1  mjacob  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.24  mjacob  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
     20  1.24  mjacob  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21   1.1  mjacob  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  1.24  mjacob  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.24  mjacob  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24   1.1  mjacob  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25   1.1  mjacob  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26   1.1  mjacob  * SUCH DAMAGE.
     27  1.24  mjacob  */
     28  1.24  mjacob /*
     29  1.24  mjacob  * Qlogic Target Mode Structure and Flag Definitions
     30   1.1  mjacob  */
     31  1.11  mjacob #ifndef	_ISP_TARGET_H
     32  1.11  mjacob #define	_ISP_TARGET_H
     33   1.1  mjacob 
     34  1.20  mjacob #define	QLTM_SENSELEN	18	/* non-FC cards only */
     35   1.1  mjacob #define QLTM_SVALID	0x80
     36   1.1  mjacob 
     37   1.1  mjacob /*
     38   1.1  mjacob  * Structure for Enable Lun and Modify Lun queue entries
     39   1.1  mjacob  */
     40   1.1  mjacob typedef struct {
     41   1.1  mjacob 	isphdr_t	le_header;
     42  1.24  mjacob 	uint32_t	le_reserved;
     43  1.24  mjacob 	uint8_t		le_lun;
     44  1.24  mjacob 	uint8_t		le_rsvd;
     45  1.24  mjacob 	uint8_t		le_ops;		/* Modify LUN only */
     46  1.24  mjacob 	uint8_t		le_tgt;		/* Not for FC */
     47  1.24  mjacob 	uint32_t	le_flags;	/* Not for FC */
     48  1.24  mjacob 	uint8_t		le_status;
     49  1.24  mjacob 	uint8_t		le_reserved2;
     50  1.24  mjacob 	uint8_t		le_cmd_count;
     51  1.24  mjacob 	uint8_t		le_in_count;
     52  1.24  mjacob 	uint8_t		le_cdb6len;	/* Not for FC */
     53  1.24  mjacob 	uint8_t		le_cdb7len;	/* Not for FC */
     54  1.24  mjacob 	uint16_t	le_timeout;
     55  1.24  mjacob 	uint16_t	le_reserved3[20];
     56   1.1  mjacob } lun_entry_t;
     57   1.1  mjacob 
     58   1.1  mjacob /*
     59   1.1  mjacob  * le_flags values
     60   1.1  mjacob  */
     61  1.12  mjacob #define LUN_TQAE	0x00000002	/* bit1  Tagged Queue Action Enable */
     62   1.1  mjacob #define LUN_DSSM	0x01000000	/* bit24 Disable Sending SDP Message */
     63   1.5  mjacob #define	LUN_DISAD	0x02000000	/* bit25 Disable autodisconnect */
     64   1.1  mjacob #define LUN_DM		0x40000000	/* bit30 Disconnects Mandatory */
     65   1.1  mjacob 
     66   1.1  mjacob /*
     67   1.1  mjacob  * le_ops values
     68   1.1  mjacob  */
     69   1.1  mjacob #define LUN_CCINCR	0x01	/* increment command count */
     70   1.1  mjacob #define LUN_CCDECR	0x02	/* decrement command count */
     71   1.1  mjacob #define LUN_ININCR	0x40	/* increment immed. notify count */
     72   1.1  mjacob #define LUN_INDECR	0x80	/* decrement immed. notify count */
     73   1.1  mjacob 
     74   1.1  mjacob /*
     75   1.1  mjacob  * le_status values
     76   1.1  mjacob  */
     77   1.1  mjacob #define	LUN_OK		0x01	/* we be rockin' */
     78   1.1  mjacob #define LUN_ERR		0x04	/* request completed with error */
     79   1.1  mjacob #define LUN_INVAL	0x06	/* invalid request */
     80   1.1  mjacob #define LUN_NOCAP	0x16	/* can't provide requested capability */
     81   1.1  mjacob #define LUN_ENABLED	0x3E	/* LUN already enabled */
     82   1.1  mjacob 
     83   1.1  mjacob /*
     84   1.1  mjacob  * Immediate Notify Entry structure
     85   1.1  mjacob  */
     86   1.1  mjacob #define IN_MSGLEN	8	/* 8 bytes */
     87   1.1  mjacob #define IN_RSVDLEN	8	/* 8 words */
     88   1.1  mjacob typedef struct {
     89   1.1  mjacob 	isphdr_t	in_header;
     90  1.24  mjacob 	uint32_t	in_reserved;
     91  1.24  mjacob 	uint8_t		in_lun;		/* lun */
     92  1.24  mjacob 	uint8_t		in_iid;		/* initiator */
     93  1.24  mjacob 	uint8_t		in_reserved2;
     94  1.24  mjacob 	uint8_t		in_tgt;		/* target */
     95  1.24  mjacob 	uint32_t	in_flags;
     96  1.24  mjacob 	uint8_t		in_status;
     97  1.24  mjacob 	uint8_t		in_rsvd2;
     98  1.24  mjacob 	uint8_t		in_tag_val;	/* tag value */
     99  1.24  mjacob 	uint8_t		in_tag_type;	/* tag type */
    100  1.24  mjacob 	uint16_t	in_seqid;	/* sequence id */
    101  1.24  mjacob 	uint8_t		in_msg[IN_MSGLEN];	/* SCSI message bytes */
    102  1.24  mjacob 	uint16_t	in_reserved3[IN_RSVDLEN];
    103  1.24  mjacob 	uint8_t		in_sense[QLTM_SENSELEN];/* suggested sense data */
    104   1.1  mjacob } in_entry_t;
    105   1.1  mjacob 
    106   1.1  mjacob typedef struct {
    107   1.1  mjacob 	isphdr_t	in_header;
    108  1.24  mjacob 	uint32_t	in_reserved;
    109  1.24  mjacob 	uint8_t		in_lun;		/* lun */
    110  1.24  mjacob 	uint8_t		in_iid;		/* initiator */
    111  1.24  mjacob 	uint16_t	in_scclun;
    112  1.24  mjacob 	uint32_t	in_reserved2;
    113  1.24  mjacob 	uint16_t	in_status;
    114  1.24  mjacob 	uint16_t	in_task_flags;
    115  1.24  mjacob 	uint16_t	in_seqid;	/* sequence id */
    116   1.1  mjacob } in_fcentry_t;
    117   1.1  mjacob 
    118  1.24  mjacob typedef struct {
    119  1.24  mjacob 	isphdr_t	in_header;
    120  1.24  mjacob 	uint32_t	in_reserved;
    121  1.24  mjacob 	uint16_t	in_iid;		/* initiator */
    122  1.24  mjacob 	uint16_t	in_scclun;
    123  1.24  mjacob 	uint32_t	in_reserved2;
    124  1.24  mjacob 	uint16_t	in_status;
    125  1.24  mjacob 	uint16_t	in_task_flags;
    126  1.24  mjacob 	uint16_t	in_seqid;	/* sequence id */
    127  1.24  mjacob } in_fcentry_e_t;
    128  1.24  mjacob 
    129   1.1  mjacob /*
    130   1.1  mjacob  * Values for the in_status field
    131   1.1  mjacob  */
    132   1.6  mjacob #define	IN_REJECT	0x0D	/* Message Reject message received */
    133   1.1  mjacob #define IN_RESET	0x0E	/* Bus Reset occurred */
    134   1.1  mjacob #define IN_NO_RCAP	0x16	/* requested capability not available */
    135   1.1  mjacob #define IN_IDE_RECEIVED	0x33	/* Initiator Detected Error msg received */
    136   1.1  mjacob #define IN_RSRC_UNAVAIL	0x34	/* resource unavailable */
    137   1.1  mjacob #define IN_MSG_RECEIVED	0x36	/* SCSI message received */
    138   1.1  mjacob #define	IN_ABORT_TASK	0x20	/* task named in RX_ID is being aborted (FC) */
    139   1.1  mjacob #define	IN_PORT_LOGOUT	0x29	/* port has logged out (FC) */
    140   1.1  mjacob #define	IN_PORT_CHANGED	0x2A	/* port changed */
    141   1.1  mjacob #define	IN_GLOBAL_LOGO	0x2E	/* all ports logged out */
    142   1.6  mjacob #define	IN_NO_NEXUS	0x3B	/* Nexus not established */
    143   1.1  mjacob 
    144   1.1  mjacob /*
    145   1.1  mjacob  * Values for the in_task_flags field- should only get one at a time!
    146   1.1  mjacob  */
    147  1.24  mjacob #define	TASK_FLAGS_RESERVED_MASK	(0xe700)
    148  1.24  mjacob #define	TASK_FLAGS_CLEAR_ACA		(1<<14)
    149  1.24  mjacob #define	TASK_FLAGS_TARGET_RESET		(1<<13)
    150  1.24  mjacob #define	TASK_FLAGS_LUN_RESET		(1<<12)
    151   1.1  mjacob #define	TASK_FLAGS_CLEAR_TASK_SET	(1<<10)
    152  1.24  mjacob #define	TASK_FLAGS_ABORT_TASK_SET	(1<<9)
    153   1.1  mjacob 
    154  1.24  mjacob /*
    155  1.24  mjacob  * ISP24XX Immediate Notify
    156  1.24  mjacob  */
    157  1.24  mjacob typedef struct {
    158  1.24  mjacob 	isphdr_t	in_header;
    159  1.24  mjacob 	uint32_t	in_reserved;
    160  1.24  mjacob 	uint16_t	in_nphdl;
    161  1.24  mjacob 	uint16_t	in_reserved1;
    162  1.24  mjacob 	uint16_t	in_flags;
    163  1.24  mjacob 	uint16_t	in_srr_rxid;
    164  1.24  mjacob 	uint16_t	in_status;
    165  1.24  mjacob 	uint8_t		in_status_subcode;
    166  1.24  mjacob 	uint8_t		in_reserved2;
    167  1.24  mjacob 	uint32_t	in_rxid;
    168  1.24  mjacob 	uint16_t	in_srr_reloff_lo;
    169  1.24  mjacob 	uint16_t	in_srr_reloff_hi;
    170  1.24  mjacob 	uint16_t	in_srr_iu;
    171  1.24  mjacob 	uint16_t	in_srr_oxid;
    172  1.24  mjacob 	uint8_t		in_reserved3[18];
    173  1.24  mjacob 	uint8_t		in_reserved4;
    174  1.24  mjacob 	uint8_t		in_vpindex;
    175  1.24  mjacob 	uint32_t	in_reserved5;
    176  1.24  mjacob 	uint16_t	in_portid_lo;
    177  1.24  mjacob 	uint8_t		in_portid_hi;
    178  1.24  mjacob 	uint8_t		in_reserved6;
    179  1.24  mjacob 	uint16_t	in_reserved7;
    180  1.24  mjacob 	uint16_t	in_oxid;
    181  1.24  mjacob } in_fcentry_24xx_t;
    182  1.24  mjacob 
    183  1.24  mjacob #define	IN24XX_FLAG_PUREX_IOCB		0x1
    184  1.24  mjacob #define	IN24XX_FLAG_GLOBAL_LOGOUT	0x2
    185  1.24  mjacob 
    186  1.24  mjacob #define	IN24XX_LIP_RESET	0x0E
    187  1.24  mjacob #define	IN24XX_LINK_RESET	0x0F
    188  1.24  mjacob #define	IN24XX_PORT_LOGOUT	0x29
    189  1.24  mjacob #define	IN24XX_PORT_CHANGED	0x2A
    190  1.24  mjacob #define	IN24XX_LINK_FAILED	0x2E
    191  1.24  mjacob #define	IN24XX_SRR_RCVD		0x45
    192  1.24  mjacob #define	IN24XX_ELS_RCVD		0x46	/*
    193  1.24  mjacob 					 * login-affectin ELS received- check
    194  1.24  mjacob 					 * subcode for specific opcode
    195  1.24  mjacob 					 */
    196   1.1  mjacob /*
    197   1.1  mjacob  * Notify Acknowledge Entry structure
    198   1.1  mjacob  */
    199   1.1  mjacob #define NA_RSVDLEN	22
    200   1.1  mjacob typedef struct {
    201   1.1  mjacob 	isphdr_t	na_header;
    202  1.24  mjacob 	uint32_t	na_reserved;
    203  1.24  mjacob 	uint8_t		na_lun;		/* lun */
    204  1.24  mjacob 	uint8_t		na_iid;		/* initiator */
    205  1.24  mjacob 	uint8_t		na_reserved2;
    206  1.24  mjacob 	uint8_t		na_tgt;		/* target */
    207  1.24  mjacob 	uint32_t	na_flags;
    208  1.24  mjacob 	uint8_t		na_status;
    209  1.24  mjacob 	uint8_t		na_event;
    210  1.24  mjacob 	uint16_t	na_seqid;	/* sequence id */
    211  1.24  mjacob 	uint16_t	na_reserved3[NA_RSVDLEN];
    212   1.1  mjacob } na_entry_t;
    213   1.1  mjacob 
    214   1.1  mjacob /*
    215   1.1  mjacob  * Value for the na_event field
    216   1.1  mjacob  */
    217   1.1  mjacob #define NA_RST_CLRD	0x80	/* Clear an async event notification */
    218   1.4      he #define	NA_OK		0x01	/* Notify Acknowledge Succeeded */
    219   1.4      he #define	NA_INVALID	0x06	/* Invalid Notify Acknowledge */
    220   1.1  mjacob 
    221   1.1  mjacob #define	NA2_RSVDLEN	21
    222   1.1  mjacob typedef struct {
    223   1.1  mjacob 	isphdr_t	na_header;
    224  1.24  mjacob 	uint32_t	na_reserved;
    225  1.24  mjacob 	uint8_t		na_reserved1;
    226  1.24  mjacob 	uint8_t		na_iid;		/* initiator loop id */
    227  1.24  mjacob 	uint16_t	na_response;
    228  1.24  mjacob 	uint16_t	na_flags;
    229  1.24  mjacob 	uint16_t	na_reserved2;
    230  1.24  mjacob 	uint16_t	na_status;
    231  1.24  mjacob 	uint16_t	na_task_flags;
    232  1.24  mjacob 	uint16_t	na_seqid;	/* sequence id */
    233  1.24  mjacob 	uint16_t	na_reserved3[NA2_RSVDLEN];
    234   1.1  mjacob } na_fcentry_t;
    235  1.24  mjacob 
    236  1.24  mjacob typedef struct {
    237  1.24  mjacob 	isphdr_t	na_header;
    238  1.24  mjacob 	uint32_t	na_reserved;
    239  1.24  mjacob 	uint16_t	na_iid;		/* initiator loop id */
    240  1.24  mjacob 	uint16_t	na_response;	/* response code */
    241  1.24  mjacob 	uint16_t	na_flags;
    242  1.24  mjacob 	uint16_t	na_reserved2;
    243  1.24  mjacob 	uint16_t	na_status;
    244  1.24  mjacob 	uint16_t	na_task_flags;
    245  1.24  mjacob 	uint16_t	na_seqid;	/* sequence id */
    246  1.24  mjacob 	uint16_t	na_reserved3[NA2_RSVDLEN];
    247  1.24  mjacob } na_fcentry_e_t;
    248  1.24  mjacob 
    249   1.1  mjacob #define	NAFC_RCOUNT	0x80	/* increment resource count */
    250   1.1  mjacob #define NAFC_RST_CLRD	0x20	/* Clear LIP Reset */
    251  1.24  mjacob #define	NAFC_TVALID	0x10	/* task mangement response code is valid */
    252  1.24  mjacob 
    253  1.24  mjacob /*
    254  1.24  mjacob  * ISP24XX Notify Acknowledge
    255  1.24  mjacob  */
    256  1.24  mjacob 
    257  1.24  mjacob typedef struct {
    258  1.24  mjacob 	isphdr_t	na_header;
    259  1.24  mjacob 	uint32_t	na_handle;
    260  1.24  mjacob 	uint16_t	na_nphdl;
    261  1.24  mjacob 	uint16_t	na_reserved1;
    262  1.24  mjacob 	uint16_t	na_flags;
    263  1.24  mjacob 	uint16_t	na_srr_rxid;
    264  1.24  mjacob 	uint16_t	na_status;
    265  1.24  mjacob 	uint8_t		na_status_subcode;
    266  1.24  mjacob 	uint8_t		na_reserved2;
    267  1.24  mjacob 	uint32_t	na_rxid;
    268  1.24  mjacob 	uint16_t	na_srr_reloff_lo;
    269  1.24  mjacob 	uint16_t	na_srr_reloff_hi;
    270  1.24  mjacob 	uint16_t	na_srr_iu;
    271  1.24  mjacob 	uint16_t	na_srr_flags;
    272  1.24  mjacob 	uint8_t		na_reserved3[18];
    273  1.24  mjacob 	uint8_t		na_reserved4;
    274  1.24  mjacob 	uint8_t		na_vpindex;
    275  1.24  mjacob 	uint8_t		na_srr_reject_vunique;
    276  1.24  mjacob 	uint8_t		na_srr_reject_explanation;
    277  1.24  mjacob 	uint8_t		na_srr_reject_code;
    278  1.24  mjacob 	uint8_t		na_reserved5;
    279  1.24  mjacob 	uint8_t		na_reserved6[6];
    280  1.24  mjacob 	uint16_t	na_oxid;
    281  1.24  mjacob } na_fcentry_24xx_t;
    282  1.24  mjacob 
    283   1.1  mjacob /*
    284   1.1  mjacob  * Accept Target I/O Entry structure
    285   1.1  mjacob  */
    286   1.1  mjacob #define ATIO_CDBLEN	26
    287   1.1  mjacob 
    288   1.1  mjacob typedef struct {
    289   1.1  mjacob 	isphdr_t	at_header;
    290  1.24  mjacob 	uint16_t	at_reserved;
    291  1.24  mjacob 	uint16_t	at_handle;
    292  1.24  mjacob 	uint8_t		at_lun;		/* lun */
    293  1.24  mjacob 	uint8_t		at_iid;		/* initiator */
    294  1.24  mjacob 	uint8_t		at_cdblen; 	/* cdb length */
    295  1.24  mjacob 	uint8_t		at_tgt;		/* target */
    296  1.24  mjacob 	uint32_t	at_flags;
    297  1.24  mjacob 	uint8_t		at_status;	/* firmware status */
    298  1.24  mjacob 	uint8_t		at_scsi_status;	/* scsi status */
    299  1.24  mjacob 	uint8_t		at_tag_val;	/* tag value */
    300  1.24  mjacob 	uint8_t		at_tag_type;	/* tag type */
    301  1.24  mjacob 	uint8_t		at_cdb[ATIO_CDBLEN];	/* received CDB */
    302  1.24  mjacob 	uint8_t		at_sense[QLTM_SENSELEN];/* suggested sense data */
    303   1.1  mjacob } at_entry_t;
    304   1.1  mjacob 
    305   1.1  mjacob /*
    306   1.1  mjacob  * at_flags values
    307   1.1  mjacob  */
    308   1.1  mjacob #define AT_NODISC	0x00008000	/* disconnect disabled */
    309  1.12  mjacob #define AT_TQAE		0x00000002	/* Tagged Queue Action enabled */
    310   1.1  mjacob 
    311   1.1  mjacob /*
    312   1.1  mjacob  * at_status values
    313   1.1  mjacob  */
    314   1.1  mjacob #define AT_PATH_INVALID	0x07	/* ATIO sent to firmware for disabled lun */
    315   1.1  mjacob #define	AT_RESET	0x0E	/* SCSI Bus Reset Occurred */
    316   1.1  mjacob #define AT_PHASE_ERROR	0x14	/* Bus phase sequence error */
    317   1.1  mjacob #define AT_NOCAP	0x16	/* Requested capability not available */
    318   1.1  mjacob #define AT_BDR_MSG	0x17	/* Bus Device Reset msg received */
    319   1.1  mjacob #define AT_CDB		0x3D	/* CDB received */
    320   1.1  mjacob /*
    321  1.12  mjacob  * Macros to create and fetch and test concatenated handle and tag value macros
    322  1.12  mjacob  */
    323  1.12  mjacob 
    324  1.24  mjacob #define	AT_MAKE_TAGID(tid, bus, inst, aep)				\
    325  1.24  mjacob 	tid = aep->at_handle;						\
    326  1.24  mjacob 	if (aep->at_flags & AT_TQAE) {					\
    327  1.24  mjacob 		tid |= (aep->at_tag_val << 16);				\
    328  1.24  mjacob 		tid |= (1 << 24);					\
    329  1.24  mjacob 	}								\
    330  1.24  mjacob 	tid |= (bus << 25);						\
    331  1.24  mjacob 	tid |= (inst << 26)
    332  1.24  mjacob 
    333  1.24  mjacob #define	CT_MAKE_TAGID(tid, bus, inst, ct)				\
    334  1.24  mjacob 	tid = ct->ct_fwhandle;						\
    335  1.24  mjacob 	if (ct->ct_flags & CT_TQAE) {					\
    336  1.24  mjacob 		tid |= (ct->ct_tag_val << 16);				\
    337  1.24  mjacob 		tid |= (1 << 24);					\
    338  1.24  mjacob 	}								\
    339  1.24  mjacob 	tid |= ((bus & 0x1) << 25);					\
    340  1.24  mjacob 	tid |= (inst << 26)
    341  1.24  mjacob 
    342  1.24  mjacob #define	AT_HAS_TAG(val)		((val) & (1 << 24))
    343  1.24  mjacob #define	AT_GET_TAG(val)		(((val) >> 16) & 0xff)
    344  1.24  mjacob #define	AT_GET_INST(val)	(((val) >> 26) & 0x3f)
    345  1.24  mjacob #define	AT_GET_BUS(val)		(((val) >> 25) & 0x1)
    346  1.24  mjacob #define	AT_GET_HANDLE(val)	((val) & 0xffff)
    347  1.24  mjacob 
    348  1.24  mjacob #define	IN_MAKE_TAGID(tid, bus, inst, inp)				\
    349  1.24  mjacob 	tid = inp->in_seqid;						\
    350  1.24  mjacob 	tid |= (inp->in_tag_val << 16);					\
    351  1.24  mjacob 	tid |= (1 << 24);						\
    352  1.24  mjacob 	tid |= (bus << 25);						\
    353  1.24  mjacob 	tid |= (inst << 26)
    354  1.24  mjacob 
    355  1.24  mjacob #define	TAG_INSERT_INST(tid, inst)					\
    356  1.24  mjacob 	tid &= ~(0x3ffffff);						\
    357  1.24  mjacob 	tid |= (inst << 26)
    358  1.24  mjacob 
    359  1.24  mjacob #define	TAG_INSERT_BUS(tid, bus)					\
    360  1.24  mjacob 	tid &= ~(1 << 25);						\
    361  1.24  mjacob 	tid |= (bus << 25)
    362  1.12  mjacob 
    363  1.12  mjacob /*
    364   1.1  mjacob  * Accept Target I/O Entry structure, Type 2
    365   1.1  mjacob  */
    366   1.1  mjacob #define ATIO2_CDBLEN	16
    367   1.1  mjacob 
    368   1.1  mjacob typedef struct {
    369   1.1  mjacob 	isphdr_t	at_header;
    370  1.24  mjacob 	uint32_t	at_reserved;
    371  1.24  mjacob 	uint8_t		at_lun;		/* lun or reserved */
    372  1.24  mjacob 	uint8_t		at_iid;		/* initiator */
    373  1.24  mjacob 	uint16_t	at_rxid; 	/* response ID */
    374  1.24  mjacob 	uint16_t	at_flags;
    375  1.24  mjacob 	uint16_t	at_status;	/* firmware status */
    376  1.24  mjacob 	uint8_t		at_crn;		/* command reference number */
    377  1.24  mjacob 	uint8_t		at_taskcodes;
    378  1.24  mjacob 	uint8_t		at_taskflags;
    379  1.24  mjacob 	uint8_t		at_execodes;
    380  1.24  mjacob 	uint8_t		at_cdb[ATIO2_CDBLEN];	/* received CDB */
    381  1.24  mjacob 	uint32_t	at_datalen;		/* allocated data len */
    382  1.24  mjacob 	uint16_t	at_scclun;		/* SCC Lun or reserved */
    383  1.24  mjacob 	uint16_t	at_wwpn[4];		/* WWPN of initiator */
    384  1.24  mjacob 	uint16_t	at_reserved2[6];
    385  1.24  mjacob 	uint16_t	at_oxid;
    386   1.1  mjacob } at2_entry_t;
    387  1.10  mjacob 
    388  1.24  mjacob typedef struct {
    389  1.24  mjacob 	isphdr_t	at_header;
    390  1.24  mjacob 	uint32_t	at_reserved;
    391  1.24  mjacob 	uint16_t	at_iid;		/* initiator */
    392  1.24  mjacob 	uint16_t	at_rxid; 	/* response ID */
    393  1.24  mjacob 	uint16_t	at_flags;
    394  1.24  mjacob 	uint16_t	at_status;	/* firmware status */
    395  1.24  mjacob 	uint8_t		at_crn;		/* command reference number */
    396  1.24  mjacob 	uint8_t		at_taskcodes;
    397  1.24  mjacob 	uint8_t		at_taskflags;
    398  1.24  mjacob 	uint8_t		at_execodes;
    399  1.24  mjacob 	uint8_t		at_cdb[ATIO2_CDBLEN];	/* received CDB */
    400  1.24  mjacob 	uint32_t	at_datalen;		/* allocated data len */
    401  1.24  mjacob 	uint16_t	at_scclun;		/* SCC Lun or reserved */
    402  1.24  mjacob 	uint16_t	at_wwpn[4];		/* WWPN of initiator */
    403  1.24  mjacob 	uint16_t	at_reserved2[6];
    404  1.24  mjacob 	uint16_t	at_oxid;
    405  1.24  mjacob } at2e_entry_t;
    406  1.24  mjacob 
    407  1.10  mjacob #define	ATIO2_WWPN_OFFSET	0x2A
    408  1.10  mjacob #define	ATIO2_OXID_OFFSET	0x3E
    409   1.1  mjacob 
    410   1.1  mjacob #define	ATIO2_TC_ATTR_MASK	0x7
    411   1.1  mjacob #define	ATIO2_TC_ATTR_SIMPLEQ	0
    412   1.1  mjacob #define	ATIO2_TC_ATTR_HEADOFQ	1
    413   1.1  mjacob #define	ATIO2_TC_ATTR_ORDERED	2
    414   1.1  mjacob #define	ATIO2_TC_ATTR_ACAQ	4
    415   1.1  mjacob #define	ATIO2_TC_ATTR_UNTAGGED	5
    416   1.1  mjacob 
    417  1.20  mjacob #define	ATIO2_EX_WRITE		0x1
    418  1.20  mjacob #define	ATIO2_EX_READ		0x2
    419  1.24  mjacob /*
    420  1.24  mjacob  * Macros to create and fetch and test concatenated handle and tag value macros
    421  1.24  mjacob  */
    422  1.24  mjacob #define	AT2_MAKE_TAGID(tid, bus, inst, aep)				\
    423  1.24  mjacob 	tid = aep->at_rxid;						\
    424  1.24  mjacob 	tid |= (((uint64_t)inst) << 32);				\
    425  1.24  mjacob 	tid |= (((uint64_t)bus) << 48)
    426  1.24  mjacob 
    427  1.24  mjacob #define	CT2_MAKE_TAGID(tid, bus, inst, ct)				\
    428  1.24  mjacob 	tid = ct->ct_rxid;						\
    429  1.24  mjacob 	tid |= (((uint64_t)inst) << 32);				\
    430  1.24  mjacob 	tid |= (((uint64_t)(bus & 0xff)) << 48)
    431  1.24  mjacob 
    432  1.24  mjacob #define	AT2_HAS_TAG(val)	1
    433  1.24  mjacob #define	AT2_GET_TAG(val)	((val) & 0xffffffff)
    434  1.24  mjacob #define	AT2_GET_INST(val)	((val) >> 32)
    435  1.24  mjacob #define	AT2_GET_HANDLE		AT2_GET_TAG
    436  1.24  mjacob #define	AT2_GET_BUS(val)	(((val) >> 48) & 0xff)
    437  1.24  mjacob 
    438  1.24  mjacob #define	FC_HAS_TAG	AT2_HAS_TAG
    439  1.24  mjacob #define	FC_GET_TAG	AT2_GET_TAG
    440  1.24  mjacob #define	FC_GET_INST	AT2_GET_INST
    441  1.24  mjacob #define	FC_GET_HANDLE	AT2_GET_HANDLE
    442  1.24  mjacob 
    443  1.24  mjacob #define	IN_FC_MAKE_TAGID(tid, bus, inst, seqid)				\
    444  1.24  mjacob 	tid = seqid;							\
    445  1.24  mjacob 	tid |= (((uint64_t)inst) << 32);				\
    446  1.24  mjacob 	tid |= (((uint64_t)(bus & 0xff)) << 48)
    447  1.24  mjacob 
    448  1.24  mjacob #define	FC_TAG_INSERT_INST(tid, inst)					\
    449  1.24  mjacob 	tid &= ~0xffff00000000ull;					\
    450  1.24  mjacob 	tid |= (((uint64_t)inst) << 32)
    451  1.24  mjacob 
    452  1.24  mjacob /*
    453  1.24  mjacob  * 24XX ATIO Definition
    454  1.24  mjacob  *
    455  1.24  mjacob  * This is *quite* different from other entry types.
    456  1.24  mjacob  * First of all, it has its own queue it comes in on.
    457  1.24  mjacob  *
    458  1.24  mjacob  * Secondly, it doesn't have a normal header.
    459  1.24  mjacob  *
    460  1.24  mjacob  * Thirdly, it's just a passthru of the FCP CMND IU
    461  1.24  mjacob  * which is recorded in big endian mode.
    462  1.24  mjacob  */
    463  1.24  mjacob typedef struct {
    464  1.24  mjacob 	uint8_t		at_type;
    465  1.24  mjacob 	uint8_t		at_count;
    466  1.24  mjacob 	/*
    467  1.24  mjacob 	 * Task attribute in high four bits,
    468  1.24  mjacob 	 * the rest is the FCP CMND IU Length.
    469  1.24  mjacob 	 * NB: the command can extend past the
    470  1.24  mjacob 	 * length for a single queue entry.
    471  1.24  mjacob 	 */
    472  1.24  mjacob 	uint16_t	at_ta_len;
    473  1.24  mjacob 	uint32_t	at_rxid;
    474  1.24  mjacob 	fc_hdr_t	at_hdr;
    475  1.24  mjacob 	fcp_cmnd_iu_t	at_cmnd;
    476  1.24  mjacob } at7_entry_t;
    477  1.24  mjacob 
    478  1.20  mjacob 
    479   1.1  mjacob /*
    480   1.1  mjacob  * Continue Target I/O Entry structure
    481   1.1  mjacob  * Request from driver. The response from the
    482   1.1  mjacob  * ISP firmware is the same except that the last 18
    483   1.1  mjacob  * bytes are overwritten by suggested sense data if
    484   1.1  mjacob  * the 'autosense valid' bit is set in the status byte.
    485   1.1  mjacob  */
    486   1.1  mjacob typedef struct {
    487   1.1  mjacob 	isphdr_t	ct_header;
    488  1.24  mjacob 	uint16_t	ct_syshandle;
    489  1.24  mjacob 	uint16_t	ct_fwhandle;	/* required by f/w */
    490  1.24  mjacob 	uint8_t		ct_lun;	/* lun */
    491  1.24  mjacob 	uint8_t		ct_iid;	/* initiator id */
    492  1.24  mjacob 	uint8_t		ct_reserved2;
    493  1.24  mjacob 	uint8_t		ct_tgt;	/* our target id */
    494  1.24  mjacob 	uint32_t	ct_flags;
    495  1.24  mjacob 	uint8_t 	ct_status;	/* isp status */
    496  1.24  mjacob 	uint8_t 	ct_scsi_status;	/* scsi status */
    497  1.24  mjacob 	uint8_t 	ct_tag_val;	/* tag value */
    498  1.24  mjacob 	uint8_t 	ct_tag_type;	/* tag type */
    499  1.24  mjacob 	uint32_t	ct_xfrlen;	/* transfer length */
    500  1.24  mjacob 	uint32_t	ct_resid;	/* residual length */
    501  1.24  mjacob 	uint16_t	ct_timeout;
    502  1.24  mjacob 	uint16_t	ct_seg_count;
    503  1.24  mjacob 	ispds_t		ct_dataseg[ISP_RQDSEG];
    504   1.1  mjacob } ct_entry_t;
    505   1.1  mjacob 
    506   1.1  mjacob /*
    507   1.2  mjacob  * For some of the dual port SCSI adapters, port (bus #) is reported
    508   1.2  mjacob  * in the MSbit of ct_iid. Bit fields are a bit too awkward here.
    509   1.2  mjacob  *
    510   1.2  mjacob  * Note that this does not apply to FC adapters at all which can and
    511  1.24  mjacob  * do report IIDs between 0x81 && 0xfe (or 0x7ff) which represent devices
    512  1.24  mjacob  * that have logged in across a SCSI fabric.
    513   1.2  mjacob  */
    514   1.2  mjacob #define	GET_IID_VAL(x)		(x & 0x3f)
    515   1.2  mjacob #define	GET_BUS_VAL(x)		((x >> 7) & 0x1)
    516  1.15  mjacob #define	SET_IID_VAL(y, x)	y = ((y & ~0x3f) | (x & 0x3f))
    517  1.15  mjacob #define	SET_BUS_VAL(y, x)	y = ((y & 0x3f) | ((x & 0x1) << 7))
    518   1.2  mjacob 
    519   1.2  mjacob /*
    520   1.1  mjacob  * ct_flags values
    521   1.1  mjacob  */
    522  1.12  mjacob #define CT_TQAE		0x00000002	/* bit  1, Tagged Queue Action enable */
    523   1.1  mjacob #define CT_DATA_IN	0x00000040	/* bits 6&7, Data direction */
    524   1.1  mjacob #define CT_DATA_OUT	0x00000080	/* bits 6&7, Data direction */
    525   1.1  mjacob #define CT_NO_DATA	0x000000C0	/* bits 6&7, Data direction */
    526   1.1  mjacob #define	CT_CCINCR	0x00000100	/* bit 8, autoincrement atio count */
    527   1.1  mjacob #define CT_DATAMASK	0x000000C0	/* bits 6&7, Data direction */
    528   1.6  mjacob #define	CT_INISYNCWIDE	0x00004000	/* bit 14, Do Sync/Wide Negotiation */
    529   1.1  mjacob #define CT_NODISC	0x00008000	/* bit 15, Disconnects disabled */
    530   1.1  mjacob #define CT_DSDP		0x01000000	/* bit 24, Disable Save Data Pointers */
    531   1.1  mjacob #define CT_SENDRDP	0x04000000	/* bit 26, Send Restore Pointers msg */
    532   1.1  mjacob #define CT_SENDSTATUS	0x80000000	/* bit 31, Send SCSI status byte */
    533   1.1  mjacob 
    534   1.1  mjacob /*
    535   1.1  mjacob  * ct_status values
    536   1.1  mjacob  * - set by the firmware when it returns the CTIO
    537   1.1  mjacob  */
    538   1.1  mjacob #define CT_OK		0x01	/* completed without error */
    539   1.1  mjacob #define CT_ABORTED	0x02	/* aborted by host */
    540   1.1  mjacob #define CT_ERR		0x04	/* see sense data for error */
    541   1.1  mjacob #define CT_INVAL	0x06	/* request for disabled lun */
    542   1.1  mjacob #define CT_NOPATH	0x07	/* invalid ITL nexus */
    543   1.1  mjacob #define	CT_INVRXID	0x08	/* (FC only) Invalid RX_ID */
    544  1.13  mjacob #define	CT_DATA_OVER	0x09	/* (FC only) Data Overrun */
    545   1.1  mjacob #define CT_RSELTMO	0x0A	/* reselection timeout after 2 tries */
    546   1.1  mjacob #define CT_TIMEOUT	0x0B	/* timed out */
    547   1.1  mjacob #define CT_RESET	0x0E	/* SCSI Bus Reset occurred */
    548   1.6  mjacob #define	CT_PARITY	0x0F	/* Uncorrectable Parity Error */
    549  1.13  mjacob #define	CT_BUS_ERROR	0x10	/* (FC Only) DMA PCI Error */
    550   1.6  mjacob #define	CT_PANIC	0x13	/* Unrecoverable Error */
    551   1.1  mjacob #define CT_PHASE_ERROR	0x14	/* Bus phase sequence error */
    552  1.24  mjacob #define	CT_DATA_UNDER	0x15	/* (FC only) Data Underrun */
    553   1.1  mjacob #define CT_BDR_MSG	0x17	/* Bus Device Reset msg received */
    554   1.1  mjacob #define CT_TERMINATED	0x19	/* due to Terminate Transfer mbox cmd */
    555  1.24  mjacob #define	CT_PORTUNAVAIL	0x28	/* port not available */
    556   1.1  mjacob #define	CT_LOGOUT	0x29	/* port logout */
    557   1.1  mjacob #define	CT_PORTCHANGED	0x2A	/* port changed */
    558   1.6  mjacob #define	CT_IDE		0x33	/* Initiator Detected Error */
    559   1.1  mjacob #define CT_NOACK	0x35	/* Outstanding Immed. Notify. entry */
    560  1.24  mjacob #define	CT_SRR		0x45	/* SRR Received */
    561  1.24  mjacob #define	CT_LUN_RESET	0x48	/* Lun Reset Received */
    562   1.1  mjacob 
    563   1.1  mjacob /*
    564   1.1  mjacob  * When the firmware returns a CTIO entry, it may overwrite the last
    565   1.1  mjacob  * part of the structure with sense data. This starts at offset 0x2E
    566   1.1  mjacob  * into the entry, which is in the middle of ct_dataseg[1]. Rather
    567   1.1  mjacob  * than define a new struct for this, I'm just using the sense data
    568   1.1  mjacob  * offset.
    569   1.1  mjacob  */
    570   1.1  mjacob #define CTIO_SENSE_OFFSET	0x2E
    571   1.1  mjacob 
    572   1.1  mjacob /*
    573   1.1  mjacob  * Entry length in u_longs. All entries are the same size so
    574   1.1  mjacob  * any one will do as the numerator.
    575   1.1  mjacob  */
    576  1.24  mjacob #define UINT32_ENTRY_SIZE	(sizeof(at_entry_t)/sizeof(uint32_t))
    577   1.1  mjacob 
    578   1.1  mjacob /*
    579   1.1  mjacob  * QLA2100 CTIO (type 2) entry
    580   1.1  mjacob  */
    581   1.1  mjacob #define	MAXRESPLEN	26
    582   1.1  mjacob typedef struct {
    583   1.1  mjacob 	isphdr_t	ct_header;
    584  1.24  mjacob 	uint32_t	ct_syshandle;
    585  1.24  mjacob 	uint8_t		ct_lun;		/* lun */
    586  1.24  mjacob 	uint8_t		ct_iid;		/* initiator id */
    587  1.24  mjacob 	uint16_t	ct_rxid;	/* response ID */
    588  1.24  mjacob 	uint16_t	ct_flags;
    589  1.24  mjacob 	uint16_t 	ct_status;	/* isp status */
    590  1.24  mjacob 	uint16_t	ct_timeout;
    591  1.24  mjacob 	uint16_t	ct_seg_count;
    592  1.24  mjacob 	uint32_t	ct_reloff;	/* relative offset */
    593   1.2  mjacob 	int32_t		ct_resid;	/* residual length */
    594   1.1  mjacob 	union {
    595   1.1  mjacob 		/*
    596   1.1  mjacob 		 * The three different modes that the target driver
    597  1.16  mjacob 		 * can set the CTIO{2,3,4} up as.
    598   1.1  mjacob 		 *
    599   1.1  mjacob 		 * The first is for sending FCP_DATA_IUs as well as
    600   1.1  mjacob 		 * (optionally) sending a terminal SCSI status FCP_RSP_IU.
    601   1.1  mjacob 		 *
    602   1.1  mjacob 		 * The second is for sending SCSI sense data in an FCP_RSP_IU.
    603   1.1  mjacob 		 * Note that no FCP_DATA_IUs will be sent.
    604   1.1  mjacob 		 *
    605   1.1  mjacob 		 * The third is for sending FCP_RSP_IUs as built specifically
    606   1.1  mjacob 		 * in system memory as located by the isp_dataseg.
    607   1.1  mjacob 		 */
    608   1.1  mjacob 		struct {
    609  1.24  mjacob 			uint32_t _reserved;
    610  1.24  mjacob 			uint16_t _reserved2;
    611  1.24  mjacob 			uint16_t ct_scsi_status;
    612  1.24  mjacob 			uint32_t ct_xfrlen;
    613  1.16  mjacob 			union {
    614  1.24  mjacob 				ispds_t ct_dataseg[ISP_RQDSEG_T2];
    615  1.24  mjacob 				ispds64_t ct_dataseg64[ISP_RQDSEG_T3];
    616  1.24  mjacob 				ispdslist_t ct_dslist;
    617  1.24  mjacob 			} u;
    618   1.1  mjacob 		} m0;
    619   1.1  mjacob 		struct {
    620  1.24  mjacob 			uint16_t _reserved;
    621  1.24  mjacob 			uint16_t _reserved2;
    622  1.24  mjacob 			uint16_t ct_senselen;
    623  1.24  mjacob 			uint16_t ct_scsi_status;
    624  1.24  mjacob 			uint16_t ct_resplen;
    625  1.24  mjacob 			uint8_t  ct_resp[MAXRESPLEN];
    626   1.1  mjacob 		} m1;
    627   1.1  mjacob 		struct {
    628  1.24  mjacob 			uint32_t _reserved;
    629  1.24  mjacob 			uint16_t _reserved2;
    630  1.24  mjacob 			uint16_t _reserved3;
    631  1.24  mjacob 			uint32_t ct_datalen;
    632   1.1  mjacob 			ispds_t ct_fcp_rsp_iudata;
    633   1.1  mjacob 		} m2;
    634   1.1  mjacob 	} rsp;
    635   1.1  mjacob } ct2_entry_t;
    636   1.1  mjacob 
    637  1.24  mjacob typedef struct {
    638  1.24  mjacob 	isphdr_t	ct_header;
    639  1.24  mjacob 	uint32_t	ct_syshandle;
    640  1.24  mjacob 	uint16_t	ct_iid;		/* initiator id */
    641  1.24  mjacob 	uint16_t	ct_rxid;	/* response ID */
    642  1.24  mjacob 	uint16_t	ct_flags;
    643  1.24  mjacob 	uint16_t 	ct_status;	/* isp status */
    644  1.24  mjacob 	uint16_t	ct_timeout;
    645  1.24  mjacob 	uint16_t	ct_seg_count;
    646  1.24  mjacob 	uint32_t	ct_reloff;	/* relative offset */
    647  1.24  mjacob 	int32_t		ct_resid;	/* residual length */
    648  1.24  mjacob 	union {
    649  1.24  mjacob 		struct {
    650  1.24  mjacob 			uint32_t _reserved;
    651  1.24  mjacob 			uint16_t _reserved2;
    652  1.24  mjacob 			uint16_t ct_scsi_status;
    653  1.24  mjacob 			uint32_t ct_xfrlen;
    654  1.24  mjacob 			union {
    655  1.24  mjacob 				ispds_t ct_dataseg[ISP_RQDSEG_T2];
    656  1.24  mjacob 				ispds64_t ct_dataseg64[ISP_RQDSEG_T3];
    657  1.24  mjacob 				ispdslist_t ct_dslist;
    658  1.24  mjacob 			} u;
    659  1.24  mjacob 		} m0;
    660  1.24  mjacob 		struct {
    661  1.24  mjacob 			uint16_t _reserved;
    662  1.24  mjacob 			uint16_t _reserved2;
    663  1.24  mjacob 			uint16_t ct_senselen;
    664  1.24  mjacob 			uint16_t ct_scsi_status;
    665  1.24  mjacob 			uint16_t ct_resplen;
    666  1.24  mjacob 			uint8_t  ct_resp[MAXRESPLEN];
    667  1.24  mjacob 		} m1;
    668  1.24  mjacob 		struct {
    669  1.24  mjacob 			uint32_t _reserved;
    670  1.24  mjacob 			uint16_t _reserved2;
    671  1.24  mjacob 			uint16_t _reserved3;
    672  1.24  mjacob 			uint32_t ct_datalen;
    673  1.24  mjacob 			ispds_t ct_fcp_rsp_iudata;
    674  1.24  mjacob 		} m2;
    675  1.24  mjacob 	} rsp;
    676  1.24  mjacob } ct2e_entry_t;
    677  1.24  mjacob 
    678   1.1  mjacob /*
    679   1.1  mjacob  * ct_flags values for CTIO2
    680   1.1  mjacob  */
    681   1.1  mjacob #define	CT2_FLAG_MODE0	0x0000
    682   1.1  mjacob #define	CT2_FLAG_MODE1	0x0001
    683   1.1  mjacob #define	CT2_FLAG_MODE2	0x0002
    684  1.24  mjacob #define		CT2_FLAG_MMASK	0x0003
    685  1.24  mjacob #define CT2_DATA_IN	0x0040
    686  1.24  mjacob #define CT2_DATA_OUT	0x0080
    687  1.24  mjacob #define CT2_NO_DATA	0x00C0
    688  1.24  mjacob #define 	CT2_DATAMASK	0x00C0
    689   1.1  mjacob #define	CT2_CCINCR	0x0100
    690   1.1  mjacob #define	CT2_FASTPOST	0x0200
    691  1.24  mjacob #define	CT2_CONFIRM	0x2000
    692  1.20  mjacob #define	CT2_TERMINATE	0x4000
    693   1.1  mjacob #define CT2_SENDSTATUS	0x8000
    694   1.1  mjacob 
    695   1.1  mjacob /*
    696   1.1  mjacob  * ct_status values are (mostly) the same as that for ct_entry.
    697   1.1  mjacob  */
    698   1.1  mjacob 
    699   1.1  mjacob /*
    700   1.1  mjacob  * ct_scsi_status values- the low 8 bits are the normal SCSI status
    701   1.1  mjacob  * we know and love. The upper 8 bits are validity markers for FCP_RSP_IU
    702   1.1  mjacob  * fields.
    703   1.1  mjacob  */
    704   1.1  mjacob #define	CT2_RSPLEN_VALID	0x0100
    705   1.1  mjacob #define	CT2_SNSLEN_VALID	0x0200
    706   1.1  mjacob #define	CT2_DATA_OVER		0x0400
    707   1.1  mjacob #define	CT2_DATA_UNDER		0x0800
    708   1.1  mjacob 
    709   1.1  mjacob /*
    710  1.24  mjacob  * ISP24XX CTIO
    711  1.24  mjacob  */
    712  1.24  mjacob #define	MAXRESPLEN_24XX	24
    713  1.24  mjacob typedef struct {
    714  1.24  mjacob 	isphdr_t	ct_header;
    715  1.24  mjacob 	uint32_t	ct_syshandle;
    716  1.24  mjacob 	uint16_t	ct_nphdl;	/* status on returned CTIOs */
    717  1.24  mjacob 	uint16_t	ct_timeout;
    718  1.24  mjacob 	uint16_t	ct_seg_count;
    719  1.24  mjacob 	uint8_t		ct_vpindex;
    720  1.24  mjacob 	uint8_t		ct_xflags;
    721  1.24  mjacob 	uint16_t	ct_iid_lo;	/* low 16 bits of portid */
    722  1.24  mjacob 	uint8_t		ct_iid_hi;	/* hi 8 bits of portid */
    723  1.24  mjacob 	uint8_t		ct_reserved;
    724  1.24  mjacob 	uint32_t	ct_rxid;
    725  1.24  mjacob 	uint16_t	ct_senselen;	/* mode 0 only */
    726  1.24  mjacob 	uint16_t	ct_flags;
    727  1.24  mjacob 	int32_t		ct_resid;	/* residual length */
    728  1.24  mjacob 	uint16_t	ct_oxid;
    729  1.24  mjacob 	uint16_t	ct_scsi_status;	/* modes 0 && 1 only */
    730  1.24  mjacob 	union {
    731  1.24  mjacob 		struct {
    732  1.24  mjacob 			uint32_t	reloff;
    733  1.24  mjacob 			uint32_t	reserved0;
    734  1.24  mjacob 			uint32_t	ct_xfrlen;
    735  1.24  mjacob 			uint32_t	reserved1;
    736  1.24  mjacob 			ispds64_t	ds;
    737  1.24  mjacob 		} m0;
    738  1.24  mjacob 		struct {
    739  1.24  mjacob 			uint16_t ct_resplen;
    740  1.24  mjacob 			uint16_t reserved;
    741  1.24  mjacob 			uint8_t  ct_resp[MAXRESPLEN_24XX];
    742  1.24  mjacob 		} m1;
    743  1.24  mjacob 		struct {
    744  1.24  mjacob 			uint32_t reserved0;
    745  1.24  mjacob 			uint32_t ct_datalen;
    746  1.24  mjacob 			uint32_t reserved1;
    747  1.24  mjacob 			ispds64_t ct_fcp_rsp_iudata;
    748  1.24  mjacob 		} m2;
    749  1.24  mjacob 	} rsp;
    750  1.24  mjacob } ct7_entry_t;
    751  1.24  mjacob 
    752  1.24  mjacob /*
    753  1.24  mjacob  * ct_flags values for CTIO7
    754  1.24  mjacob  */
    755  1.24  mjacob #define CT7_DATA_IN	0x0002
    756  1.24  mjacob #define CT7_DATA_OUT	0x0001
    757  1.24  mjacob #define CT7_NO_DATA	0x0000
    758  1.24  mjacob #define 	CT7_DATAMASK	0x003
    759  1.24  mjacob #define	CT7_DSD_ENABLE	0x0004
    760  1.24  mjacob #define	CT7_CONF_STSFD	0x0010
    761  1.24  mjacob #define	CT7_EXPLCT_CONF	0x0020
    762  1.24  mjacob #define	CT7_FLAG_MODE0	0x0000
    763  1.24  mjacob #define	CT7_FLAG_MODE1	0x0040
    764  1.24  mjacob #define	CT7_FLAG_MODE7	0x0080
    765  1.24  mjacob #define		CT7_FLAG_MMASK	0x00C0
    766  1.24  mjacob #define	CT7_FASTPOST	0x0100
    767  1.24  mjacob #define	CT7_ATTR_MASK	0x1e00	/* task attributes from atio7 */
    768  1.24  mjacob #define	CT7_CONFIRM	0x2000
    769  1.24  mjacob #define	CT7_TERMINATE	0x4000
    770  1.24  mjacob #define CT7_SENDSTATUS	0x8000
    771  1.24  mjacob 
    772  1.24  mjacob /*
    773  1.24  mjacob  * Type 7 CTIO status codes
    774  1.24  mjacob  */
    775  1.24  mjacob #define CT7_OK		0x01	/* completed without error */
    776  1.24  mjacob #define CT7_ABORTED	0x02	/* aborted by host */
    777  1.24  mjacob #define CT7_ERR		0x04	/* see sense data for error */
    778  1.24  mjacob #define CT7_INVAL	0x06	/* request for disabled lun */
    779  1.24  mjacob #define	CT7_INVRXID	0x08	/* (FC only) Invalid RX_ID */
    780  1.24  mjacob #define	CT7_DATA_OVER	0x09	/* (FC only) Data Overrun */
    781  1.24  mjacob #define CT7_TIMEOUT	0x0B	/* timed out */
    782  1.24  mjacob #define CT7_RESET	0x0E	/* LIP Rset Received */
    783  1.24  mjacob #define	CT7_BUS_ERROR	0x10	/* DMA PCI Error */
    784  1.24  mjacob #define	CT7_REASSY_ERR	0x11	/* DMA reassembly error */
    785  1.24  mjacob #define	CT7_DATA_UNDER	0x15	/* (FC only) Data Underrun */
    786  1.24  mjacob #define	CT7_PORTUNAVAIL	0x28	/* port not available */
    787  1.24  mjacob #define	CT7_LOGOUT	0x29	/* port logout */
    788  1.24  mjacob #define	CT7_PORTCHANGED	0x2A	/* port changed */
    789  1.24  mjacob #define	CT7_SRR		0x45	/* SRR Received */
    790  1.24  mjacob 
    791  1.24  mjacob /*
    792  1.24  mjacob  * Other 24XX related target IOCBs
    793  1.24  mjacob  */
    794  1.24  mjacob 
    795  1.24  mjacob /*
    796  1.24  mjacob  * ABTS Received
    797  1.24  mjacob  */
    798  1.24  mjacob typedef struct {
    799  1.24  mjacob 	isphdr_t	abts_header;
    800  1.24  mjacob 	uint8_t		abts_reserved0[6];
    801  1.24  mjacob 	uint16_t	abts_nphdl;
    802  1.24  mjacob 	uint16_t	abts_reserved1;
    803  1.24  mjacob 	uint16_t	abts_sof;
    804  1.24  mjacob 	uint32_t	abts_rxid_abts;
    805  1.24  mjacob 	uint16_t	abts_did_lo;
    806  1.24  mjacob 	uint8_t		abts_did_hi;
    807  1.24  mjacob 	uint8_t		abts_r_ctl;
    808  1.24  mjacob 	uint16_t	abts_sid_lo;
    809  1.24  mjacob 	uint8_t		abts_sid_hi;
    810  1.24  mjacob 	uint8_t		abts_cs_ctl;
    811  1.24  mjacob 	uint16_t	abts_fs_ctl;
    812  1.24  mjacob 	uint8_t		abts_f_ctl;
    813  1.24  mjacob 	uint8_t		abts_type;
    814  1.24  mjacob 	uint16_t	abts_seq_cnt;
    815  1.24  mjacob 	uint8_t		abts_df_ctl;
    816  1.24  mjacob 	uint8_t		abts_seq_id;
    817  1.24  mjacob 	uint16_t	abts_rx_id;
    818  1.24  mjacob 	uint16_t	abts_ox_id;
    819  1.24  mjacob 	uint32_t	abts_param;
    820  1.24  mjacob 	uint8_t		abts_reserved2[16];
    821  1.24  mjacob 	uint32_t	abts_rxid_task;
    822  1.24  mjacob } abts_t;
    823  1.24  mjacob 
    824  1.24  mjacob typedef struct {
    825  1.24  mjacob 	isphdr_t	abts_rsp_header;
    826  1.24  mjacob 	uint32_t	abts_rsp_handle;
    827  1.24  mjacob 	uint16_t	abts_rsp_status;
    828  1.24  mjacob 	uint16_t	abts_rsp_nphdl;
    829  1.24  mjacob 	uint16_t	abts_rsp_ctl_flags;
    830  1.24  mjacob 	uint16_t	abts_rsp_sof;
    831  1.24  mjacob 	uint32_t	abts_rsp_rxid_abts;
    832  1.24  mjacob 	uint16_t	abts_rsp_did_lo;
    833  1.24  mjacob 	uint8_t		abts_rsp_did_hi;
    834  1.24  mjacob 	uint8_t		abts_rsp_r_ctl;
    835  1.24  mjacob 	uint16_t	abts_rsp_sid_lo;
    836  1.24  mjacob 	uint8_t		abts_rsp_sid_hi;
    837  1.24  mjacob 	uint8_t		abts_rsp_cs_ctl;
    838  1.24  mjacob 	uint16_t	abts_rsp_f_ctl_lo;
    839  1.24  mjacob 	uint8_t		abts_rsp_f_ctl_hi;
    840  1.24  mjacob 	uint8_t		abts_rsp_type;
    841  1.24  mjacob 	uint16_t	abts_rsp_seq_cnt;
    842  1.24  mjacob 	uint8_t		abts_rsp_df_ctl;
    843  1.24  mjacob 	uint8_t		abts_rsp_seq_id;
    844  1.24  mjacob 	uint16_t	abts_rsp_rx_id;
    845  1.24  mjacob 	uint16_t	abts_rsp_ox_id;
    846  1.24  mjacob 	uint32_t	abts_rsp_param;
    847  1.24  mjacob 	union {
    848  1.24  mjacob 		struct {
    849  1.24  mjacob 			uint16_t reserved;
    850  1.24  mjacob 			uint8_t	last_seq_id;
    851  1.24  mjacob 			uint8_t seq_id_valid;
    852  1.24  mjacob 			uint16_t aborted_rx_id;
    853  1.24  mjacob 			uint16_t aborted_ox_id;
    854  1.24  mjacob 			uint16_t high_seq_cnt;
    855  1.24  mjacob 			uint16_t low_seq_cnt;
    856  1.24  mjacob 			uint8_t reserved2[4];
    857  1.24  mjacob 		} ba_acc;
    858  1.24  mjacob 		struct {
    859  1.24  mjacob 			uint8_t vendor_unique;
    860  1.24  mjacob 			uint8_t	explanation;
    861  1.24  mjacob 			uint8_t reason;
    862  1.24  mjacob 			uint8_t reserved;
    863  1.24  mjacob 			uint8_t reserved2[12];
    864  1.24  mjacob 		} ba_rjt;
    865  1.24  mjacob 		struct {
    866  1.24  mjacob 			uint8_t reserved[8];
    867  1.24  mjacob 			uint32_t subcode1;
    868  1.24  mjacob 			uint32_t subcode2;
    869  1.24  mjacob 		} rsp;
    870  1.24  mjacob 		uint8_t reserved[16];
    871  1.24  mjacob 	} abts_rsp_payload;
    872  1.24  mjacob 	uint32_t	abts_rsp_rxid_task;
    873  1.24  mjacob } abts_rsp_t;
    874  1.24  mjacob 
    875  1.24  mjacob /* terminate this ABTS exchange */
    876  1.24  mjacob #define	ISP24XX_ABTS_RSP_TERMINATE	0x01
    877  1.24  mjacob 
    878  1.24  mjacob #define	ISP24XX_ABTS_RSP_COMPLETE	0x00
    879  1.24  mjacob #define	ISP24XX_ABTS_RSP_RESET		0x04
    880  1.24  mjacob #define	ISP24XX_ABTS_RSP_ABORTED	0x05
    881  1.24  mjacob #define	ISP24XX_ABTS_RSP_TIMEOUT	0x06
    882  1.24  mjacob #define	ISP24XX_ABTS_RSP_INVXID		0x08
    883  1.24  mjacob #define	ISP24XX_ABTS_RSP_LOGOUT		0x29
    884  1.24  mjacob #define	ISP24XX_ABTS_RSP_SUBCODE	0x31
    885  1.24  mjacob 
    886  1.24  mjacob /*
    887   1.1  mjacob  * Debug macros
    888   1.1  mjacob  */
    889   1.1  mjacob 
    890   1.1  mjacob #define	ISP_TDQE(isp, msg, idx, arg)	\
    891   1.7  mjacob     if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg)
    892   1.1  mjacob 
    893  1.24  mjacob #ifndef	ISP_TOOLS
    894   1.1  mjacob /*
    895  1.16  mjacob  * The functions below are for the publicly available
    896  1.16  mjacob  * target mode functions that are internal to the Qlogic driver.
    897   1.1  mjacob  */
    898   1.1  mjacob 
    899  1.24  mjacob /*
    900  1.24  mjacob  * This function handles new response queue entry appropriate for target mode.
    901  1.24  mjacob  */
    902  1.24  mjacob int isp_target_notify(ispsoftc_t *, void *, uint32_t *);
    903  1.23    cube 
    904   1.1  mjacob /*
    905  1.24  mjacob  * This function externalizes the ability to acknowledge an Immediate Notify
    906  1.24  mjacob  * request.
    907   1.1  mjacob  */
    908  1.24  mjacob void isp_notify_ack(ispsoftc_t *, void *);
    909   1.1  mjacob 
    910   1.1  mjacob /*
    911   1.1  mjacob  * Enable/Disable/Modify a logical unit.
    912  1.13  mjacob  * (softc, cmd, bus, tgt, lun, cmd_cnt, inotify_cnt, opaque)
    913   1.1  mjacob  */
    914  1.19  mjacob #define	DFLT_CMND_CNT	0xfe	/* unmonitored */
    915  1.24  mjacob #define	DFLT_INOT_CNT	0xfe	/* unmonitored */
    916  1.24  mjacob int isp_lun_cmd(ispsoftc_t *, int, int, int, int, int, int, uint32_t);
    917   1.1  mjacob 
    918   1.1  mjacob /*
    919   1.1  mjacob  * General request queue 'put' routine for target mode entries.
    920   1.1  mjacob  */
    921  1.24  mjacob int isp_target_put_entry(ispsoftc_t *isp, void *);
    922   1.1  mjacob 
    923   1.1  mjacob /*
    924   1.1  mjacob  * General routine to put back an ATIO entry-
    925   1.1  mjacob  * used for replenishing f/w resource counts.
    926  1.12  mjacob  * The argument is a pointer to a source ATIO
    927  1.12  mjacob  * or ATIO2.
    928   1.1  mjacob  */
    929  1.24  mjacob int isp_target_put_atio(ispsoftc_t *, void *);
    930   1.1  mjacob 
    931   1.1  mjacob /*
    932   1.1  mjacob  * General routine to send a final CTIO for a command- used mostly for
    933   1.1  mjacob  * local responses.
    934   1.1  mjacob  */
    935  1.24  mjacob int isp_endcmd(ispsoftc_t *, void *, uint32_t, uint32_t);
    936   1.2  mjacob #define	ECMD_SVALID	0x100
    937   1.1  mjacob 
    938   1.1  mjacob /*
    939   1.1  mjacob  * Handle an asynchronous event
    940  1.18  mjacob  *
    941  1.18  mjacob  * Return nonzero if the interrupt that generated this event has been dismissed.
    942   1.1  mjacob  */
    943  1.24  mjacob int isp_target_async(ispsoftc_t *, int, int);
    944  1.16  mjacob #endif
    945  1.11  mjacob #endif	/* _ISP_TARGET_H */
    946