xref: /freebsd/sys/dev/ocs_fc/ocs_fcp.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1*ef270ab1SKenneth D. Merry /*-
2*ef270ab1SKenneth D. Merry  * Copyright (c) 2017 Broadcom. All rights reserved.
3*ef270ab1SKenneth D. Merry  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
4*ef270ab1SKenneth D. Merry  *
5*ef270ab1SKenneth D. Merry  * Redistribution and use in source and binary forms, with or without
6*ef270ab1SKenneth D. Merry  * modification, are permitted provided that the following conditions are met:
7*ef270ab1SKenneth D. Merry  *
8*ef270ab1SKenneth D. Merry  * 1. Redistributions of source code must retain the above copyright notice,
9*ef270ab1SKenneth D. Merry  *    this list of conditions and the following disclaimer.
10*ef270ab1SKenneth D. Merry  *
11*ef270ab1SKenneth D. Merry  * 2. Redistributions in binary form must reproduce the above copyright notice,
12*ef270ab1SKenneth D. Merry  *    this list of conditions and the following disclaimer in the documentation
13*ef270ab1SKenneth D. Merry  *    and/or other materials provided with the distribution.
14*ef270ab1SKenneth D. Merry  *
15*ef270ab1SKenneth D. Merry  * 3. Neither the name of the copyright holder nor the names of its contributors
16*ef270ab1SKenneth D. Merry  *    may be used to endorse or promote products derived from this software
17*ef270ab1SKenneth D. Merry  *    without specific prior written permission.
18*ef270ab1SKenneth D. Merry  *
19*ef270ab1SKenneth D. Merry  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20*ef270ab1SKenneth D. Merry  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21*ef270ab1SKenneth D. Merry  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22*ef270ab1SKenneth D. Merry  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23*ef270ab1SKenneth D. Merry  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*ef270ab1SKenneth D. Merry  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*ef270ab1SKenneth D. Merry  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*ef270ab1SKenneth D. Merry  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*ef270ab1SKenneth D. Merry  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*ef270ab1SKenneth D. Merry  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*ef270ab1SKenneth D. Merry  * POSSIBILITY OF SUCH DAMAGE.
30*ef270ab1SKenneth D. Merry  */
31*ef270ab1SKenneth D. Merry 
32*ef270ab1SKenneth D. Merry /**
33*ef270ab1SKenneth D. Merry  * @file
34*ef270ab1SKenneth D. Merry  * Define Fibre Channel types and structures.
35*ef270ab1SKenneth D. Merry  */
36*ef270ab1SKenneth D. Merry 
37*ef270ab1SKenneth D. Merry #ifndef _OCS_FCP_H
38*ef270ab1SKenneth D. Merry #define _OCS_FCP_H
39*ef270ab1SKenneth D. Merry 
40*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_RJT		0x01
41*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_ACC		0x02
42*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_PLOGI	0x03
43*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_FLOGI	0x04
44*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_LOGO		0x05
45*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_RRQ		0x12
46*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_PRLI		0x20
47*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_PRLO		0x21
48*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_PDISC	0x50
49*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_FDISC	0x51
50*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_ADISC	0x52
51*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_RSCN		0x61
52*ef270ab1SKenneth D. Merry #define FC_ELS_CMD_SCR		0x62
53*ef270ab1SKenneth D. Merry 
54*ef270ab1SKenneth D. Merry #define FC_TYPE_BASIC_LINK	0
55*ef270ab1SKenneth D. Merry #define FC_TYPE_FCP		0x08
56*ef270ab1SKenneth D. Merry #define FC_TYPE_GS		0x20
57*ef270ab1SKenneth D. Merry #define FC_TYPE_SW		0x22
58*ef270ab1SKenneth D. Merry 
59*ef270ab1SKenneth D. Merry #define FC_ADDR_FABRIC			0xfffffe	/** well known fabric address */
60*ef270ab1SKenneth D. Merry #define FC_ADDR_CONTROLLER              0xfffffd        /** well known fabric controller address */
61*ef270ab1SKenneth D. Merry #define FC_ADDR_IS_DOMAIN_CTRL(x)	(((x) & 0xffff00) == 0xfffc00)	/** is well known domain controller */
62*ef270ab1SKenneth D. Merry #define FC_ADDR_GET_DOMAIN_CTRL(x)	((x) & 0x0000ff)	/** get domain controller number */
63*ef270ab1SKenneth D. Merry #define FC_ADDR_NAMESERVER              0xfffffc        /** well known directory server address */
64*ef270ab1SKenneth D. Merry 
65*ef270ab1SKenneth D. Merry #define FC_GS_TYPE_ALIAS_SERVICE		0xf8
66*ef270ab1SKenneth D. Merry #define FC_GS_TYPE_MANAGEMENT_SERVICE		0xfa
67*ef270ab1SKenneth D. Merry #define FC_GS_TYPE_DIRECTORY_SERVICE		0xfc
68*ef270ab1SKenneth D. Merry 
69*ef270ab1SKenneth D. Merry #define FC_GS_SUBTYPE_NAME_SERVER		0x02
70*ef270ab1SKenneth D. Merry 
71*ef270ab1SKenneth D. Merry /**
72*ef270ab1SKenneth D. Merry  * Generic Services FC Type Bit mask macros:
73*ef270ab1SKenneth D. Merry  */
74*ef270ab1SKenneth D. Merry #define FC_GS_TYPE_WORD(type)	((type) >> 5)
75*ef270ab1SKenneth D. Merry #define FC_GS_TYPE_BIT(type)	((type) & 0x1f)
76*ef270ab1SKenneth D. Merry 
77*ef270ab1SKenneth D. Merry /**
78*ef270ab1SKenneth D. Merry  * Generic Services Name Server Request Command codes:
79*ef270ab1SKenneth D. Merry  */
80*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_GPN_ID		0x0112
81*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_GNN_ID		0x0113
82*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_GFPN_ID	0x011c
83*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_GFF_ID		0x011f
84*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_GID_FT		0x0171
85*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_GID_PT		0x01a1
86*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_RHBA		0x0200
87*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_RPA		0x0211
88*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_RPN_ID		0x0212
89*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_RNN_ID		0x0213
90*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_RCS_ID		0x0214
91*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_RFT_ID		0x0217
92*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_RFF_ID		0x021f
93*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_RSNN_NN	0x0239
94*ef270ab1SKenneth D. Merry #define FC_GS_NAMESERVER_RSPN_ID	0x0218
95*ef270ab1SKenneth D. Merry 
96*ef270ab1SKenneth D. Merry #define FC_GS_REVISION		0x03
97*ef270ab1SKenneth D. Merry 
98*ef270ab1SKenneth D. Merry #define FC_GS_IO_PARAMS		{ .fc_ct.r_ctl = 0x02, \
99*ef270ab1SKenneth D. Merry 				.fc_ct.type = FC_TYPE_GS, \
100*ef270ab1SKenneth D. Merry 				.fc_ct.df_ctl = 0x00 }
101*ef270ab1SKenneth D. Merry 
102*ef270ab1SKenneth D. Merry typedef struct fc_vft_header_s {
103*ef270ab1SKenneth D. Merry 	uint32_t	:1,
104*ef270ab1SKenneth D. Merry 			vf_id:12,
105*ef270ab1SKenneth D. Merry 			priority:3,
106*ef270ab1SKenneth D. Merry 			e:1,
107*ef270ab1SKenneth D. Merry 			:1,
108*ef270ab1SKenneth D. Merry 			type:4,
109*ef270ab1SKenneth D. Merry 			ver:2,
110*ef270ab1SKenneth D. Merry 			r_ctl:8;
111*ef270ab1SKenneth D. Merry 	uint32_t	:24,
112*ef270ab1SKenneth D. Merry 			hopct:8;
113*ef270ab1SKenneth D. Merry } fc_vft_header_t;
114*ef270ab1SKenneth D. Merry 
115*ef270ab1SKenneth D. Merry #if BYTE_ORDER == LITTLE_ENDIAN
fc_be24toh(uint32_t x)116*ef270ab1SKenneth D. Merry static inline uint32_t fc_be24toh(uint32_t x) { return (ocs_be32toh(x) >> 8); }
117*ef270ab1SKenneth D. Merry #else
fc_be24toh(uint32_t x)118*ef270ab1SKenneth D. Merry static inline uint32_t fc_be24toh(uint32_t x) { }
119*ef270ab1SKenneth D. Merry #endif
fc_htobe24(uint32_t x)120*ef270ab1SKenneth D. Merry static inline uint32_t fc_htobe24(uint32_t x) { return fc_be24toh(x); }
121*ef270ab1SKenneth D. Merry 
122*ef270ab1SKenneth D. Merry #define FC_SOFI3	0x2e
123*ef270ab1SKenneth D. Merry #define FC_SOFn3	0x36
124*ef270ab1SKenneth D. Merry #define FC_EOFN		0x41
125*ef270ab1SKenneth D. Merry #define FC_EOFT		0x42
126*ef270ab1SKenneth D. Merry 
127*ef270ab1SKenneth D. Merry /**
128*ef270ab1SKenneth D. Merry  * @brief FC header in big-endian order
129*ef270ab1SKenneth D. Merry  */
130*ef270ab1SKenneth D. Merry typedef struct fc_header_s {
131*ef270ab1SKenneth D. Merry 	uint32_t	info:4,
132*ef270ab1SKenneth D. Merry 			r_ctl:4,
133*ef270ab1SKenneth D. Merry 			d_id:24;
134*ef270ab1SKenneth D. Merry 	uint32_t	cs_ctl:8,
135*ef270ab1SKenneth D. Merry 			s_id:24;
136*ef270ab1SKenneth D. Merry 	uint32_t	type:8,
137*ef270ab1SKenneth D. Merry 			f_ctl:24;
138*ef270ab1SKenneth D. Merry 	uint32_t	seq_id:8,
139*ef270ab1SKenneth D. Merry 			df_ctl:8,
140*ef270ab1SKenneth D. Merry 			seq_cnt:16;
141*ef270ab1SKenneth D. Merry 	uint32_t	ox_id:16,
142*ef270ab1SKenneth D. Merry 			rx_id:16;
143*ef270ab1SKenneth D. Merry 	uint32_t	parameter;
144*ef270ab1SKenneth D. Merry } fc_header_t;
145*ef270ab1SKenneth D. Merry 
146*ef270ab1SKenneth D. Merry /**
147*ef270ab1SKenneth D. Merry  * @brief FC header in little-endian order
148*ef270ab1SKenneth D. Merry  */
149*ef270ab1SKenneth D. Merry typedef struct fc_header_le_s {
150*ef270ab1SKenneth D. Merry #if BYTE_ORDER == LITTLE_ENDIAN
151*ef270ab1SKenneth D. Merry 	uint32_t	d_id:24,
152*ef270ab1SKenneth D. Merry 			info:4,
153*ef270ab1SKenneth D. Merry 			r_ctl:4;
154*ef270ab1SKenneth D. Merry 	uint32_t	s_id:24,
155*ef270ab1SKenneth D. Merry 			cs_ctl:8;
156*ef270ab1SKenneth D. Merry 	uint32_t	f_ctl:24,
157*ef270ab1SKenneth D. Merry 			type:8;
158*ef270ab1SKenneth D. Merry 	uint32_t	seq_cnt:16,
159*ef270ab1SKenneth D. Merry 			df_ctl:8,
160*ef270ab1SKenneth D. Merry 			seq_id:8;
161*ef270ab1SKenneth D. Merry 	uint32_t	rx_id:16,
162*ef270ab1SKenneth D. Merry 			ox_id:16;
163*ef270ab1SKenneth D. Merry 	uint32_t	parameter;
164*ef270ab1SKenneth D. Merry #else
165*ef270ab1SKenneth D. Merry #error big endian version not defined
166*ef270ab1SKenneth D. Merry #endif
167*ef270ab1SKenneth D. Merry } fc_header_le_t;
168*ef270ab1SKenneth D. Merry 
169*ef270ab1SKenneth D. Merry /**
170*ef270ab1SKenneth D. Merry  * @brief FC VM header in big-endian order
171*ef270ab1SKenneth D. Merry  */
172*ef270ab1SKenneth D. Merry typedef struct fc_vm_header_s {
173*ef270ab1SKenneth D. Merry 	uint32_t	dst_vmid;
174*ef270ab1SKenneth D. Merry 	uint32_t	src_vmid;
175*ef270ab1SKenneth D. Merry 	uint32_t	rsvd0;
176*ef270ab1SKenneth D. Merry 	uint32_t	rsvd1;
177*ef270ab1SKenneth D. Merry } fc_vm_header_t;
178*ef270ab1SKenneth D. Merry 
179*ef270ab1SKenneth D. Merry #define FC_DFCTL_DEVICE_HDR_16_MASK	0x1
180*ef270ab1SKenneth D. Merry #define FC_DFCTL_NETWORK_HDR_MASK	0x20
181*ef270ab1SKenneth D. Merry #define FC_DFCTL_ESP_HDR_MASK		0x40
182*ef270ab1SKenneth D. Merry #define FC_DFCTL_NETWORK_HDR_SIZE	16
183*ef270ab1SKenneth D. Merry #define FC_DFCTL_ESP_HDR_SIZE		0 //FIXME
184*ef270ab1SKenneth D. Merry 
185*ef270ab1SKenneth D. Merry #define FC_RCTL_FC4_DATA	0
186*ef270ab1SKenneth D. Merry #define FC_RCTL_ELS		2
187*ef270ab1SKenneth D. Merry #define FC_RCTL_BLS		8
188*ef270ab1SKenneth D. Merry 
189*ef270ab1SKenneth D. Merry #define FC_RCTL_INFO_UNCAT	0
190*ef270ab1SKenneth D. Merry #define FC_RCTL_INFO_SOL_DATA	1
191*ef270ab1SKenneth D. Merry #define FC_RCTL_INFO_UNSOL_CTRL	2
192*ef270ab1SKenneth D. Merry #define FC_RCTL_INFO_SOL_CTRL	3
193*ef270ab1SKenneth D. Merry #define FC_RCTL_INFO_UNSOL_DATA	4
194*ef270ab1SKenneth D. Merry #define FC_RCTL_INFO_DATA_DESC	5
195*ef270ab1SKenneth D. Merry #define FC_RCTL_INFO_UNSOL_CMD	6
196*ef270ab1SKenneth D. Merry #define FC_RCTL_INFO_CMD_STATUS	7
197*ef270ab1SKenneth D. Merry 
198*ef270ab1SKenneth D. Merry #define FC_FCTL_EXCHANGE_RESPONDER	0x800000
199*ef270ab1SKenneth D. Merry #define FC_FCTL_SEQUENCE_CONTEXT	0x400000
200*ef270ab1SKenneth D. Merry #define FC_FCTL_FIRST_SEQUENCE		0x200000
201*ef270ab1SKenneth D. Merry #define FC_FCTL_LAST_SEQUENCE		0x100000
202*ef270ab1SKenneth D. Merry #define FC_FCTL_END_SEQUENCE		0x080000
203*ef270ab1SKenneth D. Merry #define FC_FCTL_END_CONNECTION		0x040000
204*ef270ab1SKenneth D. Merry #define FC_FCTL_PRIORITY_ENABLE		0x020000
205*ef270ab1SKenneth D. Merry #define FC_FCTL_SEQUENCE_INITIATIVE	0x010000
206*ef270ab1SKenneth D. Merry #define FC_FCTL_FILL_DATA_BYTES_MASK	0x000003
207*ef270ab1SKenneth D. Merry 
208*ef270ab1SKenneth D. Merry /**
209*ef270ab1SKenneth D. Merry  * Common BLS definitions:
210*ef270ab1SKenneth D. Merry  */
211*ef270ab1SKenneth D. Merry #define FC_INFO_NOP			0x0
212*ef270ab1SKenneth D. Merry #define FC_INFO_ABTS			0x1
213*ef270ab1SKenneth D. Merry #define FC_INFO_RMC			0x2
214*ef270ab1SKenneth D. Merry /* reserved				0x3 */
215*ef270ab1SKenneth D. Merry #define FC_INFO_BA_ACC			0x4
216*ef270ab1SKenneth D. Merry #define FC_INFO_BA_RJT			0x5
217*ef270ab1SKenneth D. Merry #define FC_INFO_PRMT			0x6
218*ef270ab1SKenneth D. Merry 
219*ef270ab1SKenneth D. Merry /* (FC-LS) LS_RJT Reason Codes */
220*ef270ab1SKenneth D. Merry #define FC_REASON_INVALID_COMMAND_CODE		0x01
221*ef270ab1SKenneth D. Merry #define FC_REASON_LOGICAL_ERROR			0x03
222*ef270ab1SKenneth D. Merry #define FC_REASON_LOGICAL_BUSY			0x05
223*ef270ab1SKenneth D. Merry #define FC_REASON_PROTOCOL_ERROR		0x07
224*ef270ab1SKenneth D. Merry #define FC_REASON_UNABLE_TO_PERFORM		0x09
225*ef270ab1SKenneth D. Merry #define FC_REASON_COMMAND_NOT_SUPPORTED		0x0b
226*ef270ab1SKenneth D. Merry #define FC_REASON_COMMAND_IN_PROGRESS   	0x0e
227*ef270ab1SKenneth D. Merry #define FC_REASON_VENDOR_SPECIFIC		0xff
228*ef270ab1SKenneth D. Merry 
229*ef270ab1SKenneth D. Merry /* (FC-LS) LS_RJT Reason Codes Explanations */
230*ef270ab1SKenneth D. Merry #define FC_EXPL_NO_ADDITIONAL			0x00
231*ef270ab1SKenneth D. Merry #define FC_EXPL_SPARAM_OPTIONS			0x01
232*ef270ab1SKenneth D. Merry #define FC_EXPL_SPARAM_INITIATOR		0x03
233*ef270ab1SKenneth D. Merry #define FC_EXPL_SPARAM_RECPIENT			0x05
234*ef270ab1SKenneth D. Merry #define FC_EXPL_SPARM_DATA_SIZE			0x07
235*ef270ab1SKenneth D. Merry #define FC_EXPL_SPARM_CONCURRENT		0x09
236*ef270ab1SKenneth D. Merry #define FC_EXPL_SPARM_CREDIT			0x0b
237*ef270ab1SKenneth D. Merry #define FC_EXPL_INV_PORT_NAME 			0x0d
238*ef270ab1SKenneth D. Merry #define FC_EXPL_INV_NODE_NAME 			0x0e
239*ef270ab1SKenneth D. Merry #define FC_EXPL_INV_COMMON_SPARAMS 		0x0f
240*ef270ab1SKenneth D. Merry #define FC_EXPL_INV_ASSOC_HEADER		0x11
241*ef270ab1SKenneth D. Merry #define FC_EXPL_ASSOC_HDR_REQUIRED		0x13
242*ef270ab1SKenneth D. Merry #define FC_EXPL_INV_ORIGINATOR_S_ID		0x15
243*ef270ab1SKenneth D. Merry #define FC_EXPL_INV_X_ID_COMBINATION		0x17
244*ef270ab1SKenneth D. Merry #define FC_EXPL_COMMAND_IN_PROGRESS		0x19
245*ef270ab1SKenneth D. Merry #define FC_EXPL_NPORT_LOGIN_REQUIRED		0x1e
246*ef270ab1SKenneth D. Merry #define FC_EXPL_N_PORT_ID			0x1f
247*ef270ab1SKenneth D. Merry #define FC_EXPL_INSUFFICIENT_RESOURCES		0x29
248*ef270ab1SKenneth D. Merry #define FC_EXPL_UNABLE_TO_SUPPLY_DATA		0x2a
249*ef270ab1SKenneth D. Merry #define FC_EXPL_REQUEST_NOT_SUPPORTED		0x2c
250*ef270ab1SKenneth D. Merry #define FC_EXPL_INV_PAYLOAD_LEN			0x1d
251*ef270ab1SKenneth D. Merry #define FC_EXPL_INV_PORT_NODE_NAME		0x44
252*ef270ab1SKenneth D. Merry #define FC_EXPL_LOGIN_EXT_NOT_SUPPORTED		0x46
253*ef270ab1SKenneth D. Merry #define FC_EXPL_AUTH_REQUIRED			0x48
254*ef270ab1SKenneth D. Merry #define FC_EXPL_SCAN_VALUE_NOT_ALLOWED		0x50
255*ef270ab1SKenneth D. Merry #define FC_EXPL_SCAN_VALUE_NOT_SUPPORTED 	0x51
256*ef270ab1SKenneth D. Merry #define FC_EXPL_NO_RESOURCES_ASSIGNED		0x52
257*ef270ab1SKenneth D. Merry #define FC_EXPL_MAC_ADDR_MODE_NOT_SUPPORTED	0x60
258*ef270ab1SKenneth D. Merry #define FC_EXPL_MAC_ADDR_INCORRECTLY_FORMED	0x61
259*ef270ab1SKenneth D. Merry #define FC_EXPL_VN2VN_PORT_NOT_IN_NEIGHBOR_SET	0x62
260*ef270ab1SKenneth D. Merry 
261*ef270ab1SKenneth D. Merry #define FC_EXPL_INV_X_ID			0x03	/* invalid OX_ID - RX_ID combination */
262*ef270ab1SKenneth D. Merry #define FC_EXPL_SEQUENCE_ABORTED		0x05
263*ef270ab1SKenneth D. Merry 
264*ef270ab1SKenneth D. Merry typedef struct fc_ba_acc_payload_s {
265*ef270ab1SKenneth D. Merry #define FC_SEQ_ID_VALID			0x80
266*ef270ab1SKenneth D. Merry #define FC_SEQ_ID_INVALID		0x00
267*ef270ab1SKenneth D. Merry 	uint32_t	seq_id_validity:8,
268*ef270ab1SKenneth D. Merry 			seq_id:8,
269*ef270ab1SKenneth D. Merry 			:16;
270*ef270ab1SKenneth D. Merry 	uint32_t	ox_id:16,
271*ef270ab1SKenneth D. Merry 			rx_id:16;
272*ef270ab1SKenneth D. Merry 	uint32_t	low_seq_cnt:16,
273*ef270ab1SKenneth D. Merry 			high_seq_cnt:16;
274*ef270ab1SKenneth D. Merry } fc_ba_acc_payload_t;
275*ef270ab1SKenneth D. Merry 
276*ef270ab1SKenneth D. Merry typedef struct fc_ba_rjt_payload_s {
277*ef270ab1SKenneth D. Merry 	uint32_t	vendor_unique:8,
278*ef270ab1SKenneth D. Merry 			reason_explanation:8,
279*ef270ab1SKenneth D. Merry 			reason_code:8,
280*ef270ab1SKenneth D. Merry 			:8;
281*ef270ab1SKenneth D. Merry } fc_ba_rjt_payload_t;
282*ef270ab1SKenneth D. Merry 
283*ef270ab1SKenneth D. Merry typedef struct fc_els_gen_s {
284*ef270ab1SKenneth D. Merry 	uint32_t	command_code: 8,
285*ef270ab1SKenneth D. Merry 			resv1: 24;
286*ef270ab1SKenneth D. Merry } fc_els_gen_t;
287*ef270ab1SKenneth D. Merry 
288*ef270ab1SKenneth D. Merry typedef struct fc_plogi_playload_s {
289*ef270ab1SKenneth D. Merry 	uint32_t	command_code: 8,
290*ef270ab1SKenneth D. Merry 			resv1: 24;
291*ef270ab1SKenneth D. Merry 	uint32_t	common_service_parameters[4];
292*ef270ab1SKenneth D. Merry 	uint32_t	port_name_hi;
293*ef270ab1SKenneth D. Merry 	uint32_t	port_name_lo;
294*ef270ab1SKenneth D. Merry 	uint32_t	node_name_hi;
295*ef270ab1SKenneth D. Merry 	uint32_t	node_name_lo;
296*ef270ab1SKenneth D. Merry 	uint32_t	class1_service_parameters[4];
297*ef270ab1SKenneth D. Merry 	uint32_t	class2_service_parameters[4];
298*ef270ab1SKenneth D. Merry 	uint32_t	class3_service_parameters[4];
299*ef270ab1SKenneth D. Merry 	uint32_t	class4_service_parameters[4];
300*ef270ab1SKenneth D. Merry 	uint32_t	vendor_version_level[4];
301*ef270ab1SKenneth D. Merry } fc_plogi_payload_t;
302*ef270ab1SKenneth D. Merry 
303*ef270ab1SKenneth D. Merry typedef fc_plogi_payload_t fc_sparms_t;
304*ef270ab1SKenneth D. Merry 
305*ef270ab1SKenneth D. Merry typedef struct fc_logo_payload_s {
306*ef270ab1SKenneth D. Merry 	uint32_t	command_code: 8,
307*ef270ab1SKenneth D. Merry 			resv1:24;
308*ef270ab1SKenneth D. Merry 	uint32_t	:8,
309*ef270ab1SKenneth D. Merry 			port_id:24;
310*ef270ab1SKenneth D. Merry 	uint32_t	port_name_hi;
311*ef270ab1SKenneth D. Merry 	uint32_t	port_name_lo;
312*ef270ab1SKenneth D. Merry } fc_logo_payload_t;
313*ef270ab1SKenneth D. Merry 
314*ef270ab1SKenneth D. Merry typedef struct fc_acc_payload_s {
315*ef270ab1SKenneth D. Merry 	uint32_t	command_code: 8,
316*ef270ab1SKenneth D. Merry 			resv1:24;
317*ef270ab1SKenneth D. Merry } fc_acc_payload_t;
318*ef270ab1SKenneth D. Merry 
319*ef270ab1SKenneth D. Merry typedef struct fc_ls_rjt_payload_s {
320*ef270ab1SKenneth D. Merry 	uint32_t	command_code:8,
321*ef270ab1SKenneth D. Merry 			resv1:24;
322*ef270ab1SKenneth D. Merry 	uint32_t	resv2:8,
323*ef270ab1SKenneth D. Merry 			reason_code:8,
324*ef270ab1SKenneth D. Merry 			reason_code_exp:8,
325*ef270ab1SKenneth D. Merry 			vendor_unique:8;
326*ef270ab1SKenneth D. Merry } fc_ls_rjt_payload_t;
327*ef270ab1SKenneth D. Merry 
328*ef270ab1SKenneth D. Merry typedef struct fc_prli_payload_s {
329*ef270ab1SKenneth D. Merry 	uint32_t	command_code:8,
330*ef270ab1SKenneth D. Merry 			page_length:8,
331*ef270ab1SKenneth D. Merry 			payload_length:16;
332*ef270ab1SKenneth D. Merry 	uint32_t	type:8,
333*ef270ab1SKenneth D. Merry 			type_ext:8,
334*ef270ab1SKenneth D. Merry 			flags:16;
335*ef270ab1SKenneth D. Merry 	uint32_t	originator_pa;
336*ef270ab1SKenneth D. Merry 	uint32_t	responder_pa;
337*ef270ab1SKenneth D. Merry 	uint32_t	:16,
338*ef270ab1SKenneth D. Merry 			service_params:16;
339*ef270ab1SKenneth D. Merry } fc_prli_payload_t;
340*ef270ab1SKenneth D. Merry 
341*ef270ab1SKenneth D. Merry typedef struct fc_prlo_payload_s {
342*ef270ab1SKenneth D. Merry 	uint32_t	command_code:8,
343*ef270ab1SKenneth D. Merry 			page_length:8,
344*ef270ab1SKenneth D. Merry 			payload_length:16;
345*ef270ab1SKenneth D. Merry 	uint32_t	type:8,
346*ef270ab1SKenneth D. Merry 			type_ext:8,
347*ef270ab1SKenneth D. Merry 			:16;
348*ef270ab1SKenneth D. Merry 	uint32_t	:32;
349*ef270ab1SKenneth D. Merry 	uint32_t	:32;
350*ef270ab1SKenneth D. Merry 	uint32_t	:32;
351*ef270ab1SKenneth D. Merry } fc_prlo_payload_t;
352*ef270ab1SKenneth D. Merry 
353*ef270ab1SKenneth D. Merry typedef struct fc_prlo_acc_payload_s {
354*ef270ab1SKenneth D. Merry 	uint32_t	command_code:8,
355*ef270ab1SKenneth D. Merry 			page_length:8,
356*ef270ab1SKenneth D. Merry 			payload_length:16;
357*ef270ab1SKenneth D. Merry 	uint32_t	type:8,
358*ef270ab1SKenneth D. Merry 			type_ext:8,
359*ef270ab1SKenneth D. Merry 			:4,
360*ef270ab1SKenneth D. Merry 			response_code:4,
361*ef270ab1SKenneth D. Merry 			:8;
362*ef270ab1SKenneth D. Merry 	uint32_t	:32;
363*ef270ab1SKenneth D. Merry 	uint32_t	:32;
364*ef270ab1SKenneth D. Merry 	uint32_t	:32;
365*ef270ab1SKenneth D. Merry } fc_prlo_acc_payload_t;
366*ef270ab1SKenneth D. Merry 
367*ef270ab1SKenneth D. Merry typedef struct fc_adisc_payload_s {
368*ef270ab1SKenneth D. Merry 	uint32_t	command_code:8,
369*ef270ab1SKenneth D. Merry 			payload_length:24;
370*ef270ab1SKenneth D. Merry 	uint32_t	:8,
371*ef270ab1SKenneth D. Merry 			hard_address:24;
372*ef270ab1SKenneth D. Merry 	uint32_t	port_name_hi;
373*ef270ab1SKenneth D. Merry 	uint32_t	port_name_lo;
374*ef270ab1SKenneth D. Merry 	uint32_t	node_name_hi;
375*ef270ab1SKenneth D. Merry 	uint32_t	node_name_lo;
376*ef270ab1SKenneth D. Merry 	uint32_t	:8,
377*ef270ab1SKenneth D. Merry 			port_id:24;
378*ef270ab1SKenneth D. Merry } fc_adisc_payload_t;
379*ef270ab1SKenneth D. Merry 
380*ef270ab1SKenneth D. Merry /* PRLI flags */
381*ef270ab1SKenneth D. Merry #define FC_PRLI_ORIGINATOR_PA_VALID	0x8000
382*ef270ab1SKenneth D. Merry #define FC_PRLI_RESPONDER_PA_VALID	0x4000
383*ef270ab1SKenneth D. Merry #define FC_PRLI_ESTABLISH_IMAGE_PAIR	0x2000
384*ef270ab1SKenneth D. Merry #define FC_PRLI_SERVICE_PARAM_INVALID	0x0800
385*ef270ab1SKenneth D. Merry #define FC_PRLI_REQUEST_EXECUTED	0x0100
386*ef270ab1SKenneth D. Merry 
387*ef270ab1SKenneth D. Merry /* PRLI Service Parameters */
388*ef270ab1SKenneth D. Merry #define FC_PRLI_REC_SUPPORT		0x0400
389*ef270ab1SKenneth D. Merry #define FC_PRLI_TASK_RETRY_ID_REQ	0x0200
390*ef270ab1SKenneth D. Merry #define FC_PRLI_RETRY			0x0100
391*ef270ab1SKenneth D. Merry #define FC_PRLI_CONFIRMED_COMPLETION	0x0080
392*ef270ab1SKenneth D. Merry #define FC_PRLI_DATA_OVERLAY		0x0040
393*ef270ab1SKenneth D. Merry #define FC_PRLI_INITIATOR_FUNCTION      0x0020
394*ef270ab1SKenneth D. Merry #define FC_PRLI_TARGET_FUNCTION         0x0010
395*ef270ab1SKenneth D. Merry #define FC_PRLI_READ_XRDY_DISABLED	0x0002
396*ef270ab1SKenneth D. Merry #define FC_PRLI_WRITE_XRDY_DISABLED	0x0001
397*ef270ab1SKenneth D. Merry 
398*ef270ab1SKenneth D. Merry /* PRLO Logout flags */
399*ef270ab1SKenneth D. Merry #define FC_PRLO_REQUEST_EXECUTED	0x0001
400*ef270ab1SKenneth D. Merry 
401*ef270ab1SKenneth D. Merry typedef struct fc_scr_payload_s {
402*ef270ab1SKenneth D. Merry 	uint32_t	command_code:8,
403*ef270ab1SKenneth D. Merry 			:24;
404*ef270ab1SKenneth D. Merry 	uint32_t	:24,
405*ef270ab1SKenneth D. Merry 			function:8;
406*ef270ab1SKenneth D. Merry } fc_scr_payload_t;
407*ef270ab1SKenneth D. Merry 
408*ef270ab1SKenneth D. Merry #define FC_SCR_REG_FABRIC		1
409*ef270ab1SKenneth D. Merry #define FC_SCR_REG_NPORT		2
410*ef270ab1SKenneth D. Merry #define FC_SCR_REG_FULL			3
411*ef270ab1SKenneth D. Merry 
412*ef270ab1SKenneth D. Merry typedef struct {
413*ef270ab1SKenneth D. Merry 	uint32_t :2,
414*ef270ab1SKenneth D. Merry 		rscn_event_qualifier:4,
415*ef270ab1SKenneth D. Merry 		address_format:2,
416*ef270ab1SKenneth D. Merry 		port_id:24;
417*ef270ab1SKenneth D. Merry } fc_rscn_affected_port_id_page_t;
418*ef270ab1SKenneth D. Merry 
419*ef270ab1SKenneth D. Merry typedef struct fc_rscn_payload_s {
420*ef270ab1SKenneth D. Merry 	uint32_t	command_code:8,
421*ef270ab1SKenneth D. Merry 			page_length:8,
422*ef270ab1SKenneth D. Merry 			payload_length:16;
423*ef270ab1SKenneth D. Merry 	fc_rscn_affected_port_id_page_t port_list[1];
424*ef270ab1SKenneth D. Merry } fc_rscn_payload_t;
425*ef270ab1SKenneth D. Merry 
426*ef270ab1SKenneth D. Merry typedef struct fcct_iu_header_s {
427*ef270ab1SKenneth D. Merry #if BYTE_ORDER == LITTLE_ENDIAN
428*ef270ab1SKenneth D. Merry 	uint32_t	revision:8,
429*ef270ab1SKenneth D. Merry 			in_id:24;
430*ef270ab1SKenneth D. Merry 	uint32_t	gs_type:8,
431*ef270ab1SKenneth D. Merry 			gs_subtype:8,
432*ef270ab1SKenneth D. Merry 			options:8,
433*ef270ab1SKenneth D. Merry 			resv1:8;
434*ef270ab1SKenneth D. Merry 	uint32_t	cmd_rsp_code:16,
435*ef270ab1SKenneth D. Merry 			max_residual_size:16;
436*ef270ab1SKenneth D. Merry 	uint32_t	fragment_id:8,
437*ef270ab1SKenneth D. Merry 			reason_code:8,
438*ef270ab1SKenneth D. Merry 			reason_code_explanation:8,
439*ef270ab1SKenneth D. Merry 			vendor_specific:8;
440*ef270ab1SKenneth D. Merry #else
441*ef270ab1SKenneth D. Merry #error big endian version not defined
442*ef270ab1SKenneth D. Merry #endif
443*ef270ab1SKenneth D. Merry } fcct_iu_header_t;
444*ef270ab1SKenneth D. Merry 
445*ef270ab1SKenneth D. Merry #define FCCT_REJECT_INVALID_COMMAND_CODE	1
446*ef270ab1SKenneth D. Merry #define FCCT_REJECT_INVALID_VERSION_LEVEL	2
447*ef270ab1SKenneth D. Merry #define FCCT_LOGICAL_ERROR			3
448*ef270ab1SKenneth D. Merry #define FCCT_INVALID_CT_IU_SIZE			4
449*ef270ab1SKenneth D. Merry #define FCCT_LOGICAL_BUSY			5
450*ef270ab1SKenneth D. Merry #define FCCT_PROTOCOL_ERROR			7
451*ef270ab1SKenneth D. Merry #define FCCT_UNABLE_TO_PERFORM			9
452*ef270ab1SKenneth D. Merry #define FCCT_COMMAND_NOT_SUPPORTED		0x0b
453*ef270ab1SKenneth D. Merry #define FCCT_FABRIC_PORT_NAME_NOT_REGISTERED	0x0c
454*ef270ab1SKenneth D. Merry #define FCCT_SERVER_NOT_AVAILABLE		0x0d
455*ef270ab1SKenneth D. Merry #define FCCT_SESSION_COULD_NOT_BE_ESTABLISHED	0x0e
456*ef270ab1SKenneth D. Merry #define FCCT_VENDOR_SPECIFIC_ERROR		0xff
457*ef270ab1SKenneth D. Merry 
458*ef270ab1SKenneth D. Merry #define FCCT_NO_ADDITIONAL_EXPLANATION		0
459*ef270ab1SKenneth D. Merry #define FCCT_AUTHORIZATION_EXCEPTION		0xf0
460*ef270ab1SKenneth D. Merry #define FCCT_AUTHENTICATION_EXCEPTION		0xf1
461*ef270ab1SKenneth D. Merry #define FCCT_DATA_BASE_FULL			0xf2
462*ef270ab1SKenneth D. Merry #define FCCT_DATA_BASE_EMPTY			0xf3
463*ef270ab1SKenneth D. Merry #define FCCT_PROCESSING_REQUEST			0xf4
464*ef270ab1SKenneth D. Merry #define FCCT_UNABLE_TO_VERIFY_CONNECTION	0xf5
465*ef270ab1SKenneth D. Merry #define FCCT_DEVICES_NOT_IN_COMMON_ZONE		0xf6
466*ef270ab1SKenneth D. Merry 
467*ef270ab1SKenneth D. Merry typedef struct {
468*ef270ab1SKenneth D. Merry 	fcct_iu_header_t hdr;
469*ef270ab1SKenneth D. Merry #if BYTE_ORDER == LITTLE_ENDIAN
470*ef270ab1SKenneth D. Merry 	uint32_t	port_id;
471*ef270ab1SKenneth D. Merry 	uint32_t	fc4_types;
472*ef270ab1SKenneth D. Merry #else
473*ef270ab1SKenneth D. Merry #error big endian version not defined
474*ef270ab1SKenneth D. Merry #endif
475*ef270ab1SKenneth D. Merry } fcgs_rft_id_t;
476*ef270ab1SKenneth D. Merry 
477*ef270ab1SKenneth D. Merry typedef struct {
478*ef270ab1SKenneth D. Merry 	fcct_iu_header_t hdr;
479*ef270ab1SKenneth D. Merry #if BYTE_ORDER == LITTLE_ENDIAN
480*ef270ab1SKenneth D. Merry 	uint32_t	port_id;
481*ef270ab1SKenneth D. Merry 	uint32_t	:16,
482*ef270ab1SKenneth D. Merry 			fc4_features:8,
483*ef270ab1SKenneth D. Merry 			type_code:8;
484*ef270ab1SKenneth D. Merry #else
485*ef270ab1SKenneth D. Merry #error big endian version not defined
486*ef270ab1SKenneth D. Merry #endif
487*ef270ab1SKenneth D. Merry } fcgs_rff_id_t;
488*ef270ab1SKenneth D. Merry 
489*ef270ab1SKenneth D. Merry #pragma pack(1)
490*ef270ab1SKenneth D. Merry typedef struct {
491*ef270ab1SKenneth D. Merry 	fcct_iu_header_t hdr;
492*ef270ab1SKenneth D. Merry #if BYTE_ORDER == LITTLE_ENDIAN
493*ef270ab1SKenneth D. Merry 	uint32_t	port_id;
494*ef270ab1SKenneth D. Merry 	uint64_t	port_name;
495*ef270ab1SKenneth D. Merry #else
496*ef270ab1SKenneth D. Merry #error big endian version not defined
497*ef270ab1SKenneth D. Merry #endif
498*ef270ab1SKenneth D. Merry } fcgs_rpn_id_t;
499*ef270ab1SKenneth D. Merry #pragma pack()
500*ef270ab1SKenneth D. Merry 
501*ef270ab1SKenneth D. Merry #pragma pack(1)
502*ef270ab1SKenneth D. Merry typedef struct {
503*ef270ab1SKenneth D. Merry 	fcct_iu_header_t hdr;
504*ef270ab1SKenneth D. Merry #if BYTE_ORDER == LITTLE_ENDIAN
505*ef270ab1SKenneth D. Merry 	uint32_t	port_id;
506*ef270ab1SKenneth D. Merry 	uint64_t	node_name;
507*ef270ab1SKenneth D. Merry #else
508*ef270ab1SKenneth D. Merry #error big endian version not defined
509*ef270ab1SKenneth D. Merry #endif
510*ef270ab1SKenneth D. Merry } fcgs_rnn_id_t;
511*ef270ab1SKenneth D. Merry #pragma pack()
512*ef270ab1SKenneth D. Merry 
513*ef270ab1SKenneth D. Merry #define FCCT_CLASS_OF_SERVICE_F	0x1
514*ef270ab1SKenneth D. Merry #define FCCT_CLASS_OF_SERVICE_2	0x4
515*ef270ab1SKenneth D. Merry #define FCCT_CLASS_OF_SERVICE_3	0x8
516*ef270ab1SKenneth D. Merry #pragma pack(1)
517*ef270ab1SKenneth D. Merry typedef struct {
518*ef270ab1SKenneth D. Merry 	fcct_iu_header_t hdr;
519*ef270ab1SKenneth D. Merry #if BYTE_ORDER == LITTLE_ENDIAN
520*ef270ab1SKenneth D. Merry 	uint32_t	port_id;
521*ef270ab1SKenneth D. Merry 	uint32_t	class_of_srvc;
522*ef270ab1SKenneth D. Merry #else
523*ef270ab1SKenneth D. Merry #error big endian version not defined
524*ef270ab1SKenneth D. Merry #endif
525*ef270ab1SKenneth D. Merry } fcgs_rcs_id_t;
526*ef270ab1SKenneth D. Merry #pragma pack()
527*ef270ab1SKenneth D. Merry 
528*ef270ab1SKenneth D. Merry #pragma pack(1)
529*ef270ab1SKenneth D. Merry typedef struct {
530*ef270ab1SKenneth D. Merry 	fcct_iu_header_t hdr;
531*ef270ab1SKenneth D. Merry #if BYTE_ORDER == LITTLE_ENDIAN
532*ef270ab1SKenneth D. Merry 	uint64_t	node_name;
533*ef270ab1SKenneth D. Merry 	uint8_t		name_len;
534*ef270ab1SKenneth D. Merry 	char		sym_node_name[1];
535*ef270ab1SKenneth D. Merry /*TODO: need name length and symbolic name */
536*ef270ab1SKenneth D. Merry #else
537*ef270ab1SKenneth D. Merry #error big endian version not defined
538*ef270ab1SKenneth D. Merry #endif
539*ef270ab1SKenneth D. Merry } fcgs_rsnn_nn_t;
540*ef270ab1SKenneth D. Merry #pragma pack()
541*ef270ab1SKenneth D. Merry 
542*ef270ab1SKenneth D. Merry #define FCCT_HDR_CMDRSP_ACCEPT	0x8002
543*ef270ab1SKenneth D. Merry #define FCCT_HDR_CMDRSP_REJECT	0x8001
544*ef270ab1SKenneth D. Merry 
fcct_build_req_header(fcct_iu_header_t * hdr,uint16_t cmd,uint16_t max_size)545*ef270ab1SKenneth D. Merry static inline void fcct_build_req_header(fcct_iu_header_t *hdr, uint16_t cmd, uint16_t max_size)
546*ef270ab1SKenneth D. Merry {
547*ef270ab1SKenneth D. Merry 	/* use old rev (1) to accommodate older switches */
548*ef270ab1SKenneth D. Merry 	hdr->revision = 1;
549*ef270ab1SKenneth D. Merry 	hdr->in_id = 0;
550*ef270ab1SKenneth D. Merry 	hdr->gs_type = FC_GS_TYPE_DIRECTORY_SERVICE;
551*ef270ab1SKenneth D. Merry 	hdr->gs_subtype = FC_GS_SUBTYPE_NAME_SERVER;
552*ef270ab1SKenneth D. Merry 	hdr->options = 0;
553*ef270ab1SKenneth D. Merry 	hdr->resv1 = 0;
554*ef270ab1SKenneth D. Merry 	hdr->cmd_rsp_code = ocs_htobe16(cmd);
555*ef270ab1SKenneth D. Merry 	hdr->max_residual_size = ocs_htobe16(max_size/(sizeof(uint32_t))); /* words */
556*ef270ab1SKenneth D. Merry 	hdr->fragment_id = 0;
557*ef270ab1SKenneth D. Merry 	hdr->reason_code = 0;
558*ef270ab1SKenneth D. Merry 	hdr->reason_code_explanation = 0;
559*ef270ab1SKenneth D. Merry 	hdr->vendor_specific = 0;
560*ef270ab1SKenneth D. Merry }
561*ef270ab1SKenneth D. Merry 
562*ef270ab1SKenneth D. Merry typedef struct fcct_rftid_req_s {
563*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
564*ef270ab1SKenneth D. Merry 	uint32_t		port_id;
565*ef270ab1SKenneth D. Merry 	uint32_t		fc4_types[8];
566*ef270ab1SKenneth D. Merry } fcct_rftid_req_t;
567*ef270ab1SKenneth D. Merry 
568*ef270ab1SKenneth D. Merry #define FC4_FEATURE_TARGET	(1U << 0)
569*ef270ab1SKenneth D. Merry #define FC4_FEATURE_INITIATOR	(1U << 1)
570*ef270ab1SKenneth D. Merry 
571*ef270ab1SKenneth D. Merry typedef struct fcct_rffid_req_s {
572*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
573*ef270ab1SKenneth D. Merry 	uint32_t		port_id;
574*ef270ab1SKenneth D. Merry 	uint32_t		:16,
575*ef270ab1SKenneth D. Merry 				fc4_feature_bits:8,
576*ef270ab1SKenneth D. Merry 				type:8;
577*ef270ab1SKenneth D. Merry } fcct_rffid_req_t;
578*ef270ab1SKenneth D. Merry 
579*ef270ab1SKenneth D. Merry typedef struct fcct_gnnid_req_s {
580*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
581*ef270ab1SKenneth D. Merry 	uint32_t		:8,
582*ef270ab1SKenneth D. Merry 				port_id:24;
583*ef270ab1SKenneth D. Merry } fcct_gnnid_req_t;
584*ef270ab1SKenneth D. Merry 
585*ef270ab1SKenneth D. Merry typedef struct fcct_gpnid_req_s {
586*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
587*ef270ab1SKenneth D. Merry 	uint32_t		:8,
588*ef270ab1SKenneth D. Merry 				port_id:24;
589*ef270ab1SKenneth D. Merry } fcct_gpnid_req_t;
590*ef270ab1SKenneth D. Merry 
591*ef270ab1SKenneth D. Merry typedef struct fcct_gffid_req_s {
592*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
593*ef270ab1SKenneth D. Merry 	uint32_t		:8,
594*ef270ab1SKenneth D. Merry 				port_id:24;
595*ef270ab1SKenneth D. Merry } fcct_gffid_req_t;
596*ef270ab1SKenneth D. Merry 
597*ef270ab1SKenneth D. Merry typedef struct fcct_gidft_req_s {
598*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
599*ef270ab1SKenneth D. Merry 	uint32_t		:8,
600*ef270ab1SKenneth D. Merry 				domain_id_scope:8,
601*ef270ab1SKenneth D. Merry 				area_id_scope:8,
602*ef270ab1SKenneth D. Merry 				type:8;
603*ef270ab1SKenneth D. Merry } fcct_gidft_req_t;
604*ef270ab1SKenneth D. Merry 
605*ef270ab1SKenneth D. Merry typedef struct fcct_gidpt_req_s {
606*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
607*ef270ab1SKenneth D. Merry 	uint32_t		port_type:8,
608*ef270ab1SKenneth D. Merry 				domain_id_scope:8,
609*ef270ab1SKenneth D. Merry 				area_id_scope:8,
610*ef270ab1SKenneth D. Merry 				flags:8;
611*ef270ab1SKenneth D. Merry } fcct_gidpt_req_t;
612*ef270ab1SKenneth D. Merry 
613*ef270ab1SKenneth D. Merry typedef struct fcct_gnnid_acc_s {
614*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
615*ef270ab1SKenneth D. Merry 	uint64_t		node_name;
616*ef270ab1SKenneth D. Merry } fcct_gnnid_acc_t;
617*ef270ab1SKenneth D. Merry 
618*ef270ab1SKenneth D. Merry typedef struct fcct_gpnid_acc_s {
619*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
620*ef270ab1SKenneth D. Merry 	uint64_t		port_name;
621*ef270ab1SKenneth D. Merry } fcct_gpnid_acc_t;
622*ef270ab1SKenneth D. Merry 
623*ef270ab1SKenneth D. Merry typedef struct fcct_gffid_acc_s {
624*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
625*ef270ab1SKenneth D. Merry 	uint8_t			fc4_feature_bits;
626*ef270ab1SKenneth D. Merry } fcct_gffid_acc_t;
627*ef270ab1SKenneth D. Merry 
628*ef270ab1SKenneth D. Merry typedef struct fcct_gidft_acc_s {
629*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
630*ef270ab1SKenneth D. Merry 	struct {
631*ef270ab1SKenneth D. Merry 		uint32_t	ctl:8,
632*ef270ab1SKenneth D. Merry 				port_id:24;
633*ef270ab1SKenneth D. Merry 	} port_list[1];
634*ef270ab1SKenneth D. Merry } fcct_gidft_acc_t;
635*ef270ab1SKenneth D. Merry 
636*ef270ab1SKenneth D. Merry typedef struct fcct_gidpt_acc_s {
637*ef270ab1SKenneth D. Merry 	fcct_iu_header_t	hdr;
638*ef270ab1SKenneth D. Merry 	struct {
639*ef270ab1SKenneth D. Merry 		uint32_t	ctl:8,
640*ef270ab1SKenneth D. Merry 				port_id:24;
641*ef270ab1SKenneth D. Merry 	} port_list[1];
642*ef270ab1SKenneth D. Merry } fcct_gidpt_acc_t;
643*ef270ab1SKenneth D. Merry 
644*ef270ab1SKenneth D. Merry #define FCCT_GID_PT_LAST_ID	0x80
645*ef270ab1SKenneth D. Merry #define FCCT_GIDPT_ID_MASK	0x00ffffff
646*ef270ab1SKenneth D. Merry 
647*ef270ab1SKenneth D. Merry typedef struct fcp_cmnd_iu_s {
648*ef270ab1SKenneth D. Merry 	uint8_t		fcp_lun[8];
649*ef270ab1SKenneth D. Merry 	uint8_t		command_reference_number;
650*ef270ab1SKenneth D. Merry 	uint8_t		task_attribute:3,
651*ef270ab1SKenneth D. Merry 			command_priority:4,
652*ef270ab1SKenneth D. Merry 			:1;
653*ef270ab1SKenneth D. Merry 	uint8_t		task_management_flags;
654*ef270ab1SKenneth D. Merry 	uint8_t		wrdata:1,
655*ef270ab1SKenneth D. Merry 			rddata:1,
656*ef270ab1SKenneth D. Merry 			additional_fcp_cdb_length:6;
657*ef270ab1SKenneth D. Merry 	uint8_t		fcp_cdb[16];
658*ef270ab1SKenneth D. Merry 	uint8_t		fcp_cdb_and_dl[20];	/* < May contain up to 16 bytes of CDB, followed by fcp_dl */
659*ef270ab1SKenneth D. Merry } fcp_cmnd_iu_t;
660*ef270ab1SKenneth D. Merry 
661*ef270ab1SKenneth D. Merry #define FCP_LUN_ADDRESS_METHOD_SHIFT	6
662*ef270ab1SKenneth D. Merry #define FCP_LUN_ADDRESS_METHOD_MASK	0xc0
663*ef270ab1SKenneth D. Merry #define FCP_LUN_ADDR_METHOD_PERIPHERAL	0x0
664*ef270ab1SKenneth D. Merry #define FCP_LUN_ADDR_METHOD_FLAT	0x1
665*ef270ab1SKenneth D. Merry #define FCP_LUN_ADDR_METHOD_LOGICAL	0x2
666*ef270ab1SKenneth D. Merry #define FCP_LUN_ADDR_METHOD_EXTENDED	0x3
667*ef270ab1SKenneth D. Merry 
668*ef270ab1SKenneth D. Merry #define FCP_LUN_ADDR_SIMPLE_MAX		0xff
669*ef270ab1SKenneth D. Merry #define FCP_LUN_ADDR_FLAT_MAX		0x3fff
670*ef270ab1SKenneth D. Merry 
671*ef270ab1SKenneth D. Merry #define FCP_TASK_ATTR_SIMPLE		0x0
672*ef270ab1SKenneth D. Merry #define FCP_TASK_ATTR_HEAD_OF_QUEUE	0x1
673*ef270ab1SKenneth D. Merry #define FCP_TASK_ATTR_ORDERED		0x2
674*ef270ab1SKenneth D. Merry #define FCP_TASK_ATTR_ACA		0x4
675*ef270ab1SKenneth D. Merry #define FCP_TASK_ATTR_UNTAGGED          0x5
676*ef270ab1SKenneth D. Merry 
677*ef270ab1SKenneth D. Merry #define FCP_QUERY_TASK_SET		BIT(0)
678*ef270ab1SKenneth D. Merry #define FCP_ABORT_TASK_SET		BIT(1)
679*ef270ab1SKenneth D. Merry #define FCP_CLEAR_TASK_SET		BIT(2)
680*ef270ab1SKenneth D. Merry #define FCP_QUERY_ASYNCHRONOUS_EVENT	BIT(3)
681*ef270ab1SKenneth D. Merry #define FCP_LOGICAL_UNIT_RESET		BIT(4)
682*ef270ab1SKenneth D. Merry #define FCP_TARGET_RESET		BIT(5)
683*ef270ab1SKenneth D. Merry #define FCP_CLEAR_ACA			BIT(6)
684*ef270ab1SKenneth D. Merry 
685*ef270ab1SKenneth D. Merry /* SPC-4 says that the maximum length of sense data is 252 bytes */
686*ef270ab1SKenneth D. Merry #define FCP_MAX_SENSE_LEN		252
687*ef270ab1SKenneth D. Merry #define FCP_MAX_RSP_LEN			  8
688*ef270ab1SKenneth D. Merry /*
689*ef270ab1SKenneth D. Merry  * FCP_RSP buffer will either have sense or response data, but not both
690*ef270ab1SKenneth D. Merry  * so pick the larger.
691*ef270ab1SKenneth D. Merry  */
692*ef270ab1SKenneth D. Merry #define FCP_MAX_RSP_INFO_LEN		FCP_MAX_SENSE_LEN
693*ef270ab1SKenneth D. Merry 
694*ef270ab1SKenneth D. Merry typedef struct fcp_rsp_iu_s {
695*ef270ab1SKenneth D. Merry 	uint8_t		rsvd[8];
696*ef270ab1SKenneth D. Merry 	uint8_t		status_qualifier[2];
697*ef270ab1SKenneth D. Merry 	uint8_t		flags;
698*ef270ab1SKenneth D. Merry 	uint8_t		scsi_status;
699*ef270ab1SKenneth D. Merry 	uint8_t		fcp_resid[4];
700*ef270ab1SKenneth D. Merry 	uint8_t		fcp_sns_len[4];
701*ef270ab1SKenneth D. Merry 	uint8_t		fcp_rsp_len[4];
702*ef270ab1SKenneth D. Merry 	uint8_t		data[FCP_MAX_RSP_INFO_LEN];
703*ef270ab1SKenneth D. Merry } fcp_rsp_iu_t;
704*ef270ab1SKenneth D. Merry 
705*ef270ab1SKenneth D. Merry /** Flag field defines: */
706*ef270ab1SKenneth D. Merry #define FCP_RSP_LEN_VALID		BIT(0)
707*ef270ab1SKenneth D. Merry #define FCP_SNS_LEN_VALID		BIT(1)
708*ef270ab1SKenneth D. Merry #define FCP_RESID_OVER			BIT(2)
709*ef270ab1SKenneth D. Merry #define FCP_RESID_UNDER			BIT(3)
710*ef270ab1SKenneth D. Merry #define FCP_CONF_REQ			BIT(4)
711*ef270ab1SKenneth D. Merry #define FCP_BIDI_READ_RESID_OVER	BIT(5)
712*ef270ab1SKenneth D. Merry #define FCP_BIDI_READ_RESID_UNDER	BIT(6)
713*ef270ab1SKenneth D. Merry #define FCP_BIDI_RSP			BIT(7)
714*ef270ab1SKenneth D. Merry 
715*ef270ab1SKenneth D. Merry /** Status values: */
716*ef270ab1SKenneth D. Merry #define FCP_TMF_COMPLETE		0x00
717*ef270ab1SKenneth D. Merry #define FCP_DATA_LENGTH_MISMATCH	0x01
718*ef270ab1SKenneth D. Merry #define FCP_INVALID_FIELD		0x02
719*ef270ab1SKenneth D. Merry #define FCP_DATA_RO_MISMATCH		0x03
720*ef270ab1SKenneth D. Merry #define FCP_TMF_REJECTED		0x04
721*ef270ab1SKenneth D. Merry #define FCP_TMF_FAILED			0x05
722*ef270ab1SKenneth D. Merry #define FCP_TMF_SUCCEEDED		0x08
723*ef270ab1SKenneth D. Merry #define FCP_TMF_INCORRECT_LUN		0x09
724*ef270ab1SKenneth D. Merry 
725*ef270ab1SKenneth D. Merry /** FCP-4 Table 28, TMF response information: */
726*ef270ab1SKenneth D. Merry typedef struct fc_rsp_info_s {
727*ef270ab1SKenneth D. Merry 	uint8_t addl_rsp_info[3];
728*ef270ab1SKenneth D. Merry 	uint8_t rsp_code;
729*ef270ab1SKenneth D. Merry 	uint32_t :32;
730*ef270ab1SKenneth D. Merry } fcp_rsp_info_t;
731*ef270ab1SKenneth D. Merry 
732*ef270ab1SKenneth D. Merry typedef struct fcp_xfer_rdy_iu_s {
733*ef270ab1SKenneth D. Merry 	uint8_t		fcp_data_ro[4];
734*ef270ab1SKenneth D. Merry 	uint8_t		fcp_burst_len[4];
735*ef270ab1SKenneth D. Merry 	uint8_t		rsvd[4];
736*ef270ab1SKenneth D. Merry } fcp_xfer_rdy_iu_t;
737*ef270ab1SKenneth D. Merry 
738*ef270ab1SKenneth D. Merry #define MAX_ACC_REJECT_PAYLOAD (sizeof(fc_ls_rjt_payload_t) > sizeof(fc_acc_payload_t) ? sizeof(fc_ls_rjt_payload_t) : sizeof(fc_acc_payload_t))
739*ef270ab1SKenneth D. Merry 
740*ef270ab1SKenneth D. Merry #endif /* !_OCS_FCP_H */
741