xref: /onnv-gate/usr/src/uts/common/sys/fibre-channel/impl/fc_portif.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	_FC_PORTIF_H
277836SJohn.Forte@Sun.COM #define	_FC_PORTIF_H
287836SJohn.Forte@Sun.COM 
297836SJohn.Forte@Sun.COM #include <sys/note.h>
307836SJohn.Forte@Sun.COM 
317836SJohn.Forte@Sun.COM #ifdef	__cplusplus
327836SJohn.Forte@Sun.COM extern "C" {
337836SJohn.Forte@Sun.COM #endif
347836SJohn.Forte@Sun.COM 
357836SJohn.Forte@Sun.COM /*
367836SJohn.Forte@Sun.COM  * To remove the port WWN from the orphan list; An orphan list
377836SJohn.Forte@Sun.COM  * scan typically happens during ONLINE processing (after a LIP
387836SJohn.Forte@Sun.COM  * in Public loop or link reset) or during RSCN validation.
397836SJohn.Forte@Sun.COM  */
407836SJohn.Forte@Sun.COM #define	FC_ORPHAN_SCAN_LIMIT		15
417836SJohn.Forte@Sun.COM 
427836SJohn.Forte@Sun.COM /*
437836SJohn.Forte@Sun.COM  * Show a limited tolerance on the number of LOGOs that an
447836SJohn.Forte@Sun.COM  * N/NL_Port can send; Beyond that it'll be removed entirely
457836SJohn.Forte@Sun.COM  * from the port driver's data base. The tolerance counter
467836SJohn.Forte@Sun.COM  * is reset after each link reset.
477836SJohn.Forte@Sun.COM  */
487836SJohn.Forte@Sun.COM #define	FC_LOGO_TOLERANCE_LIMIT		16
497836SJohn.Forte@Sun.COM #define	FC_LOGO_TOLERANCE_TIME_LIMIT	5000000	/* 5 seconds */
507836SJohn.Forte@Sun.COM 
517836SJohn.Forte@Sun.COM /*
527836SJohn.Forte@Sun.COM  * ns_flags field definitions in struct
537836SJohn.Forte@Sun.COM  * fctl_ns_req_t
547836SJohn.Forte@Sun.COM  */
557836SJohn.Forte@Sun.COM #define	FCTL_NS_FILL_NS_MAP		0x01
567836SJohn.Forte@Sun.COM #define	FCTL_NS_GET_DEV_COUNT		0x02
577836SJohn.Forte@Sun.COM #define	FCTL_NS_NO_DATA_BUF		0x04
587836SJohn.Forte@Sun.COM #define	FCTL_NS_BUF_IS_USERLAND		0x08
597836SJohn.Forte@Sun.COM #define	FCTL_NS_BUF_IS_FC_PORTMAP	0x10
607836SJohn.Forte@Sun.COM #define	FCTL_NS_CREATE_DEVICE		0x20
617836SJohn.Forte@Sun.COM #define	FCTL_NS_VALIDATE_PD		0x40
627836SJohn.Forte@Sun.COM #define	FCTL_NS_ASYNC_REQUEST		0x80
637836SJohn.Forte@Sun.COM #define	FCTL_GAN_START_ID		0xFFFFFF
647836SJohn.Forte@Sun.COM 
657836SJohn.Forte@Sun.COM 
667836SJohn.Forte@Sun.COM 
677836SJohn.Forte@Sun.COM /*
687836SJohn.Forte@Sun.COM  * Values for the fp_soft_state field in the fc_local_port_t struct.
697836SJohn.Forte@Sun.COM  *
707836SJohn.Forte@Sun.COM  * Notice below that in two cases, suspend and pm-suspend,there
717836SJohn.Forte@Sun.COM  * is no usage of _IN_, which means the bits will stay even after
727836SJohn.Forte@Sun.COM  * suspend/pm-suspend is complete they are cleared at the time of
737836SJohn.Forte@Sun.COM  * resume/pm-resume.
747836SJohn.Forte@Sun.COM  */
757836SJohn.Forte@Sun.COM 
767836SJohn.Forte@Sun.COM /*
777836SJohn.Forte@Sun.COM  * FP_SOFT_IN_DETACH is set in fp_detach_handler(), which is called from
787836SJohn.Forte@Sun.COM  * fp_detach() for the DDI_DETACH flag. FP_SOFT_IN_DETACH is checked in
797836SJohn.Forte@Sun.COM  * numerous places. It is never explicitly cleared -- apparently the code
807836SJohn.Forte@Sun.COM  * relies on ddi_softstate_free(9F) to clear it.
817836SJohn.Forte@Sun.COM  */
827836SJohn.Forte@Sun.COM #define	FP_SOFT_IN_DETACH		0x0002
837836SJohn.Forte@Sun.COM 
847836SJohn.Forte@Sun.COM /*
857836SJohn.Forte@Sun.COM  * FP_SOFT_SUSPEND is set in fp_suspend_handler() and cleared in
867836SJohn.Forte@Sun.COM  * fp_resume_handler.  It is tested in a number of placed in fp and fctl,
877836SJohn.Forte@Sun.COM  * including fp_job_handler().
887836SJohn.Forte@Sun.COM  */
897836SJohn.Forte@Sun.COM #define	FP_SOFT_SUSPEND			0x0004
907836SJohn.Forte@Sun.COM 
917836SJohn.Forte@Sun.COM /*
927836SJohn.Forte@Sun.COM  * FP_SOFT_POWER_DOWN is set in fp_power_down() and cleared in fp_power_up().
937836SJohn.Forte@Sun.COM  * It is tested in a number of different places in fp/fctl.
947836SJohn.Forte@Sun.COM  */
957836SJohn.Forte@Sun.COM #define	FP_SOFT_POWER_DOWN		0x0008
967836SJohn.Forte@Sun.COM #define	FP_SOFT_IN_STATEC_CB		0x0010
977836SJohn.Forte@Sun.COM #define	FP_SOFT_IN_UNSOL_CB		0x0020
987836SJohn.Forte@Sun.COM #define	FP_SOFT_IN_LINK_RESET		0x0040
997836SJohn.Forte@Sun.COM #define	FP_SOFT_BAD_LINK		0x0080
1007836SJohn.Forte@Sun.COM #define	FP_SOFT_IN_FCA_RESET		0x0100
1017836SJohn.Forte@Sun.COM #define	FP_DETACH_INPROGRESS		0x0200
1027836SJohn.Forte@Sun.COM #define	FP_DETACH_FAILED		0x0400
1037836SJohn.Forte@Sun.COM #define	FP_SOFT_NO_PMCOMP		0x0800
104*10264SZhong.Wang@Sun.COM #define	FP_SOFT_FCA_IS_NODMA		0x1000
1057836SJohn.Forte@Sun.COM 
1067836SJohn.Forte@Sun.COM /*
1077836SJohn.Forte@Sun.COM  * Instruct the port driver to just accept logins from these addresses
1087836SJohn.Forte@Sun.COM  */
1097836SJohn.Forte@Sun.COM #define	FC_MUST_ACCEPT_D_ID(x)		(FC_WELL_KNOWN_ADDR(x) || (x) == 0)
1107836SJohn.Forte@Sun.COM 
1117836SJohn.Forte@Sun.COM #define	FC_IS_REAL_DEVICE(x)		(!FC_MUST_ACCEPT_D_ID(x))
1127836SJohn.Forte@Sun.COM 
1137836SJohn.Forte@Sun.COM /*
1147836SJohn.Forte@Sun.COM  * Bit definitions for fp_options field in fc_local_port_t
1157836SJohn.Forte@Sun.COM  * structure for Feature and Hack additions to make
1167836SJohn.Forte@Sun.COM  * the driver code a real hairball.
1177836SJohn.Forte@Sun.COM  */
1187836SJohn.Forte@Sun.COM #define	FP_NS_SMART_COUNT			0x01
1197836SJohn.Forte@Sun.COM #define	FP_SEND_RJT				0x02
1207836SJohn.Forte@Sun.COM #define	FP_CORE_ON_OFFLINE_TIMEOUT		0x04
1217836SJohn.Forte@Sun.COM #define	FP_RESET_CORE_ON_OFFLINE_TIMEOUT	0x08
1227836SJohn.Forte@Sun.COM #define	FP_TARGET_MODE				0x10
1237836SJohn.Forte@Sun.COM 
1247836SJohn.Forte@Sun.COM 
1257836SJohn.Forte@Sun.COM /*
1267836SJohn.Forte@Sun.COM  * Values for fp_pm_level in the fc_local_port_t struct. Tracks current PM
1277836SJohn.Forte@Sun.COM  * level for the local port.
1287836SJohn.Forte@Sun.COM  */
1297836SJohn.Forte@Sun.COM #define	FP_PM_PORT_DOWN			0
1307836SJohn.Forte@Sun.COM #define	FP_PM_PORT_UP			1
1317836SJohn.Forte@Sun.COM 
1327836SJohn.Forte@Sun.COM 
1337836SJohn.Forte@Sun.COM /*
1347836SJohn.Forte@Sun.COM  * FC port compoment for PM. Used with pm_raise_power() and friends.
1357836SJohn.Forte@Sun.COM  */
1367836SJohn.Forte@Sun.COM #define	FP_PM_COMPONENT			0
1377836SJohn.Forte@Sun.COM 
1387836SJohn.Forte@Sun.COM 
1397836SJohn.Forte@Sun.COM #define	FCTL_WWN_SIZE(wwn)		\
1407836SJohn.Forte@Sun.COM 	(sizeof ((wwn)->raw_wwn) / sizeof ((wwn)->raw_wwn[0]))
1417836SJohn.Forte@Sun.COM 
1427836SJohn.Forte@Sun.COM 
1437836SJohn.Forte@Sun.COM /*
1447836SJohn.Forte@Sun.COM  * Structure for issuing a work request to the per-instance "job handler"
1457836SJohn.Forte@Sun.COM  * thread. Primarily allocated/initialized by fctl_alloc_job() and freed by
146*10264SZhong.Wang@Sun.COM  * fctl_dealloc_job().	fctl keeps a kmem_cache of these structs anchored by the
1477836SJohn.Forte@Sun.COM  * fctl_job_cache global variable.  The cache is created at fctl's _init(9E) and
1487836SJohn.Forte@Sun.COM  * destroyed at fctl's _fini(9E).  See also fctl_cache_constructor()
1497836SJohn.Forte@Sun.COM  * and fctl_cache_destructor().
1507836SJohn.Forte@Sun.COM  */
1517836SJohn.Forte@Sun.COM typedef struct job_request {
1527836SJohn.Forte@Sun.COM 	/*
153*10264SZhong.Wang@Sun.COM 	 * ID code for the job or task to be performed.	 Set by fctl_alloc_job()
1547836SJohn.Forte@Sun.COM 	 * and read by fp_job_handler().
1557836SJohn.Forte@Sun.COM 	 */
1567836SJohn.Forte@Sun.COM 	int		job_code;
1577836SJohn.Forte@Sun.COM 
1587836SJohn.Forte@Sun.COM 	/*
1597836SJohn.Forte@Sun.COM 	 * Completion status of the request.  Typically FC_SUCCESS or
1607836SJohn.Forte@Sun.COM 	 * FC_FAILURE, but may make use of other error code values (such as
1617836SJohn.Forte@Sun.COM 	 * FC_OFFLINE, FC_BADCMD, FC_NO_MAP, and friends). The complete set
1627836SJohn.Forte@Sun.COM 	 * of values is not clearly specified.
1637836SJohn.Forte@Sun.COM 	 */
1647836SJohn.Forte@Sun.COM 	int		job_result;
1657836SJohn.Forte@Sun.COM 
1667836SJohn.Forte@Sun.COM 	/* Execution control flags (defined below) */
1677836SJohn.Forte@Sun.COM 	int		job_flags;
1687836SJohn.Forte@Sun.COM 
1697836SJohn.Forte@Sun.COM 	/*
1707836SJohn.Forte@Sun.COM 	 * This allows multiple concurrent operations using the same
1717836SJohn.Forte@Sun.COM 	 * job_request_t struct, such as a PLOGI to a group of remote ports
1727836SJohn.Forte@Sun.COM 	 * (see fp_plogi_group()).
1737836SJohn.Forte@Sun.COM 	 *
1747836SJohn.Forte@Sun.COM 	 * This is why this scheme needs the job_mutex to protect
1757836SJohn.Forte@Sun.COM 	 * the job_counter variable, plus the additional job_port_sema for
1767836SJohn.Forte@Sun.COM 	 * synchronizing thread(s).
1777836SJohn.Forte@Sun.COM 	 */
1787836SJohn.Forte@Sun.COM 	int		job_counter;
1797836SJohn.Forte@Sun.COM 
1807836SJohn.Forte@Sun.COM 
1817836SJohn.Forte@Sun.COM 	opaque_t	job_cb_arg;		/* callback func arg */
1827836SJohn.Forte@Sun.COM 
1837836SJohn.Forte@Sun.COM 	kmutex_t	job_mutex;
1847836SJohn.Forte@Sun.COM 	ksema_t		job_fctl_sema;
1857836SJohn.Forte@Sun.COM 	ksema_t		job_port_sema;
1867836SJohn.Forte@Sun.COM 
1877836SJohn.Forte@Sun.COM 
1887836SJohn.Forte@Sun.COM 	void		(*job_comp) (opaque_t, uchar_t result);
1897836SJohn.Forte@Sun.COM 	fc_packet_t	**job_ulp_pkts;
1907836SJohn.Forte@Sun.COM 	uint32_t	job_ulp_listlen;	/* packet list length */
1917836SJohn.Forte@Sun.COM 	void		*job_private;		/* caller's private */
1927836SJohn.Forte@Sun.COM 	void		*job_arg;		/* caller's argument */
1937836SJohn.Forte@Sun.COM 
1947836SJohn.Forte@Sun.COM 	/*
1957836SJohn.Forte@Sun.COM 	 * Pointer for singly-liked list of outstanding job_request structs,
1967836SJohn.Forte@Sun.COM 	 * maintained on a per-instance basis by the fp_port_head and
1977836SJohn.Forte@Sun.COM 	 * fp_port_tail pointers in the fc_local_port_t struct.
1987836SJohn.Forte@Sun.COM 	 */
199*10264SZhong.Wang@Sun.COM 	struct job_request	*job_next;
2007836SJohn.Forte@Sun.COM } job_request_t;
2017836SJohn.Forte@Sun.COM 
2027836SJohn.Forte@Sun.COM 
2037836SJohn.Forte@Sun.COM #if	!defined(__lint)
2047836SJohn.Forte@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("unique per request",
2057836SJohn.Forte@Sun.COM 	job_request::job_code job_request::job_result job_request::job_flags
2067836SJohn.Forte@Sun.COM 	job_request::job_cb_arg job_request::job_comp
2077836SJohn.Forte@Sun.COM 	job_request::job_ulp_pkts job_request::job_ulp_listlen
2087836SJohn.Forte@Sun.COM 	job_request::job_private job_request::job_arg))
2097836SJohn.Forte@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(fc_local_port::fp_mutex, job_request::job_next))
2107836SJohn.Forte@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(job_request::job_mutex, job_request::job_counter))
2117836SJohn.Forte@Sun.COM #endif	/* __lint */
2127836SJohn.Forte@Sun.COM 
2137836SJohn.Forte@Sun.COM 
2147836SJohn.Forte@Sun.COM /*
2157836SJohn.Forte@Sun.COM  * Values for the job_code field in the job_request_t struct.
2167836SJohn.Forte@Sun.COM  */
2177836SJohn.Forte@Sun.COM #define	JOB_ATTACH_ULP			1	/* ULP call to fc_ulp_add() */
2187836SJohn.Forte@Sun.COM #define	JOB_PORT_STARTUP		2
2197836SJohn.Forte@Sun.COM #define	JOB_PORT_GETMAP			3
2207836SJohn.Forte@Sun.COM #define	JOB_PORT_GETMAP_PLOGI_ALL	4
2217836SJohn.Forte@Sun.COM #define	JOB_PLOGI_ONE			5
2227836SJohn.Forte@Sun.COM #define	JOB_PLOGI_GROUP			6
2237836SJohn.Forte@Sun.COM #define	JOB_LOGO_ONE			7
2247836SJohn.Forte@Sun.COM #define	JOB_PORT_OFFLINE		8
2257836SJohn.Forte@Sun.COM #define	JOB_PORT_ONLINE			9
2267836SJohn.Forte@Sun.COM 
2277836SJohn.Forte@Sun.COM /* Prepare the local port and the driver softstate for a DDI_DETACH. */
2287836SJohn.Forte@Sun.COM #define	JOB_PORT_SHUTDOWN		10
2297836SJohn.Forte@Sun.COM 
2307836SJohn.Forte@Sun.COM /* Handle an unsolicited request in the job thread */
2317836SJohn.Forte@Sun.COM #define	JOB_UNSOL_REQUEST		11
2327836SJohn.Forte@Sun.COM 
2337836SJohn.Forte@Sun.COM #define	JOB_NS_CMD			12
2347836SJohn.Forte@Sun.COM #define	JOB_LINK_RESET			13
2357836SJohn.Forte@Sun.COM #define	JOB_ULP_NOTIFY			14
2367836SJohn.Forte@Sun.COM 
2377836SJohn.Forte@Sun.COM #define	JOB_FCIO_LOGIN			15
2387836SJohn.Forte@Sun.COM #define	JOB_FCIO_LOGOUT			16
2397836SJohn.Forte@Sun.COM 
2407836SJohn.Forte@Sun.COM /*
2417836SJohn.Forte@Sun.COM  * This is used for requests that will not actually be dispatched to the job
2427836SJohn.Forte@Sun.COM  * thread.
2437836SJohn.Forte@Sun.COM  */
2447836SJohn.Forte@Sun.COM #define	JOB_DUMMY			127
2457836SJohn.Forte@Sun.COM 
2467836SJohn.Forte@Sun.COM 
2477836SJohn.Forte@Sun.COM /*
2487836SJohn.Forte@Sun.COM  * Bitmask values for the job_flags field in the job_request_t struct.
2497836SJohn.Forte@Sun.COM  *
2507836SJohn.Forte@Sun.COM  * JOB_TYPE_FCTL_ASYNC is set in various places in fp and fctl. If set then
2517836SJohn.Forte@Sun.COM  * fctl_jobdone() will call the completion function in the job_comp field and
252*10264SZhong.Wang@Sun.COM  * deallocate the job_request_t struct.	 If not set then fctl_jobdone() will
2537836SJohn.Forte@Sun.COM  * sema_v() the job_fctl_sema to wake up any waiting thread.  This bit is also
2547836SJohn.Forte@Sun.COM  * checked in fc_ulp_login(): if *clear* then fc_ulp_login() will call
2557836SJohn.Forte@Sun.COM  * fctl_jobwait() in order to block the calling thread in the job_fctl_sema, and
2567836SJohn.Forte@Sun.COM  * then call fctl_dealloc_job() after fctl_jobwait() returns.
2577836SJohn.Forte@Sun.COM  *
2587836SJohn.Forte@Sun.COM  * JOB_TYPE_FP_ASYNC is set in various places in fp. If set then fp_jobdone()
2597836SJohn.Forte@Sun.COM  * will call fctl_jobdone(); if clear then fp_jobdone() will sema_v() the
260*10264SZhong.Wang@Sun.COM  * job_port_sema in the job_request_t.	fp_port_shutdown() also looks for
2617836SJohn.Forte@Sun.COM  * JOB_TYPE_FP_ASYNC.  Just to keep thing interesting, JOB_TYPE_FP_ASYNC is
2627836SJohn.Forte@Sun.COM  * also set in fp_validate_area_domain() and cleared in fp_fcio_login() and
2637836SJohn.Forte@Sun.COM  * fp_ns_get_devcount()
2647836SJohn.Forte@Sun.COM  *
2657836SJohn.Forte@Sun.COM  * The apparent purpose of all this is to allow nested job requests to
2667836SJohn.Forte@Sun.COM  * occur in parallel.
2677836SJohn.Forte@Sun.COM  *
2687836SJohn.Forte@Sun.COM  * JOB_CANCEL_ULP_NOTIFICATION appears to be intended to  the number of
2697836SJohn.Forte@Sun.COM  * state change callbacks that are reported to ULPs when mutiple state
2707836SJohn.Forte@Sun.COM  * changes are being processed in parallel.
2717836SJohn.Forte@Sun.COM  */
2727836SJohn.Forte@Sun.COM #define	JOB_TYPE_FCTL_ASYNC		0x01
2737836SJohn.Forte@Sun.COM #define	JOB_TYPE_FP_ASYNC		0x02
2747836SJohn.Forte@Sun.COM #define	JOB_CANCEL_ULP_NOTIFICATION	0x10
2757836SJohn.Forte@Sun.COM 
2767836SJohn.Forte@Sun.COM 
2777836SJohn.Forte@Sun.COM 
2787836SJohn.Forte@Sun.COM typedef struct fc_port_clist {
2797836SJohn.Forte@Sun.COM 	opaque_t	clist_port;		/* port handle */
2807836SJohn.Forte@Sun.COM 	uint32_t	clist_state;		/* port state */
2817836SJohn.Forte@Sun.COM 	uint32_t	clist_len;		/* map len */
2827836SJohn.Forte@Sun.COM 	uint32_t	clist_size;		/* alloc len */
283*10264SZhong.Wang@Sun.COM 	fc_portmap_t	*clist_map;		/* changelist */
2847836SJohn.Forte@Sun.COM 	uint32_t	clist_flags;		/* port topology */
2857836SJohn.Forte@Sun.COM 	uint32_t	clist_wait;		/* for synchronous requests */
2867836SJohn.Forte@Sun.COM 	kmutex_t	clist_mutex;		/* clist lock */
2877836SJohn.Forte@Sun.COM 	kcondvar_t	clist_cv;		/* clist cv */
2887836SJohn.Forte@Sun.COM } fc_port_clist_t;
2897836SJohn.Forte@Sun.COM 
2907836SJohn.Forte@Sun.COM #if	!defined(__lint)
2917836SJohn.Forte@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("unique per state change", fc_port_clist))
2927836SJohn.Forte@Sun.COM #endif	/* __lint */
2937836SJohn.Forte@Sun.COM 
2947836SJohn.Forte@Sun.COM /*
2957836SJohn.Forte@Sun.COM  * The cmd_size and resp_size shouldn't include the CT HEADER.
2967836SJohn.Forte@Sun.COM  *
2977836SJohn.Forte@Sun.COM  * For commands like GAN, the ns_resp_size should indicate the
2987836SJohn.Forte@Sun.COM  * total number of bytes allocated in the ns_resp_buf to get all
2997836SJohn.Forte@Sun.COM  * the NS objects.
3007836SJohn.Forte@Sun.COM  */
3017836SJohn.Forte@Sun.COM typedef struct fctl_ns_req {
3027836SJohn.Forte@Sun.COM 	int			ns_result;
3037836SJohn.Forte@Sun.COM 	uint32_t		ns_gan_index;
3047836SJohn.Forte@Sun.COM 	uint32_t		ns_gan_sid;
3057836SJohn.Forte@Sun.COM 	uint32_t		ns_flags;
3067836SJohn.Forte@Sun.COM 	uint16_t		ns_cmd_code;	/* NS command code */
3077836SJohn.Forte@Sun.COM 	caddr_t			ns_cmd_buf;	/* NS command buffer */
3087836SJohn.Forte@Sun.COM 	uint16_t		ns_cmd_size;	/* NS command length */
3097836SJohn.Forte@Sun.COM 	uint16_t		ns_resp_size;	/* NS response length */
3107836SJohn.Forte@Sun.COM 	caddr_t			ns_data_buf;	/* User buffer */
3117836SJohn.Forte@Sun.COM 	uint32_t		ns_data_len;	/* User buffer length */
3127836SJohn.Forte@Sun.COM 	uint32_t		ns_gan_max;
3137836SJohn.Forte@Sun.COM 	fc_ct_header_t		ns_resp_hdr;
3147836SJohn.Forte@Sun.COM 	fc_remote_port_t	*ns_pd;
3157836SJohn.Forte@Sun.COM } fctl_ns_req_t;
3167836SJohn.Forte@Sun.COM 
3177836SJohn.Forte@Sun.COM #if	!defined(__lint)
3187836SJohn.Forte@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("unique per state change", fctl_ns_req))
3197836SJohn.Forte@Sun.COM #endif	/* __lint */
3207836SJohn.Forte@Sun.COM 
3217836SJohn.Forte@Sun.COM /*
3227836SJohn.Forte@Sun.COM  * Orphan list of Port WWNs
3237836SJohn.Forte@Sun.COM  */
3247836SJohn.Forte@Sun.COM typedef struct fc_orphan {
3257836SJohn.Forte@Sun.COM 	int			orp_nscan;	/* Number of scans */
3267836SJohn.Forte@Sun.COM 	clock_t			orp_tstamp;	/* When it disappeared */
3277836SJohn.Forte@Sun.COM 	la_wwn_t		orp_pwwn;	/* Port WWN */
3287836SJohn.Forte@Sun.COM 	struct fc_orphan	*orp_next;	/* Next orphan */
3297836SJohn.Forte@Sun.COM } fc_orphan_t;
3307836SJohn.Forte@Sun.COM 
331*10264SZhong.Wang@Sun.COM #define	FC_GET_RSP(x_port, x_handle, x_dest, x_src, x_size, x_flag)	\
332*10264SZhong.Wang@Sun.COM 	{								\
333*10264SZhong.Wang@Sun.COM 		if (!((x_port)->fp_soft_state & FP_SOFT_FCA_IS_NODMA)) {\
334*10264SZhong.Wang@Sun.COM 			ddi_rep_get8((x_handle), (uint8_t *)(x_dest),	\
335*10264SZhong.Wang@Sun.COM 				    (uint8_t *)(x_src), (x_size),	\
336*10264SZhong.Wang@Sun.COM 				    (x_flag));				\
337*10264SZhong.Wang@Sun.COM 		} else {						\
338*10264SZhong.Wang@Sun.COM 			bcopy((x_src), (x_dest), (x_size));		\
339*10264SZhong.Wang@Sun.COM 		}							\
340*10264SZhong.Wang@Sun.COM 	}
341*10264SZhong.Wang@Sun.COM 
342*10264SZhong.Wang@Sun.COM #define	FC_SET_CMD(x_port, x_handle, x_src, x_dest, x_size, x_flag)	\
343*10264SZhong.Wang@Sun.COM 	{								\
344*10264SZhong.Wang@Sun.COM 		if (!((x_port)->fp_soft_state & FP_SOFT_FCA_IS_NODMA)) {\
345*10264SZhong.Wang@Sun.COM 			ddi_rep_put8((x_handle), (uint8_t *)(x_src),	\
346*10264SZhong.Wang@Sun.COM 				    (uint8_t *)(x_dest), (x_size),	\
347*10264SZhong.Wang@Sun.COM 				    (x_flag));				\
348*10264SZhong.Wang@Sun.COM 		} else {						\
349*10264SZhong.Wang@Sun.COM 			bcopy((x_src), (x_dest), (x_size));		\
350*10264SZhong.Wang@Sun.COM 		}							\
351*10264SZhong.Wang@Sun.COM 	}
352*10264SZhong.Wang@Sun.COM 
3537836SJohn.Forte@Sun.COM #if	!defined(__lint)
3547836SJohn.Forte@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("scans don't interleave",
355*10264SZhong.Wang@Sun.COM     fc_orphan::orp_nscan fc_orphan::orp_pwwn fc_orphan::orp_tstamp))
3567836SJohn.Forte@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(fc_local_port::fp_mutex, fc_orphan::orp_next))
3577836SJohn.Forte@Sun.COM #endif /* __lint */
3587836SJohn.Forte@Sun.COM 
3597836SJohn.Forte@Sun.COM fc_remote_node_t *fctl_create_remote_node(la_wwn_t *nwwn, int sleep);
3607836SJohn.Forte@Sun.COM void fctl_destroy_remote_node(fc_remote_node_t *rnp);
3617836SJohn.Forte@Sun.COM fc_remote_port_t *fctl_create_remote_port(fc_local_port_t *port,
3627836SJohn.Forte@Sun.COM     la_wwn_t *node_wwn, la_wwn_t *port_wwn, uint32_t d_id,
3637836SJohn.Forte@Sun.COM     uchar_t recepient, int sleep);
3647836SJohn.Forte@Sun.COM int fctl_destroy_remote_port(fc_local_port_t *port, fc_remote_port_t *pd);
3657836SJohn.Forte@Sun.COM fc_remote_port_t *fctl_alloc_remote_port(fc_local_port_t *port,
3667836SJohn.Forte@Sun.COM     la_wwn_t *port_wwn, uint32_t d_id, uchar_t recepient, int sleep);
3677836SJohn.Forte@Sun.COM void fctl_dealloc_remote_port(fc_remote_port_t *pd);
3687836SJohn.Forte@Sun.COM void fctl_release_remote_port(fc_remote_port_t *pd);
3697836SJohn.Forte@Sun.COM void fctl_destroy_all_remote_ports(fc_local_port_t *port);
3707836SJohn.Forte@Sun.COM void fctl_link_remote_port_to_remote_node(fc_remote_node_t *rnp,
3717836SJohn.Forte@Sun.COM     fc_remote_port_t *pd);
3727836SJohn.Forte@Sun.COM int fctl_unlink_remote_port_from_remote_node(fc_remote_node_t *rnp,
3737836SJohn.Forte@Sun.COM     fc_remote_port_t *pd);
3747836SJohn.Forte@Sun.COM 
3757836SJohn.Forte@Sun.COM job_request_t *fctl_alloc_job(int job_code, int job_flags,
3767836SJohn.Forte@Sun.COM     void (*comp) (opaque_t, uchar_t), opaque_t arg, int sleep);
3777836SJohn.Forte@Sun.COM void fctl_dealloc_job(job_request_t *job);
3787836SJohn.Forte@Sun.COM void fctl_enque_job(fc_local_port_t *port, job_request_t *job);
3797836SJohn.Forte@Sun.COM void fctl_priority_enque_job(fc_local_port_t *port, job_request_t *job);
3807836SJohn.Forte@Sun.COM job_request_t *fctl_deque_job(fc_local_port_t *port);
3817836SJohn.Forte@Sun.COM void fctl_jobwait(job_request_t *job);
3827836SJohn.Forte@Sun.COM void fctl_jobdone(job_request_t *job);
3837836SJohn.Forte@Sun.COM 
3847836SJohn.Forte@Sun.COM void fctl_attach_ulps(fc_local_port_t *port, fc_attach_cmd_t cmd,
3857836SJohn.Forte@Sun.COM     struct modlinkage *linkage);
3867836SJohn.Forte@Sun.COM int fctl_detach_ulps(fc_local_port_t *port, fc_detach_cmd_t cmd,
3877836SJohn.Forte@Sun.COM     struct modlinkage *linkage);
3887836SJohn.Forte@Sun.COM 
3897836SJohn.Forte@Sun.COM void fctl_add_port(fc_local_port_t *port);
3907836SJohn.Forte@Sun.COM void fctl_remove_port(fc_local_port_t *port);
3917836SJohn.Forte@Sun.COM int fctl_busy_port(fc_local_port_t *port);
3927836SJohn.Forte@Sun.COM void fctl_idle_port(fc_local_port_t *port);
3937836SJohn.Forte@Sun.COM 
3947836SJohn.Forte@Sun.COM fc_remote_port_t *fctl_get_remote_port_by_did(fc_local_port_t *port,
3957836SJohn.Forte@Sun.COM     uint32_t d_id);
3967836SJohn.Forte@Sun.COM fc_remote_port_t *fctl_hold_remote_port_by_did(fc_local_port_t *port,
3977836SJohn.Forte@Sun.COM     uint32_t d_id);
3987836SJohn.Forte@Sun.COM fc_remote_port_t *fctl_get_remote_port_by_pwwn(fc_local_port_t *port,
3997836SJohn.Forte@Sun.COM     la_wwn_t *pwwn);
4007836SJohn.Forte@Sun.COM fc_remote_port_t *fctl_hold_remote_port_by_pwwn(fc_local_port_t *port,
4017836SJohn.Forte@Sun.COM     la_wwn_t *pwwn);
4027836SJohn.Forte@Sun.COM fc_remote_port_t *
4037836SJohn.Forte@Sun.COM     fctl_get_remote_port_by_pwwn_mutex_held(fc_local_port_t *port,
4047836SJohn.Forte@Sun.COM     la_wwn_t *pwwn);
4057836SJohn.Forte@Sun.COM fc_remote_node_t *fctl_get_remote_node_by_nwwn(la_wwn_t *node_wwn);
4067836SJohn.Forte@Sun.COM fc_remote_node_t *fctl_lock_remote_node_by_nwwn(la_wwn_t *node_wwn);
4077836SJohn.Forte@Sun.COM fc_remote_port_t *fctl_lookup_pd_by_did(fc_local_port_t *port, uint32_t d_id);
4087836SJohn.Forte@Sun.COM fc_remote_port_t *fctl_lookup_pd_by_index(fc_local_port_t *port,
4097836SJohn.Forte@Sun.COM     uint32_t index);
4107836SJohn.Forte@Sun.COM fc_remote_port_t *fctl_lookup_pd_by_wwn(fc_local_port_t *port, la_wwn_t wwn);
4117836SJohn.Forte@Sun.COM 
4127836SJohn.Forte@Sun.COM void fctl_enlist_did_table(fc_local_port_t *port, fc_remote_port_t *pd);
4137836SJohn.Forte@Sun.COM void fctl_delist_did_table(fc_local_port_t *port, fc_remote_port_t *pd);
4147836SJohn.Forte@Sun.COM void fctl_enlist_pwwn_table(fc_local_port_t *port, fc_remote_port_t *pd);
4157836SJohn.Forte@Sun.COM void fctl_delist_pwwn_table(fc_local_port_t *port, fc_remote_port_t *pd);
4167836SJohn.Forte@Sun.COM int fctl_enlist_nwwn_table(fc_remote_node_t *rnp, int sleep);
4177836SJohn.Forte@Sun.COM void fctl_delist_nwwn_table(fc_remote_node_t *rnp);
4187836SJohn.Forte@Sun.COM 
4197836SJohn.Forte@Sun.COM void fctl_ulp_statec_cb(void *arg);
4207836SJohn.Forte@Sun.COM void fctl_ulp_unsol_cb(fc_local_port_t *port, fc_unsol_buf_t *buf,
4217836SJohn.Forte@Sun.COM     uchar_t type);
4227836SJohn.Forte@Sun.COM int fctl_ulp_port_ioctl(fc_local_port_t *port, dev_t dev, int cmd,
4237836SJohn.Forte@Sun.COM     intptr_t data, int mode, cred_t *credp, int *rval);
4247836SJohn.Forte@Sun.COM 
4257836SJohn.Forte@Sun.COM void fctl_fillout_map(fc_local_port_t *port, fc_portmap_t **map,
4267836SJohn.Forte@Sun.COM     uint32_t *len, int whole_map, int justcopy, int orphan);
4277836SJohn.Forte@Sun.COM void fctl_copy_portmap_held(fc_portmap_t *map, fc_remote_port_t *pd);
4287836SJohn.Forte@Sun.COM void fctl_copy_portmap(fc_portmap_t *map, fc_remote_port_t *pd);
4297836SJohn.Forte@Sun.COM 
4307836SJohn.Forte@Sun.COM fctl_ns_req_t *fctl_alloc_ns_cmd(uint32_t cmd_len, uint32_t resp_len,
4317836SJohn.Forte@Sun.COM     uint32_t data_len, uint32_t ns_flags, int sleep);
4327836SJohn.Forte@Sun.COM void fctl_free_ns_cmd(fctl_ns_req_t *ns_cmd);
4337836SJohn.Forte@Sun.COM 
4347836SJohn.Forte@Sun.COM int fctl_remove_if_orphan(fc_local_port_t *port, la_wwn_t *pwwn);
4357836SJohn.Forte@Sun.COM int fctl_add_orphan_held(fc_local_port_t *port, fc_remote_port_t *pd);
4367836SJohn.Forte@Sun.COM int fctl_add_orphan(fc_local_port_t *port, fc_remote_port_t *pd, int sleep);
4377836SJohn.Forte@Sun.COM void fctl_remove_oldies(fc_local_port_t *port);
4387836SJohn.Forte@Sun.COM 
4397836SJohn.Forte@Sun.COM int fctl_is_wwn_zero(la_wwn_t *wwn);
4407836SJohn.Forte@Sun.COM int fctl_wwn_cmp(la_wwn_t *src, la_wwn_t *dst);
4417836SJohn.Forte@Sun.COM int fctl_atoi(caddr_t string, int base);
4427836SJohn.Forte@Sun.COM int fctl_count_fru_ports(fc_local_port_t *port, int npivflag);
4437836SJohn.Forte@Sun.COM fc_local_port_t *fctl_get_adapter_port_by_index(fc_local_port_t *port,
4447836SJohn.Forte@Sun.COM 	uint32_t port_index);
4457836SJohn.Forte@Sun.COM 
4467836SJohn.Forte@Sun.COM void fctl_tc_constructor(timed_counter_t *tc, uint32_t max_value,
4477836SJohn.Forte@Sun.COM     clock_t timer);
4487836SJohn.Forte@Sun.COM void fctl_tc_destructor(timed_counter_t *tc);
4497836SJohn.Forte@Sun.COM boolean_t fctl_tc_increment(timed_counter_t *tc);
4507836SJohn.Forte@Sun.COM void fctl_tc_reset(timed_counter_t *tc);
4517836SJohn.Forte@Sun.COM 
4527836SJohn.Forte@Sun.COM #ifdef	__cplusplus
4537836SJohn.Forte@Sun.COM }
4547836SJohn.Forte@Sun.COM #endif
4557836SJohn.Forte@Sun.COM 
4567836SJohn.Forte@Sun.COM #endif	/* _FC_PORTIF_H */
457