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