blob: ed5a514305c1dc9612ab5f80a71aa5a8bc83d901 [file] [log] [blame]
Jason Gunthorped50e14a2018-04-20 09:49:10 -06001/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
Sean Hefty75216632006-11-30 16:53:41 -08002/*
3 * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 */
33
34#ifndef RDMA_USER_CM_H
35#define RDMA_USER_CM_H
36
37#include <linux/types.h>
Doug Ledforddb1044d2014-08-12 19:20:11 -040038#include <linux/socket.h>
Sean Hefty75216632006-11-30 16:53:41 -080039#include <linux/in6.h>
40#include <rdma/ib_user_verbs.h>
41#include <rdma/ib_user_sa.h>
42
Sean Heftyc8f6a362007-02-15 17:00:18 -080043#define RDMA_USER_CM_ABI_VERSION 4
Sean Hefty75216632006-11-30 16:53:41 -080044
45#define RDMA_MAX_PRIVATE_DATA 256
46
47enum {
48 RDMA_USER_CM_CMD_CREATE_ID,
49 RDMA_USER_CM_CMD_DESTROY_ID,
Sean Hefty05ad9452013-05-29 10:09:30 -070050 RDMA_USER_CM_CMD_BIND_IP,
51 RDMA_USER_CM_CMD_RESOLVE_IP,
Sean Hefty75216632006-11-30 16:53:41 -080052 RDMA_USER_CM_CMD_RESOLVE_ROUTE,
53 RDMA_USER_CM_CMD_QUERY_ROUTE,
54 RDMA_USER_CM_CMD_CONNECT,
55 RDMA_USER_CM_CMD_LISTEN,
56 RDMA_USER_CM_CMD_ACCEPT,
57 RDMA_USER_CM_CMD_REJECT,
58 RDMA_USER_CM_CMD_DISCONNECT,
59 RDMA_USER_CM_CMD_INIT_QP_ATTR,
60 RDMA_USER_CM_CMD_GET_EVENT,
61 RDMA_USER_CM_CMD_GET_OPTION,
62 RDMA_USER_CM_CMD_SET_OPTION,
Sean Heftyc8f6a362007-02-15 17:00:18 -080063 RDMA_USER_CM_CMD_NOTIFY,
Sean Hefty05ad9452013-05-29 10:09:30 -070064 RDMA_USER_CM_CMD_JOIN_IP_MCAST,
Sean Hefty88314e42007-11-14 00:29:50 -080065 RDMA_USER_CM_CMD_LEAVE_MCAST,
Sean Heftyee7aed42013-05-29 10:09:25 -070066 RDMA_USER_CM_CMD_MIGRATE_ID,
Sean Heftyeebe4c32013-05-29 10:09:31 -070067 RDMA_USER_CM_CMD_QUERY,
Sean Hefty209cf2a2013-05-29 10:09:32 -070068 RDMA_USER_CM_CMD_BIND,
Sean Hefty5bc2b7b2013-05-29 10:09:33 -070069 RDMA_USER_CM_CMD_RESOLVE_ADDR,
70 RDMA_USER_CM_CMD_JOIN_MCAST
Sean Hefty75216632006-11-30 16:53:41 -080071};
72
Steve Wise2253fc02018-03-27 08:38:07 -070073/* See IBTA Annex A11, servies ID bytes 4 & 5 */
74enum rdma_ucm_port_space {
75 RDMA_PS_IPOIB = 0x0002,
76 RDMA_PS_IB = 0x013F,
77 RDMA_PS_TCP = 0x0106,
78 RDMA_PS_UDP = 0x0111,
79};
80
Sean Hefty75216632006-11-30 16:53:41 -080081/*
82 * command ABI structures.
83 */
84struct rdma_ucm_cmd_hdr {
85 __u32 cmd;
86 __u16 in;
87 __u16 out;
88};
89
90struct rdma_ucm_create_id {
Jason Gunthorpe26b99062018-03-20 14:19:51 -060091 __aligned_u64 uid;
92 __aligned_u64 response;
Steve Wise2253fc02018-03-27 08:38:07 -070093 __u16 ps; /* use enum rdma_ucm_port_space */
Sean Hefty638ef7a2011-06-14 16:31:53 -070094 __u8 qp_type;
95 __u8 reserved[5];
Sean Hefty75216632006-11-30 16:53:41 -080096};
97
98struct rdma_ucm_create_id_resp {
99 __u32 id;
100};
101
102struct rdma_ucm_destroy_id {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600103 __aligned_u64 response;
Sean Hefty75216632006-11-30 16:53:41 -0800104 __u32 id;
105 __u32 reserved;
106};
107
108struct rdma_ucm_destroy_id_resp {
109 __u32 events_reported;
110};
111
Sean Hefty05ad9452013-05-29 10:09:30 -0700112struct rdma_ucm_bind_ip {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600113 __aligned_u64 response;
Sean Hefty75216632006-11-30 16:53:41 -0800114 struct sockaddr_in6 addr;
115 __u32 id;
116};
117
Sean Heftyeebe4c32013-05-29 10:09:31 -0700118struct rdma_ucm_bind {
119 __u32 id;
120 __u16 addr_size;
121 __u16 reserved;
Jason Gunthorpe35493292016-10-27 10:51:17 -0600122 struct __kernel_sockaddr_storage addr;
Sean Heftyeebe4c32013-05-29 10:09:31 -0700123};
124
Sean Hefty05ad9452013-05-29 10:09:30 -0700125struct rdma_ucm_resolve_ip {
Sean Hefty75216632006-11-30 16:53:41 -0800126 struct sockaddr_in6 src_addr;
127 struct sockaddr_in6 dst_addr;
128 __u32 id;
129 __u32 timeout_ms;
130};
131
Sean Hefty209cf2a2013-05-29 10:09:32 -0700132struct rdma_ucm_resolve_addr {
133 __u32 id;
134 __u32 timeout_ms;
135 __u16 src_size;
136 __u16 dst_size;
137 __u32 reserved;
Jason Gunthorpe35493292016-10-27 10:51:17 -0600138 struct __kernel_sockaddr_storage src_addr;
139 struct __kernel_sockaddr_storage dst_addr;
Sean Hefty209cf2a2013-05-29 10:09:32 -0700140};
141
Sean Hefty75216632006-11-30 16:53:41 -0800142struct rdma_ucm_resolve_route {
143 __u32 id;
144 __u32 timeout_ms;
145};
146
Sean Heftyee7aed42013-05-29 10:09:25 -0700147enum {
Sean Heftyac53b262013-05-29 10:09:27 -0700148 RDMA_USER_CM_QUERY_ADDR,
Sean Heftyedaa7a52013-05-29 10:09:29 -0700149 RDMA_USER_CM_QUERY_PATH,
150 RDMA_USER_CM_QUERY_GID
Sean Heftyee7aed42013-05-29 10:09:25 -0700151};
152
153struct rdma_ucm_query {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600154 __aligned_u64 response;
Sean Hefty75216632006-11-30 16:53:41 -0800155 __u32 id;
Sean Heftyee7aed42013-05-29 10:09:25 -0700156 __u32 option;
Sean Hefty75216632006-11-30 16:53:41 -0800157};
158
159struct rdma_ucm_query_route_resp {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600160 __aligned_u64 node_guid;
Sean Hefty75216632006-11-30 16:53:41 -0800161 struct ib_user_path_rec ib_route[2];
162 struct sockaddr_in6 src_addr;
163 struct sockaddr_in6 dst_addr;
164 __u32 num_paths;
165 __u8 port_num;
166 __u8 reserved[3];
Leon Romanovsky17793832020-05-04 16:25:41 +0300167 __u32 ibdev_index;
168 __u32 reserved1;
Sean Hefty75216632006-11-30 16:53:41 -0800169};
170
Sean Heftyee7aed42013-05-29 10:09:25 -0700171struct rdma_ucm_query_addr_resp {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600172 __aligned_u64 node_guid;
Sean Heftyee7aed42013-05-29 10:09:25 -0700173 __u8 port_num;
174 __u8 reserved;
175 __u16 pkey;
176 __u16 src_size;
177 __u16 dst_size;
Jason Gunthorpe35493292016-10-27 10:51:17 -0600178 struct __kernel_sockaddr_storage src_addr;
179 struct __kernel_sockaddr_storage dst_addr;
Leon Romanovsky17793832020-05-04 16:25:41 +0300180 __u32 ibdev_index;
181 __u32 reserved1;
Sean Heftyee7aed42013-05-29 10:09:25 -0700182};
183
Sean Heftyac53b262013-05-29 10:09:27 -0700184struct rdma_ucm_query_path_resp {
185 __u32 num_paths;
186 __u32 reserved;
187 struct ib_path_rec_data path_data[0];
188};
189
Sean Hefty75216632006-11-30 16:53:41 -0800190struct rdma_ucm_conn_param {
191 __u32 qp_num;
Sean Hefty5c438132013-05-29 10:09:23 -0700192 __u32 qkey;
Sean Hefty75216632006-11-30 16:53:41 -0800193 __u8 private_data[RDMA_MAX_PRIVATE_DATA];
194 __u8 private_data_len;
195 __u8 srq;
196 __u8 responder_resources;
197 __u8 initiator_depth;
198 __u8 flow_control;
199 __u8 retry_count;
200 __u8 rnr_retry_count;
201 __u8 valid;
202};
203
204struct rdma_ucm_ud_param {
205 __u32 qp_num;
206 __u32 qkey;
207 struct ib_uverbs_ah_attr ah_attr;
208 __u8 private_data[RDMA_MAX_PRIVATE_DATA];
209 __u8 private_data_len;
210 __u8 reserved[7];
211};
212
Leon Romanovsky34e2ab52020-05-26 13:33:00 +0300213struct rdma_ucm_ece {
214 __u32 vendor_id;
215 __u32 attr_mod;
216};
217
Sean Hefty75216632006-11-30 16:53:41 -0800218struct rdma_ucm_connect {
219 struct rdma_ucm_conn_param conn_param;
220 __u32 id;
221 __u32 reserved;
Leon Romanovsky34e2ab52020-05-26 13:33:00 +0300222 struct rdma_ucm_ece ece;
Sean Hefty75216632006-11-30 16:53:41 -0800223};
224
225struct rdma_ucm_listen {
226 __u32 id;
227 __u32 backlog;
228};
229
230struct rdma_ucm_accept {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600231 __aligned_u64 uid;
Sean Hefty75216632006-11-30 16:53:41 -0800232 struct rdma_ucm_conn_param conn_param;
233 __u32 id;
234 __u32 reserved;
Leon Romanovsky0cb15372020-05-26 13:33:03 +0300235 struct rdma_ucm_ece ece;
Sean Hefty75216632006-11-30 16:53:41 -0800236};
237
238struct rdma_ucm_reject {
239 __u32 id;
240 __u8 private_data_len;
Leon Romanovsky8094ba02020-05-26 13:33:04 +0300241 __u8 reason;
242 __u8 reserved[2];
Sean Hefty75216632006-11-30 16:53:41 -0800243 __u8 private_data[RDMA_MAX_PRIVATE_DATA];
244};
245
246struct rdma_ucm_disconnect {
247 __u32 id;
248};
249
250struct rdma_ucm_init_qp_attr {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600251 __aligned_u64 response;
Sean Hefty75216632006-11-30 16:53:41 -0800252 __u32 id;
253 __u32 qp_state;
254};
255
256struct rdma_ucm_notify {
257 __u32 id;
258 __u32 event;
259};
260
Sean Hefty05ad9452013-05-29 10:09:30 -0700261struct rdma_ucm_join_ip_mcast {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600262 __aligned_u64 response; /* rdma_ucm_create_id_resp */
263 __aligned_u64 uid;
Sean Heftyc8f6a362007-02-15 17:00:18 -0800264 struct sockaddr_in6 addr;
265 __u32 id;
266};
267
Alex Veskerab15c952016-07-06 16:36:35 +0300268/* Multicast join flags */
269enum {
270 RDMA_MC_JOIN_FLAG_FULLMEMBER,
271 RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER,
272 RDMA_MC_JOIN_FLAG_RESERVED,
273};
274
Sean Hefty5bc2b7b2013-05-29 10:09:33 -0700275struct rdma_ucm_join_mcast {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600276 __aligned_u64 response; /* rdma_ucma_create_id_resp */
277 __aligned_u64 uid;
Sean Hefty5bc2b7b2013-05-29 10:09:33 -0700278 __u32 id;
279 __u16 addr_size;
Alex Veskerab15c952016-07-06 16:36:35 +0300280 __u16 join_flags;
Jason Gunthorpe35493292016-10-27 10:51:17 -0600281 struct __kernel_sockaddr_storage addr;
Sean Hefty5bc2b7b2013-05-29 10:09:33 -0700282};
283
Sean Hefty75216632006-11-30 16:53:41 -0800284struct rdma_ucm_get_event {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600285 __aligned_u64 response;
Sean Hefty75216632006-11-30 16:53:41 -0800286};
287
288struct rdma_ucm_event_resp {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600289 __aligned_u64 uid;
Sean Hefty75216632006-11-30 16:53:41 -0800290 __u32 id;
291 __u32 event;
292 __u32 status;
Jason Gunthorpe611cb922018-03-20 14:19:47 -0600293 /*
294 * NOTE: This union is not aligned to 8 bytes so none of the union
295 * members may contain a u64 or anything with higher alignment than 4.
296 */
Sean Hefty75216632006-11-30 16:53:41 -0800297 union {
298 struct rdma_ucm_conn_param conn;
299 struct rdma_ucm_ud_param ud;
300 } param;
Jason Gunthorpe611cb922018-03-20 14:19:47 -0600301 __u32 reserved;
Leon Romanovsky93531ee2020-05-26 13:33:01 +0300302 struct rdma_ucm_ece ece;
Sean Hefty75216632006-11-30 16:53:41 -0800303};
304
Sean Hefty7ce86402007-08-08 15:51:13 -0700305/* Option levels */
306enum {
Sean Heftya7ca1f02009-11-16 09:30:33 -0800307 RDMA_OPTION_ID = 0,
308 RDMA_OPTION_IB = 1
Sean Hefty7ce86402007-08-08 15:51:13 -0700309};
310
311/* Option details */
312enum {
Hefty, Seana9bb7912011-05-09 22:06:10 -0700313 RDMA_OPTION_ID_TOS = 0,
314 RDMA_OPTION_ID_REUSEADDR = 1,
Sean Hefty68602122012-06-14 20:31:39 +0000315 RDMA_OPTION_ID_AFONLY = 2,
Danit Goldberg2c1619e2019-01-24 14:18:15 +0200316 RDMA_OPTION_ID_ACK_TIMEOUT = 3
317};
318
319enum {
Hefty, Seana9bb7912011-05-09 22:06:10 -0700320 RDMA_OPTION_IB_PATH = 1
Sean Hefty7ce86402007-08-08 15:51:13 -0700321};
322
323struct rdma_ucm_set_option {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600324 __aligned_u64 optval;
Sean Hefty7ce86402007-08-08 15:51:13 -0700325 __u32 id;
326 __u32 level;
327 __u32 optname;
328 __u32 optlen;
329};
330
Sean Hefty88314e42007-11-14 00:29:50 -0800331struct rdma_ucm_migrate_id {
Jason Gunthorpe26b99062018-03-20 14:19:51 -0600332 __aligned_u64 response;
Sean Hefty88314e42007-11-14 00:29:50 -0800333 __u32 id;
334 __u32 fd;
335};
336
337struct rdma_ucm_migrate_resp {
338 __u32 events_reported;
339};
340
Sean Hefty75216632006-11-30 16:53:41 -0800341#endif /* RDMA_USER_CM_H */