xref: /freebsd/contrib/ofed/libibverbs/kern-abi.h (revision 87181516ef48be852d5e5fee53c6e0dbfc62f21e)
1 /*
2  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
3  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
4  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
5  *
6  * This software is available to you under a choice of one of two
7  * licenses.  You may choose to be licensed under the terms of the GNU
8  * General Public License (GPL) Version 2, available from the file
9  * COPYING in the main directory of this source tree, or the
10  * OpenIB.org BSD license below:
11  *
12  *     Redistribution and use in source and binary forms, with or
13  *     without modification, are permitted provided that the following
14  *     conditions are met:
15  *
16  *      - Redistributions of source code must retain the above
17  *        copyright notice, this list of conditions and the following
18  *        disclaimer.
19  *
20  *      - Redistributions in binary form must reproduce the above
21  *        copyright notice, this list of conditions and the following
22  *        disclaimer in the documentation and/or other materials
23  *        provided with the distribution.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  * SOFTWARE.
33  */
34 
35 #ifndef KERN_ABI_H
36 #define KERN_ABI_H
37 
38 #include <infiniband/types.h>
39 
40 /*
41  * This file must be kept in sync with the kernel's version of
42  * drivers/infiniband/include/ib_user_verbs.h
43  */
44 
45 /*
46  * The minimum and maximum kernel ABI that we can handle.
47  */
48 #define IB_USER_VERBS_MIN_ABI_VERSION	3
49 #define IB_USER_VERBS_MAX_ABI_VERSION	6
50 
51 #define IB_USER_VERBS_CMD_THRESHOLD    50
52 
53 enum {
54 	IB_USER_VERBS_CMD_GET_CONTEXT,
55 	IB_USER_VERBS_CMD_QUERY_DEVICE,
56 	IB_USER_VERBS_CMD_QUERY_PORT,
57 	IB_USER_VERBS_CMD_ALLOC_PD,
58 	IB_USER_VERBS_CMD_DEALLOC_PD,
59 	IB_USER_VERBS_CMD_CREATE_AH,
60 	IB_USER_VERBS_CMD_MODIFY_AH,
61 	IB_USER_VERBS_CMD_QUERY_AH,
62 	IB_USER_VERBS_CMD_DESTROY_AH,
63 	IB_USER_VERBS_CMD_REG_MR,
64 	IB_USER_VERBS_CMD_REG_SMR,
65 	IB_USER_VERBS_CMD_REREG_MR,
66 	IB_USER_VERBS_CMD_QUERY_MR,
67 	IB_USER_VERBS_CMD_DEREG_MR,
68 	IB_USER_VERBS_CMD_ALLOC_MW,
69 	IB_USER_VERBS_CMD_BIND_MW,
70 	IB_USER_VERBS_CMD_DEALLOC_MW,
71 	IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
72 	IB_USER_VERBS_CMD_CREATE_CQ,
73 	IB_USER_VERBS_CMD_RESIZE_CQ,
74 	IB_USER_VERBS_CMD_DESTROY_CQ,
75 	IB_USER_VERBS_CMD_POLL_CQ,
76 	IB_USER_VERBS_CMD_PEEK_CQ,
77 	IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
78 	IB_USER_VERBS_CMD_CREATE_QP,
79 	IB_USER_VERBS_CMD_QUERY_QP,
80 	IB_USER_VERBS_CMD_MODIFY_QP,
81 	IB_USER_VERBS_CMD_DESTROY_QP,
82 	IB_USER_VERBS_CMD_POST_SEND,
83 	IB_USER_VERBS_CMD_POST_RECV,
84 	IB_USER_VERBS_CMD_ATTACH_MCAST,
85 	IB_USER_VERBS_CMD_DETACH_MCAST,
86 	IB_USER_VERBS_CMD_CREATE_SRQ,
87 	IB_USER_VERBS_CMD_MODIFY_SRQ,
88 	IB_USER_VERBS_CMD_QUERY_SRQ,
89 	IB_USER_VERBS_CMD_DESTROY_SRQ,
90 	IB_USER_VERBS_CMD_POST_SRQ_RECV,
91 	IB_USER_VERBS_CMD_OPEN_XRCD,
92 	IB_USER_VERBS_CMD_CLOSE_XRCD,
93 	IB_USER_VERBS_CMD_CREATE_XSRQ,
94 	IB_USER_VERBS_CMD_OPEN_QP
95 };
96 
97 #define IB_USER_VERBS_CMD_COMMAND_MASK		0xff
98 #define IB_USER_VERBS_CMD_FLAGS_MASK		0xff000000u
99 #define IB_USER_VERBS_CMD_FLAGS_SHIFT		24
100 
101 
102 #define IB_USER_VERBS_CMD_FLAG_EXTENDED		0x80ul
103 
104 /* use this mask for creating extended commands */
105 #define IB_USER_VERBS_CMD_EXTENDED_MASK \
106 	(IB_USER_VERBS_CMD_FLAG_EXTENDED << \
107 	 IB_USER_VERBS_CMD_FLAGS_SHIFT)
108 
109 
110 enum {
111 	IB_USER_VERBS_CMD_QUERY_DEVICE_EX = IB_USER_VERBS_CMD_EXTENDED_MASK |
112 					    IB_USER_VERBS_CMD_QUERY_DEVICE,
113 	IB_USER_VERBS_CMD_CREATE_QP_EX = IB_USER_VERBS_CMD_EXTENDED_MASK |
114 					 IB_USER_VERBS_CMD_CREATE_QP,
115 	IB_USER_VERBS_CMD_CREATE_CQ_EX = IB_USER_VERBS_CMD_EXTENDED_MASK |
116 						IB_USER_VERBS_CMD_CREATE_CQ,
117 	IB_USER_VERBS_CMD_MODIFY_QP_EX = IB_USER_VERBS_CMD_EXTENDED_MASK |
118 						IB_USER_VERBS_CMD_MODIFY_QP,
119 	IB_USER_VERBS_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_EXTENDED_MASK +
120 					IB_USER_VERBS_CMD_THRESHOLD,
121 	IB_USER_VERBS_CMD_DESTROY_FLOW,
122 	IB_USER_VERBS_CMD_CREATE_WQ,
123 	IB_USER_VERBS_CMD_MODIFY_WQ,
124 	IB_USER_VERBS_CMD_DESTROY_WQ,
125 	IB_USER_VERBS_CMD_CREATE_RWQ_IND_TBL,
126 	IB_USER_VERBS_CMD_DESTROY_RWQ_IND_TBL,
127 };
128 
129 /*
130  * Make sure that all structs defined in this file remain laid out so
131  * that they pack the same way on 32-bit and 64-bit architectures (to
132  * avoid incompatibility between 32-bit userspace and 64-bit kernels).
133  * Specifically:
134  *  - Do not use pointer types -- pass pointers in __u64 instead.
135  *  - Make sure that any structure larger than 4 bytes is padded to a
136  *    multiple of 8 bytes.  Otherwise the structure size will be
137  *    different between 32-bit and 64-bit architectures.
138  */
139 
140 struct hdr {
141 	__u32 command;
142 	__u16 in_words;
143 	__u16 out_words;
144 };
145 
146 struct response_hdr {
147 	__u64 response;
148 };
149 
150 struct ex_hdr {
151 	struct {
152 		__u32 command;
153 		__u16 in_words;
154 		__u16 out_words;
155 	};
156 	struct {
157 		__u64 response;
158 	};
159 	struct {
160 		__u16 provider_in_words;
161 		__u16 provider_out_words;
162 		__u32 reserved;
163 	};
164 };
165 
166 struct ibv_kern_async_event {
167 	__u64 element;
168 	__u32 event_type;
169 	__u32 reserved;
170 };
171 
172 struct ibv_comp_event {
173 	__u64 cq_handle;
174 };
175 
176 /*
177  * All commands from userspace should start with a __u32 command field
178  * followed by __u16 in_words and out_words fields (which give the
179  * length of the command block and response buffer if any in 32-bit
180  * words).  The kernel driver will read these fields first and read
181  * the rest of the command struct based on these value.
182  */
183 
184 struct ibv_query_params {
185 	__u32 command;
186 	__u16 in_words;
187 	__u16 out_words;
188 	__u64 response;
189 };
190 
191 struct ibv_query_params_resp {
192 	__u32 num_cq_events;
193 };
194 
195 struct ibv_get_context {
196 	__u32 command;
197 	__u16 in_words;
198 	__u16 out_words;
199 	__u64 response;
200 	__u64 driver_data[0];
201 };
202 
203 struct ibv_get_context_resp {
204 	__u32 async_fd;
205 	__u32 num_comp_vectors;
206 };
207 
208 struct ibv_query_device {
209 	__u32 command;
210 	__u16 in_words;
211 	__u16 out_words;
212 	__u64 response;
213 	__u64 driver_data[0];
214 };
215 
216 struct ibv_query_device_resp {
217 	__u64 fw_ver;
218 	__be64 node_guid;
219 	__be64 sys_image_guid;
220 	__u64 max_mr_size;
221 	__u64 page_size_cap;
222 	__u32 vendor_id;
223 	__u32 vendor_part_id;
224 	__u32 hw_ver;
225 	__u32 max_qp;
226 	__u32 max_qp_wr;
227 	__u32 device_cap_flags;
228 	__u32 max_sge;
229 	__u32 max_sge_rd;
230 	__u32 max_cq;
231 	__u32 max_cqe;
232 	__u32 max_mr;
233 	__u32 max_pd;
234 	__u32 max_qp_rd_atom;
235 	__u32 max_ee_rd_atom;
236 	__u32 max_res_rd_atom;
237 	__u32 max_qp_init_rd_atom;
238 	__u32 max_ee_init_rd_atom;
239 	__u32 atomic_cap;
240 	__u32 max_ee;
241 	__u32 max_rdd;
242 	__u32 max_mw;
243 	__u32 max_raw_ipv6_qp;
244 	__u32 max_raw_ethy_qp;
245 	__u32 max_mcast_grp;
246 	__u32 max_mcast_qp_attach;
247 	__u32 max_total_mcast_qp_attach;
248 	__u32 max_ah;
249 	__u32 max_fmr;
250 	__u32 max_map_per_fmr;
251 	__u32 max_srq;
252 	__u32 max_srq_wr;
253 	__u32 max_srq_sge;
254 	__u16 max_pkeys;
255 	__u8  local_ca_ack_delay;
256 	__u8  phys_port_cnt;
257 	__u8  reserved[4];
258 };
259 
260 struct ibv_query_device_ex {
261 	struct ex_hdr	hdr;
262 	__u32		comp_mask;
263 	__u32		reserved;
264 };
265 
266 struct ibv_odp_caps_resp {
267 	__u64 general_caps;
268 	struct {
269 		__u32 rc_odp_caps;
270 		__u32 uc_odp_caps;
271 		__u32 ud_odp_caps;
272 	} per_transport_caps;
273 	__u32 reserved;
274 };
275 
276 struct ibv_rss_caps_resp {
277 	__u32 supported_qpts;
278 	__u32 max_rwq_indirection_tables;
279 	__u32 max_rwq_indirection_table_size;
280 	__u32 reserved;
281 };
282 
283 struct ibv_query_device_resp_ex {
284 	struct ibv_query_device_resp base;
285 	__u32 comp_mask;
286 	__u32 response_length;
287 	struct ibv_odp_caps_resp odp_caps;
288 	__u64 timestamp_mask;
289 	__u64 hca_core_clock;
290 	__u64 device_cap_flags_ex;
291 	struct ibv_rss_caps_resp rss_caps;
292 	__u32  max_wq_type_rq;
293 	__u32 raw_packet_caps;
294 };
295 
296 struct ibv_query_port {
297 	__u32 command;
298 	__u16 in_words;
299 	__u16 out_words;
300 	__u64 response;
301 	__u8  port_num;
302 	__u8  reserved[7];
303 	__u64 driver_data[0];
304 };
305 
306 struct ibv_query_port_resp {
307 	__u32 port_cap_flags;
308 	__u32 max_msg_sz;
309 	__u32 bad_pkey_cntr;
310 	__u32 qkey_viol_cntr;
311 	__u32 gid_tbl_len;
312 	__u16 pkey_tbl_len;
313 	__u16 lid;
314 	__u16 sm_lid;
315 	__u8  state;
316 	__u8  max_mtu;
317 	__u8  active_mtu;
318 	__u8  lmc;
319 	__u8  max_vl_num;
320 	__u8  sm_sl;
321 	__u8  subnet_timeout;
322 	__u8  init_type_reply;
323 	__u8  active_width;
324 	__u8  active_speed;
325 	__u8  phys_state;
326 	__u8  link_layer;
327 	__u8  reserved[2];
328 };
329 
330 struct ibv_alloc_pd {
331 	__u32 command;
332 	__u16 in_words;
333 	__u16 out_words;
334 	__u64 response;
335 	__u64 driver_data[0];
336 };
337 
338 struct ibv_alloc_pd_resp {
339 	__u32 pd_handle;
340 };
341 
342 struct ibv_dealloc_pd {
343 	__u32 command;
344 	__u16 in_words;
345 	__u16 out_words;
346 	__u32 pd_handle;
347 };
348 
349 struct ibv_open_xrcd {
350 	__u32 command;
351 	__u16 in_words;
352 	__u16 out_words;
353 	__u64 response;
354 	__u32 fd;
355 	__u32 oflags;
356 	__u64 driver_data[0];
357 };
358 
359 struct ibv_open_xrcd_resp {
360 	__u32 xrcd_handle;
361 };
362 
363 struct ibv_close_xrcd {
364 	__u32 command;
365 	__u16 in_words;
366 	__u16 out_words;
367 	__u32 xrcd_handle;
368 };
369 
370 struct ibv_reg_mr {
371 	__u32 command;
372 	__u16 in_words;
373 	__u16 out_words;
374 	__u64 response;
375 	__u64 start;
376 	__u64 length;
377 	__u64 hca_va;
378 	__u32 pd_handle;
379 	__u32 access_flags;
380 	__u64 driver_data[0];
381 };
382 
383 struct ibv_reg_mr_resp {
384 	__u32 mr_handle;
385 	__u32 lkey;
386 	__u32 rkey;
387 };
388 
389 struct ibv_rereg_mr {
390 	__u32 command;
391 	__u16 in_words;
392 	__u16 out_words;
393 	__u64 response;
394 	__u32 mr_handle;
395 	__u32 flags;
396 	__u64 start;
397 	__u64 length;
398 	__u64 hca_va;
399 	__u32 pd_handle;
400 	__u32 access_flags;
401 	__u64 driver_data[0];
402 };
403 
404 struct ibv_rereg_mr_resp {
405 	__u32 lkey;
406 	__u32 rkey;
407 };
408 
409 struct ibv_dereg_mr {
410 	__u32 command;
411 	__u16 in_words;
412 	__u16 out_words;
413 	__u32 mr_handle;
414 };
415 
416 struct ibv_alloc_mw {
417 	__u32 command;
418 	__u16 in_words;
419 	__u16 out_words;
420 	__u64 response;
421 	__u32 pd_handle;
422 	__u8  mw_type;
423 	__u8  reserved[3];
424 };
425 
426 struct ibv_alloc_mw_resp {
427 	__u32 mw_handle;
428 	__u32 rkey;
429 };
430 
431 struct ibv_dealloc_mw {
432 	__u32 command;
433 	__u16 in_words;
434 	__u16 out_words;
435 	__u32 mw_handle;
436 	__u32 reserved;
437 };
438 
439 struct ibv_create_comp_channel {
440 	__u32 command;
441 	__u16 in_words;
442 	__u16 out_words;
443 	__u64 response;
444 };
445 
446 struct ibv_create_comp_channel_resp {
447 	__u32 fd;
448 };
449 
450 struct ibv_create_cq {
451 	__u32 command;
452 	__u16 in_words;
453 	__u16 out_words;
454 	__u64 response;
455 	__u64 user_handle;
456 	__u32 cqe;
457 	__u32 comp_vector;
458 	__s32 comp_channel;
459 	__u32 reserved;
460 	__u64 driver_data[0];
461 };
462 
463 struct ibv_create_cq_resp {
464 	__u32 cq_handle;
465 	__u32 cqe;
466 };
467 
468 enum ibv_create_cq_ex_kernel_flags {
469 	IBV_CREATE_CQ_EX_KERNEL_FLAG_COMPLETION_TIMESTAMP = 1 << 0,
470 };
471 
472 struct ibv_create_cq_ex {
473 	struct ex_hdr	hdr;
474 	__u64		user_handle;
475 	__u32		cqe;
476 	__u32		comp_vector;
477 	__s32		comp_channel;
478 	__u32		comp_mask;
479 	__u32		flags;
480 	__u32		reserved;
481 };
482 
483 struct ibv_create_cq_resp_ex {
484 	struct ibv_create_cq_resp	base;
485 	__u32				comp_mask;
486 	__u32				response_length;
487 };
488 
489 struct ibv_kern_wc {
490 	__u64  wr_id;
491 	__u32  status;
492 	__u32  opcode;
493 	__u32  vendor_err;
494 	__u32  byte_len;
495 	__be32  imm_data;
496 	__u32  qp_num;
497 	__u32  src_qp;
498 	__u32  wc_flags;
499 	__u16  pkey_index;
500 	__u16  slid;
501 	__u8   sl;
502 	__u8   dlid_path_bits;
503 	__u8   port_num;
504 	__u8   reserved;
505 };
506 
507 struct ibv_poll_cq {
508 	__u32 command;
509 	__u16 in_words;
510 	__u16 out_words;
511 	__u64 response;
512 	__u32 cq_handle;
513 	__u32 ne;
514 };
515 
516 struct ibv_poll_cq_resp {
517 	__u32 count;
518 	__u32 reserved;
519 	struct ibv_kern_wc wc[0];
520 };
521 
522 struct ibv_req_notify_cq {
523 	__u32 command;
524 	__u16 in_words;
525 	__u16 out_words;
526 	__u32 cq_handle;
527 	__u32 solicited;
528 };
529 
530 struct ibv_resize_cq {
531 	__u32 command;
532 	__u16 in_words;
533 	__u16 out_words;
534 	__u64 response;
535 	__u32 cq_handle;
536 	__u32 cqe;
537 	__u64 driver_data[0];
538 };
539 
540 struct ibv_resize_cq_resp {
541 	__u32 cqe;
542 	__u32 reserved;
543 	__u64 driver_data[0];
544 };
545 
546 struct ibv_destroy_cq {
547 	__u32 command;
548 	__u16 in_words;
549 	__u16 out_words;
550 	__u64 response;
551 	__u32 cq_handle;
552 	__u32 reserved;
553 };
554 
555 struct ibv_destroy_cq_resp {
556 	__u32 comp_events_reported;
557 	__u32 async_events_reported;
558 };
559 
560 struct ibv_kern_global_route {
561 	__u8  dgid[16];
562 	__u32 flow_label;
563 	__u8  sgid_index;
564 	__u8  hop_limit;
565 	__u8  traffic_class;
566 	__u8  reserved;
567 };
568 
569 struct ibv_kern_ah_attr {
570 	struct ibv_kern_global_route grh;
571 	__u16 dlid;
572 	__u8  sl;
573 	__u8  src_path_bits;
574 	__u8  static_rate;
575 	__u8  is_global;
576 	__u8  port_num;
577 	__u8  reserved;
578 };
579 
580 struct ibv_kern_qp_attr {
581 	__u32	qp_attr_mask;
582 	__u32	qp_state;
583 	__u32	cur_qp_state;
584 	__u32	path_mtu;
585 	__u32	path_mig_state;
586 	__u32	qkey;
587 	__u32	rq_psn;
588 	__u32	sq_psn;
589 	__u32	dest_qp_num;
590 	__u32	qp_access_flags;
591 
592 	struct ibv_kern_ah_attr ah_attr;
593 	struct ibv_kern_ah_attr alt_ah_attr;
594 
595 	/* ib_qp_cap */
596 	__u32	max_send_wr;
597 	__u32	max_recv_wr;
598 	__u32	max_send_sge;
599 	__u32	max_recv_sge;
600 	__u32	max_inline_data;
601 
602 	__u16	pkey_index;
603 	__u16	alt_pkey_index;
604 	__u8	en_sqd_async_notify;
605 	__u8	sq_draining;
606 	__u8	max_rd_atomic;
607 	__u8	max_dest_rd_atomic;
608 	__u8	min_rnr_timer;
609 	__u8	port_num;
610 	__u8	timeout;
611 	__u8	retry_cnt;
612 	__u8	rnr_retry;
613 	__u8	alt_port_num;
614 	__u8	alt_timeout;
615 	__u8	reserved[5];
616 };
617 
618 #define IBV_CREATE_QP_COMMON	\
619 	__u64 user_handle;	\
620 	__u32 pd_handle;	\
621 	__u32 send_cq_handle;	\
622 	__u32 recv_cq_handle;	\
623 	__u32 srq_handle;	\
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 	__u8  sq_sig_all;	\
630 	__u8  qp_type;		\
631 	__u8  is_srq;		\
632 	__u8  reserved
633 
634 struct ibv_create_qp {
635 	__u32 command;
636 	__u16 in_words;
637 	__u16 out_words;
638 	__u64 response;
639 	IBV_CREATE_QP_COMMON;
640 	__u64 driver_data[0];
641 };
642 
643 struct ibv_create_qp_common {
644 	IBV_CREATE_QP_COMMON;
645 };
646 
647 struct ibv_open_qp {
648 	__u32 command;
649 	__u16 in_words;
650 	__u16 out_words;
651 	__u64 response;
652 	__u64 user_handle;
653 	__u32 pd_handle;
654 	__u32 qpn;
655 	__u8  qp_type;
656 	__u8  reserved[7];
657 	__u64 driver_data[0];
658 };
659 
660 /* also used for open response */
661 struct ibv_create_qp_resp {
662 	__u32 qp_handle;
663 	__u32 qpn;
664 	__u32 max_send_wr;
665 	__u32 max_recv_wr;
666 	__u32 max_send_sge;
667 	__u32 max_recv_sge;
668 	__u32 max_inline_data;
669 	__u32 reserved;
670 };
671 
672 enum ibv_create_qp_ex_kernel_mask {
673 	IBV_CREATE_QP_EX_KERNEL_MASK_IND_TABLE = 1 << 0,
674 };
675 
676 struct ibv_create_qp_ex {
677 	struct ex_hdr	hdr;
678 	struct ibv_create_qp_common base;
679 	__u32 comp_mask;
680 	__u32 create_flags;
681 	__u32 ind_tbl_handle;
682 	__u32 reserved1;
683 };
684 
685 struct ibv_create_qp_resp_ex {
686 	struct ibv_create_qp_resp base;
687 	__u32 comp_mask;
688 	__u32 response_length;
689 };
690 
691 struct ibv_qp_dest {
692 	__u8  dgid[16];
693 	__u32 flow_label;
694 	__u16 dlid;
695 	__u16 reserved;
696 	__u8  sgid_index;
697 	__u8  hop_limit;
698 	__u8  traffic_class;
699 	__u8  sl;
700 	__u8  src_path_bits;
701 	__u8  static_rate;
702 	__u8  is_global;
703 	__u8  port_num;
704 };
705 
706 struct ibv_query_qp {
707 	__u32 command;
708 	__u16 in_words;
709 	__u16 out_words;
710 	__u64 response;
711 	__u32 qp_handle;
712 	__u32 attr_mask;
713 	__u64 driver_data[0];
714 };
715 
716 struct ibv_query_qp_resp {
717 	struct ibv_qp_dest dest;
718 	struct ibv_qp_dest alt_dest;
719 	__u32 max_send_wr;
720 	__u32 max_recv_wr;
721 	__u32 max_send_sge;
722 	__u32 max_recv_sge;
723 	__u32 max_inline_data;
724 	__u32 qkey;
725 	__u32 rq_psn;
726 	__u32 sq_psn;
727 	__u32 dest_qp_num;
728 	__u32 qp_access_flags;
729 	__u16 pkey_index;
730 	__u16 alt_pkey_index;
731 	__u8  qp_state;
732 	__u8  cur_qp_state;
733 	__u8  path_mtu;
734 	__u8  path_mig_state;
735 	__u8  sq_draining;
736 	__u8  max_rd_atomic;
737 	__u8  max_dest_rd_atomic;
738 	__u8  min_rnr_timer;
739 	__u8  port_num;
740 	__u8  timeout;
741 	__u8  retry_cnt;
742 	__u8  rnr_retry;
743 	__u8  alt_port_num;
744 	__u8  alt_timeout;
745 	__u8  sq_sig_all;
746 	__u8  reserved[5];
747 	__u64 driver_data[0];
748 };
749 
750 struct ibv_modify_qp_common {
751 	struct ibv_qp_dest dest;
752 	struct ibv_qp_dest alt_dest;
753 	__u32 qp_handle;
754 	__u32 attr_mask;
755 	__u32 qkey;
756 	__u32 rq_psn;
757 	__u32 sq_psn;
758 	__u32 dest_qp_num;
759 	__u32 qp_access_flags;
760 	__u16 pkey_index;
761 	__u16 alt_pkey_index;
762 	__u8  qp_state;
763 	__u8  cur_qp_state;
764 	__u8  path_mtu;
765 	__u8  path_mig_state;
766 	__u8  en_sqd_async_notify;
767 	__u8  max_rd_atomic;
768 	__u8  max_dest_rd_atomic;
769 	__u8  min_rnr_timer;
770 	__u8  port_num;
771 	__u8  timeout;
772 	__u8  retry_cnt;
773 	__u8  rnr_retry;
774 	__u8  alt_port_num;
775 	__u8  alt_timeout;
776 	__u8  reserved[2];
777 };
778 
779 struct ibv_modify_qp {
780 	__u32 command;
781 	__u16 in_words;
782 	__u16 out_words;
783 	struct ibv_modify_qp_common base;
784 	__u64 driver_data[0];
785 };
786 
787 struct ibv_modify_qp_ex {
788 	struct ex_hdr		    hdr;
789 	struct ibv_modify_qp_common base;
790 	__u32  rate_limit;
791 	__u32  reserved;
792 };
793 
794 struct ibv_modify_qp_resp_ex {
795 	__u32  comp_mask;
796 	__u32  response_length;
797 };
798 
799 struct ibv_destroy_qp {
800 	__u32 command;
801 	__u16 in_words;
802 	__u16 out_words;
803 	__u64 response;
804 	__u32 qp_handle;
805 	__u32 reserved;
806 };
807 
808 struct ibv_destroy_qp_resp {
809 	__u32 events_reported;
810 };
811 
812 struct ibv_kern_send_wr {
813 	__u64 wr_id;
814 	__u32 num_sge;
815 	__u32 opcode;
816 	__u32 send_flags;
817 	__be32 imm_data;
818 	union {
819 		struct {
820 			__u64 remote_addr;
821 			__u32 rkey;
822 			__u32 reserved;
823 		} rdma;
824 		struct {
825 			__u64 remote_addr;
826 			__u64 compare_add;
827 			__u64 swap;
828 			__u32 rkey;
829 			__u32 reserved;
830 		} atomic;
831 		struct {
832 			__u32 ah;
833 			__u32 remote_qpn;
834 			__u32 remote_qkey;
835 			__u32 reserved;
836 		} ud;
837 	} wr;
838 	union {
839 		struct {
840 			__u32 remote_srqn;
841 		} xrc;
842 	} qp_type;
843 };
844 
845 struct ibv_kern_eth_filter {
846 	__u8  dst_mac[6];
847 	__u8  src_mac[6];
848 	__u16  ether_type;
849 	__u16  vlan_tag;
850 };
851 
852 struct ibv_kern_spec_eth {
853 	__u32 type;
854 	__u16  size;
855 	__u16 reserved;
856 	struct ibv_kern_eth_filter val;
857 	struct ibv_kern_eth_filter mask;
858 };
859 
860 struct ibv_kern_ipv4_filter {
861 	__u32 src_ip;
862 	__u32 dst_ip;
863 };
864 
865 struct ibv_kern_spec_ipv4 {
866 	__u32  type;
867 	__u16  size;
868 	__u16 reserved;
869 	struct ibv_kern_ipv4_filter val;
870 	struct ibv_kern_ipv4_filter mask;
871 };
872 
873 struct ibv_kern_ipv4_ext_filter {
874 	__u32 src_ip;
875 	__u32 dst_ip;
876 	__u8  proto;
877 	__u8  tos;
878 	__u8  ttl;
879 	__u8  flags;
880 };
881 
882 struct ibv_kern_spec_ipv4_ext {
883 	__u32  type;
884 	__u16  size;
885 	__u16 reserved;
886 	struct ibv_kern_ipv4_ext_filter val;
887 	struct ibv_kern_ipv4_ext_filter mask;
888 };
889 
890 struct ibv_kern_ipv6_filter {
891 	__u8  src_ip[16];
892 	__u8  dst_ip[16];
893 	__u32 flow_label;
894 	__u8  next_hdr;
895 	__u8  traffic_class;
896 	__u8  hop_limit;
897 	__u8  reserved;
898 };
899 
900 struct ibv_kern_spec_ipv6 {
901 	__u32  type;
902 	__u16  size;
903 	__u16 reserved;
904 	struct ibv_kern_ipv6_filter val;
905 	struct ibv_kern_ipv6_filter mask;
906 };
907 
908 struct ibv_kern_tcp_udp_filter {
909 	__u16 dst_port;
910 	__u16 src_port;
911 };
912 
913 struct ibv_kern_spec_tcp_udp {
914 	__u32  type;
915 	__u16  size;
916 	__u16 reserved;
917 	struct ibv_kern_tcp_udp_filter val;
918 	struct ibv_kern_tcp_udp_filter mask;
919 };
920 
921 struct ibv_kern_spec_action_tag {
922 	__u32  type;
923 	__u16  size;
924 	__u16 reserved;
925 	__u32 tag_id;
926 	__u32 reserved1;
927 };
928 
929 struct ibv_kern_tunnel_filter {
930 	__u32 tunnel_id;
931 };
932 
933 struct ibv_kern_spec_tunnel {
934 	__u32  type;
935 	__u16  size;
936 	__u16 reserved;
937 	struct ibv_kern_tunnel_filter val;
938 	struct ibv_kern_tunnel_filter mask;
939 };
940 
941 struct ibv_kern_spec_action_drop {
942 	__u32  type;
943 	__u16  size;
944 	__u16 reserved;
945 };
946 
947 struct ibv_kern_spec {
948 	union {
949 		struct {
950 			__u32 type;
951 			__u16 size;
952 			__u16 reserved;
953 		} hdr;
954 		struct ibv_kern_spec_eth eth;
955 		struct ibv_kern_spec_ipv4 ipv4;
956 		struct ibv_kern_spec_ipv4_ext ipv4_ext;
957 		struct ibv_kern_spec_tcp_udp tcp_udp;
958 		struct ibv_kern_spec_ipv6 ipv6;
959 		struct ibv_kern_spec_tunnel tunnel;
960 		struct ibv_kern_spec_action_tag flow_tag;
961 		struct ibv_kern_spec_action_drop drop;
962 	};
963 };
964 
965 struct ibv_kern_flow_attr {
966 	__u32 type;
967 	__u16 size;
968 	__u16 priority;
969 	__u8 num_of_specs;
970 	__u8 reserved[2];
971 	__u8 port;
972 	__u32 flags;
973 	/* Following are the optional layers according to user request
974 	 * struct ibv_kern_flow_spec_xxx
975 	 * struct ibv_kern_flow_spec_yyy
976 	 */
977 };
978 
979 struct ibv_post_send {
980 	__u32 command;
981 	__u16 in_words;
982 	__u16 out_words;
983 	__u64 response;
984 	__u32 qp_handle;
985 	__u32 wr_count;
986 	__u32 sge_count;
987 	__u32 wqe_size;
988 	struct ibv_kern_send_wr send_wr[0];
989 };
990 
991 struct ibv_post_send_resp {
992 	__u32 bad_wr;
993 };
994 
995 struct ibv_kern_recv_wr {
996 	__u64 wr_id;
997 	__u32 num_sge;
998 	__u32 reserved;
999 };
1000 
1001 struct ibv_post_recv {
1002 	__u32 command;
1003 	__u16 in_words;
1004 	__u16 out_words;
1005 	__u64 response;
1006 	__u32 qp_handle;
1007 	__u32 wr_count;
1008 	__u32 sge_count;
1009 	__u32 wqe_size;
1010 	struct ibv_kern_recv_wr recv_wr[0];
1011 };
1012 
1013 struct ibv_post_recv_resp {
1014 	__u32 bad_wr;
1015 };
1016 
1017 struct ibv_post_srq_recv {
1018 	__u32 command;
1019 	__u16 in_words;
1020 	__u16 out_words;
1021 	__u64 response;
1022 	__u32 srq_handle;
1023 	__u32 wr_count;
1024 	__u32 sge_count;
1025 	__u32 wqe_size;
1026 	struct ibv_kern_recv_wr recv_wr[0];
1027 };
1028 
1029 struct ibv_post_srq_recv_resp {
1030 	__u32 bad_wr;
1031 };
1032 
1033 struct ibv_create_ah {
1034 	__u32 command;
1035 	__u16 in_words;
1036 	__u16 out_words;
1037 	__u64 response;
1038 	__u64 user_handle;
1039 	__u32 pd_handle;
1040 	__u32 reserved;
1041 	struct ibv_kern_ah_attr attr;
1042 };
1043 
1044 struct ibv_create_ah_resp {
1045 	__u32 handle;
1046 };
1047 
1048 struct ibv_destroy_ah {
1049 	__u32 command;
1050 	__u16 in_words;
1051 	__u16 out_words;
1052 	__u32 ah_handle;
1053 };
1054 
1055 struct ibv_attach_mcast {
1056 	__u32 command;
1057 	__u16 in_words;
1058 	__u16 out_words;
1059 	__u8  gid[16];
1060 	__u32 qp_handle;
1061 	__u16 mlid;
1062 	__u16 reserved;
1063 	__u64 driver_data[0];
1064 };
1065 
1066 struct ibv_create_flow  {
1067 	struct ex_hdr hdr;
1068 	__u32 comp_mask;
1069 	__u32 qp_handle;
1070 	struct ibv_kern_flow_attr flow_attr;
1071 };
1072 
1073 struct ibv_create_flow_resp {
1074 	__u32 comp_mask;
1075 	__u32 flow_handle;
1076 };
1077 
1078 struct ibv_destroy_flow  {
1079 	struct ex_hdr hdr;
1080 	__u32 comp_mask;
1081 	__u32 flow_handle;
1082 };
1083 
1084 struct ibv_detach_mcast {
1085 	__u32 command;
1086 	__u16 in_words;
1087 	__u16 out_words;
1088 	__u8  gid[16];
1089 	__u32 qp_handle;
1090 	__u16 mlid;
1091 	__u16 reserved;
1092 	__u64 driver_data[0];
1093 };
1094 
1095 struct ibv_create_srq {
1096 	__u32 command;
1097 	__u16 in_words;
1098 	__u16 out_words;
1099 	__u64 response;
1100 	__u64 user_handle;
1101 	__u32 pd_handle;
1102 	__u32 max_wr;
1103 	__u32 max_sge;
1104 	__u32 srq_limit;
1105 	__u64 driver_data[0];
1106 };
1107 
1108 struct ibv_create_xsrq {
1109 	__u32 command;
1110 	__u16 in_words;
1111 	__u16 out_words;
1112 	__u64 response;
1113 	__u64 user_handle;
1114 	__u32 srq_type;
1115 	__u32 pd_handle;
1116 	__u32 max_wr;
1117 	__u32 max_sge;
1118 	__u32 srq_limit;
1119 	__u32 reserved;
1120 	__u32 xrcd_handle;
1121 	__u32 cq_handle;
1122 	__u64 driver_data[0];
1123 };
1124 
1125 struct ibv_create_srq_resp {
1126 	__u32 srq_handle;
1127 	__u32 max_wr;
1128 	__u32 max_sge;
1129 	__u32 srqn;
1130 };
1131 
1132 struct ibv_modify_srq {
1133 	__u32 command;
1134 	__u16 in_words;
1135 	__u16 out_words;
1136 	__u32 srq_handle;
1137 	__u32 attr_mask;
1138 	__u32 max_wr;
1139 	__u32 srq_limit;
1140 	__u64 driver_data[0];
1141 };
1142 
1143 struct ibv_query_srq {
1144 	__u32 command;
1145 	__u16 in_words;
1146 	__u16 out_words;
1147 	__u64 response;
1148 	__u32 srq_handle;
1149 	__u32 reserved;
1150 	__u64 driver_data[0];
1151 };
1152 
1153 struct ibv_query_srq_resp {
1154 	__u32 max_wr;
1155 	__u32 max_sge;
1156 	__u32 srq_limit;
1157 	__u32 reserved;
1158 };
1159 
1160 struct ibv_destroy_srq {
1161 	__u32 command;
1162 	__u16 in_words;
1163 	__u16 out_words;
1164 	__u64 response;
1165 	__u32 srq_handle;
1166 	__u32 reserved;
1167 };
1168 
1169 struct ibv_destroy_srq_resp {
1170 	__u32 events_reported;
1171 };
1172 
1173 /*
1174  * Compatibility with older ABI versions
1175  */
1176 
1177 enum {
1178 	IB_USER_VERBS_CMD_QUERY_PARAMS_V2,
1179 	IB_USER_VERBS_CMD_GET_CONTEXT_V2,
1180 	IB_USER_VERBS_CMD_QUERY_DEVICE_V2,
1181 	IB_USER_VERBS_CMD_QUERY_PORT_V2,
1182 	IB_USER_VERBS_CMD_QUERY_GID_V2,
1183 	IB_USER_VERBS_CMD_QUERY_PKEY_V2,
1184 	IB_USER_VERBS_CMD_ALLOC_PD_V2,
1185 	IB_USER_VERBS_CMD_DEALLOC_PD_V2,
1186 	IB_USER_VERBS_CMD_CREATE_AH_V2,
1187 	IB_USER_VERBS_CMD_MODIFY_AH_V2,
1188 	IB_USER_VERBS_CMD_QUERY_AH_V2,
1189 	IB_USER_VERBS_CMD_DESTROY_AH_V2,
1190 	IB_USER_VERBS_CMD_REG_MR_V2,
1191 	IB_USER_VERBS_CMD_REG_SMR_V2,
1192 	IB_USER_VERBS_CMD_REREG_MR_V2,
1193 	IB_USER_VERBS_CMD_QUERY_MR_V2,
1194 	IB_USER_VERBS_CMD_DEREG_MR_V2,
1195 	IB_USER_VERBS_CMD_ALLOC_MW_V2,
1196 	IB_USER_VERBS_CMD_BIND_MW_V2,
1197 	IB_USER_VERBS_CMD_DEALLOC_MW_V2,
1198 	IB_USER_VERBS_CMD_CREATE_CQ_V2,
1199 	IB_USER_VERBS_CMD_RESIZE_CQ_V2,
1200 	IB_USER_VERBS_CMD_DESTROY_CQ_V2,
1201 	IB_USER_VERBS_CMD_POLL_CQ_V2,
1202 	IB_USER_VERBS_CMD_PEEK_CQ_V2,
1203 	IB_USER_VERBS_CMD_REQ_NOTIFY_CQ_V2,
1204 	IB_USER_VERBS_CMD_CREATE_QP_V2,
1205 	IB_USER_VERBS_CMD_QUERY_QP_V2,
1206 	IB_USER_VERBS_CMD_MODIFY_QP_V2,
1207 	IB_USER_VERBS_CMD_DESTROY_QP_V2,
1208 	IB_USER_VERBS_CMD_POST_SEND_V2,
1209 	IB_USER_VERBS_CMD_POST_RECV_V2,
1210 	IB_USER_VERBS_CMD_ATTACH_MCAST_V2,
1211 	IB_USER_VERBS_CMD_DETACH_MCAST_V2,
1212 	IB_USER_VERBS_CMD_CREATE_SRQ_V2,
1213 	IB_USER_VERBS_CMD_MODIFY_SRQ_V2,
1214 	IB_USER_VERBS_CMD_QUERY_SRQ_V2,
1215 	IB_USER_VERBS_CMD_DESTROY_SRQ_V2,
1216 	IB_USER_VERBS_CMD_POST_SRQ_RECV_V2,
1217 	/*
1218 	 * Set commands that didn't exist to -1 so our compile-time
1219 	 * trick opcodes in IBV_INIT_CMD() doesn't break.
1220 	 */
1221 	IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL_V2 = -1,
1222 	IB_USER_VERBS_CMD_OPEN_XRCD_V2 = -1,
1223 	IB_USER_VERBS_CMD_CLOSE_XRCD_V2 = -1,
1224 	IB_USER_VERBS_CMD_CREATE_XSRQ_V2 = -1,
1225 	IB_USER_VERBS_CMD_OPEN_QP_V2 = -1,
1226 	IB_USER_VERBS_CMD_CREATE_FLOW_V2 = -1,
1227 	IB_USER_VERBS_CMD_DESTROY_FLOW_V2 = -1,
1228 	IB_USER_VERBS_CMD_QUERY_DEVICE_EX_V2 = -1,
1229 	IB_USER_VERBS_CMD_CREATE_QP_EX_V2 = -1,
1230 	IB_USER_VERBS_CMD_CREATE_CQ_EX_V2 = -1,
1231 	IB_USER_VERBS_CMD_CREATE_WQ_V2 = -1,
1232 	IB_USER_VERBS_CMD_MODIFY_WQ_V2 = -1,
1233 	IB_USER_VERBS_CMD_DESTROY_WQ_V2 = -1,
1234 	IB_USER_VERBS_CMD_CREATE_RWQ_IND_TBL_V2 = -1,
1235 	IB_USER_VERBS_CMD_DESTROY_RWQ_IND_TBL_V2 = -1,
1236 	IB_USER_VERBS_CMD_MODIFY_QP_EX_V2 = -1,
1237 };
1238 
1239 struct ibv_modify_srq_v3 {
1240 	__u32 command;
1241 	__u16 in_words;
1242 	__u16 out_words;
1243 	__u32 srq_handle;
1244 	__u32 attr_mask;
1245 	__u32 max_wr;
1246 	__u32 max_sge;
1247 	__u32 srq_limit;
1248 	__u32 reserved;
1249 	__u64 driver_data[0];
1250 };
1251 
1252 struct ibv_create_qp_resp_v3 {
1253 	__u32 qp_handle;
1254 	__u32 qpn;
1255 };
1256 
1257 struct ibv_create_qp_resp_v4 {
1258 	__u32 qp_handle;
1259 	__u32 qpn;
1260 	__u32 max_send_wr;
1261 	__u32 max_recv_wr;
1262 	__u32 max_send_sge;
1263 	__u32 max_recv_sge;
1264 	__u32 max_inline_data;
1265 };
1266 
1267 struct ibv_create_srq_resp_v5 {
1268 	__u32 srq_handle;
1269 };
1270 
1271 struct ibv_create_wq {
1272 	struct ex_hdr hdr;
1273 	__u32 comp_mask;
1274 	__u32 wq_type;
1275 	__u64 user_handle;
1276 	__u32 pd_handle;
1277 	__u32 cq_handle;
1278 	__u32 max_wr;
1279 	__u32 max_sge;
1280 	__u32 create_flags;
1281 	__u32 reserved;
1282 };
1283 
1284 struct ibv_create_wq_resp {
1285 	__u32 comp_mask;
1286 	__u32 response_length;
1287 	__u32 wq_handle;
1288 	__u32 max_wr;
1289 	__u32 max_sge;
1290 	__u32 wqn;
1291 };
1292 
1293 struct ibv_destroy_wq {
1294 	struct ex_hdr hdr;
1295 	__u32 comp_mask;
1296 	__u32 wq_handle;
1297 };
1298 
1299 struct ibv_destroy_wq_resp {
1300 	__u32 comp_mask;
1301 	__u32 response_length;
1302 	__u32 events_reported;
1303 	__u32 reserved;
1304 };
1305 
1306 struct ibv_modify_wq  {
1307 	struct ex_hdr hdr;
1308 	__u32 attr_mask;
1309 	__u32 wq_handle;
1310 	__u32 wq_state;
1311 	__u32 curr_wq_state;
1312 	__u32 flags;
1313 	__u32 flags_mask;
1314 };
1315 
1316 struct ibv_create_rwq_ind_table {
1317 	struct ex_hdr hdr;
1318 	__u32 comp_mask;
1319 	__u32 log_ind_tbl_size;
1320 	/* Following are wq handles based on log_ind_tbl_size, must be 64 bytes aligned.
1321 	 * __u32 wq_handle1
1322 	 * __u32 wq_handle2
1323 	 */
1324 };
1325 
1326 struct ibv_create_rwq_ind_table_resp {
1327 	__u32 comp_mask;
1328 	__u32 response_length;
1329 	__u32 ind_tbl_handle;
1330 	__u32 ind_tbl_num;
1331 };
1332 
1333 struct ibv_destroy_rwq_ind_table {
1334 	struct ex_hdr hdr;
1335 	__u32 comp_mask;
1336 	__u32 ind_tbl_handle;
1337 };
1338 
1339 #endif /* KERN_ABI_H */
1340