xref: /linux/include/uapi/rdma/ib_user_verbs.h (revision 26b9906612c3553189d7d1673ee116ffac474d53)
1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
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 {
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 __u64 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 	__u32 event_type;	/* enum ib_event_type */
122 	__u32 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 	__u16     max_cq_moderation_count;
131 	__u16     max_cq_moderation_period;
132 	__u32     reserved;
133 };
134 
135 /*
136  * All commands from userspace should start with a __u32 command field
137  * followed by __u16 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 	__u32 command;
148 	__u16 in_words;
149 	__u16 out_words;
150 };
151 
152 struct ib_uverbs_ex_cmd_hdr {
153 	__aligned_u64 response;
154 	__u16 provider_in_words;
155 	__u16 provider_out_words;
156 	__u32 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 	__u32 async_fd;
166 	__u32 num_comp_vectors;
167 };
168 
169 struct ib_uverbs_query_device {
170 	__aligned_u64 response;
171 	__aligned_u64 driver_data[0];
172 };
173 
174 struct ib_uverbs_query_device_resp {
175 	__aligned_u64 fw_ver;
176 	__be64 node_guid;
177 	__be64 sys_image_guid;
178 	__aligned_u64 max_mr_size;
179 	__aligned_u64 page_size_cap;
180 	__u32 vendor_id;
181 	__u32 vendor_part_id;
182 	__u32 hw_ver;
183 	__u32 max_qp;
184 	__u32 max_qp_wr;
185 	__u32 device_cap_flags;
186 	__u32 max_sge;
187 	__u32 max_sge_rd;
188 	__u32 max_cq;
189 	__u32 max_cqe;
190 	__u32 max_mr;
191 	__u32 max_pd;
192 	__u32 max_qp_rd_atom;
193 	__u32 max_ee_rd_atom;
194 	__u32 max_res_rd_atom;
195 	__u32 max_qp_init_rd_atom;
196 	__u32 max_ee_init_rd_atom;
197 	__u32 atomic_cap;
198 	__u32 max_ee;
199 	__u32 max_rdd;
200 	__u32 max_mw;
201 	__u32 max_raw_ipv6_qp;
202 	__u32 max_raw_ethy_qp;
203 	__u32 max_mcast_grp;
204 	__u32 max_mcast_qp_attach;
205 	__u32 max_total_mcast_qp_attach;
206 	__u32 max_ah;
207 	__u32 max_fmr;
208 	__u32 max_map_per_fmr;
209 	__u32 max_srq;
210 	__u32 max_srq_wr;
211 	__u32 max_srq_sge;
212 	__u16 max_pkeys;
213 	__u8  local_ca_ack_delay;
214 	__u8  phys_port_cnt;
215 	__u8  reserved[4];
216 };
217 
218 struct ib_uverbs_ex_query_device {
219 	__u32 comp_mask;
220 	__u32 reserved;
221 };
222 
223 struct ib_uverbs_odp_caps {
224 	__aligned_u64 general_caps;
225 	struct {
226 		__u32 rc_odp_caps;
227 		__u32 uc_odp_caps;
228 		__u32 ud_odp_caps;
229 	} per_transport_caps;
230 	__u32 reserved;
231 };
232 
233 struct ib_uverbs_rss_caps {
234 	/* Corresponding bit will be set if qp type from
235 	 * 'enum ib_qp_type' is supported, e.g.
236 	 * supported_qpts |= 1 << IB_QPT_UD
237 	 */
238 	__u32 supported_qpts;
239 	__u32 max_rwq_indirection_tables;
240 	__u32 max_rwq_indirection_table_size;
241 	__u32 reserved;
242 };
243 
244 struct ib_uverbs_tm_caps {
245 	/* Max size of rendezvous request message */
246 	__u32 max_rndv_hdr_size;
247 	/* Max number of entries in tag matching list */
248 	__u32 max_num_tags;
249 	/* TM flags */
250 	__u32 flags;
251 	/* Max number of outstanding list operations */
252 	__u32 max_ops;
253 	/* Max number of SGE in tag matching entry */
254 	__u32 max_sge;
255 	__u32 reserved;
256 };
257 
258 struct ib_uverbs_ex_query_device_resp {
259 	struct ib_uverbs_query_device_resp base;
260 	__u32 comp_mask;
261 	__u32 response_length;
262 	struct ib_uverbs_odp_caps odp_caps;
263 	__aligned_u64 timestamp_mask;
264 	__aligned_u64 hca_core_clock; /* in KHZ */
265 	__aligned_u64 device_cap_flags_ex;
266 	struct ib_uverbs_rss_caps rss_caps;
267 	__u32  max_wq_type_rq;
268 	__u32 raw_packet_caps;
269 	struct ib_uverbs_tm_caps tm_caps;
270 	struct ib_uverbs_cq_moderation_caps cq_moderation_caps;
271 };
272 
273 struct ib_uverbs_query_port {
274 	__aligned_u64 response;
275 	__u8  port_num;
276 	__u8  reserved[7];
277 	__aligned_u64 driver_data[0];
278 };
279 
280 struct ib_uverbs_query_port_resp {
281 	__u32 port_cap_flags;
282 	__u32 max_msg_sz;
283 	__u32 bad_pkey_cntr;
284 	__u32 qkey_viol_cntr;
285 	__u32 gid_tbl_len;
286 	__u16 pkey_tbl_len;
287 	__u16 lid;
288 	__u16 sm_lid;
289 	__u8  state;
290 	__u8  max_mtu;
291 	__u8  active_mtu;
292 	__u8  lmc;
293 	__u8  max_vl_num;
294 	__u8  sm_sl;
295 	__u8  subnet_timeout;
296 	__u8  init_type_reply;
297 	__u8  active_width;
298 	__u8  active_speed;
299 	__u8  phys_state;
300 	__u8  link_layer;
301 	__u8  reserved[2];
302 };
303 
304 struct ib_uverbs_alloc_pd {
305 	__aligned_u64 response;
306 	__aligned_u64 driver_data[0];
307 };
308 
309 struct ib_uverbs_alloc_pd_resp {
310 	__u32 pd_handle;
311 };
312 
313 struct ib_uverbs_dealloc_pd {
314 	__u32 pd_handle;
315 };
316 
317 struct ib_uverbs_open_xrcd {
318 	__aligned_u64 response;
319 	__u32 fd;
320 	__u32 oflags;
321 	__aligned_u64 driver_data[0];
322 };
323 
324 struct ib_uverbs_open_xrcd_resp {
325 	__u32 xrcd_handle;
326 };
327 
328 struct ib_uverbs_close_xrcd {
329 	__u32 xrcd_handle;
330 };
331 
332 struct ib_uverbs_reg_mr {
333 	__aligned_u64 response;
334 	__aligned_u64 start;
335 	__aligned_u64 length;
336 	__aligned_u64 hca_va;
337 	__u32 pd_handle;
338 	__u32 access_flags;
339 	__aligned_u64 driver_data[0];
340 };
341 
342 struct ib_uverbs_reg_mr_resp {
343 	__u32 mr_handle;
344 	__u32 lkey;
345 	__u32 rkey;
346 };
347 
348 struct ib_uverbs_rereg_mr {
349 	__aligned_u64 response;
350 	__u32 mr_handle;
351 	__u32 flags;
352 	__aligned_u64 start;
353 	__aligned_u64 length;
354 	__aligned_u64 hca_va;
355 	__u32 pd_handle;
356 	__u32 access_flags;
357 };
358 
359 struct ib_uverbs_rereg_mr_resp {
360 	__u32 lkey;
361 	__u32 rkey;
362 };
363 
364 struct ib_uverbs_dereg_mr {
365 	__u32 mr_handle;
366 };
367 
368 struct ib_uverbs_alloc_mw {
369 	__aligned_u64 response;
370 	__u32 pd_handle;
371 	__u8  mw_type;
372 	__u8  reserved[3];
373 };
374 
375 struct ib_uverbs_alloc_mw_resp {
376 	__u32 mw_handle;
377 	__u32 rkey;
378 };
379 
380 struct ib_uverbs_dealloc_mw {
381 	__u32 mw_handle;
382 };
383 
384 struct ib_uverbs_create_comp_channel {
385 	__aligned_u64 response;
386 };
387 
388 struct ib_uverbs_create_comp_channel_resp {
389 	__u32 fd;
390 };
391 
392 struct ib_uverbs_create_cq {
393 	__aligned_u64 response;
394 	__aligned_u64 user_handle;
395 	__u32 cqe;
396 	__u32 comp_vector;
397 	__s32 comp_channel;
398 	__u32 reserved;
399 	__aligned_u64 driver_data[0];
400 };
401 
402 enum ib_uverbs_ex_create_cq_flags {
403 	IB_UVERBS_CQ_FLAGS_TIMESTAMP_COMPLETION = 1 << 0,
404 	IB_UVERBS_CQ_FLAGS_IGNORE_OVERRUN = 1 << 1,
405 };
406 
407 struct ib_uverbs_ex_create_cq {
408 	__aligned_u64 user_handle;
409 	__u32 cqe;
410 	__u32 comp_vector;
411 	__s32 comp_channel;
412 	__u32 comp_mask;
413 	__u32 flags;  /* bitmask of ib_uverbs_ex_create_cq_flags */
414 	__u32 reserved;
415 };
416 
417 struct ib_uverbs_create_cq_resp {
418 	__u32 cq_handle;
419 	__u32 cqe;
420 };
421 
422 struct ib_uverbs_ex_create_cq_resp {
423 	struct ib_uverbs_create_cq_resp base;
424 	__u32 comp_mask;
425 	__u32 response_length;
426 };
427 
428 struct ib_uverbs_resize_cq {
429 	__aligned_u64 response;
430 	__u32 cq_handle;
431 	__u32 cqe;
432 	__aligned_u64 driver_data[0];
433 };
434 
435 struct ib_uverbs_resize_cq_resp {
436 	__u32 cqe;
437 	__u32 reserved;
438 	__aligned_u64 driver_data[0];
439 };
440 
441 struct ib_uverbs_poll_cq {
442 	__aligned_u64 response;
443 	__u32 cq_handle;
444 	__u32 ne;
445 };
446 
447 struct ib_uverbs_wc {
448 	__aligned_u64 wr_id;
449 	__u32 status;
450 	__u32 opcode;
451 	__u32 vendor_err;
452 	__u32 byte_len;
453 	union {
454 		__be32 imm_data;
455 		__u32 invalidate_rkey;
456 	} ex;
457 	__u32 qp_num;
458 	__u32 src_qp;
459 	__u32 wc_flags;
460 	__u16 pkey_index;
461 	__u16 slid;
462 	__u8 sl;
463 	__u8 dlid_path_bits;
464 	__u8 port_num;
465 	__u8 reserved;
466 };
467 
468 struct ib_uverbs_poll_cq_resp {
469 	__u32 count;
470 	__u32 reserved;
471 	struct ib_uverbs_wc wc[0];
472 };
473 
474 struct ib_uverbs_req_notify_cq {
475 	__u32 cq_handle;
476 	__u32 solicited_only;
477 };
478 
479 struct ib_uverbs_destroy_cq {
480 	__aligned_u64 response;
481 	__u32 cq_handle;
482 	__u32 reserved;
483 };
484 
485 struct ib_uverbs_destroy_cq_resp {
486 	__u32 comp_events_reported;
487 	__u32 async_events_reported;
488 };
489 
490 struct ib_uverbs_global_route {
491 	__u8  dgid[16];
492 	__u32 flow_label;
493 	__u8  sgid_index;
494 	__u8  hop_limit;
495 	__u8  traffic_class;
496 	__u8  reserved;
497 };
498 
499 struct ib_uverbs_ah_attr {
500 	struct ib_uverbs_global_route grh;
501 	__u16 dlid;
502 	__u8  sl;
503 	__u8  src_path_bits;
504 	__u8  static_rate;
505 	__u8  is_global;
506 	__u8  port_num;
507 	__u8  reserved;
508 };
509 
510 struct ib_uverbs_qp_attr {
511 	__u32	qp_attr_mask;
512 	__u32	qp_state;
513 	__u32	cur_qp_state;
514 	__u32	path_mtu;
515 	__u32	path_mig_state;
516 	__u32	qkey;
517 	__u32	rq_psn;
518 	__u32	sq_psn;
519 	__u32	dest_qp_num;
520 	__u32	qp_access_flags;
521 
522 	struct ib_uverbs_ah_attr ah_attr;
523 	struct ib_uverbs_ah_attr alt_ah_attr;
524 
525 	/* ib_qp_cap */
526 	__u32	max_send_wr;
527 	__u32	max_recv_wr;
528 	__u32	max_send_sge;
529 	__u32	max_recv_sge;
530 	__u32	max_inline_data;
531 
532 	__u16	pkey_index;
533 	__u16	alt_pkey_index;
534 	__u8	en_sqd_async_notify;
535 	__u8	sq_draining;
536 	__u8	max_rd_atomic;
537 	__u8	max_dest_rd_atomic;
538 	__u8	min_rnr_timer;
539 	__u8	port_num;
540 	__u8	timeout;
541 	__u8	retry_cnt;
542 	__u8	rnr_retry;
543 	__u8	alt_port_num;
544 	__u8	alt_timeout;
545 	__u8	reserved[5];
546 };
547 
548 struct ib_uverbs_create_qp {
549 	__aligned_u64 response;
550 	__aligned_u64 user_handle;
551 	__u32 pd_handle;
552 	__u32 send_cq_handle;
553 	__u32 recv_cq_handle;
554 	__u32 srq_handle;
555 	__u32 max_send_wr;
556 	__u32 max_recv_wr;
557 	__u32 max_send_sge;
558 	__u32 max_recv_sge;
559 	__u32 max_inline_data;
560 	__u8  sq_sig_all;
561 	__u8  qp_type;
562 	__u8  is_srq;
563 	__u8  reserved;
564 	__aligned_u64 driver_data[0];
565 };
566 
567 enum ib_uverbs_create_qp_mask {
568 	IB_UVERBS_CREATE_QP_MASK_IND_TABLE = 1UL << 0,
569 };
570 
571 enum {
572 	IB_UVERBS_CREATE_QP_SUP_COMP_MASK = IB_UVERBS_CREATE_QP_MASK_IND_TABLE,
573 };
574 
575 enum {
576 	/*
577 	 * This value is equal to IB_QP_DEST_QPN.
578 	 */
579 	IB_USER_LEGACY_LAST_QP_ATTR_MASK = 1ULL << 20,
580 };
581 
582 enum {
583 	/*
584 	 * This value is equal to IB_QP_RATE_LIMIT.
585 	 */
586 	IB_USER_LAST_QP_ATTR_MASK = 1ULL << 25,
587 };
588 
589 struct ib_uverbs_ex_create_qp {
590 	__aligned_u64 user_handle;
591 	__u32 pd_handle;
592 	__u32 send_cq_handle;
593 	__u32 recv_cq_handle;
594 	__u32 srq_handle;
595 	__u32 max_send_wr;
596 	__u32 max_recv_wr;
597 	__u32 max_send_sge;
598 	__u32 max_recv_sge;
599 	__u32 max_inline_data;
600 	__u8  sq_sig_all;
601 	__u8  qp_type;
602 	__u8  is_srq;
603 	__u8 reserved;
604 	__u32 comp_mask;
605 	__u32 create_flags;
606 	__u32 rwq_ind_tbl_handle;
607 	__u32  source_qpn;
608 };
609 
610 struct ib_uverbs_open_qp {
611 	__aligned_u64 response;
612 	__aligned_u64 user_handle;
613 	__u32 pd_handle;
614 	__u32 qpn;
615 	__u8  qp_type;
616 	__u8  reserved[7];
617 	__aligned_u64 driver_data[0];
618 };
619 
620 /* also used for open response */
621 struct ib_uverbs_create_qp_resp {
622 	__u32 qp_handle;
623 	__u32 qpn;
624 	__u32 max_send_wr;
625 	__u32 max_recv_wr;
626 	__u32 max_send_sge;
627 	__u32 max_recv_sge;
628 	__u32 max_inline_data;
629 	__u32 reserved;
630 };
631 
632 struct ib_uverbs_ex_create_qp_resp {
633 	struct ib_uverbs_create_qp_resp base;
634 	__u32 comp_mask;
635 	__u32 response_length;
636 };
637 
638 /*
639  * This struct needs to remain a multiple of 8 bytes to keep the
640  * alignment of the modify QP parameters.
641  */
642 struct ib_uverbs_qp_dest {
643 	__u8  dgid[16];
644 	__u32 flow_label;
645 	__u16 dlid;
646 	__u16 reserved;
647 	__u8  sgid_index;
648 	__u8  hop_limit;
649 	__u8  traffic_class;
650 	__u8  sl;
651 	__u8  src_path_bits;
652 	__u8  static_rate;
653 	__u8  is_global;
654 	__u8  port_num;
655 };
656 
657 struct ib_uverbs_query_qp {
658 	__aligned_u64 response;
659 	__u32 qp_handle;
660 	__u32 attr_mask;
661 	__aligned_u64 driver_data[0];
662 };
663 
664 struct ib_uverbs_query_qp_resp {
665 	struct ib_uverbs_qp_dest dest;
666 	struct ib_uverbs_qp_dest alt_dest;
667 	__u32 max_send_wr;
668 	__u32 max_recv_wr;
669 	__u32 max_send_sge;
670 	__u32 max_recv_sge;
671 	__u32 max_inline_data;
672 	__u32 qkey;
673 	__u32 rq_psn;
674 	__u32 sq_psn;
675 	__u32 dest_qp_num;
676 	__u32 qp_access_flags;
677 	__u16 pkey_index;
678 	__u16 alt_pkey_index;
679 	__u8  qp_state;
680 	__u8  cur_qp_state;
681 	__u8  path_mtu;
682 	__u8  path_mig_state;
683 	__u8  sq_draining;
684 	__u8  max_rd_atomic;
685 	__u8  max_dest_rd_atomic;
686 	__u8  min_rnr_timer;
687 	__u8  port_num;
688 	__u8  timeout;
689 	__u8  retry_cnt;
690 	__u8  rnr_retry;
691 	__u8  alt_port_num;
692 	__u8  alt_timeout;
693 	__u8  sq_sig_all;
694 	__u8  reserved[5];
695 	__aligned_u64 driver_data[0];
696 };
697 
698 struct ib_uverbs_modify_qp {
699 	struct ib_uverbs_qp_dest dest;
700 	struct ib_uverbs_qp_dest alt_dest;
701 	__u32 qp_handle;
702 	__u32 attr_mask;
703 	__u32 qkey;
704 	__u32 rq_psn;
705 	__u32 sq_psn;
706 	__u32 dest_qp_num;
707 	__u32 qp_access_flags;
708 	__u16 pkey_index;
709 	__u16 alt_pkey_index;
710 	__u8  qp_state;
711 	__u8  cur_qp_state;
712 	__u8  path_mtu;
713 	__u8  path_mig_state;
714 	__u8  en_sqd_async_notify;
715 	__u8  max_rd_atomic;
716 	__u8  max_dest_rd_atomic;
717 	__u8  min_rnr_timer;
718 	__u8  port_num;
719 	__u8  timeout;
720 	__u8  retry_cnt;
721 	__u8  rnr_retry;
722 	__u8  alt_port_num;
723 	__u8  alt_timeout;
724 	__u8  reserved[2];
725 	__aligned_u64 driver_data[0];
726 };
727 
728 struct ib_uverbs_ex_modify_qp {
729 	struct ib_uverbs_modify_qp base;
730 	__u32	rate_limit;
731 	__u32	reserved;
732 };
733 
734 struct ib_uverbs_modify_qp_resp {
735 };
736 
737 struct ib_uverbs_ex_modify_qp_resp {
738 	__u32  comp_mask;
739 	__u32  response_length;
740 };
741 
742 struct ib_uverbs_destroy_qp {
743 	__aligned_u64 response;
744 	__u32 qp_handle;
745 	__u32 reserved;
746 };
747 
748 struct ib_uverbs_destroy_qp_resp {
749 	__u32 events_reported;
750 };
751 
752 /*
753  * The ib_uverbs_sge structure isn't used anywhere, since we assume
754  * the ib_sge structure is packed the same way on 32-bit and 64-bit
755  * architectures in both kernel and user space.  It's just here to
756  * document the ABI.
757  */
758 struct ib_uverbs_sge {
759 	__aligned_u64 addr;
760 	__u32 length;
761 	__u32 lkey;
762 };
763 
764 struct ib_uverbs_send_wr {
765 	__aligned_u64 wr_id;
766 	__u32 num_sge;
767 	__u32 opcode;
768 	__u32 send_flags;
769 	union {
770 		__be32 imm_data;
771 		__u32 invalidate_rkey;
772 	} ex;
773 	union {
774 		struct {
775 			__aligned_u64 remote_addr;
776 			__u32 rkey;
777 			__u32 reserved;
778 		} rdma;
779 		struct {
780 			__aligned_u64 remote_addr;
781 			__aligned_u64 compare_add;
782 			__aligned_u64 swap;
783 			__u32 rkey;
784 			__u32 reserved;
785 		} atomic;
786 		struct {
787 			__u32 ah;
788 			__u32 remote_qpn;
789 			__u32 remote_qkey;
790 			__u32 reserved;
791 		} ud;
792 	} wr;
793 };
794 
795 struct ib_uverbs_post_send {
796 	__aligned_u64 response;
797 	__u32 qp_handle;
798 	__u32 wr_count;
799 	__u32 sge_count;
800 	__u32 wqe_size;
801 	struct ib_uverbs_send_wr send_wr[0];
802 };
803 
804 struct ib_uverbs_post_send_resp {
805 	__u32 bad_wr;
806 };
807 
808 struct ib_uverbs_recv_wr {
809 	__aligned_u64 wr_id;
810 	__u32 num_sge;
811 	__u32 reserved;
812 };
813 
814 struct ib_uverbs_post_recv {
815 	__aligned_u64 response;
816 	__u32 qp_handle;
817 	__u32 wr_count;
818 	__u32 sge_count;
819 	__u32 wqe_size;
820 	struct ib_uverbs_recv_wr recv_wr[0];
821 };
822 
823 struct ib_uverbs_post_recv_resp {
824 	__u32 bad_wr;
825 };
826 
827 struct ib_uverbs_post_srq_recv {
828 	__aligned_u64 response;
829 	__u32 srq_handle;
830 	__u32 wr_count;
831 	__u32 sge_count;
832 	__u32 wqe_size;
833 	struct ib_uverbs_recv_wr recv[0];
834 };
835 
836 struct ib_uverbs_post_srq_recv_resp {
837 	__u32 bad_wr;
838 };
839 
840 struct ib_uverbs_create_ah {
841 	__aligned_u64 response;
842 	__aligned_u64 user_handle;
843 	__u32 pd_handle;
844 	__u32 reserved;
845 	struct ib_uverbs_ah_attr attr;
846 };
847 
848 struct ib_uverbs_create_ah_resp {
849 	__u32 ah_handle;
850 };
851 
852 struct ib_uverbs_destroy_ah {
853 	__u32 ah_handle;
854 };
855 
856 struct ib_uverbs_attach_mcast {
857 	__u8  gid[16];
858 	__u32 qp_handle;
859 	__u16 mlid;
860 	__u16 reserved;
861 	__aligned_u64 driver_data[0];
862 };
863 
864 struct ib_uverbs_detach_mcast {
865 	__u8  gid[16];
866 	__u32 qp_handle;
867 	__u16 mlid;
868 	__u16 reserved;
869 	__aligned_u64 driver_data[0];
870 };
871 
872 struct ib_uverbs_flow_spec_hdr {
873 	__u32 type;
874 	__u16 size;
875 	__u16 reserved;
876 	/* followed by flow_spec */
877 	__aligned_u64 flow_spec_data[0];
878 };
879 
880 struct ib_uverbs_flow_eth_filter {
881 	__u8  dst_mac[6];
882 	__u8  src_mac[6];
883 	__be16 ether_type;
884 	__be16 vlan_tag;
885 };
886 
887 struct ib_uverbs_flow_spec_eth {
888 	union {
889 		struct ib_uverbs_flow_spec_hdr hdr;
890 		struct {
891 			__u32 type;
892 			__u16 size;
893 			__u16 reserved;
894 		};
895 	};
896 	struct ib_uverbs_flow_eth_filter val;
897 	struct ib_uverbs_flow_eth_filter mask;
898 };
899 
900 struct ib_uverbs_flow_ipv4_filter {
901 	__be32 src_ip;
902 	__be32 dst_ip;
903 	__u8	proto;
904 	__u8	tos;
905 	__u8	ttl;
906 	__u8	flags;
907 };
908 
909 struct ib_uverbs_flow_spec_ipv4 {
910 	union {
911 		struct ib_uverbs_flow_spec_hdr hdr;
912 		struct {
913 			__u32 type;
914 			__u16 size;
915 			__u16 reserved;
916 		};
917 	};
918 	struct ib_uverbs_flow_ipv4_filter val;
919 	struct ib_uverbs_flow_ipv4_filter mask;
920 };
921 
922 struct ib_uverbs_flow_tcp_udp_filter {
923 	__be16 dst_port;
924 	__be16 src_port;
925 };
926 
927 struct ib_uverbs_flow_spec_tcp_udp {
928 	union {
929 		struct ib_uverbs_flow_spec_hdr hdr;
930 		struct {
931 			__u32 type;
932 			__u16 size;
933 			__u16 reserved;
934 		};
935 	};
936 	struct ib_uverbs_flow_tcp_udp_filter val;
937 	struct ib_uverbs_flow_tcp_udp_filter mask;
938 };
939 
940 struct ib_uverbs_flow_ipv6_filter {
941 	__u8    src_ip[16];
942 	__u8    dst_ip[16];
943 	__be32	flow_label;
944 	__u8	next_hdr;
945 	__u8	traffic_class;
946 	__u8	hop_limit;
947 	__u8	reserved;
948 };
949 
950 struct ib_uverbs_flow_spec_ipv6 {
951 	union {
952 		struct ib_uverbs_flow_spec_hdr hdr;
953 		struct {
954 			__u32 type;
955 			__u16 size;
956 			__u16 reserved;
957 		};
958 	};
959 	struct ib_uverbs_flow_ipv6_filter val;
960 	struct ib_uverbs_flow_ipv6_filter mask;
961 };
962 
963 struct ib_uverbs_flow_spec_action_tag {
964 	union {
965 		struct ib_uverbs_flow_spec_hdr hdr;
966 		struct {
967 			__u32 type;
968 			__u16 size;
969 			__u16 reserved;
970 		};
971 	};
972 	__u32			      tag_id;
973 	__u32			      reserved1;
974 };
975 
976 struct ib_uverbs_flow_spec_action_drop {
977 	union {
978 		struct ib_uverbs_flow_spec_hdr hdr;
979 		struct {
980 			__u32 type;
981 			__u16 size;
982 			__u16 reserved;
983 		};
984 	};
985 };
986 
987 struct ib_uverbs_flow_tunnel_filter {
988 	__be32 tunnel_id;
989 };
990 
991 struct ib_uverbs_flow_spec_tunnel {
992 	union {
993 		struct ib_uverbs_flow_spec_hdr hdr;
994 		struct {
995 			__u32 type;
996 			__u16 size;
997 			__u16 reserved;
998 		};
999 	};
1000 	struct ib_uverbs_flow_tunnel_filter val;
1001 	struct ib_uverbs_flow_tunnel_filter mask;
1002 };
1003 
1004 struct ib_uverbs_flow_attr {
1005 	__u32 type;
1006 	__u16 size;
1007 	__u16 priority;
1008 	__u8  num_of_specs;
1009 	__u8  reserved[2];
1010 	__u8  port;
1011 	__u32 flags;
1012 	/* Following are the optional layers according to user request
1013 	 * struct ib_flow_spec_xxx
1014 	 * struct ib_flow_spec_yyy
1015 	 */
1016 	struct ib_uverbs_flow_spec_hdr flow_specs[0];
1017 };
1018 
1019 struct ib_uverbs_create_flow  {
1020 	__u32 comp_mask;
1021 	__u32 qp_handle;
1022 	struct ib_uverbs_flow_attr flow_attr;
1023 };
1024 
1025 struct ib_uverbs_create_flow_resp {
1026 	__u32 comp_mask;
1027 	__u32 flow_handle;
1028 };
1029 
1030 struct ib_uverbs_destroy_flow  {
1031 	__u32 comp_mask;
1032 	__u32 flow_handle;
1033 };
1034 
1035 struct ib_uverbs_create_srq {
1036 	__aligned_u64 response;
1037 	__aligned_u64 user_handle;
1038 	__u32 pd_handle;
1039 	__u32 max_wr;
1040 	__u32 max_sge;
1041 	__u32 srq_limit;
1042 	__aligned_u64 driver_data[0];
1043 };
1044 
1045 struct ib_uverbs_create_xsrq {
1046 	__aligned_u64 response;
1047 	__aligned_u64 user_handle;
1048 	__u32 srq_type;
1049 	__u32 pd_handle;
1050 	__u32 max_wr;
1051 	__u32 max_sge;
1052 	__u32 srq_limit;
1053 	__u32 max_num_tags;
1054 	__u32 xrcd_handle;
1055 	__u32 cq_handle;
1056 	__aligned_u64 driver_data[0];
1057 };
1058 
1059 struct ib_uverbs_create_srq_resp {
1060 	__u32 srq_handle;
1061 	__u32 max_wr;
1062 	__u32 max_sge;
1063 	__u32 srqn;
1064 };
1065 
1066 struct ib_uverbs_modify_srq {
1067 	__u32 srq_handle;
1068 	__u32 attr_mask;
1069 	__u32 max_wr;
1070 	__u32 srq_limit;
1071 	__aligned_u64 driver_data[0];
1072 };
1073 
1074 struct ib_uverbs_query_srq {
1075 	__aligned_u64 response;
1076 	__u32 srq_handle;
1077 	__u32 reserved;
1078 	__aligned_u64 driver_data[0];
1079 };
1080 
1081 struct ib_uverbs_query_srq_resp {
1082 	__u32 max_wr;
1083 	__u32 max_sge;
1084 	__u32 srq_limit;
1085 	__u32 reserved;
1086 };
1087 
1088 struct ib_uverbs_destroy_srq {
1089 	__aligned_u64 response;
1090 	__u32 srq_handle;
1091 	__u32 reserved;
1092 };
1093 
1094 struct ib_uverbs_destroy_srq_resp {
1095 	__u32 events_reported;
1096 };
1097 
1098 struct ib_uverbs_ex_create_wq  {
1099 	__u32 comp_mask;
1100 	__u32 wq_type;
1101 	__aligned_u64 user_handle;
1102 	__u32 pd_handle;
1103 	__u32 cq_handle;
1104 	__u32 max_wr;
1105 	__u32 max_sge;
1106 	__u32 create_flags; /* Use enum ib_wq_flags */
1107 	__u32 reserved;
1108 };
1109 
1110 struct ib_uverbs_ex_create_wq_resp {
1111 	__u32 comp_mask;
1112 	__u32 response_length;
1113 	__u32 wq_handle;
1114 	__u32 max_wr;
1115 	__u32 max_sge;
1116 	__u32 wqn;
1117 };
1118 
1119 struct ib_uverbs_ex_destroy_wq  {
1120 	__u32 comp_mask;
1121 	__u32 wq_handle;
1122 };
1123 
1124 struct ib_uverbs_ex_destroy_wq_resp {
1125 	__u32 comp_mask;
1126 	__u32 response_length;
1127 	__u32 events_reported;
1128 	__u32 reserved;
1129 };
1130 
1131 struct ib_uverbs_ex_modify_wq  {
1132 	__u32 attr_mask;
1133 	__u32 wq_handle;
1134 	__u32 wq_state;
1135 	__u32 curr_wq_state;
1136 	__u32 flags; /* Use enum ib_wq_flags */
1137 	__u32 flags_mask; /* Use enum ib_wq_flags */
1138 };
1139 
1140 /* Prevent memory allocation rather than max expected size */
1141 #define IB_USER_VERBS_MAX_LOG_IND_TBL_SIZE 0x0d
1142 struct ib_uverbs_ex_create_rwq_ind_table  {
1143 	__u32 comp_mask;
1144 	__u32 log_ind_tbl_size;
1145 	/* Following are the wq handles according to log_ind_tbl_size
1146 	 * wq_handle1
1147 	 * wq_handle2
1148 	 */
1149 	__u32 wq_handles[0];
1150 };
1151 
1152 struct ib_uverbs_ex_create_rwq_ind_table_resp {
1153 	__u32 comp_mask;
1154 	__u32 response_length;
1155 	__u32 ind_tbl_handle;
1156 	__u32 ind_tbl_num;
1157 };
1158 
1159 struct ib_uverbs_ex_destroy_rwq_ind_table  {
1160 	__u32 comp_mask;
1161 	__u32 ind_tbl_handle;
1162 };
1163 
1164 struct ib_uverbs_cq_moderation {
1165 	__u16 cq_count;
1166 	__u16 cq_period;
1167 };
1168 
1169 struct ib_uverbs_ex_modify_cq {
1170 	__u32 cq_handle;
1171 	__u32 attr_mask;
1172 	struct ib_uverbs_cq_moderation attr;
1173 	__u32 reserved;
1174 };
1175 
1176 #define IB_DEVICE_NAME_MAX 64
1177 
1178 #endif /* IB_USER_VERBS_H */
1179