xref: /freebsd/sys/dev/isp/isp_stds.h (revision 10365e5a68725142a2a7effaec46ca1d8f5b273a)
110365e5aSMatt Jacob /* $FreeBSD$ */
210365e5aSMatt Jacob /*-
310365e5aSMatt Jacob  * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters.
410365e5aSMatt Jacob  *
510365e5aSMatt Jacob  * Copyright (c) 1997-2006 by Matthew Jacob
610365e5aSMatt Jacob  * All rights reserved.
710365e5aSMatt Jacob  *
810365e5aSMatt Jacob  * Redistribution and use in source and binary forms, with or without
910365e5aSMatt Jacob  * modification, are permitted provided that the following conditions
1010365e5aSMatt Jacob  * are met:
1110365e5aSMatt Jacob  * 1. Redistributions of source code must retain the above copyright
1210365e5aSMatt Jacob  *    notice immediately at the beginning of the file, without modification,
1310365e5aSMatt Jacob  *    this list of conditions, and the following disclaimer.
1410365e5aSMatt Jacob  * 2. The name of the author may not be used to endorse or promote products
1510365e5aSMatt Jacob  *    derived from this software without specific prior written permission.
1610365e5aSMatt Jacob  *
1710365e5aSMatt Jacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1810365e5aSMatt Jacob  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1910365e5aSMatt Jacob  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2010365e5aSMatt Jacob  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
2110365e5aSMatt Jacob  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2210365e5aSMatt Jacob  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2310365e5aSMatt Jacob  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2410365e5aSMatt Jacob  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2510365e5aSMatt Jacob  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2610365e5aSMatt Jacob  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2710365e5aSMatt Jacob  * SUCH DAMAGE.
2810365e5aSMatt Jacob  *
2910365e5aSMatt Jacob  */
3010365e5aSMatt Jacob /*
3110365e5aSMatt Jacob  * Structures that derive directly from public standards.
3210365e5aSMatt Jacob  */
3310365e5aSMatt Jacob #ifndef	_ISP_STDS_H
3410365e5aSMatt Jacob #define	_ISP_STDS_H
3510365e5aSMatt Jacob 
3610365e5aSMatt Jacob /*
3710365e5aSMatt Jacob  * FC Frame Header
3810365e5aSMatt Jacob  *
3910365e5aSMatt Jacob  * Source: dpANS-X3.xxx-199x, section 18 (AKA FC-PH-2)
4010365e5aSMatt Jacob  *
4110365e5aSMatt Jacob  */
4210365e5aSMatt Jacob typedef struct {
4310365e5aSMatt Jacob 	uint8_t		r_ctl;
4410365e5aSMatt Jacob 	uint8_t		d_id[3];
4510365e5aSMatt Jacob 	uint8_t		cs_ctl;
4610365e5aSMatt Jacob 	uint8_t		s_id[3];
4710365e5aSMatt Jacob 	uint8_t		type;
4810365e5aSMatt Jacob 	uint8_t		f_ctl;
4910365e5aSMatt Jacob 	uint8_t		seq_id;
5010365e5aSMatt Jacob 	uint8_t		df_ctl;
5110365e5aSMatt Jacob 	uint16_t	seq_cnt;
5210365e5aSMatt Jacob 	uint16_t	ox_id;
5310365e5aSMatt Jacob 	uint16_t	rx_id;
5410365e5aSMatt Jacob 	uint32_t	parameter;
5510365e5aSMatt Jacob } fc_hdr_t;
5610365e5aSMatt Jacob 
5710365e5aSMatt Jacob /*
5810365e5aSMatt Jacob  * FCP_CMND_IU Payload
5910365e5aSMatt Jacob  *
6010365e5aSMatt Jacob  * Source: NICTS T10, Project 1144D, Revision 07a, Section 9 (AKA fcp2-r07a)
6110365e5aSMatt Jacob  *
6210365e5aSMatt Jacob  * Notes:
6310365e5aSMatt Jacob  *	When additional cdb length is defined in fcp_cmnd_alen_datadir,
6410365e5aSMatt Jacob  * 	bits 2..7, the actual cdb length is 16 + ((fcp_cmnd_alen_datadir>>2)*4),
6510365e5aSMatt Jacob  *	with the datalength following in MSB format just after.
6610365e5aSMatt Jacob  */
6710365e5aSMatt Jacob typedef struct {
6810365e5aSMatt Jacob 	uint8_t		fcp_cmnd_lun[8];
6910365e5aSMatt Jacob 	uint8_t		fcp_cmnd_crn;
7010365e5aSMatt Jacob 	uint8_t		fcp_cmnd_task_attribute;
7110365e5aSMatt Jacob 	uint8_t		fcp_cmnd_task_management;
7210365e5aSMatt Jacob 	uint8_t		fcp_cmnd_alen_datadir;
7310365e5aSMatt Jacob 	union {
7410365e5aSMatt Jacob 		struct {
7510365e5aSMatt Jacob 			uint8_t		fcp_cmnd_cdb[16];
7610365e5aSMatt Jacob 			uint32_t	fcp_cmnd_dl;
7710365e5aSMatt Jacob 		} sf;
7810365e5aSMatt Jacob 		struct {
7910365e5aSMatt Jacob 			uint8_t		fcp_cmnd_cdb[1];
8010365e5aSMatt Jacob 		} lf;
8110365e5aSMatt Jacob 	} cdb_dl;
8210365e5aSMatt Jacob } fcp_cmnd_iu_t;
8310365e5aSMatt Jacob 
8410365e5aSMatt Jacob 
8510365e5aSMatt Jacob #define	FCP_CMND_TASK_ATTR_SIMPLE	0x00
8610365e5aSMatt Jacob #define	FCP_CMND_TASK_ATTR_HEAD		0x01
8710365e5aSMatt Jacob #define	FCP_CMND_TASK_ATTR_ORDERED	0x02
8810365e5aSMatt Jacob #define	FCP_CMND_TASK_ATTR_ACA		0x04
8910365e5aSMatt Jacob #define	FCP_CMND_TASK_ATTR_UNTAGGED	0x05
9010365e5aSMatt Jacob #define	FCP_CMND_TASK_ATTR_MASK		0x07
9110365e5aSMatt Jacob 
9210365e5aSMatt Jacob #define	FCP_CMND_ADDTL_CDBLEN_SHIFT	2
9310365e5aSMatt Jacob 
9410365e5aSMatt Jacob #define	FCP_CMND_DATA_WRITE		0x01
9510365e5aSMatt Jacob #define	FCP_CMND_DATA_READ		0x02
9610365e5aSMatt Jacob 
9710365e5aSMatt Jacob #define	FCP_CMND_DATA_DIR_MASK		0x03
9810365e5aSMatt Jacob 
9910365e5aSMatt Jacob #define	FCP_CMND_TMF_CLEAR_ACA		0x40
10010365e5aSMatt Jacob #define	FCP_CMND_TMF_TGT_RESET		0x20
10110365e5aSMatt Jacob #define	FCP_CMND_TMF_LUN_RESET		0x10
10210365e5aSMatt Jacob #define	FCP_CMND_TMF_CLEAR_TASK_SET	0x04
10310365e5aSMatt Jacob #define	FCP_CMND_TMF_ABORT_TASK_SET	0x02
10410365e5aSMatt Jacob 
10510365e5aSMatt Jacob /*
10610365e5aSMatt Jacob  * Basic CT IU Header
10710365e5aSMatt Jacob  *
10810365e5aSMatt Jacob  * Source: X3.288-199x Generic Services 2 Rev 5.3 (FC-GS-2) Section 4.3.1
10910365e5aSMatt Jacob  */
11010365e5aSMatt Jacob 
11110365e5aSMatt Jacob typedef struct {
11210365e5aSMatt Jacob 	uint8_t		ct_revision;
11310365e5aSMatt Jacob 	uint8_t		ct_in_id[3];
11410365e5aSMatt Jacob 	uint8_t		ct_fcs_type;
11510365e5aSMatt Jacob 	uint8_t		ct_fcs_subtype;
11610365e5aSMatt Jacob 	uint8_t		ct_options;
11710365e5aSMatt Jacob 	uint8_t		ct_reserved0;
11810365e5aSMatt Jacob 	uint16_t	ct_cmd_resp;
11910365e5aSMatt Jacob 	uint16_t	ct_bcnt_resid;
12010365e5aSMatt Jacob 	uint8_t		ct_reserved1;
12110365e5aSMatt Jacob 	uint8_t		ct_reason;
12210365e5aSMatt Jacob 	uint8_t		ct_explanation;
12310365e5aSMatt Jacob 	uint8_t		ct_vunique;
12410365e5aSMatt Jacob } ct_hdr_t;
12510365e5aSMatt Jacob #define	CT_REVISION		1
12610365e5aSMatt Jacob #define	CT_FC_TYPE_FC		0xFC
12710365e5aSMatt Jacob #define CT_FC_SUBTYPE_NS	0x02
12810365e5aSMatt Jacob 
12910365e5aSMatt Jacob /*
13010365e5aSMatt Jacob  * RFT_ID Requet CT_IU
13110365e5aSMatt Jacob  *
13210365e5aSMatt Jacob  * Source: INCITS xxx-200x Generic Services- 5 Rev 8.5 Section 5.2.5.30
13310365e5aSMatt Jacob  */
13410365e5aSMatt Jacob typedef struct {
13510365e5aSMatt Jacob 	ct_hdr_t	rftid_hdr;
13610365e5aSMatt Jacob 	uint8_t		rftid_reserved;
13710365e5aSMatt Jacob 	uint8_t		rftid_portid[3];
13810365e5aSMatt Jacob 	uint32_t	rftid_fc4types[8];
13910365e5aSMatt Jacob } rft_id_t;
14010365e5aSMatt Jacob 
14110365e5aSMatt Jacob 
14210365e5aSMatt Jacob /* unconverted miscellany */
14310365e5aSMatt Jacob /*
14410365e5aSMatt Jacob  * Basic FC Link Service defines
14510365e5aSMatt Jacob  */
14610365e5aSMatt Jacob /*
14710365e5aSMatt Jacob  * These are in the R_CTL field.
14810365e5aSMatt Jacob  */
14910365e5aSMatt Jacob #define	ABTS			0x81
15010365e5aSMatt Jacob #define	BA_ACC			0x84	/* of ABORT SEQUENCE */
15110365e5aSMatt Jacob #define	BA_RJT			0x85	/* of ABORT SEQUENCE */
15210365e5aSMatt Jacob 
15310365e5aSMatt Jacob /*
15410365e5aSMatt Jacob  * Link Service Accept/Reject
15510365e5aSMatt Jacob  */
15610365e5aSMatt Jacob #define	LS_ACC			0x8002
15710365e5aSMatt Jacob #define	LS_RJT			0x8001
15810365e5aSMatt Jacob 
15910365e5aSMatt Jacob /*
16010365e5aSMatt Jacob  * FC ELS Codes- bits 31-24 of the first payload word of an ELS frame.
16110365e5aSMatt Jacob  */
16210365e5aSMatt Jacob #define	PLOGI			0x03
16310365e5aSMatt Jacob #define	FLOGI			0x04
16410365e5aSMatt Jacob #define	LOGO			0x05
16510365e5aSMatt Jacob #define	ABTX			0x06
16610365e5aSMatt Jacob #define	PRLI			0x20
16710365e5aSMatt Jacob #define	PRLO			0x21
16810365e5aSMatt Jacob #define	TPRLO			0x24
16910365e5aSMatt Jacob #define	RNC			0x53
17010365e5aSMatt Jacob 
17110365e5aSMatt Jacob /*
17210365e5aSMatt Jacob  * FC4 defines
17310365e5aSMatt Jacob  */
17410365e5aSMatt Jacob #define	FC4_IP		5	/* ISO/EEC 8802-2 LLC/SNAP */
17510365e5aSMatt Jacob #define	FC4_SCSI	8	/* SCSI-3 via Fibre Channel Protocol (FCP) */
17610365e5aSMatt Jacob #define	FC4_FC_SVC	0x20	/* Fibre Channel Services */
17710365e5aSMatt Jacob 
17810365e5aSMatt Jacob #ifndef	MSG_ABORT
17910365e5aSMatt Jacob #define	MSG_ABORT		0x06
18010365e5aSMatt Jacob #endif
18110365e5aSMatt Jacob #ifndef	MSG_BUS_DEV_RESET
18210365e5aSMatt Jacob #define	MSG_BUS_DEV_RESET	0x0c
18310365e5aSMatt Jacob #endif
18410365e5aSMatt Jacob #ifndef	MSG_ABORT_TAG
18510365e5aSMatt Jacob #define	MSG_ABORT_TAG		0x0d
18610365e5aSMatt Jacob #endif
18710365e5aSMatt Jacob #ifndef	MSG_CLEAR_QUEUE
18810365e5aSMatt Jacob #define	MSG_CLEAR_QUEUE		0x0e
18910365e5aSMatt Jacob #endif
19010365e5aSMatt Jacob #ifndef	MSG_REL_RECOVERY
19110365e5aSMatt Jacob #define	MSG_REL_RECOVERY	0x10
19210365e5aSMatt Jacob #endif
19310365e5aSMatt Jacob #ifndef	MSG_TERM_IO_PROC
19410365e5aSMatt Jacob #define	MSG_TERM_IO_PROC	0x11
19510365e5aSMatt Jacob #endif
19610365e5aSMatt Jacob #ifndef	MSG_LUN_RESET
19710365e5aSMatt Jacob #define	MSG_LUN_RESET		0x17
19810365e5aSMatt Jacob #endif
19910365e5aSMatt Jacob 
20010365e5aSMatt Jacob #endif	/* _ISP_STDS_H */
201