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