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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_FC4_FCAL_LINKAPP_H
28 #define	_SYS_FC4_FCAL_LINKAPP_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * linkapp.h
36  *
37  *	This file contains the definitions for structures and macros
38  *	for fiber channel link application payloads and data.
39  */
40 
41 /*
42  * Well Known Fiber Chaneel Addresses to reach the fabric for
43  * various services.
44  */
45 
46 #define	MAX_FCODE_SIZE		0x2000
47 #define	FS_GENERAL_MULTICAST	0xfffff7
48 #define	FS_WELL_KNOWN_MULTICAST	0xfffff8
49 #define	FS_HUNT_GROUP		0xfffff9
50 #define	FS_MANAGEMENT_SERVER	0xfffffa
51 #define	FS_TIME_SERVER		0xfffffb
52 #define	FS_NAME_SERVER		0xfffffc
53 #define	FS_FABRIC_CONTROLLER	0xfffffd
54 #define	FS_FABRIC_F_PORT	0xfffffe
55 #define	FS_BROADCAST		0xffffff
56 
57 /*
58  * Link Application Opcodes.
59  */
60 
61 #define	LA_ELS_RJT		0x01
62 #define	LA_ELS_ACC		0x02
63 #define	LA_ELS_PLOGI		0x03
64 #define	LA_ELS_FLOGI		0x04
65 #define	LA_ELS_LOGO		0x05
66 #define	LA_ELS_ABTX		0x06
67 #define	LA_ELS_RCS		0x07
68 #define	LA_ELS_RES		0x08
69 #define	LA_ELS_RSS		0x09
70 #define	LA_ELS_RSI		0x0a
71 #define	LA_ELS_ESTS		0x0b
72 #define	LA_ELS_ESTC		0x0c
73 #define	LA_ELS_ADVC		0x0d
74 #define	LA_ELS_RTV		0x0e
75 #define	LA_ELS_RLS		0x0f
76 #define	LA_ELS_ECHO		0x10
77 #define	LA_ELS_RRQ		0x12
78 #define	LA_ELS_PRLI		0x20
79 #define	LA_ELS_PRLO		0x21
80 #define	LA_ELS_SCN		0x22
81 #define	LA_ELS_TPLS		0x23
82 #define	LA_ELS_GPRLO		0x24
83 #define	LA_ELS_GAID		0x30
84 #define	LA_ELS_FACT		0x31
85 #define	LA_ELS_FDACT		0x32
86 #define	LA_ELS_NACT		0x33
87 #define	LA_ELS_NDACT		0x34
88 #define	LA_ELS_QoSR		0x40
89 #define	LA_ELS_RVCS		0x41
90 #define	LA_ELS_PDISC		0x50
91 #define	LA_ELS_FDISC		0x51
92 #define	LA_ELS_ADISC		0x52
93 #define	LA_ELS_NEW_IDENT	0xf0	/* SMCC specific */
94 #define	LA_ELS_DISPLAY		0xf1	/* SMCC specific */
95 #define	LA_ELS_IDENT		0x20	/* SMCC specifi, SSA compat. */
96 
97 /*
98  * Events supported by soc+ HBA driver
99  */
100 #define	FCAL_INSERT_EVENT	"SUNW,sf:DEVICE-INSERTION.1"
101 #define	FCAL_REMOVE_EVENT	"SUNW,sf:DEVICE-REMOVAL.1"
102 
103 /* Basic Accept Payload. */
104 typedef struct la_ba_acc {
105 	uchar_t		seq_id:8;
106 	uchar_t		org_s_id[3];
107 	ushort_t	ox_id;
108 	ushort_t	rx_id;
109 } la_ba_acc_t;
110 
111 /* Basic Reject. */
112 typedef struct la_ba_rjt {
113 	uchar_t		reserved;
114 	uchar_t		reason_code;
115 	uchar_t		explanation;
116 	uchar_t		vendor;
117 } la_ba_rjt_t;
118 
119 /*
120  * Basic Reject Reason Codes.
121  */
122 #define	RJT_INVALID_CMD		0x01
123 #define	RJT_LOGICAL_ERR		0x03
124 #define	RJT_LOGICAL_BUSY	0x05
125 #define	RJT_PROTOCOL_ERR	0x07
126 #define	RJT_UNABLE		0x09
127 #define	RJT_UNSUPPORTED		0x0B
128 #define	RJT_VENDOR		0xFF
129 
130 /*
131  * Basic Reject Explanation Codes
132  */
133 #define	RJT_NOEXPLANATION	0x00
134 #define	RJT_INVALID_OSID	0x01
135 #define	RJT_INVALID_OXID_RXID	0x03
136 #define	RJT_INVALID_SEQID	0x05
137 #define	RJT_ABORT_INACTIVE_SEQ	0x07
138 #define	RJT_UNABLE_TO_SUPPLY	0x09
139 
140 /*
141  * Service parameters.
142  */
143 typedef struct common_service {
144 	uint_t		fcph;
145 	uint_t		btob_crdt;
146 	uint_t		cmn_features;
147 	uint_t		reserved;
148 } common_svc_t;
149 
150 typedef struct service_param {
151 	uchar_t		data[16];
152 } svc_param_t;
153 
154 /* World Wide Name formats */
155 typedef union la_wwn {
156 	uchar_t		raw_wwn[8];
157 	struct {
158 	    uint_t	naa_id : 4;
159 	    uint_t	nport_id : 12;
160 	    uint_t	wwn_hi : 16;
161 	    uint_t	wwn_lo;
162 	} w;
163 } la_wwn_t;
164 
165 #define	FC_WWN_SIZE	8
166 
167 /*
168  * Values for naa_id
169  */
170 #define	NAA_ID_IEEE		1
171 #define	NAA_ID_IEEE_EXTENDED	2
172 
173 /* Login Payload. */
174 typedef struct la_els_logi {
175 	uchar_t		ls_code;
176 	uchar_t		mbz[3];
177 	common_svc_t	common_service;
178 
179 	la_wwn_t	nport_ww_name;
180 	la_wwn_t	node_ww_name;
181 
182 	svc_param_t	class_1;
183 	svc_param_t	class_2;
184 	svc_param_t	class_3;
185 	uchar_t		reserved[16];
186 	uchar_t		vendor_version_level[16];
187 } la_els_logi_t;
188 
189 typedef	la_els_logi_t	la_els_logi_reply_t;
190 #define	la_logi_t	la_els_logi_t
191 
192 #define	SP_F_PORT_LOGIN	0x10
193 
194 /* Read Link Error Status */
195 typedef struct la_els_rls {
196 	uchar_t		ls_code;
197 	uchar_t		mbz[3];
198 	uchar_t		reserved;
199 	uchar_t		nport_id[3];
200 } la_els_rls_t;
201 
202 /* Read Link Error Status Reply */
203 typedef struct la_els_rls_reply {
204 	uchar_t		ls_code;
205 	uchar_t		mbz[3];
206 	uint_t	link_failure;
207 	uint_t	loss_of_sync;
208 	uint_t	loss_of_signal;
209 	uint_t	primitive;
210 	uint_t	invalid_transmission;
211 	uint_t	invalid_crc;
212 } la_els_rls_reply_t;
213 
214 /* Logout payload. */
215 typedef struct la_els_logo {
216 	uchar_t		ls_code;
217 	uchar_t		mbz[3];
218 	uchar_t		reserved;
219 	uchar_t		nport_id[3];
220 	la_wwn_t	nport_ww_name;
221 } la_els_logo_t;
222 
223 /* Logout reply payload. */
224 typedef la_els_logo_t la_els_logo_reply_t;
225 
226 /* Reinstate recovery qualifier */
227 typedef	struct la_els_rrq {
228 	uchar_t		ls_code;
229 	uchar_t		mbz[3];
230 	uchar_t		reserved;
231 	uchar_t		source_id[3];
232 	ushort_t	ox_id;
233 	ushort_t	rx_id;
234 	uchar_t		assoc_header[32];
235 } la_els_rrq_t;
236 
237 /* Reinstate recovery qualifier reply */
238 typedef la_els_logo_t la_els_rrq_reply_t;
239 
240 /* Process login */
241 typedef struct la_els_prli {
242 	uchar_t		ls_code;
243 	uchar_t		page_length;
244 	ushort_t	payload_length;
245 	uchar_t		service_params[16];
246 } la_els_prli_t;
247 
248 /* Process login reply */
249 typedef	la_els_prli_t la_els_prli_reply_t;
250 
251 /* Process logout */
252 typedef la_els_prli_t la_els_prlo_t;
253 
254 /* process logout reply */
255 typedef	la_els_prli_t la_els_prlo_reply_t;
256 
257 /* Port discovery */
258 typedef la_els_logi_t la_els_pdisc_t;
259 
260 /* Port discovery reply */
261 typedef la_els_logi_reply_t la_els_pdisc_reply_t;
262 
263 /* Address discovery */
264 typedef	struct la_els_adisc {
265 	uchar_t	ls_code;
266 	uchar_t	mbz[3];
267 	uint_t	hard_address;
268 	uchar_t	port_wwn[8];
269 	uchar_t	node_wwn[8];
270 	uint_t	nport_id;
271 } la_els_adisc_t;
272 
273 /* Address discovery reply */
274 typedef	la_els_adisc_t la_els_adisc_reply_t;
275 
276 /* Identify */
277 typedef	struct la_els_identify {
278 	uint_t	ls_code;
279 	uint_t	byte_count;
280 } la_els_identify_t;
281 
282 /* Identify reply */
283 typedef	struct la_els_identify_reply {
284 	uint_t	ls_code;
285 	uchar_t	fcode[MAX_FCODE_SIZE];
286 } la_els_identify_reply;
287 
288 /* Link Application Reject */
289 typedef struct la_els_rjt {
290 	uchar_t	ls_code;
291 	uchar_t	mbz[3];
292 	uchar_t	reserved;
293 	uchar_t	reason_code;
294 	uchar_t	explanation;
295 	uchar_t	vendor;
296 } la_els_rjt_t;
297 
298 /*
299  * LA_RJT Reason Codes.
300  */
301 #define	LA_RJT_INVALID			0x01
302 #define	LA_RJT_LOGICAL_ERR		0x03
303 #define	LA_RJT_LOGICAL_BUSY		0x05
304 #define	LA_RJT_PROTOCOL_ERR		0x07
305 #define	LA_RJT_UNABLE_TO_PERFORM	0x09
306 #define	LA_RJT_NOT_SUPPORTED		0x0b
307 #define	LA_RJT_VENDOR			0xff
308 
309 /*
310  * LA_RJT explanations
311  */
312 #define	LA_RJT_NOEXPLANATION	0x00
313 #define	LA_RJT_OPTIONS		0x01
314 #define	LA_RJT_INITIATOR	0x03
315 #define	LA_RJT_RECIPIENT	0x05
316 #define	LA_RJT_DATA_FIELD_SIZE	0x07
317 #define	LA_RJT_CONCURRENT	0x09
318 #define	LA_RJT_CREDIT		0x0b
319 
320 #define	LA_RJT_INVALID_PORT_WWNAME	0x0d
321 #define	LA_RJT_INVALID_NODE_WWNAME	0x0e
322 #define	LA_RJT_INVALID_COMMON_SVC	0x0f
323 
324 #define	LA_RJT_INVALID_ASSOC_HEADER	0x11
325 #define	LA_RJT_ASSOC_HDR_REQD		0x13
326 #define	LA_RJT_INVALID_ORIG_SID		0x15
327 #define	LA_RJT_INVALID_FQXID		0x17
328 #define	LA_RJT_REQUEST_IN_PROGRESS	0x19
329 #define	LA_RJT_INVALID_NPORT_ID		0x1f
330 
331 #define	LA_RJT_ INVALID_SEQ_ID		0x21
332 #define	LA_RJT_ABT_INVALID_XID		0x23
333 #define	LA_RJT_ABT_INACTIVE_XID		0x25
334 #define	LA_RJT_RRQ_REQUIRED		0x27
335 #define	LA_RJT_INSUFFICENT		0x29
336 
337 #define	LA_RJT_REQUESTED_DATA		0x2a
338 #define	LA_RJT_REQUEST_NOT_SUPPORTED	0x2c
339 
340 #ifdef	__cplusplus
341 }
342 #endif
343 
344 #endif	/* !_SYS_FC4_FCAL_LINKAPP_H */
345