1*c39526b7SPramod Gunjikar /*
2*c39526b7SPramod Gunjikar  * CDDL HEADER START
3*c39526b7SPramod Gunjikar  *
4*c39526b7SPramod Gunjikar  * The contents of this file are subject to the terms of the
5*c39526b7SPramod Gunjikar  * Common Development and Distribution License (the "License").
6*c39526b7SPramod Gunjikar  * You may not use this file except in compliance with the License.
7*c39526b7SPramod Gunjikar  *
8*c39526b7SPramod Gunjikar  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*c39526b7SPramod Gunjikar  * or http://www.opensolaris.org/os/licensing.
10*c39526b7SPramod Gunjikar  * See the License for the specific language governing permissions
11*c39526b7SPramod Gunjikar  * and limitations under the License.
12*c39526b7SPramod Gunjikar  *
13*c39526b7SPramod Gunjikar  * When distributing Covered Code, include this CDDL HEADER in each
14*c39526b7SPramod Gunjikar  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*c39526b7SPramod Gunjikar  * If applicable, add the following below this CDDL HEADER, with the
16*c39526b7SPramod Gunjikar  * fields enclosed by brackets "[]" replaced with your own identifying
17*c39526b7SPramod Gunjikar  * information: Portions Copyright [yyyy] [name of copyright owner]
18*c39526b7SPramod Gunjikar  *
19*c39526b7SPramod Gunjikar  * CDDL HEADER END
20*c39526b7SPramod Gunjikar  */
21*c39526b7SPramod Gunjikar 
22*c39526b7SPramod Gunjikar /*
23*c39526b7SPramod Gunjikar  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*c39526b7SPramod Gunjikar  */
25*c39526b7SPramod Gunjikar 
26*c39526b7SPramod Gunjikar #ifndef _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_H
27*c39526b7SPramod Gunjikar #define	_SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_H
28*c39526b7SPramod Gunjikar 
29*c39526b7SPramod Gunjikar #ifdef __cplusplus
30*c39526b7SPramod Gunjikar extern "C" {
31*c39526b7SPramod Gunjikar #endif
32*c39526b7SPramod Gunjikar 
33*c39526b7SPramod Gunjikar /*
34*c39526b7SPramod Gunjikar  *
35*c39526b7SPramod Gunjikar  * NAME: sol_uverbs.h
36*c39526b7SPramod Gunjikar  *
37*c39526b7SPramod Gunjikar  * DESC: Solaris OFED User Verbs Kernel Agent header file.
38*c39526b7SPramod Gunjikar  *
39*c39526b7SPramod Gunjikar  */
40*c39526b7SPramod Gunjikar #include <sys/ib/clients/of/ofed_kernel.h>
41*c39526b7SPramod Gunjikar #include <sys/ib/clients/of/rdma/ib_user_verbs.h>
42*c39526b7SPramod Gunjikar #include <sys/ib/clients/of/sol_uverbs/sol_uverbs_hca.h>
43*c39526b7SPramod Gunjikar #include <sys/ib/clients/of/sol_ofs/sol_ofs_common.h>
44*c39526b7SPramod Gunjikar #include <sys/ib/clients/of/sol_uverbs/sol_uverbs2ucma.h>
45*c39526b7SPramod Gunjikar 
46*c39526b7SPramod Gunjikar /*
47*c39526b7SPramod Gunjikar  * Definitions
48*c39526b7SPramod Gunjikar  */
49*c39526b7SPramod Gunjikar #define	SOL_UVERBS_DRIVER_MAX_HCA_MINOR	(16)
50*c39526b7SPramod Gunjikar #define	SOL_UVERBS_DRIVER_EVENT_MINOR	(17)
51*c39526b7SPramod Gunjikar #define	SOL_UVERBS_DRIVER_MAX_MINOR	(18)
52*c39526b7SPramod Gunjikar 
53*c39526b7SPramod Gunjikar 
54*c39526b7SPramod Gunjikar /*
55*c39526b7SPramod Gunjikar  * Structures
56*c39526b7SPramod Gunjikar  */
57*c39526b7SPramod Gunjikar 
58*c39526b7SPramod Gunjikar /*
59*c39526b7SPramod Gunjikar  * Kernel User Verbs Events.
60*c39526b7SPramod Gunjikar  *
61*c39526b7SPramod Gunjikar  * User verbs kernel events (asynchronous and completion) representation.
62*c39526b7SPramod Gunjikar  * IBT events are mapped back to OFA events.
63*c39526b7SPramod Gunjikar  */
64*c39526b7SPramod Gunjikar typedef struct uverbs_event {
65*c39526b7SPramod Gunjikar 
66*c39526b7SPramod Gunjikar 	union {
67*c39526b7SPramod Gunjikar 		struct ib_uverbs_async_event_desc	async;
68*c39526b7SPramod Gunjikar 		struct ib_uverbs_comp_event_desc	comp;
69*c39526b7SPramod Gunjikar 	} ev_desc;
70*c39526b7SPramod Gunjikar 
71*c39526b7SPramod Gunjikar 	llist_head_t	ev_list;
72*c39526b7SPramod Gunjikar 	llist_head_t	ev_obj_list;
73*c39526b7SPramod Gunjikar 	uint32_t	*ev_counter;
74*c39526b7SPramod Gunjikar } uverbs_event_t;
75*c39526b7SPramod Gunjikar 
76*c39526b7SPramod Gunjikar 
77*c39526b7SPramod Gunjikar /*
78*c39526b7SPramod Gunjikar  * Module Context.
79*c39526b7SPramod Gunjikar  *
80*c39526b7SPramod Gunjikar  * There is a single module context which maintains the list
81*c39526b7SPramod Gunjikar  * of HCA's retrieved from IBT. A user process indicates the
82*c39526b7SPramod Gunjikar  * target HCA open via the uverbs unique minor device number
83*c39526b7SPramod Gunjikar  * associated with the HCA.
84*c39526b7SPramod Gunjikar  */
85*c39526b7SPramod Gunjikar typedef struct {
86*c39526b7SPramod Gunjikar 	kmutex_t		lock;
87*c39526b7SPramod Gunjikar 	dev_info_t		*dip;
88*c39526b7SPramod Gunjikar 
89*c39526b7SPramod Gunjikar 	/*
90*c39526b7SPramod Gunjikar 	 * Underlying IBT HCA Info
91*c39526b7SPramod Gunjikar 	 */
92*c39526b7SPramod Gunjikar 
93*c39526b7SPramod Gunjikar 	ibt_clnt_modinfo_t	clnt_modinfo;
94*c39526b7SPramod Gunjikar 	ibt_clnt_hdl_t		clnt_hdl;
95*c39526b7SPramod Gunjikar 	uint32_t		hca_count;
96*c39526b7SPramod Gunjikar 	ib_guid_t		*hca_guid_list;
97*c39526b7SPramod Gunjikar 	sol_uverbs_hca_t	*hcas;
98*c39526b7SPramod Gunjikar 
99*c39526b7SPramod Gunjikar 	/*
100*c39526b7SPramod Gunjikar 	 * Support user asyncrhonous and completion event delivery via
101*c39526b7SPramod Gunjikar 	 * user event filesystem.
102*c39526b7SPramod Gunjikar 	 */
103*c39526b7SPramod Gunjikar 	dev_t			dev;
104*c39526b7SPramod Gunjikar } uverbs_module_context_t;
105*c39526b7SPramod Gunjikar 
106*c39526b7SPramod Gunjikar /*
107*c39526b7SPramod Gunjikar  * User Event File.
108*c39526b7SPramod Gunjikar  *
109*c39526b7SPramod Gunjikar  * Used for delivery of asynchronous and synchronous events to the user.
110*c39526b7SPramod Gunjikar  * An asynchronous event file is created during the allocation of
111*c39526b7SPramod Gunjikar  * a user verbs consumer context, a completion event file is created
112*c39526b7SPramod Gunjikar  * when the user verbs consumer creates a completion channel.
113*c39526b7SPramod Gunjikar  */
114*c39526b7SPramod Gunjikar typedef struct uverbs_ufile_uobj {
115*c39526b7SPramod Gunjikar 	sol_ofs_uobj_t			uobj;
116*c39526b7SPramod Gunjikar 	kmutex_t			lock;
117*c39526b7SPramod Gunjikar 	int				ref;
118*c39526b7SPramod Gunjikar 	kcondvar_t			poll_wait;
119*c39526b7SPramod Gunjikar 	struct pollhead			poll_head;
120*c39526b7SPramod Gunjikar 	struct uverbs_uctxt_uobj	*uctxt;
121*c39526b7SPramod Gunjikar 	int				is_async;
122*c39526b7SPramod Gunjikar 	llist_head_t			event_list;
123*c39526b7SPramod Gunjikar 	sol_uverbs_cq_ctrl_t		ufile_notify_enabled;
124*c39526b7SPramod Gunjikar 	uint32_t			ufile_cq_cnt;
125*c39526b7SPramod Gunjikar } uverbs_ufile_uobj_t;
126*c39526b7SPramod Gunjikar 
127*c39526b7SPramod Gunjikar /*
128*c39526b7SPramod Gunjikar  * Type of user context -
129*c39526b7SPramod Gunjikar  */
130*c39526b7SPramod Gunjikar #define		SOL_UVERBS_UCTXT_VERBS		0x001
131*c39526b7SPramod Gunjikar #define		SOL_UVERBS_UCTXT_EVENT		0x100
132*c39526b7SPramod Gunjikar #define		SOL_UVERBS_UCTXT_ASYNC		0x101
133*c39526b7SPramod Gunjikar #define		SOL_UVERBS_UCTXT_COMPL		0x110
134*c39526b7SPramod Gunjikar 
135*c39526b7SPramod Gunjikar /*
136*c39526b7SPramod Gunjikar  * User Context.
137*c39526b7SPramod Gunjikar  *
138*c39526b7SPramod Gunjikar  * A user context is created when a user process opens a specific minor
139*c39526b7SPramod Gunjikar  * device.  The context maintains a list of resources created by this
140*c39526b7SPramod Gunjikar  * user that allows the resources to be cleaned up on user close.
141*c39526b7SPramod Gunjikar  */
142*c39526b7SPramod Gunjikar typedef struct uverbs_uctxt_uobj {
143*c39526b7SPramod Gunjikar 	sol_ofs_uobj_t		uobj;
144*c39526b7SPramod Gunjikar 	kmutex_t		lock;
145*c39526b7SPramod Gunjikar 	uverbs_module_context_t	*mod_ctxt;
146*c39526b7SPramod Gunjikar 	sol_uverbs_hca_t	*hca;		/* short cut to specific hca */
147*c39526b7SPramod Gunjikar 
148*c39526b7SPramod Gunjikar 	/*
149*c39526b7SPramod Gunjikar 	 * List of user resource objects created by this context.  The
150*c39526b7SPramod Gunjikar 	 * objects themselves live in the associated object table, and
151*c39526b7SPramod Gunjikar 	 * the code should use the table to access and use resources.
152*c39526b7SPramod Gunjikar 	 * Any objects that remain in these list will be destroyed at
153*c39526b7SPramod Gunjikar 	 * user close to free the associated resources.
154*c39526b7SPramod Gunjikar 	 *
155*c39526b7SPramod Gunjikar 	 * The user context "lock" should be held when invoking
156*c39526b7SPramod Gunjikar 	 * routines to manipulate the lists.
157*c39526b7SPramod Gunjikar 	 */
158*c39526b7SPramod Gunjikar 	genlist_t		pd_list;
159*c39526b7SPramod Gunjikar 	genlist_t		mr_list;
160*c39526b7SPramod Gunjikar 	genlist_t		cq_list;
161*c39526b7SPramod Gunjikar 	genlist_t		qp_list;
162*c39526b7SPramod Gunjikar 	genlist_t		srq_list;
163*c39526b7SPramod Gunjikar 	genlist_t		ah_list;
164*c39526b7SPramod Gunjikar 
165*c39526b7SPramod Gunjikar 	/*
166*c39526b7SPramod Gunjikar 	 * Event filesystem interfaces for IB asyncrhonous events
167*c39526b7SPramod Gunjikar 	 * and completion events.
168*c39526b7SPramod Gunjikar 	 */
169*c39526b7SPramod Gunjikar 	uverbs_ufile_uobj_t    *comp_evfile;
170*c39526b7SPramod Gunjikar 	uverbs_ufile_uobj_t    *async_evfile;
171*c39526b7SPramod Gunjikar 
172*c39526b7SPramod Gunjikar 	/*
173*c39526b7SPramod Gunjikar 	 * User context can be created for :
174*c39526b7SPramod Gunjikar 	 *	1. All Verbs API
175*c39526b7SPramod Gunjikar 	 *	2. For getting a file for async events.
176*c39526b7SPramod Gunjikar 	 *	3. For getting a file for completion events.
177*c39526b7SPramod Gunjikar 	 * For (1) - pointers to (2) & (3) will be updated. For (2) and (3)
178*c39526b7SPramod Gunjikar 	 * pointer to (1) will be maintained.
179*c39526b7SPramod Gunjikar 	 */
180*c39526b7SPramod Gunjikar 	uint16_t		uctxt_type;
181*c39526b7SPramod Gunjikar 	uint32_t		uctxt_verbs_id;
182*c39526b7SPramod Gunjikar 	uint32_t		uctxt_async_id;
183*c39526b7SPramod Gunjikar 	uint32_t		uctxt_comp_id;
184*c39526b7SPramod Gunjikar 	uint8_t			uctxt_free_pending;
185*c39526b7SPramod Gunjikar } uverbs_uctxt_uobj_t;
186*c39526b7SPramod Gunjikar 
187*c39526b7SPramod Gunjikar /*
188*c39526b7SPramod Gunjikar  * User PD objects created at PD allocation
189*c39526b7SPramod Gunjikar  */
190*c39526b7SPramod Gunjikar typedef struct uverbs_upd_uobj {
191*c39526b7SPramod Gunjikar 	sol_ofs_uobj_t		uobj;
192*c39526b7SPramod Gunjikar 	ibt_pd_hdl_t		pd;
193*c39526b7SPramod Gunjikar 	genlist_entry_t		*list_entry;	/* per user ctx list entry */
194*c39526b7SPramod Gunjikar 	uint32_t		active_qp_cnt;
195*c39526b7SPramod Gunjikar 	uint8_t			free_pending;
196*c39526b7SPramod Gunjikar } uverbs_upd_uobj_t;
197*c39526b7SPramod Gunjikar 
198*c39526b7SPramod Gunjikar /*
199*c39526b7SPramod Gunjikar  * User MR objects created at MR registration
200*c39526b7SPramod Gunjikar  */
201*c39526b7SPramod Gunjikar typedef struct uverbs_umr_uobj {
202*c39526b7SPramod Gunjikar 	sol_ofs_uobj_t	uobj;
203*c39526b7SPramod Gunjikar 	ibt_mr_hdl_t	mr;
204*c39526b7SPramod Gunjikar 	genlist_entry_t	*list_entry;	/* per user ctx list entry */
205*c39526b7SPramod Gunjikar } uverbs_umr_uobj_t;
206*c39526b7SPramod Gunjikar 
207*c39526b7SPramod Gunjikar /*
208*c39526b7SPramod Gunjikar  * User CQ objects created at CQ allocation
209*c39526b7SPramod Gunjikar  */
210*c39526b7SPramod Gunjikar typedef struct uverbs_ucq_uobj {
211*c39526b7SPramod Gunjikar 	sol_ofs_uobj_t		uobj;
212*c39526b7SPramod Gunjikar 	ibt_cq_hdl_t		cq;
213*c39526b7SPramod Gunjikar 	genlist_entry_t		*list_entry;	/* per user ctx list entry */
214*c39526b7SPramod Gunjikar 	uverbs_uctxt_uobj_t	*uctxt;
215*c39526b7SPramod Gunjikar 	uverbs_ufile_uobj_t	*comp_chan;
216*c39526b7SPramod Gunjikar 	uint32_t		comp_events_reported;
217*c39526b7SPramod Gunjikar 	uint32_t		async_events_reported;
218*c39526b7SPramod Gunjikar 	llist_head_t		async_list;
219*c39526b7SPramod Gunjikar 	llist_head_t		comp_list;
220*c39526b7SPramod Gunjikar 	uint32_t		active_qp_cnt;
221*c39526b7SPramod Gunjikar 	uint8_t			free_pending;
222*c39526b7SPramod Gunjikar } uverbs_ucq_uobj_t;
223*c39526b7SPramod Gunjikar 
224*c39526b7SPramod Gunjikar /*
225*c39526b7SPramod Gunjikar  * User Shared Receive CQ objects created at SRQ allocation
226*c39526b7SPramod Gunjikar  */
227*c39526b7SPramod Gunjikar typedef struct uverbs_usrq_uobj {
228*c39526b7SPramod Gunjikar 	sol_ofs_uobj_t		uobj;
229*c39526b7SPramod Gunjikar 	ibt_srq_hdl_t		srq;
230*c39526b7SPramod Gunjikar 	genlist_entry_t		*list_entry;	/* per user ctx list entry */
231*c39526b7SPramod Gunjikar 	uverbs_uctxt_uobj_t	*uctxt;
232*c39526b7SPramod Gunjikar 	uint32_t		async_events_reported;
233*c39526b7SPramod Gunjikar 	llist_head_t		async_list;
234*c39526b7SPramod Gunjikar 	uint32_t		active_qp_cnt;
235*c39526b7SPramod Gunjikar 	uint8_t			free_pending;
236*c39526b7SPramod Gunjikar } uverbs_usrq_uobj_t;
237*c39526b7SPramod Gunjikar 
238*c39526b7SPramod Gunjikar /*
239*c39526b7SPramod Gunjikar  * User address handle objects created at AH allocation
240*c39526b7SPramod Gunjikar  */
241*c39526b7SPramod Gunjikar typedef struct uverbs_uah_uobj {
242*c39526b7SPramod Gunjikar 	sol_ofs_uobj_t	uobj;
243*c39526b7SPramod Gunjikar 	ibt_ah_hdl_t	ah;
244*c39526b7SPramod Gunjikar 	genlist_entry_t	*list_entry;	/* per user ctx list entry */
245*c39526b7SPramod Gunjikar } uverbs_uah_uobj_t;
246*c39526b7SPramod Gunjikar 
247*c39526b7SPramod Gunjikar /*
248*c39526b7SPramod Gunjikar  * User QP objects created at QP allocation
249*c39526b7SPramod Gunjikar  */
250*c39526b7SPramod Gunjikar #define	SOL_UVERBS_UQP_RCQ_VALID	0x01
251*c39526b7SPramod Gunjikar #define	SOL_UVERBS_UQP_SRQ_VALID	0x02
252*c39526b7SPramod Gunjikar 
253*c39526b7SPramod Gunjikar typedef struct uverbs_uqp_uobj {
254*c39526b7SPramod Gunjikar 	sol_ofs_uobj_t			uobj;
255*c39526b7SPramod Gunjikar 	ibt_qp_hdl_t			qp;
256*c39526b7SPramod Gunjikar 	genlist_entry_t			*list_entry;	/* per uctx list */
257*c39526b7SPramod Gunjikar 	uint32_t			max_inline_data;
258*c39526b7SPramod Gunjikar 	uverbs_uctxt_uobj_t		*uctxt;
259*c39526b7SPramod Gunjikar 	uint32_t			qp_num;		/* 24 bits valid */
260*c39526b7SPramod Gunjikar 	uint32_t			disable_qp_mod;
261*c39526b7SPramod Gunjikar 	enum ib_qp_type			ofa_qp_type;
262*c39526b7SPramod Gunjikar 	llist_head_t			mcast_list;
263*c39526b7SPramod Gunjikar 	llist_head_t			async_list;
264*c39526b7SPramod Gunjikar 	uint32_t			async_events_reported;
265*c39526b7SPramod Gunjikar 	uverbs_ucq_uobj_t		*uqp_rcq;
266*c39526b7SPramod Gunjikar 	uverbs_ucq_uobj_t		*uqp_scq;
267*c39526b7SPramod Gunjikar 
268*c39526b7SPramod Gunjikar 	uint32_t			uqp_pd_hdl;
269*c39526b7SPramod Gunjikar 	uint32_t			uqp_scq_hdl;
270*c39526b7SPramod Gunjikar 	uint32_t			uqp_rcq_hdl;
271*c39526b7SPramod Gunjikar 	uint32_t			uqp_srq_hdl;
272*c39526b7SPramod Gunjikar 	uint8_t				uqp_rcq_srq_valid;
273*c39526b7SPramod Gunjikar 
274*c39526b7SPramod Gunjikar 	sol_uverbs_qp_free_state_t	uqp_free_state;
275*c39526b7SPramod Gunjikar } uverbs_uqp_uobj_t;
276*c39526b7SPramod Gunjikar 
277*c39526b7SPramod Gunjikar extern sol_ofs_uobj_table_t uverbs_uctxt_uo_tbl;
278*c39526b7SPramod Gunjikar extern sol_ofs_uobj_table_t uverbs_upd_uo_tbl;
279*c39526b7SPramod Gunjikar extern sol_ofs_uobj_table_t uverbs_uah_uo_tbl;
280*c39526b7SPramod Gunjikar extern sol_ofs_uobj_table_t uverbs_umr_uo_tbl;
281*c39526b7SPramod Gunjikar extern sol_ofs_uobj_table_t uverbs_ucq_uo_tbl;
282*c39526b7SPramod Gunjikar extern sol_ofs_uobj_table_t uverbs_usrq_uo_tbl;
283*c39526b7SPramod Gunjikar extern sol_ofs_uobj_table_t uverbs_uqp_uo_tbl;
284*c39526b7SPramod Gunjikar extern sol_ofs_uobj_table_t uverbs_ufile_uo_tbl;
285*c39526b7SPramod Gunjikar 
286*c39526b7SPramod Gunjikar /*
287*c39526b7SPramod Gunjikar  * The following structure is used currently to pass data back to
288*c39526b7SPramod Gunjikar  * libmthca on user allocation context.  This should be passed opaquely
289*c39526b7SPramod Gunjikar  * to maintain a true hal, we'll look for a generic way to get this information
290*c39526b7SPramod Gunjikar  * and deliver it opaquely post EA-1.
291*c39526b7SPramod Gunjikar  */
292*c39526b7SPramod Gunjikar struct mthca_alloc_ucontext_resp {
293*c39526b7SPramod Gunjikar 	uint32_t	qp_tab_size;
294*c39526b7SPramod Gunjikar 	uint32_t	uarc_size;
295*c39526b7SPramod Gunjikar };
296*c39526b7SPramod Gunjikar 
297*c39526b7SPramod Gunjikar struct ib_udata {
298*c39526b7SPramod Gunjikar 	void	*inbuf;
299*c39526b7SPramod Gunjikar 	void	*outbuf;
300*c39526b7SPramod Gunjikar 	size_t	inlen;
301*c39526b7SPramod Gunjikar 	size_t	outlen;
302*c39526b7SPramod Gunjikar };
303*c39526b7SPramod Gunjikar 
304*c39526b7SPramod Gunjikar int sol_uverbs_dummy_command(uverbs_uctxt_uobj_t *uctxt, char *buf,
305*c39526b7SPramod Gunjikar     int in_len, int out_len);
306*c39526b7SPramod Gunjikar int sol_uverbs_get_context(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
307*c39526b7SPramod Gunjikar     int out_len);
308*c39526b7SPramod Gunjikar int sol_uverbs_alloc_pd(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
309*c39526b7SPramod Gunjikar     int out_len);
310*c39526b7SPramod Gunjikar int sol_uverbs_dealloc_pd(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
311*c39526b7SPramod Gunjikar     int out_len);
312*c39526b7SPramod Gunjikar int sol_uverbs_create_ah(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
313*c39526b7SPramod Gunjikar     int out_len);
314*c39526b7SPramod Gunjikar int sol_uverbs_destroy_ah(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
315*c39526b7SPramod Gunjikar     int out_len);
316*c39526b7SPramod Gunjikar int sol_uverbs_query_device(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
317*c39526b7SPramod Gunjikar     int out_len);
318*c39526b7SPramod Gunjikar int sol_uverbs_query_port(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
319*c39526b7SPramod Gunjikar     int out_len);
320*c39526b7SPramod Gunjikar int sol_uverbs_query_gid(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
321*c39526b7SPramod Gunjikar     int out_len);
322*c39526b7SPramod Gunjikar int sol_uverbs_query_pkey(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
323*c39526b7SPramod Gunjikar     int out_len);
324*c39526b7SPramod Gunjikar int sol_uverbs_reg_mr(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
325*c39526b7SPramod Gunjikar     int out_len);
326*c39526b7SPramod Gunjikar int sol_uverbs_dereg_mr(uverbs_uctxt_uobj_t *uctxt, char *buf, int in_len,
327*c39526b7SPramod Gunjikar     int out_len);
328*c39526b7SPramod Gunjikar int sol_uverbs_create_comp_channel(uverbs_uctxt_uobj_t *uctxt, char *buf,
329*c39526b7SPramod Gunjikar     int in_len, int out_len);
330*c39526b7SPramod Gunjikar 
331*c39526b7SPramod Gunjikar uint32_t
332*c39526b7SPramod Gunjikar sol_uverbs_ibt_to_of_device_cap_flags(ibt_hca_flags_t flags,
333*c39526b7SPramod Gunjikar     ibt_hca_flags2_t flags2);
334*c39526b7SPramod Gunjikar 
335*c39526b7SPramod Gunjikar uint64_t
336*c39526b7SPramod Gunjikar sol_uverbs_ibt_to_of_page_sz(ibt_page_sizes_t page_szs);
337*c39526b7SPramod Gunjikar 
338*c39526b7SPramod Gunjikar int sol_uverbs_ibt_to_kernel_status(ibt_status_t  status);
339*c39526b7SPramod Gunjikar uint32_t sol_uverbs_qpnum2uqpid(uint32_t qp_num);
340*c39526b7SPramod Gunjikar 
341*c39526b7SPramod Gunjikar int uverbs_upd_free(uverbs_upd_uobj_t *, uverbs_uctxt_uobj_t *);
342*c39526b7SPramod Gunjikar int uverbs_uqp_free(uverbs_uqp_uobj_t *, uverbs_uctxt_uobj_t *);
343*c39526b7SPramod Gunjikar int uverbs_usrq_free(uverbs_usrq_uobj_t *, uverbs_uctxt_uobj_t *);
344*c39526b7SPramod Gunjikar int uverbs_ucq_free(uverbs_ucq_uobj_t *, uverbs_uctxt_uobj_t *);
345*c39526b7SPramod Gunjikar 
346*c39526b7SPramod Gunjikar /*
347*c39526b7SPramod Gunjikar  * The following helpers simply provide easy access for acquiring and locking
348*c39526b7SPramod Gunjikar  * User Objects.
349*c39526b7SPramod Gunjikar  */
350*c39526b7SPramod Gunjikar static inline uverbs_uctxt_uobj_t *
uverbs_uobj_get_uctxt_read(uint32_t id)351*c39526b7SPramod Gunjikar uverbs_uobj_get_uctxt_read(uint32_t id)
352*c39526b7SPramod Gunjikar {
353*c39526b7SPramod Gunjikar 	return (uverbs_uctxt_uobj_t *)
354*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_read(&uverbs_uctxt_uo_tbl, id);
355*c39526b7SPramod Gunjikar }
356*c39526b7SPramod Gunjikar static inline uverbs_uctxt_uobj_t *
uverbs_uobj_get_uctxt_write(uint32_t id)357*c39526b7SPramod Gunjikar uverbs_uobj_get_uctxt_write(uint32_t id)
358*c39526b7SPramod Gunjikar {
359*c39526b7SPramod Gunjikar 	return (uverbs_uctxt_uobj_t *)
360*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_write(&uverbs_uctxt_uo_tbl, id);
361*c39526b7SPramod Gunjikar }
362*c39526b7SPramod Gunjikar static inline uverbs_upd_uobj_t *
uverbs_uobj_get_upd_read(uint32_t id)363*c39526b7SPramod Gunjikar uverbs_uobj_get_upd_read(uint32_t id)
364*c39526b7SPramod Gunjikar {
365*c39526b7SPramod Gunjikar 	return (uverbs_upd_uobj_t *)
366*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_read(&uverbs_upd_uo_tbl, id);
367*c39526b7SPramod Gunjikar }
368*c39526b7SPramod Gunjikar static inline uverbs_upd_uobj_t *
uverbs_uobj_get_upd_write(uint32_t id)369*c39526b7SPramod Gunjikar uverbs_uobj_get_upd_write(uint32_t id)
370*c39526b7SPramod Gunjikar {
371*c39526b7SPramod Gunjikar 	return (uverbs_upd_uobj_t *)
372*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_write(&uverbs_upd_uo_tbl, id);
373*c39526b7SPramod Gunjikar }
374*c39526b7SPramod Gunjikar static inline uverbs_umr_uobj_t *
uverbs_uobj_get_umr_read(uint32_t id)375*c39526b7SPramod Gunjikar uverbs_uobj_get_umr_read(uint32_t id)
376*c39526b7SPramod Gunjikar {
377*c39526b7SPramod Gunjikar 	return (uverbs_umr_uobj_t *)
378*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_read(&uverbs_umr_uo_tbl, id);
379*c39526b7SPramod Gunjikar }
380*c39526b7SPramod Gunjikar static inline uverbs_umr_uobj_t *
uverbs_uobj_get_umr_write(uint32_t id)381*c39526b7SPramod Gunjikar uverbs_uobj_get_umr_write(uint32_t id)
382*c39526b7SPramod Gunjikar {
383*c39526b7SPramod Gunjikar 	return (uverbs_umr_uobj_t *)
384*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_write(&uverbs_umr_uo_tbl, id);
385*c39526b7SPramod Gunjikar }
386*c39526b7SPramod Gunjikar static inline uverbs_ucq_uobj_t *
uverbs_uobj_get_ucq_read(uint32_t id)387*c39526b7SPramod Gunjikar uverbs_uobj_get_ucq_read(uint32_t id)
388*c39526b7SPramod Gunjikar {
389*c39526b7SPramod Gunjikar 	return (uverbs_ucq_uobj_t *)
390*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_read(&uverbs_ucq_uo_tbl, id);
391*c39526b7SPramod Gunjikar }
392*c39526b7SPramod Gunjikar static inline uverbs_ucq_uobj_t *
uverbs_uobj_get_ucq_write(uint32_t id)393*c39526b7SPramod Gunjikar uverbs_uobj_get_ucq_write(uint32_t id)
394*c39526b7SPramod Gunjikar {
395*c39526b7SPramod Gunjikar 	return (uverbs_ucq_uobj_t *)
396*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_write(&uverbs_ucq_uo_tbl, (int)id);
397*c39526b7SPramod Gunjikar }
398*c39526b7SPramod Gunjikar static inline uverbs_usrq_uobj_t *
uverbs_uobj_get_usrq_read(uint32_t id)399*c39526b7SPramod Gunjikar uverbs_uobj_get_usrq_read(uint32_t id)
400*c39526b7SPramod Gunjikar {
401*c39526b7SPramod Gunjikar 	return (uverbs_usrq_uobj_t *)
402*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_read(&uverbs_usrq_uo_tbl, id);
403*c39526b7SPramod Gunjikar }
404*c39526b7SPramod Gunjikar static inline uverbs_usrq_uobj_t *
uverbs_uobj_get_usrq_write(uint32_t id)405*c39526b7SPramod Gunjikar uverbs_uobj_get_usrq_write(uint32_t id)
406*c39526b7SPramod Gunjikar {
407*c39526b7SPramod Gunjikar 	return (uverbs_usrq_uobj_t *)
408*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_write(&uverbs_usrq_uo_tbl, id);
409*c39526b7SPramod Gunjikar }
410*c39526b7SPramod Gunjikar static inline uverbs_uah_uobj_t *
uverbs_uobj_get_uah_read(uint32_t id)411*c39526b7SPramod Gunjikar uverbs_uobj_get_uah_read(uint32_t id)
412*c39526b7SPramod Gunjikar {
413*c39526b7SPramod Gunjikar 	return (uverbs_uah_uobj_t *)
414*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_read(&uverbs_uah_uo_tbl, id);
415*c39526b7SPramod Gunjikar }
416*c39526b7SPramod Gunjikar static inline uverbs_uah_uobj_t *
uverbs_uobj_get_uah_write(uint32_t id)417*c39526b7SPramod Gunjikar uverbs_uobj_get_uah_write(uint32_t id)
418*c39526b7SPramod Gunjikar {
419*c39526b7SPramod Gunjikar 	return (uverbs_uah_uobj_t *)
420*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_write(&uverbs_uah_uo_tbl, id);
421*c39526b7SPramod Gunjikar }
422*c39526b7SPramod Gunjikar static inline uverbs_uqp_uobj_t *
uverbs_uobj_get_uqp_read(uint32_t id)423*c39526b7SPramod Gunjikar uverbs_uobj_get_uqp_read(uint32_t id)
424*c39526b7SPramod Gunjikar {
425*c39526b7SPramod Gunjikar 	return (uverbs_uqp_uobj_t *)
426*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_read(&uverbs_uqp_uo_tbl, id);
427*c39526b7SPramod Gunjikar }
428*c39526b7SPramod Gunjikar static inline uverbs_uqp_uobj_t *
uverbs_uobj_get_uqp_write(uint32_t id)429*c39526b7SPramod Gunjikar uverbs_uobj_get_uqp_write(uint32_t id)
430*c39526b7SPramod Gunjikar {
431*c39526b7SPramod Gunjikar 	return (uverbs_uqp_uobj_t *)
432*c39526b7SPramod Gunjikar 	    sol_ofs_uobj_get_write(&uverbs_uqp_uo_tbl, id);
433*c39526b7SPramod Gunjikar }
434*c39526b7SPramod Gunjikar 
435*c39526b7SPramod Gunjikar #ifdef __cplusplus
436*c39526b7SPramod Gunjikar }
437*c39526b7SPramod Gunjikar #endif
438*c39526b7SPramod Gunjikar #endif /* _SYS_IB_CLIENTS_OF_SOL_UVERBS_SOL_UVERBS_H */
439