xref: /titanic_51/usr/src/uts/common/sys/ib/ibtl/impl/ibtl_ibnex.h (revision e8174f4e2380e6f86f1f916e0617342e8a977885)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_IB_IBTL_IMPL_IBTL_IBNEX_H
27 #define	_SYS_IB_IBTL_IMPL_IBTL_IBNEX_H
28 
29 /*
30  * ibtl_ibnex.h
31  *
32  * All data structures and function prototypes that are specific to the
33  * IBTL<--->IB nexus private interface.
34  */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * Cfgadm restricts ap_id length to 30 bytes (See CFGA_LOG_EXT_LEN)
42  */
43 #define	IBTL_IBNEX_APID_LEN	31
44 #define	IBTL_IBNEX_STR_LEN	64
45 
46 /*
47  * "ioc" and "ibport" child device names
48  */
49 #define	IBNEX_IOC_CNAME		"ioc"
50 #define	IBNEX_IBPORT_CNAME	"ibport"
51 
52 /*
53  * These two defines are used by the function ibtl_ibnex_get_hca_info().
54  * If IBTL_IBNEX_LIST_CLNTS_FLAG is specified then an NVL packed list
55  * of only client names/ap_ids/alternate_HCA is returned.
56  * If IBTL_IBNEX_UNCFG_CLNTS_FLAG is specified then an NVL packed list
57  * of only client ap_ids/devpaths is returned.
58  */
59 #define	IBTL_IBNEX_LIST_CLNTS_FLAG	0x1	/* -x list_clients option */
60 #define	IBTL_IBNEX_UNCFG_CLNTS_FLAG	0x2	/* -x unconfig_clients option */
61 
62 typedef struct ibtl_ibnex_cb_args_s {
63 	uint_t			cb_flag;
64 	dev_info_t		*cb_dip;
65 	struct modlinkage	*cb_modlp;
66 	ib_guid_t		cb_hca_guid;
67 } ibtl_ibnex_cb_args_t;
68 
69 /* Possible values for cb_flag */
70 #define	IBTL_IBNEX_IBC_INIT		0x11
71 #define	IBTL_IBNEX_IBC_FINI		0x22
72 #define	IBTL_IBNEX_REPROBE_DEV_REQ	0x33
73 
74 /*
75  * Function:
76  *	ibtl_ibnex_callback_t
77  * Inputs:
78  *	cb_args		- Arguments for the callback
79  * Returns:
80  *	IBT_SUCCESS/IBT_FAILURE
81  * Description:
82  *	Currently this routine provides function to check wheter
83  *	particular client has access to open HCA or not.
84  */
85 typedef ibt_status_t (*ibtl_ibnex_callback_t)(ibtl_ibnex_cb_args_t *);
86 
87 /*
88  * Function:
89  *	ibtl_ibnex_register_callback
90  * Inputs:
91  *	ibnex_ibtl_callback	- IBTL's IB nexus driver callback function
92  * Returns:
93  *	NONE
94  * Description:
95  *	Register a callback routine for IB nexus driver.
96  */
97 void	ibtl_ibnex_register_callback(ibtl_ibnex_callback_t);
98 
99 /*
100  * Function:
101  *	ibtl_ibnex_unregister_callback
102  * Inputs:
103  *	NONE
104  * Returns:
105  *	NONE
106  * Description:
107  *	Un-register the callback routine for IB nexus driver.
108  */
109 void	ibtl_ibnex_unregister_callback();
110 
111 /*
112  * Function:
113  *	ibtl_ibnex_get_hca_info
114  * Input:
115  *	hca_guid	- The HCA's node GUID.
116  *	flag		- Tells what to do
117  *			IBTL_IBNEX_LIST_CLNTS_FLAG - Build client names/ap_ids/
118  *			    alternate_HCA database
119  *			IBTL_IBNEX_UNCFG_CLNTS_FLAG - Build client devpaths/
120  *			    ap_id database
121  *	callback	- Callback function to get ap_id from ib(7d)
122  * Output:
123  *	buffer		- The information is returned in this buffer
124  *      bufsiz		- The size of the information buffer
125  * Returns:
126  *	IBT_SUCCESS/IBT_HCA_INVALID/IBT_FAILURE
127  * Description:
128  *      For a given HCA node GUID it figures out the registered clients
129  *	(ie. ones who called ibt_attach(9f) on this GUID) and creates
130  *	a NVL packed buffer (of either names/ap_ids/alternate_HCA or
131  *	devpaths/ap_ids) and returns it. If a valid flag is not specified
132  *	then an error is returned.
133  */
134 ibt_status_t	ibtl_ibnex_get_hca_info(ib_guid_t hca_guid, int flag,
135 		    char **buffer, size_t *bufsiz,
136 		    void (*callback)(dev_info_t *, char **));
137 
138 /*
139  * Function:
140  *	ibtl_ibnex_hcadip2guid
141  * Input:
142  *	dev_info_t	- The "dip" of this HCA
143  * Output:
144  *	hca_guid	- The HCA's node GUID.
145  * Description:
146  *	For a given HCA dip it figures out the GUID
147  *	and returns it. If not found, NULL is returned.
148  */
149 ib_guid_t	ibtl_ibnex_hcadip2guid(dev_info_t *);
150 
151 /*
152  * Function:
153  *	ibtl_ibnex_hcaguid2dip
154  * Input:
155  *	hca_guid	- The HCA's node GUID.
156  * Output:
157  *	dev_info_t	- The "dip" of this HCA
158  * Returns:
159  *	 "dip" on SUCCESS, NULL on FAILURE
160  * Description:
161  *	For a given HCA node GUID it figures out the "dip"
162  *	and returns it. If not found, NULL is returned.
163  */
164 dev_info_t	*ibtl_ibnex_hcaguid2dip(ib_guid_t);
165 
166 /*
167  * Function:
168  *	ibtl_ibnex_get_hca_verbose_data
169  * Input:
170  *	hca_guid	- The HCA's node GUID.
171  * Output:
172  *	buffer		- The information is returned in this buffer
173  *      bufsiz		- The size of the information buffer
174  * Returns:
175  *	IBT_SUCCESS/IBT_HCA_INVALID/IBT_FAILURE
176  * Description:
177  *      For a given HCA node GUID it figures out the verbose listing display.
178  */
179 ibt_status_t	ibtl_ibnex_get_hca_verbose_data(ib_guid_t, char **, size_t *);
180 
181 /*
182  * Function:
183  *	ibtl_ibnex_valid_hca_parent
184  * Input:
185  *	pdip		- The parent dip from client's child dev_info_t
186  * Output:
187  *	NONE
188  * Returns:
189  *	IBT_SUCCESS/IBT_NO_HCAS_AVAILABLE
190  * Description:
191  *	For a given pdip, of Port/VPPA devices, match it against all the
192  *	registered HCAs's dip.  If match found return IBT_SUCCESS,
193  *	else IBT_NO_HCAS_AVAILABLE.
194  *	For IOC/Pseudo devices check if the given pdip is that of
195  *	the ib(7d) nexus. If yes return IBT_SUCCESS,
196  *	else IBT_NO_HCAS_AVAILABLE.
197  */
198 ibt_status_t	ibtl_ibnex_valid_hca_parent(dev_info_t *);
199 
200 /*
201  * Function:
202  *	ibtl_ibnex_phci_register
203  * Input:
204  *	hca_dip		- The HCA dip
205  * Output:
206  *	NONE
207  * Returns:
208  *	IBT_SUCCESS/IBT_FAILURE
209  * Description:
210  * 	Register the HCA dip as the MPxIO PCHI.
211  */
212 ibt_status_t	ibtl_ibnex_phci_register(dev_info_t *hca_dip);
213 
214 /*
215  * Function:
216  *	ibtl_ibnex_phci_unregister
217  * Input:
218  *	hca_dip		- The HCA dip
219  * Output:
220  *	NONE
221  * Returns:
222  *	IBT_SUCCESS/IBT_FAILURE
223  * Description:
224  * 	Free up any pending MPxIO Pathinfos and unregister the HCA dip as the
225  * 	MPxIO PCHI.
226  */
227 ibt_status_t	ibtl_ibnex_phci_unregister(dev_info_t *hca_dip);
228 
229 /*
230  * Function:
231  *	ibtl_ibnex_query_hca_byguid
232  * Input:
233  *	hca_guid	- The HCA's node GUID.
234  *	driver_name_size- size of the caller allocated driver_name buffer
235  * Output:
236  *	hca_attrs	- caller allocated buffer which will contain
237  *			  HCA attributes upon success
238  *	driver_name	- caller allocated buffer which will contain
239  *			  HCA driver name upon success
240  *	driver_instance - HCA driver instance
241  *	hca_device_path	- caller allocated buffer of size MAXPATHLEN which
242  *			  will contain hca device path upon success.
243  * Returns:
244  *	IBT_SUCCESS/IBT_FAILURE
245  * Description:
246  *	Get the HCA attributes, driver name and instance number of the
247  *	specified HCA.
248  */
249 ibt_status_t
250 ibtl_ibnex_query_hca_byguid(ib_guid_t, ibt_hca_attr_t *, char *, size_t, int *,
251     char *);
252 
253 #ifdef __cplusplus
254 }
255 #endif
256 
257 #endif /* _SYS_IB_IBTL_IMPL_IBTL_IBNEX_H */
258