xref: /illumos-gate/usr/src/uts/common/sys/ib/ibtl/ibtl_ci_types.h (revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea)
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_IBTL_CI_TYPES_H
27 #define	_SYS_IB_IBTL_IBTL_CI_TYPES_H
28 
29 /*
30  * ibtl_ci_types.h
31  * Definitions shared between the IBTL and CI interface.
32  */
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 typedef	struct ibc_cq_s		*ibt_opaque1_t;
39 typedef	struct ibc_srq_s	*ibt_opaque2_t;
40 typedef	struct ibc_rdd_s	*ibt_rdd_hdl_t;	/* ibt_alloc_eec() */
41 
42 
43 /*
44  * Channel Modify flags - ibt_cep_modify_flags_t
45  *
46  *    Note:
47  *	That the IBT_CEP_SET_RESET_INIT, IBT_CEP_SET_INIT_RTR
48  *	IBT_CEP_SET_RTR_RTS flags are mutually exclusive. However if one of the
49  *	optional attributes associated with these flags is to be modified then
50  *	the corresponding modify flag must also be specified. For example if
51  *	a client wishes to transit from the INIT to RTR state but additionally
52  *	they want to disable atomics, then the modify flags should be:
53  *
54  *	(IBT_CEP_SET_INIT_RTR | IBT_CEP_SET_ATOMIC)
55  *
56  *	And the following attributes specified:
57  *
58  *		- Number of responder resources for RDMA read/atomic ops.
59  *		- Primary Path Address Vector Information.
60  *		- Destination QPN.
61  *		- PSN for ReceiveQ.
62  *		- Minimum RNR NAK Timer field value.
63  *		- ibt_cep_flags_t set to IBT_CEP_ATOMIC
64  *
65  */
66 #define	IBT_CEP_SET_RESET_INIT		IBT_CEP_SET_OPAQUE1
67 #define	IBT_CEP_SET_INIT_RTR		IBT_CEP_SET_OPAQUE2
68 #define	IBT_CEP_SET_RTR_RTS		IBT_CEP_SET_OPAQUE3
69 
70 #define	IBT_CEP_SET_STATE		IBT_CEP_SET_OPAQUE4
71 #define	IBT_CEP_SET_MTU			IBT_CEP_SET_OPAQUE5
72 
73 #define	IBT_CEP_SET_TIMEOUT		IBT_CEP_SET_OPAQUE6
74 #define	IBT_CEP_SET_PKEY_IX		IBT_CEP_SET_OPAQUE7
75 #define	IBT_CEP_SET_MIG			IBT_CEP_SET_OPAQUE8
76 
77 /*
78  * ibt_async_code_t
79  */
80 #define	IBT_EVENT_PATH_MIGRATED_QP	IBT_EVENT_PATH_MIGRATED
81 #define	IBT_EVENT_COM_EST_QP		IBT_EVENT_COM_EST
82 #define	IBT_EVENT_COM_EST_EEC		IBT_ASYNC_OPAQUE2
83 #define	IBT_ERROR_CATASTROPHIC_QP	IBT_ERROR_CATASTROPHIC_CHAN
84 #define	IBT_ERROR_INVALID_REQUEST_QP	IBT_ERROR_INVALID_REQUEST_CHAN
85 #define	IBT_ERROR_ACCESS_VIOLATION_QP	IBT_ERROR_ACCESS_VIOLATION_CHAN
86 #define	IBT_ERROR_PATH_MIGRATE_REQ_QP	IBT_ERROR_PATH_MIGRATE_REQ
87 #define	IBT_EVENT_EMPTY_QP		IBT_EVENT_EMPTY_CHAN
88 
89 
90 /*
91  * ibt_adds_vect_t
92  */
93 #define	av_send_grh	av_opaque1	/* flag to specify if GRH is there */
94 #define	av_dlid		av_opaque2	/* destination LID, or router LID */
95 #define	av_src_path	av_opaque3	/* Source path bits */
96 #define	av_sgid_ix	av_opaque4
97 
98 /*
99  * ibt_wc_t
100  */
101 #define	wc_slid		wc_opaque1	/* source LID */
102 #define	wc_pkey_ix	wc_opaque2	/* The P_Key index, GSI only */
103 #define	wc_path_bits	wc_opaque4	/* DLID path bits, UD's, RawIPv6 & */
104 					/* RawEthr only */
105 
106 /*
107  * ibt_mcg_attr_t
108  */
109 #define	mc_mlid		mc_opaque1	/* Multicast LID */
110 
111 /*
112  * ibt_mcg_info_t
113  */
114 #define	mc_pkt_lt	mc_opaque2
115 
116 /*
117  * ibt_hca_flags_t
118  */
119 #define	IBT_HCA_RESIZE_QP	IBT_HCA_RESIZE_CHAN
120 
121 /*
122  * ibt_object_type_t
123  */
124 #define	IBT_HDL_QP	IBT_HDL_CHANNEL
125 #define	IBT_HDL_AH	IBT_HDL_UD_DEST
126 
127 /*
128  * ibt_hca_attr_t
129  */
130 #define	hca_max_ah	hca_max_ud_dest	/* Max address handles in HCA */
131 #define	hca_ah_max_ci_priv_sz	hca_ud_dest_max_ci_priv_sz
132 #define	hca_qp_max_ci_priv_sz	hca_chan_max_ci_priv_sz
133 #define	hca_max_qp	hca_max_chans	/* Max Channels supported by the HCA */
134 #define	hca_max_qp_sz	hca_max_chan_sz	/* Max outstanding WRs on any channel */
135 #define	hca_max_rdma_out_qp	hca_max_rdma_out_chan
136 #define	hca_max_rdma_in_qp	hca_max_rdma_in_chan
137 #define	hca_max_mcg_qps		hca_max_mcg_chans
138 #define	hca_max_qp_per_mcg	hca_max_chan_per_mcg
139 
140 /*
141  * ibt_hca_portinfo_t
142  */
143 #define	p_base_lid	p_opaque1	/* Base LID of the port */
144 
145 
146 /* Mapping of Verbs defined return status to channel specific. */
147 #define	IBT_QP_FULL			IBT_CHAN_FULL
148 #define	IBT_QP_HDL_INVALID		IBT_CHAN_HDL_INVALID
149 #define	IBT_QP_ATTR_RO			IBT_CHAN_ATTR_RO
150 #define	IBT_QP_STATE_INVALID		IBT_CHAN_STATE_INVALID
151 #define	IBT_QP_SRV_TYPE_INVALID		IBT_CHAN_SRV_TYPE_INVALID
152 #define	IBT_QP_IN_USE			IBT_CHAN_IN_USE
153 #define	IBT_QP_ATOMICS_NOT_SUPPORTED	IBT_CHAN_ATOMICS_NOT_SUPPORTED
154 #define	IBT_QP_OP_TYPE_INVALID		IBT_CHAN_OP_TYPE_INVALID
155 #define	IBT_QP_SGL_FORMAT_INVALID	IBT_CHAN_SGL_FORMAT_INVALID
156 #define	IBT_QP_SGL_LEN_INVALID		IBT_CHAN_SGL_LEN_INVALID
157 #define	IBT_QP_APM_STATE_INVALID	IBT_CHAN_APM_STATE_INVALID
158 #define	IBT_QP_SZ_INSUFFICIENT		IBT_CHAN_SZ_INSUFFICIENT
159 #define	IBT_QP_SPECIAL_TYPE_INVALID	IBT_CHAN_SPECIAL_TYPE_INVALID
160 #define	IBT_WC_LOCAL_QP_OP_ERR		IBT_WC_LOCAL_CHAN_OP_ERR
161 #define	IBT_AH_HDL_INVALID		IBT_UD_DEST_HDL_INVALID
162 #define	IBT_HCA_MCG_QP_EXCEEDED		IBT_HCA_MCG_CHAN_EXCEEDED
163 #define	IBT_MC_MLID_INVALID		IBT_MC_OPAQUE
164 #define	IBT_QP_SRQ			IBT_CHAN_SRQ
165 #define	IBT_QP_TYPE_2A_MW_BOUND		IBT_CHAN_TYPE_2A_MW_BOUND
166 #define	IBT_QP_WQE_SZ_INSUFF		IBT_CHAN_WQE_SZ_INSUFF
167 
168 
169 /*
170  * ibt_cep_path_t
171  */
172 #define	cep_timeout	cep_cm_opaque1	/* 6 bits of timeout exponent */
173 					/* Local ACK timeout for RC */
174 
175 /*
176  * Define an ibt UD Destination struct. This holds all the information
177  * needed to reach a UD destination.
178  *
179  * The ibt_ud_dest_s struct is known by the CI and IBTL.  This structure is
180  * referenced by the CI during UD work request processing.  It is defined here
181  * here so that IBTL does not need to do any data copying during ibt_post_send.
182  */
183 typedef struct ibt_ud_dest_s {
184 	ibt_ah_hdl_t		ud_ah;		/* Address handle */
185 	ib_qpn_t		ud_dst_qpn;	/* Destination QPN */
186 	ib_qkey_t		ud_qkey;	/* Q_Key */
187 
188 	/* The following fields are IBTL-only, i.e., opaque to the CI */
189 	struct ibtl_hca_s	*ud_dest_opaque1;
190 } ibt_ud_dest_t;
191 
192 /*
193  * Reserved For Future Use
194  * RD destination address info.
195  */
196 typedef struct ibt_rd_dest_s {
197 	ibt_ah_hdl_t	rd_ah;		/* Address handle */
198 	ib_eecn_t	rd_eecn;	/* Local EEC Number */
199 	ib_qpn_t	rd_dst_qpn;	/* Destination QP Number */
200 	ib_qkey_t	rd_dst_qkey;	/* The Q_Key for the destination QP */
201 } ibt_rd_dest_t;
202 
203 /*
204  * QP Type.
205  */
206 typedef enum ibt_qp_type_e {
207 	IBT_RC_RQP	= 0,
208 	IBT_RD_RQP	= 1,	/* Reserved For Future Use */
209 	IBT_UC_RQP	= 2,	/* Reserved For Future Use */
210 	IBT_UD_RQP	= 3
211 } ibt_qp_type_t;
212 
213 /*
214  * Special QP Type.
215  */
216 typedef enum ibt_sqp_type_e {
217 	IBT_SMI_SQP		= 0,
218 	IBT_GSI_SQP		= 1,
219 	IBT_RAWIP_SQP		= 2,	/* Reserved For Future Use */
220 	IBT_RAWETHER_SQP	= 3	/* Reserved For Future Use */
221 } ibt_sqp_type_t;
222 
223 /*
224  * QP alloc flags.
225  */
226 typedef enum ibt_qp_alloc_flags_e {
227 	IBT_QP_NO_FLAGS		= 0,
228 	IBT_QP_USER_MAP		= (1 << 0),
229 	IBT_QP_DEFER_ALLOC	= (1 << 1),
230 	IBT_QP_USES_SRQ		= (1 << 2),
231 	IBT_QP_USES_RSS		= (1 << 3)
232 } ibt_qp_alloc_flags_t;
233 
234 /*
235  * QP Alloc Attributes definition.
236  *
237  * Contains the QP attributes that are required to create a QP.
238  */
239 typedef struct ibt_qp_alloc_attr_s {
240 	ibt_qp_alloc_flags_t	qp_alloc_flags;
241 	ibt_cq_hdl_t		qp_scq_hdl;	/* SQ CQ IBT Hdl */
242 	ibt_cq_hdl_t		qp_rcq_hdl;	/* RQ CQ IBT Hdl */
243 	ibt_rdd_hdl_t		qp_rdd_hdl;	/* Reserved */
244 	ibt_pd_hdl_t		qp_pd_hdl;	/* PD handle. */
245 	ibt_chan_sizes_t	qp_sizes;	/* Queue and SGL */
246 	ibt_attr_flags_t	qp_flags;	/* SQ Signaling Type etc */
247 	ibt_opaque1_t		qp_opaque1;
248 	ibt_opaque1_t		qp_opaque2;
249 	ibt_srq_hdl_t		qp_srq_hdl;	/* SRQ ibt hdl */
250 	ibt_opaque2_t		qp_opaque3;
251 } ibt_qp_alloc_attr_t;
252 
253 
254 /*
255  * QP query info
256  */
257 /* RC transport specific */
258 typedef struct ibt_qp_rc_attr_s {
259 	uint32_t		rc_sq_psn:24;	/* SQ PSN */
260 	uint32_t		rc_rq_psn:24;	/* RQ PSN */
261 	ib_qpn_t		rc_dst_qpn;	/* Destination QPN */
262 	ibt_cep_cmstate_t	rc_mig_state;	/* Channel Migration State */
263 	ibt_rnr_retry_cnt_t	rc_rnr_retry_cnt;
264 	uint8_t			rc_retry_cnt:3;
265 	uint8_t			rc_rdma_ra_out;	/* max RDMA-R/Atomic sent */
266 						/* Number of RDMA RD's & */
267 						/* Atomics outstanding */
268 	uint8_t			rc_rdma_ra_in;	/* Incoming RDMA-R/Atomic */
269 						/* Responder resources for */
270 						/* handling incoming RDMA */
271 						/* RD's & Atomics */
272 	ibt_rnr_nak_time_t	rc_min_rnr_nak;	/* min RNR-NAK timer */
273 	ib_mtu_t		rc_path_mtu;
274 	ibt_cep_path_t		rc_path;	/* primary path */
275 	ibt_cep_path_t		rc_alt_path;	/* alternate path */
276 } ibt_qp_rc_attr_t;
277 
278 /*
279  * Reserved For Future Use.
280  * UC transport specific
281  */
282 typedef struct ibt_qp_uc_attr_s {
283 	uint32_t		uc_sq_psn:24;	/* SQ PSN */
284 	uint32_t		uc_rq_psn:24;	/* RQ PSN */
285 	ib_qpn_t		uc_dst_qpn;	/* destination QPN */
286 	ibt_cep_cmstate_t	uc_mig_state;	/* Channel Migration State */
287 	ib_mtu_t		uc_path_mtu;
288 	ibt_cep_path_t		uc_path;	/* primary path */
289 	ibt_cep_path_t		uc_alt_path;	/* alternate path */
290 } ibt_qp_uc_attr_t;
291 
292 /*
293  * Reserved For Future Use.
294  * RD transport specific
295  */
296 typedef struct ibt_qp_rd_attr_s {
297 	ib_qkey_t		rd_qkey;
298 	ibt_rnr_nak_time_t	rd_min_rnr_nak;	/* min RNR-NAK timer */
299 } ibt_qp_rd_attr_t;
300 
301 /* UD transport specific */
302 typedef struct ibt_qp_ud_attr_s {
303 	ib_qkey_t	ud_qkey;	/* Q_Key */
304 	uint32_t	ud_sq_psn:24;	/* SQ PSN */
305 	uint16_t	ud_pkey_ix;	/* P_Key Index */
306 	uint8_t		ud_port;	/* port */
307 	ibt_rss_attr_t	ud_rss;		/* RSS stuff */
308 } ibt_qp_ud_attr_t;
309 
310 /*
311  * Common QP Info
312  */
313 typedef struct ibt_qp_info_s {
314 	uint_t			qp_sq_sz;	/* SQ WQEs */
315 	uint_t			qp_rq_sz;	/* RQ WQEs */
316 	ibt_cep_state_t		qp_state;	/* QP state */
317 	ibt_cep_state_t		qp_current_state; /* current state for */
318 						/* modify_qp to RTS state */
319 	ibt_cep_flags_t		qp_flags;	/* QP flags */
320 	ibt_tran_srv_t		qp_trans;	/* transport service type */
321 	union {					/* transport specific */
322 		ibt_qp_rc_attr_t	rc;
323 		ibt_qp_rd_attr_t	rd;	/* Reserved For Future Use */
324 		ibt_qp_uc_attr_t	uc;	/* Reserved For Future Use */
325 		ibt_qp_ud_attr_t	ud;
326 	} qp_transport;
327 } ibt_qp_info_t;
328 
329 
330 /*
331  * QP Query Attributes definition.
332  */
333 typedef struct ibt_qp_query_attr_s {
334 	ibt_cq_hdl_t		qp_sq_cq;	/* SQ CQ */
335 	ibt_cq_hdl_t		qp_rq_cq;	/* RQ CQ */
336 	ibt_rdd_hdl_t		qp_rdd_hdl;	/* Reserved */
337 	ib_qpn_t		qp_qpn;		/* QPN */
338 	uint_t			qp_sq_sgl;	/* max SQ SGL */
339 	uint_t			qp_rq_sgl;	/* max RQ SGL */
340 	ibt_qp_info_t		qp_info;	/* Modifiable attributes */
341 	ibt_srq_hdl_t		qp_srq;		/* SRQ hdl or NULL */
342 	ibt_attr_flags_t	qp_flags;
343 } ibt_qp_query_attr_t;
344 
345 
346 /*
347  * Reserved For Future Use.
348  * EEC Info.
349  */
350 typedef struct ibt_eec_info_s {
351 	uint32_t		eec_sq_psn:24;	/* SQ PSN */
352 	uint32_t		eec_rq_psn:24;	/* RQ PSN */
353 	ib_eecn_t		eec_dst_eecn;	/* destination EECN */
354 	ibt_cep_state_t		eec_state;	/* EEC state */
355 	ibt_cep_cmstate_t	eec_mig;	/* channel migration state */
356 	uint8_t			eec_rdma_ra_out;	/* RDMA-R/Atomics out */
357 	uint8_t			eec_rdma_ra_in;		/* RDMA-R/Atomics in */
358 	uint8_t			eec_retry_cnt:3;
359 	ibt_rnr_retry_cnt_t	eec_rnr_retry_cnt;
360 	ib_mtu_t		eec_path_mtu;
361 	ibt_cep_path_t		eec_prim_path;	/* primary path */
362 	ibt_cep_path_t		eec_alt_path;	/* alternate path */
363 } ibt_eec_info_t;
364 
365 /*
366  * Reserved For Future Use.
367  * EEC Query Attributes definition.
368  */
369 typedef struct ibt_eec_query_attr_s {
370 	ib_eecn_t		eec_eecn;	/* The EEC Number */
371 	ibt_rdd_hdl_t		eec_rdd_hdl;
372 	ibt_eec_info_t		eec_info;	/* Modifiable attributes */
373 } ibt_eec_query_attr_t;
374 
375 
376 #define	ibt_ah_flags_t	ibt_ud_dest_flags_t
377 #define	IBT_AH_NO_FLAGS		IBT_UD_DEST_NO_FLAGS
378 #define	IBT_AH_USER_MAP		IBT_UD_DEST_USER_MAP
379 #define	IBT_AH_DEFER_ALLOC	IBT_UD_DEST_DEFER_ALLOC
380 
381 #ifdef __cplusplus
382 }
383 #endif
384 
385 #endif	/* _SYS_IB_IBTL_IBTL_CI_TYPES_H */
386