xref: /onnv-gate/usr/src/uts/common/sys/fibre-channel/ulp/fcsm.h (revision 10264:1196af6129ec)
17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM  * CDDL HEADER START
37836SJohn.Forte@Sun.COM  *
47836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM  *
87836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM  * and limitations under the License.
127836SJohn.Forte@Sun.COM  *
137836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM  *
197836SJohn.Forte@Sun.COM  * CDDL HEADER END
207836SJohn.Forte@Sun.COM  */
217836SJohn.Forte@Sun.COM /*
22*10264SZhong.Wang@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237836SJohn.Forte@Sun.COM  * Use is subject to license terms.
247836SJohn.Forte@Sun.COM  */
257836SJohn.Forte@Sun.COM 
267836SJohn.Forte@Sun.COM #ifndef	_FCSM_H
277836SJohn.Forte@Sun.COM #define	_FCSM_H
287836SJohn.Forte@Sun.COM 
297836SJohn.Forte@Sun.COM #ifdef	__cplusplus
307836SJohn.Forte@Sun.COM extern "C" {
317836SJohn.Forte@Sun.COM #endif
327836SJohn.Forte@Sun.COM 
337836SJohn.Forte@Sun.COM #ifdef _KERNEL
347836SJohn.Forte@Sun.COM 
357836SJohn.Forte@Sun.COM /*
367836SJohn.Forte@Sun.COM  * Message printing flags
377836SJohn.Forte@Sun.COM  */
387836SJohn.Forte@Sun.COM #define	SM_LOG			1
397836SJohn.Forte@Sun.COM #define	SM_CONSOLE		2
407836SJohn.Forte@Sun.COM #define	SM_LOG_AND_CONSOLE	3
417836SJohn.Forte@Sun.COM 
427836SJohn.Forte@Sun.COM /*
437836SJohn.Forte@Sun.COM  * Debug levels
447836SJohn.Forte@Sun.COM  */
457836SJohn.Forte@Sun.COM #define	SMDL_TRACE	0x0001
467836SJohn.Forte@Sun.COM #define	SMDL_IO		0x0002
477836SJohn.Forte@Sun.COM #define	SMDL_ERR	0x0004
487836SJohn.Forte@Sun.COM #define	SMDL_INFO	0x0008
497836SJohn.Forte@Sun.COM 
507836SJohn.Forte@Sun.COM #ifdef	DEBUG
517836SJohn.Forte@Sun.COM #define	FCSM_DEBUG(level, args)	\
527836SJohn.Forte@Sun.COM 	if (fcsm_debug & (level))	fcsm_display args
537836SJohn.Forte@Sun.COM 
547836SJohn.Forte@Sun.COM extern uint32_t fcsm_debug;
557836SJohn.Forte@Sun.COM #else /* DEBUG */
567836SJohn.Forte@Sun.COM #define	FCSM_DEBUG(level, args)
577836SJohn.Forte@Sun.COM #endif /* DEBUG */
587836SJohn.Forte@Sun.COM 
597836SJohn.Forte@Sun.COM #define	FCSM_INIT_INSTANCES	8	/* # of instances for soft_state_init */
607836SJohn.Forte@Sun.COM /*
617836SJohn.Forte@Sun.COM  * Open flags
627836SJohn.Forte@Sun.COM  */
637836SJohn.Forte@Sun.COM #define	FCSM_IDLE		0x00
647836SJohn.Forte@Sun.COM #define	FCSM_OPEN		0x01
657836SJohn.Forte@Sun.COM #define	FCSM_EXCL		0x02
667836SJohn.Forte@Sun.COM 
677836SJohn.Forte@Sun.COM #define	FCSM_ELS_TIMEOUT	(20)	/* secs */
687836SJohn.Forte@Sun.COM #define	FCSM_MS_TIMEOUT		(20)	/* secs */
697836SJohn.Forte@Sun.COM 
707836SJohn.Forte@Sun.COM #define	FCSM_OFFLINE_TICKER	(120)	/* secs */
717836SJohn.Forte@Sun.COM 
727836SJohn.Forte@Sun.COM /* Definitions for command retries */
737836SJohn.Forte@Sun.COM #define	FCSM_MAX_CMD_RETRIES	5	/* Max retries in case of failure */
747836SJohn.Forte@Sun.COM #define	FCSM_RETRY_INTERVAL	3	/* Retry interval in seconds */
757836SJohn.Forte@Sun.COM #define	FCSM_RETRY_TICKER	1	/* Retry thread execution interval */
767836SJohn.Forte@Sun.COM 
777836SJohn.Forte@Sun.COM #define	FCSM_MAX_JOB_RETRIES	3	/* Max retries in case of job failure */
787836SJohn.Forte@Sun.COM 
797836SJohn.Forte@Sun.COM /*
807836SJohn.Forte@Sun.COM  * fcsm_job - Job structure to issue commands using command thread
817836SJohn.Forte@Sun.COM  */
827836SJohn.Forte@Sun.COM typedef struct fcsm_job {
837836SJohn.Forte@Sun.COM 	uint32_t	job_code;		/* Command code */
847836SJohn.Forte@Sun.COM 	uint32_t	job_flags;		/* Command Flags */
857836SJohn.Forte@Sun.COM 	int		job_port_instance;	/* port driver instance */
867836SJohn.Forte@Sun.COM 	int		job_result;		/* job completion result */
877836SJohn.Forte@Sun.COM 	opaque_t	job_arg;		/* Command Arguments */
887836SJohn.Forte@Sun.COM 	opaque_t	job_caller_priv;	/* Caller private */
897836SJohn.Forte@Sun.COM 	void		(*job_comp)(opaque_t, struct fcsm_job *, int);
907836SJohn.Forte@Sun.COM 						/* completion func */
917836SJohn.Forte@Sun.COM 	opaque_t	job_comp_arg;		/* Arg for completion func */
927836SJohn.Forte@Sun.COM 	kmutex_t	job_mutex;		/* per command mutex */
937836SJohn.Forte@Sun.COM 	ksema_t		job_sema;		/* To wait for completion */
947836SJohn.Forte@Sun.COM 	struct fcsm_job	*job_next;		/* for linked list */
957836SJohn.Forte@Sun.COM 	int		job_retry_count;	/* Retry count */
96*10264SZhong.Wang@Sun.COM 	void		*job_priv;		/* for fcsm private use	 */
977836SJohn.Forte@Sun.COM 	uint32_t	job_priv_flags;		/* fcsm private flags */
987836SJohn.Forte@Sun.COM } fcsm_job_t;
997836SJohn.Forte@Sun.COM 
1007836SJohn.Forte@Sun.COM /*
1017836SJohn.Forte@Sun.COM  * fcsm_t - FCSM Structure for per port information
1027836SJohn.Forte@Sun.COM  */
1037836SJohn.Forte@Sun.COM typedef struct fcsm {
1047836SJohn.Forte@Sun.COM 	kmutex_t		sm_mutex;	/* mutex for protection */
1057836SJohn.Forte@Sun.COM 	struct fcsm		*sm_next;	/* for global linked list */
1067836SJohn.Forte@Sun.COM 	int			sm_sid;		/* FCA Port ID */
1077836SJohn.Forte@Sun.COM 	int			sm_instance;	/* fc port instance number */
1087836SJohn.Forte@Sun.COM 	uint32_t		sm_port_state;	/* FCA port state */
1097836SJohn.Forte@Sun.COM 	uint32_t		sm_port_top;	/* Port topology */
1107836SJohn.Forte@Sun.COM 	uint32_t		sm_state;	/* San Mgmt State information */
1117836SJohn.Forte@Sun.COM 	uint32_t		sm_flags;	/* San Mgmt Flags (see below) */
1127836SJohn.Forte@Sun.COM 	int			sm_ncmds;	/* # of pending commands */
1137836SJohn.Forte@Sun.COM 	int			sm_cb_count;	/* # callbacks in progress */
1147836SJohn.Forte@Sun.COM 	fc_ulp_port_info_t	sm_port_info;	/* FCA Port Information */
1157836SJohn.Forte@Sun.COM 	fcsm_job_t		*sm_job_head;	/* port's job queue head */
1167836SJohn.Forte@Sun.COM 	fcsm_job_t		*sm_job_tail;	/* port's job queue tail */
1177836SJohn.Forte@Sun.COM 	struct fcsm_cmd		*sm_retry_head;	/* cmd retry queue head */
1187836SJohn.Forte@Sun.COM 	struct fcsm_cmd		*sm_retry_tail;	/* cmd retry queue tail */
1197836SJohn.Forte@Sun.COM 	timeout_id_t		sm_retry_tid;	/* retry timer */
1207836SJohn.Forte@Sun.COM 	timeout_id_t		sm_offline_tid;	/* offline timer */
1217836SJohn.Forte@Sun.COM 	kcondvar_t		sm_job_cv;	/* cv for job processing */
1227836SJohn.Forte@Sun.COM 	uint32_t		sm_dev_count;	/* # of devices discovered */
1237836SJohn.Forte@Sun.COM 	fc_portmap_t		*sm_portmap;	/* device map */
1247836SJohn.Forte@Sun.COM 	kthread_t		*sm_thread;	/* per port job thread */
1257836SJohn.Forte@Sun.COM 	kmem_cache_t		*sm_cmd_cache;	/* per port fc packet cache */
1267836SJohn.Forte@Sun.COM 	la_els_logi_t		sm_ms_service_params;
1277836SJohn.Forte@Sun.COM 						/* Mgmt Server Login Params */
1287836SJohn.Forte@Sun.COM 	callb_cpr_t		sm_cpr_info;	/* CPR info */
1297836SJohn.Forte@Sun.COM } fcsm_t;
1307836SJohn.Forte@Sun.COM 
1317836SJohn.Forte@Sun.COM 
1327836SJohn.Forte@Sun.COM typedef struct fcsm_cmd {
1337836SJohn.Forte@Sun.COM 	fc_packet_t	*cmd_fp_pkt;
1347836SJohn.Forte@Sun.COM 	fcsm_job_t	*cmd_job;
1357836SJohn.Forte@Sun.COM 	fcsm_t		*cmd_fcsm;
1367836SJohn.Forte@Sun.COM 	int		cmd_retry_count;
1377836SJohn.Forte@Sun.COM 	int		cmd_retry_interval;
1387836SJohn.Forte@Sun.COM 	int		cmd_max_retries;
1397836SJohn.Forte@Sun.COM 	struct fcsm_cmd	*cmd_next;
1407836SJohn.Forte@Sun.COM 	void		(*cmd_comp)(struct fcsm_cmd *);
1417836SJohn.Forte@Sun.COM 	int		(*cmd_transport)(opaque_t, fc_packet_t *);
1427836SJohn.Forte@Sun.COM 	uint32_t	cmd_dma_flags;
1437836SJohn.Forte@Sun.COM 	fc_packet_t	cmd_fc_packet;
1447836SJohn.Forte@Sun.COM } fcsm_cmd_t;
1457836SJohn.Forte@Sun.COM 
1467836SJohn.Forte@Sun.COM /*
1477836SJohn.Forte@Sun.COM  * sm_flags in the per port FCSM Structure
1487836SJohn.Forte@Sun.COM  */
1497836SJohn.Forte@Sun.COM #define	FCSM_ATTACHING			0x0001
1507836SJohn.Forte@Sun.COM #define	FCSM_ATTACHED			0x0002
1517836SJohn.Forte@Sun.COM #define	FCSM_DETACHING			0x0004
1527836SJohn.Forte@Sun.COM #define	FCSM_DETACHED			0x0008
1537836SJohn.Forte@Sun.COM #define	FCSM_SUSPENDED			0x0010
1547836SJohn.Forte@Sun.COM #define	FCSM_POWER_DOWN			0x0020
1557836SJohn.Forte@Sun.COM #define	FCSM_RESTORE_RETRY_TIMEOUT	0x0040
1567836SJohn.Forte@Sun.COM #define	FCSM_RESTORE_OFFLINE_TIMEOUT	0x0080
1577836SJohn.Forte@Sun.COM #define	FCSM_RETRY_TIMER_ACTIVE		0x0100
1587836SJohn.Forte@Sun.COM #define	FCSM_SERIALIZE_JOBTHREAD	0x0200
1597836SJohn.Forte@Sun.COM #define	FCSM_CMD_RETRY_Q_SUSPENDED	0x0400
1607836SJohn.Forte@Sun.COM #define	FCSM_PORT_OFFLINE		0x0800
1617836SJohn.Forte@Sun.COM #define	FCSM_LINK_DOWN			0x1000
1627836SJohn.Forte@Sun.COM #define	FCSM_MGMT_SERVER_LOGGED_IN	0x2000
1637836SJohn.Forte@Sun.COM #define	FCSM_MGMT_SERVER_LOGIN_IN_PROG	0x4000
164*10264SZhong.Wang@Sun.COM #define	FCSM_USING_NODMA_FCA		0x8000
1657836SJohn.Forte@Sun.COM 
1667836SJohn.Forte@Sun.COM /* Command flags for Job structure */
1677836SJohn.Forte@Sun.COM #define	FCSM_JOBFLAG_SYNC		0x01
1687836SJohn.Forte@Sun.COM #define	FCSM_JOBFLAG_ASYNC		0x02
1697836SJohn.Forte@Sun.COM #define	FCSM_JOBFLAG_SERIALIZE		0x04
1707836SJohn.Forte@Sun.COM #define	FCSM_JOBFLAG_CTHEADER_BE	0X08
1717836SJohn.Forte@Sun.COM 
1727836SJohn.Forte@Sun.COM /* Command codes */
1737836SJohn.Forte@Sun.COM #define	FCSM_JOB_NONE			0x00
1747836SJohn.Forte@Sun.COM #define	FCSM_JOB_THREAD_SHUTDOWN	0x01
1757836SJohn.Forte@Sun.COM #define	FCSM_JOB_LOGIN_NAME_SERVER	0x02
1767836SJohn.Forte@Sun.COM #define	FCSM_JOB_LOGIN_MGMT_SERVER	0x03
1777836SJohn.Forte@Sun.COM #define	FCSM_JOB_CT_PASSTHRU		0x04
1787836SJohn.Forte@Sun.COM 
1797836SJohn.Forte@Sun.COM /* Private flags for command */
1807836SJohn.Forte@Sun.COM #define	FCSM_JOB_PRIV_WAIT_FOR_LOGIN	0x01
1817836SJohn.Forte@Sun.COM #define	FCSM_JOB_PRIV_LOGIN_IN_PROG	0x02
1827836SJohn.Forte@Sun.COM 
1837836SJohn.Forte@Sun.COM /* Command DMA Flags */
1847836SJohn.Forte@Sun.COM #define	FCSM_CF_CMD_VALID_DMA_MEM	0x01
1857836SJohn.Forte@Sun.COM #define	FCSM_CF_CMD_VALID_DMA_BIND	0x02
1867836SJohn.Forte@Sun.COM #define	FCSM_CF_RESP_VALID_DMA_MEM	0x04
1877836SJohn.Forte@Sun.COM #define	FCSM_CF_RESP_VALID_DMA_BIND	0x08
1887836SJohn.Forte@Sun.COM 
1897836SJohn.Forte@Sun.COM #define	FCSM_INIT_CMD(cmd, job, tran_flags, tran_type, max_retries, func) { \
1907836SJohn.Forte@Sun.COM 	(cmd)->cmd_job = (job); \
1917836SJohn.Forte@Sun.COM 	(cmd)->cmd_fc_packet.pkt_tran_flags = (tran_flags); \
1927836SJohn.Forte@Sun.COM 	(cmd)->cmd_fc_packet.pkt_tran_type = (tran_type); \
1937836SJohn.Forte@Sun.COM 	(cmd)->cmd_max_retries = max_retries; \
1947836SJohn.Forte@Sun.COM 	(cmd)->cmd_comp = func; \
1957836SJohn.Forte@Sun.COM }
1967836SJohn.Forte@Sun.COM 
1977836SJohn.Forte@Sun.COM /*
1987836SJohn.Forte@Sun.COM  * Macros to address endian issues
199*10264SZhong.Wang@Sun.COM  * local variable "fcsm" must exist before using these
2007836SJohn.Forte@Sun.COM  */
201*10264SZhong.Wang@Sun.COM #define	FCSM_REP_RD(handle, hostaddr, devaddr, cnt)			\
202*10264SZhong.Wang@Sun.COM 	{								\
203*10264SZhong.Wang@Sun.COM 		if (!((fcsm)->sm_flags & FCSM_USING_NODMA_FCA)) {	\
204*10264SZhong.Wang@Sun.COM 			ddi_rep_get8((handle), (uint8_t *)(hostaddr),	\
205*10264SZhong.Wang@Sun.COM 				    (uint8_t *)(devaddr), (cnt),	\
206*10264SZhong.Wang@Sun.COM 				    DDI_DEV_AUTOINCR);			\
207*10264SZhong.Wang@Sun.COM 		} else {						\
208*10264SZhong.Wang@Sun.COM 			bcopy((devaddr), (hostaddr), (cnt));		\
209*10264SZhong.Wang@Sun.COM 		}							\
210*10264SZhong.Wang@Sun.COM 	}
2117836SJohn.Forte@Sun.COM 
212*10264SZhong.Wang@Sun.COM #define	FCSM_REP_WR(handle, hostaddr, devaddr, cnt)			\
213*10264SZhong.Wang@Sun.COM 	{								\
214*10264SZhong.Wang@Sun.COM 		if (!((fcsm)->sm_flags & FCSM_USING_NODMA_FCA)) {	\
215*10264SZhong.Wang@Sun.COM 			ddi_rep_put8((handle), (uint8_t *)(hostaddr),	\
216*10264SZhong.Wang@Sun.COM 				    (uint8_t *)(devaddr), (cnt),	\
217*10264SZhong.Wang@Sun.COM 				    DDI_DEV_AUTOINCR);			\
218*10264SZhong.Wang@Sun.COM 		} else {						\
219*10264SZhong.Wang@Sun.COM 			bcopy((hostaddr), (devaddr), (cnt));		\
220*10264SZhong.Wang@Sun.COM 		}							\
221*10264SZhong.Wang@Sun.COM 	}
2227836SJohn.Forte@Sun.COM 
2237836SJohn.Forte@Sun.COM #endif /* _KERNEL */
2247836SJohn.Forte@Sun.COM 
2257836SJohn.Forte@Sun.COM /*
2267836SJohn.Forte@Sun.COM  * IOCTL Definitions
2277836SJohn.Forte@Sun.COM  */
2287836SJohn.Forte@Sun.COM typedef struct fc_ct_aiu {
2297836SJohn.Forte@Sun.COM 	fc_ct_header_t	aiu_header;
2307836SJohn.Forte@Sun.COM 	char		aiu_payload[1];
2317836SJohn.Forte@Sun.COM 	/* aiu_payload can be up to 'm' bytes (arbitrary length) */
2327836SJohn.Forte@Sun.COM } fc_ct_aiu_t;
2337836SJohn.Forte@Sun.COM 
2347836SJohn.Forte@Sun.COM #define	FCSMIO			('S' << 8)
2357836SJohn.Forte@Sun.COM #define	FCSMIO_CMD		(FCSMIO | 2000)
2367836SJohn.Forte@Sun.COM 
2377836SJohn.Forte@Sun.COM #define	FCSMIO_SUB_CMD		('Y' << 8)
2387836SJohn.Forte@Sun.COM #define	FCSMIO_CT_CMD		(FCSMIO_SUB_CMD + 0x01)
2397836SJohn.Forte@Sun.COM #define	FCSMIO_ADAPTER_LIST	(FCSMIO_SUB_CMD + 0x02)
2407836SJohn.Forte@Sun.COM #define	FCSMIO_FIND_ADAPTER	(FCSMIO_SUB_CMD + 0x03)
2417836SJohn.Forte@Sun.COM 
2427836SJohn.Forte@Sun.COM #define	FCSM_MAX_CT_SIZE	(65536)		/* 64K */
2437836SJohn.Forte@Sun.COM 
2447836SJohn.Forte@Sun.COM /* Management Server - Fabric Configuration Server Commands */
2457836SJohn.Forte@Sun.COM #define	MS_CS_GTIN	0x0100	/* Get Topology Information */
2467836SJohn.Forte@Sun.COM #define	MS_CS_GIEL	0x0101	/* Get Interconnect Element List */
2477836SJohn.Forte@Sun.COM #define	MS_CS_GIET	0x0111	/* Get Interconnect Element Type */
2487836SJohn.Forte@Sun.COM #define	MS_CS_GDID	0x0112	/* Get Domain Identifier */
2497836SJohn.Forte@Sun.COM #define	MS_CS_GMID	0x0113	/* Get Management Identifier */
2507836SJohn.Forte@Sun.COM #define	MS_CS_GFN	0x0114	/* Get Fabric Name */
2517836SJohn.Forte@Sun.COM #define	MS_CS_GIELN	0x0115	/* Get Interconnect Element Logical Name */
2527836SJohn.Forte@Sun.COM #define	MS_CS_GMAL	0x0116	/* Get Management Address List */
2537836SJohn.Forte@Sun.COM #define	MS_CS_GIEIL	0x0117	/* Get Interconnect Element Information List */
2547836SJohn.Forte@Sun.COM #define	MS_CS_GPL	0x0118	/* Get Port List */
2557836SJohn.Forte@Sun.COM #define	MS_CS_GPT	0x0121	/* Get Port Type */
2567836SJohn.Forte@Sun.COM #define	MS_CS_GPPN	0x0122	/* Get Physical Port Number */
2577836SJohn.Forte@Sun.COM #define	MS_CS_GAPNL	0x0124	/* Get Attached Port Name List */
2587836SJohn.Forte@Sun.COM #define	MS_CS_GPS	0x0126	/* Get Port State */
2597836SJohn.Forte@Sun.COM #define	MS_CS_GATIN	0x0128	/* Get Attached Topology Information */
2607836SJohn.Forte@Sun.COM #define	MS_CS_GPLNL	0x0191	/* Get Platform Node Name List */
2617836SJohn.Forte@Sun.COM #define	MS_CS_GPLT	0x0192	/* Get Platform Type */
2627836SJohn.Forte@Sun.COM #define	MS_CS_GPLML	0x0193	/* Get Platform Management Address List */
2637836SJohn.Forte@Sun.COM #define	MS_CS_GNPL	0x01a1	/* Get Platform Name - Node Name */
2647836SJohn.Forte@Sun.COM #define	MS_CS_GPNL	0x01a2	/* Get Platform Name List */
2657836SJohn.Forte@Sun.COM #define	MS_CS_GNID	0x01b1	/* Get Node Identification Data - Node Name */
2667836SJohn.Forte@Sun.COM #define	MS_CS_RIELN	0x0215	/* Register Interconnect Element Logical Name */
2677836SJohn.Forte@Sun.COM #define	MS_CS_RPL	0x0280	/* Register Platform */
2687836SJohn.Forte@Sun.COM #define	MS_CS_RPLN	0x0291	/* Register Platform Name */
2697836SJohn.Forte@Sun.COM #define	MS_CS_RPLT	0x0292	/* Register Platform Type */
2707836SJohn.Forte@Sun.COM #define	MS_CS_RPLM	0x0293	/* Register Platform Management Address */
2717836SJohn.Forte@Sun.COM #define	MS_CS_DPL	0x0380	/* Deregister Platform */
2727836SJohn.Forte@Sun.COM #define	MS_CS_DPLN	0x0391	/* Deregister Platform Node Name */
2737836SJohn.Forte@Sun.COM #define	MS_CS_DPLML	0x0393	/* Deregister Platform Management Addr List */
2747836SJohn.Forte@Sun.COM 
2757836SJohn.Forte@Sun.COM #ifdef _KERNEL
2767836SJohn.Forte@Sun.COM 
2777836SJohn.Forte@Sun.COM /*
2787836SJohn.Forte@Sun.COM  * Driver entry point functions
2797836SJohn.Forte@Sun.COM  */
2807836SJohn.Forte@Sun.COM static int	fcsm_attach(dev_info_t *, ddi_attach_cmd_t);
2817836SJohn.Forte@Sun.COM static int	fcsm_detach(dev_info_t *, ddi_detach_cmd_t);
2827836SJohn.Forte@Sun.COM static int	fcsm_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
2837836SJohn.Forte@Sun.COM static int	fcsm_open(dev_t *, int, int, cred_t *);
2847836SJohn.Forte@Sun.COM static int	fcsm_close(dev_t, int, int, cred_t *);
2857836SJohn.Forte@Sun.COM static int	fcsm_ioctl(dev_t, int, intptr_t, int, cred_t *, int *);
2867836SJohn.Forte@Sun.COM 
2877836SJohn.Forte@Sun.COM /*
2887836SJohn.Forte@Sun.COM  * FC Transport functions
2897836SJohn.Forte@Sun.COM  */
2907836SJohn.Forte@Sun.COM static int	fcsm_port_attach(opaque_t, fc_ulp_port_info_t *,
2917836SJohn.Forte@Sun.COM 		    fc_attach_cmd_t, uint32_t);
2927836SJohn.Forte@Sun.COM static int	fcsm_port_detach(opaque_t, fc_ulp_port_info_t *,
2937836SJohn.Forte@Sun.COM 		    fc_detach_cmd_t);
2947836SJohn.Forte@Sun.COM static int	fcsm_port_ioctl(opaque_t, opaque_t, dev_t, int, intptr_t,
2957836SJohn.Forte@Sun.COM 		    int, cred_t *, int *, uint32_t);
2967836SJohn.Forte@Sun.COM static void	fcsm_statec_cb(opaque_t, opaque_t, uint32_t, uint32_t,
2977836SJohn.Forte@Sun.COM 		    fc_portmap_t *, uint32_t, uint32_t);
2987836SJohn.Forte@Sun.COM static int	fcsm_els_cb(opaque_t, opaque_t, fc_unsol_buf_t *, uint32_t);
2997836SJohn.Forte@Sun.COM static int	fcsm_data_cb(opaque_t, opaque_t, fc_unsol_buf_t *, uint32_t);
3007836SJohn.Forte@Sun.COM 
3017836SJohn.Forte@Sun.COM /*
3027836SJohn.Forte@Sun.COM  * Internal functions
3037836SJohn.Forte@Sun.COM  */
3047836SJohn.Forte@Sun.COM static int	fcsm_handle_port_attach(fc_ulp_port_info_t *, uint32_t, int);
3057836SJohn.Forte@Sun.COM static int	fcsm_handle_port_resume(opaque_t, fc_ulp_port_info_t *,
3067836SJohn.Forte@Sun.COM 		    fc_attach_cmd_t, uint32_t, fcsm_t *);
3077836SJohn.Forte@Sun.COM static int	fcsm_handle_port_detach(fc_ulp_port_info_t *, fcsm_t *,
3087836SJohn.Forte@Sun.COM 		    fc_detach_cmd_t);
3097836SJohn.Forte@Sun.COM static void	fcsm_suspend_port(fcsm_t *);
3107836SJohn.Forte@Sun.COM static void	fcsm_resume_port(fcsm_t *);
3117836SJohn.Forte@Sun.COM static void	fcsm_cleanup_port(fcsm_t *);
3127836SJohn.Forte@Sun.COM static void	fcsm_offline_timeout(void *);
3137836SJohn.Forte@Sun.COM static int	fcsm_fciocmd(intptr_t, int, cred_t *, fcio_t *);
3147836SJohn.Forte@Sun.COM static int	fcsm_fcio_copyout(fcio_t *, intptr_t, int);
3157836SJohn.Forte@Sun.COM static int	fcsm_job_cache_constructor(void *, void *, int);
3167836SJohn.Forte@Sun.COM static void	fcsm_job_cache_destructor(void *, void *);
3177836SJohn.Forte@Sun.COM static fcsm_job_t *fcsm_alloc_job(int);
3187836SJohn.Forte@Sun.COM static void	fcsm_dealloc_job(fcsm_job_t *);
3197836SJohn.Forte@Sun.COM static void	fcsm_init_job(fcsm_job_t *, int, uint32_t, uint32_t, opaque_t,
3207836SJohn.Forte@Sun.COM 		    opaque_t, void (*comp)(opaque_t, fcsm_job_t *, int),
3217836SJohn.Forte@Sun.COM 		    opaque_t);
3227836SJohn.Forte@Sun.COM static int	fcsm_process_job(fcsm_job_t *, int);
3237836SJohn.Forte@Sun.COM static void	fcsm_enque_job(fcsm_t *, fcsm_job_t *, int);
3247836SJohn.Forte@Sun.COM static fcsm_job_t *fcsm_deque_job(fcsm_t *);
3257836SJohn.Forte@Sun.COM static int	fcsm_cmd_cache_constructor(void *, void *, int);
3267836SJohn.Forte@Sun.COM static void	fcsm_cmd_cache_destructor(void *, void *);
3277836SJohn.Forte@Sun.COM static fcsm_cmd_t	*fcsm_alloc_cmd(fcsm_t *, uint32_t, uint32_t, int);
3287836SJohn.Forte@Sun.COM static void	fcsm_free_cmd_dma(fcsm_cmd_t *);
3297836SJohn.Forte@Sun.COM static void	fcsm_job_thread(fcsm_t *);
3307836SJohn.Forte@Sun.COM static int	fcsm_retry_job(fcsm_t *fcsm, fcsm_job_t *job);
3317836SJohn.Forte@Sun.COM static void	fcsm_jobdone(fcsm_job_t *);
3327836SJohn.Forte@Sun.COM static void	fcsm_ct_init(fcsm_t *, fcsm_cmd_t *, fc_ct_aiu_t *, size_t,
3337836SJohn.Forte@Sun.COM 		    void (*comp_func)());
3347836SJohn.Forte@Sun.COM static void	fcsm_ct_intr(fcsm_cmd_t *);
3357836SJohn.Forte@Sun.COM static void	fcsm_job_ct_passthru(fcsm_job_t *);
3367836SJohn.Forte@Sun.COM static int	fcsm_login_and_process_job(fcsm_t *, fcsm_job_t *);
3377836SJohn.Forte@Sun.COM static void	fcsm_login_ms_comp(opaque_t, fcsm_job_t *, int);
3387836SJohn.Forte@Sun.COM static void	fcsm_els_init(fcsm_cmd_t *, uint32_t);
3397836SJohn.Forte@Sun.COM static int	fcsm_xlogi_init(fcsm_t *, fcsm_cmd_t *, uint32_t,
3407836SJohn.Forte@Sun.COM 		    void (*comp_func)(), uchar_t);
3417836SJohn.Forte@Sun.COM static void	fcsm_xlogi_intr(fcsm_cmd_t *);
3427836SJohn.Forte@Sun.COM static void	fcsm_job_login_mgmt_server(fcsm_job_t *);
3437836SJohn.Forte@Sun.COM int		fcsm_ct_passthru(int, fcio_t *, int, int,
3447836SJohn.Forte@Sun.COM 		    void (*func)(fcio_t *));
3457836SJohn.Forte@Sun.COM static void	fcsm_ct_passthru_comp(opaque_t, fcsm_job_t *, int);
3467836SJohn.Forte@Sun.COM static void	fcsm_pkt_common_intr(fc_packet_t *);
3477836SJohn.Forte@Sun.COM static int	fcsm_issue_cmd(fcsm_cmd_t *);
3487836SJohn.Forte@Sun.COM static int	fcsm_retry_cmd(fcsm_cmd_t *);
3497836SJohn.Forte@Sun.COM static void	fcsm_enque_cmd(fcsm_t *, fcsm_cmd_t *);
3507836SJohn.Forte@Sun.COM static fcsm_cmd_t *fcsm_deque_cmd(fcsm_t *);
3517836SJohn.Forte@Sun.COM static void	fcsm_retry_timeout(void *);
3527836SJohn.Forte@Sun.COM static void	fcsm_force_port_detach_all(void);
3537836SJohn.Forte@Sun.COM 
3547836SJohn.Forte@Sun.COM 
3557836SJohn.Forte@Sun.COM /*
3567836SJohn.Forte@Sun.COM  * Utility functions
3577836SJohn.Forte@Sun.COM  */
3587836SJohn.Forte@Sun.COM static void	fcsm_disp_devlist(fcsm_t *, fc_portmap_t *, uint32_t);
3597836SJohn.Forte@Sun.COM 
3607836SJohn.Forte@Sun.COM static void	fcsm_display(int, int, fcsm_t *,
3617836SJohn.Forte@Sun.COM 		    fc_packet_t *, const char *, ...);
3627836SJohn.Forte@Sun.COM int		fcsm_pkt_state_to_rval(uchar_t, uint32_t);
3637836SJohn.Forte@Sun.COM caddr_t		fcsm_port_state_to_str(uint32_t);
3647836SJohn.Forte@Sun.COM caddr_t		fcsm_topology_to_str(uint32_t);
3657836SJohn.Forte@Sun.COM static caddr_t	fcsm_dev_type_to_str(uint32_t);
3667836SJohn.Forte@Sun.COM 
3677836SJohn.Forte@Sun.COM 
3687836SJohn.Forte@Sun.COM #endif /* _KERNEL */
3697836SJohn.Forte@Sun.COM 
3707836SJohn.Forte@Sun.COM 
3717836SJohn.Forte@Sun.COM #ifdef	__cplusplus
3727836SJohn.Forte@Sun.COM }
3737836SJohn.Forte@Sun.COM #endif
3747836SJohn.Forte@Sun.COM 
3757836SJohn.Forte@Sun.COM #endif /* _FCSM_H */
376