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