xref: /onnv-gate/usr/src/uts/common/sys/ib/ibnex/ibnex.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _SYS_IB_IBNEX_IBNEX_H
28*0Sstevel@tonic-gate #define	_SYS_IB_IBNEX_IBNEX_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * ibnex.h
34*0Sstevel@tonic-gate  * This file contains defines and structures used within the IB Nexus
35*0Sstevel@tonic-gate  */
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate #ifdef __cplusplus
38*0Sstevel@tonic-gate extern "C" {
39*0Sstevel@tonic-gate #endif
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate #include <sys/sunndi.h>
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate /* Defines for return codes within the IB nexus driver */
44*0Sstevel@tonic-gate typedef enum {
45*0Sstevel@tonic-gate 	IBNEX_SUCCESS =	0,
46*0Sstevel@tonic-gate 	IBNEX_FAILURE = -1,
47*0Sstevel@tonic-gate 	IBNEX_OFFLINE_FAILED = -2,
48*0Sstevel@tonic-gate 	IBNEX_BUSY = -3,
49*0Sstevel@tonic-gate 	IBNEX_INVALID_NODE = -4
50*0Sstevel@tonic-gate } ibnex_rval_t;
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate /* IOC device node specific data */
54*0Sstevel@tonic-gate typedef struct ibnex_ioc_node_s {
55*0Sstevel@tonic-gate 	ib_guid_t		iou_guid;	/* GUID of the IOU */
56*0Sstevel@tonic-gate 	ib_guid_t		ioc_guid;	/* GUID of the IOC */
57*0Sstevel@tonic-gate 	char			ioc_id_string[IB_DM_IOC_ID_STRING_LEN];
58*0Sstevel@tonic-gate 	uint32_t		ioc_ngids;
59*0Sstevel@tonic-gate 	/* This field will be non NULL only for diconnected IOCs */
60*0Sstevel@tonic-gate 	ib_dm_ioc_ctrl_profile_t	*ioc_profile;
61*0Sstevel@tonic-gate } ibnex_ioc_node_t;
62*0Sstevel@tonic-gate 
63*0Sstevel@tonic-gate /* DLPI device node specific data */
64*0Sstevel@tonic-gate typedef struct ibnex_port_node_s {
65*0Sstevel@tonic-gate 	uint8_t			port_num;
66*0Sstevel@tonic-gate 	int			port_commsvc_idx;
67*0Sstevel@tonic-gate 	ib_guid_t		port_guid;
68*0Sstevel@tonic-gate 	ib_guid_t		port_hcaguid;
69*0Sstevel@tonic-gate 	ib_pkey_t		port_pkey;
70*0Sstevel@tonic-gate } ibnex_port_node_t;
71*0Sstevel@tonic-gate 
72*0Sstevel@tonic-gate /* Pseudo device node specific data */
73*0Sstevel@tonic-gate typedef struct ibnex_pseudo_node_s {
74*0Sstevel@tonic-gate 	char			*pseudo_node_addr;	/* node addr of drvr */
75*0Sstevel@tonic-gate 	char			*pseudo_unit_addr;	/* unit addr of drvr */
76*0Sstevel@tonic-gate 	int			pseudo_unit_addr_len;	/* unit addr len */
77*0Sstevel@tonic-gate 	char			*pseudo_devi_name;	/* name of driver */
78*0Sstevel@tonic-gate 	int			pseudo_new_node;	/* new node */
79*0Sstevel@tonic-gate } ibnex_pseudo_node_t;
80*0Sstevel@tonic-gate 
81*0Sstevel@tonic-gate /*
82*0Sstevel@tonic-gate  * Defines for Child device node types. Note that these values are also
83*0Sstevel@tonic-gate  * in use by usr/src/lib/cfgadm_plugins/ib/common/cfga_ib.h.
84*0Sstevel@tonic-gate  * Any changes to these need to be reflected in that file as well.
85*0Sstevel@tonic-gate  */
86*0Sstevel@tonic-gate typedef enum {
87*0Sstevel@tonic-gate 	IBNEX_PORT_COMMSVC_NODE,
88*0Sstevel@tonic-gate 	IBNEX_VPPA_COMMSVC_NODE,
89*0Sstevel@tonic-gate 	IBNEX_HCASVC_COMMSVC_NODE,
90*0Sstevel@tonic-gate 	IBNEX_IOC_NODE,
91*0Sstevel@tonic-gate 	IBNEX_PSEUDO_NODE
92*0Sstevel@tonic-gate } ibnex_node_type_t;
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate /*
96*0Sstevel@tonic-gate  * Defines for Child device node state:
97*0Sstevel@tonic-gate  *
98*0Sstevel@tonic-gate  * By default the node is set to CONFIGURED state.
99*0Sstevel@tonic-gate  *	CONFIGURED:---(bus_config/cfgadm configure)---->CONFIGURED
100*0Sstevel@tonic-gate  *	CONFIGURED:----(cfgadm unconfigure:success)--->UNCONFIGURED
101*0Sstevel@tonic-gate  *	CONFIGURED:----(cfgadm unconfigure:fail)--->still CONFIGURED
102*0Sstevel@tonic-gate  *	UNCONFIGURED:----(cfgadm configure:success)--->CONFIGURED
103*0Sstevel@tonic-gate  *
104*0Sstevel@tonic-gate  * We maintain two additional states:
105*0Sstevel@tonic-gate  *	CONFIGURING:---(bus_config/cfgadm configure in progress
106*0Sstevel@tonic-gate  *	UNCONFIGURING:--(cfgadm unconfigure in progress)
107*0Sstevel@tonic-gate  * This is maintained to avoid race conditions between multiple cfgadm
108*0Sstevel@tonic-gate  * operations.
109*0Sstevel@tonic-gate  */
110*0Sstevel@tonic-gate typedef enum ibnex_node_state_e {
111*0Sstevel@tonic-gate 	IBNEX_CFGADM_CONFIGURED,	/* node is "configured" */
112*0Sstevel@tonic-gate 	IBNEX_CFGADM_UNCONFIGURED,	/* node is "unconfigured" */
113*0Sstevel@tonic-gate 	IBNEX_CFGADM_CONFIGURING,	/* node getting configured */
114*0Sstevel@tonic-gate 	IBNEX_CFGADM_UNCONFIGURING	/* node getting unconfigured */
115*0Sstevel@tonic-gate } ibnex_node_state_t;
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate /*
118*0Sstevel@tonic-gate  * Defines for reprobe_state:
119*0Sstevel@tonic-gate  * 	IBNEX_NODE_REPROBE_NOTIFY_ON_UPDATE
120*0Sstevel@tonic-gate  *		Reprobe and notify if there is a property update
121*0Sstevel@tonic-gate  *	IBNEX_NODE_REPROBE_NOTIFY_ALWAYS
122*0Sstevel@tonic-gate  *		Reprobe and notify always.
123*0Sstevel@tonic-gate  *	IBNEX_NODE_REPROBE_IOC_WAIT
124*0Sstevel@tonic-gate  *		Reprobe for IOC apid waiting
125*0Sstevel@tonic-gate  *
126*0Sstevel@tonic-gate  * Device reprobes triggered by ibt_reprobe_dev will result in an DDI
127*0Sstevel@tonic-gate  * event, even though no prepoerties have changed.
128*0Sstevel@tonic-gate  */
129*0Sstevel@tonic-gate #define	IBNEX_NODE_REPROBE_NOTIFY_ON_UPDATE	0x01
130*0Sstevel@tonic-gate #define	IBNEX_NODE_REPROBE_NOTIFY_ALWAYS	0x02
131*0Sstevel@tonic-gate #define	IBNEX_NODE_REPROBE_IOC_WAIT			0x04
132*0Sstevel@tonic-gate 
133*0Sstevel@tonic-gate /* Node specific information, stored as dev_info_t private data */
134*0Sstevel@tonic-gate typedef struct ibnex_node_data_s {
135*0Sstevel@tonic-gate 	dev_info_t		*node_dip;
136*0Sstevel@tonic-gate 	union {
137*0Sstevel@tonic-gate 		ibnex_ioc_node_t	ioc_node;
138*0Sstevel@tonic-gate 		ibnex_port_node_t	port_node;
139*0Sstevel@tonic-gate 		ibnex_pseudo_node_t	pseudo_node;
140*0Sstevel@tonic-gate 	} node_data;
141*0Sstevel@tonic-gate 	struct ibnex_node_data_s *node_next;
142*0Sstevel@tonic-gate 	struct ibnex_node_data_s *node_prev;
143*0Sstevel@tonic-gate 	ibnex_node_type_t	node_type;
144*0Sstevel@tonic-gate 	ibnex_node_state_t	node_state;
145*0Sstevel@tonic-gate 	int			node_reprobe_state;	/* Node reprobe flag */
146*0Sstevel@tonic-gate } ibnex_node_data_t;
147*0Sstevel@tonic-gate 
148*0Sstevel@tonic-gate /*
149*0Sstevel@tonic-gate  * The fields of IOC and Port node are initialized when the
150*0Sstevel@tonic-gate  * device node is created. These are read only for the rest
151*0Sstevel@tonic-gate  * of the IBnexus driver.
152*0Sstevel@tonic-gate  */
153*0Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_ioc_node_s))
154*0Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_port_node_s))
155*0Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_pseudo_node_s))
156*0Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", ibnex_node_data_s))
157*0Sstevel@tonic-gate 
158*0Sstevel@tonic-gate #define	IBNEX_VALID_NODE_TYPE(n)	\
159*0Sstevel@tonic-gate 	(((n)->node_type == IBNEX_PORT_COMMSVC_NODE) || \
160*0Sstevel@tonic-gate 	((n)->node_type == IBNEX_VPPA_COMMSVC_NODE) || \
161*0Sstevel@tonic-gate 	((n)->node_type == IBNEX_HCASVC_COMMSVC_NODE) || \
162*0Sstevel@tonic-gate 	((n)->node_type == IBNEX_IOC_NODE) || \
163*0Sstevel@tonic-gate 	((n)->node_type == IBNEX_PSEUDO_NODE))
164*0Sstevel@tonic-gate 
165*0Sstevel@tonic-gate #define	IBNEX_COMMSVC_NODE_TYPE(n)	\
166*0Sstevel@tonic-gate 	(((n)->node_type == IBNEX_PORT_COMMSVC_NODE) || \
167*0Sstevel@tonic-gate 	((n)->node_type == IBNEX_VPPA_COMMSVC_NODE) || \
168*0Sstevel@tonic-gate 	((n)->node_type == IBNEX_HCASVC_COMMSVC_NODE))
169*0Sstevel@tonic-gate 
170*0Sstevel@tonic-gate /*
171*0Sstevel@tonic-gate  * Definition for the IB nexus global per-instance structure.
172*0Sstevel@tonic-gate  * IB nexus supports only one instance.
173*0Sstevel@tonic-gate  */
174*0Sstevel@tonic-gate typedef struct ibnex_s {
175*0Sstevel@tonic-gate 	dev_info_t		*ibnex_dip;
176*0Sstevel@tonic-gate 	kmutex_t		ibnex_mutex;
177*0Sstevel@tonic-gate 	int			ibnex_num_comm_svcs;
178*0Sstevel@tonic-gate 	char			**ibnex_comm_svc_names;
179*0Sstevel@tonic-gate 	int			ibnex_nvppa_comm_svcs;
180*0Sstevel@tonic-gate 	char			**ibnex_vppa_comm_svc_names;
181*0Sstevel@tonic-gate 	int			ibnex_nhcasvc_comm_svcs;
182*0Sstevel@tonic-gate 	char			**ibnex_hcasvc_comm_svc_names;
183*0Sstevel@tonic-gate 	ibnex_node_data_t	*ibnex_port_node_head;
184*0Sstevel@tonic-gate 	ibnex_node_data_t	*ibnex_ioc_node_head;
185*0Sstevel@tonic-gate 	ibnex_node_data_t	*ibnex_pseudo_node_head;
186*0Sstevel@tonic-gate 
187*0Sstevel@tonic-gate 	/*
188*0Sstevel@tonic-gate 	 * NDI Event handle for -all- ibnexus events
189*0Sstevel@tonic-gate 	 * Event Cookie for IB_PROP_UPDATE_EVENT event
190*0Sstevel@tonic-gate 	 */
191*0Sstevel@tonic-gate 	ndi_event_hdl_t		ibnex_ndi_event_hdl;
192*0Sstevel@tonic-gate 	ddi_eventcookie_t	ibnex_prop_update_evt_cookie;
193*0Sstevel@tonic-gate 
194*0Sstevel@tonic-gate 	/* Flags & condition variables for reprobe handling */
195*0Sstevel@tonic-gate 	int					ibnex_reprobe_state;
196*0Sstevel@tonic-gate 	kcondvar_t			ibnex_reprobe_cv;
197*0Sstevel@tonic-gate 
198*0Sstevel@tonic-gate 	/* Count of disconnected IOCs still configured */
199*0Sstevel@tonic-gate 	int					ibnex_num_disconnect_iocs;
200*0Sstevel@tonic-gate 
201*0Sstevel@tonic-gate 	/* Pseudo nodes inited from ibnex_get_snapshot? */
202*0Sstevel@tonic-gate 	int			ibnex_pseudo_inited;
203*0Sstevel@tonic-gate } ibnex_t;
204*0Sstevel@tonic-gate 
205*0Sstevel@tonic-gate /*
206*0Sstevel@tonic-gate  * States for ibnex_reprobe_state
207*0Sstevel@tonic-gate  *	0 to REPROBE_ALL_PROGRESS
208*0Sstevel@tonic-gate  *		Reprobe all when no reprobes pending
209*0Sstevel@tonic-gate  *	REPROBE_ALL_PROGRESS to REPROBE_ALL_WAIT
210*0Sstevel@tonic-gate  *		Reprobe all request when another in progress
211*0Sstevel@tonic-gate  *	0 to REPROBE_IOC_WAIT
212*0Sstevel@tonic-gate  *		Waiting for One or more reprobe_ioc to complete
213*0Sstevel@tonic-gate  *
214*0Sstevel@tonic-gate  * Reprobe logic will ensure :
215*0Sstevel@tonic-gate  *	1. A single reprobe all at any time.
216*0Sstevel@tonic-gate  *	2. No individual IOC reprobe overlaps with reprobe all.
217*0Sstevel@tonic-gate  *	3. Reprobe for multiple IOCs can be in parallel
218*0Sstevel@tonic-gate  *	4. Single reprobe for each IOC.
219*0Sstevel@tonic-gate  */
220*0Sstevel@tonic-gate #define	IBNEX_REPROBE_ALL_PROGRESS	0x01
221*0Sstevel@tonic-gate #define	IBNEX_REPROBE_ALL_WAIT		0x02
222*0Sstevel@tonic-gate #define	IBNEX_REPROBE_IOC_WAIT		0x04
223*0Sstevel@tonic-gate 
224*0Sstevel@tonic-gate /* Defines for creating and binding device nodes.  */
225*0Sstevel@tonic-gate #define	IBNEX_MAX_COMPAT_NAMES		6
226*0Sstevel@tonic-gate #define	IBNEX_MAX_IBPORT_COMPAT_NAMES	3
227*0Sstevel@tonic-gate #define	IBNEX_MAX_COMPAT_LEN		48
228*0Sstevel@tonic-gate #define	IBNEX_MAX_COMPAT_PROP_SZ	\
229*0Sstevel@tonic-gate 	IBNEX_MAX_COMPAT_NAMES * IBNEX_MAX_COMPAT_LEN
230*0Sstevel@tonic-gate #define	IBNEX_MAX_IBPORT_COMPAT_PROP_SZ	\
231*0Sstevel@tonic-gate 	IBNEX_MAX_IBPORT_COMPAT_NAMES * IBNEX_MAX_COMPAT_LEN
232*0Sstevel@tonic-gate #define	IBNEX_DEVFS_ENUMERATE		0x1	/* enumerate via devfs(7fs) */
233*0Sstevel@tonic-gate #define	IBNEX_CFGADM_ENUMERATE		0x2	/* enumerate via cfgadm */
234*0Sstevel@tonic-gate 
235*0Sstevel@tonic-gate #define	IBNEX_MAX_NODEADDR_SZ		35
236*0Sstevel@tonic-gate 
237*0Sstevel@tonic-gate /* Define for forming the unit address from GUID and class string */
238*0Sstevel@tonic-gate #define	IBNEX_FORM_GUID(buf, size, guid) \
239*0Sstevel@tonic-gate 		(void) snprintf((buf), (size), "%llX", (longlong_t)guid);
240*0Sstevel@tonic-gate 
241*0Sstevel@tonic-gate #define	IBNEX_INVALID_PKEY(pkey)	\
242*0Sstevel@tonic-gate 		(((pkey) == IB_PKEY_INVALID_FULL) || \
243*0Sstevel@tonic-gate 		((pkey) == IB_PKEY_INVALID_LIMITED))
244*0Sstevel@tonic-gate 
245*0Sstevel@tonic-gate /*
246*0Sstevel@tonic-gate  * Defines for the tags of IB DDI events
247*0Sstevel@tonic-gate  */
248*0Sstevel@tonic-gate typedef enum {
249*0Sstevel@tonic-gate 		IB_EVENT_TAG_PROP_UPDATE = 0
250*0Sstevel@tonic-gate } ib_ddi_event_tag_t;
251*0Sstevel@tonic-gate 
252*0Sstevel@tonic-gate #ifdef __cplusplus
253*0Sstevel@tonic-gate }
254*0Sstevel@tonic-gate #endif
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate #endif	/* _SYS_IB_IBNEX_IBNEX_H */
257