1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
2 /*
3  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
4  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
5  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
6  * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.
7  *
8  * This software is available to you under a choice of one of two
9  * licenses.  You may choose to be licensed under the terms of the GNU
10  * General Public License (GPL) Version 2, available from the file
11  * COPYING in the main directory of this source tree, or the
12  * OpenIB.org BSD license below:
13  *
14  *     Redistribution and use in source and binary forms, with or
15  *     without modification, are permitted provided that the following
16  *     conditions are met:
17  *
18  *      - Redistributions of source code must retain the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer.
21  *
22  *      - Redistributions in binary form must reproduce the above
23  *        copyright notice, this list of conditions and the following
24  *        disclaimer in the documentation and/or other materials
25  *        provided with the distribution.
26  *
27  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
31  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
32  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34  * SOFTWARE.
35  */
36 
37 #ifndef IB_USER_VERBS_H
38 #define IB_USER_VERBS_H
39 
40 #include <linux/types.h>
41 
42 /*
43  * Increment this value if any changes that break userspace ABI
44  * compatibility are made.
45  */
46 #define IB_USER_VERBS_ABI_VERSION	6
47 #define IB_USER_VERBS_CMD_THRESHOLD    50
48 
49 enum ib_uverbs_write_cmds {
50 	IB_USER_VERBS_CMD_GET_CONTEXT,
51 	IB_USER_VERBS_CMD_QUERY_DEVICE,
52 	IB_USER_VERBS_CMD_QUERY_PORT,
53 	IB_USER_VERBS_CMD_ALLOC_PD,
54 	IB_USER_VERBS_CMD_DEALLOC_PD,
55 	IB_USER_VERBS_CMD_CREATE_AH,
56 	IB_USER_VERBS_CMD_MODIFY_AH,
57 	IB_USER_VERBS_CMD_QUERY_AH,
58 	IB_USER_VERBS_CMD_DESTROY_AH,
59 	IB_USER_VERBS_CMD_REG_MR,
60 	IB_USER_VERBS_CMD_REG_SMR,
61 	IB_USER_VERBS_CMD_REREG_MR,
62 	IB_USER_VERBS_CMD_QUERY_MR,
63 	IB_USER_VERBS_CMD_DEREG_MR,
64 	IB_USER_VERBS_CMD_ALLOC_MW,
65 	IB_USER_VERBS_CMD_BIND_MW,
66 	IB_USER_VERBS_CMD_DEALLOC_MW,
67 	IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
68 	IB_USER_VERBS_CMD_CREATE_CQ,
69 	IB_USER_VERBS_CMD_RESIZE_CQ,
70 	IB_USER_VERBS_CMD_DESTROY_CQ,
71 	IB_USER_VERBS_CMD_POLL_CQ,
72 	IB_USER_VERBS_CMD_PEEK_CQ,
73 	IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
74 	IB_USER_VERBS_CMD_CREATE_QP,
75 	IB_USER_VERBS_CMD_QUERY_QP,
76 	IB_USER_VERBS_CMD_MODIFY_QP,
77 	IB_USER_VERBS_CMD_DESTROY_QP,
78 	IB_USER_VERBS_CMD_POST_SEND,
79 	IB_USER_VERBS_CMD_POST_RECV,
80 	IB_USER_VERBS_CMD_ATTACH_MCAST,
81 	IB_USER_VERBS_CMD_DETACH_MCAST,
82 	IB_USER_VERBS_CMD_CREATE_SRQ,
83 	IB_USER_VERBS_CMD_MODIFY_SRQ,
84 	IB_USER_VERBS_CMD_QUERY_SRQ,
85 	IB_USER_VERBS_CMD_DESTROY_SRQ,
86 	IB_USER_VERBS_CMD_POST_SRQ_RECV,
87 	IB_USER_VERBS_CMD_OPEN_XRCD,
88 	IB_USER_VERBS_CMD_CLOSE_XRCD,
89 	IB_USER_VERBS_CMD_CREATE_XSRQ,
90 	IB_USER_VERBS_CMD_OPEN_QP,
91 };
92 
93 enum {
94 	IB_USER_VERBS_EX_CMD_QUERY_DEVICE = IB_USER_VERBS_CMD_QUERY_DEVICE,
95 	IB_USER_VERBS_EX_CMD_CREATE_CQ = IB_USER_VERBS_CMD_CREATE_CQ,
96 	IB_USER_VERBS_EX_CMD_CREATE_QP = IB_USER_VERBS_CMD_CREATE_QP,
97 	IB_USER_VERBS_EX_CMD_MODIFY_QP = IB_USER_VERBS_CMD_MODIFY_QP,
98 	IB_USER_VERBS_EX_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_THRESHOLD,
99 	IB_USER_VERBS_EX_CMD_DESTROY_FLOW,
100 	IB_USER_VERBS_EX_CMD_CREATE_WQ,
101 	IB_USER_VERBS_EX_CMD_MODIFY_WQ,
102 	IB_USER_VERBS_EX_CMD_DESTROY_WQ,
103 	IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL,
104 	IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL,
105 	IB_USER_VERBS_EX_CMD_MODIFY_CQ
106 };
107 
108 /*
109  * Make sure that all structs defined in this file remain laid out so
110  * that they pack the same way on 32-bit and 64-bit architectures (to
111  * avoid incompatibility between 32-bit userspace and 64-bit kernels).
112  * Specifically:
113  *  - Do not use pointer types -- pass pointers in uint64_t instead.
114  *  - Make sure that any structure larger than 4 bytes is padded to a
115  *    multiple of 8 bytes.  Otherwise the structure size will be
116  *    different between 32-bit and 64-bit architectures.
117  */
118 
119 struct ib_uverbs_async_event_desc {
120 	__aligned_u64 element;
121 	uint32_t event_type;	/* enum ib_event_type */
122 	uint32_t reserved;
123 };
124 
125 struct ib_uverbs_comp_event_desc {
126 	__aligned_u64 cq_handle;
127 };
128 
129 struct ib_uverbs_cq_moderation_caps {
130 	uint16_t     max_cq_moderation_count;
131 	uint16_t     max_cq_moderation_period;
132 	uint32_t     reserved;
133 };
134 
135 /*
136  * All commands from userspace should start with a uint32_t command field
137  * followed by uint16_t in_words and out_words fields (which give the
138  * length of the command block and response buffer if any in 32-bit
139  * words).  The kernel driver will read these fields first and read
140  * the rest of the command struct based on these value.
141  */
142 
143 #define IB_USER_VERBS_CMD_COMMAND_MASK 0xff
144 #define IB_USER_VERBS_CMD_FLAG_EXTENDED 0x80000000u
145 
146 struct ib_uverbs_cmd_hdr {
147 	uint32_t command;
148 	uint16_t in_words;
149 	uint16_t out_words;
150 };
151 
152 struct ib_uverbs_ex_cmd_hdr {
153 	__aligned_u64 response;
154 	uint16_t provider_in_words;
155 	uint16_t provider_out_words;
156 	uint32_t cmd_hdr_reserved;
157 };
158 
159 struct ib_uverbs_get_context {
160 	__aligned_u64 response;
161 	__aligned_u64 driver_data[0];
162 };
163 
164 struct ib_uverbs_get_context_resp {
165 	uint32_t async_fd;
166 	uint32_t num_comp_vectors;
167 	__aligned_u64 driver_data[0];
168 };
169 
170 struct ib_uverbs_query_device {
171 	__aligned_u64 response;
172 	__aligned_u64 driver_data[0];
173 };
174 
175 struct ib_uverbs_query_device_resp {
176 	__aligned_u64 fw_ver;
177 	uint64_t node_guid;
178 	uint64_t sys_image_guid;
179 	__aligned_u64 max_mr_size;
180 	__aligned_u64 page_size_cap;
181 	uint32_t vendor_id;
182 	uint32_t vendor_part_id;
183 	uint32_t hw_ver;
184 	uint32_t max_qp;
185 	uint32_t max_qp_wr;
186 	uint32_t device_cap_flags;
187 	uint32_t max_sge;
188 	uint32_t max_sge_rd;
189 	uint32_t max_cq;
190 	uint32_t max_cqe;
191 	uint32_t max_mr;
192 	uint32_t max_pd;
193 	uint32_t max_qp_rd_atom;
194 	uint32_t max_ee_rd_atom;
195 	uint32_t max_res_rd_atom;
196 	uint32_t max_qp_init_rd_atom;
197 	uint32_t max_ee_init_rd_atom;
198 	uint32_t atomic_cap;
199 	uint32_t max_ee;
200 	uint32_t max_rdd;
201 	uint32_t max_mw;
202 	uint32_t max_raw_ipv6_qp;
203 	uint32_t max_raw_ethy_qp;
204 	uint32_t max_mcast_grp;
205 	uint32_t max_mcast_qp_attach;
206 	uint32_t max_total_mcast_qp_attach;
207 	uint32_t max_ah;
208 	uint32_t max_fmr;
209 	uint32_t max_map_per_fmr;
210 	uint32_t max_srq;
211 	uint32_t max_srq_wr;
212 	uint32_t max_srq_sge;
213 	uint16_t max_pkeys;
214 	uint8_t  local_ca_ack_delay;
215 	uint8_t  phys_port_cnt;
216 	uint8_t  reserved[4];
217 };
218 
219 struct ib_uverbs_ex_query_device {
220 	uint32_t comp_mask;
221 	uint32_t reserved;
222 };
223 
224 struct ib_uverbs_odp_caps {
225 	__aligned_u64 general_caps;
226 	struct {
227 		uint32_t rc_odp_caps;
228 		uint32_t uc_odp_caps;
229 		uint32_t ud_odp_caps;
230 	} per_transport_caps;
231 	uint32_t reserved;
232 };
233 
234 struct ib_uverbs_rss_caps {
235 	/* Corresponding bit will be set if qp type from
236 	 * 'enum ib_qp_type' is supported, e.g.
237 	 * supported_qpts |= 1 << IB_QPT_UD
238 	 */
239 	uint32_t supported_qpts;
240 	uint32_t max_rwq_indirection_tables;
241 	uint32_t max_rwq_indirection_table_size;
242 	uint32_t reserved;
243 };
244 
245 struct ib_uverbs_tm_caps {
246 	/* Max size of rendezvous request message */
247 	uint32_t max_rndv_hdr_size;
248 	/* Max number of entries in tag matching list */
249 	uint32_t max_num_tags;
250 	/* TM flags */
251 	uint32_t flags;
252 	/* Max number of outstanding list operations */
253 	uint32_t max_ops;
254 	/* Max number of SGE in tag matching entry */
255 	uint32_t max_sge;
256 	uint32_t reserved;
257 };
258 
259 struct ib_uverbs_ex_query_device_resp {
260 	struct ib_uverbs_query_device_resp base;
261 	uint32_t comp_mask;
262 	uint32_t response_length;
263 	struct ib_uverbs_odp_caps odp_caps;
264 	__aligned_u64 timestamp_mask;
265 	__aligned_u64 hca_core_clock; /* in KHZ */
266 	__aligned_u64 device_cap_flags_ex;
267 	struct ib_uverbs_rss_caps rss_caps;
268 	uint32_t  max_wq_type_rq;
269 	uint32_t raw_packet_caps;
270 	struct ib_uverbs_tm_caps tm_caps;
271 	struct ib_uverbs_cq_moderation_caps cq_moderation_caps;
272 	__aligned_u64 max_dm_size;
273 	uint32_t xrc_odp_caps;
274 	uint32_t reserved;
275 };
276 
277 struct ib_uverbs_query_port {
278 	__aligned_u64 response;
279 	uint8_t  port_num;
280 	uint8_t  reserved[7];
281 	__aligned_u64 driver_data[0];
282 };
283 
284 struct ib_uverbs_query_port_resp {
285 	uint32_t port_cap_flags;		/* see ib_uverbs_query_port_cap_flags */
286 	uint32_t max_msg_sz;
287 	uint32_t bad_pkey_cntr;
288 	uint32_t qkey_viol_cntr;
289 	uint32_t gid_tbl_len;
290 	uint16_t pkey_tbl_len;
291 	uint16_t lid;
292 	uint16_t sm_lid;
293 	uint8_t  state;
294 	uint8_t  max_mtu;
295 	uint8_t  active_mtu;
296 	uint8_t  lmc;
297 	uint8_t  max_vl_num;
298 	uint8_t  sm_sl;
299 	uint8_t  subnet_timeout;
300 	uint8_t  init_type_reply;
301 	uint8_t  active_width;
302 	uint8_t  active_speed;
303 	uint8_t  phys_state;
304 	uint8_t  link_layer;
305 	uint8_t  flags;			/* see ib_uverbs_query_port_flags */
306 	uint8_t  reserved;
307 };
308 
309 struct ib_uverbs_alloc_pd {
310 	__aligned_u64 response;
311 	__aligned_u64 driver_data[0];
312 };
313 
314 struct ib_uverbs_alloc_pd_resp {
315 	uint32_t pd_handle;
316 	uint32_t driver_data[0];
317 };
318 
319 struct ib_uverbs_dealloc_pd {
320 	uint32_t pd_handle;
321 };
322 
323 struct ib_uverbs_open_xrcd {
324 	__aligned_u64 response;
325 	uint32_t fd;
326 	uint32_t oflags;
327 	__aligned_u64 driver_data[0];
328 };
329 
330 struct ib_uverbs_open_xrcd_resp {
331 	uint32_t xrcd_handle;
332 	uint32_t driver_data[0];
333 };
334 
335 struct ib_uverbs_close_xrcd {
336 	uint32_t xrcd_handle;
337 };
338 
339 struct ib_uverbs_reg_mr {
340 	__aligned_u64 response;
341 	__aligned_u64 start;
342 	__aligned_u64 length;
343 	__aligned_u64 hca_va;
344 	uint32_t pd_handle;
345 	uint32_t access_flags;
346 	__aligned_u64 driver_data[0];
347 };
348 
349 struct ib_uverbs_reg_mr_resp {
350 	uint32_t mr_handle;
351 	uint32_t lkey;
352 	uint32_t rkey;
353 	uint32_t driver_data[0];
354 };
355 
356 struct ib_uverbs_rereg_mr {
357 	__aligned_u64 response;
358 	uint32_t mr_handle;
359 	uint32_t flags;
360 	__aligned_u64 start;
361 	__aligned_u64 length;
362 	__aligned_u64 hca_va;
363 	uint32_t pd_handle;
364 	uint32_t access_flags;
365 	__aligned_u64 driver_data[0];
366 };
367 
368 struct ib_uverbs_rereg_mr_resp {
369 	uint32_t lkey;
370 	uint32_t rkey;
371 	__aligned_u64 driver_data[0];
372 };
373 
374 struct ib_uverbs_dereg_mr {
375 	uint32_t mr_handle;
376 };
377 
378 struct ib_uverbs_alloc_mw {
379 	__aligned_u64 response;
380 	uint32_t pd_handle;
381 	uint8_t  mw_type;
382 	uint8_t  reserved[3];
383 	__aligned_u64 driver_data[0];
384 };
385 
386 struct ib_uverbs_alloc_mw_resp {
387 	uint32_t mw_handle;
388 	uint32_t rkey;
389 	__aligned_u64 driver_data[0];
390 };
391 
392 struct ib_uverbs_dealloc_mw {
393 	uint32_t mw_handle;
394 };
395 
396 struct ib_uverbs_create_comp_channel {
397 	__aligned_u64 response;
398 };
399 
400 struct ib_uverbs_create_comp_channel_resp {
401 	uint32_t fd;
402 };
403 
404 struct ib_uverbs_create_cq {
405 	__aligned_u64 response;
406 	__aligned_u64 user_handle;
407 	uint32_t cqe;
408 	uint32_t comp_vector;
409 	int32_t comp_channel;
410 	uint32_t reserved;
411 	__aligned_u64 driver_data[0];
412 };
413 
414 enum ib_uverbs_ex_create_cq_flags {
415 	IB_UVERBS_CQ_FLAGS_TIMESTAMP_COMPLETION = 1 << 0,
416 	IB_UVERBS_CQ_FLAGS_IGNORE_OVERRUN = 1 << 1,
417 };
418 
419 struct ib_uverbs_ex_create_cq {
420 	__aligned_u64 user_handle;
421 	uint32_t cqe;
422 	uint32_t comp_vector;
423 	int32_t comp_channel;
424 	uint32_t comp_mask;
425 	uint32_t flags;  /* bitmask of ib_uverbs_ex_create_cq_flags */
426 	uint32_t reserved;
427 };
428 
429 struct ib_uverbs_create_cq_resp {
430 	uint32_t cq_handle;
431 	uint32_t cqe;
432 	__aligned_u64 driver_data[0];
433 };
434 
435 struct ib_uverbs_ex_create_cq_resp {
436 	struct ib_uverbs_create_cq_resp base;
437 	uint32_t comp_mask;
438 	uint32_t response_length;
439 };
440 
441 struct ib_uverbs_resize_cq {
442 	__aligned_u64 response;
443 	uint32_t cq_handle;
444 	uint32_t cqe;
445 	__aligned_u64 driver_data[0];
446 };
447 
448 struct ib_uverbs_resize_cq_resp {
449 	uint32_t cqe;
450 	uint32_t reserved;
451 	__aligned_u64 driver_data[0];
452 };
453 
454 struct ib_uverbs_poll_cq {
455 	__aligned_u64 response;
456 	uint32_t cq_handle;
457 	uint32_t ne;
458 };
459 
460 enum ib_uverbs_wc_opcode {
461 	IB_UVERBS_WC_SEND = 0,
462 	IB_UVERBS_WC_RDMA_WRITE = 1,
463 	IB_UVERBS_WC_RDMA_READ = 2,
464 	IB_UVERBS_WC_COMP_SWAP = 3,
465 	IB_UVERBS_WC_FETCH_ADD = 4,
466 	IB_UVERBS_WC_BIND_MW = 5,
467 	IB_UVERBS_WC_LOCAL_INV = 6,
468 	IB_UVERBS_WC_TSO = 7,
469 };
470 
471 struct ib_uverbs_wc {
472 	__aligned_u64 wr_id;
473 	uint32_t status;
474 	uint32_t opcode;
475 	uint32_t vendor_err;
476 	uint32_t byte_len;
477 	union {
478 		uint32_t imm_data;
479 		uint32_t invalidate_rkey;
480 	} ex;
481 	uint32_t qp_num;
482 	uint32_t src_qp;
483 	uint32_t wc_flags;
484 	uint16_t pkey_index;
485 	uint16_t slid;
486 	uint8_t sl;
487 	uint8_t dlid_path_bits;
488 	uint8_t port_num;
489 	uint8_t reserved;
490 };
491 
492 struct ib_uverbs_poll_cq_resp {
493 	uint32_t count;
494 	uint32_t reserved;
495 	struct ib_uverbs_wc wc[0];
496 };
497 
498 struct ib_uverbs_req_notify_cq {
499 	uint32_t cq_handle;
500 	uint32_t solicited_only;
501 };
502 
503 struct ib_uverbs_destroy_cq {
504 	__aligned_u64 response;
505 	uint32_t cq_handle;
506 	uint32_t reserved;
507 };
508 
509 struct ib_uverbs_destroy_cq_resp {
510 	uint32_t comp_events_reported;
511 	uint32_t async_events_reported;
512 };
513 
514 struct ib_uverbs_global_route {
515 	uint8_t  dgid[16];
516 	uint32_t flow_label;
517 	uint8_t  sgid_index;
518 	uint8_t  hop_limit;
519 	uint8_t  traffic_class;
520 	uint8_t  reserved;
521 };
522 
523 struct ib_uverbs_ah_attr {
524 	struct ib_uverbs_global_route grh;
525 	uint16_t dlid;
526 	uint8_t  sl;
527 	uint8_t  src_path_bits;
528 	uint8_t  static_rate;
529 	uint8_t  is_global;
530 	uint8_t  port_num;
531 	uint8_t  reserved;
532 };
533 
534 struct ib_uverbs_qp_attr {
535 	uint32_t	qp_attr_mask;
536 	uint32_t	qp_state;
537 	uint32_t	cur_qp_state;
538 	uint32_t	path_mtu;
539 	uint32_t	path_mig_state;
540 	uint32_t	qkey;
541 	uint32_t	rq_psn;
542 	uint32_t	sq_psn;
543 	uint32_t	dest_qp_num;
544 	uint32_t	qp_access_flags;
545 
546 	struct ib_uverbs_ah_attr ah_attr;
547 	struct ib_uverbs_ah_attr alt_ah_attr;
548 
549 	/* ib_qp_cap */
550 	uint32_t	max_send_wr;
551 	uint32_t	max_recv_wr;
552 	uint32_t	max_send_sge;
553 	uint32_t	max_recv_sge;
554 	uint32_t	max_inline_data;
555 
556 	uint16_t	pkey_index;
557 	uint16_t	alt_pkey_index;
558 	uint8_t	en_sqd_async_notify;
559 	uint8_t	sq_draining;
560 	uint8_t	max_rd_atomic;
561 	uint8_t	max_dest_rd_atomic;
562 	uint8_t	min_rnr_timer;
563 	uint8_t	port_num;
564 	uint8_t	timeout;
565 	uint8_t	retry_cnt;
566 	uint8_t	rnr_retry;
567 	uint8_t	alt_port_num;
568 	uint8_t	alt_timeout;
569 	uint8_t	reserved[5];
570 };
571 
572 struct ib_uverbs_create_qp {
573 	__aligned_u64 response;
574 	__aligned_u64 user_handle;
575 	uint32_t pd_handle;
576 	uint32_t send_cq_handle;
577 	uint32_t recv_cq_handle;
578 	uint32_t srq_handle;
579 	uint32_t max_send_wr;
580 	uint32_t max_recv_wr;
581 	uint32_t max_send_sge;
582 	uint32_t max_recv_sge;
583 	uint32_t max_inline_data;
584 	uint8_t  sq_sig_all;
585 	uint8_t  qp_type;
586 	uint8_t  is_srq;
587 	uint8_t  reserved;
588 	__aligned_u64 driver_data[0];
589 };
590 
591 enum ib_uverbs_create_qp_mask {
592 	IB_UVERBS_CREATE_QP_MASK_IND_TABLE = 1UL << 0,
593 };
594 
595 enum {
596 	IB_UVERBS_CREATE_QP_SUP_COMP_MASK = IB_UVERBS_CREATE_QP_MASK_IND_TABLE,
597 };
598 
599 struct ib_uverbs_ex_create_qp {
600 	__aligned_u64 user_handle;
601 	uint32_t pd_handle;
602 	uint32_t send_cq_handle;
603 	uint32_t recv_cq_handle;
604 	uint32_t srq_handle;
605 	uint32_t max_send_wr;
606 	uint32_t max_recv_wr;
607 	uint32_t max_send_sge;
608 	uint32_t max_recv_sge;
609 	uint32_t max_inline_data;
610 	uint8_t  sq_sig_all;
611 	uint8_t  qp_type;
612 	uint8_t  is_srq;
613 	uint8_t reserved;
614 	uint32_t comp_mask;
615 	uint32_t create_flags;
616 	uint32_t rwq_ind_tbl_handle;
617 	uint32_t  source_qpn;
618 };
619 
620 struct ib_uverbs_open_qp {
621 	__aligned_u64 response;
622 	__aligned_u64 user_handle;
623 	uint32_t pd_handle;
624 	uint32_t qpn;
625 	uint8_t  qp_type;
626 	uint8_t  reserved[7];
627 	__aligned_u64 driver_data[0];
628 };
629 
630 /* also used for open response */
631 struct ib_uverbs_create_qp_resp {
632 	uint32_t qp_handle;
633 	uint32_t qpn;
634 	uint32_t max_send_wr;
635 	uint32_t max_recv_wr;
636 	uint32_t max_send_sge;
637 	uint32_t max_recv_sge;
638 	uint32_t max_inline_data;
639 	uint32_t reserved;
640 	uint32_t driver_data[0];
641 };
642 
643 struct ib_uverbs_ex_create_qp_resp {
644 	struct ib_uverbs_create_qp_resp base;
645 	uint32_t comp_mask;
646 	uint32_t response_length;
647 };
648 
649 /*
650  * This struct needs to remain a multiple of 8 bytes to keep the
651  * alignment of the modify QP parameters.
652  */
653 struct ib_uverbs_qp_dest {
654 	uint8_t  dgid[16];
655 	uint32_t flow_label;
656 	uint16_t dlid;
657 	uint16_t reserved;
658 	uint8_t  sgid_index;
659 	uint8_t  hop_limit;
660 	uint8_t  traffic_class;
661 	uint8_t  sl;
662 	uint8_t  src_path_bits;
663 	uint8_t  static_rate;
664 	uint8_t  is_global;
665 	uint8_t  port_num;
666 };
667 
668 struct ib_uverbs_query_qp {
669 	__aligned_u64 response;
670 	uint32_t qp_handle;
671 	uint32_t attr_mask;
672 	__aligned_u64 driver_data[0];
673 };
674 
675 struct ib_uverbs_query_qp_resp {
676 	struct ib_uverbs_qp_dest dest;
677 	struct ib_uverbs_qp_dest alt_dest;
678 	uint32_t max_send_wr;
679 	uint32_t max_recv_wr;
680 	uint32_t max_send_sge;
681 	uint32_t max_recv_sge;
682 	uint32_t max_inline_data;
683 	uint32_t qkey;
684 	uint32_t rq_psn;
685 	uint32_t sq_psn;
686 	uint32_t dest_qp_num;
687 	uint32_t qp_access_flags;
688 	uint16_t pkey_index;
689 	uint16_t alt_pkey_index;
690 	uint8_t  qp_state;
691 	uint8_t  cur_qp_state;
692 	uint8_t  path_mtu;
693 	uint8_t  path_mig_state;
694 	uint8_t  sq_draining;
695 	uint8_t  max_rd_atomic;
696 	uint8_t  max_dest_rd_atomic;
697 	uint8_t  min_rnr_timer;
698 	uint8_t  port_num;
699 	uint8_t  timeout;
700 	uint8_t  retry_cnt;
701 	uint8_t  rnr_retry;
702 	uint8_t  alt_port_num;
703 	uint8_t  alt_timeout;
704 	uint8_t  sq_sig_all;
705 	uint8_t  reserved[5];
706 	__aligned_u64 driver_data[0];
707 };
708 
709 struct ib_uverbs_modify_qp {
710 	struct ib_uverbs_qp_dest dest;
711 	struct ib_uverbs_qp_dest alt_dest;
712 	uint32_t qp_handle;
713 	uint32_t attr_mask;
714 	uint32_t qkey;
715 	uint32_t rq_psn;
716 	uint32_t sq_psn;
717 	uint32_t dest_qp_num;
718 	uint32_t qp_access_flags;
719 	uint16_t pkey_index;
720 	uint16_t alt_pkey_index;
721 	uint8_t  qp_state;
722 	uint8_t  cur_qp_state;
723 	uint8_t  path_mtu;
724 	uint8_t  path_mig_state;
725 	uint8_t  en_sqd_async_notify;
726 	uint8_t  max_rd_atomic;
727 	uint8_t  max_dest_rd_atomic;
728 	uint8_t  min_rnr_timer;
729 	uint8_t  port_num;
730 	uint8_t  timeout;
731 	uint8_t  retry_cnt;
732 	uint8_t  rnr_retry;
733 	uint8_t  alt_port_num;
734 	uint8_t  alt_timeout;
735 	uint8_t  reserved[2];
736 	__aligned_u64 driver_data[0];
737 };
738 
739 struct ib_uverbs_ex_modify_qp {
740 	struct ib_uverbs_modify_qp base;
741 	uint32_t	rate_limit;
742 	uint32_t	reserved;
743 };
744 
745 struct ib_uverbs_ex_modify_qp_resp {
746 	uint32_t  comp_mask;
747 	uint32_t  response_length;
748 };
749 
750 struct ib_uverbs_destroy_qp {
751 	__aligned_u64 response;
752 	uint32_t qp_handle;
753 	uint32_t reserved;
754 };
755 
756 struct ib_uverbs_destroy_qp_resp {
757 	uint32_t events_reported;
758 };
759 
760 /*
761  * The ib_uverbs_sge structure isn't used anywhere, since we assume
762  * the ib_sge structure is packed the same way on 32-bit and 64-bit
763  * architectures in both kernel and user space.  It's just here to
764  * document the ABI.
765  */
766 struct ib_uverbs_sge {
767 	__aligned_u64 addr;
768 	uint32_t length;
769 	uint32_t lkey;
770 };
771 
772 enum ib_uverbs_wr_opcode {
773 	IB_UVERBS_WR_RDMA_WRITE = 0,
774 	IB_UVERBS_WR_RDMA_WRITE_WITH_IMM = 1,
775 	IB_UVERBS_WR_SEND = 2,
776 	IB_UVERBS_WR_SEND_WITH_IMM = 3,
777 	IB_UVERBS_WR_RDMA_READ = 4,
778 	IB_UVERBS_WR_ATOMIC_CMP_AND_SWP = 5,
779 	IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD = 6,
780 	IB_UVERBS_WR_LOCAL_INV = 7,
781 	IB_UVERBS_WR_BIND_MW = 8,
782 	IB_UVERBS_WR_SEND_WITH_INV = 9,
783 	IB_UVERBS_WR_TSO = 10,
784 	IB_UVERBS_WR_RDMA_READ_WITH_INV = 11,
785 	IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP = 12,
786 	IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD = 13,
787 	/* Review enum ib_wr_opcode before modifying this */
788 };
789 
790 struct ib_uverbs_send_wr {
791 	__aligned_u64 wr_id;
792 	uint32_t num_sge;
793 	uint32_t opcode;		/* see enum ib_uverbs_wr_opcode */
794 	uint32_t send_flags;
795 	union {
796 		uint32_t imm_data;
797 		uint32_t invalidate_rkey;
798 	} ex;
799 	union {
800 		struct {
801 			__aligned_u64 remote_addr;
802 			uint32_t rkey;
803 			uint32_t reserved;
804 		} rdma;
805 		struct {
806 			__aligned_u64 remote_addr;
807 			__aligned_u64 compare_add;
808 			__aligned_u64 swap;
809 			uint32_t rkey;
810 			uint32_t reserved;
811 		} atomic;
812 		struct {
813 			uint32_t ah;
814 			uint32_t remote_qpn;
815 			uint32_t remote_qkey;
816 			uint32_t reserved;
817 		} ud;
818 	} wr;
819 };
820 
821 struct ib_uverbs_post_send {
822 	__aligned_u64 response;
823 	uint32_t qp_handle;
824 	uint32_t wr_count;
825 	uint32_t sge_count;
826 	uint32_t wqe_size;
827 	struct ib_uverbs_send_wr send_wr[0];
828 };
829 
830 struct ib_uverbs_post_send_resp {
831 	uint32_t bad_wr;
832 };
833 
834 struct ib_uverbs_recv_wr {
835 	__aligned_u64 wr_id;
836 	uint32_t num_sge;
837 	uint32_t reserved;
838 };
839 
840 struct ib_uverbs_post_recv {
841 	__aligned_u64 response;
842 	uint32_t qp_handle;
843 	uint32_t wr_count;
844 	uint32_t sge_count;
845 	uint32_t wqe_size;
846 	struct ib_uverbs_recv_wr recv_wr[0];
847 };
848 
849 struct ib_uverbs_post_recv_resp {
850 	uint32_t bad_wr;
851 };
852 
853 struct ib_uverbs_post_srq_recv {
854 	__aligned_u64 response;
855 	uint32_t srq_handle;
856 	uint32_t wr_count;
857 	uint32_t sge_count;
858 	uint32_t wqe_size;
859 	struct ib_uverbs_recv_wr recv[0];
860 };
861 
862 struct ib_uverbs_post_srq_recv_resp {
863 	uint32_t bad_wr;
864 };
865 
866 struct ib_uverbs_create_ah {
867 	__aligned_u64 response;
868 	__aligned_u64 user_handle;
869 	uint32_t pd_handle;
870 	uint32_t reserved;
871 	struct ib_uverbs_ah_attr attr;
872 	__aligned_u64 driver_data[0];
873 };
874 
875 struct ib_uverbs_create_ah_resp {
876 	uint32_t ah_handle;
877 	uint32_t driver_data[0];
878 };
879 
880 struct ib_uverbs_destroy_ah {
881 	uint32_t ah_handle;
882 };
883 
884 struct ib_uverbs_attach_mcast {
885 	uint8_t  gid[16];
886 	uint32_t qp_handle;
887 	uint16_t mlid;
888 	uint16_t reserved;
889 	__aligned_u64 driver_data[0];
890 };
891 
892 struct ib_uverbs_detach_mcast {
893 	uint8_t  gid[16];
894 	uint32_t qp_handle;
895 	uint16_t mlid;
896 	uint16_t reserved;
897 	__aligned_u64 driver_data[0];
898 };
899 
900 struct ib_uverbs_flow_spec_hdr {
901 	uint32_t type;
902 	uint16_t size;
903 	uint16_t reserved;
904 	/* followed by flow_spec */
905 	__aligned_u64 flow_spec_data[0];
906 };
907 
908 struct ib_uverbs_flow_eth_filter {
909 	uint8_t  dst_mac[6];
910 	uint8_t  src_mac[6];
911 	uint16_t ether_type;
912 	uint16_t vlan_tag;
913 };
914 
915 struct ib_uverbs_flow_spec_eth {
916 	union {
917 		struct ib_uverbs_flow_spec_hdr hdr;
918 		struct {
919 			uint32_t type;
920 			uint16_t size;
921 			uint16_t reserved;
922 		};
923 	};
924 	struct ib_uverbs_flow_eth_filter val;
925 	struct ib_uverbs_flow_eth_filter mask;
926 };
927 
928 struct ib_uverbs_flow_ipv4_filter {
929 	uint32_t src_ip;
930 	uint32_t dst_ip;
931 	uint8_t	proto;
932 	uint8_t	tos;
933 	uint8_t	ttl;
934 	uint8_t	flags;
935 };
936 
937 struct ib_uverbs_flow_spec_ipv4 {
938 	union {
939 		struct ib_uverbs_flow_spec_hdr hdr;
940 		struct {
941 			uint32_t type;
942 			uint16_t size;
943 			uint16_t reserved;
944 		};
945 	};
946 	struct ib_uverbs_flow_ipv4_filter val;
947 	struct ib_uverbs_flow_ipv4_filter mask;
948 };
949 
950 struct ib_uverbs_flow_tcp_udp_filter {
951 	uint16_t dst_port;
952 	uint16_t src_port;
953 };
954 
955 struct ib_uverbs_flow_spec_tcp_udp {
956 	union {
957 		struct ib_uverbs_flow_spec_hdr hdr;
958 		struct {
959 			uint32_t type;
960 			uint16_t size;
961 			uint16_t reserved;
962 		};
963 	};
964 	struct ib_uverbs_flow_tcp_udp_filter val;
965 	struct ib_uverbs_flow_tcp_udp_filter mask;
966 };
967 
968 struct ib_uverbs_flow_ipv6_filter {
969 	uint8_t    src_ip[16];
970 	uint8_t    dst_ip[16];
971 	uint32_t	flow_label;
972 	uint8_t	next_hdr;
973 	uint8_t	traffic_class;
974 	uint8_t	hop_limit;
975 	uint8_t	reserved;
976 };
977 
978 struct ib_uverbs_flow_spec_ipv6 {
979 	union {
980 		struct ib_uverbs_flow_spec_hdr hdr;
981 		struct {
982 			uint32_t type;
983 			uint16_t size;
984 			uint16_t reserved;
985 		};
986 	};
987 	struct ib_uverbs_flow_ipv6_filter val;
988 	struct ib_uverbs_flow_ipv6_filter mask;
989 };
990 
991 struct ib_uverbs_flow_spec_action_tag {
992 	union {
993 		struct ib_uverbs_flow_spec_hdr hdr;
994 		struct {
995 			uint32_t type;
996 			uint16_t size;
997 			uint16_t reserved;
998 		};
999 	};
1000 	uint32_t			      tag_id;
1001 	uint32_t			      reserved1;
1002 };
1003 
1004 struct ib_uverbs_flow_spec_action_drop {
1005 	union {
1006 		struct ib_uverbs_flow_spec_hdr hdr;
1007 		struct {
1008 			uint32_t type;
1009 			uint16_t size;
1010 			uint16_t reserved;
1011 		};
1012 	};
1013 };
1014 
1015 struct ib_uverbs_flow_spec_action_handle {
1016 	union {
1017 		struct ib_uverbs_flow_spec_hdr hdr;
1018 		struct {
1019 			uint32_t type;
1020 			uint16_t size;
1021 			uint16_t reserved;
1022 		};
1023 	};
1024 	uint32_t			      handle;
1025 	uint32_t			      reserved1;
1026 };
1027 
1028 struct ib_uverbs_flow_spec_action_count {
1029 	union {
1030 		struct ib_uverbs_flow_spec_hdr hdr;
1031 		struct {
1032 			uint32_t type;
1033 			uint16_t size;
1034 			uint16_t reserved;
1035 		};
1036 	};
1037 	uint32_t			      handle;
1038 	uint32_t			      reserved1;
1039 };
1040 
1041 struct ib_uverbs_flow_tunnel_filter {
1042 	uint32_t tunnel_id;
1043 };
1044 
1045 struct ib_uverbs_flow_spec_tunnel {
1046 	union {
1047 		struct ib_uverbs_flow_spec_hdr hdr;
1048 		struct {
1049 			uint32_t type;
1050 			uint16_t size;
1051 			uint16_t reserved;
1052 		};
1053 	};
1054 	struct ib_uverbs_flow_tunnel_filter val;
1055 	struct ib_uverbs_flow_tunnel_filter mask;
1056 };
1057 
1058 struct ib_uverbs_flow_spec_esp_filter {
1059 	uint32_t spi;
1060 	uint32_t seq;
1061 };
1062 
1063 struct ib_uverbs_flow_spec_esp {
1064 	union {
1065 		struct ib_uverbs_flow_spec_hdr hdr;
1066 		struct {
1067 			uint32_t type;
1068 			uint16_t size;
1069 			uint16_t reserved;
1070 		};
1071 	};
1072 	struct ib_uverbs_flow_spec_esp_filter val;
1073 	struct ib_uverbs_flow_spec_esp_filter mask;
1074 };
1075 
1076 struct ib_uverbs_flow_gre_filter {
1077 	/* c_ks_res0_ver field is bits 0-15 in offset 0 of a standard GRE header:
1078 	 * bit 0 - C - checksum bit.
1079 	 * bit 1 - reserved. set to 0.
1080 	 * bit 2 - key bit.
1081 	 * bit 3 - sequence number bit.
1082 	 * bits 4:12 - reserved. set to 0.
1083 	 * bits 13:15 - GRE version.
1084 	 */
1085 	uint16_t c_ks_res0_ver;
1086 	uint16_t protocol;
1087 	uint32_t key;
1088 };
1089 
1090 struct ib_uverbs_flow_spec_gre {
1091 	union {
1092 		struct ib_uverbs_flow_spec_hdr hdr;
1093 		struct {
1094 			uint32_t type;
1095 			uint16_t size;
1096 			uint16_t reserved;
1097 		};
1098 	};
1099 	struct ib_uverbs_flow_gre_filter     val;
1100 	struct ib_uverbs_flow_gre_filter     mask;
1101 };
1102 
1103 struct ib_uverbs_flow_mpls_filter {
1104 	/* The field includes the entire MPLS label:
1105 	 * bits 0:19 - label field.
1106 	 * bits 20:22 - traffic class field.
1107 	 * bits 23 - bottom of stack bit.
1108 	 * bits 24:31 - ttl field.
1109 	 */
1110 	uint32_t label;
1111 };
1112 
1113 struct ib_uverbs_flow_spec_mpls {
1114 	union {
1115 		struct ib_uverbs_flow_spec_hdr hdr;
1116 		struct {
1117 			uint32_t type;
1118 			uint16_t size;
1119 			uint16_t reserved;
1120 		};
1121 	};
1122 	struct ib_uverbs_flow_mpls_filter     val;
1123 	struct ib_uverbs_flow_mpls_filter     mask;
1124 };
1125 
1126 struct ib_uverbs_flow_attr {
1127 	uint32_t type;
1128 	uint16_t size;
1129 	uint16_t priority;
1130 	uint8_t  num_of_specs;
1131 	uint8_t  reserved[2];
1132 	uint8_t  port;
1133 	uint32_t flags;
1134 	/* Following are the optional layers according to user request
1135 	 * struct ib_flow_spec_xxx
1136 	 * struct ib_flow_spec_yyy
1137 	 */
1138 	struct ib_uverbs_flow_spec_hdr flow_specs[0];
1139 };
1140 
1141 struct ib_uverbs_create_flow  {
1142 	uint32_t comp_mask;
1143 	uint32_t qp_handle;
1144 	struct ib_uverbs_flow_attr flow_attr;
1145 };
1146 
1147 struct ib_uverbs_create_flow_resp {
1148 	uint32_t comp_mask;
1149 	uint32_t flow_handle;
1150 };
1151 
1152 struct ib_uverbs_destroy_flow  {
1153 	uint32_t comp_mask;
1154 	uint32_t flow_handle;
1155 };
1156 
1157 struct ib_uverbs_create_srq {
1158 	__aligned_u64 response;
1159 	__aligned_u64 user_handle;
1160 	uint32_t pd_handle;
1161 	uint32_t max_wr;
1162 	uint32_t max_sge;
1163 	uint32_t srq_limit;
1164 	__aligned_u64 driver_data[0];
1165 };
1166 
1167 struct ib_uverbs_create_xsrq {
1168 	__aligned_u64 response;
1169 	__aligned_u64 user_handle;
1170 	uint32_t srq_type;
1171 	uint32_t pd_handle;
1172 	uint32_t max_wr;
1173 	uint32_t max_sge;
1174 	uint32_t srq_limit;
1175 	uint32_t max_num_tags;
1176 	uint32_t xrcd_handle;
1177 	uint32_t cq_handle;
1178 	__aligned_u64 driver_data[0];
1179 };
1180 
1181 struct ib_uverbs_create_srq_resp {
1182 	uint32_t srq_handle;
1183 	uint32_t max_wr;
1184 	uint32_t max_sge;
1185 	uint32_t srqn;
1186 	uint32_t driver_data[0];
1187 };
1188 
1189 struct ib_uverbs_modify_srq {
1190 	uint32_t srq_handle;
1191 	uint32_t attr_mask;
1192 	uint32_t max_wr;
1193 	uint32_t srq_limit;
1194 	__aligned_u64 driver_data[0];
1195 };
1196 
1197 struct ib_uverbs_query_srq {
1198 	__aligned_u64 response;
1199 	uint32_t srq_handle;
1200 	uint32_t reserved;
1201 	__aligned_u64 driver_data[0];
1202 };
1203 
1204 struct ib_uverbs_query_srq_resp {
1205 	uint32_t max_wr;
1206 	uint32_t max_sge;
1207 	uint32_t srq_limit;
1208 	uint32_t reserved;
1209 };
1210 
1211 struct ib_uverbs_destroy_srq {
1212 	__aligned_u64 response;
1213 	uint32_t srq_handle;
1214 	uint32_t reserved;
1215 };
1216 
1217 struct ib_uverbs_destroy_srq_resp {
1218 	uint32_t events_reported;
1219 };
1220 
1221 struct ib_uverbs_ex_create_wq  {
1222 	uint32_t comp_mask;
1223 	uint32_t wq_type;
1224 	__aligned_u64 user_handle;
1225 	uint32_t pd_handle;
1226 	uint32_t cq_handle;
1227 	uint32_t max_wr;
1228 	uint32_t max_sge;
1229 	uint32_t create_flags; /* Use enum ib_wq_flags */
1230 	uint32_t reserved;
1231 };
1232 
1233 struct ib_uverbs_ex_create_wq_resp {
1234 	uint32_t comp_mask;
1235 	uint32_t response_length;
1236 	uint32_t wq_handle;
1237 	uint32_t max_wr;
1238 	uint32_t max_sge;
1239 	uint32_t wqn;
1240 };
1241 
1242 struct ib_uverbs_ex_destroy_wq  {
1243 	uint32_t comp_mask;
1244 	uint32_t wq_handle;
1245 };
1246 
1247 struct ib_uverbs_ex_destroy_wq_resp {
1248 	uint32_t comp_mask;
1249 	uint32_t response_length;
1250 	uint32_t events_reported;
1251 	uint32_t reserved;
1252 };
1253 
1254 struct ib_uverbs_ex_modify_wq  {
1255 	uint32_t attr_mask;
1256 	uint32_t wq_handle;
1257 	uint32_t wq_state;
1258 	uint32_t curr_wq_state;
1259 	uint32_t flags; /* Use enum ib_wq_flags */
1260 	uint32_t flags_mask; /* Use enum ib_wq_flags */
1261 };
1262 
1263 /* Prevent memory allocation rather than max expected size */
1264 #define IB_USER_VERBS_MAX_LOG_IND_TBL_SIZE 0x0d
1265 struct ib_uverbs_ex_create_rwq_ind_table  {
1266 	uint32_t comp_mask;
1267 	uint32_t log_ind_tbl_size;
1268 	/* Following are the wq handles according to log_ind_tbl_size
1269 	 * wq_handle1
1270 	 * wq_handle2
1271 	 */
1272 	uint32_t wq_handles[0];
1273 };
1274 
1275 struct ib_uverbs_ex_create_rwq_ind_table_resp {
1276 	uint32_t comp_mask;
1277 	uint32_t response_length;
1278 	uint32_t ind_tbl_handle;
1279 	uint32_t ind_tbl_num;
1280 };
1281 
1282 struct ib_uverbs_ex_destroy_rwq_ind_table  {
1283 	uint32_t comp_mask;
1284 	uint32_t ind_tbl_handle;
1285 };
1286 
1287 struct ib_uverbs_cq_moderation {
1288 	uint16_t cq_count;
1289 	uint16_t cq_period;
1290 };
1291 
1292 struct ib_uverbs_ex_modify_cq {
1293 	uint32_t cq_handle;
1294 	uint32_t attr_mask;
1295 	struct ib_uverbs_cq_moderation attr;
1296 	uint32_t reserved;
1297 };
1298 
1299 #define IB_DEVICE_NAME_MAX 64
1300 
1301 #endif /* IB_USER_VERBS_H */
1302