xref: /onnv-gate/usr/src/uts/common/sys/fibre-channel/impl/fctl_private.h (revision 8494:b1310325fc32)
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*8494SReed.Liu@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	_FCTL_PRIVATE_H
277836SJohn.Forte@Sun.COM #define	_FCTL_PRIVATE_H
287836SJohn.Forte@Sun.COM 
297836SJohn.Forte@Sun.COM 
307836SJohn.Forte@Sun.COM #include <sys/note.h>
317836SJohn.Forte@Sun.COM 
327836SJohn.Forte@Sun.COM #include <sys/fibre-channel/impl/fc_ulpif.h>
337836SJohn.Forte@Sun.COM 
347836SJohn.Forte@Sun.COM #ifdef	__cplusplus
357836SJohn.Forte@Sun.COM extern "C" {
367836SJohn.Forte@Sun.COM #endif
377836SJohn.Forte@Sun.COM 
387836SJohn.Forte@Sun.COM /*
397836SJohn.Forte@Sun.COM  * Stuff strictly internal to fctl that
407836SJohn.Forte@Sun.COM  * isn't exposed to any other modules.
417836SJohn.Forte@Sun.COM  */
427836SJohn.Forte@Sun.COM #define	PWWN_HASH_TABLE_SIZE	(32)		/* 2^n */
437836SJohn.Forte@Sun.COM #define	D_ID_HASH_TABLE_SIZE	(32)		/* 2^n */
447836SJohn.Forte@Sun.COM #define	NWWN_HASH_TABLE_SIZE	(32)		/* 2^n */
457836SJohn.Forte@Sun.COM #define	HASH_FUNC(key, size)	((key) & (size - 1))
467836SJohn.Forte@Sun.COM #define	WWN_HASH_KEY(x)		((x)[0] + (x)[1] + (x)[2] +\
477836SJohn.Forte@Sun.COM 				    (x)[3] + (x)[4] + (x)[5] +\
487836SJohn.Forte@Sun.COM 				    (x)[6] + (x)[7])
497836SJohn.Forte@Sun.COM #define	D_ID_HASH_FUNC(x, size)	((x) & (size - 1))
507836SJohn.Forte@Sun.COM #define	FC4_TYPE_WORD_POS(x)	((uchar_t)(x) >> 5)
517836SJohn.Forte@Sun.COM #define	FC4_TYPE_BIT_POS(x)	((uchar_t)(x) & 0x1F)
527836SJohn.Forte@Sun.COM #define	FC_ACTION_INVALID	-1
537836SJohn.Forte@Sun.COM #define	FC_REASON_INVALID	-1
547836SJohn.Forte@Sun.COM #define	FC_EXPLN_INVALID	-1
557836SJohn.Forte@Sun.COM 
567836SJohn.Forte@Sun.COM /*
577836SJohn.Forte@Sun.COM  * Internally translated and used state change values to ULPs
587836SJohn.Forte@Sun.COM  */
597836SJohn.Forte@Sun.COM #define	FC_ULP_STATEC_DONT_CARE		0
607836SJohn.Forte@Sun.COM #define	FC_ULP_STATEC_ONLINE		1
617836SJohn.Forte@Sun.COM #define	FC_ULP_STATEC_OFFLINE		2
627836SJohn.Forte@Sun.COM #define	FC_ULP_STATEC_OFFLINE_TIMEOUT	3
637836SJohn.Forte@Sun.COM 
647836SJohn.Forte@Sun.COM #define	FC_ULP_ADD_RETRY_COUNT		90
657836SJohn.Forte@Sun.COM #define	FC_MAX_TRACE_BUF_LEN		512
667836SJohn.Forte@Sun.COM 
677836SJohn.Forte@Sun.COM 
687836SJohn.Forte@Sun.COM #define	FC_NPIV_MAX_PORT		255
697836SJohn.Forte@Sun.COM 
707836SJohn.Forte@Sun.COM /*
717836SJohn.Forte@Sun.COM  * port_dstate values
727836SJohn.Forte@Sun.COM  */
737836SJohn.Forte@Sun.COM #define	ULP_PORT_ATTACH			0x01
747836SJohn.Forte@Sun.COM #define	ULP_PORT_SUSPEND		0x02
757836SJohn.Forte@Sun.COM #define	ULP_PORT_POWER_DOWN		0x04
767836SJohn.Forte@Sun.COM #define	ULP_PORT_BUSY			0x08
777836SJohn.Forte@Sun.COM #define	FCTL_DISALLOW_CALLBACKS(x)	(!((x) & ULP_PORT_ATTACH) ||\
787836SJohn.Forte@Sun.COM 					((x) & ULP_PORT_BUSY))
797836SJohn.Forte@Sun.COM 
807836SJohn.Forte@Sun.COM typedef struct ulp_ports {
81*8494SReed.Liu@Sun.COM 	struct ulp_ports	*port_next;
827836SJohn.Forte@Sun.COM 	int			port_dstate;
837836SJohn.Forte@Sun.COM 	uint32_t		port_statec;
847836SJohn.Forte@Sun.COM 	kmutex_t		port_mutex;
857836SJohn.Forte@Sun.COM 	struct fc_local_port	*port_handle;
867836SJohn.Forte@Sun.COM } fc_ulp_ports_t;
877836SJohn.Forte@Sun.COM 
887836SJohn.Forte@Sun.COM 
897836SJohn.Forte@Sun.COM typedef struct ulp_module {
90*8494SReed.Liu@Sun.COM 	struct ulp_module	*mod_next;
91*8494SReed.Liu@Sun.COM 	fc_ulp_modinfo_t	*mod_info;
927836SJohn.Forte@Sun.COM 	fc_ulp_ports_t		*mod_ports;
937836SJohn.Forte@Sun.COM } fc_ulp_module_t;
947836SJohn.Forte@Sun.COM 
957836SJohn.Forte@Sun.COM 
967836SJohn.Forte@Sun.COM typedef struct ulp_list {
977836SJohn.Forte@Sun.COM 	fc_ulp_modinfo_t	*ulp_info;
987836SJohn.Forte@Sun.COM 	struct ulp_list		*ulp_next;
997836SJohn.Forte@Sun.COM } fc_ulp_list_t;
1007836SJohn.Forte@Sun.COM 
1017836SJohn.Forte@Sun.COM 
1027836SJohn.Forte@Sun.COM typedef struct fca_port {
103*8494SReed.Liu@Sun.COM 	struct fca_port		*port_next;
1047836SJohn.Forte@Sun.COM 	struct fc_local_port	*port_handle;
1057836SJohn.Forte@Sun.COM } fc_fca_port_t;
1067836SJohn.Forte@Sun.COM 
1077836SJohn.Forte@Sun.COM typedef struct timed_counter {
1087836SJohn.Forte@Sun.COM 	struct timed_counter	*sig;
1097836SJohn.Forte@Sun.COM 	uint32_t		counter;
1107836SJohn.Forte@Sun.COM 	uint32_t		max_value;
1117836SJohn.Forte@Sun.COM 	boolean_t		maxed_out;
1127836SJohn.Forte@Sun.COM 	kmutex_t		mutex;
1137836SJohn.Forte@Sun.COM 	boolean_t		active;
1147836SJohn.Forte@Sun.COM 	clock_t			timer;
1157836SJohn.Forte@Sun.COM 	timeout_id_t		tid;
1167836SJohn.Forte@Sun.COM } timed_counter_t;
1177836SJohn.Forte@Sun.COM 
1187836SJohn.Forte@Sun.COM /*
1197836SJohn.Forte@Sun.COM  * Struct describing a remote node. A remote node is associated with one
1207836SJohn.Forte@Sun.COM  * or more remote ports (fc_remote_port_t structs) that are all accessible
1217836SJohn.Forte@Sun.COM  * through one local port (fc_local_port_t struct).
1227836SJohn.Forte@Sun.COM  *
1237836SJohn.Forte@Sun.COM  * Each fc_remote_node_t struct is also referenced by nwwn in the global
1247836SJohn.Forte@Sun.COM  * nwwn_hash_table[] list.
1257836SJohn.Forte@Sun.COM  */
1267836SJohn.Forte@Sun.COM typedef struct fc_remote_node {
1277836SJohn.Forte@Sun.COM 	/*
1287836SJohn.Forte@Sun.COM 	 * Mutex lock to protect access to all members of this struct.
1297836SJohn.Forte@Sun.COM 	 * Current implementation dictates acquisition of fd_mutex before
1307836SJohn.Forte@Sun.COM 	 * pd_mutex can be acquired (when both locks must be acquired).
1317836SJohn.Forte@Sun.COM 	 */
1327836SJohn.Forte@Sun.COM 	kmutex_t		fd_mutex;
1337836SJohn.Forte@Sun.COM 
1347836SJohn.Forte@Sun.COM 	/* Node WWN for the remote node */
1357836SJohn.Forte@Sun.COM 	la_wwn_t		fd_node_name;
1367836SJohn.Forte@Sun.COM 
1377836SJohn.Forte@Sun.COM 	/*
1387836SJohn.Forte@Sun.COM 	 * This is the number of (active) fc_remote_port_t structs that
1397836SJohn.Forte@Sun.COM 	 * are associated with this remote node.
1407836SJohn.Forte@Sun.COM 	 */
1417836SJohn.Forte@Sun.COM 	int			fd_numports;
1427836SJohn.Forte@Sun.COM 
1437836SJohn.Forte@Sun.COM 	/*
1447836SJohn.Forte@Sun.COM 	 * Tracks whether this struct is "valid" or "invalid", using the
1457836SJohn.Forte@Sun.COM 	 * FC_REMOTE_NODE_* values given above.
1467836SJohn.Forte@Sun.COM 	 */
1477836SJohn.Forte@Sun.COM 	int			fd_flags;
1487836SJohn.Forte@Sun.COM 
1497836SJohn.Forte@Sun.COM 	/* Linked list of remote ports associated with this remote node. */
150*8494SReed.Liu@Sun.COM 	struct fc_remote_port	*fd_portlistp;
1517836SJohn.Forte@Sun.COM 
1527836SJohn.Forte@Sun.COM 	uchar_t			fd_ipa[8];	/* Initial proc assoc */
1537836SJohn.Forte@Sun.COM 	uchar_t			fd_vv[16];	/* Vendor Version */
1547836SJohn.Forte@Sun.COM 	uchar_t			fd_snn_len;	/* node symbolic name len */
1557836SJohn.Forte@Sun.COM 	uchar_t			fd_snn[255];	/* node symbolic name */
1567836SJohn.Forte@Sun.COM } fc_remote_node_t;
1577836SJohn.Forte@Sun.COM 
1587836SJohn.Forte@Sun.COM /*
1597836SJohn.Forte@Sun.COM  * Stack depth for troubleshooting (only used in debug code)
1607836SJohn.Forte@Sun.COM  */
1617836SJohn.Forte@Sun.COM #define	FC_STACK_DEPTH			14
1627836SJohn.Forte@Sun.COM 
1637836SJohn.Forte@Sun.COM /*
1647836SJohn.Forte@Sun.COM  * The fc_remote_port_t struct represents a remote FC port that is
1657836SJohn.Forte@Sun.COM  * accessible via the local FC port (fc_local_port_t). Each remote
1667836SJohn.Forte@Sun.COM  * FC port is associated with one FC local port (fc_local_port_t,
1677836SJohn.Forte@Sun.COM  * above) and one remote FC node (fc_remote_node_t, see below).
1687836SJohn.Forte@Sun.COM  * fc_remote_port_t structs are created and destroyed as needed to
1697836SJohn.Forte@Sun.COM  * correspond with changing conditions out on the link.
1707836SJohn.Forte@Sun.COM  */
1717836SJohn.Forte@Sun.COM typedef struct fc_remote_port {
1727836SJohn.Forte@Sun.COM 	/*
1737836SJohn.Forte@Sun.COM 	 * Ah, the infamous 'pd_mutex' that has given developers so much
1747836SJohn.Forte@Sun.COM 	 * joy over the years....
1757836SJohn.Forte@Sun.COM 	 * (Gotta love the original, extremely helpful comment.)
1767836SJohn.Forte@Sun.COM 	 */
1777836SJohn.Forte@Sun.COM 	kmutex_t		pd_mutex;	/* mutex */
1787836SJohn.Forte@Sun.COM 
1797836SJohn.Forte@Sun.COM 	fc_portid_t		pd_port_id;	/* Port Identifier */
1807836SJohn.Forte@Sun.COM 	la_wwn_t		pd_port_name;	/* the port WWN */
1817836SJohn.Forte@Sun.COM 
1827836SJohn.Forte@Sun.COM 	/*
1837836SJohn.Forte@Sun.COM 	 * Reference count of the # of logins initiated by a ULP
1847836SJohn.Forte@Sun.COM 	 * (i.e., this is the # of ULPs accessing the struct). See
1857836SJohn.Forte@Sun.COM 	 * fp_plogi_group() for more info.
1867836SJohn.Forte@Sun.COM 	 */
1877836SJohn.Forte@Sun.COM 	int			pd_login_count;
1887836SJohn.Forte@Sun.COM 
1897836SJohn.Forte@Sun.COM 	/*
1907836SJohn.Forte@Sun.COM 	 * This appears to track the login state of the remote FC port.
1917836SJohn.Forte@Sun.COM 	 * Used with the PORT_DEVICE_* macros in fc_appif.h.
1927836SJohn.Forte@Sun.COM 	 */
1937836SJohn.Forte@Sun.COM 	uint32_t		pd_state;
1947836SJohn.Forte@Sun.COM 
1957836SJohn.Forte@Sun.COM 	/*
1967836SJohn.Forte@Sun.COM 	 * Link pointers for the port wwn and D_ID hash lists. These point
1977836SJohn.Forte@Sun.COM 	 * to the next remote port in the current hash chain.
1987836SJohn.Forte@Sun.COM 	 */
199*8494SReed.Liu@Sun.COM 	struct fc_remote_port	*pd_wwn_hnext;
200*8494SReed.Liu@Sun.COM 	struct fc_remote_port	*pd_did_hnext;
2017836SJohn.Forte@Sun.COM 
2027836SJohn.Forte@Sun.COM 	/*
2037836SJohn.Forte@Sun.COM 	 * Link pointer for list of *all* fc_remote_port_t structs
2047836SJohn.Forte@Sun.COM 	 * associated with the same fc_local_port_t struct.
2057836SJohn.Forte@Sun.COM 	 */
206*8494SReed.Liu@Sun.COM 	struct fc_remote_port	*pd_port_next;
2077836SJohn.Forte@Sun.COM 
2087836SJohn.Forte@Sun.COM 	/*
2097836SJohn.Forte@Sun.COM 	 * Pointer to the fc_remote_node_t struct for the remote node
2107836SJohn.Forte@Sun.COM 	 * associated with the remote port.
2117836SJohn.Forte@Sun.COM 	 */
212*8494SReed.Liu@Sun.COM 	struct fc_remote_node	*pd_remote_nodep;
2137836SJohn.Forte@Sun.COM 
2147836SJohn.Forte@Sun.COM 	/* port type for the remote port */
2157836SJohn.Forte@Sun.COM 	fc_porttype_t		pd_porttype;
2167836SJohn.Forte@Sun.COM 
2177836SJohn.Forte@Sun.COM 	fc_hardaddr_t		pd_hard_addr;	/* Hard Address */
2187836SJohn.Forte@Sun.COM 
2197836SJohn.Forte@Sun.COM 	/*
2207836SJohn.Forte@Sun.COM 	 * Back pointer to the fc_local_port_t struct for the local port
2217836SJohn.Forte@Sun.COM 	 * associated with this remote port.
2227836SJohn.Forte@Sun.COM 	 */
2237836SJohn.Forte@Sun.COM 	struct fc_local_port	*pd_port;
2247836SJohn.Forte@Sun.COM 
2257836SJohn.Forte@Sun.COM 	/*
2267836SJohn.Forte@Sun.COM 	 * (Sigh) this actually doesn't have anything to do with the "type"
2277836SJohn.Forte@Sun.COM 	 * of the remote port per se.  It's really more an indicator of the
2287836SJohn.Forte@Sun.COM 	 * most recently known state/status of the remote port. It's intended
2297836SJohn.Forte@Sun.COM 	 * to help figure out if/how the remote port has either gone away or
2307836SJohn.Forte@Sun.COM 	 * changed somehow after an event has occurred on the link.
2317836SJohn.Forte@Sun.COM 	 * There also seems to be some connection to the "changed map".
2327836SJohn.Forte@Sun.COM 	 *
2337836SJohn.Forte@Sun.COM 	 * The legal values for this are the PORT_DEVICE_* definitions
2347836SJohn.Forte@Sun.COM 	 * earlier in this file.
2357836SJohn.Forte@Sun.COM 	 */
2367836SJohn.Forte@Sun.COM 	uchar_t			pd_type;	/* new or old */
2377836SJohn.Forte@Sun.COM 
2387836SJohn.Forte@Sun.COM 	/*
2397836SJohn.Forte@Sun.COM 	 * This tracks the current state/status of a login attempt at the
240*8494SReed.Liu@Sun.COM 	 * remote port.	 Legal values are given above.
2417836SJohn.Forte@Sun.COM 	 * See also the pd_state field.
2427836SJohn.Forte@Sun.COM 	 */
2437836SJohn.Forte@Sun.COM 	uchar_t			pd_flags;	/* login in progress */
2447836SJohn.Forte@Sun.COM 
2457836SJohn.Forte@Sun.COM 	uchar_t			pd_login_class;	/* Logi Class */
2467836SJohn.Forte@Sun.COM 
2477836SJohn.Forte@Sun.COM 	/* Legal values are given above (beware of the mipselling) */
2487836SJohn.Forte@Sun.COM 	uchar_t			pd_recepient;	/* who did PLOGI? */
2497836SJohn.Forte@Sun.COM 
2507836SJohn.Forte@Sun.COM 	uchar_t			pd_ip_addr[8];	/* IP address */
2517836SJohn.Forte@Sun.COM 	uint32_t		pd_fc4types[8];	/* FC-4 types */
2527836SJohn.Forte@Sun.COM 	uint32_t		pd_cos;		/* class of service */
253*8494SReed.Liu@Sun.COM 	struct common_service	pd_csp;		/* common service */
254*8494SReed.Liu@Sun.COM 	struct service_param	pd_clsp1;	/* Class 1 */
255*8494SReed.Liu@Sun.COM 	struct service_param	pd_clsp2;	/* Class 2 */
256*8494SReed.Liu@Sun.COM 	struct service_param	pd_clsp3;	/* Class 3 */
2577836SJohn.Forte@Sun.COM 
2587836SJohn.Forte@Sun.COM 	/* This is _SO_ private that even we don't use it */
2597836SJohn.Forte@Sun.COM 	caddr_t			pd_private;	/* private data */
2607836SJohn.Forte@Sun.COM 
2617836SJohn.Forte@Sun.COM 	/*
2627836SJohn.Forte@Sun.COM 	 * This is a count of the number of references to (or holds on)
2637836SJohn.Forte@Sun.COM 	 * this remote port.
2647836SJohn.Forte@Sun.COM 	 */
2657836SJohn.Forte@Sun.COM 	int			pd_ref_count;	/* number of references */
2667836SJohn.Forte@Sun.COM 
2677836SJohn.Forte@Sun.COM 	/*
2687836SJohn.Forte@Sun.COM 	 * Re-login disable for FCP-2 error recovery.  This is intended to
2697836SJohn.Forte@Sun.COM 	 * help with tape devices when an RSCN or Link Reset occurs during
2707836SJohn.Forte@Sun.COM 	 * a long write operations (like backup). fp's default action is
2717836SJohn.Forte@Sun.COM 	 * to try to log in again, but that forces a rewind on the LUN
2727836SJohn.Forte@Sun.COM 	 * and corrupts its state.
2737836SJohn.Forte@Sun.COM 	 *
2747836SJohn.Forte@Sun.COM 	 * The legal bit values are given below. Some specific definitions
2757836SJohn.Forte@Sun.COM 	 * are as follows:
2767836SJohn.Forte@Sun.COM 	 *
2777836SJohn.Forte@Sun.COM 	 *   PD_IN_DID_QUEUE: The fc_remote_port_t is present in the d_id
2787836SJohn.Forte@Sun.COM 	 *		    hash list of the associated fc_local_port_t.  (This
2797836SJohn.Forte@Sun.COM 	 *		    is apparently meant to cover some races).
2807836SJohn.Forte@Sun.COM 	 *   PD_LOGGED_OUT: This is a directive to ignore the NORELOGIN if
2817836SJohn.Forte@Sun.COM 	 *		    an actual logout occurred
2827836SJohn.Forte@Sun.COM 	 */
2837836SJohn.Forte@Sun.COM 	uchar_t			pd_aux_flags;	/* relogin disable */
2847836SJohn.Forte@Sun.COM 
285*8494SReed.Liu@Sun.COM 	uchar_t			pd_spn_len;	/* length of sym name */
286*8494SReed.Liu@Sun.COM 	char			pd_spn[255];	/* symbolic port name */
2877836SJohn.Forte@Sun.COM 
2887836SJohn.Forte@Sun.COM 	/*
2897836SJohn.Forte@Sun.COM 	 * Count of the # of unsolicited LOGOs received. See the definition
2907836SJohn.Forte@Sun.COM 	 * of FC_LOGO_TOLERANCE_LIMIT in fp.c.
2917836SJohn.Forte@Sun.COM 	 */
2927836SJohn.Forte@Sun.COM 	timed_counter_t		pd_logo_tc;
2937836SJohn.Forte@Sun.COM 
2947836SJohn.Forte@Sun.COM #ifdef	DEBUG
2957836SJohn.Forte@Sun.COM 	int			pd_w_depth;	/* for WWN hash table */
2967836SJohn.Forte@Sun.COM 	pc_t			pd_w_stack[FC_STACK_DEPTH];
2977836SJohn.Forte@Sun.COM 	int			pd_d_depth;	/* for D_ID hash table */
2987836SJohn.Forte@Sun.COM 	pc_t			pd_d_stack[FC_STACK_DEPTH];
2997836SJohn.Forte@Sun.COM #endif
3007836SJohn.Forte@Sun.COM } fc_remote_port_t;
3017836SJohn.Forte@Sun.COM 
3027836SJohn.Forte@Sun.COM 
3037836SJohn.Forte@Sun.COM /*
3047836SJohn.Forte@Sun.COM  * Structs for the global nwwn_hash_table[] entries.
3057836SJohn.Forte@Sun.COM  *
3067836SJohn.Forte@Sun.COM  * At _init() time, fctl allocates an array of fctl_nwwn_list_t structs that
307*8494SReed.Liu@Sun.COM  * has nwwn_table_size entries.	 The hash_head member anchors a linked
3087836SJohn.Forte@Sun.COM  * list of fctl_nwwn_elem_t structs that are linked via the fne_next pointer.
3097836SJohn.Forte@Sun.COM  * Each fctl_nwwn_elem_t also contains a pointer to one fc_remote_node_t struct.
3107836SJohn.Forte@Sun.COM  */
3117836SJohn.Forte@Sun.COM typedef struct fctl_nwwn_elem fctl_nwwn_elem_t;
3127836SJohn.Forte@Sun.COM 
3137836SJohn.Forte@Sun.COM struct fctl_nwwn_elem {
3147836SJohn.Forte@Sun.COM 	fctl_nwwn_elem_t	*fne_nextp;
315*8494SReed.Liu@Sun.COM 	fc_remote_node_t	*fne_nodep;
3167836SJohn.Forte@Sun.COM };
3177836SJohn.Forte@Sun.COM 
3187836SJohn.Forte@Sun.COM typedef struct fctl_nwwn_list {
3197836SJohn.Forte@Sun.COM 	fctl_nwwn_elem_t	*fnl_headp;
3207836SJohn.Forte@Sun.COM } fctl_nwwn_list_t;
3217836SJohn.Forte@Sun.COM 
3227836SJohn.Forte@Sun.COM 
3237836SJohn.Forte@Sun.COM 
3247836SJohn.Forte@Sun.COM typedef struct fc_errmap {
3257836SJohn.Forte@Sun.COM 	int	fc_errno;
3267836SJohn.Forte@Sun.COM 	char	*fc_errname;
3277836SJohn.Forte@Sun.COM } fc_errmap_t;
3287836SJohn.Forte@Sun.COM 
3297836SJohn.Forte@Sun.COM 
3307836SJohn.Forte@Sun.COM typedef struct fc_pkt_reason {
3317836SJohn.Forte@Sun.COM 	int	reason_val;
3327836SJohn.Forte@Sun.COM 	char	*reason_msg;
3337836SJohn.Forte@Sun.COM } fc_pkt_reason_t;
3347836SJohn.Forte@Sun.COM 
3357836SJohn.Forte@Sun.COM 
3367836SJohn.Forte@Sun.COM typedef struct fc_pkt_action {
3377836SJohn.Forte@Sun.COM 	int	action_val;
3387836SJohn.Forte@Sun.COM 	char	*action_msg;
3397836SJohn.Forte@Sun.COM } fc_pkt_action_t;
3407836SJohn.Forte@Sun.COM 
3417836SJohn.Forte@Sun.COM 
3427836SJohn.Forte@Sun.COM typedef struct fc_pkt_expln {
3437836SJohn.Forte@Sun.COM 	int	expln_val;
3447836SJohn.Forte@Sun.COM 	char	*expln_msg;
3457836SJohn.Forte@Sun.COM } fc_pkt_expln_t;
3467836SJohn.Forte@Sun.COM 
3477836SJohn.Forte@Sun.COM 
3487836SJohn.Forte@Sun.COM typedef struct fc_pkt_error {
3497836SJohn.Forte@Sun.COM 	int			pkt_state;
3507836SJohn.Forte@Sun.COM 	char			*pkt_msg;
3517836SJohn.Forte@Sun.COM 	fc_pkt_reason_t		*pkt_reason;
3527836SJohn.Forte@Sun.COM 	fc_pkt_action_t		*pkt_action;
3537836SJohn.Forte@Sun.COM 	fc_pkt_expln_t		*pkt_expln;
3547836SJohn.Forte@Sun.COM } fc_pkt_error_t;
3557836SJohn.Forte@Sun.COM 
3567836SJohn.Forte@Sun.COM 
3577836SJohn.Forte@Sun.COM /*
3587836SJohn.Forte@Sun.COM  * Values for the fd_flags field in the fc_remote_node_t struct.
3597836SJohn.Forte@Sun.COM  * Note, the code seems to rely on the struct initialization using
3607836SJohn.Forte@Sun.COM  * kmem_zalloc() to set all the bits to zero, since FC_REMOTE_NODE_INVALID
3617836SJohn.Forte@Sun.COM  * is never explicitly set anywhere.
3627836SJohn.Forte@Sun.COM  */
3637836SJohn.Forte@Sun.COM #define	FC_REMOTE_NODE_INVALID	0
3647836SJohn.Forte@Sun.COM #define	FC_REMOTE_NODE_VALID	1
3657836SJohn.Forte@Sun.COM 
3667836SJohn.Forte@Sun.COM 
3677836SJohn.Forte@Sun.COM /*
3687836SJohn.Forte@Sun.COM  * Values for the pd_flags field in the fc_remote_port_t struct.  These
3697836SJohn.Forte@Sun.COM  * are used in a _lot_ of places. NOTE: these are values, not bit flags.
3707836SJohn.Forte@Sun.COM  */
3717836SJohn.Forte@Sun.COM #define	PD_IDLE			0x00
3727836SJohn.Forte@Sun.COM #define	PD_ELS_IN_PROGRESS	0x01
3737836SJohn.Forte@Sun.COM #define	PD_ELS_MARK		0x02
3747836SJohn.Forte@Sun.COM 
3757836SJohn.Forte@Sun.COM 
3767836SJohn.Forte@Sun.COM /*
3777836SJohn.Forte@Sun.COM  * Bit values for the pd_aux_flags field in the fc_remote_port_t struct.
3787836SJohn.Forte@Sun.COM  */
3797836SJohn.Forte@Sun.COM #define	PD_IN_DID_QUEUE		0x01	/* The fc_remote_port_t is present */
3807836SJohn.Forte@Sun.COM 					/* in the D_ID hash list of the */
3817836SJohn.Forte@Sun.COM 					/* associated fc_local_port_t. (This */
3827836SJohn.Forte@Sun.COM 					/* is apparently meant to narrow */
3837836SJohn.Forte@Sun.COM 					/* some race windows). */
3847836SJohn.Forte@Sun.COM #define	PD_DISABLE_RELOGIN	0x02
3857836SJohn.Forte@Sun.COM #define	PD_NEEDS_REMOVAL	0x04
3867836SJohn.Forte@Sun.COM #define	PD_LOGGED_OUT		0x08	/* This is a directive to ignore */
3877836SJohn.Forte@Sun.COM 					/* the NORELOGIN if an actual logout */
3887836SJohn.Forte@Sun.COM 					/* occurred */
3897836SJohn.Forte@Sun.COM #define	PD_GIVEN_TO_ULPS	0x10	/* A reference to this pd has been */
3907836SJohn.Forte@Sun.COM 					/* given to one or more ULPs. */
3917836SJohn.Forte@Sun.COM 
3927836SJohn.Forte@Sun.COM /*
3937836SJohn.Forte@Sun.COM  * Values for the pd_recepient field in the fc_remote_port_t struct.
3947836SJohn.Forte@Sun.COM  * Tries to describe where a PLOGI attempt originated.
3957836SJohn.Forte@Sun.COM  */
3967836SJohn.Forte@Sun.COM #define	PD_PLOGI_INITIATOR		0
3977836SJohn.Forte@Sun.COM #define	PD_PLOGI_RECEPIENT		1
3987836SJohn.Forte@Sun.COM 
3997836SJohn.Forte@Sun.COM 
4007836SJohn.Forte@Sun.COM /*
4017836SJohn.Forte@Sun.COM  * The fc_local_port_t struct represents a local FC port. It is the softstate
4027836SJohn.Forte@Sun.COM  * struct for each fp instance, so it comes into existence at DDI_ATTACH
4037836SJohn.Forte@Sun.COM  * and is deleted during DDI_DETACH.
4047836SJohn.Forte@Sun.COM  */
4057836SJohn.Forte@Sun.COM typedef struct fc_local_port {
4067836SJohn.Forte@Sun.COM 	/*
4077836SJohn.Forte@Sun.COM 	 * Mutex to protect certain data fields in this struct.
4087836SJohn.Forte@Sun.COM 	 */
4097836SJohn.Forte@Sun.COM 	kmutex_t		fp_mutex;
4107836SJohn.Forte@Sun.COM 
4117836SJohn.Forte@Sun.COM 	/*
4127836SJohn.Forte@Sun.COM 	 * fp_state sort of tracks the state of the link at the local port.
4137836SJohn.Forte@Sun.COM 	 * The actual 'state' is kept in the lower byte, and the port speed
4147836SJohn.Forte@Sun.COM 	 * is kept in the next most significant byte.  The code makes
4157836SJohn.Forte@Sun.COM 	 * extensive use of the FC_PORT_SPEED_MASK() and FC_PORT_STATE_MASK()
416*8494SReed.Liu@Sun.COM 	 * macros to separate these two items.	The current link topology
4177836SJohn.Forte@Sun.COM 	 * is actually kept separately in the fp_topology field.
4187836SJohn.Forte@Sun.COM 	 * The legal values for fp_state are given above.
4197836SJohn.Forte@Sun.COM 	 */
4207836SJohn.Forte@Sun.COM 	volatile uint32_t	fp_state;
4217836SJohn.Forte@Sun.COM 
4227836SJohn.Forte@Sun.COM 	/*
4237836SJohn.Forte@Sun.COM 	 * The S_ID for the local port. See fc_types.h for the fc_portid_t
4247836SJohn.Forte@Sun.COM 	 * definition.
4257836SJohn.Forte@Sun.COM 	 */
4267836SJohn.Forte@Sun.COM 	fc_portid_t		fp_port_id;
4277836SJohn.Forte@Sun.COM 
4287836SJohn.Forte@Sun.COM 	/*
4297836SJohn.Forte@Sun.COM 	 * Opaque reference handle for the local port device. This value
4307836SJohn.Forte@Sun.COM 	 * is supplied by the FCA driver and is passed unaltered to
4317836SJohn.Forte@Sun.COM 	 * various FCA driver entry point functions.
4327836SJohn.Forte@Sun.COM 	 */
4337836SJohn.Forte@Sun.COM 	opaque_t		fp_fca_handle;
4347836SJohn.Forte@Sun.COM 
4357836SJohn.Forte@Sun.COM 	/* Entry point vectors for the FCA driver at this FC port */
4367836SJohn.Forte@Sun.COM 	struct fca_tran		*fp_fca_tran;
4377836SJohn.Forte@Sun.COM 
4387836SJohn.Forte@Sun.COM 	/*
4397836SJohn.Forte@Sun.COM 	 * fp's homegrown "job" threading mechanism (not a Solaris DDI taskq).
4407836SJohn.Forte@Sun.COM 	 *
4417836SJohn.Forte@Sun.COM 	 * Head/tail pointers for a linked list of requests to be executed
442*8494SReed.Liu@Sun.COM 	 * in a driver-private thread.	One thread per fc_local_port_t struct.
4437836SJohn.Forte@Sun.COM 	 * The thread is created during DDI_ATTACH for the instance.
4447836SJohn.Forte@Sun.COM 	 */
4457836SJohn.Forte@Sun.COM 	struct job_request	*fp_job_head;
4467836SJohn.Forte@Sun.COM 	struct job_request	*fp_job_tail;
4477836SJohn.Forte@Sun.COM 
448*8494SReed.Liu@Sun.COM 	struct fp_cmd		*fp_wait_head;		/* waitQ head */
4497836SJohn.Forte@Sun.COM 	struct fp_cmd		*fp_wait_tail;		/* waitQ tail */
4507836SJohn.Forte@Sun.COM 
4517836SJohn.Forte@Sun.COM 	/*
4527836SJohn.Forte@Sun.COM 	 * Current port topology. Uses the FC_TOP_* values defined in
453*8494SReed.Liu@Sun.COM 	 * fc_appif.h.	This is used with the FC_IS_TOP_SWITCH() macro and
4547836SJohn.Forte@Sun.COM 	 * is also used with the FC_TOP_EXTERNAL() macro in the ULPs.
4557836SJohn.Forte@Sun.COM 	 */
4567836SJohn.Forte@Sun.COM 	uint32_t		fp_topology;		/* topology */
4577836SJohn.Forte@Sun.COM 
4587836SJohn.Forte@Sun.COM 	/*
4597836SJohn.Forte@Sun.COM 	 * The fp_task and fp_last_task fields are used mainly in the
4607836SJohn.Forte@Sun.COM 	 * fp_job_handler() function.  These are used to indicate when a job
4617836SJohn.Forte@Sun.COM 	 * is executing.  They also allow a second job to be issued while
4627836SJohn.Forte@Sun.COM 	 * the current job is still in progress, but only one level of nesting
4637836SJohn.Forte@Sun.COM 	 * is permitted.
4647836SJohn.Forte@Sun.COM 	 *
4657836SJohn.Forte@Sun.COM 	 * The legal values for these fields are given in fp.h
4667836SJohn.Forte@Sun.COM 	 *
4677836SJohn.Forte@Sun.COM 	 * This should not be confused with the Solaris DDI taskq mechanism,
4687836SJohn.Forte@Sun.COM 	 * altho also fp makes use of that in some places (just to keep life
4697836SJohn.Forte@Sun.COM 	 * interesting).
4707836SJohn.Forte@Sun.COM 	 */
4717836SJohn.Forte@Sun.COM 	int			fp_task;		/* current task */
4727836SJohn.Forte@Sun.COM 	int			fp_last_task;		/* last task */
4737836SJohn.Forte@Sun.COM 
4747836SJohn.Forte@Sun.COM 	/*
4757836SJohn.Forte@Sun.COM 	 * fp_soft_state actually tracks the progression of the fp driver
4767836SJohn.Forte@Sun.COM 	 * in various code paths, particularly in attach, detach, suspend,
4777836SJohn.Forte@Sun.COM 	 * resume, and state change callbacks.
4787836SJohn.Forte@Sun.COM 	 *
4797836SJohn.Forte@Sun.COM 	 * The values for this are defined in fc_portif.h.
4807836SJohn.Forte@Sun.COM 	 *
4817836SJohn.Forte@Sun.COM 	 * This is sometimes used in conjunction with the fp_statec_busy
4827836SJohn.Forte@Sun.COM 	 * field (see below), but there is no direct, 1-to-1 correlation
4837836SJohn.Forte@Sun.COM 	 * in how these are used together.
4847836SJohn.Forte@Sun.COM 	 */
4857836SJohn.Forte@Sun.COM 	volatile uint16_t	fp_soft_state;
4867836SJohn.Forte@Sun.COM 
4877836SJohn.Forte@Sun.COM 
4887836SJohn.Forte@Sun.COM 	/*
4897836SJohn.Forte@Sun.COM 	 * Software restoration bit fields for (PM)SUSPEND/(PM)RESUME (??)
4907836SJohn.Forte@Sun.COM 	 * Legal values are FP_RESTORE_* in fp.h
4917836SJohn.Forte@Sun.COM 	 */
4927836SJohn.Forte@Sun.COM 	uint16_t		fp_restore;
4937836SJohn.Forte@Sun.COM 
4947836SJohn.Forte@Sun.COM 	/*
4957836SJohn.Forte@Sun.COM 	 * Open/Close bit flags. Used in fp_open(), fp_close(), fp_ioctl()
4967836SJohn.Forte@Sun.COM 	 * and fp_fciocmd(). See fp.h for legal values.
4977836SJohn.Forte@Sun.COM 	 */
4987836SJohn.Forte@Sun.COM 	uchar_t			fp_flag;		/* open/close flag */
4997836SJohn.Forte@Sun.COM 
5007836SJohn.Forte@Sun.COM 	uchar_t			fp_verbose;
5017836SJohn.Forte@Sun.COM 	uchar_t			fp_ns_login_class;	/* NS Logi Class */
5027836SJohn.Forte@Sun.COM 	uchar_t			fp_sym_port_namelen;	/* Symb port name len */
5037836SJohn.Forte@Sun.COM 	uint32_t		fp_cos;			/* class of service */
5047836SJohn.Forte@Sun.COM 
5057836SJohn.Forte@Sun.COM 	/*
5067836SJohn.Forte@Sun.COM 	 * Base pointer for hash table of fc_remote_port_t structs (remote
5077836SJohn.Forte@Sun.COM 	 * ports) accessible thru the local port. The table is hashed by
5087836SJohn.Forte@Sun.COM 	 * the D_ID of the remote port.
5097836SJohn.Forte@Sun.COM 	 */
5107836SJohn.Forte@Sun.COM 	struct d_id_hash	*fp_did_table;
5117836SJohn.Forte@Sun.COM 
5127836SJohn.Forte@Sun.COM 	/*
5137836SJohn.Forte@Sun.COM 	 * Base pointer for hash table of fc_remote_port_t structs (remote
5147836SJohn.Forte@Sun.COM 	 * ports) accessible thru the local port. The table is hashed by
5157836SJohn.Forte@Sun.COM 	 * the port WWN of the remote port.
5167836SJohn.Forte@Sun.COM 	 */
5177836SJohn.Forte@Sun.COM 	struct pwwn_hash	*fp_pwwn_table;
5187836SJohn.Forte@Sun.COM 
519*8494SReed.Liu@Sun.COM 	struct kmem_cache	*fp_pkt_cache;
520*8494SReed.Liu@Sun.COM 	int			fp_out_fpcmds;	/* outstanding fp_cmd # */
5217836SJohn.Forte@Sun.COM 
5227836SJohn.Forte@Sun.COM 	/*
5237836SJohn.Forte@Sun.COM 	 * fp_statec_busy tracks the progression of state change
5247836SJohn.Forte@Sun.COM 	 * callbacks within the fp driver. It follows unsolicited callbacks
5257836SJohn.Forte@Sun.COM 	 * and things like the port startup which happens during the attach.
5267836SJohn.Forte@Sun.COM 	 * The value increments when a state change is active and decrements
5277836SJohn.Forte@Sun.COM 	 * when it completes.
5287836SJohn.Forte@Sun.COM 	 *
5297836SJohn.Forte@Sun.COM 	 * The benefit of this is that we should be processing only the
5307836SJohn.Forte@Sun.COM 	 * latest state change and drop the existing one.  Coalescing of
5317836SJohn.Forte@Sun.COM 	 * multiple outstanding state changes is NOT performed.
5327836SJohn.Forte@Sun.COM 	 *
5337836SJohn.Forte@Sun.COM 	 * This is accessed in many places in the code, and also is buried
5347836SJohn.Forte@Sun.COM 	 * in some macros (see fp_soft_state above).
5357836SJohn.Forte@Sun.COM 	 *
5367836SJohn.Forte@Sun.COM 	 * IMPORTANT: The code currently permits nested state changes,
5377836SJohn.Forte@Sun.COM 	 * and there is no limitation on the allowed level of nesting.
5387836SJohn.Forte@Sun.COM 	 */
5397836SJohn.Forte@Sun.COM 	int			fp_statec_busy;
5407836SJohn.Forte@Sun.COM 
5417836SJohn.Forte@Sun.COM 	int			fp_port_num;		/* port number */
5427836SJohn.Forte@Sun.COM 	struct fp_cmd		*fp_els_resp_pkt;	/* ready response pkt */
5437836SJohn.Forte@Sun.COM 	int			fp_instance;		/* instance number */
5447836SJohn.Forte@Sun.COM 
5457836SJohn.Forte@Sun.COM 	/*
5467836SJohn.Forte@Sun.COM 	 * Flag to indicate whether or not the ULP attach is in progress. Used
5477836SJohn.Forte@Sun.COM 	 * to synchronize execution of various functions. Seems intended to
5487836SJohn.Forte@Sun.COM 	 * have a value of either zero or one.
5497836SJohn.Forte@Sun.COM 	 */
5507836SJohn.Forte@Sun.COM 	int			fp_ulp_attach;		/* ULP attach done ? */
5517836SJohn.Forte@Sun.COM 
5527836SJohn.Forte@Sun.COM 	int			fp_dev_count;		/* number of devices */
5537836SJohn.Forte@Sun.COM 	int			fp_ptpt_master;		/* my WWN is greater */
5547836SJohn.Forte@Sun.COM 	int			fp_ulp_nload;		/* count of ULPs */
555*8494SReed.Liu@Sun.COM 	int			fp_total_devices;	/* total count */
5567836SJohn.Forte@Sun.COM 
5577836SJohn.Forte@Sun.COM 	/*
5587836SJohn.Forte@Sun.COM 	 * Another "busy/not busy" flag. Value is either 0 or 1.
5597836SJohn.Forte@Sun.COM 	 */
5607836SJohn.Forte@Sun.COM 	int			fp_els_resp_pkt_busy;
5617836SJohn.Forte@Sun.COM 
5627836SJohn.Forte@Sun.COM 	/*
5637836SJohn.Forte@Sun.COM 	 * This is the "state" of the link on the local port, as reported
5647836SJohn.Forte@Sun.COM 	 * by the underlying FCA driver at bind time. This uses the same
5657836SJohn.Forte@Sun.COM 	 * values as fp_state above, including FC_STATE_OFFLINE, FC_STATE_LOOP,
5667836SJohn.Forte@Sun.COM 	 * and FC_PORT_STATE_MASK(port->fp_bind_state).
5677836SJohn.Forte@Sun.COM 	 */
5687836SJohn.Forte@Sun.COM 	uint32_t		fp_bind_state;		/* at bind time */
5697836SJohn.Forte@Sun.COM 
5707836SJohn.Forte@Sun.COM 	/*
5717836SJohn.Forte@Sun.COM 	 * Bit field of various parameterized behaviors for the local port.
5727836SJohn.Forte@Sun.COM 	 * CAUTION: there is also an fp global variable called "fp_options"
5737836SJohn.Forte@Sun.COM 	 * that is used to initialize this field during DDI_ATTACH.
5747836SJohn.Forte@Sun.COM 	 */
5757836SJohn.Forte@Sun.COM 	uint32_t		fp_options;
5767836SJohn.Forte@Sun.COM 
5777836SJohn.Forte@Sun.COM 	/*
5787836SJohn.Forte@Sun.COM 	 * Apparently intended to facilitate reporting the FC_HBA type
579*8494SReed.Liu@Sun.COM 	 * for the local port.	Legal values are in fcgs2.h. The
5807836SJohn.Forte@Sun.COM 	 * fc_porttype_t typedef is in fc_types.h
5817836SJohn.Forte@Sun.COM 	 */
5827836SJohn.Forte@Sun.COM 	fc_porttype_t		fp_port_type;
5837836SJohn.Forte@Sun.COM 
5847836SJohn.Forte@Sun.COM 	uint32_t		fp_ub_count;		/* Number of UBs */
5857836SJohn.Forte@Sun.COM 	int			fp_active_ubs;		/* outstanding UBs */
5867836SJohn.Forte@Sun.COM 	uint64_t		*fp_ub_tokens;		/* UB tokens */
5877836SJohn.Forte@Sun.COM 
5887836SJohn.Forte@Sun.COM 	/*
5897836SJohn.Forte@Sun.COM 	 * CV to inform fp "job" thread that there is work to do.
5907836SJohn.Forte@Sun.COM 	 * See fp_job_handler() function.
5917836SJohn.Forte@Sun.COM 	 */
5927836SJohn.Forte@Sun.COM 	kcondvar_t		fp_cv;
5937836SJohn.Forte@Sun.COM 
5947836SJohn.Forte@Sun.COM 	/*
5957836SJohn.Forte@Sun.COM 	 * Apparently intended to prevent race conditions by holding off any
5967836SJohn.Forte@Sun.COM 	 * DDI_DETACHes for the local port while a ULP attach is in progress.
5977836SJohn.Forte@Sun.COM 	 */
5987836SJohn.Forte@Sun.COM 	kcondvar_t		fp_attach_cv;		/* ULP attach cv */
5997836SJohn.Forte@Sun.COM 
6007836SJohn.Forte@Sun.COM 	/*
6017836SJohn.Forte@Sun.COM 	 * Save up the devinfo pointers from Solaris, for performing
6027836SJohn.Forte@Sun.COM 	 * pm_raise_power(), pm_busy_component(), and other DDI friends.
6037836SJohn.Forte@Sun.COM 	 */
6047836SJohn.Forte@Sun.COM 	dev_info_t		*fp_port_dip;		/* port dip */
6057836SJohn.Forte@Sun.COM 	dev_info_t		*fp_fca_dip;		/* FCA dip */
6067836SJohn.Forte@Sun.COM 
6077836SJohn.Forte@Sun.COM 	/* This is a real Solaris DDI taskq (not the fp "job" queue) */
6087836SJohn.Forte@Sun.COM 	taskq_t			*fp_taskq;		/* callback queue */
6097836SJohn.Forte@Sun.COM 
6107836SJohn.Forte@Sun.COM 	timeout_id_t		fp_wait_tid;		/* retry timer */
6117836SJohn.Forte@Sun.COM 	timeout_id_t		fp_offline_tid;		/* Offline timeout ID */
612*8494SReed.Liu@Sun.COM 	fc_lilpmap_t		fp_lilp_map;		/* LILP map */
6137836SJohn.Forte@Sun.COM 	la_els_logi_t		fp_service_params;	/* service parameters */
6147836SJohn.Forte@Sun.COM 	fc_fcp_dma_t		fp_fcp_dma;		/* FCP DVMA space */
6157836SJohn.Forte@Sun.COM 	fc_reset_action_t	fp_reset_action;	/* FCA reset behavior */
6167836SJohn.Forte@Sun.COM 	fc_dma_behavior_t	fp_dma_behavior;	/* FCA DMA behavior */
6177836SJohn.Forte@Sun.COM 	uchar_t			fp_sym_node_namelen;	/* Sym node name len */
6187836SJohn.Forte@Sun.COM 	uchar_t			fp_ipa[8];		/* initial proc assoc */
6197836SJohn.Forte@Sun.COM 	uchar_t			fp_ip_addr[16];		/* IP address */
6207836SJohn.Forte@Sun.COM 	uint32_t		fp_fc4_types[8];	/* fc4 types */
6217836SJohn.Forte@Sun.COM 	struct fc_orphan	*fp_orphan_list;	/* orphan list */
6227836SJohn.Forte@Sun.COM 	int			fp_orphan_count;	/* number of orphans */
6237836SJohn.Forte@Sun.COM 
6247836SJohn.Forte@Sun.COM 	/*
6257836SJohn.Forte@Sun.COM 	 * Current PM power level of the local port device. Values
6267836SJohn.Forte@Sun.COM 	 * are given in fc_portif.h
6277836SJohn.Forte@Sun.COM 	 */
6287836SJohn.Forte@Sun.COM 	int			fp_pm_level;		/* power level */
6297836SJohn.Forte@Sun.COM 
6307836SJohn.Forte@Sun.COM 	/* Increment/decrement in fctl_busy_port() and fctl_idle_port() */
6317836SJohn.Forte@Sun.COM 	int			fp_pm_busy;		/* port busy */
6327836SJohn.Forte@Sun.COM 
6337836SJohn.Forte@Sun.COM 	int			fp_pm_busy_nocomp;	/* busy (no comp) */
6347836SJohn.Forte@Sun.COM 	fc_hardaddr_t		fp_hard_addr;		/* Hard Address */
6357836SJohn.Forte@Sun.COM 	char			fp_sym_port_name[255];	/* Symb port name */
6367836SJohn.Forte@Sun.COM 	char			fp_sym_node_name[255];	/* Symb node name */
6377836SJohn.Forte@Sun.COM 
6387836SJohn.Forte@Sun.COM 	/*
6397836SJohn.Forte@Sun.COM 	 * Opaque data for CALLB_CPR_* macros used by the per-local-port
640*8494SReed.Liu@Sun.COM 	 * job thread.	Required for safe thread shutdown during PM operations.
6417836SJohn.Forte@Sun.COM 	 */
6427836SJohn.Forte@Sun.COM 	callb_cpr_t		fp_cpr_info;		/* CPR info */
6437836SJohn.Forte@Sun.COM 
6447836SJohn.Forte@Sun.COM 	char			fp_jindex;		/* Not used */
6457836SJohn.Forte@Sun.COM 	char			fp_jbuf[15];		/* Not used */
6467836SJohn.Forte@Sun.COM 
647*8494SReed.Liu@Sun.COM 	char			fp_ibuf[15];		/* instance buf	 */
6487836SJohn.Forte@Sun.COM 	char			fp_rnid_init;		/* init done */
6497836SJohn.Forte@Sun.COM 	fc_rnid_t		fp_rnid_params;		/* node id data */
6507836SJohn.Forte@Sun.COM 
6517836SJohn.Forte@Sun.COM 	/* T11 FC-HBA data */
6527836SJohn.Forte@Sun.COM 	fca_port_attrs_t	fp_hba_port_attrs;
6537836SJohn.Forte@Sun.COM 	fc_hba_state_change_t	fp_last_change;
6547836SJohn.Forte@Sun.COM 	uint8_t			fp_port_supported_fc4_types[32];
6557836SJohn.Forte@Sun.COM 	uint8_t			fp_port_active_fc4_types[32];
6567836SJohn.Forte@Sun.COM 	uint32_t		fp_port_speed;
6577836SJohn.Forte@Sun.COM 	la_wwn_t		fp_fabric_name;
6587836SJohn.Forte@Sun.COM 	uint32_t		fp_rscn_count;
6597836SJohn.Forte@Sun.COM 	int			fp_npiv_portnum;
6607836SJohn.Forte@Sun.COM #define	FC_NPIV_DISABLE	0
6617836SJohn.Forte@Sun.COM #define	FC_NPIV_ENABLE	1
6627836SJohn.Forte@Sun.COM 	int			fp_npiv_flag;
6637836SJohn.Forte@Sun.COM #define	FC_NPIV_DELETING 1
6647836SJohn.Forte@Sun.COM 	int			fp_npiv_state;
6657836SJohn.Forte@Sun.COM #define	FC_PHY_PORT	0
6667836SJohn.Forte@Sun.COM #define	FC_NPIV_PORT	1
6677836SJohn.Forte@Sun.COM 	int			fp_npiv_type;
6687836SJohn.Forte@Sun.COM 	int			fp_npiv_portindex[FC_NPIV_MAX_PORT];
6697836SJohn.Forte@Sun.COM 	struct	fc_local_port	*fp_port_next;
6707836SJohn.Forte@Sun.COM 	struct	fc_local_port	*fp_port_prev;
6717836SJohn.Forte@Sun.COM } fc_local_port_t;
6727836SJohn.Forte@Sun.COM 
6737836SJohn.Forte@Sun.COM 
6747836SJohn.Forte@Sun.COM /*
6757836SJohn.Forte@Sun.COM  * Struct for the d_id hash table in the fc_local_port_t struct.  The code
6767836SJohn.Forte@Sun.COM  * allocates memory for an array of D_ID_HASH_TABLE_SIZE elements at
677*8494SReed.Liu@Sun.COM  * attach time.	 The array pointer is saved at the fp_did_table member
6787836SJohn.Forte@Sun.COM  * in the fc_local_port_t struct.
6797836SJohn.Forte@Sun.COM  *  Each hash chain is a singly-linked list of fc_remote_port_t
6807836SJohn.Forte@Sun.COM  * structs, using the pd_did_hnext pointer in the fc_remote_port_t struct.
6817836SJohn.Forte@Sun.COM  */
6827836SJohn.Forte@Sun.COM struct d_id_hash {
683*8494SReed.Liu@Sun.COM 	struct fc_remote_port	*d_id_head;	/* Head of linked list */
684*8494SReed.Liu@Sun.COM 	int			d_id_count;	/* Count of list entries */
6857836SJohn.Forte@Sun.COM };
6867836SJohn.Forte@Sun.COM 
6877836SJohn.Forte@Sun.COM 
6887836SJohn.Forte@Sun.COM /*
6897836SJohn.Forte@Sun.COM  * Struct for the pwwn hash table in the fc_local_port_t struct.  The code
6907836SJohn.Forte@Sun.COM  * allocates memory for an array of PWWN_HASH_TABLE_SIZE elements at
691*8494SReed.Liu@Sun.COM  * attach time.	 The array pointer is saved at the fp_pwwn_table member
6927836SJohn.Forte@Sun.COM  * in the fc_local_port_t struct.
6937836SJohn.Forte@Sun.COM  * Each hash chain is a singly-linked list of fc_remote_port_t
6947836SJohn.Forte@Sun.COM  * structs, using the pd_wwn_hnext pointer in the fc_remote_port_t struct.
6957836SJohn.Forte@Sun.COM  */
6967836SJohn.Forte@Sun.COM struct pwwn_hash {
697*8494SReed.Liu@Sun.COM 	struct fc_remote_port	*pwwn_head;	/* Head of linked list */
698*8494SReed.Liu@Sun.COM 	int			pwwn_count;	/* Count of list entries */
6997836SJohn.Forte@Sun.COM };
7007836SJohn.Forte@Sun.COM 
7017836SJohn.Forte@Sun.COM 
7027836SJohn.Forte@Sun.COM /* Function prototypes */
7037836SJohn.Forte@Sun.COM static dev_info_t *
7047836SJohn.Forte@Sun.COM fctl_findchild(dev_info_t *pdip, char *cname, char *caddr);
7057836SJohn.Forte@Sun.COM int fctl_fca_create_npivport(dev_info_t *parent,
7067836SJohn.Forte@Sun.COM     dev_info_t *phydip, char *nwwn, char *pwwn, uint32_t *vindex);
7077836SJohn.Forte@Sun.COM static int fctl_fca_bus_ctl(dev_info_t *fca_dip, dev_info_t *rip,
7087836SJohn.Forte@Sun.COM     ddi_ctl_enum_t op, void *arg, void *result);
7097836SJohn.Forte@Sun.COM static int fctl_initchild(dev_info_t *fca_dip, dev_info_t *port_dip);
7107836SJohn.Forte@Sun.COM static int fctl_uninitchild(dev_info_t *fca_dip, dev_info_t *port_dip);
7117836SJohn.Forte@Sun.COM static int fctl_cache_constructor(void *buf, void *cdarg, int size);
7127836SJohn.Forte@Sun.COM static void fctl_cache_destructor(void *buf, void *cdarg);
7137836SJohn.Forte@Sun.COM static int fctl_pre_attach(fc_ulp_ports_t *ulp_port, fc_attach_cmd_t cmd);
7147836SJohn.Forte@Sun.COM static void fctl_post_attach(fc_ulp_module_t *mod, fc_ulp_ports_t *ulp_port,
7157836SJohn.Forte@Sun.COM     fc_attach_cmd_t cmd, int rval);
7167836SJohn.Forte@Sun.COM static int fctl_pre_detach(fc_ulp_ports_t *ulp_port, fc_detach_cmd_t cmd);
7177836SJohn.Forte@Sun.COM static void fctl_post_detach(fc_ulp_module_t *mod, fc_ulp_ports_t *ulp_port,
7187836SJohn.Forte@Sun.COM     fc_detach_cmd_t cmd, int rval);
7197836SJohn.Forte@Sun.COM static fc_ulp_ports_t *fctl_add_ulp_port(fc_ulp_module_t *ulp_module,
7207836SJohn.Forte@Sun.COM     fc_local_port_t *port_handle, int sleep);
7217836SJohn.Forte@Sun.COM static fc_ulp_ports_t *fctl_alloc_ulp_port(int sleep);
7227836SJohn.Forte@Sun.COM static int fctl_remove_ulp_port(struct ulp_module *ulp_module,
7237836SJohn.Forte@Sun.COM     fc_local_port_t *port_handle);
7247836SJohn.Forte@Sun.COM static void fctl_dealloc_ulp_port(fc_ulp_ports_t *next);
7257836SJohn.Forte@Sun.COM static fc_ulp_ports_t *fctl_get_ulp_port(struct ulp_module *ulp_module,
7267836SJohn.Forte@Sun.COM     fc_local_port_t *port_handle);
7277836SJohn.Forte@Sun.COM static int fctl_update_host_ns_values(fc_local_port_t *port,
7287836SJohn.Forte@Sun.COM     fc_ns_cmd_t *ns_req);
7297836SJohn.Forte@Sun.COM static int fctl_retrieve_host_ns_values(fc_local_port_t *port,
7307836SJohn.Forte@Sun.COM     fc_ns_cmd_t *ns_req);
7317836SJohn.Forte@Sun.COM static void fctl_print_if_not_orphan(fc_local_port_t *port,
7327836SJohn.Forte@Sun.COM     fc_remote_port_t *pd);
7337836SJohn.Forte@Sun.COM static void fctl_link_reset_done(opaque_t port_handle, uchar_t result);
7347836SJohn.Forte@Sun.COM static int fctl_error(int fc_errno, char **errmsg);
7357836SJohn.Forte@Sun.COM static int fctl_pkt_error(fc_packet_t *pkt, char **state, char **reason,
7367836SJohn.Forte@Sun.COM     char **action, char **expln);
7377836SJohn.Forte@Sun.COM static void fctl_check_alpa_list(fc_local_port_t *port, fc_remote_port_t *pd);
7387836SJohn.Forte@Sun.COM static int fctl_is_alpa_present(fc_local_port_t *port, uchar_t alpa);
7397836SJohn.Forte@Sun.COM static void fc_trace_freemsg(fc_trace_logq_t *logq);
7407836SJohn.Forte@Sun.COM static void fctl_init_dma_attr(fc_local_port_t *port, fc_ulp_module_t *mod,
741*8494SReed.Liu@Sun.COM     fc_ulp_port_info_t	*info);
7427836SJohn.Forte@Sun.COM fc_local_port_t *fc_get_npiv_port(fc_local_port_t *phyport, la_wwn_t *pwwn);
7437836SJohn.Forte@Sun.COM fc_local_port_t *fc_delete_npiv_port(fc_local_port_t *phyport, la_wwn_t *pwwn);
7447836SJohn.Forte@Sun.COM 
7457836SJohn.Forte@Sun.COM 
7467836SJohn.Forte@Sun.COM #ifdef	__cplusplus
7477836SJohn.Forte@Sun.COM }
7487836SJohn.Forte@Sun.COM #endif
7497836SJohn.Forte@Sun.COM 
7507836SJohn.Forte@Sun.COM #endif	/* _FCTL_PRIVATE_H */
751