xref: /titanic_50/usr/src/uts/common/sys/fibre-channel/fca/emlxs/emlxs_fcf.h (revision 8f23e9fa8abcb5857661066b954e63400d589b65)
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
9  * http://www.opensource.org/licenses/cddl1.txt.
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 /*
23  * Copyright (c) 2004-2012 Emulex. All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _EMLXS_FCF_H
28 #define	_EMLXS_FCF_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #define	FCFTAB_MAX_FCFI_COUNT		1
35 #define	FCFI_MAX_VFI_COUNT		1
36 
37 /* Internal generic events */
38 #define	FCF_EVENT_STATE_ENTER		0
39 
40 /* External async fabric events */
41 #define	FCF_EVENT_SHUTDOWN		1
42 #define	FCF_EVENT_LINKUP		2
43 #define	FCF_EVENT_LINKDOWN		3
44 #define	FCF_EVENT_CVL			4
45 #define	FCF_EVENT_FCFTAB_FULL		5
46 #define	FCF_EVENT_FCF_FOUND		6
47 #define	FCF_EVENT_FCF_LOST		7
48 #define	FCF_EVENT_FCF_CHANGED		8
49 
50 /* Internal async events */
51 #define	FCF_EVENT_FCFTAB_ONLINE		9
52 #define	FCF_EVENT_FCFTAB_OFFLINE	10
53 
54 #define	FCF_EVENT_FCFI_ONLINE		11
55 #define	FCF_EVENT_FCFI_OFFLINE		12
56 #define	FCF_EVENT_FCFI_PAUSE		13
57 
58 #define	FCF_EVENT_VFI_ONLINE		14
59 #define	FCF_EVENT_VFI_OFFLINE		15
60 #define	FCF_EVENT_VFI_PAUSE		16
61 
62 #define	FCF_EVENT_VPI_ONLINE		17
63 #define	FCF_EVENT_VPI_OFFLINE		18
64 #define	FCF_EVENT_VPI_PAUSE		19
65 
66 #define	FCF_EVENT_RPI_ONLINE		20
67 #define	FCF_EVENT_RPI_OFFLINE		21
68 #define	FCF_EVENT_RPI_PAUSE		22
69 #define	FCF_EVENT_RPI_RESUME		23
70 
71 /* State change reason codes */		  /* explan */
72 #define	FCF_REASON_NONE			0
73 #define	FCF_REASON_REENTER		1
74 #define	FCF_REASON_EVENT		2 /* evt */
75 #define	FCF_REASON_REQUESTED		3
76 #define	FCF_REASON_NO_MBOX		4
77 #define	FCF_REASON_NO_BUFFER		5
78 #define	FCF_REASON_SEND_FAILED		6 /* status */
79 #define	FCF_REASON_MBOX_FAILED		7 /* status */
80 #define	FCF_REASON_MBOX_BUSY		8 /* status */
81 #define	FCF_REASON_NO_FCFI		9
82 #define	FCF_REASON_NO_VFI		10
83 #define	FCF_REASON_ONLINE_FAILED	11
84 #define	FCF_REASON_OFFLINE_FAILED	12
85 #define	FCF_REASON_OP_FAILED		13 /* attempts */
86 #define	FCF_REASON_NO_PKT		14
87 #define	FCF_REASON_NO_NODE		15
88 #define	FCF_REASON_NOT_ALLOWED		16
89 #define	FCF_REASON_UNUSED		17
90 #define	FCF_REASON_INVALID		18
91 
92 typedef struct XRIobj
93 {
94 	struct XRIobj	*_f;
95 	struct XRIobj	*_b;
96 	uint16_t	XRI;
97 	uint16_t	state;
98 #define	XRI_STATE_FREE			0
99 #define	XRI_STATE_ALLOCATED		1
100 
101 	uint16_t	sge_count;
102 	uint16_t	iotag;
103 	MBUF_INFO	SGList;
104 	struct RPIobj	*rpip;
105 	struct RPIobj	*reserved_rpip;
106 	emlxs_buf_t	*sbp;
107 	uint32_t 	rx_id; /* Used for unsol exchanges */
108 	uint32_t 	flag;
109 #define	EMLXS_XRI_RESERVED		0x00000001
110 #define	EMLXS_XRI_PENDING_IO		0x00000002
111 #define	EMLXS_XRI_BUSY			0x00000004
112 
113 	uint32_t 	type;
114 #define	EMLXS_XRI_SOL_FCP_TYPE		1
115 #define	EMLXS_XRI_UNSOL_FCP_TYPE	2
116 #define	EMLXS_XRI_SOL_CT_TYPE		3
117 #define	EMLXS_XRI_UNSOL_CT_TYPE		4
118 #define	EMLXS_XRI_SOL_ELS_TYPE		5
119 #define	EMLXS_XRI_UNSOL_ELS_TYPE	6
120 #define	EMLXS_XRI_SOL_BLS_TYPE		7
121 
122 } XRIobj_t;
123 
124 
125 typedef struct emlxs_deferred_cmpl
126 {
127 	struct emlxs_port *port;
128 	struct emlxs_node *node;
129 
130 	void *arg1;
131 	void *arg2;
132 	void *arg3;
133 
134 } emlxs_deferred_cmpl_t;
135 
136 
137 #define	FABRIC_RPI		0xffff
138 
139 typedef struct RPIobj
140 {
141 	uint16_t	index;
142 	uint16_t	RPI;
143 
144 	uint16_t	prev_reason;
145 	uint16_t	prev_state;
146 
147 	uint16_t	reason;
148 	uint16_t	state;
149 #define	RPI_STATE_FREE			0
150 
151 #define	RPI_STATE_RESERVED		1
152 #define	RPI_STATE_OFFLINE		2
153 
154 #define	RPI_STATE_UNREG_CMPL		3
155 #define	RPI_STATE_UNREG_FAILED		4
156 #define	RPI_STATE_UNREG			5
157 
158 #define	RPI_STATE_REG			6
159 #define	RPI_STATE_REG_FAILED		7
160 #define	RPI_STATE_REG_CMPL		8
161 
162 #define	RPI_STATE_PAUSED		9
163 
164 #define	RPI_STATE_RESUME		10
165 #define	RPI_STATE_RESUME_FAILED		11
166 #define	RPI_STATE_RESUME_CMPL		12
167 
168 #define	RPI_STATE_ONLINE		13
169 
170 
171 	uint32_t	flag;
172 #define	EMLXS_RPI_VPI			0x00000010 /* rpi_online set */
173 #define	EMLXS_RPI_PAUSED		0x00000020 /* rpi_paused set */
174 #define	EMLXS_RPI_REG			0x00000040
175 
176 #define	EMLXS_RPI_FIRST			0x80000000
177 
178 	uint32_t	attempts;
179 	uint32_t	xri_count;  /* Managed by XRIobj_t */
180 
181 	uint32_t	idle_timer;
182 
183 	struct VPIobj 	*vpip;
184 
185 	/* Node info */
186 	struct emlxs_node	*node;
187 	uint32_t	did;
188 	SERV_PARM	sparam;
189 
190 	emlxs_deferred_cmpl_t *cmpl;
191 
192 } RPIobj_t;
193 
194 
195 typedef struct VPIobj
196 {
197 	uint16_t 	index;
198 	uint16_t 	VPI;
199 
200 	uint16_t	prev_reason;
201 	uint16_t	prev_state;
202 
203 	uint16_t	reason;
204 	uint16_t	state;
205 #define	VPI_STATE_OFFLINE		0
206 
207 #define	VPI_STATE_INIT			1
208 #define	VPI_STATE_INIT_FAILED		2
209 #define	VPI_STATE_INIT_CMPL		3
210 
211 #define	VPI_STATE_UNREG_CMPL		4
212 #define	VPI_STATE_UNREG_FAILED		5
213 #define	VPI_STATE_UNREG			6
214 
215 #define	VPI_STATE_LOGO_CMPL		7
216 #define	VPI_STATE_LOGO_FAILED		8
217 #define	VPI_STATE_LOGO			9
218 
219 #define	VPI_STATE_PORT_OFFLINE		10
220 #define	VPI_STATE_PORT_ONLINE		11
221 
222 #define	VPI_STATE_LOGI			12
223 #define	VPI_STATE_LOGI_FAILED		13
224 #define	VPI_STATE_LOGI_CMPL		14
225 
226 #define	VPI_STATE_REG			15
227 #define	VPI_STATE_REG_FAILED		16
228 #define	VPI_STATE_REG_CMPL		17
229 
230 #define	VPI_STATE_PAUSED		18
231 #define	VPI_STATE_ONLINE		19
232 
233 
234 	uint32_t 	flag;
235 #define	EMLXS_VPI_ONLINE_REQ		0x00000001
236 #define	EMLXS_VPI_OFFLINE_REQ		0x00000002
237 #define	EMLXS_VPI_PAUSE_REQ		0x00000004
238 #define	EMLXS_VPI_REQ_MASK		0x0000000F
239 
240 #define	EMLXS_VPI_VFI			0x00000010 /* vpi_online set */
241 #define	EMLXS_VPI_VFI_LOGI		0x00000020 /* logi_count set */
242 #define	EMLXS_VPI_INIT			0x00000040
243 #define	EMLXS_VPI_REG			0x00000080
244 #define	EMLXS_VPI_PORT_ONLINE		0x00000100
245 #define	EMLXS_VPI_LOGI			0x00000200
246 #define	EMLXS_VPI_PORT_UNBIND		0x40000000
247 #define	EMLXS_VPI_PORT_ENABLED		0x80000000
248 
249 	uint32_t	attempts;
250 
251 	RPIobj_t	fabric_rpi;	/* Reserved Fabric RPI object */
252 	RPIobj_t	*fabric_rpip;	/* Fabric RPI pointer (&fabric_rpi) */
253 	RPIobj_t	*p2p_rpip;
254 
255 	struct emlxs_port *port;
256 
257 	struct VFIobj	*vfip; /* Managed by VFIobj_t */
258 	uint32_t	rpi_online; /* Managed by RPIobj_t */
259 	uint32_t	rpi_paused; /* Managed by RPIobj_t */
260 
261 } VPIobj_t;
262 
263 
264 typedef struct VFIobj
265 {
266 	uint16_t	index;
267 	uint16_t	VFI;
268 
269 	uint16_t	prev_reason;
270 	uint16_t	prev_state;
271 
272 	uint16_t	reason;
273 	uint16_t	state;
274 #define	VFI_STATE_OFFLINE		0
275 
276 #define	VFI_STATE_INIT			1
277 #define	VFI_STATE_INIT_FAILED		2
278 #define	VFI_STATE_INIT_CMPL		3
279 
280 #define	VFI_STATE_VPI_OFFLINE_CMPL	4
281 #define	VFI_STATE_VPI_OFFLINE		5
282 
283 #define	VFI_STATE_VPI_ONLINE		6
284 #define	VFI_STATE_VPI_ONLINE_CMPL	7
285 
286 #define	VFI_STATE_UNREG_CMPL		8
287 #define	VFI_STATE_UNREG_FAILED		9
288 #define	VFI_STATE_UNREG			10
289 
290 #define	VFI_STATE_REG			11
291 #define	VFI_STATE_REG_FAILED		12
292 #define	VFI_STATE_REG_CMPL		13
293 
294 #define	VFI_STATE_PAUSED		14
295 #define	VFI_STATE_ONLINE		15
296 
297 	uint32_t	flag;
298 #define	EMLXS_VFI_ONLINE_REQ		0x00000001
299 #define	EMLXS_VFI_OFFLINE_REQ		0x00000002
300 #define	EMLXS_VFI_PAUSE_REQ		0x00000004
301 #define	EMLXS_VFI_REQ_MASK		0x0000000F
302 
303 #define	EMLXS_VFI_FCFI			0x00000010 /* vfi_online set */
304 #define	EMLXS_VFI_INIT			0x00000020
305 #define	EMLXS_VFI_REG			0x00000040
306 
307 	SERV_PARM	sparam;		/* Last registered sparams */
308 
309 	uint32_t	attempts;
310 
311 	struct FCFIobj 	*fcfp;		/* Managed by FCFIobj_t */
312 
313 	uint32_t	vpi_online;	/* Managed by VPIobj_t */
314 	uint32_t 	logi_count;	/* Managed by VPIobj_t */
315 	struct VPIobj 	*flogi_vpip;	/* Managed by VPIobj_t */
316 
317 } VFIobj_t;
318 
319 
320 typedef struct FCFIobj
321 {
322 	uint16_t	index;
323 	uint16_t	FCFI;
324 
325 	uint16_t	fcf_index;
326 	uint16_t	vlan_id;
327 
328 	uint16_t	prev_reason;
329 	uint16_t	prev_state;
330 
331 	uint16_t	reason;
332 	uint16_t	state;
333 #define	FCFI_STATE_FREE			0
334 
335 #define	FCFI_STATE_OFFLINE		1
336 
337 #define	FCFI_STATE_UNREG_CMPL		2
338 #define	FCFI_STATE_UNREG_FAILED		3
339 #define	FCFI_STATE_UNREG		4
340 
341 #define	FCFI_STATE_REG			5
342 #define	FCFI_STATE_REG_FAILED		6
343 #define	FCFI_STATE_REG_CMPL		7
344 
345 #define	FCFI_STATE_VFI_OFFLINE_CMPL	8
346 #define	FCFI_STATE_VFI_OFFLINE		9
347 
348 #define	FCFI_STATE_VFI_ONLINE		10
349 #define	FCFI_STATE_VFI_ONLINE_CMPL	11
350 
351 #define	FCFI_STATE_PAUSED		12
352 #define	FCFI_STATE_ONLINE		13
353 
354 
355 	uint16_t 	pad;
356 	uint16_t 	generation;
357 
358 	uint32_t 	offline_timer;
359 	uint32_t 	attempts;
360 
361 	uint32_t	event_tag;
362 	uint32_t	flag;
363 #define	EMLXS_FCFI_ONLINE_REQ		0x00000001
364 #define	EMLXS_FCFI_OFFLINE_REQ		0x00000002
365 #define	EMLXS_FCFI_PAUSE_REQ		0x00000004
366 #define	EMLXS_FCFI_REQ_MASK		0x0000000F
367 
368 #define	EMLXS_FCFI_FCFTAB		0x00000010 /* fcfi_online set */
369 #define	EMLXS_FCFI_REG			0x00000020
370 
371 #define	EMLXS_FCFI_VALID		0x00000100
372 #define	EMLXS_FCFI_AVAILABLE		0x00000200
373 #define	EMLXS_FCFI_CONFIGURED		0x00000400
374 #define	EMLXS_FCFI_FRESH		0x00000800
375 #define	EMLXS_FCFI_FAILED		0x00001000
376 #define	EMLXS_FCFI_SELECTED		0x00002000 /* in use */
377 
378 #define	EMLXS_FCFI_VLAN_ID		0x00010000
379 #define	EMLXS_FCFI_BOOT			0x00020000
380 #define	EMLXS_FCFI_PRIMARY		0x00040000
381 
382 #define	EMLXS_FCFI_TAGGED		0x80000000
383 
384 	/* struct VFTable	vftab */
385 
386 	FCF_RECORD_t	fcf_rec;
387 	uint32_t	priority;
388 
389 	uint32_t	vfi_online;  /* Managed by VFIobj_t */
390 
391 } FCFIobj_t;
392 
393 
394 typedef struct VFTable
395 {
396 	uint16_t 	prev_reason;
397 	uint16_t 	prev_state;
398 
399 	uint16_t 	reason;
400 	uint16_t 	state;
401 #define	VFTAB_STATE_DISABLED		0
402 
403 	uint32_t	vfi_active;
404 	uint32_t	vfi_count;
405 	VFIobj_t	*table;
406 
407 } VFTable_t;
408 
409 typedef struct FCFTable
410 {
411 
412 	uint16_t 	prev_reason;
413 	uint16_t 	prev_state;
414 
415 	uint16_t 	reason;
416 	uint16_t 	state;
417 /* Common states */
418 #define	FCFTAB_STATE_SHUTDOWN			0
419 #define	FCFTAB_STATE_OFFLINE			1
420 
421 /* FCOE states */
422 #define	FCOE_FCFTAB_STATE_SHUTDOWN		FCFTAB_STATE_SHUTDOWN
423 #define	FCOE_FCFTAB_STATE_OFFLINE		FCFTAB_STATE_OFFLINE
424 
425 #define	FCOE_FCFTAB_STATE_SOLICIT		2
426 #define	FCOE_FCFTAB_STATE_SOLICIT_FAILED	3
427 #define	FCOE_FCFTAB_STATE_SOLICIT_CMPL		4
428 
429 #define	FCOE_FCFTAB_STATE_READ			5
430 #define	FCOE_FCFTAB_STATE_READ_FAILED		6
431 #define	FCOE_FCFTAB_STATE_READ_CMPL		7
432 
433 #define	FCOE_FCFTAB_STATE_FCFI_OFFLINE_CMPL	8
434 #define	FCOE_FCFTAB_STATE_FCFI_OFFLINE		9
435 
436 #define	FCOE_FCFTAB_STATE_FCFI_ONLINE		10
437 #define	FCOE_FCFTAB_STATE_FCFI_ONLINE_CMPL	11
438 
439 #define	FCOE_FCFTAB_STATE_ONLINE		12
440 
441 
442 /* FC states */
443 #define	FC_FCFTAB_STATE_SHUTDOWN		FCFTAB_STATE_SHUTDOWN
444 #define	FC_FCFTAB_STATE_OFFLINE			FCFTAB_STATE_OFFLINE
445 
446 #define	FC_FCFTAB_STATE_TOPO			2
447 #define	FC_FCFTAB_STATE_TOPO_FAILED		3
448 #define	FC_FCFTAB_STATE_TOPO_CMPL		4
449 
450 #define	FC_FCFTAB_STATE_CFGLINK			5
451 #define	FC_FCFTAB_STATE_CFGLINK_FAILED		6
452 #define	FC_FCFTAB_STATE_CFGLINK_CMPL		7
453 
454 #define	FC_FCFTAB_STATE_SPARM			8
455 #define	FC_FCFTAB_STATE_SPARM_FAILED		9
456 #define	FC_FCFTAB_STATE_SPARM_CMPL		10
457 
458 #define	FC_FCFTAB_STATE_FCFI_OFFLINE_CMPL	11
459 #define	FC_FCFTAB_STATE_FCFI_OFFLINE		12
460 
461 #define	FC_FCFTAB_STATE_FCFI_ONLINE		13
462 #define	FC_FCFTAB_STATE_FCFI_ONLINE_CMPL	14
463 
464 #define	FC_FCFTAB_STATE_ONLINE			15
465 
466 
467 	uint16_t 	TID;
468 	uint16_t 	generation;
469 
470 	uint32_t 	flag;
471 /* Common flags */
472 #define	EMLXS_FCFTAB_REQ_MASK			0x0000000F
473 #define	EMLXS_FCFTAB_SHUTDOWN			0x80000000
474 
475 /* FCOE flags */
476 #define	EMLXS_FCOE_FCFTAB_SOL_REQ		0x00000001
477 #define	EMLXS_FCOE_FCFTAB_READ_REQ		0x00000002
478 #define	EMLXS_FCOE_FCFTAB_OFFLINE_REQ		0x00000004
479 
480 /* FC flags */
481 #define	EMLXS_FC_FCFTAB_TOPO_REQ		0x00000001
482 #define	EMLXS_FC_FCFTAB_CFGLINK_REQ		0x00000002
483 #define	EMLXS_FC_FCFTAB_SPARM_REQ		0x00000004
484 #define	EMLXS_FC_FCFTAB_OFFLINE_REQ		0x00000008
485 
486 	uint32_t 	attempts;
487 
488 	uint32_t	fcfi_online;  /* Managed by FCFIobj_t */
489 
490 	FCFIobj_t	*fcfi[FCFTAB_MAX_FCFI_COUNT];
491 	uint32_t	fcfi_count;
492 
493 	FCFIobj_t	*table;
494 	uint16_t	table_count;
495 
496 	uint32_t 	online_timer;	/* FC */
497 
498 	uint32_t 	sol_timer;	/* FCOE */
499 	uint32_t 	read_timer;	/* FCOE */
500 
501 } FCFTable_t;
502 #define	FCFTAB_READ_ALL		(void*)0xffff
503 
504 #ifdef	__cplusplus
505 }
506 #endif
507 
508 #endif	/* _EMLXS_FCF_H */
509