1 /*
2  * Copyright (c) 2018, Mellanox Technologies inc.  All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #ifndef IB_USER_IOCTL_CMDS_H
34 #define IB_USER_IOCTL_CMDS_H
35 
36 #define UVERBS_ID_NS_MASK 0xF000
37 #define UVERBS_ID_NS_SHIFT 12
38 
39 #define UVERBS_UDATA_DRIVER_DATA_NS	1
40 #define UVERBS_UDATA_DRIVER_DATA_FLAG	(1UL << UVERBS_ID_NS_SHIFT)
41 
42 enum uverbs_default_objects {
43 	UVERBS_OBJECT_DEVICE, /* No instances of DEVICE are allowed */
44 	UVERBS_OBJECT_PD,
45 	UVERBS_OBJECT_COMP_CHANNEL,
46 	UVERBS_OBJECT_CQ,
47 	UVERBS_OBJECT_QP,
48 	UVERBS_OBJECT_SRQ,
49 	UVERBS_OBJECT_AH,
50 	UVERBS_OBJECT_MR,
51 	UVERBS_OBJECT_MW,
52 	UVERBS_OBJECT_FLOW,
53 	UVERBS_OBJECT_XRCD,
54 	UVERBS_OBJECT_RWQ_IND_TBL,
55 	UVERBS_OBJECT_WQ,
56 	UVERBS_OBJECT_FLOW_ACTION,
57 	UVERBS_OBJECT_DM,
58 	UVERBS_OBJECT_COUNTERS,
59 	UVERBS_OBJECT_ASYNC_EVENT,
60 };
61 
62 enum {
63 	UVERBS_ATTR_UHW_IN = UVERBS_UDATA_DRIVER_DATA_FLAG,
64 	UVERBS_ATTR_UHW_OUT,
65 };
66 
67 enum uverbs_methods_device {
68 	UVERBS_METHOD_INVOKE_WRITE,
69 	UVERBS_METHOD_INFO_HANDLES,
70 	UVERBS_METHOD_QUERY_PORT,
71 	UVERBS_METHOD_GET_CONTEXT,
72 	UVERBS_METHOD_QUERY_CONTEXT,
73 };
74 
75 enum uverbs_attrs_invoke_write_cmd_attr_ids {
76 	UVERBS_ATTR_CORE_IN,
77 	UVERBS_ATTR_CORE_OUT,
78 	UVERBS_ATTR_WRITE_CMD,
79 };
80 
81 enum uverbs_attrs_query_port_cmd_attr_ids {
82 	UVERBS_ATTR_QUERY_PORT_PORT_NUM,
83 	UVERBS_ATTR_QUERY_PORT_RESP,
84 };
85 
86 enum uverbs_attrs_get_context_attr_ids {
87 	UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
88 	UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT,
89 };
90 
91 enum uverbs_attrs_query_context_attr_ids {
92 	UVERBS_ATTR_QUERY_CONTEXT_NUM_COMP_VECTORS,
93 	UVERBS_ATTR_QUERY_CONTEXT_CORE_SUPPORT,
94 };
95 
96 enum uverbs_attrs_create_cq_cmd_attr_ids {
97 	UVERBS_ATTR_CREATE_CQ_HANDLE,
98 	UVERBS_ATTR_CREATE_CQ_CQE,
99 	UVERBS_ATTR_CREATE_CQ_USER_HANDLE,
100 	UVERBS_ATTR_CREATE_CQ_COMP_CHANNEL,
101 	UVERBS_ATTR_CREATE_CQ_COMP_VECTOR,
102 	UVERBS_ATTR_CREATE_CQ_FLAGS,
103 	UVERBS_ATTR_CREATE_CQ_RESP_CQE,
104 	UVERBS_ATTR_CREATE_CQ_EVENT_FD,
105 };
106 
107 enum uverbs_attrs_destroy_cq_cmd_attr_ids {
108 	UVERBS_ATTR_DESTROY_CQ_HANDLE,
109 	UVERBS_ATTR_DESTROY_CQ_RESP,
110 };
111 
112 enum uverbs_attrs_create_flow_action_esp {
113 	UVERBS_ATTR_CREATE_FLOW_ACTION_ESP_HANDLE,
114 	UVERBS_ATTR_FLOW_ACTION_ESP_ATTRS,
115 	UVERBS_ATTR_FLOW_ACTION_ESP_ESN,
116 	UVERBS_ATTR_FLOW_ACTION_ESP_KEYMAT,
117 	UVERBS_ATTR_FLOW_ACTION_ESP_REPLAY,
118 	UVERBS_ATTR_FLOW_ACTION_ESP_ENCAP,
119 };
120 
121 enum uverbs_attrs_modify_flow_action_esp {
122 	UVERBS_ATTR_MODIFY_FLOW_ACTION_ESP_HANDLE =
123 		UVERBS_ATTR_CREATE_FLOW_ACTION_ESP_HANDLE,
124 };
125 
126 enum uverbs_attrs_destroy_flow_action_esp {
127 	UVERBS_ATTR_DESTROY_FLOW_ACTION_HANDLE,
128 };
129 
130 enum uverbs_attrs_create_qp_cmd_attr_ids {
131 	UVERBS_ATTR_CREATE_QP_HANDLE,
132 	UVERBS_ATTR_CREATE_QP_XRCD_HANDLE,
133 	UVERBS_ATTR_CREATE_QP_PD_HANDLE,
134 	UVERBS_ATTR_CREATE_QP_SRQ_HANDLE,
135 	UVERBS_ATTR_CREATE_QP_SEND_CQ_HANDLE,
136 	UVERBS_ATTR_CREATE_QP_RECV_CQ_HANDLE,
137 	UVERBS_ATTR_CREATE_QP_IND_TABLE_HANDLE,
138 	UVERBS_ATTR_CREATE_QP_USER_HANDLE,
139 	UVERBS_ATTR_CREATE_QP_CAP,
140 	UVERBS_ATTR_CREATE_QP_TYPE,
141 	UVERBS_ATTR_CREATE_QP_FLAGS,
142 	UVERBS_ATTR_CREATE_QP_SOURCE_QPN,
143 	UVERBS_ATTR_CREATE_QP_EVENT_FD,
144 	UVERBS_ATTR_CREATE_QP_RESP_CAP,
145 	UVERBS_ATTR_CREATE_QP_RESP_QP_NUM,
146 };
147 
148 enum uverbs_attrs_destroy_qp_cmd_attr_ids {
149 	UVERBS_ATTR_DESTROY_QP_HANDLE,
150 	UVERBS_ATTR_DESTROY_QP_RESP,
151 };
152 
153 enum uverbs_methods_qp {
154 	UVERBS_METHOD_QP_CREATE,
155 	UVERBS_METHOD_QP_DESTROY,
156 };
157 
158 enum uverbs_attrs_create_srq_cmd_attr_ids {
159 	UVERBS_ATTR_CREATE_SRQ_HANDLE,
160 	UVERBS_ATTR_CREATE_SRQ_PD_HANDLE,
161 	UVERBS_ATTR_CREATE_SRQ_XRCD_HANDLE,
162 	UVERBS_ATTR_CREATE_SRQ_CQ_HANDLE,
163 	UVERBS_ATTR_CREATE_SRQ_USER_HANDLE,
164 	UVERBS_ATTR_CREATE_SRQ_MAX_WR,
165 	UVERBS_ATTR_CREATE_SRQ_MAX_SGE,
166 	UVERBS_ATTR_CREATE_SRQ_LIMIT,
167 	UVERBS_ATTR_CREATE_SRQ_MAX_NUM_TAGS,
168 	UVERBS_ATTR_CREATE_SRQ_TYPE,
169 	UVERBS_ATTR_CREATE_SRQ_EVENT_FD,
170 	UVERBS_ATTR_CREATE_SRQ_RESP_MAX_WR,
171 	UVERBS_ATTR_CREATE_SRQ_RESP_MAX_SGE,
172 	UVERBS_ATTR_CREATE_SRQ_RESP_SRQ_NUM,
173 };
174 
175 enum uverbs_attrs_destroy_srq_cmd_attr_ids {
176 	UVERBS_ATTR_DESTROY_SRQ_HANDLE,
177 	UVERBS_ATTR_DESTROY_SRQ_RESP,
178 };
179 
180 enum uverbs_methods_srq {
181 	UVERBS_METHOD_SRQ_CREATE,
182 	UVERBS_METHOD_SRQ_DESTROY,
183 };
184 
185 enum uverbs_methods_cq {
186 	UVERBS_METHOD_CQ_CREATE,
187 	UVERBS_METHOD_CQ_DESTROY,
188 };
189 
190 enum uverbs_attrs_create_wq_cmd_attr_ids {
191 	UVERBS_ATTR_CREATE_WQ_HANDLE,
192 	UVERBS_ATTR_CREATE_WQ_PD_HANDLE,
193 	UVERBS_ATTR_CREATE_WQ_CQ_HANDLE,
194 	UVERBS_ATTR_CREATE_WQ_USER_HANDLE,
195 	UVERBS_ATTR_CREATE_WQ_TYPE,
196 	UVERBS_ATTR_CREATE_WQ_EVENT_FD,
197 	UVERBS_ATTR_CREATE_WQ_MAX_WR,
198 	UVERBS_ATTR_CREATE_WQ_MAX_SGE,
199 	UVERBS_ATTR_CREATE_WQ_FLAGS,
200 	UVERBS_ATTR_CREATE_WQ_RESP_MAX_WR,
201 	UVERBS_ATTR_CREATE_WQ_RESP_MAX_SGE,
202 	UVERBS_ATTR_CREATE_WQ_RESP_WQ_NUM,
203 };
204 
205 enum uverbs_attrs_destroy_wq_cmd_attr_ids {
206 	UVERBS_ATTR_DESTROY_WQ_HANDLE,
207 	UVERBS_ATTR_DESTROY_WQ_RESP,
208 };
209 
210 enum uverbs_methods_wq {
211 	UVERBS_METHOD_WQ_CREATE,
212 	UVERBS_METHOD_WQ_DESTROY,
213 };
214 
215 enum uverbs_methods_actions_flow_action_ops {
216 	UVERBS_METHOD_FLOW_ACTION_ESP_CREATE,
217 	UVERBS_METHOD_FLOW_ACTION_DESTROY,
218 	UVERBS_METHOD_FLOW_ACTION_ESP_MODIFY,
219 };
220 
221 enum uverbs_attrs_alloc_dm_cmd_attr_ids {
222 	UVERBS_ATTR_ALLOC_DM_HANDLE,
223 	UVERBS_ATTR_ALLOC_DM_LENGTH,
224 	UVERBS_ATTR_ALLOC_DM_ALIGNMENT,
225 };
226 
227 enum uverbs_attrs_free_dm_cmd_attr_ids {
228 	UVERBS_ATTR_FREE_DM_HANDLE,
229 };
230 
231 enum uverbs_methods_dm {
232 	UVERBS_METHOD_DM_ALLOC,
233 	UVERBS_METHOD_DM_FREE,
234 };
235 
236 enum uverbs_attrs_reg_dm_mr_cmd_attr_ids {
237 	UVERBS_ATTR_REG_DM_MR_HANDLE,
238 	UVERBS_ATTR_REG_DM_MR_OFFSET,
239 	UVERBS_ATTR_REG_DM_MR_LENGTH,
240 	UVERBS_ATTR_REG_DM_MR_PD_HANDLE,
241 	UVERBS_ATTR_REG_DM_MR_ACCESS_FLAGS,
242 	UVERBS_ATTR_REG_DM_MR_DM_HANDLE,
243 	UVERBS_ATTR_REG_DM_MR_RESP_LKEY,
244 	UVERBS_ATTR_REG_DM_MR_RESP_RKEY,
245 };
246 
247 enum uverbs_methods_mr {
248 	UVERBS_METHOD_DM_MR_REG,
249 	UVERBS_METHOD_MR_DESTROY,
250 	UVERBS_METHOD_ADVISE_MR,
251 	UVERBS_METHOD_QUERY_MR,
252 };
253 
254 enum uverbs_attrs_mr_destroy_ids {
255 	UVERBS_ATTR_DESTROY_MR_HANDLE,
256 };
257 
258 enum uverbs_attrs_advise_mr_cmd_attr_ids {
259 	UVERBS_ATTR_ADVISE_MR_PD_HANDLE,
260 	UVERBS_ATTR_ADVISE_MR_ADVICE,
261 	UVERBS_ATTR_ADVISE_MR_FLAGS,
262 	UVERBS_ATTR_ADVISE_MR_SGE_LIST,
263 };
264 
265 enum uverbs_attrs_query_mr_cmd_attr_ids {
266 	UVERBS_ATTR_QUERY_MR_HANDLE,
267 	UVERBS_ATTR_QUERY_MR_RESP_LKEY,
268 	UVERBS_ATTR_QUERY_MR_RESP_RKEY,
269 	UVERBS_ATTR_QUERY_MR_RESP_LENGTH,
270 	UVERBS_ATTR_QUERY_MR_RESP_IOVA,
271 };
272 
273 enum uverbs_attrs_create_counters_cmd_attr_ids {
274 	UVERBS_ATTR_CREATE_COUNTERS_HANDLE,
275 };
276 
277 enum uverbs_attrs_destroy_counters_cmd_attr_ids {
278 	UVERBS_ATTR_DESTROY_COUNTERS_HANDLE,
279 };
280 
281 enum uverbs_attrs_read_counters_cmd_attr_ids {
282 	UVERBS_ATTR_READ_COUNTERS_HANDLE,
283 	UVERBS_ATTR_READ_COUNTERS_BUFF,
284 	UVERBS_ATTR_READ_COUNTERS_FLAGS,
285 };
286 
287 enum uverbs_methods_actions_counters_ops {
288 	UVERBS_METHOD_COUNTERS_CREATE,
289 	UVERBS_METHOD_COUNTERS_DESTROY,
290 	UVERBS_METHOD_COUNTERS_READ,
291 };
292 
293 enum uverbs_attrs_info_handles_id {
294 	UVERBS_ATTR_INFO_OBJECT_ID,
295 	UVERBS_ATTR_INFO_TOTAL_HANDLES,
296 	UVERBS_ATTR_INFO_HANDLES_LIST,
297 };
298 
299 enum uverbs_methods_pd {
300 	UVERBS_METHOD_PD_DESTROY,
301 };
302 
303 enum uverbs_attrs_pd_destroy_ids {
304 	UVERBS_ATTR_DESTROY_PD_HANDLE,
305 };
306 
307 enum uverbs_methods_mw {
308 	UVERBS_METHOD_MW_DESTROY,
309 };
310 
311 enum uverbs_attrs_mw_destroy_ids {
312 	UVERBS_ATTR_DESTROY_MW_HANDLE,
313 };
314 
315 enum uverbs_methods_xrcd {
316 	UVERBS_METHOD_XRCD_DESTROY,
317 };
318 
319 enum uverbs_attrs_xrcd_destroy_ids {
320 	UVERBS_ATTR_DESTROY_XRCD_HANDLE,
321 };
322 
323 enum uverbs_methods_ah {
324 	UVERBS_METHOD_AH_DESTROY,
325 };
326 
327 enum uverbs_attrs_ah_destroy_ids {
328 	UVERBS_ATTR_DESTROY_AH_HANDLE,
329 };
330 
331 enum uverbs_methods_rwq_ind_tbl {
332 	UVERBS_METHOD_RWQ_IND_TBL_DESTROY,
333 };
334 
335 enum uverbs_attrs_rwq_ind_tbl_destroy_ids {
336 	UVERBS_ATTR_DESTROY_RWQ_IND_TBL_HANDLE,
337 };
338 
339 enum uverbs_methods_flow {
340 	UVERBS_METHOD_FLOW_DESTROY,
341 };
342 
343 enum uverbs_attrs_flow_destroy_ids {
344 	UVERBS_ATTR_DESTROY_FLOW_HANDLE,
345 };
346 
347 enum uverbs_method_async_event {
348 	UVERBS_METHOD_ASYNC_EVENT_ALLOC,
349 };
350 
351 enum uverbs_attrs_async_event_create {
352 	UVERBS_ATTR_ASYNC_EVENT_ALLOC_FD_HANDLE,
353 };
354 
355 #endif
356