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