xref: /onnv-gate/usr/src/uts/common/sys/fibre-channel/impl/fp.h (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM  */
25*7836SJohn.Forte@Sun.COM 
26*7836SJohn.Forte@Sun.COM #ifndef	_FP_H
27*7836SJohn.Forte@Sun.COM #define	_FP_H
28*7836SJohn.Forte@Sun.COM 
29*7836SJohn.Forte@Sun.COM 
30*7836SJohn.Forte@Sun.COM #include <sys/note.h>
31*7836SJohn.Forte@Sun.COM 
32*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
33*7836SJohn.Forte@Sun.COM extern "C" {
34*7836SJohn.Forte@Sun.COM #endif
35*7836SJohn.Forte@Sun.COM 
36*7836SJohn.Forte@Sun.COM /*
37*7836SJohn.Forte@Sun.COM  * Debugging, Error reporting, and tracing
38*7836SJohn.Forte@Sun.COM  */
39*7836SJohn.Forte@Sun.COM #define	FP_LOG_SIZE		1024 * 1024
40*7836SJohn.Forte@Sun.COM 
41*7836SJohn.Forte@Sun.COM #define	FP_LEVEL_1		0x00001		/* attach/detach PM CPR */
42*7836SJohn.Forte@Sun.COM #define	FP_LEVEL_2		0x00002		/* startup */
43*7836SJohn.Forte@Sun.COM #define	FP_LEVEL_3		0x00004		/* state change, discovery */
44*7836SJohn.Forte@Sun.COM #define	FP_LEVEL_4		0x00008		/* statec/devc to ULPs */
45*7836SJohn.Forte@Sun.COM #define	FP_LEVEL_5		0x00010		/* FCA UB callbacks */
46*7836SJohn.Forte@Sun.COM #define	FP_LEVEL_6		0x00020		/* Name Server */
47*7836SJohn.Forte@Sun.COM #define	FP_LEVEL_7		0x00040		/* RSCN */
48*7836SJohn.Forte@Sun.COM #define	FP_LEVEL_8		0x00080		/* I/O tracing */
49*7836SJohn.Forte@Sun.COM #define	FP_LEVEL_9		0x00100		/* Failure messages */
50*7836SJohn.Forte@Sun.COM 
51*7836SJohn.Forte@Sun.COM 
52*7836SJohn.Forte@Sun.COM /*
53*7836SJohn.Forte@Sun.COM  * Log contents to system messages file
54*7836SJohn.Forte@Sun.COM  */
55*7836SJohn.Forte@Sun.COM #define	FP_MSG_LEVEL_1		(FP_LEVEL_1 | FC_TRACE_LOG_MSG)
56*7836SJohn.Forte@Sun.COM #define	FP_MSG_LEVEL_2		(FP_LEVEL_2 | FC_TRACE_LOG_MSG)
57*7836SJohn.Forte@Sun.COM #define	FP_MSG_LEVEL_3		(FP_LEVEL_3 | FC_TRACE_LOG_MSG)
58*7836SJohn.Forte@Sun.COM #define	FP_MSG_LEVEL_4		(FP_LEVEL_4 | FC_TRACE_LOG_MSG)
59*7836SJohn.Forte@Sun.COM #define	FP_MSG_LEVEL_5		(FP_LEVEL_5 | FC_TRACE_LOG_MSG)
60*7836SJohn.Forte@Sun.COM #define	FP_MSG_LEVEL_6		(FP_LEVEL_6 | FC_TRACE_LOG_MSG)
61*7836SJohn.Forte@Sun.COM #define	FP_MSG_LEVEL_7		(FP_LEVEL_7 | FC_TRACE_LOG_MSG)
62*7836SJohn.Forte@Sun.COM #define	FP_MSG_LEVEL_8		(FP_LEVEL_8 | FC_TRACE_LOG_MSG)
63*7836SJohn.Forte@Sun.COM #define	FP_MSG_LEVEL_9		(FP_LEVEL_9 | FC_TRACE_LOG_MSG)
64*7836SJohn.Forte@Sun.COM 
65*7836SJohn.Forte@Sun.COM 
66*7836SJohn.Forte@Sun.COM /*
67*7836SJohn.Forte@Sun.COM  * Log contents to trace buffer
68*7836SJohn.Forte@Sun.COM  */
69*7836SJohn.Forte@Sun.COM #define	FP_BUF_LEVEL_1		(FP_LEVEL_1 | FC_TRACE_LOG_BUF)
70*7836SJohn.Forte@Sun.COM #define	FP_BUF_LEVEL_2		(FP_LEVEL_2 | FC_TRACE_LOG_BUF)
71*7836SJohn.Forte@Sun.COM #define	FP_BUF_LEVEL_3		(FP_LEVEL_3 | FC_TRACE_LOG_BUF)
72*7836SJohn.Forte@Sun.COM #define	FP_BUF_LEVEL_4		(FP_LEVEL_4 | FC_TRACE_LOG_BUF)
73*7836SJohn.Forte@Sun.COM #define	FP_BUF_LEVEL_5		(FP_LEVEL_5 | FC_TRACE_LOG_BUF)
74*7836SJohn.Forte@Sun.COM #define	FP_BUF_LEVEL_6		(FP_LEVEL_6 | FC_TRACE_LOG_BUF)
75*7836SJohn.Forte@Sun.COM #define	FP_BUF_LEVEL_7		(FP_LEVEL_7 | FC_TRACE_LOG_BUF)
76*7836SJohn.Forte@Sun.COM #define	FP_BUF_LEVEL_8		(FP_LEVEL_8 | FC_TRACE_LOG_BUF)
77*7836SJohn.Forte@Sun.COM #define	FP_BUF_LEVEL_9		(FP_LEVEL_9 | FC_TRACE_LOG_BUF)
78*7836SJohn.Forte@Sun.COM 
79*7836SJohn.Forte@Sun.COM 
80*7836SJohn.Forte@Sun.COM /*
81*7836SJohn.Forte@Sun.COM  * Log contents to both system messages file and trace buffer
82*7836SJohn.Forte@Sun.COM  */
83*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_LEVEL_1	(FP_LEVEL_1 | FC_TRACE_LOG_BUF |\
84*7836SJohn.Forte@Sun.COM 				FC_TRACE_LOG_MSG)
85*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_LEVEL_2	(FP_LEVEL_2 | FC_TRACE_LOG_BUF |\
86*7836SJohn.Forte@Sun.COM 				FC_TRACE_LOG_MSG)
87*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_LEVEL_3	(FP_LEVEL_3 | FC_TRACE_LOG_BUF |\
88*7836SJohn.Forte@Sun.COM 				FC_TRACE_LOG_MSG)
89*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_LEVEL_4	(FP_LEVEL_4 | FC_TRACE_LOG_BUF |\
90*7836SJohn.Forte@Sun.COM 				FC_TRACE_LOG_MSG)
91*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_LEVEL_5	(FP_LEVEL_5 | FC_TRACE_LOG_BUF |\
92*7836SJohn.Forte@Sun.COM 				FC_TRACE_LOG_MSG)
93*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_LEVEL_6	(FP_LEVEL_6 | FC_TRACE_LOG_BUF |\
94*7836SJohn.Forte@Sun.COM 				FC_TRACE_LOG_MSG)
95*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_LEVEL_7	(FP_LEVEL_7 | FC_TRACE_LOG_BUF |\
96*7836SJohn.Forte@Sun.COM 				FC_TRACE_LOG_MSG)
97*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_LEVEL_8	(FP_LEVEL_8 | FC_TRACE_LOG_BUF |\
98*7836SJohn.Forte@Sun.COM 				FC_TRACE_LOG_MSG)
99*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_LEVEL_9	(FP_LEVEL_9 | FC_TRACE_LOG_BUF |\
100*7836SJohn.Forte@Sun.COM 				FC_TRACE_LOG_MSG)
101*7836SJohn.Forte@Sun.COM 
102*7836SJohn.Forte@Sun.COM /*
103*7836SJohn.Forte@Sun.COM  * Log contents to system messages file, console and trace buffer
104*7836SJohn.Forte@Sun.COM  */
105*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_CONSOLE_LEVEL_1	(FP_LEVEL_1 | FC_TRACE_LOG_BUF |\
106*7836SJohn.Forte@Sun.COM 					FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE)
107*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_CONSOLE_LEVEL_2	(FP_LEVEL_2 | FC_TRACE_LOG_BUF |\
108*7836SJohn.Forte@Sun.COM 					FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE)
109*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_CONSOLE_LEVEL_3	(FP_LEVEL_3 | FC_TRACE_LOG_BUF |\
110*7836SJohn.Forte@Sun.COM 					FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE)
111*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_CONSOLE_LEVEL_4	(FP_LEVEL_4 | FC_TRACE_LOG_BUF |\
112*7836SJohn.Forte@Sun.COM 					FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE)
113*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_CONSOLE_LEVEL_5	(FP_LEVEL_5 | FC_TRACE_LOG_BUF |\
114*7836SJohn.Forte@Sun.COM 					FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE)
115*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_CONSOLE_LEVEL_6	(FP_LEVEL_6 | FC_TRACE_LOG_BUF |\
116*7836SJohn.Forte@Sun.COM 					FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE)
117*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_CONSOLE_LEVEL_7	(FP_LEVEL_7 | FC_TRACE_LOG_BUF |\
118*7836SJohn.Forte@Sun.COM 					FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE)
119*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_CONSOLE_LEVEL_8	(FP_LEVEL_8 | FC_TRACE_LOG_BUF |\
120*7836SJohn.Forte@Sun.COM 					FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE)
121*7836SJohn.Forte@Sun.COM #define	FP_MSG_BUF_CONSOLE_LEVEL_9	(FP_LEVEL_9 | FC_TRACE_LOG_BUF |\
122*7836SJohn.Forte@Sun.COM 					FC_TRACE_LOG_MSG | FC_TRACE_LOG_CONSOLE)
123*7836SJohn.Forte@Sun.COM #ifdef DEBUG
124*7836SJohn.Forte@Sun.COM 
125*7836SJohn.Forte@Sun.COM #define	FP_DTRACE		fc_trace_debug
126*7836SJohn.Forte@Sun.COM 
127*7836SJohn.Forte@Sun.COM #else
128*7836SJohn.Forte@Sun.COM 
129*7836SJohn.Forte@Sun.COM #define	FP_DTRACE
130*7836SJohn.Forte@Sun.COM 
131*7836SJohn.Forte@Sun.COM #endif
132*7836SJohn.Forte@Sun.COM 
133*7836SJohn.Forte@Sun.COM #define	FP_TRACE		fc_trace_debug
134*7836SJohn.Forte@Sun.COM 
135*7836SJohn.Forte@Sun.COM 
136*7836SJohn.Forte@Sun.COM #ifdef	DEBUG
137*7836SJohn.Forte@Sun.COM 
138*7836SJohn.Forte@Sun.COM #define	FP_TRACE_DEFAULT 	(FC_TRACE_LOG_MASK | FP_LEVEL_1 |\
139*7836SJohn.Forte@Sun.COM 				FP_LEVEL_2 | FP_LEVEL_3 |\
140*7836SJohn.Forte@Sun.COM 				FP_LEVEL_4 | FP_LEVEL_5 |\
141*7836SJohn.Forte@Sun.COM 				FP_LEVEL_6 | FP_LEVEL_7 | FP_LEVEL_9)
142*7836SJohn.Forte@Sun.COM 
143*7836SJohn.Forte@Sun.COM #else
144*7836SJohn.Forte@Sun.COM 
145*7836SJohn.Forte@Sun.COM #define	FP_TRACE_DEFAULT 	(FC_TRACE_LOG_MASK | FP_LEVEL_1 |\
146*7836SJohn.Forte@Sun.COM 				FP_LEVEL_2 | FP_LEVEL_3 |\
147*7836SJohn.Forte@Sun.COM 				FP_LEVEL_4 | FP_LEVEL_5 |\
148*7836SJohn.Forte@Sun.COM 				FP_LEVEL_6 | FP_LEVEL_7 | FP_LEVEL_9)
149*7836SJohn.Forte@Sun.COM #endif
150*7836SJohn.Forte@Sun.COM 
151*7836SJohn.Forte@Sun.COM #define	FP_THEAD(x, y, z)	fp_logq, x->fp_ibuf, fp_trace, y, z
152*7836SJohn.Forte@Sun.COM 
153*7836SJohn.Forte@Sun.COM #define	FP_NHEAD1(x, y)		FP_THEAD(port, FP_BUF_LEVEL_##x, y)
154*7836SJohn.Forte@Sun.COM 
155*7836SJohn.Forte@Sun.COM #define	FP_NHEAD2(x, y)		FP_THEAD(port, FP_MSG_BUF_LEVEL_##x, y)
156*7836SJohn.Forte@Sun.COM 
157*7836SJohn.Forte@Sun.COM #define	FP_NHEAD3(x, y)		FP_THEAD(port, FP_MSG_BUF_CONSOLE_LEVEL_##x, y)
158*7836SJohn.Forte@Sun.COM 
159*7836SJohn.Forte@Sun.COM 
160*7836SJohn.Forte@Sun.COM /* This is used in about a dozen or so places in fp.c */
161*7836SJohn.Forte@Sun.COM #define	FP_IS_PKT_ERROR(pkt)	(((pkt)->pkt_state != FC_PKT_SUCCESS) ||\
162*7836SJohn.Forte@Sun.COM 				((pkt)->pkt_state == FC_PKT_SUCCESS &&\
163*7836SJohn.Forte@Sun.COM 				(pkt)->pkt_resp_resid != 0))
164*7836SJohn.Forte@Sun.COM 
165*7836SJohn.Forte@Sun.COM 
166*7836SJohn.Forte@Sun.COM /*
167*7836SJohn.Forte@Sun.COM  * This is only used in fp_ns_init() and fp_fabric_online().
168*7836SJohn.Forte@Sun.COM  */
169*7836SJohn.Forte@Sun.COM #define	FP_MAX_DEVICES			255
170*7836SJohn.Forte@Sun.COM 
171*7836SJohn.Forte@Sun.COM 
172*7836SJohn.Forte@Sun.COM /*
173*7836SJohn.Forte@Sun.COM  * Software restoration bit fields while doing (PM)SUSPEND/(PM)RESUME
174*7836SJohn.Forte@Sun.COM  * Used with the fp_restore field in the fc_local_port_t struct.
175*7836SJohn.Forte@Sun.COM  */
176*7836SJohn.Forte@Sun.COM #define	FP_RESTORE_WAIT_TIMEOUT		0x01
177*7836SJohn.Forte@Sun.COM #define	FP_RESTORE_OFFLINE_TIMEOUT	0x02
178*7836SJohn.Forte@Sun.COM #define	FP_ELS_TIMEOUT		(20)
179*7836SJohn.Forte@Sun.COM #define	FP_NS_TIMEOUT		(120)
180*7836SJohn.Forte@Sun.COM #define	FP_IS_F_PORT(p)		((p) & 0x1000)
181*7836SJohn.Forte@Sun.COM #define	FP_RETRY_COUNT		(5)
182*7836SJohn.Forte@Sun.COM #define	FP_RETRY_DELAY		(3)			/* E_D_TOV + 1 second */
183*7836SJohn.Forte@Sun.COM #define	FP_OFFLINE_TICKER	(90)			/* seconds */
184*7836SJohn.Forte@Sun.COM #define	FP_DEFAULT_SID		(0x000AE)		/* Used once */
185*7836SJohn.Forte@Sun.COM #define	FP_DEFAULT_DID		(0x000EA)		/* Used once */
186*7836SJohn.Forte@Sun.COM #define	FP_PORT_IDENTIFIER_LEN	(4)
187*7836SJohn.Forte@Sun.COM #define	FP_UNSOL_BUF_COUNT	(20)
188*7836SJohn.Forte@Sun.COM #define	FP_UNSOL_BUF_SIZE	(sizeof (la_els_logi_t))
189*7836SJohn.Forte@Sun.COM #define	FP_CMDWAIT_DELAY	(240)	/* Enough time for all cmds to complt */
190*7836SJohn.Forte@Sun.COM 
191*7836SJohn.Forte@Sun.COM 
192*7836SJohn.Forte@Sun.COM /*
193*7836SJohn.Forte@Sun.COM  * Values and macros  used with fp_task and fp_last_task fields in
194*7836SJohn.Forte@Sun.COM  * the fc_local_port_t struct. Also see fp_job_handler() for more info.
195*7836SJohn.Forte@Sun.COM  */
196*7836SJohn.Forte@Sun.COM #define	FP_TASK_IDLE			0
197*7836SJohn.Forte@Sun.COM #define	FP_TASK_PORT_STARTUP		1
198*7836SJohn.Forte@Sun.COM #define	FP_TASK_OFFLINE			2
199*7836SJohn.Forte@Sun.COM #define	FP_TASK_ONLINE			3
200*7836SJohn.Forte@Sun.COM #define	FP_TASK_GETMAP			4
201*7836SJohn.Forte@Sun.COM 
202*7836SJohn.Forte@Sun.COM 
203*7836SJohn.Forte@Sun.COM /*
204*7836SJohn.Forte@Sun.COM  * cmd_flags
205*7836SJohn.Forte@Sun.COM  */
206*7836SJohn.Forte@Sun.COM #define	FP_CMD_CFLAG_UNDEFINED		(-1)
207*7836SJohn.Forte@Sun.COM #define	FP_CMD_PLOGI_DONT_CARE		0x00
208*7836SJohn.Forte@Sun.COM #define	FP_CMD_PLOGI_RETAIN		0x01	/* Retain LOGIN */
209*7836SJohn.Forte@Sun.COM #define	FP_CMD_DELDEV_ON_ERROR		0x02	/* Remove device on error */
210*7836SJohn.Forte@Sun.COM 
211*7836SJohn.Forte@Sun.COM /*
212*7836SJohn.Forte@Sun.COM  * cmd_dflags
213*7836SJohn.Forte@Sun.COM  */
214*7836SJohn.Forte@Sun.COM #define	FP_CMD_VALID_DMA_MEM		0x01
215*7836SJohn.Forte@Sun.COM #define	FP_CMD_VALID_DMA_BIND		0x02
216*7836SJohn.Forte@Sun.COM #define	FP_RESP_VALID_DMA_MEM		0x04
217*7836SJohn.Forte@Sun.COM #define	FP_RESP_VALID_DMA_BIND		0x08
218*7836SJohn.Forte@Sun.COM 
219*7836SJohn.Forte@Sun.COM 
220*7836SJohn.Forte@Sun.COM /* Values for fp_flag field in the fc_local_port_t struct */
221*7836SJohn.Forte@Sun.COM #define	FP_IDLE		0x00
222*7836SJohn.Forte@Sun.COM #define	FP_OPEN		0x01
223*7836SJohn.Forte@Sun.COM #define	FP_EXCL		0x02
224*7836SJohn.Forte@Sun.COM #define	FP_EXCL_BUSY	0x04	/* Exclusive operation in progress */
225*7836SJohn.Forte@Sun.COM 
226*7836SJohn.Forte@Sun.COM 
227*7836SJohn.Forte@Sun.COM /* message block/unblock'ing */
228*7836SJohn.Forte@Sun.COM #define	FP_WARNING_MESSAGES		0x01
229*7836SJohn.Forte@Sun.COM #define	FP_FATAL_MESSAGES		0x02
230*7836SJohn.Forte@Sun.COM 
231*7836SJohn.Forte@Sun.COM 
232*7836SJohn.Forte@Sun.COM #define	FP_IS_CLASS_1_OR_2(x)	\
233*7836SJohn.Forte@Sun.COM 	((x) == FC_TRAN_CLASS1 || (x) == FC_TRAN_CLASS2)
234*7836SJohn.Forte@Sun.COM 
235*7836SJohn.Forte@Sun.COM 
236*7836SJohn.Forte@Sun.COM /*
237*7836SJohn.Forte@Sun.COM  * Driver message control
238*7836SJohn.Forte@Sun.COM  */
239*7836SJohn.Forte@Sun.COM typedef enum fp_mesg_dest {
240*7836SJohn.Forte@Sun.COM 	FP_CONSOLE_ONLY,
241*7836SJohn.Forte@Sun.COM 	FP_LOG_ONLY,
242*7836SJohn.Forte@Sun.COM 	FP_LOG_AND_CONSOLE
243*7836SJohn.Forte@Sun.COM } fp_mesg_dest_t;
244*7836SJohn.Forte@Sun.COM 
245*7836SJohn.Forte@Sun.COM typedef struct soft_attach {
246*7836SJohn.Forte@Sun.COM 	fc_attach_cmd_t    	att_cmd;
247*7836SJohn.Forte@Sun.COM 	struct fc_local_port   	*att_port;
248*7836SJohn.Forte@Sun.COM 	boolean_t		att_need_pm_idle;
249*7836SJohn.Forte@Sun.COM } fp_soft_attach_t;
250*7836SJohn.Forte@Sun.COM 
251*7836SJohn.Forte@Sun.COM typedef struct fp_cmd {
252*7836SJohn.Forte@Sun.COM 	uint16_t	cmd_dflags;		/* DMA flags */
253*7836SJohn.Forte@Sun.COM 	ksema_t		cmd_sema;
254*7836SJohn.Forte@Sun.COM 	int		cmd_flags;		/* cmd flags */
255*7836SJohn.Forte@Sun.COM 	int		cmd_retry_count;
256*7836SJohn.Forte@Sun.COM 	int		cmd_retry_interval;	/* milli secs */
257*7836SJohn.Forte@Sun.COM 	fc_packet_t	cmd_pkt;
258*7836SJohn.Forte@Sun.COM 	fc_local_port_t	*cmd_port;
259*7836SJohn.Forte@Sun.COM 	opaque_t	cmd_private;
260*7836SJohn.Forte@Sun.COM 	struct fp_cmd	*cmd_next;
261*7836SJohn.Forte@Sun.COM 	fc_packet_t	*cmd_ulp_pkt;
262*7836SJohn.Forte@Sun.COM 	job_request_t	*cmd_job;
263*7836SJohn.Forte@Sun.COM 	int (*cmd_transport) (opaque_t fca_handle, fc_packet_t *);
264*7836SJohn.Forte@Sun.COM } fp_cmd_t;
265*7836SJohn.Forte@Sun.COM 
266*7836SJohn.Forte@Sun.COM typedef struct fp_unsol_spec {
267*7836SJohn.Forte@Sun.COM 	fc_local_port_t	*port;
268*7836SJohn.Forte@Sun.COM 	fc_unsol_buf_t	*buf;
269*7836SJohn.Forte@Sun.COM } fp_unsol_spec_t;
270*7836SJohn.Forte@Sun.COM 
271*7836SJohn.Forte@Sun.COM 
272*7836SJohn.Forte@Sun.COM #if	!defined(__lint)
273*7836SJohn.Forte@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("unique per request", fp_cmd))
274*7836SJohn.Forte@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("unique per request", soft_attach))
275*7836SJohn.Forte@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("unique per request", fp_unsol_spec))
276*7836SJohn.Forte@Sun.COM #endif	/* __lint */
277*7836SJohn.Forte@Sun.COM 
278*7836SJohn.Forte@Sun.COM /*
279*7836SJohn.Forte@Sun.COM  * Procedure templates.
280*7836SJohn.Forte@Sun.COM  */
281*7836SJohn.Forte@Sun.COM static int fp_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
282*7836SJohn.Forte@Sun.COM static int fp_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
283*7836SJohn.Forte@Sun.COM static int fp_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd,
284*7836SJohn.Forte@Sun.COM     void *arg, void **result);
285*7836SJohn.Forte@Sun.COM static int fp_power(dev_info_t *dip, int comp, int level);
286*7836SJohn.Forte@Sun.COM static int fp_open(dev_t *devp, int flag, int otype, cred_t *credp);
287*7836SJohn.Forte@Sun.COM static int fp_close(dev_t dev, int flag, int otype, cred_t *credp);
288*7836SJohn.Forte@Sun.COM static int fp_ioctl(dev_t dev, int cmd, intptr_t data, int mode,
289*7836SJohn.Forte@Sun.COM     cred_t *credp, int *rval);
290*7836SJohn.Forte@Sun.COM static int fp_attach_handler(dev_info_t *dip);
291*7836SJohn.Forte@Sun.COM static int fp_resume_handler(dev_info_t *dip);
292*7836SJohn.Forte@Sun.COM static int fp_power_up(fc_local_port_t *port);
293*7836SJohn.Forte@Sun.COM static int fp_resume_all(fc_local_port_t *port, fc_attach_cmd_t cmd);
294*7836SJohn.Forte@Sun.COM static int fp_detach_handler(fc_local_port_t *port);
295*7836SJohn.Forte@Sun.COM static int fp_suspend_handler(fc_local_port_t *port);
296*7836SJohn.Forte@Sun.COM static int fp_power_down(fc_local_port_t *port);
297*7836SJohn.Forte@Sun.COM static void fp_suspend_all(fc_local_port_t *port);
298*7836SJohn.Forte@Sun.COM static int fp_cache_constructor(void *buf, void *cdarg, int kmflags);
299*7836SJohn.Forte@Sun.COM static void fp_cache_destructor(void *buf, void *cdarg);
300*7836SJohn.Forte@Sun.COM static fp_cmd_t *fp_alloc_pkt(fc_local_port_t *port, int cmd_len,
301*7836SJohn.Forte@Sun.COM     int resp_len, int kmflags, fc_remote_port_t *pd);
302*7836SJohn.Forte@Sun.COM static void fp_free_pkt(fp_cmd_t *cmd);
303*7836SJohn.Forte@Sun.COM static void fp_free_dma(fp_cmd_t *cmd);
304*7836SJohn.Forte@Sun.COM static void fp_job_handler(fc_local_port_t *port);
305*7836SJohn.Forte@Sun.COM static int fp_port_startup(fc_local_port_t *port, job_request_t *job);
306*7836SJohn.Forte@Sun.COM static void fp_startup_done(opaque_t arg, uchar_t result);
307*7836SJohn.Forte@Sun.COM static void fp_ulp_port_attach(void *arg);
308*7836SJohn.Forte@Sun.COM static int fp_sendcmd(fc_local_port_t *port, fp_cmd_t *cmd,
309*7836SJohn.Forte@Sun.COM     opaque_t fca_handle);
310*7836SJohn.Forte@Sun.COM static void fp_resendcmd(void *port_handle);
311*7836SJohn.Forte@Sun.COM static int fp_retry_cmd(fc_packet_t *pkt);
312*7836SJohn.Forte@Sun.COM static void fp_enque_cmd(fc_local_port_t *port, fp_cmd_t *cmd);
313*7836SJohn.Forte@Sun.COM static int fp_handle_reject(fc_packet_t *pkt);
314*7836SJohn.Forte@Sun.COM static uchar_t fp_get_nextclass(fc_local_port_t *port, uchar_t cur_class);
315*7836SJohn.Forte@Sun.COM static int fp_is_class_supported(uint32_t cos, uchar_t tran_class);
316*7836SJohn.Forte@Sun.COM static fp_cmd_t *fp_deque_cmd(fc_local_port_t *port);
317*7836SJohn.Forte@Sun.COM static void fp_jobwait(job_request_t *job);
318*7836SJohn.Forte@Sun.COM int fp_state_to_rval(uchar_t state);
319*7836SJohn.Forte@Sun.COM static void fp_iodone(fp_cmd_t *cmd);
320*7836SJohn.Forte@Sun.COM static void fp_jobdone(job_request_t *job);
321*7836SJohn.Forte@Sun.COM static void fp_port_shutdown(fc_local_port_t *port, job_request_t *job);
322*7836SJohn.Forte@Sun.COM static void fp_get_loopmap(fc_local_port_t *port, job_request_t *job);
323*7836SJohn.Forte@Sun.COM static void fp_loop_online(fc_local_port_t *port, job_request_t *job,
324*7836SJohn.Forte@Sun.COM     int orphan);
325*7836SJohn.Forte@Sun.COM static int fp_get_lilpmap(fc_local_port_t *port, fc_lilpmap_t *lilp_map);
326*7836SJohn.Forte@Sun.COM static int fp_fabric_login(fc_local_port_t *port, uint32_t s_id,
327*7836SJohn.Forte@Sun.COM     job_request_t *job, int flag, int sleep);
328*7836SJohn.Forte@Sun.COM static int fp_port_login(fc_local_port_t *port, uint32_t d_id,
329*7836SJohn.Forte@Sun.COM     job_request_t *job, int cmd_flag, int sleep, fc_remote_port_t *pd,
330*7836SJohn.Forte@Sun.COM     fc_packet_t *ulp_pkt);
331*7836SJohn.Forte@Sun.COM static void fp_register_login(ddi_acc_handle_t *handle, fc_remote_port_t *pd,
332*7836SJohn.Forte@Sun.COM     la_els_logi_t *acc, uchar_t class);
333*7836SJohn.Forte@Sun.COM static void fp_remote_port_offline(fc_remote_port_t *pd);
334*7836SJohn.Forte@Sun.COM static void fp_unregister_login(fc_remote_port_t *pd);
335*7836SJohn.Forte@Sun.COM static void fp_port_offline(fc_local_port_t *port, int notify);
336*7836SJohn.Forte@Sun.COM static void fp_offline_timeout(void *port_handle);
337*7836SJohn.Forte@Sun.COM static void fp_els_init(fp_cmd_t *cmd, uint32_t s_id, uint32_t d_id,
338*7836SJohn.Forte@Sun.COM     void (*comp) (), job_request_t *job);
339*7836SJohn.Forte@Sun.COM static void fp_xlogi_init(fc_local_port_t *port, fp_cmd_t *cmd, uint32_t s_id,
340*7836SJohn.Forte@Sun.COM     uint32_t d_id, void (*intr) (), job_request_t *job, uchar_t ls_code);
341*7836SJohn.Forte@Sun.COM static void fp_logo_init(fc_remote_port_t *pd, fp_cmd_t *cmd,
342*7836SJohn.Forte@Sun.COM     job_request_t *job);
343*7836SJohn.Forte@Sun.COM static void fp_adisc_init(fp_cmd_t *cmd, job_request_t *job);
344*7836SJohn.Forte@Sun.COM static int fp_ulp_statec_cb(fc_local_port_t *port, uint32_t state,
345*7836SJohn.Forte@Sun.COM     fc_portmap_t *changelist, uint32_t listlen, uint32_t alloc_len, int sleep);
346*7836SJohn.Forte@Sun.COM static int fp_ulp_devc_cb(fc_local_port_t *port, fc_portmap_t *changelist,
347*7836SJohn.Forte@Sun.COM     uint32_t listlen, uint32_t alloc_len, int sleep, int sync);
348*7836SJohn.Forte@Sun.COM static void fp_plogi_group(fc_local_port_t *port, job_request_t *job);
349*7836SJohn.Forte@Sun.COM static void fp_ns_init(fc_local_port_t *port, job_request_t *job, int sleep);
350*7836SJohn.Forte@Sun.COM static void fp_ns_fini(fc_local_port_t *port, job_request_t *job);
351*7836SJohn.Forte@Sun.COM static int fp_ns_reg(fc_local_port_t *port, fc_remote_port_t *pd,
352*7836SJohn.Forte@Sun.COM     uint16_t cmd_code, job_request_t *job, int polled, int sleep);
353*7836SJohn.Forte@Sun.COM static int fp_common_intr(fc_packet_t *pkt, int iodone);
354*7836SJohn.Forte@Sun.COM static void fp_flogi_intr(fc_packet_t *pkt);
355*7836SJohn.Forte@Sun.COM static void fp_plogi_intr(fc_packet_t *pkt);
356*7836SJohn.Forte@Sun.COM static void fp_adisc_intr(fc_packet_t *pkt);
357*7836SJohn.Forte@Sun.COM static void fp_logo_intr(fc_packet_t *pkt);
358*7836SJohn.Forte@Sun.COM static void fp_rls_intr(fc_packet_t *pkt);
359*7836SJohn.Forte@Sun.COM static void fp_rnid_intr(fc_packet_t *pkt);
360*7836SJohn.Forte@Sun.COM static int  fp_send_rnid(fc_local_port_t *port, intptr_t data, int mode,
361*7836SJohn.Forte@Sun.COM     fcio_t *fcio, la_wwn_t *pwwn);
362*7836SJohn.Forte@Sun.COM static int  fp_get_rnid(fc_local_port_t *port, intptr_t data, int mode,
363*7836SJohn.Forte@Sun.COM     fcio_t *fcio);
364*7836SJohn.Forte@Sun.COM static int  fp_set_rnid(fc_local_port_t *port, intptr_t data, int mode,
365*7836SJohn.Forte@Sun.COM     fcio_t *fcio);
366*7836SJohn.Forte@Sun.COM static void fp_intr(fc_packet_t *pkt);
367*7836SJohn.Forte@Sun.COM static void fp_statec_cb(opaque_t port_handle, uint32_t state);
368*7836SJohn.Forte@Sun.COM static int fp_ns_scr(fc_local_port_t *port, job_request_t *job,
369*7836SJohn.Forte@Sun.COM     uchar_t scr_func, int sleep);
370*7836SJohn.Forte@Sun.COM static int fp_ns_get_devcount(fc_local_port_t *port, job_request_t *job,
371*7836SJohn.Forte@Sun.COM     int create, int sleep);
372*7836SJohn.Forte@Sun.COM static int fp_fciocmd(fc_local_port_t *port, intptr_t data, int mode,
373*7836SJohn.Forte@Sun.COM     fcio_t *fcio);
374*7836SJohn.Forte@Sun.COM static int fp_copyout(void *from, void *to, size_t len, int mode);
375*7836SJohn.Forte@Sun.COM static int fp_fcio_copyout(fcio_t *fcio, intptr_t data, int mode);
376*7836SJohn.Forte@Sun.COM static void fp_p2p_online(fc_local_port_t *port, job_request_t *job);
377*7836SJohn.Forte@Sun.COM static int fp_fillout_p2pmap(fc_local_port_t *port, fcio_t *fcio, int mode);
378*7836SJohn.Forte@Sun.COM static void fp_fabric_online(fc_local_port_t *port, job_request_t *job);
379*7836SJohn.Forte@Sun.COM static int fp_fillout_loopmap(fc_local_port_t *port, fcio_t *fcio, int mode);
380*7836SJohn.Forte@Sun.COM static void fp_unsol_intr(fc_packet_t *pkt);
381*7836SJohn.Forte@Sun.COM static void fp_linit_intr(fc_packet_t *pkt);
382*7836SJohn.Forte@Sun.COM static void fp_unsol_cb(opaque_t port_handle, fc_unsol_buf_t *buf,
383*7836SJohn.Forte@Sun.COM     uint32_t type);
384*7836SJohn.Forte@Sun.COM static void fp_handle_unsol_buf(fc_local_port_t *port, fc_unsol_buf_t *buf,
385*7836SJohn.Forte@Sun.COM     job_request_t *job);
386*7836SJohn.Forte@Sun.COM static void fp_ba_rjt_init(fc_local_port_t *port, fp_cmd_t *cmd,
387*7836SJohn.Forte@Sun.COM     fc_unsol_buf_t *buf, job_request_t *job);
388*7836SJohn.Forte@Sun.COM static void fp_els_rjt_init(fc_local_port_t *port, fp_cmd_t *cmd,
389*7836SJohn.Forte@Sun.COM     fc_unsol_buf_t *buf, uchar_t action, uchar_t reason, job_request_t *job);
390*7836SJohn.Forte@Sun.COM static void fp_els_acc_init(fc_local_port_t *port, fp_cmd_t *cmd,
391*7836SJohn.Forte@Sun.COM     fc_unsol_buf_t *buf, job_request_t *job);
392*7836SJohn.Forte@Sun.COM static void fp_handle_unsol_logo(fc_local_port_t *port, fc_unsol_buf_t *buf,
393*7836SJohn.Forte@Sun.COM     fc_remote_port_t *pd, job_request_t *job);
394*7836SJohn.Forte@Sun.COM static void fp_handle_unsol_prlo(fc_local_port_t *port, fc_unsol_buf_t *buf,
395*7836SJohn.Forte@Sun.COM     fc_remote_port_t *pd, job_request_t *job);
396*7836SJohn.Forte@Sun.COM static void fp_unsol_resp_init(fc_packet_t *pkt, fc_unsol_buf_t *buf,
397*7836SJohn.Forte@Sun.COM     uchar_t r_ctl, uchar_t type);
398*7836SJohn.Forte@Sun.COM static void fp_i_handle_unsol_els(fc_local_port_t *port, fc_unsol_buf_t *buf);
399*7836SJohn.Forte@Sun.COM static void fp_handle_unsol_plogi(fc_local_port_t *port, fc_unsol_buf_t *buf,
400*7836SJohn.Forte@Sun.COM     job_request_t *job, int sleep);
401*7836SJohn.Forte@Sun.COM static void fp_handle_unsol_flogi(fc_local_port_t *port, fc_unsol_buf_t *buf,
402*7836SJohn.Forte@Sun.COM     job_request_t *job, int sleep);
403*7836SJohn.Forte@Sun.COM static void fp_login_acc_init(fc_local_port_t *port, fp_cmd_t *cmd,
404*7836SJohn.Forte@Sun.COM     fc_unsol_buf_t *buf, job_request_t *job, int sleep);
405*7836SJohn.Forte@Sun.COM static void fp_handle_unsol_rscn(fc_local_port_t *port, fc_unsol_buf_t *buf,
406*7836SJohn.Forte@Sun.COM     job_request_t *job, int sleep);
407*7836SJohn.Forte@Sun.COM static void fp_fillout_old_map_held(fc_portmap_t *map, fc_remote_port_t *pd,
408*7836SJohn.Forte@Sun.COM     uchar_t flag);
409*7836SJohn.Forte@Sun.COM static void fp_fillout_old_map(fc_portmap_t *map, fc_remote_port_t *pd,
410*7836SJohn.Forte@Sun.COM     uchar_t flag);
411*7836SJohn.Forte@Sun.COM static void fp_fillout_changed_map(fc_portmap_t *map, fc_remote_port_t *pd,
412*7836SJohn.Forte@Sun.COM     uint32_t *new_did, la_wwn_t *new_pwwn);
413*7836SJohn.Forte@Sun.COM static void fp_fillout_new_nsmap(fc_local_port_t *port,
414*7836SJohn.Forte@Sun.COM     ddi_acc_handle_t *handle, fc_portmap_t *port_map, ns_resp_gan_t *gan_resp,
415*7836SJohn.Forte@Sun.COM     uint32_t d_id);
416*7836SJohn.Forte@Sun.COM static int fp_remote_lip(fc_local_port_t *port, la_wwn_t *pwwn, int sleep,
417*7836SJohn.Forte@Sun.COM     job_request_t *job);
418*7836SJohn.Forte@Sun.COM static void fp_stuff_device_with_gan(ddi_acc_handle_t *handle,
419*7836SJohn.Forte@Sun.COM     fc_remote_port_t *pd, ns_resp_gan_t *gan_resp);
420*7836SJohn.Forte@Sun.COM static int fp_ns_query(fc_local_port_t *port, fctl_ns_req_t *ns_cmd,
421*7836SJohn.Forte@Sun.COM     job_request_t *job, int polled, int sleep);
422*7836SJohn.Forte@Sun.COM static void fp_ct_init(fc_local_port_t *port, fp_cmd_t *cmd,
423*7836SJohn.Forte@Sun.COM     fctl_ns_req_t *ns_cmd, uint16_t cmd_code, caddr_t cmd_buf,
424*7836SJohn.Forte@Sun.COM     uint16_t cmd_len, uint16_t resp_len, job_request_t *job);
425*7836SJohn.Forte@Sun.COM static void fp_ns_intr(fc_packet_t *pkt);
426*7836SJohn.Forte@Sun.COM static void fp_gan_handler(fc_packet_t *pkt, fctl_ns_req_t *ns_cmd);
427*7836SJohn.Forte@Sun.COM static void fp_ns_query_handler(fc_packet_t *pkt, fctl_ns_req_t *ns_cmd);
428*7836SJohn.Forte@Sun.COM static void fp_handle_unsol_adisc(fc_local_port_t *port, fc_unsol_buf_t *buf,
429*7836SJohn.Forte@Sun.COM     fc_remote_port_t *pd, job_request_t *job);
430*7836SJohn.Forte@Sun.COM static void fp_adisc_acc_init(fc_local_port_t *port, fp_cmd_t *cmd,
431*7836SJohn.Forte@Sun.COM     fc_unsol_buf_t *buf, job_request_t *job);
432*7836SJohn.Forte@Sun.COM static void fp_load_ulp_modules(dev_info_t *dip, fc_local_port_t *port);
433*7836SJohn.Forte@Sun.COM static int fp_logout(fc_local_port_t *port, fc_remote_port_t *pd,
434*7836SJohn.Forte@Sun.COM     job_request_t *job);
435*7836SJohn.Forte@Sun.COM static void fp_attach_ulps(fc_local_port_t *port, fc_attach_cmd_t cmd);
436*7836SJohn.Forte@Sun.COM static int fp_ulp_notify(fc_local_port_t *port, uint32_t statec, int sleep);
437*7836SJohn.Forte@Sun.COM static int fp_ns_getmap(fc_local_port_t *port, job_request_t *job,
438*7836SJohn.Forte@Sun.COM     fc_portmap_t **map, uint32_t *len, uint32_t sid);
439*7836SJohn.Forte@Sun.COM static fc_remote_port_t *fp_create_remote_port_by_ns(fc_local_port_t *port,
440*7836SJohn.Forte@Sun.COM     uint32_t d_id, int sleep);
441*7836SJohn.Forte@Sun.COM static int fp_check_perms(uchar_t open_flag, uint16_t ioctl_cmd);
442*7836SJohn.Forte@Sun.COM static int fp_bind_callbacks(fc_local_port_t *port);
443*7836SJohn.Forte@Sun.COM static void fp_retrieve_caps(fc_local_port_t *port);
444*7836SJohn.Forte@Sun.COM static void fp_validate_area_domain(fc_local_port_t *port, uint32_t id,
445*7836SJohn.Forte@Sun.COM     uint32_t mask, job_request_t *job, int sleep);
446*7836SJohn.Forte@Sun.COM static void fp_validate_rscn_page(fc_local_port_t *port, fc_affected_id_t *page,
447*7836SJohn.Forte@Sun.COM     job_request_t *job, fctl_ns_req_t *ns_cmd, fc_portmap_t *listptr,
448*7836SJohn.Forte@Sun.COM     int *listindex, int sleep);
449*7836SJohn.Forte@Sun.COM static int fp_ns_validate_device(fc_local_port_t *port, fc_remote_port_t *pd,
450*7836SJohn.Forte@Sun.COM     job_request_t *job, int polled, int sleep);
451*7836SJohn.Forte@Sun.COM static int fp_validate_lilp_map(fc_lilpmap_t *lilp_map);
452*7836SJohn.Forte@Sun.COM static int fp_is_valid_alpa(uchar_t al_pa);
453*7836SJohn.Forte@Sun.COM static void fp_ulp_unsol_cb(void *arg);
454*7836SJohn.Forte@Sun.COM static void fp_printf(fc_local_port_t *port, int level, fp_mesg_dest_t dest,
455*7836SJohn.Forte@Sun.COM     int fc_errno, fc_packet_t *pkt, const char *fmt, ...);
456*7836SJohn.Forte@Sun.COM static int fp_fcio_logout(fc_local_port_t *port, fcio_t *fcio,
457*7836SJohn.Forte@Sun.COM     job_request_t *job);
458*7836SJohn.Forte@Sun.COM static int fp_fcio_login(fc_local_port_t *port, fcio_t *fcio,
459*7836SJohn.Forte@Sun.COM     job_request_t *job);
460*7836SJohn.Forte@Sun.COM 
461*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
462*7836SJohn.Forte@Sun.COM }
463*7836SJohn.Forte@Sun.COM #endif
464*7836SJohn.Forte@Sun.COM 
465*7836SJohn.Forte@Sun.COM #endif	/* _FP_H */
466