xref: /titanic_44/usr/src/uts/common/sys/fibre-channel/ulp/fcsm.h (revision 7ff836697c120cb94bd30d5c2204eb9b74718e4c)
1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte /*
22*7ff83669SZhong Wang  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23fcf3ce44SJohn Forte  * Use is subject to license terms.
24fcf3ce44SJohn Forte  */
25fcf3ce44SJohn Forte 
26fcf3ce44SJohn Forte #ifndef	_FCSM_H
27fcf3ce44SJohn Forte #define	_FCSM_H
28fcf3ce44SJohn Forte 
29fcf3ce44SJohn Forte #ifdef	__cplusplus
30fcf3ce44SJohn Forte extern "C" {
31fcf3ce44SJohn Forte #endif
32fcf3ce44SJohn Forte 
33fcf3ce44SJohn Forte #ifdef _KERNEL
34fcf3ce44SJohn Forte 
35fcf3ce44SJohn Forte /*
36fcf3ce44SJohn Forte  * Message printing flags
37fcf3ce44SJohn Forte  */
38fcf3ce44SJohn Forte #define	SM_LOG			1
39fcf3ce44SJohn Forte #define	SM_CONSOLE		2
40fcf3ce44SJohn Forte #define	SM_LOG_AND_CONSOLE	3
41fcf3ce44SJohn Forte 
42fcf3ce44SJohn Forte /*
43fcf3ce44SJohn Forte  * Debug levels
44fcf3ce44SJohn Forte  */
45fcf3ce44SJohn Forte #define	SMDL_TRACE	0x0001
46fcf3ce44SJohn Forte #define	SMDL_IO		0x0002
47fcf3ce44SJohn Forte #define	SMDL_ERR	0x0004
48fcf3ce44SJohn Forte #define	SMDL_INFO	0x0008
49fcf3ce44SJohn Forte 
50fcf3ce44SJohn Forte #ifdef	DEBUG
51fcf3ce44SJohn Forte #define	FCSM_DEBUG(level, args)	\
52fcf3ce44SJohn Forte 	if (fcsm_debug & (level))	fcsm_display args
53fcf3ce44SJohn Forte 
54fcf3ce44SJohn Forte extern uint32_t fcsm_debug;
55fcf3ce44SJohn Forte #else /* DEBUG */
56fcf3ce44SJohn Forte #define	FCSM_DEBUG(level, args)
57fcf3ce44SJohn Forte #endif /* DEBUG */
58fcf3ce44SJohn Forte 
59fcf3ce44SJohn Forte #define	FCSM_INIT_INSTANCES	8	/* # of instances for soft_state_init */
60fcf3ce44SJohn Forte /*
61fcf3ce44SJohn Forte  * Open flags
62fcf3ce44SJohn Forte  */
63fcf3ce44SJohn Forte #define	FCSM_IDLE		0x00
64fcf3ce44SJohn Forte #define	FCSM_OPEN		0x01
65fcf3ce44SJohn Forte #define	FCSM_EXCL		0x02
66fcf3ce44SJohn Forte 
67fcf3ce44SJohn Forte #define	FCSM_ELS_TIMEOUT	(20)	/* secs */
68fcf3ce44SJohn Forte #define	FCSM_MS_TIMEOUT		(20)	/* secs */
69fcf3ce44SJohn Forte 
70fcf3ce44SJohn Forte #define	FCSM_OFFLINE_TICKER	(120)	/* secs */
71fcf3ce44SJohn Forte 
72fcf3ce44SJohn Forte /* Definitions for command retries */
73fcf3ce44SJohn Forte #define	FCSM_MAX_CMD_RETRIES	5	/* Max retries in case of failure */
74fcf3ce44SJohn Forte #define	FCSM_RETRY_INTERVAL	3	/* Retry interval in seconds */
75fcf3ce44SJohn Forte #define	FCSM_RETRY_TICKER	1	/* Retry thread execution interval */
76fcf3ce44SJohn Forte 
77fcf3ce44SJohn Forte #define	FCSM_MAX_JOB_RETRIES	3	/* Max retries in case of job failure */
78fcf3ce44SJohn Forte 
79fcf3ce44SJohn Forte /*
80fcf3ce44SJohn Forte  * fcsm_job - Job structure to issue commands using command thread
81fcf3ce44SJohn Forte  */
82fcf3ce44SJohn Forte typedef struct fcsm_job {
83fcf3ce44SJohn Forte 	uint32_t	job_code;		/* Command code */
84fcf3ce44SJohn Forte 	uint32_t	job_flags;		/* Command Flags */
85fcf3ce44SJohn Forte 	int		job_port_instance;	/* port driver instance */
86fcf3ce44SJohn Forte 	int		job_result;		/* job completion result */
87fcf3ce44SJohn Forte 	opaque_t	job_arg;		/* Command Arguments */
88fcf3ce44SJohn Forte 	opaque_t	job_caller_priv;	/* Caller private */
89fcf3ce44SJohn Forte 	void		(*job_comp)(opaque_t, struct fcsm_job *, int);
90fcf3ce44SJohn Forte 						/* completion func */
91fcf3ce44SJohn Forte 	opaque_t	job_comp_arg;		/* Arg for completion func */
92fcf3ce44SJohn Forte 	kmutex_t	job_mutex;		/* per command mutex */
93fcf3ce44SJohn Forte 	ksema_t		job_sema;		/* To wait for completion */
94fcf3ce44SJohn Forte 	struct fcsm_job	*job_next;		/* for linked list */
95fcf3ce44SJohn Forte 	int		job_retry_count;	/* Retry count */
96fcf3ce44SJohn Forte 	void		*job_priv;		/* for fcsm private use	 */
97fcf3ce44SJohn Forte 	uint32_t	job_priv_flags;		/* fcsm private flags */
98fcf3ce44SJohn Forte } fcsm_job_t;
99fcf3ce44SJohn Forte 
100fcf3ce44SJohn Forte /*
101fcf3ce44SJohn Forte  * fcsm_t - FCSM Structure for per port information
102fcf3ce44SJohn Forte  */
103fcf3ce44SJohn Forte typedef struct fcsm {
104fcf3ce44SJohn Forte 	kmutex_t		sm_mutex;	/* mutex for protection */
105fcf3ce44SJohn Forte 	struct fcsm		*sm_next;	/* for global linked list */
106fcf3ce44SJohn Forte 	int			sm_sid;		/* FCA Port ID */
107fcf3ce44SJohn Forte 	int			sm_instance;	/* fc port instance number */
108fcf3ce44SJohn Forte 	uint32_t		sm_port_state;	/* FCA port state */
109fcf3ce44SJohn Forte 	uint32_t		sm_port_top;	/* Port topology */
110fcf3ce44SJohn Forte 	uint32_t		sm_state;	/* San Mgmt State information */
111fcf3ce44SJohn Forte 	uint32_t		sm_flags;	/* San Mgmt Flags (see below) */
112fcf3ce44SJohn Forte 	int			sm_ncmds;	/* # of pending commands */
113fcf3ce44SJohn Forte 	int			sm_cb_count;	/* # callbacks in progress */
114fcf3ce44SJohn Forte 	fc_ulp_port_info_t	sm_port_info;	/* FCA Port Information */
115fcf3ce44SJohn Forte 	fcsm_job_t		*sm_job_head;	/* port's job queue head */
116fcf3ce44SJohn Forte 	fcsm_job_t		*sm_job_tail;	/* port's job queue tail */
117fcf3ce44SJohn Forte 	struct fcsm_cmd		*sm_retry_head;	/* cmd retry queue head */
118fcf3ce44SJohn Forte 	struct fcsm_cmd		*sm_retry_tail;	/* cmd retry queue tail */
119fcf3ce44SJohn Forte 	timeout_id_t		sm_retry_tid;	/* retry timer */
120fcf3ce44SJohn Forte 	timeout_id_t		sm_offline_tid;	/* offline timer */
121fcf3ce44SJohn Forte 	kcondvar_t		sm_job_cv;	/* cv for job processing */
122fcf3ce44SJohn Forte 	uint32_t		sm_dev_count;	/* # of devices discovered */
123fcf3ce44SJohn Forte 	fc_portmap_t		*sm_portmap;	/* device map */
124fcf3ce44SJohn Forte 	kthread_t		*sm_thread;	/* per port job thread */
125fcf3ce44SJohn Forte 	kmem_cache_t		*sm_cmd_cache;	/* per port fc packet cache */
126fcf3ce44SJohn Forte 	la_els_logi_t		sm_ms_service_params;
127fcf3ce44SJohn Forte 						/* Mgmt Server Login Params */
128fcf3ce44SJohn Forte 	callb_cpr_t		sm_cpr_info;	/* CPR info */
129fcf3ce44SJohn Forte } fcsm_t;
130fcf3ce44SJohn Forte 
131fcf3ce44SJohn Forte 
132fcf3ce44SJohn Forte typedef struct fcsm_cmd {
133fcf3ce44SJohn Forte 	fc_packet_t	*cmd_fp_pkt;
134fcf3ce44SJohn Forte 	fcsm_job_t	*cmd_job;
135fcf3ce44SJohn Forte 	fcsm_t		*cmd_fcsm;
136fcf3ce44SJohn Forte 	int		cmd_retry_count;
137fcf3ce44SJohn Forte 	int		cmd_retry_interval;
138fcf3ce44SJohn Forte 	int		cmd_max_retries;
139fcf3ce44SJohn Forte 	struct fcsm_cmd	*cmd_next;
140fcf3ce44SJohn Forte 	void		(*cmd_comp)(struct fcsm_cmd *);
141fcf3ce44SJohn Forte 	int		(*cmd_transport)(opaque_t, fc_packet_t *);
142fcf3ce44SJohn Forte 	uint32_t	cmd_dma_flags;
143fcf3ce44SJohn Forte 	fc_packet_t	cmd_fc_packet;
144fcf3ce44SJohn Forte } fcsm_cmd_t;
145fcf3ce44SJohn Forte 
146fcf3ce44SJohn Forte /*
147fcf3ce44SJohn Forte  * sm_flags in the per port FCSM Structure
148fcf3ce44SJohn Forte  */
149fcf3ce44SJohn Forte #define	FCSM_ATTACHING			0x0001
150fcf3ce44SJohn Forte #define	FCSM_ATTACHED			0x0002
151fcf3ce44SJohn Forte #define	FCSM_DETACHING			0x0004
152fcf3ce44SJohn Forte #define	FCSM_DETACHED			0x0008
153fcf3ce44SJohn Forte #define	FCSM_SUSPENDED			0x0010
154fcf3ce44SJohn Forte #define	FCSM_POWER_DOWN			0x0020
155fcf3ce44SJohn Forte #define	FCSM_RESTORE_RETRY_TIMEOUT	0x0040
156fcf3ce44SJohn Forte #define	FCSM_RESTORE_OFFLINE_TIMEOUT	0x0080
157fcf3ce44SJohn Forte #define	FCSM_RETRY_TIMER_ACTIVE		0x0100
158fcf3ce44SJohn Forte #define	FCSM_SERIALIZE_JOBTHREAD	0x0200
159fcf3ce44SJohn Forte #define	FCSM_CMD_RETRY_Q_SUSPENDED	0x0400
160fcf3ce44SJohn Forte #define	FCSM_PORT_OFFLINE		0x0800
161fcf3ce44SJohn Forte #define	FCSM_LINK_DOWN			0x1000
162fcf3ce44SJohn Forte #define	FCSM_MGMT_SERVER_LOGGED_IN	0x2000
163fcf3ce44SJohn Forte #define	FCSM_MGMT_SERVER_LOGIN_IN_PROG	0x4000
164*7ff83669SZhong Wang #define	FCSM_USING_NODMA_FCA		0x8000
165fcf3ce44SJohn Forte 
166fcf3ce44SJohn Forte /* Command flags for Job structure */
167fcf3ce44SJohn Forte #define	FCSM_JOBFLAG_SYNC		0x01
168fcf3ce44SJohn Forte #define	FCSM_JOBFLAG_ASYNC		0x02
169fcf3ce44SJohn Forte #define	FCSM_JOBFLAG_SERIALIZE		0x04
170fcf3ce44SJohn Forte #define	FCSM_JOBFLAG_CTHEADER_BE	0X08
171fcf3ce44SJohn Forte 
172fcf3ce44SJohn Forte /* Command codes */
173fcf3ce44SJohn Forte #define	FCSM_JOB_NONE			0x00
174fcf3ce44SJohn Forte #define	FCSM_JOB_THREAD_SHUTDOWN	0x01
175fcf3ce44SJohn Forte #define	FCSM_JOB_LOGIN_NAME_SERVER	0x02
176fcf3ce44SJohn Forte #define	FCSM_JOB_LOGIN_MGMT_SERVER	0x03
177fcf3ce44SJohn Forte #define	FCSM_JOB_CT_PASSTHRU		0x04
178fcf3ce44SJohn Forte 
179fcf3ce44SJohn Forte /* Private flags for command */
180fcf3ce44SJohn Forte #define	FCSM_JOB_PRIV_WAIT_FOR_LOGIN	0x01
181fcf3ce44SJohn Forte #define	FCSM_JOB_PRIV_LOGIN_IN_PROG	0x02
182fcf3ce44SJohn Forte 
183fcf3ce44SJohn Forte /* Command DMA Flags */
184fcf3ce44SJohn Forte #define	FCSM_CF_CMD_VALID_DMA_MEM	0x01
185fcf3ce44SJohn Forte #define	FCSM_CF_CMD_VALID_DMA_BIND	0x02
186fcf3ce44SJohn Forte #define	FCSM_CF_RESP_VALID_DMA_MEM	0x04
187fcf3ce44SJohn Forte #define	FCSM_CF_RESP_VALID_DMA_BIND	0x08
188fcf3ce44SJohn Forte 
189fcf3ce44SJohn Forte #define	FCSM_INIT_CMD(cmd, job, tran_flags, tran_type, max_retries, func) { \
190fcf3ce44SJohn Forte 	(cmd)->cmd_job = (job); \
191fcf3ce44SJohn Forte 	(cmd)->cmd_fc_packet.pkt_tran_flags = (tran_flags); \
192fcf3ce44SJohn Forte 	(cmd)->cmd_fc_packet.pkt_tran_type = (tran_type); \
193fcf3ce44SJohn Forte 	(cmd)->cmd_max_retries = max_retries; \
194fcf3ce44SJohn Forte 	(cmd)->cmd_comp = func; \
195fcf3ce44SJohn Forte }
196fcf3ce44SJohn Forte 
197fcf3ce44SJohn Forte /*
198fcf3ce44SJohn Forte  * Macros to address endian issues
199*7ff83669SZhong Wang  * local variable "fcsm" must exist before using these
200fcf3ce44SJohn Forte  */
201*7ff83669SZhong Wang #define	FCSM_REP_RD(handle, hostaddr, devaddr, cnt)			\
202*7ff83669SZhong Wang 	{								\
203*7ff83669SZhong Wang 		if (!((fcsm)->sm_flags & FCSM_USING_NODMA_FCA)) {	\
204*7ff83669SZhong Wang 			ddi_rep_get8((handle), (uint8_t *)(hostaddr),	\
205*7ff83669SZhong Wang 				    (uint8_t *)(devaddr), (cnt),	\
206*7ff83669SZhong Wang 				    DDI_DEV_AUTOINCR);			\
207*7ff83669SZhong Wang 		} else {						\
208*7ff83669SZhong Wang 			bcopy((devaddr), (hostaddr), (cnt));		\
209*7ff83669SZhong Wang 		}							\
210*7ff83669SZhong Wang 	}
211fcf3ce44SJohn Forte 
212*7ff83669SZhong Wang #define	FCSM_REP_WR(handle, hostaddr, devaddr, cnt)			\
213*7ff83669SZhong Wang 	{								\
214*7ff83669SZhong Wang 		if (!((fcsm)->sm_flags & FCSM_USING_NODMA_FCA)) {	\
215*7ff83669SZhong Wang 			ddi_rep_put8((handle), (uint8_t *)(hostaddr),	\
216*7ff83669SZhong Wang 				    (uint8_t *)(devaddr), (cnt),	\
217*7ff83669SZhong Wang 				    DDI_DEV_AUTOINCR);			\
218*7ff83669SZhong Wang 		} else {						\
219*7ff83669SZhong Wang 			bcopy((hostaddr), (devaddr), (cnt));		\
220*7ff83669SZhong Wang 		}							\
221*7ff83669SZhong Wang 	}
222fcf3ce44SJohn Forte 
223fcf3ce44SJohn Forte #endif /* _KERNEL */
224fcf3ce44SJohn Forte 
225fcf3ce44SJohn Forte /*
226fcf3ce44SJohn Forte  * IOCTL Definitions
227fcf3ce44SJohn Forte  */
228fcf3ce44SJohn Forte typedef struct fc_ct_aiu {
229fcf3ce44SJohn Forte 	fc_ct_header_t	aiu_header;
230fcf3ce44SJohn Forte 	char		aiu_payload[1];
231fcf3ce44SJohn Forte 	/* aiu_payload can be up to 'm' bytes (arbitrary length) */
232fcf3ce44SJohn Forte } fc_ct_aiu_t;
233fcf3ce44SJohn Forte 
234fcf3ce44SJohn Forte #define	FCSMIO			('S' << 8)
235fcf3ce44SJohn Forte #define	FCSMIO_CMD		(FCSMIO | 2000)
236fcf3ce44SJohn Forte 
237fcf3ce44SJohn Forte #define	FCSMIO_SUB_CMD		('Y' << 8)
238fcf3ce44SJohn Forte #define	FCSMIO_CT_CMD		(FCSMIO_SUB_CMD + 0x01)
239fcf3ce44SJohn Forte #define	FCSMIO_ADAPTER_LIST	(FCSMIO_SUB_CMD + 0x02)
240fcf3ce44SJohn Forte #define	FCSMIO_FIND_ADAPTER	(FCSMIO_SUB_CMD + 0x03)
241fcf3ce44SJohn Forte 
242fcf3ce44SJohn Forte #define	FCSM_MAX_CT_SIZE	(65536)		/* 64K */
243fcf3ce44SJohn Forte 
244fcf3ce44SJohn Forte /* Management Server - Fabric Configuration Server Commands */
245fcf3ce44SJohn Forte #define	MS_CS_GTIN	0x0100	/* Get Topology Information */
246fcf3ce44SJohn Forte #define	MS_CS_GIEL	0x0101	/* Get Interconnect Element List */
247fcf3ce44SJohn Forte #define	MS_CS_GIET	0x0111	/* Get Interconnect Element Type */
248fcf3ce44SJohn Forte #define	MS_CS_GDID	0x0112	/* Get Domain Identifier */
249fcf3ce44SJohn Forte #define	MS_CS_GMID	0x0113	/* Get Management Identifier */
250fcf3ce44SJohn Forte #define	MS_CS_GFN	0x0114	/* Get Fabric Name */
251fcf3ce44SJohn Forte #define	MS_CS_GIELN	0x0115	/* Get Interconnect Element Logical Name */
252fcf3ce44SJohn Forte #define	MS_CS_GMAL	0x0116	/* Get Management Address List */
253fcf3ce44SJohn Forte #define	MS_CS_GIEIL	0x0117	/* Get Interconnect Element Information List */
254fcf3ce44SJohn Forte #define	MS_CS_GPL	0x0118	/* Get Port List */
255fcf3ce44SJohn Forte #define	MS_CS_GPT	0x0121	/* Get Port Type */
256fcf3ce44SJohn Forte #define	MS_CS_GPPN	0x0122	/* Get Physical Port Number */
257fcf3ce44SJohn Forte #define	MS_CS_GAPNL	0x0124	/* Get Attached Port Name List */
258fcf3ce44SJohn Forte #define	MS_CS_GPS	0x0126	/* Get Port State */
259fcf3ce44SJohn Forte #define	MS_CS_GATIN	0x0128	/* Get Attached Topology Information */
260fcf3ce44SJohn Forte #define	MS_CS_GPLNL	0x0191	/* Get Platform Node Name List */
261fcf3ce44SJohn Forte #define	MS_CS_GPLT	0x0192	/* Get Platform Type */
262fcf3ce44SJohn Forte #define	MS_CS_GPLML	0x0193	/* Get Platform Management Address List */
263fcf3ce44SJohn Forte #define	MS_CS_GNPL	0x01a1	/* Get Platform Name - Node Name */
264fcf3ce44SJohn Forte #define	MS_CS_GPNL	0x01a2	/* Get Platform Name List */
265fcf3ce44SJohn Forte #define	MS_CS_GNID	0x01b1	/* Get Node Identification Data - Node Name */
266fcf3ce44SJohn Forte #define	MS_CS_RIELN	0x0215	/* Register Interconnect Element Logical Name */
267fcf3ce44SJohn Forte #define	MS_CS_RPL	0x0280	/* Register Platform */
268fcf3ce44SJohn Forte #define	MS_CS_RPLN	0x0291	/* Register Platform Name */
269fcf3ce44SJohn Forte #define	MS_CS_RPLT	0x0292	/* Register Platform Type */
270fcf3ce44SJohn Forte #define	MS_CS_RPLM	0x0293	/* Register Platform Management Address */
271fcf3ce44SJohn Forte #define	MS_CS_DPL	0x0380	/* Deregister Platform */
272fcf3ce44SJohn Forte #define	MS_CS_DPLN	0x0391	/* Deregister Platform Node Name */
273fcf3ce44SJohn Forte #define	MS_CS_DPLML	0x0393	/* Deregister Platform Management Addr List */
274fcf3ce44SJohn Forte 
275fcf3ce44SJohn Forte #ifdef _KERNEL
276fcf3ce44SJohn Forte 
277fcf3ce44SJohn Forte /*
278fcf3ce44SJohn Forte  * Driver entry point functions
279fcf3ce44SJohn Forte  */
280fcf3ce44SJohn Forte static int	fcsm_attach(dev_info_t *, ddi_attach_cmd_t);
281fcf3ce44SJohn Forte static int	fcsm_detach(dev_info_t *, ddi_detach_cmd_t);
282fcf3ce44SJohn Forte static int	fcsm_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
283fcf3ce44SJohn Forte static int	fcsm_open(dev_t *, int, int, cred_t *);
284fcf3ce44SJohn Forte static int	fcsm_close(dev_t, int, int, cred_t *);
285fcf3ce44SJohn Forte static int	fcsm_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
286fcf3ce44SJohn Forte 
287fcf3ce44SJohn Forte /*
288fcf3ce44SJohn Forte  * FC Transport functions
289fcf3ce44SJohn Forte  */
290fcf3ce44SJohn Forte static int	fcsm_port_attach(opaque_t, fc_ulp_port_info_t *,
291fcf3ce44SJohn Forte 		    fc_attach_cmd_t, uint32_t);
292fcf3ce44SJohn Forte static int	fcsm_port_detach(opaque_t, fc_ulp_port_info_t *,
293fcf3ce44SJohn Forte 		    fc_detach_cmd_t);
294fcf3ce44SJohn Forte static int	fcsm_port_ioctl(opaque_t, opaque_t, dev_t, int, intptr_t,
295fcf3ce44SJohn Forte 		    int, cred_t *, int *, uint32_t);
296fcf3ce44SJohn Forte static void	fcsm_statec_cb(opaque_t, opaque_t, uint32_t, uint32_t,
297fcf3ce44SJohn Forte 		    fc_portmap_t *, uint32_t, uint32_t);
298fcf3ce44SJohn Forte static int	fcsm_els_cb(opaque_t, opaque_t, fc_unsol_buf_t *, uint32_t);
299fcf3ce44SJohn Forte static int	fcsm_data_cb(opaque_t, opaque_t, fc_unsol_buf_t *, uint32_t);
300fcf3ce44SJohn Forte 
301fcf3ce44SJohn Forte /*
302fcf3ce44SJohn Forte  * Internal functions
303fcf3ce44SJohn Forte  */
304fcf3ce44SJohn Forte static int	fcsm_handle_port_attach(fc_ulp_port_info_t *, uint32_t, int);
305fcf3ce44SJohn Forte static int	fcsm_handle_port_resume(opaque_t, fc_ulp_port_info_t *,
306fcf3ce44SJohn Forte 		    fc_attach_cmd_t, uint32_t, fcsm_t *);
307fcf3ce44SJohn Forte static int	fcsm_handle_port_detach(fc_ulp_port_info_t *, fcsm_t *,
308fcf3ce44SJohn Forte 		    fc_detach_cmd_t);
309fcf3ce44SJohn Forte static void	fcsm_suspend_port(fcsm_t *);
310fcf3ce44SJohn Forte static void	fcsm_resume_port(fcsm_t *);
311fcf3ce44SJohn Forte static void	fcsm_cleanup_port(fcsm_t *);
312fcf3ce44SJohn Forte static void	fcsm_offline_timeout(void *);
313fcf3ce44SJohn Forte static int	fcsm_fciocmd(intptr_t, int, cred_t *, fcio_t *);
314fcf3ce44SJohn Forte static int	fcsm_fcio_copyout(fcio_t *, intptr_t, int);
315fcf3ce44SJohn Forte static int	fcsm_job_cache_constructor(void *, void *, int);
316fcf3ce44SJohn Forte static void	fcsm_job_cache_destructor(void *, void *);
317fcf3ce44SJohn Forte static fcsm_job_t *fcsm_alloc_job(int);
318fcf3ce44SJohn Forte static void	fcsm_dealloc_job(fcsm_job_t *);
319fcf3ce44SJohn Forte static void	fcsm_init_job(fcsm_job_t *, int, uint32_t, uint32_t, opaque_t,
320fcf3ce44SJohn Forte 		    opaque_t, void (*comp)(opaque_t, fcsm_job_t *, int),
321fcf3ce44SJohn Forte 		    opaque_t);
322fcf3ce44SJohn Forte static int	fcsm_process_job(fcsm_job_t *, int);
323fcf3ce44SJohn Forte static void	fcsm_enque_job(fcsm_t *, fcsm_job_t *, int);
324fcf3ce44SJohn Forte static fcsm_job_t *fcsm_deque_job(fcsm_t *);
325fcf3ce44SJohn Forte static int	fcsm_cmd_cache_constructor(void *, void *, int);
326fcf3ce44SJohn Forte static void	fcsm_cmd_cache_destructor(void *, void *);
327fcf3ce44SJohn Forte static fcsm_cmd_t	*fcsm_alloc_cmd(fcsm_t *, uint32_t, uint32_t, int);
328fcf3ce44SJohn Forte static void	fcsm_free_cmd_dma(fcsm_cmd_t *);
329fcf3ce44SJohn Forte static void	fcsm_job_thread(fcsm_t *);
330fcf3ce44SJohn Forte static int	fcsm_retry_job(fcsm_t *fcsm, fcsm_job_t *job);
331fcf3ce44SJohn Forte static void	fcsm_jobdone(fcsm_job_t *);
332fcf3ce44SJohn Forte static void	fcsm_ct_init(fcsm_t *, fcsm_cmd_t *, fc_ct_aiu_t *, size_t,
333fcf3ce44SJohn Forte 		    void (*comp_func)());
334fcf3ce44SJohn Forte static void	fcsm_ct_intr(fcsm_cmd_t *);
335fcf3ce44SJohn Forte static void	fcsm_job_ct_passthru(fcsm_job_t *);
336fcf3ce44SJohn Forte static int	fcsm_login_and_process_job(fcsm_t *, fcsm_job_t *);
337fcf3ce44SJohn Forte static void	fcsm_login_ms_comp(opaque_t, fcsm_job_t *, int);
338fcf3ce44SJohn Forte static void	fcsm_els_init(fcsm_cmd_t *, uint32_t);
339fcf3ce44SJohn Forte static int	fcsm_xlogi_init(fcsm_t *, fcsm_cmd_t *, uint32_t,
340fcf3ce44SJohn Forte 		    void (*comp_func)(), uchar_t);
341fcf3ce44SJohn Forte static void	fcsm_xlogi_intr(fcsm_cmd_t *);
342fcf3ce44SJohn Forte static void	fcsm_job_login_mgmt_server(fcsm_job_t *);
343fcf3ce44SJohn Forte int		fcsm_ct_passthru(int, fcio_t *, int, int,
344fcf3ce44SJohn Forte 		    void (*func)(fcio_t *));
345fcf3ce44SJohn Forte static void	fcsm_ct_passthru_comp(opaque_t, fcsm_job_t *, int);
346fcf3ce44SJohn Forte static void	fcsm_pkt_common_intr(fc_packet_t *);
347fcf3ce44SJohn Forte static int	fcsm_issue_cmd(fcsm_cmd_t *);
348fcf3ce44SJohn Forte static int	fcsm_retry_cmd(fcsm_cmd_t *);
349fcf3ce44SJohn Forte static void	fcsm_enque_cmd(fcsm_t *, fcsm_cmd_t *);
350fcf3ce44SJohn Forte static fcsm_cmd_t *fcsm_deque_cmd(fcsm_t *);
351fcf3ce44SJohn Forte static void	fcsm_retry_timeout(void *);
352fcf3ce44SJohn Forte static void	fcsm_force_port_detach_all(void);
353fcf3ce44SJohn Forte 
354fcf3ce44SJohn Forte 
355fcf3ce44SJohn Forte /*
356fcf3ce44SJohn Forte  * Utility functions
357fcf3ce44SJohn Forte  */
358fcf3ce44SJohn Forte static void	fcsm_disp_devlist(fcsm_t *, fc_portmap_t *, uint32_t);
359fcf3ce44SJohn Forte 
360fcf3ce44SJohn Forte static void	fcsm_display(int, int, fcsm_t *,
361fcf3ce44SJohn Forte 		    fc_packet_t *, const char *, ...);
362fcf3ce44SJohn Forte int		fcsm_pkt_state_to_rval(uchar_t, uint32_t);
363fcf3ce44SJohn Forte caddr_t		fcsm_port_state_to_str(uint32_t);
364fcf3ce44SJohn Forte caddr_t		fcsm_topology_to_str(uint32_t);
365fcf3ce44SJohn Forte static caddr_t	fcsm_dev_type_to_str(uint32_t);
366fcf3ce44SJohn Forte 
367fcf3ce44SJohn Forte 
368fcf3ce44SJohn Forte #endif /* _KERNEL */
369fcf3ce44SJohn Forte 
370fcf3ce44SJohn Forte 
371fcf3ce44SJohn Forte #ifdef	__cplusplus
372fcf3ce44SJohn Forte }
373fcf3ce44SJohn Forte #endif
374fcf3ce44SJohn Forte 
375fcf3ce44SJohn Forte #endif /* _FCSM_H */
376