xref: /illumos-gate/usr/src/uts/common/sys/ib/ibtl/impl/ibtl_cm.h (revision a23420cf95f05ac67f2c299116a3225581e519d1)
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 (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef _SYS_IB_IBTL_IMPL_IBTL_CM_H
26 #define	_SYS_IB_IBTL_IMPL_IBTL_CM_H
27 
28 /*
29  * ibtl_cm.h
30  *
31  * All data structures and function prototypes that are specific to the
32  * IBTL <-> IBCM private interface.
33  */
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * ibt_ud_dest_t is defined in ibtl_ci_types.h, it holds all the
41  * information needed to reach a UD destination.
42  *
43  *	typedef struct ibt_ud_dest_s {
44  *		ibc_ah_hdl_t		ud_ah;		* Address handle *
45  *		ib_qpn_t		ud_dst_qpn;	* Destination QPN *
46  *		ib_qkey_t		ud_qkey;	* Q_Key *
47  *
48  *		* The following fields are CM-only, i.e., opaque to the CI *
49  *		struct ibtl_hca_s	*ud_hca;	* IBTL HCA handle *
50  *	} ibt_ud_dest_t;
51  */
52 #define	ud_dest_hca	ud_dest_opaque1
53 
54 /* CM private data */
55 void ibtl_cm_set_chan_private(ibt_channel_hdl_t chan, void *cm_private);
56 void *ibtl_cm_get_chan_private(ibt_channel_hdl_t chan);
57 void ibtl_cm_release_chan_private(ibt_channel_hdl_t chan);
58 void ibtl_cm_wait_chan_private(ibt_channel_hdl_t chan);
59 
60 /*
61  * ibtl_cm_get_hca_port() helper function will retrieve these for the
62  * specified SGID value.
63  */
64 typedef struct ibtl_cm_hca_port_s {
65 	ib_guid_t	hp_hca_guid;	/* HCA GUID. */
66 	ib_guid_t	hp_port_guid;   /* Port GUID. */
67 	ib_lid_t	hp_base_lid;	/* Base LID of Port. */
68 	uint8_t		hp_port;	/* HCA Port Number. */
69 	uint8_t		hp_sgid_ix;	/* SGID Index in SGID Table. */
70 	uint8_t		hp_lmc:3;	/* Local mask control */
71 	ib_mtu_t	hp_mtu;		/* Max transfer unit - pkt */
72 } ibtl_cm_hca_port_t;
73 
74 /*
75  * ibtl_cm_get_hca_port()
76  *
77  * 	A helper function to get HCA node GUID, Base LID, SGID Index,
78  *	port number, LMC and MTU for the specified SGID.
79  *
80  *	sgid		Input Source GID.
81  *
82  *	hca_guid	Optional HCA Guid.
83  *
84  *	hca_port	Pointer to ibtl_cm_hca_port_t structure,
85  */
86 ibt_status_t ibtl_cm_get_hca_port(ib_gid_t sgid, ib_guid_t hca_guid,
87     ibtl_cm_hca_port_t *hca_port);
88 
89 
90 ibt_status_t ibtl_cm_get_local_comp_gids(ib_guid_t hca_guid, ib_gid_t sgid,
91     ib_gid_t **gids_p, uint_t *num_gids_p);
92 
93 int ibtl_cm_is_multi_sm(ib_guid_t hca_guid);
94 
95 /*
96  * ibtl_cm_get_1st_full_pkey_ix()
97  *
98  *	A helper function to get P_Key Index of the first full member P_Key
99  *	available on the specified HCA and Port combination.
100  *
101  *	hca_guid	HCA GUID.
102  *
103  *	port		HCA port number.
104  */
105 uint16_t ibtl_cm_get_1st_full_pkey_ix(ib_guid_t hca_guid, uint8_t port);
106 
107 
108 /*
109  * Functions to support CM and clients to reliably free RC QPs.
110  *
111  * ibtl_cm_chan_is_open()
112  *
113  *	Inform IBTL that the connection has been established on this
114  *	channel so that a later call to ibtl_cm_chan_is_closed()
115  *	will be required to free the QPN used by this channel.
116  *
117  * ibtl_cm_chan_is_opening()
118  *
119  *	Inform IBTL that the connection established on this channel is
120  *	in progress.
121  *
122  * ibtl_cm_chan_open_is_aborted()
123  *
124  *	Inform IBTL that the connection established on this channel has
125  *	aborted. So undo what was done in ibtl_cm_chan_is_opening().
126  *
127  * ibtl_cm_chan_is_closing()
128  *
129  *	Inform IBTL that the TIMEWAIT delay for the connection has been
130  *	started for this channel so that the QP can be freed.
131  *
132  * ibtl_cm_is_chan_closing()
133  *
134  *	Returns 1 if the connection on this channel has been moved to TIME WAIT
135  *
136  * ibtl_cm_is_chan_closed()
137  *
138  *	Returns 1 if the connection on this channel has completed TIME WAIT
139  *
140  * ibtl_cm_chan_is_closed()
141  *
142  *	Inform IBTL that the TIMEWAIT delay for the connection has been
143  *	reached for this channel so that the QPN can be reused.
144  *
145  *	rc_chan		Channel Handle
146  *
147  * ibtl_cm_chan_is_reused()
148  *
149  *	Inform IBTL that the channel is going to be re-used for another
150  *	connection.
151  *
152  *	rc_chan		Channel Handle
153  */
154 void ibtl_cm_chan_is_open(ibt_channel_hdl_t rc_chan);
155 void ibtl_cm_chan_is_opening(ibt_channel_hdl_t rc_chan);
156 void ibtl_cm_chan_open_is_aborted(ibt_channel_hdl_t rc_chan);
157 void ibtl_cm_chan_is_closing(ibt_channel_hdl_t rc_chan);
158 void ibtl_cm_chan_is_closed(ibt_channel_hdl_t rc_chan);
159 void ibtl_cm_chan_is_reused(ibt_channel_hdl_t rc_chan);
160 int  ibtl_cm_is_chan_closing(ibt_channel_hdl_t rc_chan);
161 int  ibtl_cm_is_chan_closed(ibt_channel_hdl_t rc_chan);
162 
163 /*
164  * ibtl_cm_get_chan_type()
165  *
166  *	A helper function to get channel transport type.
167  */
168 ibt_tran_srv_t ibtl_cm_get_chan_type(ibt_channel_hdl_t chan);
169 
170 /*
171  * ibtl_cm_change_service_cnt()
172  *
173  *	Inform IBTL that service registration count has changed
174  *	so that it can correctly manage whether or not it should
175  *	allow ibt_detach() to succeed.
176  */
177 void ibtl_cm_change_service_cnt(ibt_clnt_hdl_t ibt_hdl, int delta_num_sids);
178 
179 /*
180  * ibtl_cm_query_hca_ports_byguid()
181  *
182  *	Use the cached copy of the portinfo.
183  */
184 ibt_status_t ibtl_cm_query_hca_ports_byguid(ib_guid_t hca_guid, uint8_t port,
185     ibt_hca_portinfo_t **port_info_p, uint_t *ports_p, uint_t *size_p);
186 
187 
188 /*
189  * ibtl_cm_get_active_plist
190  *
191  *	Returns a list of active source points which satisfy the desired
192  *	attribute. The memory allocated for the array "port_list_p" should
193  *	be freed by the caller using ibtl_cm_free_active_plist().
194  *
195  * ibtl_cm_free_active_plist
196  *
197  *	Frees the memory allocated in ibtl_cm_get_active_plist().
198  */
199 
200 #define	IBTL_CM_SIMPLE_SETUP	0
201 #define	IBTL_CM_MULTI_SM	(1 << 0)
202 #define	IBTL_CM_MULTI_HCA	(1 << 1)
203 
204 typedef struct ibtl_cm_port_list_s {
205 	ib_guid_t	p_hca_guid;
206 	ib_gid_t	p_sgid;
207 	ib_lid_t	p_base_lid;
208 	ib_mtu_t	p_mtu;
209 	uint8_t		p_sgid_ix;
210 	uint8_t		p_port_num;
211 	uint8_t		p_count;
212 	uint8_t		p_multi;
213 	void		*p_saa_hdl;
214 	ibt_ip_addr_t	p_src_ip;
215 } ibtl_cm_port_list_t;
216 
217 ibt_status_t ibtl_cm_get_active_plist(ibt_path_attr_t *attr,
218     ibt_path_flags_t flags, ibtl_cm_port_list_t **port_list_p);
219 void ibtl_cm_free_active_plist(ibtl_cm_port_list_t *port_list);
220 
221 /*
222  * Functions to support ibt_register_subnet_notices and the
223  * related callbacks.
224  *
225  * ibtl_cm_set_sm_notice_handler
226  *	Pass the handler into IBTL where it will actually be used.
227  *
228  * ibtl_cm_sm_notice_handler
229  *	Post an event to interested IBT clients.
230  *
231  * ibtl_cm_sm_notice_init_failure
232  *	Inform the client that callbacks are not working.
233  */
234 void ibtl_cm_sm_notice_handler(ib_gid_t sgid, ibt_subnet_event_code_t code,
235     ibt_subnet_event_t *event);
236 
237 void ibtl_cm_set_sm_notice_handler(ibt_clnt_hdl_t ibt_hdl,
238     ibt_sm_notice_handler_t sm_notice_handler, void *private);
239 
240 /* pass all failing sgids at once */
241 typedef struct ibtl_cm_sm_init_fail_s {
242 	int		smf_num_sgids;
243 	ibt_clnt_hdl_t	smf_ibt_hdl;
244 	ib_gid_t	smf_sgid[1];
245 } ibtl_cm_sm_init_fail_t;
246 
247 void ibtl_cm_sm_notice_init_failure(ibtl_cm_sm_init_fail_t *ifail);
248 
249 char *ibtl_cm_get_clnt_name(ibt_clnt_hdl_t ibt_hdl);
250 
251 /*
252  * ibtl_cm_set_node_info_cb: This is a private interface between IBTL and IBCM
253  * to let IBTL get the Node Record of a remote port. This interface is used by
254  * IBCM to register a callback which can be used by IBTL to get the Node record.
255  */
256 void ibtl_cm_set_node_info_cb(ibt_status_t (*)(ib_guid_t, uint8_t, ib_lid_t,
257     ibt_node_info_t *));
258 
259 #ifdef __cplusplus
260 }
261 #endif
262 
263 #endif /* _SYS_IB_IBTL_IMPL_IBTL_CM_H */
264