xref: /titanic_50/usr/src/uts/common/sys/fibre-channel/fc_appif.h (revision 45818ee124adeaaf947698996b4f4c722afc6d1f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_FC_APPIF_H
27 #define	_FC_APPIF_H
28 
29 #include <sys/note.h>
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
36 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
37 #endif	/* _BIT_FIELDS_LTOH */
38 
39 /*
40  * Local port topology definitions
41  *
42  * fp/fctl use these a lot with the fp_topology field in the fc_port_t struct,
43  * but use is not limited to fp_topology. These are also understood by ULPs.
44  */
45 #define	FC_TOP_UNKNOWN 		0
46 #define	FC_TOP_PRIVATE_LOOP	1
47 #define	FC_TOP_PUBLIC_LOOP	2
48 #define	FC_TOP_FABRIC		3
49 #define	FC_TOP_PT_PT		4
50 #define	FC_TOP_NO_NS		5
51 
52 /*
53  * Macros used with the preceeding topology #defines.
54  * fp/fctl use these a lot with the fp_topology field in the fc_port_t struct,
55  * but use is not limited to fp_topology. These are also understood by ULPs.
56  */
57 #define	FC_TOP_EXTERNAL(t)	FC_IS_TOP_SWITCH(t)
58 #define	FC_IS_TOP_SWITCH(t)	(((t) == FC_TOP_FABRIC) ||\
59 				((t) == FC_TOP_PUBLIC_LOOP))
60 
61 /*
62  * fc_remote_port state (map_state) definitions.
63  *
64  * Used with the pd_state field in the fc_remote_port_t struct.
65  */
66 #define	PORT_DEVICE_INVALID	0	/* State when created or login failed */
67 #define	PORT_DEVICE_VALID	1	/* Logged out */
68 #define	PORT_DEVICE_LOGGED_IN	2	/* Logged in */
69 
70 
71 /*
72  * Firmware, FCode revision field lengths
73  */
74 #define	FC_FCODE_REV_SIZE	25
75 #define	FC_FW_REV_SIZE		25
76 
77 typedef struct ct_header {
78 #if defined(_BIT_FIELDS_LTOH)
79 	uint32_t	ct_inid	: 24,		/* Initial Node ID */
80 			ct_rev	: 8;		/* Revision */
81 
82 	uint32_t	ct_reserved1 : 8,
83 			ct_options : 8,
84 			ct_fcssubtype : 8,
85 			ct_fcstype : 8;
86 
87 	uint32_t	ct_aiusize : 16,
88 			ct_cmdrsp : 16;
89 
90 	uint32_t	ct_vendor : 8,
91 			ct_expln : 8,
92 			ct_reason : 8,
93 			ct_reserved2 : 8;
94 
95 #else
96 	uint32_t	ct_rev : 8,		/* revision */
97 			ct_inid : 24;		/* initial node ID */
98 	uint32_t	ct_fcstype : 8,		/* type of service */
99 			ct_fcssubtype : 8,	/* subtype of service */
100 			ct_options : 8,		/* options */
101 			ct_reserved1 : 8;	/* reserved */
102 
103 	uint32_t	ct_cmdrsp : 16,		/* command/response code */
104 			ct_aiusize : 16;	/* AIU/residual size */
105 
106 	uint32_t	ct_reserved2 : 8,	/* reserved */
107 			ct_reason : 8,		/* reason code */
108 			ct_expln : 8,		/* reason explanation */
109 			ct_vendor : 8;		/* vendor unique */
110 
111 #endif	/* _BIT_FIELDS_LTOH */
112 } fc_ct_header_t;
113 
114 /* World Wide Name format */
115 typedef union la_wwn {
116 	uchar_t			raw_wwn[8];
117 	uint32_t		i_wwn[2];
118 
119 #if defined(_BIT_FIELDS_LTOH)
120 	struct {
121 		uint32_t	wwn_hi : 16,
122 				nport_id : 12,
123 				naa_id : 4;
124 		uint32_t	wwn_lo;
125 	}w;
126 
127 #else
128 	struct {
129 		uint32_t	naa_id : 4,
130 				nport_id : 12,
131 				wwn_hi : 16;
132 		uint32_t	wwn_lo;
133 	}w;
134 #endif	/* _BIT_FIELDS_LTOH */
135 } la_wwn_t;
136 
137 /*
138  * Values for naa_id
139  */
140 #define	NAA_ID_IEEE		1
141 #define	NAA_ID_IEEE_EXTENDED	2
142 
143 #ifndef	FC_WWN_SIZE
144 #define	FC_WWN_SIZE		(sizeof (la_wwn_t))
145 #endif /* FC_WWN_SIZE */
146 
147 typedef struct service_param {
148 	uint16_t	class_opt;
149 	uint16_t	initiator_ctl;
150 	uint16_t	recipient_ctl;
151 	uint16_t	rcv_size;
152 	uint16_t	conc_sequences;
153 	uint16_t	n_port_e_to_e_credit;
154 	uint16_t	open_seq_per_xchng;
155 	uint16_t	rsvd;
156 } svc_param_t;
157 
158 typedef struct common_service {
159 	uint16_t    fcph_version;
160 	uint16_t    btob_credit;
161 	uint16_t    cmn_features;
162 	uint16_t    rx_bufsize;
163 	uint16_t    conc_sequences;
164 	uint16_t    relative_offset;
165 	uint32_t    e_d_tov;
166 } com_svc_t;
167 
168 typedef struct ls_code {
169 #if defined(_BIT_FIELDS_LTOH)
170 	uint32_t	mbz : 24,
171 			ls_code : 8;
172 
173 #else
174 	uint32_t	ls_code : 8,
175 			mbz : 24;
176 #endif	/* _BIT_FIELDS_LTOH */
177 } ls_code_t;
178 
179 
180 /* Login Payload. */
181 typedef struct la_els_logi {
182 	ls_code_t	ls_code;
183 	com_svc_t	common_service;
184 
185 	la_wwn_t	nport_ww_name;
186 	la_wwn_t	node_ww_name;
187 
188 	svc_param_t	class_1;
189 	svc_param_t	class_2;
190 	svc_param_t	class_3;
191 
192 	uchar_t		reserved[16];
193 	uchar_t		vendor_version[16];
194 } la_els_logi_t;
195 
196 typedef struct fc_ns_cmd {
197 	uint32_t	ns_flags;		/* for future use */
198 	uint16_t	ns_cmd;			/* NS command type */
199 	uint16_t	ns_req_len;
200 	caddr_t		ns_req_payload;		/* No CT header */
201 	uint16_t	ns_resp_len;
202 	caddr_t		ns_resp_payload;	/* no CT header */
203 	void		*ns_fctl_private;	/* Transport private */
204 	fc_ct_header_t	ns_resp_hdr;		/* for the curious */
205 } fc_ns_cmd_t;
206 
207 #if defined(_SYSCALL32)
208 
209 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
210 #pragma pack(4)
211 #endif
212 
213 typedef struct la_els_logi32 {
214 	ls_code_t	ls_code;
215 	com_svc_t	common_service;
216 	la_wwn_t	nport_ww_name;
217 	la_wwn_t	node_ww_name;
218 	svc_param_t	class_1;
219 	svc_param_t	class_2;
220 	svc_param_t	class_3;
221 	uchar_t		reserved[16];
222 	uchar_t		vendor_version[16];
223 } la_els_logi32_t;
224 
225 typedef struct fc_ns_cmd32 {
226 	uint32_t	ns_flags;		/* for future use */
227 	uint16_t	ns_cmd;			/* NS command type */
228 	uint16_t	ns_req_len;
229 	caddr_t		ns_req_payload;		/* No CT header */
230 	uint16_t	ns_resp_len;
231 	caddr_t		ns_resp_payload;	/* no CT header */
232 	void		*ns_fctl_private;	/* Transport private */
233 	fc_ct_header_t	ns_resp_hdr;		/* for the curious */
234 } fc_ns_cmd32_t;
235 
236 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
237 #pragma pack()
238 #endif
239 
240 #endif	/* _SYSCALL32 */
241 
242 /* Link Error Parameters in the RLS Accept payload */
243 typedef struct fc_rls_acc_params {
244 	uint32_t	rls_link_fail;		/* link failure count */
245 	uint32_t	rls_sync_loss;		/* loss of sync count */
246 	uint32_t	rls_sig_loss;		/* loss of signal count */
247 	uint32_t	rls_prim_seq_err;	/* primitive seq error */
248 	uint32_t	rls_invalid_word;	/* invalid tx word */
249 	uint32_t	rls_invalid_crc;	/* invalid CRC count */
250 } fc_rls_acc_t;
251 
252 /* RLS Payload. */
253 typedef struct la_els_rls {
254 	ls_code_t	ls_code;
255 	fc_portid_t	rls_portid;		/* port identifier */
256 } la_els_rls_t;
257 
258 /* RLS accept payload */
259 typedef struct la_els_rls_acc {
260 	ls_code_t	ls_code;
261 	fc_rls_acc_t	rls_link_params;	/* link error status block */
262 } la_els_rls_acc_t;
263 
264 /* Node Id Parameters in the RNID Get/Set Accept/Request payload */
265 typedef struct fc_rnid_params {
266 	uchar_t		global_id[16];		/* global name */
267 	uint32_t	unit_type;		/* unit type */
268 	uint32_t	port_id;		/* port id */
269 	uint32_t	num_attached;		/* number of attached nodes */
270 	uint16_t	ip_version;		/* ip version */
271 	uint16_t	udp_port;		/* udp port number */
272 	uchar_t		ip_addr[16];		/* ip address */
273 	uint16_t	specific_id_resv;	/* reserved */
274 	uint16_t	topo_flags;		/* topology discovery flags */
275 } fc_rnid_t;
276 
277 /* RNID get data format flag */
278 #define	FCIO_CFLAGS_RNID_GET_GENERAL_TOPOLOGY	0xDF
279 #define	FCIO_CFLAGS_RNID_GET_VENDOR_SPECIFIC	0xE0
280 
281 /* RNID maximum data length - common data(16) + specific data(252) */
282 #define	FCIO_RNID_MAX_DATA_LEN	268
283 
284 /* RNID Payload. */
285 typedef struct la_els_rnid {
286 	ls_code_t	ls_code;
287 	uchar_t		data_format;		/* data format returned */
288 	uchar_t		resv[3];
289 } la_els_rnid_t;
290 
291 /*
292  * ELS RNID header
293  * - cmn_len can be 0 or 16 - if it is 0 then specific data starts at
294  *   offset 8 else specific data starts at offset 24 in the RNID els response
295  */
296 typedef struct fc_rnid_hdr {
297 	uchar_t		data_format;
298 	uchar_t		cmn_len;
299 	uchar_t		resv;
300 	uchar_t		specific_len;
301 }fc_rnid_hdr_t;
302 
303 typedef struct la_els_rnid_acc {
304 	ls_code_t	ls_code;
305 	fc_rnid_hdr_t  	hdr;
306 	uchar_t		data[FCIO_RNID_MAX_DATA_LEN];
307 } la_els_rnid_acc_t;
308 
309 typedef struct la_npiv_create_entry {
310 	la_wwn_t	VNodeWWN;
311 	la_wwn_t	VPortWWN;
312 	uint32_t	vindex;
313 } la_npiv_create_entry_t;
314 
315 #if	!defined(__lint)
316 _NOTE(SCHEME_PROTECTS_DATA("unique per request", fc_ns_cmd))
317 _NOTE(SCHEME_PROTECTS_DATA("unique per request", ct_header))
318 _NOTE(SCHEME_PROTECTS_DATA("unique per request", la_els_logi))
319 _NOTE(SCHEME_PROTECTS_DATA("unique per request", la_wwn))
320 _NOTE(SCHEME_PROTECTS_DATA("unique per request", fc_rls_acc_params))
321 _NOTE(SCHEME_PROTECTS_DATA("unique per request", la_els_rls))
322 _NOTE(SCHEME_PROTECTS_DATA("unique per request", la_els_rls_acc))
323 _NOTE(SCHEME_PROTECTS_DATA("unique per request", fc_rnid_params))
324 _NOTE(SCHEME_PROTECTS_DATA("unique per request", la_els_rnid))
325 _NOTE(SCHEME_PROTECTS_DATA("unique per request", la_els_rnid_acc))
326 #endif /* __lint */
327 
328 #ifdef	__cplusplus
329 }
330 #endif
331 
332 #endif	/* _FC_APPIF_H */
333