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 __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 	__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 	__be64 node_guid;
178 	__be64 sys_image_guid;
179 	__aligned_u64 max_mr_size;
180 	__aligned_u64 page_size_cap;
181 	__u32 vendor_id;
182 	__u32 vendor_part_id;
183 	__u32 hw_ver;
184 	__u32 max_qp;
185 	__u32 max_qp_wr;
186 	__u32 device_cap_flags;
187 	__u32 max_sge;
188 	__u32 max_sge_rd;
189 	__u32 max_cq;
190 	__u32 max_cqe;
191 	__u32 max_mr;
192 	__u32 max_pd;
193 	__u32 max_qp_rd_atom;
194 	__u32 max_ee_rd_atom;
195 	__u32 max_res_rd_atom;
196 	__u32 max_qp_init_rd_atom;
197 	__u32 max_ee_init_rd_atom;
198 	__u32 atomic_cap;
199 	__u32 max_ee;
200 	__u32 max_rdd;
201 	__u32 max_mw;
202 	__u32 max_raw_ipv6_qp;
203 	__u32 max_raw_ethy_qp;
204 	__u32 max_mcast_grp;
205 	__u32 max_mcast_qp_attach;
206 	__u32 max_total_mcast_qp_attach;
207 	__u32 max_ah;
208 	__u32 max_fmr;
209 	__u32 max_map_per_fmr;
210 	__u32 max_srq;
211 	__u32 max_srq_wr;
212 	__u32 max_srq_sge;
213 	__u16 max_pkeys;
214 	__u8  local_ca_ack_delay;
215 	__u8  phys_port_cnt;
216 	__u8  reserved[4];
217 };
218 
219 struct ib_uverbs_ex_query_device {
220 	__u32 comp_mask;
221 	__u32 reserved;
222 };
223 
224 struct ib_uverbs_odp_caps {
225 	__aligned_u64 general_caps;
226 	struct {
227 		__u32 rc_odp_caps;
228 		__u32 uc_odp_caps;
229 		__u32 ud_odp_caps;
230 	} per_transport_caps;
231 	__u32 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 	__u32 supported_qpts;
240 	__u32 max_rwq_indirection_tables;
241 	__u32 max_rwq_indirection_table_size;
242 	__u32 reserved;
243 };
244 
245 struct ib_uverbs_tm_caps {
246 	/* Max size of rendezvous request message */
247 	__u32 max_rndv_hdr_size;
248 	/* Max number of entries in tag matching list */
249 	__u32 max_num_tags;
250 	/* TM flags */
251 	__u32 flags;
252 	/* Max number of outstanding list operations */
253 	__u32 max_ops;
254 	/* Max number of SGE in tag matching entry */
255 	__u32 max_sge;
256 	__u32 reserved;
257 };
258 
259 struct ib_uverbs_ex_query_device_resp {
260 	struct ib_uverbs_query_device_resp base;
261 	__u32 comp_mask;
262 	__u32 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 	__u32  max_wq_type_rq;
269 	__u32 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 	__u32 xrc_odp_caps;
274 	__u32 reserved;
275 };
276 
277 struct ib_uverbs_query_port {
278 	__aligned_u64 response;
279 	__u8  port_num;
280 	__u8  reserved[7];
281 	__aligned_u64 driver_data[0];
282 };
283 
284 struct ib_uverbs_query_port_resp {
285 	__u32 port_cap_flags;		/* see ib_uverbs_query_port_cap_flags */
286 	__u32 max_msg_sz;
287 	__u32 bad_pkey_cntr;
288 	__u32 qkey_viol_cntr;
289 	__u32 gid_tbl_len;
290 	__u16 pkey_tbl_len;
291 	__u16 lid;
292 	__u16 sm_lid;
293 	__u8  state;
294 	__u8  max_mtu;
295 	__u8  active_mtu;
296 	__u8  lmc;
297 	__u8  max_vl_num;
298 	__u8  sm_sl;
299 	__u8  subnet_timeout;
300 	__u8  init_type_reply;
301 	__u8  active_width;
302 	__u8  active_speed;
303 	__u8  phys_state;
304 	__u8  link_layer;
305 	__u8  flags;			/* see ib_uverbs_query_port_flags */
306 	__u8  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 	__u32 pd_handle;
316 	__u32 driver_data[0];
317 };
318 
319 struct ib_uverbs_dealloc_pd {
320 	__u32 pd_handle;
321 };
322 
323 struct ib_uverbs_open_xrcd {
324 	__aligned_u64 response;
325 	__u32 fd;
326 	__u32 oflags;
327 	__aligned_u64 driver_data[0];
328 };
329 
330 struct ib_uverbs_open_xrcd_resp {
331 	__u32 xrcd_handle;
332 	__u32 driver_data[0];
333 };
334 
335 struct ib_uverbs_close_xrcd {
336 	__u32 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 	__u32 pd_handle;
345 	__u32 access_flags;
346 	__aligned_u64 driver_data[0];
347 };
348 
349 struct ib_uverbs_reg_mr_resp {
350 	__u32 mr_handle;
351 	__u32 lkey;
352 	__u32 rkey;
353 	__u32 driver_data[0];
354 };
355 
356 struct ib_uverbs_rereg_mr {
357 	__aligned_u64 response;
358 	__u32 mr_handle;
359 	__u32 flags;
360 	__aligned_u64 start;
361 	__aligned_u64 length;
362 	__aligned_u64 hca_va;
363 	__u32 pd_handle;
364 	__u32 access_flags;
365 	__aligned_u64 driver_data[0];
366 };
367 
368 struct ib_uverbs_rereg_mr_resp {
369 	__u32 lkey;
370 	__u32 rkey;
371 	__aligned_u64 driver_data[0];
372 };
373 
374 struct ib_uverbs_dereg_mr {
375 	__u32 mr_handle;
376 };
377 
378 struct ib_uverbs_alloc_mw {
379 	__aligned_u64 response;
380 	__u32 pd_handle;
381 	__u8  mw_type;
382 	__u8  reserved[3];
383 	__aligned_u64 driver_data[0];
384 };
385 
386 struct ib_uverbs_alloc_mw_resp {
387 	__u32 mw_handle;
388 	__u32 rkey;
389 	__aligned_u64 driver_data[0];
390 };
391 
392 struct ib_uverbs_dealloc_mw {
393 	__u32 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 	__u32 fd;
402 };
403 
404 struct ib_uverbs_create_cq {
405 	__aligned_u64 response;
406 	__aligned_u64 user_handle;
407 	__u32 cqe;
408 	__u32 comp_vector;
409 	__s32 comp_channel;
410 	__u32 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 	__u32 cqe;
422 	__u32 comp_vector;
423 	__s32 comp_channel;
424 	__u32 comp_mask;
425 	__u32 flags;  /* bitmask of ib_uverbs_ex_create_cq_flags */
426 	__u32 reserved;
427 };
428 
429 struct ib_uverbs_create_cq_resp {
430 	__u32 cq_handle;
431 	__u32 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 	__u32 comp_mask;
438 	__u32 response_length;
439 };
440 
441 struct ib_uverbs_resize_cq {
442 	__aligned_u64 response;
443 	__u32 cq_handle;
444 	__u32 cqe;
445 	__aligned_u64 driver_data[0];
446 };
447 
448 struct ib_uverbs_resize_cq_resp {
449 	__u32 cqe;
450 	__u32 reserved;
451 	__aligned_u64 driver_data[0];
452 };
453 
454 struct ib_uverbs_poll_cq {
455 	__aligned_u64 response;
456 	__u32 cq_handle;
457 	__u32 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 	__u32 status;
474 	__u32 opcode;
475 	__u32 vendor_err;
476 	__u32 byte_len;
477 	union {
478 		__be32 imm_data;
479 		__u32 invalidate_rkey;
480 	} ex;
481 	__u32 qp_num;
482 	__u32 src_qp;
483 	__u32 wc_flags;
484 	__u16 pkey_index;
485 	__u16 slid;
486 	__u8 sl;
487 	__u8 dlid_path_bits;
488 	__u8 port_num;
489 	__u8 reserved;
490 };
491 
492 struct ib_uverbs_poll_cq_resp {
493 	__u32 count;
494 	__u32 reserved;
495 	struct ib_uverbs_wc wc[0];
496 };
497 
498 struct ib_uverbs_req_notify_cq {
499 	__u32 cq_handle;
500 	__u32 solicited_only;
501 };
502 
503 struct ib_uverbs_destroy_cq {
504 	__aligned_u64 response;
505 	__u32 cq_handle;
506 	__u32 reserved;
507 };
508 
509 struct ib_uverbs_destroy_cq_resp {
510 	__u32 comp_events_reported;
511 	__u32 async_events_reported;
512 };
513 
514 struct ib_uverbs_global_route {
515 	__u8  dgid[16];
516 	__u32 flow_label;
517 	__u8  sgid_index;
518 	__u8  hop_limit;
519 	__u8  traffic_class;
520 	__u8  reserved;
521 };
522 
523 struct ib_uverbs_ah_attr {
524 	struct ib_uverbs_global_route grh;
525 	__u16 dlid;
526 	__u8  sl;
527 	__u8  src_path_bits;
528 	__u8  static_rate;
529 	__u8  is_global;
530 	__u8  port_num;
531 	__u8  reserved;
532 };
533 
534 struct ib_uverbs_qp_attr {
535 	__u32	qp_attr_mask;
536 	__u32	qp_state;
537 	__u32	cur_qp_state;
538 	__u32	path_mtu;
539 	__u32	path_mig_state;
540 	__u32	qkey;
541 	__u32	rq_psn;
542 	__u32	sq_psn;
543 	__u32	dest_qp_num;
544 	__u32	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 	__u32	max_send_wr;
551 	__u32	max_recv_wr;
552 	__u32	max_send_sge;
553 	__u32	max_recv_sge;
554 	__u32	max_inline_data;
555 
556 	__u16	pkey_index;
557 	__u16	alt_pkey_index;
558 	__u8	en_sqd_async_notify;
559 	__u8	sq_draining;
560 	__u8	max_rd_atomic;
561 	__u8	max_dest_rd_atomic;
562 	__u8	min_rnr_timer;
563 	__u8	port_num;
564 	__u8	timeout;
565 	__u8	retry_cnt;
566 	__u8	rnr_retry;
567 	__u8	alt_port_num;
568 	__u8	alt_timeout;
569 	__u8	reserved[5];
570 };
571 
572 struct ib_uverbs_create_qp {
573 	__aligned_u64 response;
574 	__aligned_u64 user_handle;
575 	__u32 pd_handle;
576 	__u32 send_cq_handle;
577 	__u32 recv_cq_handle;
578 	__u32 srq_handle;
579 	__u32 max_send_wr;
580 	__u32 max_recv_wr;
581 	__u32 max_send_sge;
582 	__u32 max_recv_sge;
583 	__u32 max_inline_data;
584 	__u8  sq_sig_all;
585 	__u8  qp_type;
586 	__u8  is_srq;
587 	__u8  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 enum {
600 	/*
601 	 * This value is equal to IB_QP_DEST_QPN.
602 	 */
603 	IB_USER_LEGACY_LAST_QP_ATTR_MASK = 1ULL << 20,
604 };
605 
606 enum {
607 	/*
608 	 * This value is equal to IB_QP_RATE_LIMIT.
609 	 */
610 	IB_USER_LAST_QP_ATTR_MASK = 1ULL << 25,
611 };
612 
613 struct ib_uverbs_ex_create_qp {
614 	__aligned_u64 user_handle;
615 	__u32 pd_handle;
616 	__u32 send_cq_handle;
617 	__u32 recv_cq_handle;
618 	__u32 srq_handle;
619 	__u32 max_send_wr;
620 	__u32 max_recv_wr;
621 	__u32 max_send_sge;
622 	__u32 max_recv_sge;
623 	__u32 max_inline_data;
624 	__u8  sq_sig_all;
625 	__u8  qp_type;
626 	__u8  is_srq;
627 	__u8 reserved;
628 	__u32 comp_mask;
629 	__u32 create_flags;
630 	__u32 rwq_ind_tbl_handle;
631 	__u32  source_qpn;
632 };
633 
634 struct ib_uverbs_open_qp {
635 	__aligned_u64 response;
636 	__aligned_u64 user_handle;
637 	__u32 pd_handle;
638 	__u32 qpn;
639 	__u8  qp_type;
640 	__u8  reserved[7];
641 	__aligned_u64 driver_data[0];
642 };
643 
644 /* also used for open response */
645 struct ib_uverbs_create_qp_resp {
646 	__u32 qp_handle;
647 	__u32 qpn;
648 	__u32 max_send_wr;
649 	__u32 max_recv_wr;
650 	__u32 max_send_sge;
651 	__u32 max_recv_sge;
652 	__u32 max_inline_data;
653 	__u32 reserved;
654 	__u32 driver_data[0];
655 };
656 
657 struct ib_uverbs_ex_create_qp_resp {
658 	struct ib_uverbs_create_qp_resp base;
659 	__u32 comp_mask;
660 	__u32 response_length;
661 };
662 
663 /*
664  * This struct needs to remain a multiple of 8 bytes to keep the
665  * alignment of the modify QP parameters.
666  */
667 struct ib_uverbs_qp_dest {
668 	__u8  dgid[16];
669 	__u32 flow_label;
670 	__u16 dlid;
671 	__u16 reserved;
672 	__u8  sgid_index;
673 	__u8  hop_limit;
674 	__u8  traffic_class;
675 	__u8  sl;
676 	__u8  src_path_bits;
677 	__u8  static_rate;
678 	__u8  is_global;
679 	__u8  port_num;
680 };
681 
682 struct ib_uverbs_query_qp {
683 	__aligned_u64 response;
684 	__u32 qp_handle;
685 	__u32 attr_mask;
686 	__aligned_u64 driver_data[0];
687 };
688 
689 struct ib_uverbs_query_qp_resp {
690 	struct ib_uverbs_qp_dest dest;
691 	struct ib_uverbs_qp_dest alt_dest;
692 	__u32 max_send_wr;
693 	__u32 max_recv_wr;
694 	__u32 max_send_sge;
695 	__u32 max_recv_sge;
696 	__u32 max_inline_data;
697 	__u32 qkey;
698 	__u32 rq_psn;
699 	__u32 sq_psn;
700 	__u32 dest_qp_num;
701 	__u32 qp_access_flags;
702 	__u16 pkey_index;
703 	__u16 alt_pkey_index;
704 	__u8  qp_state;
705 	__u8  cur_qp_state;
706 	__u8  path_mtu;
707 	__u8  path_mig_state;
708 	__u8  sq_draining;
709 	__u8  max_rd_atomic;
710 	__u8  max_dest_rd_atomic;
711 	__u8  min_rnr_timer;
712 	__u8  port_num;
713 	__u8  timeout;
714 	__u8  retry_cnt;
715 	__u8  rnr_retry;
716 	__u8  alt_port_num;
717 	__u8  alt_timeout;
718 	__u8  sq_sig_all;
719 	__u8  reserved[5];
720 	__aligned_u64 driver_data[0];
721 };
722 
723 struct ib_uverbs_modify_qp {
724 	struct ib_uverbs_qp_dest dest;
725 	struct ib_uverbs_qp_dest alt_dest;
726 	__u32 qp_handle;
727 	__u32 attr_mask;
728 	__u32 qkey;
729 	__u32 rq_psn;
730 	__u32 sq_psn;
731 	__u32 dest_qp_num;
732 	__u32 qp_access_flags;
733 	__u16 pkey_index;
734 	__u16 alt_pkey_index;
735 	__u8  qp_state;
736 	__u8  cur_qp_state;
737 	__u8  path_mtu;
738 	__u8  path_mig_state;
739 	__u8  en_sqd_async_notify;
740 	__u8  max_rd_atomic;
741 	__u8  max_dest_rd_atomic;
742 	__u8  min_rnr_timer;
743 	__u8  port_num;
744 	__u8  timeout;
745 	__u8  retry_cnt;
746 	__u8  rnr_retry;
747 	__u8  alt_port_num;
748 	__u8  alt_timeout;
749 	__u8  reserved[2];
750 	__aligned_u64 driver_data[0];
751 };
752 
753 struct ib_uverbs_ex_modify_qp {
754 	struct ib_uverbs_modify_qp base;
755 	__u32	rate_limit;
756 	__u32	reserved;
757 };
758 
759 struct ib_uverbs_ex_modify_qp_resp {
760 	__u32  comp_mask;
761 	__u32  response_length;
762 };
763 
764 struct ib_uverbs_destroy_qp {
765 	__aligned_u64 response;
766 	__u32 qp_handle;
767 	__u32 reserved;
768 };
769 
770 struct ib_uverbs_destroy_qp_resp {
771 	__u32 events_reported;
772 };
773 
774 /*
775  * The ib_uverbs_sge structure isn't used anywhere, since we assume
776  * the ib_sge structure is packed the same way on 32-bit and 64-bit
777  * architectures in both kernel and user space.  It's just here to
778  * document the ABI.
779  */
780 struct ib_uverbs_sge {
781 	__aligned_u64 addr;
782 	__u32 length;
783 	__u32 lkey;
784 };
785 
786 enum ib_uverbs_wr_opcode {
787 	IB_UVERBS_WR_RDMA_WRITE = 0,
788 	IB_UVERBS_WR_RDMA_WRITE_WITH_IMM = 1,
789 	IB_UVERBS_WR_SEND = 2,
790 	IB_UVERBS_WR_SEND_WITH_IMM = 3,
791 	IB_UVERBS_WR_RDMA_READ = 4,
792 	IB_UVERBS_WR_ATOMIC_CMP_AND_SWP = 5,
793 	IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD = 6,
794 	IB_UVERBS_WR_LOCAL_INV = 7,
795 	IB_UVERBS_WR_BIND_MW = 8,
796 	IB_UVERBS_WR_SEND_WITH_INV = 9,
797 	IB_UVERBS_WR_TSO = 10,
798 	IB_UVERBS_WR_RDMA_READ_WITH_INV = 11,
799 	IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP = 12,
800 	IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD = 13,
801 	/* Review enum ib_wr_opcode before modifying this */
802 };
803 
804 struct ib_uverbs_send_wr {
805 	__aligned_u64 wr_id;
806 	__u32 num_sge;
807 	__u32 opcode;		/* see enum ib_uverbs_wr_opcode */
808 	__u32 send_flags;
809 	union {
810 		__be32 imm_data;
811 		__u32 invalidate_rkey;
812 	} ex;
813 	union {
814 		struct {
815 			__aligned_u64 remote_addr;
816 			__u32 rkey;
817 			__u32 reserved;
818 		} rdma;
819 		struct {
820 			__aligned_u64 remote_addr;
821 			__aligned_u64 compare_add;
822 			__aligned_u64 swap;
823 			__u32 rkey;
824 			__u32 reserved;
825 		} atomic;
826 		struct {
827 			__u32 ah;
828 			__u32 remote_qpn;
829 			__u32 remote_qkey;
830 			__u32 reserved;
831 		} ud;
832 	} wr;
833 };
834 
835 struct ib_uverbs_post_send {
836 	__aligned_u64 response;
837 	__u32 qp_handle;
838 	__u32 wr_count;
839 	__u32 sge_count;
840 	__u32 wqe_size;
841 	struct ib_uverbs_send_wr send_wr[0];
842 };
843 
844 struct ib_uverbs_post_send_resp {
845 	__u32 bad_wr;
846 };
847 
848 struct ib_uverbs_recv_wr {
849 	__aligned_u64 wr_id;
850 	__u32 num_sge;
851 	__u32 reserved;
852 };
853 
854 struct ib_uverbs_post_recv {
855 	__aligned_u64 response;
856 	__u32 qp_handle;
857 	__u32 wr_count;
858 	__u32 sge_count;
859 	__u32 wqe_size;
860 	struct ib_uverbs_recv_wr recv_wr[0];
861 };
862 
863 struct ib_uverbs_post_recv_resp {
864 	__u32 bad_wr;
865 };
866 
867 struct ib_uverbs_post_srq_recv {
868 	__aligned_u64 response;
869 	__u32 srq_handle;
870 	__u32 wr_count;
871 	__u32 sge_count;
872 	__u32 wqe_size;
873 	struct ib_uverbs_recv_wr recv[0];
874 };
875 
876 struct ib_uverbs_post_srq_recv_resp {
877 	__u32 bad_wr;
878 };
879 
880 struct ib_uverbs_create_ah {
881 	__aligned_u64 response;
882 	__aligned_u64 user_handle;
883 	__u32 pd_handle;
884 	__u32 reserved;
885 	struct ib_uverbs_ah_attr attr;
886 	__aligned_u64 driver_data[0];
887 };
888 
889 struct ib_uverbs_create_ah_resp {
890 	__u32 ah_handle;
891 	__u32 driver_data[0];
892 };
893 
894 struct ib_uverbs_destroy_ah {
895 	__u32 ah_handle;
896 };
897 
898 struct ib_uverbs_attach_mcast {
899 	__u8  gid[16];
900 	__u32 qp_handle;
901 	__u16 mlid;
902 	__u16 reserved;
903 	__aligned_u64 driver_data[0];
904 };
905 
906 struct ib_uverbs_detach_mcast {
907 	__u8  gid[16];
908 	__u32 qp_handle;
909 	__u16 mlid;
910 	__u16 reserved;
911 	__aligned_u64 driver_data[0];
912 };
913 
914 struct ib_uverbs_flow_spec_hdr {
915 	__u32 type;
916 	__u16 size;
917 	__u16 reserved;
918 	/* followed by flow_spec */
919 	__aligned_u64 flow_spec_data[0];
920 };
921 
922 struct ib_uverbs_flow_eth_filter {
923 	__u8  dst_mac[6];
924 	__u8  src_mac[6];
925 	__be16 ether_type;
926 	__be16 vlan_tag;
927 };
928 
929 struct ib_uverbs_flow_spec_eth {
930 	union {
931 		struct ib_uverbs_flow_spec_hdr hdr;
932 		struct {
933 			__u32 type;
934 			__u16 size;
935 			__u16 reserved;
936 		};
937 	};
938 	struct ib_uverbs_flow_eth_filter val;
939 	struct ib_uverbs_flow_eth_filter mask;
940 };
941 
942 struct ib_uverbs_flow_ipv4_filter {
943 	__be32 src_ip;
944 	__be32 dst_ip;
945 	__u8	proto;
946 	__u8	tos;
947 	__u8	ttl;
948 	__u8	flags;
949 };
950 
951 struct ib_uverbs_flow_spec_ipv4 {
952 	union {
953 		struct ib_uverbs_flow_spec_hdr hdr;
954 		struct {
955 			__u32 type;
956 			__u16 size;
957 			__u16 reserved;
958 		};
959 	};
960 	struct ib_uverbs_flow_ipv4_filter val;
961 	struct ib_uverbs_flow_ipv4_filter mask;
962 };
963 
964 struct ib_uverbs_flow_tcp_udp_filter {
965 	__be16 dst_port;
966 	__be16 src_port;
967 };
968 
969 struct ib_uverbs_flow_spec_tcp_udp {
970 	union {
971 		struct ib_uverbs_flow_spec_hdr hdr;
972 		struct {
973 			__u32 type;
974 			__u16 size;
975 			__u16 reserved;
976 		};
977 	};
978 	struct ib_uverbs_flow_tcp_udp_filter val;
979 	struct ib_uverbs_flow_tcp_udp_filter mask;
980 };
981 
982 struct ib_uverbs_flow_ipv6_filter {
983 	__u8    src_ip[16];
984 	__u8    dst_ip[16];
985 	__be32	flow_label;
986 	__u8	next_hdr;
987 	__u8	traffic_class;
988 	__u8	hop_limit;
989 	__u8	reserved;
990 };
991 
992 struct ib_uverbs_flow_spec_ipv6 {
993 	union {
994 		struct ib_uverbs_flow_spec_hdr hdr;
995 		struct {
996 			__u32 type;
997 			__u16 size;
998 			__u16 reserved;
999 		};
1000 	};
1001 	struct ib_uverbs_flow_ipv6_filter val;
1002 	struct ib_uverbs_flow_ipv6_filter mask;
1003 };
1004 
1005 struct ib_uverbs_flow_spec_action_tag {
1006 	union {
1007 		struct ib_uverbs_flow_spec_hdr hdr;
1008 		struct {
1009 			__u32 type;
1010 			__u16 size;
1011 			__u16 reserved;
1012 		};
1013 	};
1014 	__u32			      tag_id;
1015 	__u32			      reserved1;
1016 };
1017 
1018 struct ib_uverbs_flow_spec_action_drop {
1019 	union {
1020 		struct ib_uverbs_flow_spec_hdr hdr;
1021 		struct {
1022 			__u32 type;
1023 			__u16 size;
1024 			__u16 reserved;
1025 		};
1026 	};
1027 };
1028 
1029 struct ib_uverbs_flow_spec_action_handle {
1030 	union {
1031 		struct ib_uverbs_flow_spec_hdr hdr;
1032 		struct {
1033 			__u32 type;
1034 			__u16 size;
1035 			__u16 reserved;
1036 		};
1037 	};
1038 	__u32			      handle;
1039 	__u32			      reserved1;
1040 };
1041 
1042 struct ib_uverbs_flow_spec_action_count {
1043 	union {
1044 		struct ib_uverbs_flow_spec_hdr hdr;
1045 		struct {
1046 			__u32 type;
1047 			__u16 size;
1048 			__u16 reserved;
1049 		};
1050 	};
1051 	__u32			      handle;
1052 	__u32			      reserved1;
1053 };
1054 
1055 struct ib_uverbs_flow_tunnel_filter {
1056 	__be32 tunnel_id;
1057 };
1058 
1059 struct ib_uverbs_flow_spec_tunnel {
1060 	union {
1061 		struct ib_uverbs_flow_spec_hdr hdr;
1062 		struct {
1063 			__u32 type;
1064 			__u16 size;
1065 			__u16 reserved;
1066 		};
1067 	};
1068 	struct ib_uverbs_flow_tunnel_filter val;
1069 	struct ib_uverbs_flow_tunnel_filter mask;
1070 };
1071 
1072 struct ib_uverbs_flow_spec_esp_filter {
1073 	__u32 spi;
1074 	__u32 seq;
1075 };
1076 
1077 struct ib_uverbs_flow_spec_esp {
1078 	union {
1079 		struct ib_uverbs_flow_spec_hdr hdr;
1080 		struct {
1081 			__u32 type;
1082 			__u16 size;
1083 			__u16 reserved;
1084 		};
1085 	};
1086 	struct ib_uverbs_flow_spec_esp_filter val;
1087 	struct ib_uverbs_flow_spec_esp_filter mask;
1088 };
1089 
1090 struct ib_uverbs_flow_gre_filter {
1091 	/* c_ks_res0_ver field is bits 0-15 in offset 0 of a standard GRE header:
1092 	 * bit 0 - C - checksum bit.
1093 	 * bit 1 - reserved. set to 0.
1094 	 * bit 2 - key bit.
1095 	 * bit 3 - sequence number bit.
1096 	 * bits 4:12 - reserved. set to 0.
1097 	 * bits 13:15 - GRE version.
1098 	 */
1099 	__be16 c_ks_res0_ver;
1100 	__be16 protocol;
1101 	__be32 key;
1102 };
1103 
1104 struct ib_uverbs_flow_spec_gre {
1105 	union {
1106 		struct ib_uverbs_flow_spec_hdr hdr;
1107 		struct {
1108 			__u32 type;
1109 			__u16 size;
1110 			__u16 reserved;
1111 		};
1112 	};
1113 	struct ib_uverbs_flow_gre_filter     val;
1114 	struct ib_uverbs_flow_gre_filter     mask;
1115 };
1116 
1117 struct ib_uverbs_flow_mpls_filter {
1118 	/* The field includes the entire MPLS label:
1119 	 * bits 0:19 - label field.
1120 	 * bits 20:22 - traffic class field.
1121 	 * bits 23 - bottom of stack bit.
1122 	 * bits 24:31 - ttl field.
1123 	 */
1124 	__be32 label;
1125 };
1126 
1127 struct ib_uverbs_flow_spec_mpls {
1128 	union {
1129 		struct ib_uverbs_flow_spec_hdr hdr;
1130 		struct {
1131 			__u32 type;
1132 			__u16 size;
1133 			__u16 reserved;
1134 		};
1135 	};
1136 	struct ib_uverbs_flow_mpls_filter     val;
1137 	struct ib_uverbs_flow_mpls_filter     mask;
1138 };
1139 
1140 struct ib_uverbs_flow_attr {
1141 	__u32 type;
1142 	__u16 size;
1143 	__u16 priority;
1144 	__u8  num_of_specs;
1145 	__u8  reserved[2];
1146 	__u8  port;
1147 	__u32 flags;
1148 	/* Following are the optional layers according to user request
1149 	 * struct ib_flow_spec_xxx
1150 	 * struct ib_flow_spec_yyy
1151 	 */
1152 	struct ib_uverbs_flow_spec_hdr flow_specs[0];
1153 };
1154 
1155 struct ib_uverbs_create_flow  {
1156 	__u32 comp_mask;
1157 	__u32 qp_handle;
1158 	struct ib_uverbs_flow_attr flow_attr;
1159 };
1160 
1161 struct ib_uverbs_create_flow_resp {
1162 	__u32 comp_mask;
1163 	__u32 flow_handle;
1164 };
1165 
1166 struct ib_uverbs_destroy_flow  {
1167 	__u32 comp_mask;
1168 	__u32 flow_handle;
1169 };
1170 
1171 struct ib_uverbs_create_srq {
1172 	__aligned_u64 response;
1173 	__aligned_u64 user_handle;
1174 	__u32 pd_handle;
1175 	__u32 max_wr;
1176 	__u32 max_sge;
1177 	__u32 srq_limit;
1178 	__aligned_u64 driver_data[0];
1179 };
1180 
1181 struct ib_uverbs_create_xsrq {
1182 	__aligned_u64 response;
1183 	__aligned_u64 user_handle;
1184 	__u32 srq_type;
1185 	__u32 pd_handle;
1186 	__u32 max_wr;
1187 	__u32 max_sge;
1188 	__u32 srq_limit;
1189 	__u32 max_num_tags;
1190 	__u32 xrcd_handle;
1191 	__u32 cq_handle;
1192 	__aligned_u64 driver_data[0];
1193 };
1194 
1195 struct ib_uverbs_create_srq_resp {
1196 	__u32 srq_handle;
1197 	__u32 max_wr;
1198 	__u32 max_sge;
1199 	__u32 srqn;
1200 	__u32 driver_data[0];
1201 };
1202 
1203 struct ib_uverbs_modify_srq {
1204 	__u32 srq_handle;
1205 	__u32 attr_mask;
1206 	__u32 max_wr;
1207 	__u32 srq_limit;
1208 	__aligned_u64 driver_data[0];
1209 };
1210 
1211 struct ib_uverbs_query_srq {
1212 	__aligned_u64 response;
1213 	__u32 srq_handle;
1214 	__u32 reserved;
1215 	__aligned_u64 driver_data[0];
1216 };
1217 
1218 struct ib_uverbs_query_srq_resp {
1219 	__u32 max_wr;
1220 	__u32 max_sge;
1221 	__u32 srq_limit;
1222 	__u32 reserved;
1223 };
1224 
1225 struct ib_uverbs_destroy_srq {
1226 	__aligned_u64 response;
1227 	__u32 srq_handle;
1228 	__u32 reserved;
1229 };
1230 
1231 struct ib_uverbs_destroy_srq_resp {
1232 	__u32 events_reported;
1233 };
1234 
1235 struct ib_uverbs_ex_create_wq  {
1236 	__u32 comp_mask;
1237 	__u32 wq_type;
1238 	__aligned_u64 user_handle;
1239 	__u32 pd_handle;
1240 	__u32 cq_handle;
1241 	__u32 max_wr;
1242 	__u32 max_sge;
1243 	__u32 create_flags; /* Use enum ib_wq_flags */
1244 	__u32 reserved;
1245 };
1246 
1247 struct ib_uverbs_ex_create_wq_resp {
1248 	__u32 comp_mask;
1249 	__u32 response_length;
1250 	__u32 wq_handle;
1251 	__u32 max_wr;
1252 	__u32 max_sge;
1253 	__u32 wqn;
1254 };
1255 
1256 struct ib_uverbs_ex_destroy_wq  {
1257 	__u32 comp_mask;
1258 	__u32 wq_handle;
1259 };
1260 
1261 struct ib_uverbs_ex_destroy_wq_resp {
1262 	__u32 comp_mask;
1263 	__u32 response_length;
1264 	__u32 events_reported;
1265 	__u32 reserved;
1266 };
1267 
1268 struct ib_uverbs_ex_modify_wq  {
1269 	__u32 attr_mask;
1270 	__u32 wq_handle;
1271 	__u32 wq_state;
1272 	__u32 curr_wq_state;
1273 	__u32 flags; /* Use enum ib_wq_flags */
1274 	__u32 flags_mask; /* Use enum ib_wq_flags */
1275 };
1276 
1277 /* Prevent memory allocation rather than max expected size */
1278 #define IB_USER_VERBS_MAX_LOG_IND_TBL_SIZE 0x0d
1279 struct ib_uverbs_ex_create_rwq_ind_table  {
1280 	__u32 comp_mask;
1281 	__u32 log_ind_tbl_size;
1282 	/* Following are the wq handles according to log_ind_tbl_size
1283 	 * wq_handle1
1284 	 * wq_handle2
1285 	 */
1286 	__u32 wq_handles[0];
1287 };
1288 
1289 struct ib_uverbs_ex_create_rwq_ind_table_resp {
1290 	__u32 comp_mask;
1291 	__u32 response_length;
1292 	__u32 ind_tbl_handle;
1293 	__u32 ind_tbl_num;
1294 };
1295 
1296 struct ib_uverbs_ex_destroy_rwq_ind_table  {
1297 	__u32 comp_mask;
1298 	__u32 ind_tbl_handle;
1299 };
1300 
1301 struct ib_uverbs_cq_moderation {
1302 	__u16 cq_count;
1303 	__u16 cq_period;
1304 };
1305 
1306 struct ib_uverbs_ex_modify_cq {
1307 	__u32 cq_handle;
1308 	__u32 attr_mask;
1309 	struct ib_uverbs_cq_moderation attr;
1310 	__u32 reserved;
1311 };
1312 
1313 #define IB_DEVICE_NAME_MAX 64
1314 
1315 #endif /* IB_USER_VERBS_H */
1316