xref: /titanic_51/usr/src/uts/common/sys/ib/ibtl/ibvti.h (revision 1a7c1b724419d3cb5fa6eea75123c6b2060ba31b)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_IB_IBTL_IBVTI_H
28 #define	_SYS_IB_IBTL_IBVTI_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * ibvti.h
34  *
35  * This file contains private verbs level transport interface extensions.
36  */
37 #include <sys/ib/ibtl/ibti_common.h>
38 #include <sys/ib/ibtl/ibtl_ci_types.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #define	IBT_CM_NO_QP		IBT_CM_NO_CHAN		/* ibt_cm_reason_t */
45 
46 #define	IBT_CM_SREP_QPN_VALID	IBT_CM_SREP_CHAN_VALID	/* ibt_sidr_status_t */
47 #define	IBT_CM_SREP_NO_QP	IBT_CM_SREP_NO_CHAN	/* ibt_sidr_status_t */
48 
49 #define	IBT_OCHAN_CM_RETRY	IBT_OCHAN_OPAQUE1 /* ibt_chan_open_flags_t */
50 #define	IBT_OCHAN_STARTING_PSN	IBT_OCHAN_OPAQUE2 /* ibt_chan_open_flags_t */
51 #define	IBT_OCHAN_LOCAL_CM_TM	IBT_OCHAN_OPAQUE3 /* ibt_chan_open_flags_t */
52 #define	IBT_OCHAN_REMOTE_CM_TM	IBT_OCHAN_OPAQUE4 /* ibt_chan_open_flags_t */
53 #define	IBT_OCHAN_RDC_EXISTS	IBT_OCHAN_OPAQUE5 /* ibt_chan_open_flags_t */
54 
55 #define	oc_cm_retry_cnt		oc_opaque1	/* ibt_chan_open_args_t */
56 						/* The number of times the */
57 						/* CM will retry its MADs */
58 						/* when IBT_OCHAN_CM_RETRY */
59 						/* is set */
60 #define	oc_starting_psn		oc_opaque2	/* ibt_chan_open_args_t */
61 						/* use oc_starting_psn when */
62 						/* IBT_OCHAN_STARTING_PSN is */
63 						/* set */
64 
65 #define	oc_local_cm_time	oc_opaque3	/* ibt_chan_open_args_t */
66 						/* The maximum time in */
67 						/* microseconds that local */
68 						/* client takes to  respond */
69 						/* for a CM callback */
70 
71 #define	oc_remote_cm_time	oc_opaque4	/* ibt_chan_open_args_t */
72 						/* The maximum time in */
73 						/* microseconds that remote */
74 						/* node takes to  respond */
75 						/* for a CM MAD */
76 
77 #define	cm_eec_hdl		cm_opaque	/* ibt_cm_event_t */
78 
79 #define	req_remote_eecn		req_opaque1	/* ibt_cm_req_rcv_t */
80 #define	req_local_eecn		req_opaque2	/* ibt_cm_req_rcv_t */
81 
82 #define	IBT_CM_RDC_EXISTS	0x4		/* ibt_cm_flags_t */
83 
84 #define	ai_dlid			ai_opaque1	/* Local dest, or router LID */
85 #define	ai_src_path		ai_opaque2	/* Source path bits */
86 
87 
88 /*
89  * Note that variables of type ibt_qp_hdl_t (really ibt_channel_hdl_t)
90  * can be used in some of the IBTI interfaces, e.g., ibt_open_rc_channel().
91  */
92 #define	ibt_qp_hdl_t		ibt_channel_hdl_t
93 
94 /*
95  * ibt_cq_priority_t
96  * VTI clients have full control over CQ priorities.
97  */
98 #define	IBT_CQ_PRI_1	IBT_CQ_OPAQUE_1		/* Lowest priority */
99 #define	IBT_CQ_PRI_2	IBT_CQ_OPAQUE_2
100 #define	IBT_CQ_PRI_3	IBT_CQ_OPAQUE_3
101 #define	IBT_CQ_PRI_4	IBT_CQ_OPAQUE_4
102 #define	IBT_CQ_PRI_5	IBT_CQ_OPAQUE_5
103 #define	IBT_CQ_PRI_6	IBT_CQ_OPAQUE_6
104 #define	IBT_CQ_PRI_7	IBT_CQ_OPAQUE_7
105 #define	IBT_CQ_PRI_8	IBT_CQ_OPAQUE_8
106 #define	IBT_CQ_PRI_9	IBT_CQ_OPAQUE_9
107 #define	IBT_CQ_PRI_10	IBT_CQ_OPAQUE_10
108 #define	IBT_CQ_PRI_11	IBT_CQ_OPAQUE_11
109 #define	IBT_CQ_PRI_12	IBT_CQ_OPAQUE_12
110 #define	IBT_CQ_PRI_13	IBT_CQ_OPAQUE_13
111 #define	IBT_CQ_PRI_14	IBT_CQ_OPAQUE_14
112 #define	IBT_CQ_PRI_15	IBT_CQ_OPAQUE_15
113 #define	IBT_CQ_PRI_16	IBT_CQ_OPAQUE_16	/* Highest priority */
114 
115 /*
116  * FUNCTION PROTOTYPES.
117  */
118 /*
119  * ibt_alloc_ah()
120  *	Allocates and returns an address handle (ibt_ah_hdl_t).
121  *
122  *	hca_hdl		The IBT HCA handle returned to the client
123  *			on an ibt_open_hca() call.
124  *
125  *	flags		IBT_AH_NO_FLAGS, IBT_AH_USER_MAP and IBT_AH_DEFER_ALLOC
126  *
127  *	pd		Is a protection domain to associate with this handle.
128  *
129  *	adds_vectp	Points to an ibt_adds_vect_t struct.
130  *
131  *	ah_p		The address to store the allocated address handle.
132  *
133  */
134 ibt_status_t ibt_alloc_ah(ibt_hca_hdl_t hca_hdl, ibt_ah_flags_t flags,
135     ibt_pd_hdl_t pd, ibt_adds_vect_t *adds_vectp, ibt_ah_hdl_t *ah_p);
136 
137 /*
138  * ibt_free_ah()
139  *	Release/de-allocate the specified handle.
140  *
141  *	hca_hdl		The IBT HCA handle.
142  *
143  *	ah		The address handle.
144  */
145 ibt_status_t ibt_free_ah(ibt_hca_hdl_t hca_hdl, ibt_ah_hdl_t ah);
146 
147 /*
148  * ibt_query_ah
149  *	Obtain the address vector information for the specified address handle.
150  *
151  *	hca_hdl		The IBT HCA handle returned to the client
152  *			on an ibt_open_hca() call.
153  *
154  *	ah		The address handle.
155  *
156  *	pd_p		The protection domain handle of the PD with which this
157  *			address handle is associated.
158  *
159  *	adds_vectp	Points to an ibt_adds_vect_t struct.
160  *
161  */
162 ibt_status_t ibt_query_ah(ibt_hca_hdl_t hca_hdl, ibt_ah_hdl_t ah,
163     ibt_pd_hdl_t *pd_p, ibt_adds_vect_t *adds_vectp);
164 
165 /*
166  * ibt_modify_ah
167  *	Modify the address vector information for the specified address handle.
168  *
169  *	hca_hdl		The IBT HCA handle returned to the client on an
170  *			ibt_open_hca() call.
171  *
172  *	ah		The address handle.
173  *
174  *	adds_vectp	Points to an ibt_adds_vect_t struct. The new address
175  *			vector information is specified is this returned struct.
176  */
177 ibt_status_t ibt_modify_ah(ibt_hca_hdl_t hca_hdl, ibt_ah_hdl_t ah,
178     ibt_adds_vect_t *adds_vectp);
179 
180 
181 /*
182  * ibt_alloc_qp()
183  *	Allocate a QP with specified attributes.
184  *
185  *	hca_hdl		Specifies the QP's HCA.
186  *
187  *	type		Specifies the type of QP to alloc in ibt_alloc_qp()
188  *
189  *	qp_attr		Specifies the ibt_qp_alloc_attr_t that are needed to
190  *			allocate a QP. All allocated QP's are returned in the
191  *			RESET state.
192  *
193  *	queue_sizes_p	NULL or a pointer to ibt_chan_sizes_s struct to return
194  *			new channel sizes.
195  *			cs_sq		Returned new SendQ size.
196  *			cs_rq		Returned new RecvQ size.
197  *			cs_sq_sgl	Returned Max SGL elements in a SQ WR.
198  *			cs_rq_sgl	Returned Max SGL elements in a RQ WR.
199  *
200  *	qpn_p		NULL or a pointer to return QP Number of the
201  *			allocated QP.
202  *
203  *	ibt_qp_p	The address to store the handle of the allocated QP.
204  *
205  * Note:
206  *	QPs allocated by ibt_alloc_qp are in the RESET state.  The client
207  *	needs to transition an RC QP into the INIT state if it is going to
208  *	use ibt_open_rc_channel to establish the connection.
209  *	The client needs to transition an UD QP into the RTS state.
210  */
211 ibt_status_t ibt_alloc_qp(ibt_hca_hdl_t hca_hdl, ibt_qp_type_t type,
212     ibt_qp_alloc_attr_t *qp_attr, ibt_chan_sizes_t *queue_sizes_p,
213     ib_qpn_t *qpn_p, ibt_qp_hdl_t *ibt_qp_p);
214 
215 /*
216  * ibt_alloc_special_qp()
217  *	Allocate a special QP with specified attributes.
218  *
219  *	hca_hdl		Specifies the QP's HCA.
220  *
221  *	port		Specifies the Port on the HCA.
222  *
223  *	type		Specifies the type of Special QP to alloc.
224  *
225  *	qp_attr		Specifies the ibt_qp_alloc_attr_t that are needed to
226  *			allocate a Special QP. All allocated QP's are returned
227  *			in the RESET state.
228  *
229  *	queue_sizes_p	NULL or a pointer to ibt_chan_sizes_s struct to return
230  *			new channel sizes.
231  *			cs_sq		Returned new SendQ size.
232  *			cs_rq		Returned new RecvQ size.
233  *			cs_sq_sgl	Returned Max SGL elements in a SQ WR.
234  *			cs_rq_sgl	Returned Max SGL elements in a RQ WR.
235  *
236  *	ibt_qp_p	The address to store the handle of the allocated QP.
237  *
238  * Note:
239  *	QPs allocated by ibt_alloc_special_qp are in the RESET state.
240  *	The client needs to transition an UD QP into the RTS state.
241  */
242 ibt_status_t ibt_alloc_special_qp(ibt_hca_hdl_t hca_hdl, uint8_t port,
243     ibt_sqp_type_t type, ibt_qp_alloc_attr_t *qp_attr,
244     ibt_chan_sizes_t *queue_sizes_p, ibt_qp_hdl_t *ibt_qp_p);
245 
246 /*
247  * ibt_flush_qp()
248  *	Transition a QP into error state to flush all outstanding
249  *	work requests. Must be called before calling ibt_free_qp().
250  *	Use ibt_close_rc_channel for RC QPs that have been opened
251  *	successfully.
252  *
253  *	ibt_qp		The ibt_qp_hdl_t of previously allocated QP.
254  */
255 ibt_status_t ibt_flush_qp(ibt_qp_hdl_t ibt_qp);
256 
257 /*
258  * ibt_initialize_qp()
259  *	Transition a QP from RESET state into a usable state.
260  *	An RC QP is transitioned into the INIT state, ready for
261  *	a call to ibt_open_rc_channel().  A UD QP is transitioned
262  *	all the way to the RTS state.
263  *
264  *	ibt_qp		The ibt_qp_hdl_t of previously allocated QP.
265  *
266  *	modify_attrp	Points to an ibt_qp_info_t struct that contains all
267  *			the attributes of the specified QP that a client is
268  *			allowed to modify after a QP has been allocated.
269  */
270 ibt_status_t ibt_initialize_qp(ibt_qp_hdl_t ibt_qp,
271     ibt_qp_info_t *modify_attrp);
272 
273 
274 /*
275  * ibt_free_qp()
276  *	De-allocate or free the resources associated with an existing QP.
277  *
278  *	ibt_qp		The ibt_qp_hdl_t of previously allocated QP.
279  */
280 ibt_status_t ibt_free_qp(ibt_qp_hdl_t ibt_qp);
281 
282 
283 /*
284  * ibt_query_qp()
285  *	Query the attributes of an existing QP.
286  *
287  *	ibt_qp		The ibt_qp_hdl_t of previously allocated QP.
288  *
289  *	qp_attrp	Specifies the ibt_qp_query_attr_t contains all the
290  *			attributes of the specified QP.
291  */
292 ibt_status_t ibt_query_qp(ibt_qp_hdl_t ibt_qp, ibt_qp_query_attr_t *qp_attrp);
293 
294 
295 /*
296  * ibt_modify_qp()
297  *	Modify the attributes of an existing QP.
298  *
299  *	ibt_qp		The ibt_qp_hdl_t of previously allocated QP.
300  *
301  *	flags		Specifies which attributes in ibt_qp_mod_attr_t
302  *			are to be modified.
303  *
304  *	qp_attr		Points to an ibt_qp_info_t struct that contains all
305  *			the attributes of the specified QP that a client is
306  *			allowed to modify after a QP has been allocated.
307  *
308  *	actual_sz	NULL or a pointer to ibt_queue_size_s struct to
309  *			return new queue sizes.
310  *			sq_sz		Returned new SendQ size.
311  *			rq_sz		Returned new RecvQ size.
312  */
313 ibt_status_t ibt_modify_qp(ibt_qp_hdl_t ibt_qp, ibt_cep_modify_flags_t flags,
314     ibt_qp_info_t *qp_attr, ibt_queue_sizes_t *actual_sz);
315 
316 /*
317  * ibt_set_qp_private(), ibt_get_qp_private()
318  *	Set/Get the client private data.
319  *
320  *	ibt_qp		The ibt_qp_hdl_t of the allocated QP.
321  *
322  *	clnt_private	The client private data.
323  */
324 void ibt_set_qp_private(ibt_qp_hdl_t ibt_qp, void *clnt_private);
325 void *ibt_get_qp_private(ibt_qp_hdl_t ibt_qp);
326 
327 
328 /*
329  * ibt_qp_to_hca_guid
330  *      A helper function to retrieve HCA GUID for the specified QP.
331  *
332  *      ibt_qp		The ibt_qp_hdl_t of the allocated QP.
333  *
334  *      hca_guid        Returned HCA GUID on which the specified QP is
335  *                      allocated. Valid if it is non-NULL on return.
336  */
337 ib_guid_t ibt_qp_to_hca_guid(ibt_qp_hdl_t ibt_qp);
338 
339 
340 /*
341  * ibt_recover_ud_qp()
342  *      Recover an UD QP which has transitioned to SQ Error state. The
343  *      ibt_recover_ud_qp() transitions the QP from SQ Error state to
344  *	Ready-To-Send QP state.
345  *
346  *      If a work request posted to a UD QP's send queue completes with
347  *      an error (see ibt_wc_status_t), the QP gets transitioned to SQ
348  *      Error state. In order to reuse this QP, ibt_recover_ud_qp() can
349  *      be used to recover the QP to a usable (Ready-to-Send) state.
350  *
351  *      ibt_qp         An UD QP handle which is in SQError state.
352  */
353 ibt_status_t ibt_recover_ud_qp(ibt_qp_hdl_t ibt_qp);
354 
355 
356 /*
357  * Datagram Domain Functions
358  */
359 
360 /*
361  * ibt_ud_get_dqpn
362  *	Finds the destination QPN at the specified destination that the
363  *	specified service can be reached on. The IBTF CM initiates the
364  *	service ID resolution protocol (SIDR) to determine a destination QPN.
365  *
366  *	attr		A pointer to an ibt_ud_dest_attr_t struct input arg.
367  *
368  *	mode		IBT_BLOCKING		Do not return until completed.
369  *						"returns" must not be NULL.
370  *			IBT_NONBLOCKING		Return as soon as possible.
371  *						This requires that the client
372  *						supplies a UD CM handler to
373  *						be called when this completes.
374  *						"returns" must be NULL.
375  *
376  *	returns		If the function is called in blocking mode, "returns"
377  *			is a pointer to an ibt_ud_returns_t struct, containing:
378  *
379  *			ud_status	  Indicates if the UD destination handle
380  *					  was allocated successfully. If the
381  *					  handle was not allocated the status
382  *					  code gives an indication why not.
383  *			ud_redirect	  A ibt_redirect_info_s struct, valid
384  *					  for a ud_status of
385  *					  IBT_CM_SREP_REDIRECT. The remote
386  *					  destination could not provide the
387  *					  service requested in dest_attrs. The
388  *					  request was redirected to a new
389  *					  destination, the details of which are
390  *					  returned in ud_redirect.
391  *			ud_dqpn		  Returned destination QPN.
392  *			ud_qkey		  Q_Key for destination QPN.
393  *			ud_priv_data_len  The length (in bytes) of the buffer
394  *					  pointed to by ud_priv_data.
395  *			ud_priv_data	  A pointer to the caller's buffer
396  *					  where private data from the
397  *					  destination node is returned.
398  */
399 ibt_status_t ibt_ud_get_dqpn(ibt_ud_dest_attr_t *attr,
400     ibt_execution_mode_t mode, ibt_ud_returns_t *returns);
401 
402 /*
403  * ibt_get_module_failure()
404  *
405  *	Used to obtain a special IBTF failure code for IB module specific
406  *	failures, i.e. failures other than those defined in ibt_status_t.
407  *
408  *	type	Identifies the failing IB module.
409  *
410  *	ena	'0' or the data for Fault Management Architecture (ENA).
411  */
412 ibt_status_t ibt_get_module_failure(ibt_failure_type_t type, uint64_t ena);
413 
414 #ifdef __cplusplus
415 }
416 #endif
417 
418 #endif /* _SYS_IB_IBTL_IBVTI_H */
419