xref: /illumos-gate/usr/src/uts/common/sys/ib/ibtl/ibci.h (revision 7c478bd9)
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_IBCI_H
28 #define	_SYS_IB_IBTL_IBCI_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * ibci.h
34  *
35  * Define the data structures and function prototypes that comprise
36  * the IB Channel API (API for HCA drivers).  All CI handles are opaque
37  * to the IBTF here, real data is accessed in the HCA driver by a
38  * typecast to a driver specific struct.
39  */
40 
41 #include <sys/ib/ibtl/ibtl_types.h>
42 #include <sys/ib/ibtl/ibtl_ci_types.h>
43 #include <sys/modctl.h>
44 
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 /*
51  * Define CI opaque IBTF handles.
52  */
53 typedef	struct	ibtl_qp_s	*ibtl_qp_hdl_t;		/* ibt_alloc_qp() */
54 typedef struct	ibtl_eec_s	*ibtl_eec_hdl_t;	/* ibt_alloc_eec() */
55 
56 /*
57  * Define IBTF opaque CI handles.
58  */
59 typedef struct ibc_hca_s	*ibc_hca_hdl_t; /* HCA/CI Handle */
60 typedef struct ibc_pd_s		*ibc_pd_hdl_t;	/* Protection Domain Handle */
61 typedef	struct ibc_rdd_s	*ibc_rdd_hdl_t;	/* Reliable Datagram Domain */
62 typedef struct ibc_ah_s		*ibc_ah_hdl_t;	/* Address Handle */
63 typedef struct ibc_qp_s		*ibc_qp_hdl_t;	/* Queue Pair Handle */
64 typedef struct ibc_srq_s	*ibc_srq_hdl_t;	/* Shared Receive Queue Hdl */
65 typedef struct ibc_qpn_s	*ibc_qpn_hdl_t;	/* Queue Pair Number Handle */
66 typedef struct ibc_cq_s		*ibc_cq_hdl_t;	/* Completion Queue Handle */
67 typedef struct ibc_eec_s	*ibc_eec_hdl_t; /* End-to-End Context Handle */
68 
69 #define	ibc_mr_hdl_t	ibt_mr_hdl_t	/* Memory Region Handle */
70 #define	ibc_mw_hdl_t	ibt_mw_hdl_t	/* Memory Window Handle */
71 #define	ibc_ma_hdl_t	ibt_ma_hdl_t	/* Memory Area Handle */
72 
73 /* Handle used by CI for up calls to IBTF */
74 typedef struct ibtl_hca_devinfo_s *ibc_clnt_hdl_t;	/* ibc_attach() */
75 
76 /*
77  * Fields opaque to TI, but visible to CI
78  */
79 
80 /*
81  * ibt_qp_alloc_attr_t
82  */
83 #define	qp_ibc_scq_hdl	qp_opaque1
84 #define	qp_ibc_rcq_hdl	qp_opaque2
85 #define	qp_ibc_srq_hdl	qp_opaque3
86 
87 
88 /*
89  * ibt_status_t
90  */
91 #define	IBT_HCA_RAWD_CHAN_EXCEEDED	IBT_ERR_OPAQUE1	/* Requested raw QP */
92 							/* exceeds HCA max */
93 							/* limit */
94 #define	IBT_CHAN_RAWD_NOT_SUPPORTED	IBT_ERR_OPAQUE2	/* Raw datagram QPs */
95 							/* not supported */
96 #define	IBT_CHAN_RD_NOT_SUPPORTED	IBT_ERR_OPAQUE3	/* RD not supported */
97 #define	IBT_EEC_HDL_INVALID		IBT_ERR_OPAQUE4	/* Invalid EEC handle */
98 #define	IBT_EEC_STATE_INVALID		IBT_ERR_OPAQUE5	/* Invalid EEC State */
99 #define	IBT_EEC_ATTR_RO			IBT_ERR_OPAQUE6	/* Can't Change EEC */
100 							/* Attribute */
101 #define	IBT_RDD_IN_USE			IBT_ERR_OPAQUE7	/* RDD in Use */
102 #define	IBT_RDD_HDL_INVALID		IBT_ERR_OPAQUE8	/* Invalid RDD */
103 #define	IBT_RNR_NAK_TIMER_INVALID	IBT_ERR_OPAQUE9	/* Invalid RNR NAK */
104 							/* Timer Value */
105 #define	IBT_RDD_NOT_SUPPORTED		IBT_ERR_OPAQUE10
106 
107 
108 /*
109  * ibt_wc_status_t
110  */
111 #define	IBT_WC_LOCAL_EEC_OP_ERR		12	/* Internal consistency error */
112 #define	IBT_WC_LOCAL_RDD_VIOLATION_ERR	30	/* The RDD associated with */
113 						/* the QP does not match */
114 						/* the RDD associated with */
115 						/* the EE Context */
116 #define	IBT_WC_REMOTE_RD_REQ_INVALID	31	/* Detected an invalid */
117 						/* incoming RD message */
118 #define	IBT_WC_EEC_REMOTE_ABORTED	32	/* Requester aborted the */
119 						/* operation */
120 #define	IBT_WC_EEC_NUM_INVALID		33	/* Invalid EEC Number */
121 						/* detected */
122 #define	IBT_WC_EEC_STATE_INVALID	34	/* Invalid EEC state */
123 
124 /*
125  * ibt_async_code_t
126  */
127 #define	IBT_EVENT_PATH_MIGRATED_EEC	IBT_ASYNC_OPAQUE1
128 #define	IBT_ERROR_CATASTROPHIC_EEC	IBT_ASYNC_OPAQUE3
129 #define	IBT_ERROR_PATH_MIGRATE_REQ_EEC	IBT_ASYNC_OPAQUE4
130 
131 /*
132  * ibt_object_type_t
133  */
134 #define	IBT_HDL_EEC	IBT_HDL_OPAQUE1
135 #define	IBT_HDL_RDD	IBT_HDL_OPAQUE2
136 
137 
138 /*
139  * ibt_hca_attr_t
140  */
141 #define	hca_max_rdd		hca_opaque2	/* Max RDDs in HCA */
142 #define	hca_max_eec		hca_opaque3	/* Max EEContexts in HCA */
143 #define	hca_max_rd_sgl		hca_opaque4	/* Max SGL entries per RD WR */
144 #define	hca_max_rdma_in_ee	hca_opaque5	/* Max RDMA Reads/Atomics in */
145 						/* per EEC with HCA as target */
146 #define	hca_max_rdma_out_ee	hca_opaque6	/* Max RDMA Reads/Atomics out */
147 						/* per EE by this HCA */
148 #define	hca_max_ipv6_qp		hca_max_ipv6_chan
149 #define	hca_max_ether_qp	hca_max_ether_chan
150 #define	hca_eec_max_ci_priv_sz	hca_opaque7
151 #define	hca_rdd_max_ci_priv_sz	hca_opaque8
152 
153 
154 /*
155  * ibt_wc_t
156  */
157 #define	wc_eecn		wc_opaque3	/* End-to-End Context RD's only */
158 
159 
160 /* Channel Interface version */
161 typedef enum ibc_version_e {
162 	IBCI_V1		= 1
163 } ibc_version_t;
164 
165 
166 typedef enum ibc_free_qp_flags_e {
167 	IBC_FREE_QP_AND_QPN	= 0,	/* free all qp resources */
168 	IBC_FREE_QP_ONLY	= 1	/* OK to free the QP, but the QPN */
169 					/* cannot be reused until a future */
170 					/* call to ibc_release_qpn(qpn_hdl), */
171 					/* where qpn_hdl is a return value */
172 					/* of ibc_free_qp() */
173 } ibc_free_qp_flags_t;
174 
175 /*
176  * RDD alloc flags
177  */
178 typedef enum ibc_rdd_flags_e {
179 	IBT_RDD_NO_FLAGS	= 0,
180 	IBT_RDD_USER_MAP	= (1 << 0),
181 	IBT_RDD_DEFER_ALLOC	= (1 << 1)
182 } ibc_rdd_flags_t;
183 
184 /*
185  * EEC alloc flags
186  */
187 typedef enum ibc_eec_flags_e {
188 	IBT_EEC_NO_FLAGS	= 0,
189 	IBT_EEC_USER_MAP	= (1 << 0),
190 	IBT_EEC_DEFER_ALLOC	= (1 << 1)
191 } ibc_eec_flags_t;
192 
193 
194 /*
195  * Completion Queues
196  *
197  */
198 
199 /*
200  * CQ handler attribute structure.
201  */
202 typedef struct ibc_cq_handler_attr_s {
203 	ibt_cq_handler_id_t	h_id;		/* Valid ID != NULL */
204 	int			h_flags;	/* Flags of ddi_intr_get_cap */
205 	int			h_pri;		/* priority from */
206 						/* ddi_intr_get_pri */
207 	void			*h_bind;	/* unknown intrd stuff */
208 } ibc_cq_handler_attr_t;
209 
210 
211 /*
212  * Event data for asynchronous events and errors. The QP/EEC/CQ/SRQ handle,
213  * or port number associated with the Event/Error is passed as an argument
214  * to the async handler.
215  *
216  * Here is the table that describes which async_event struct members need
217  * to be defined when ibc_async_handler is called.
218  *
219  *		async_code		async_event fields
220  *	IBT_EVENT_PATH_MIGRATED_QP		ev_qp_hdl
221  *	IBT_EVENT_SQD				ev_qp_hdl
222  *	IBT_EVENT_COM_EST_QP			ev_qp_hdl
223  *	IBT_ERROR_CATASTROPHIC_QP		ev_qp_hdl
224  *	IBT_ERROR_INVALID_REQUEST_QP		ev_qp_hdl
225  *	IBT_ERROR_ACCESS_VIOLATION_QP		ev_qp_hdl
226  *	IBT_ERROR_PATH_MIGRATE_REQ_QP		ev_qp_hdl
227  *
228  *	IBT_EVENT_PATH_MIGRATED_EEC		ev_eec_hdl
229  *	IBT_EVENT_COM_EST_EEC			ev_eec_hdl
230  *	IBT_ERROR_PATH_MIGRATE_REQ_EEC		ev_eec_hdl
231  *	IBT_ERROR_CATASTROPHIC_EEC		ev_eec_hdl
232  *
233  *	IBT_ERROR_CQ				ev_cq_hdl
234  *	IBT_ERROR_LOCAL_CATASTROPHIC		none
235  *	IBT_ERROR_PORT_DOWN			ev_port
236  *	IBT_EVENT_PORT_UP			ev_port
237  *	IBT_EVENT_LIMIT_REACHED_SRQ		ev_srq_hdl
238  *	IBT_EVENT_EMPTY_QP			ev_qp_hdl
239  *	IBT_ERROR_CATASTROPHIC_SRQ		ev_srq_hdl
240  */
241 typedef struct ibc_async_event_s {
242 	uint64_t	ev_fma_ena;	/* fault management error data */
243 	ibtl_qp_hdl_t	ev_qp_hdl;	/* IBTF QP handle. */
244 	ibtl_eec_hdl_t	ev_eec_hdl;	/* IBTF EEC handle. */
245 	ibt_cq_hdl_t	ev_cq_hdl;	/* IBT CQ handle. */
246 	uint8_t		ev_port;	/* Valid for PORT UP/DOWN events */
247 	ibt_srq_hdl_t	ev_srq_hdl;	/* SRQ handle */
248 } ibc_async_event_t;
249 
250 
251 typedef struct ibc_operations_s {
252 	/* HCA */
253 	ibt_status_t (*ibc_query_hca_ports)(ibc_hca_hdl_t hca, uint8_t port,
254 	    ibt_hca_portinfo_t *info_p);
255 	ibt_status_t (*ibc_modify_ports)(ibc_hca_hdl_t hca, uint8_t port,
256 	    ibt_port_modify_flags_t flags, uint8_t init_type);
257 	ibt_status_t (*ibc_modify_system_image)(ibc_hca_hdl_t hca,
258 	    ib_guid_t sys_guid);
259 
260 	/* Protection Domain */
261 	ibt_status_t (*ibc_alloc_pd)(ibc_hca_hdl_t hca, ibt_pd_flags_t flags,
262 	    ibc_pd_hdl_t *pd_p);
263 	ibt_status_t (*ibc_free_pd)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd);
264 
265 	/* Reliable Datagram Domain */
266 	ibt_status_t (*ibc_alloc_rdd)(ibc_hca_hdl_t hca, ibc_rdd_flags_t flags,
267 	    ibc_rdd_hdl_t *rdd_p);
268 	ibt_status_t (*ibc_free_rdd)(ibc_hca_hdl_t hca, ibc_rdd_hdl_t rdd);
269 
270 	/* Address Handle */
271 	ibt_status_t (*ibc_alloc_ah)(ibc_hca_hdl_t hca, ibt_ah_flags_t flags,
272 	    ibc_pd_hdl_t pd, ibt_adds_vect_t *attr_p, ibc_ah_hdl_t *ah_p);
273 	ibt_status_t (*ibc_free_ah)(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah);
274 	ibt_status_t (*ibc_query_ah)(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah,
275 	    ibc_pd_hdl_t *pd_p, ibt_adds_vect_t *attr_p);
276 	ibt_status_t (*ibc_modify_ah)(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah,
277 	    ibt_adds_vect_t *attr_p);
278 
279 	/* Queue Pair */
280 	ibt_status_t (*ibc_alloc_qp)(ibc_hca_hdl_t hca, ibtl_qp_hdl_t ibtl_qp,
281 	    ibt_qp_type_t type, ibt_qp_alloc_attr_t *attr_p,
282 	    ibt_chan_sizes_t *queue_sizes_p, ib_qpn_t *qpn, ibc_qp_hdl_t *qp_p);
283 	ibt_status_t (*ibc_alloc_special_qp)(ibc_hca_hdl_t hca, uint8_t port,
284 	    ibtl_qp_hdl_t ibt_qp, ibt_sqp_type_t type,
285 	    ibt_qp_alloc_attr_t *attr_p, ibt_chan_sizes_t *queue_sizes_p,
286 	    ibc_qp_hdl_t *qp_p);
287 	ibt_status_t (*ibc_free_qp)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
288 	    ibc_free_qp_flags_t free_qp_flags, ibc_qpn_hdl_t *qpnh_p);
289 	ibt_status_t (*ibc_release_qpn)(ibc_hca_hdl_t hca, ibc_qpn_hdl_t qpnh);
290 	ibt_status_t (*ibc_query_qp)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
291 	    ibt_qp_query_attr_t *attr_p);
292 	ibt_status_t (*ibc_modify_qp)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
293 	    ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p,
294 	    ibt_queue_sizes_t *actual_sz);
295 
296 	/* Completion Queues */
297 	ibt_status_t (*ibc_alloc_cq)(ibc_hca_hdl_t hca, ibt_cq_hdl_t ibt_cq,
298 	    ibt_cq_attr_t *attr_p, ibc_cq_hdl_t *cq_p, uint_t *actual_size);
299 	ibt_status_t (*ibc_free_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq);
300 	ibt_status_t (*ibc_query_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq,
301 	    uint_t *entries);
302 	ibt_status_t (*ibc_resize_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq,
303 	    uint_t size, uint_t *actual_size);
304 	ibt_status_t (*ibc_alloc_cq_sched)(ibc_hca_hdl_t hca,
305 	    ibt_cq_sched_flags_t flags, ibc_cq_handler_attr_t *handler_attrs_p);
306 	ibt_status_t (*ibc_free_cq_sched)(ibc_hca_hdl_t hca,
307 	    ibt_cq_handler_id_t id);
308 
309 	/* EE Context */
310 	ibt_status_t (*ibc_alloc_eec)(ibc_hca_hdl_t hca, ibc_eec_flags_t flags,
311 	    ibtl_eec_hdl_t ibtl_eec, ibc_rdd_hdl_t rdd, ibc_eec_hdl_t *eec_p);
312 	ibt_status_t (*ibc_free_eec)(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec);
313 	ibt_status_t (*ibc_query_eec)(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec,
314 	    ibt_eec_query_attr_t *attr_p);
315 	ibt_status_t (*ibc_modify_eec)(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec,
316 	    ibt_cep_modify_flags_t flags, ibt_eec_info_t *info_p);
317 
318 	/* Memory Registration */
319 	ibt_status_t (*ibc_register_mr)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
320 	    ibt_mr_attr_t *attr_p, void *ibtl_reserved, ibc_mr_hdl_t *mr_p,
321 	    ibt_mr_desc_t *mem_desc);
322 	ibt_status_t (*ibc_register_buf)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
323 	    ibt_smr_attr_t *attrp, struct buf *buf, void *ibtl_reserved,
324 	    ibc_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc);
325 	ibt_status_t (*ibc_register_shared_mr)(ibc_hca_hdl_t hca,
326 	    ibc_mr_hdl_t mr, ibc_pd_hdl_t pd, ibt_smr_attr_t *attr_p,
327 	    void *ibtl_reserved, ibc_mr_hdl_t *mr_p, ibt_mr_desc_t *mem_desc);
328 	ibt_status_t (*ibc_deregister_mr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr);
329 	ibt_status_t (*ibc_query_mr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr,
330 	    ibt_mr_query_attr_t *info_p);
331 	ibt_status_t (*ibc_reregister_mr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr,
332 	    ibc_pd_hdl_t pd, ibt_mr_attr_t *attr_p, void *ibtl_reserved,
333 	    ibc_mr_hdl_t *mr_p, ibt_mr_desc_t *mem_desc);
334 	ibt_status_t (*ibc_reregister_buf)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr,
335 	    ibc_pd_hdl_t pd, ibt_smr_attr_t *attrp, struct buf *buf,
336 	    void *ibtl_reserved, ibc_mr_hdl_t *mr_p, ibt_mr_desc_t *mem_desc);
337 	ibt_status_t (*ibc_sync_mr)(ibc_hca_hdl_t hca,
338 	    ibt_mr_sync_t *mr_segments, size_t	num_segments);
339 
340 	/* Memory Window */
341 	ibt_status_t (*ibc_alloc_mw)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
342 	    ibt_mw_flags_t flags, ibc_mw_hdl_t *mw_p, ibt_rkey_t *rkey_p);
343 	ibt_status_t (*ibc_free_mw)(ibc_hca_hdl_t hca, ibc_mw_hdl_t mw);
344 	ibt_status_t (*ibc_query_mw)(ibc_hca_hdl_t hca, ibc_mw_hdl_t mw,
345 	    ibt_mw_query_attr_t *mw_attr_p);
346 
347 	/* Multicast Group */
348 	ibt_status_t (*ibc_attach_mcg)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
349 	    ib_gid_t gid, ib_lid_t lid);
350 	ibt_status_t (*ibc_detach_mcg)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
351 	    ib_gid_t gid, ib_lid_t lid);
352 
353 	/* WR processing */
354 	ibt_status_t (*ibc_post_send)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
355 	    ibt_send_wr_t *wr_p, uint_t num_wr, uint_t *num_posted);
356 	ibt_status_t (*ibc_post_recv)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
357 	    ibt_recv_wr_t *wr_p, uint_t num_wr, uint_t *num_posted);
358 	ibt_status_t (*ibc_poll_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq,
359 	    ibt_wc_t *wc_p, uint_t num_wc, uint_t *num_polled);
360 	ibt_status_t (*ibc_notify_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq,
361 	    ibt_cq_notify_flags_t flags);
362 
363 	/* CI Object Private Data */
364 	ibt_status_t (*ibc_ci_data_in)(ibc_hca_hdl_t hca,
365 	    ibt_ci_data_flags_t flags, ibt_object_type_t object,
366 	    void *ibc_object_handle, void *data_p, size_t data_sz);
367 	ibt_status_t (*ibc_ci_data_out)(ibc_hca_hdl_t hca,
368 	    ibt_ci_data_flags_t flags, ibt_object_type_t object,
369 	    void *ibc_object_handle, void *data_p, size_t data_sz);
370 
371 	/* Shared Receive Queues */
372 	ibt_status_t (*ibc_alloc_srq)(ibc_hca_hdl_t hca, ibt_srq_flags_t flags,
373 	    ibt_srq_hdl_t ibt_srq, ibc_pd_hdl_t pd, ibt_srq_sizes_t *sizes,
374 	    ibc_srq_hdl_t *ibc_srq_p, ibt_srq_sizes_t *real_size_p);
375 	ibt_status_t (*ibc_free_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq);
376 	ibt_status_t (*ibc_query_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq,
377 	    ibc_pd_hdl_t *pd_p, ibt_srq_sizes_t *sizes_p, uint_t *limit);
378 	ibt_status_t (*ibc_modify_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq,
379 	    ibt_srq_modify_flags_t flags, uint_t size, uint_t limit,
380 	    uint_t *real_size_p);
381 	ibt_status_t (*ibc_post_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq,
382 	    ibt_recv_wr_t *wr, uint_t num_wr, uint_t *num_posted_p);
383 
384 	/* Address translation */
385 	ibt_status_t (*ibc_map_mem_area)(ibc_hca_hdl_t hca_hdl,
386 	    ibt_va_attr_t *va_attrs, void *ibtl_reserved,
387 	    uint_t paddr_list_len, ibt_phys_buf_t *paddr_list_p,
388 	    uint_t *num_paddr_p, ibc_ma_hdl_t *ibc_ma_hdl_p);
389 	ibt_status_t (*ibc_unmap_mem_area)(ibc_hca_hdl_t hca_hdl,
390 	    ibc_ma_hdl_t ma_hdl);
391 
392 	/* Allocate L_Key */
393 	ibt_status_t (*ibc_alloc_lkey)(ibc_hca_hdl_t hca_hdl, ibc_pd_hdl_t pd,
394 	    ibt_lkey_flags_t flags, uint_t phys_buf_list_sz,
395 	    ibc_mr_hdl_t *mr_p, ibt_pmr_desc_t *mem_desc_p);
396 
397 	/* Physical Register Memory Region */
398 	ibt_status_t (*ibc_register_physical_mr)(ibc_hca_hdl_t hca,
399 	    ibc_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattr, void *ibtl_reserved,
400 	    ibc_mr_hdl_t *mr_p, ibt_pmr_desc_t *mem_desc_p);
401 	ibt_status_t (*ibc_reregister_physical_mr)(ibc_hca_hdl_t hca,
402 	    ibc_mr_hdl_t mr, ibc_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattr,
403 	    void *ibtl_reserved, ibc_mr_hdl_t *mr_p,
404 	    ibt_pmr_desc_t *mem_desc_p);
405 } ibc_operations_t;
406 
407 
408 /*
409  * The ibc_hca_info_s structure is used for HCA drivers to communicate its
410  * HCA specific information to IBTF when it attaches a device via ibc_attach().
411  *
412  * IBTF assumes that the structures pointed to by the hca_ops and hca_attr
413  * structure members are persistent.
414  */
415 
416 typedef struct ibc_hca_info_s {
417 	ibc_version_t		hca_ci_vers;	/* CI Version */
418 	dev_info_t		*hca_dip;	/* HCA dev_info */
419 	ibc_hca_hdl_t		hca_handle;	/* used for call through */
420 						/* "hca_ops" */
421 	ibc_operations_t	*hca_ops;
422 	ibt_hca_attr_t		*hca_attr;
423 	ibc_cq_handler_attr_t	hca_def_cq_handler_attr;
424 } ibc_hca_info_t;
425 
426 
427 /* Channel Interface return status */
428 typedef enum ibc_status_e {
429 	IBC_SUCCESS = 0,
430 	IBC_FAILURE = 1
431 } ibc_status_t;
432 
433 /*
434  * CI up-calls to IBTF.
435  */
436 
437 /*
438  * ibc_init
439  *	Registers CI clients with the Solaris I/O framework
440  *
441  * ibc_fini
442  *	Un-Registers CI clients with the Solaris I/O framework
443  *
444  *	modlp           - Pointer to IBC client module linkage structure
445  */
446 
447 int ibc_init(struct modlinkage *modlp);
448 void ibc_fini(struct modlinkage *modlp);
449 
450 /*
451  * ibc_attach
452  *	Register HCA device with IBTF.
453  *
454  *	ibc_hdl_p	An IBTF HCA device info handle, assigned by IBTF.
455  *			To be used by the HCA driver in all its kernel
456  *			function calls to IBTF.
457  *
458  *	info_p		Pointer to ibc_hca_info_t() struct, which contains
459  *			HCA driver's information needed by IBTF.
460  *
461  * ibc_post_attach
462  *	After a successful ibc_attach, this must be called.
463  *
464  *	ibc_hdl		The IBTF HCA device info handle that was returned
465  *			as the result of a previously successful call to
466  *			ibc_attach.
467  *
468  * ibc_pre_detach
469  *	Attempt to De-Register HCA Device from IBTF.
470  *	This requires the cooperation of IBTF clients to
471  *	stop using this HCA.  Upon success, the HCA driver
472  *	is committed to calling ibc_detach.
473  *
474  *	ibc_hdl		An IBTF HCA device info handle.
475  *			Obtained by ibc_attach().
476  *
477  *	cmd		Type of detach command - DDI_DETACH.
478  *
479  * ibc_detach
480  *	De-Register HCA Device from IBTF.
481  *	This function will succeed if ibc_pre_detach has previously
482  *	succeeded for this device.
483  *
484  *	ibc_hdl		An IBTF HCA device info handle.
485  */
486 
487 ibc_status_t ibc_attach(ibc_clnt_hdl_t *ibc_hdl_p, ibc_hca_info_t *info_p);
488 void ibc_post_attach(ibc_clnt_hdl_t ibc_hdl);
489 ibc_status_t ibc_pre_detach(ibc_clnt_hdl_t ibc_hdl, ddi_detach_cmd_t cmd);
490 void ibc_detach(ibc_clnt_hdl_t ibc_hdl);
491 
492 /*
493  * ibc_cq_handler
494  *	IBTF Completion Queue Notification Handler.
495  *
496  *	ibc_hdl		An IBTF HCA device info handle.
497  *			Obtained by ibc_attach().
498  *
499  *	ibt_cq		An IBT CQ handle, on which completion notification
500  *			has occurred. This is passed to HCA driver during
501  *			ibc_alloc_cq().
502  */
503 void ibc_cq_handler(ibc_clnt_hdl_t ibc_hdl, ibt_cq_hdl_t ibt_cq);
504 
505 /*
506  * ibc_async_handler
507  *	IBTF Asynchronous event/error handler.
508  *
509  *	ibc_hdl		An IBTF HCA device info handle.
510  *			Obtained by ibc_attach().
511  *
512  *	code		Asynchronous event code.
513  *
514  *	event_p		Pointer to ibc_async_event_t struct, to return event
515  *			information.
516  */
517 void ibc_async_handler(ibc_clnt_hdl_t ibc_hdl, ibt_async_code_t code,
518     ibc_async_event_t *event_p);
519 /*
520  * ibc_memory_handler
521  *	IBTF memory event/error handler.
522  *
523  *	ibc_hdl		An IBTF HCA device info handle.
524  *			Obtained by ibc_attach().
525  *
526  *	code		Indicates if the Event/Error is with an Memory Area or
527  *			Memory Region.
528  *
529  *	data_p		Pointer to ibt_mem_data_t struct.
530  *
531  *	ibtl_reserved	The private data associated with either the MR or MA
532  *			handle contained in the ibt_mem_data_t struct, that
533  *			was passed to the CI on a memory registration or memory
534  *			map operation.
535  */
536 void ibc_memory_handler(ibc_clnt_hdl_t ibc_hdl, ibt_mem_code_t code,
537     ibt_mem_data_t *data_p, void *ibtl_reserved);
538 
539 /*
540  * ibc_get_ci_failure()
541  *
542  *	Used to obtain a special IBTF failure code for CI specific failures,
543  *	failures other than those defined in ibt_status_t.
544  *
545  *	ena	'0' or the ENA the CI intends to use in an ereport for this
546  *		failure.
547  */
548 ibt_status_t ibc_get_ci_failure(uint64_t ena);
549 
550 #ifdef __cplusplus
551 }
552 #endif
553 
554 #endif	/* _SYS_IB_IBTL_IBCI_H */
555