1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
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.
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:
14 * Redistribution and use in source and binary forms, with or
15 * without modification, are permitted provided that the following
18 * - Redistributions of source code must retain the above
19 * copyright notice, this list of conditions and the following
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.
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
37 #ifndef IB_USER_VERBS_H
38 #define IB_USER_VERBS_H
40 #include <linux/types.h>
43 * Increment this value if any changes that break userspace ABI
44 * compatibility are made.
46 #define IB_USER_VERBS_ABI_VERSION 6
47 #define IB_USER_VERBS_CMD_THRESHOLD 50
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,
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
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).
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.
119 struct ib_uverbs_async_event_desc {
121 __u32 event_type; /* enum ib_event_type */
125 struct ib_uverbs_comp_event_desc {
129 struct ib_uverbs_cq_moderation_caps {
130 __u16 max_cq_moderation_count;
131 __u16 max_cq_moderation_period;
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.
143 #define IB_USER_VERBS_CMD_COMMAND_MASK 0xff
144 #define IB_USER_VERBS_CMD_FLAGS_MASK 0xff000000u
145 #define IB_USER_VERBS_CMD_FLAGS_SHIFT 24
147 #define IB_USER_VERBS_CMD_FLAG_EXTENDED 0x80
149 struct ib_uverbs_cmd_hdr {
155 struct ib_uverbs_ex_cmd_hdr {
157 __u16 provider_in_words;
158 __u16 provider_out_words;
159 __u32 cmd_hdr_reserved;
162 struct ib_uverbs_get_context {
164 __u64 driver_data[0];
167 struct ib_uverbs_get_context_resp {
169 __u32 num_comp_vectors;
172 struct ib_uverbs_query_device {
174 __u64 driver_data[0];
177 struct ib_uverbs_query_device_resp {
180 __be64 sys_image_guid;
184 __u32 vendor_part_id;
188 __u32 device_cap_flags;
195 __u32 max_qp_rd_atom;
196 __u32 max_ee_rd_atom;
197 __u32 max_res_rd_atom;
198 __u32 max_qp_init_rd_atom;
199 __u32 max_ee_init_rd_atom;
204 __u32 max_raw_ipv6_qp;
205 __u32 max_raw_ethy_qp;
207 __u32 max_mcast_qp_attach;
208 __u32 max_total_mcast_qp_attach;
211 __u32 max_map_per_fmr;
216 __u8 local_ca_ack_delay;
221 struct ib_uverbs_ex_query_device {
226 struct ib_uverbs_odp_caps {
232 } per_transport_caps;
236 struct ib_uverbs_rss_caps {
237 /* Corresponding bit will be set if qp type from
238 * 'enum ib_qp_type' is supported, e.g.
239 * supported_qpts |= 1 << IB_QPT_UD
241 __u32 supported_qpts;
242 __u32 max_rwq_indirection_tables;
243 __u32 max_rwq_indirection_table_size;
247 struct ib_uverbs_tm_caps {
248 /* Max size of rendezvous request message */
249 __u32 max_rndv_hdr_size;
250 /* Max number of entries in tag matching list */
254 /* Max number of outstanding list operations */
256 /* Max number of SGE in tag matching entry */
261 struct ib_uverbs_ex_query_device_resp {
262 struct ib_uverbs_query_device_resp base;
264 __u32 response_length;
265 struct ib_uverbs_odp_caps odp_caps;
266 __u64 timestamp_mask;
267 __u64 hca_core_clock; /* in KHZ */
268 __u64 device_cap_flags_ex;
269 struct ib_uverbs_rss_caps rss_caps;
270 __u32 max_wq_type_rq;
271 __u32 raw_packet_caps;
272 struct ib_uverbs_tm_caps tm_caps;
273 struct ib_uverbs_cq_moderation_caps cq_moderation_caps;
276 struct ib_uverbs_query_port {
280 __u64 driver_data[0];
283 struct ib_uverbs_query_port_resp {
284 __u32 port_cap_flags;
287 __u32 qkey_viol_cntr;
299 __u8 init_type_reply;
307 struct ib_uverbs_alloc_pd {
309 __u64 driver_data[0];
312 struct ib_uverbs_alloc_pd_resp {
316 struct ib_uverbs_dealloc_pd {
320 struct ib_uverbs_open_xrcd {
324 __u64 driver_data[0];
327 struct ib_uverbs_open_xrcd_resp {
331 struct ib_uverbs_close_xrcd {
335 struct ib_uverbs_reg_mr {
342 __u64 driver_data[0];
345 struct ib_uverbs_reg_mr_resp {
351 struct ib_uverbs_rereg_mr {
362 struct ib_uverbs_rereg_mr_resp {
367 struct ib_uverbs_dereg_mr {
371 struct ib_uverbs_alloc_mw {
378 struct ib_uverbs_alloc_mw_resp {
383 struct ib_uverbs_dealloc_mw {
387 struct ib_uverbs_create_comp_channel {
391 struct ib_uverbs_create_comp_channel_resp {
395 struct ib_uverbs_create_cq {
402 __u64 driver_data[0];
405 struct ib_uverbs_ex_create_cq {
415 struct ib_uverbs_create_cq_resp {
420 struct ib_uverbs_ex_create_cq_resp {
421 struct ib_uverbs_create_cq_resp base;
423 __u32 response_length;
426 struct ib_uverbs_resize_cq {
430 __u64 driver_data[0];
433 struct ib_uverbs_resize_cq_resp {
436 __u64 driver_data[0];
439 struct ib_uverbs_poll_cq {
445 struct ib_uverbs_wc {
453 __u32 invalidate_rkey;
466 struct ib_uverbs_poll_cq_resp {
469 struct ib_uverbs_wc wc[0];
472 struct ib_uverbs_req_notify_cq {
474 __u32 solicited_only;
477 struct ib_uverbs_destroy_cq {
483 struct ib_uverbs_destroy_cq_resp {
484 __u32 comp_events_reported;
485 __u32 async_events_reported;
488 struct ib_uverbs_global_route {
497 struct ib_uverbs_ah_attr {
498 struct ib_uverbs_global_route grh;
508 struct ib_uverbs_qp_attr {
513 __u32 path_mig_state;
518 __u32 qp_access_flags;
520 struct ib_uverbs_ah_attr ah_attr;
521 struct ib_uverbs_ah_attr alt_ah_attr;
528 __u32 max_inline_data;
531 __u16 alt_pkey_index;
532 __u8 en_sqd_async_notify;
535 __u8 max_dest_rd_atomic;
546 struct ib_uverbs_create_qp {
550 __u32 send_cq_handle;
551 __u32 recv_cq_handle;
557 __u32 max_inline_data;
562 __u64 driver_data[0];
565 enum ib_uverbs_create_qp_mask {
566 IB_UVERBS_CREATE_QP_MASK_IND_TABLE = 1UL << 0,
570 IB_UVERBS_CREATE_QP_SUP_COMP_MASK = IB_UVERBS_CREATE_QP_MASK_IND_TABLE,
575 * This value is equal to IB_QP_DEST_QPN.
577 IB_USER_LEGACY_LAST_QP_ATTR_MASK = 1ULL << 20,
582 * This value is equal to IB_QP_RATE_LIMIT.
584 IB_USER_LAST_QP_ATTR_MASK = 1ULL << 25,
587 struct ib_uverbs_ex_create_qp {
590 __u32 send_cq_handle;
591 __u32 recv_cq_handle;
597 __u32 max_inline_data;
604 __u32 rwq_ind_tbl_handle;
608 struct ib_uverbs_open_qp {
615 __u64 driver_data[0];
618 /* also used for open response */
619 struct ib_uverbs_create_qp_resp {
626 __u32 max_inline_data;
630 struct ib_uverbs_ex_create_qp_resp {
631 struct ib_uverbs_create_qp_resp base;
633 __u32 response_length;
637 * This struct needs to remain a multiple of 8 bytes to keep the
638 * alignment of the modify QP parameters.
640 struct ib_uverbs_qp_dest {
655 struct ib_uverbs_query_qp {
659 __u64 driver_data[0];
662 struct ib_uverbs_query_qp_resp {
663 struct ib_uverbs_qp_dest dest;
664 struct ib_uverbs_qp_dest alt_dest;
669 __u32 max_inline_data;
674 __u32 qp_access_flags;
676 __u16 alt_pkey_index;
683 __u8 max_dest_rd_atomic;
693 __u64 driver_data[0];
696 struct ib_uverbs_modify_qp {
697 struct ib_uverbs_qp_dest dest;
698 struct ib_uverbs_qp_dest alt_dest;
705 __u32 qp_access_flags;
707 __u16 alt_pkey_index;
712 __u8 en_sqd_async_notify;
714 __u8 max_dest_rd_atomic;
723 __u64 driver_data[0];
726 struct ib_uverbs_ex_modify_qp {
727 struct ib_uverbs_modify_qp base;
732 struct ib_uverbs_modify_qp_resp {
735 struct ib_uverbs_ex_modify_qp_resp {
737 __u32 response_length;
740 struct ib_uverbs_destroy_qp {
746 struct ib_uverbs_destroy_qp_resp {
747 __u32 events_reported;
751 * The ib_uverbs_sge structure isn't used anywhere, since we assume
752 * the ib_sge structure is packed the same way on 32-bit and 64-bit
753 * architectures in both kernel and user space. It's just here to
756 struct ib_uverbs_sge {
762 struct ib_uverbs_send_wr {
769 __u32 invalidate_rkey;
793 struct ib_uverbs_post_send {
799 struct ib_uverbs_send_wr send_wr[0];
802 struct ib_uverbs_post_send_resp {
806 struct ib_uverbs_recv_wr {
812 struct ib_uverbs_post_recv {
818 struct ib_uverbs_recv_wr recv_wr[0];
821 struct ib_uverbs_post_recv_resp {
825 struct ib_uverbs_post_srq_recv {
831 struct ib_uverbs_recv_wr recv[0];
834 struct ib_uverbs_post_srq_recv_resp {
838 struct ib_uverbs_create_ah {
843 struct ib_uverbs_ah_attr attr;
846 struct ib_uverbs_create_ah_resp {
850 struct ib_uverbs_destroy_ah {
854 struct ib_uverbs_attach_mcast {
859 __u64 driver_data[0];
862 struct ib_uverbs_detach_mcast {
867 __u64 driver_data[0];
870 struct ib_uverbs_flow_spec_hdr {
874 /* followed by flow_spec */
875 __u64 flow_spec_data[0];
878 struct ib_uverbs_flow_eth_filter {
885 struct ib_uverbs_flow_spec_eth {
887 struct ib_uverbs_flow_spec_hdr hdr;
894 struct ib_uverbs_flow_eth_filter val;
895 struct ib_uverbs_flow_eth_filter mask;
898 struct ib_uverbs_flow_ipv4_filter {
907 struct ib_uverbs_flow_spec_ipv4 {
909 struct ib_uverbs_flow_spec_hdr hdr;
916 struct ib_uverbs_flow_ipv4_filter val;
917 struct ib_uverbs_flow_ipv4_filter mask;
920 struct ib_uverbs_flow_tcp_udp_filter {
925 struct ib_uverbs_flow_spec_tcp_udp {
927 struct ib_uverbs_flow_spec_hdr hdr;
934 struct ib_uverbs_flow_tcp_udp_filter val;
935 struct ib_uverbs_flow_tcp_udp_filter mask;
938 struct ib_uverbs_flow_ipv6_filter {
948 struct ib_uverbs_flow_spec_ipv6 {
950 struct ib_uverbs_flow_spec_hdr hdr;
957 struct ib_uverbs_flow_ipv6_filter val;
958 struct ib_uverbs_flow_ipv6_filter mask;
961 struct ib_uverbs_flow_spec_action_tag {
963 struct ib_uverbs_flow_spec_hdr hdr;
974 struct ib_uverbs_flow_spec_action_drop {
976 struct ib_uverbs_flow_spec_hdr hdr;
985 struct ib_uverbs_flow_tunnel_filter {
989 struct ib_uverbs_flow_spec_tunnel {
991 struct ib_uverbs_flow_spec_hdr hdr;
998 struct ib_uverbs_flow_tunnel_filter val;
999 struct ib_uverbs_flow_tunnel_filter mask;
1002 struct ib_uverbs_flow_attr {
1010 /* Following are the optional layers according to user request
1011 * struct ib_flow_spec_xxx
1012 * struct ib_flow_spec_yyy
1014 struct ib_uverbs_flow_spec_hdr flow_specs[0];
1017 struct ib_uverbs_create_flow {
1020 struct ib_uverbs_flow_attr flow_attr;
1023 struct ib_uverbs_create_flow_resp {
1028 struct ib_uverbs_destroy_flow {
1033 struct ib_uverbs_create_srq {
1040 __u64 driver_data[0];
1043 struct ib_uverbs_create_xsrq {
1054 __u64 driver_data[0];
1057 struct ib_uverbs_create_srq_resp {
1064 struct ib_uverbs_modify_srq {
1069 __u64 driver_data[0];
1072 struct ib_uverbs_query_srq {
1076 __u64 driver_data[0];
1079 struct ib_uverbs_query_srq_resp {
1086 struct ib_uverbs_destroy_srq {
1092 struct ib_uverbs_destroy_srq_resp {
1093 __u32 events_reported;
1096 struct ib_uverbs_ex_create_wq {
1104 __u32 create_flags; /* Use enum ib_wq_flags */
1108 struct ib_uverbs_ex_create_wq_resp {
1110 __u32 response_length;
1117 struct ib_uverbs_ex_destroy_wq {
1122 struct ib_uverbs_ex_destroy_wq_resp {
1124 __u32 response_length;
1125 __u32 events_reported;
1129 struct ib_uverbs_ex_modify_wq {
1133 __u32 curr_wq_state;
1134 __u32 flags; /* Use enum ib_wq_flags */
1135 __u32 flags_mask; /* Use enum ib_wq_flags */
1138 /* Prevent memory allocation rather than max expected size */
1139 #define IB_USER_VERBS_MAX_LOG_IND_TBL_SIZE 0x0d
1140 struct ib_uverbs_ex_create_rwq_ind_table {
1142 __u32 log_ind_tbl_size;
1143 /* Following are the wq handles according to log_ind_tbl_size
1147 __u32 wq_handles[0];
1150 struct ib_uverbs_ex_create_rwq_ind_table_resp {
1152 __u32 response_length;
1153 __u32 ind_tbl_handle;
1157 struct ib_uverbs_ex_destroy_rwq_ind_table {
1159 __u32 ind_tbl_handle;
1162 struct ib_uverbs_cq_moderation {
1167 struct ib_uverbs_ex_modify_cq {
1170 struct ib_uverbs_cq_moderation attr;
1174 #define IB_DEVICE_NAME_MAX 64
1176 #endif /* IB_USER_VERBS_H */