xref: /freebsd/sys/dev/isp/isp_stds.h (revision 98981e638fcc14130ec02035bb9cee1b40377a57)
1 /* $FreeBSD$ */
2 /*-
3  * Mailbox and Queue Entry Definitions for for Qlogic ISP SCSI adapters.
4  *
5  * Copyright (c) 1997-2006 by Matthew Jacob
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice immediately at the beginning of the file, without modification,
13  *    this list of conditions, and the following disclaimer.
14  * 2. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  */
30 /*
31  * Structures that derive directly from public standards.
32  */
33 #ifndef	_ISP_STDS_H
34 #define	_ISP_STDS_H
35 
36 /*
37  * FC Frame Header
38  *
39  * Source: dpANS-X3.xxx-199x, section 18 (AKA FC-PH-2)
40  *
41  */
42 typedef struct {
43 	uint8_t		r_ctl;
44 	uint8_t		d_id[3];
45 	uint8_t		cs_ctl;
46 	uint8_t		s_id[3];
47 	uint8_t		type;
48 	uint8_t		f_ctl;
49 	uint8_t		seq_id;
50 	uint8_t		df_ctl;
51 	uint16_t	seq_cnt;
52 	uint16_t	ox_id;
53 	uint16_t	rx_id;
54 	uint32_t	parameter;
55 } fc_hdr_t;
56 
57 /*
58  * FCP_CMND_IU Payload
59  *
60  * Source: NICTS T10, Project 1144D, Revision 07a, Section 9 (AKA fcp2-r07a)
61  *
62  * Notes:
63  *	When additional cdb length is defined in fcp_cmnd_alen_datadir,
64  * 	bits 2..7, the actual cdb length is 16 + ((fcp_cmnd_alen_datadir>>2)*4),
65  *	with the datalength following in MSB format just after.
66  */
67 typedef struct {
68 	uint8_t		fcp_cmnd_lun[8];
69 	uint8_t		fcp_cmnd_crn;
70 	uint8_t		fcp_cmnd_task_attribute;
71 	uint8_t		fcp_cmnd_task_management;
72 	uint8_t		fcp_cmnd_alen_datadir;
73 	union {
74 		struct {
75 			uint8_t		fcp_cmnd_cdb[16];
76 			uint32_t	fcp_cmnd_dl;
77 		} sf;
78 		struct {
79 			uint8_t		fcp_cmnd_cdb[1];
80 		} lf;
81 	} cdb_dl;
82 } fcp_cmnd_iu_t;
83 
84 
85 #define	FCP_CMND_TASK_ATTR_SIMPLE	0x00
86 #define	FCP_CMND_TASK_ATTR_HEAD		0x01
87 #define	FCP_CMND_TASK_ATTR_ORDERED	0x02
88 #define	FCP_CMND_TASK_ATTR_ACA		0x04
89 #define	FCP_CMND_TASK_ATTR_UNTAGGED	0x05
90 #define	FCP_CMND_TASK_ATTR_MASK		0x07
91 
92 #define	FCP_CMND_ADDTL_CDBLEN_SHIFT	2
93 
94 #define	FCP_CMND_DATA_WRITE		0x01
95 #define	FCP_CMND_DATA_READ		0x02
96 
97 #define	FCP_CMND_DATA_DIR_MASK		0x03
98 
99 #define	FCP_CMND_TMF_CLEAR_ACA		0x40
100 #define	FCP_CMND_TMF_TGT_RESET		0x20
101 #define	FCP_CMND_TMF_LUN_RESET		0x10
102 #define	FCP_CMND_TMF_CLEAR_TASK_SET	0x04
103 #define	FCP_CMND_TMF_ABORT_TASK_SET	0x02
104 
105 /*
106  * Basic CT IU Header
107  *
108  * Source: X3.288-199x Generic Services 2 Rev 5.3 (FC-GS-2) Section 4.3.1
109  */
110 
111 typedef struct {
112 	uint8_t		ct_revision;
113 	uint8_t		ct_in_id[3];
114 	uint8_t		ct_fcs_type;
115 	uint8_t		ct_fcs_subtype;
116 	uint8_t		ct_options;
117 	uint8_t		ct_reserved0;
118 	uint16_t	ct_cmd_resp;
119 	uint16_t	ct_bcnt_resid;
120 	uint8_t		ct_reserved1;
121 	uint8_t		ct_reason;
122 	uint8_t		ct_explanation;
123 	uint8_t		ct_vunique;
124 } ct_hdr_t;
125 #define	CT_REVISION		1
126 #define	CT_FC_TYPE_FC		0xFC
127 #define CT_FC_SUBTYPE_NS	0x02
128 
129 /*
130  * RFT_ID Requet CT_IU
131  *
132  * Source: INCITS xxx-200x Generic Services- 5 Rev 8.5 Section 5.2.5.30
133  */
134 typedef struct {
135 	ct_hdr_t	rftid_hdr;
136 	uint8_t		rftid_reserved;
137 	uint8_t		rftid_portid[3];
138 	uint32_t	rftid_fc4types[8];
139 } rft_id_t;
140 
141 
142 /* unconverted miscellany */
143 /*
144  * Basic FC Link Service defines
145  */
146 /*
147  * These are in the R_CTL field.
148  */
149 #define	ABTS			0x81
150 #define	BA_ACC			0x84	/* of ABORT SEQUENCE */
151 #define	BA_RJT			0x85	/* of ABORT SEQUENCE */
152 
153 /*
154  * Link Service Accept/Reject
155  */
156 #define	LS_ACC			0x8002
157 #define	LS_RJT			0x8001
158 
159 /*
160  * FC ELS Codes- bits 31-24 of the first payload word of an ELS frame.
161  */
162 #define	PLOGI			0x03
163 #define	FLOGI			0x04
164 #define	LOGO			0x05
165 #define	ABTX			0x06
166 #define	PRLI			0x20
167 #define	PRLO			0x21
168 #define	TPRLO			0x24
169 #define	RNC			0x53
170 
171 /*
172  * FC4 defines
173  */
174 #define	FC4_IP		5	/* ISO/EEC 8802-2 LLC/SNAP */
175 #define	FC4_SCSI	8	/* SCSI-3 via Fibre Channel Protocol (FCP) */
176 #define	FC4_FC_SVC	0x20	/* Fibre Channel Services */
177 
178 #ifndef	MSG_ABORT
179 #define	MSG_ABORT		0x06
180 #endif
181 #ifndef	MSG_BUS_DEV_RESET
182 #define	MSG_BUS_DEV_RESET	0x0c
183 #endif
184 #ifndef	MSG_ABORT_TAG
185 #define	MSG_ABORT_TAG		0x0d
186 #endif
187 #ifndef	MSG_CLEAR_QUEUE
188 #define	MSG_CLEAR_QUEUE		0x0e
189 #endif
190 #ifndef	MSG_REL_RECOVERY
191 #define	MSG_REL_RECOVERY	0x10
192 #endif
193 #ifndef	MSG_TERM_IO_PROC
194 #define	MSG_TERM_IO_PROC	0x11
195 #endif
196 #ifndef	MSG_LUN_RESET
197 #define	MSG_LUN_RESET		0x17
198 #endif
199 
200 #endif	/* _ISP_STDS_H */
201