xref: /openbmc/linux/include/uapi/rdma/rdma_user_cm.h (revision 8730046c)
1 /*
2  * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #ifndef RDMA_USER_CM_H
34 #define RDMA_USER_CM_H
35 
36 #include <linux/types.h>
37 #include <linux/socket.h>
38 #include <linux/in6.h>
39 #include <rdma/ib_user_verbs.h>
40 #include <rdma/ib_user_sa.h>
41 
42 #define RDMA_USER_CM_ABI_VERSION	4
43 
44 #define RDMA_MAX_PRIVATE_DATA		256
45 
46 enum {
47 	RDMA_USER_CM_CMD_CREATE_ID,
48 	RDMA_USER_CM_CMD_DESTROY_ID,
49 	RDMA_USER_CM_CMD_BIND_IP,
50 	RDMA_USER_CM_CMD_RESOLVE_IP,
51 	RDMA_USER_CM_CMD_RESOLVE_ROUTE,
52 	RDMA_USER_CM_CMD_QUERY_ROUTE,
53 	RDMA_USER_CM_CMD_CONNECT,
54 	RDMA_USER_CM_CMD_LISTEN,
55 	RDMA_USER_CM_CMD_ACCEPT,
56 	RDMA_USER_CM_CMD_REJECT,
57 	RDMA_USER_CM_CMD_DISCONNECT,
58 	RDMA_USER_CM_CMD_INIT_QP_ATTR,
59 	RDMA_USER_CM_CMD_GET_EVENT,
60 	RDMA_USER_CM_CMD_GET_OPTION,
61 	RDMA_USER_CM_CMD_SET_OPTION,
62 	RDMA_USER_CM_CMD_NOTIFY,
63 	RDMA_USER_CM_CMD_JOIN_IP_MCAST,
64 	RDMA_USER_CM_CMD_LEAVE_MCAST,
65 	RDMA_USER_CM_CMD_MIGRATE_ID,
66 	RDMA_USER_CM_CMD_QUERY,
67 	RDMA_USER_CM_CMD_BIND,
68 	RDMA_USER_CM_CMD_RESOLVE_ADDR,
69 	RDMA_USER_CM_CMD_JOIN_MCAST
70 };
71 
72 /*
73  * command ABI structures.
74  */
75 struct rdma_ucm_cmd_hdr {
76 	__u32 cmd;
77 	__u16 in;
78 	__u16 out;
79 };
80 
81 struct rdma_ucm_create_id {
82 	__u64 uid;
83 	__u64 response;
84 	__u16 ps;
85 	__u8  qp_type;
86 	__u8  reserved[5];
87 };
88 
89 struct rdma_ucm_create_id_resp {
90 	__u32 id;
91 };
92 
93 struct rdma_ucm_destroy_id {
94 	__u64 response;
95 	__u32 id;
96 	__u32 reserved;
97 };
98 
99 struct rdma_ucm_destroy_id_resp {
100 	__u32 events_reported;
101 };
102 
103 struct rdma_ucm_bind_ip {
104 	__u64 response;
105 	struct sockaddr_in6 addr;
106 	__u32 id;
107 };
108 
109 struct rdma_ucm_bind {
110 	__u32 id;
111 	__u16 addr_size;
112 	__u16 reserved;
113 	struct __kernel_sockaddr_storage addr;
114 };
115 
116 struct rdma_ucm_resolve_ip {
117 	struct sockaddr_in6 src_addr;
118 	struct sockaddr_in6 dst_addr;
119 	__u32 id;
120 	__u32 timeout_ms;
121 };
122 
123 struct rdma_ucm_resolve_addr {
124 	__u32 id;
125 	__u32 timeout_ms;
126 	__u16 src_size;
127 	__u16 dst_size;
128 	__u32 reserved;
129 	struct __kernel_sockaddr_storage src_addr;
130 	struct __kernel_sockaddr_storage dst_addr;
131 };
132 
133 struct rdma_ucm_resolve_route {
134 	__u32 id;
135 	__u32 timeout_ms;
136 };
137 
138 enum {
139 	RDMA_USER_CM_QUERY_ADDR,
140 	RDMA_USER_CM_QUERY_PATH,
141 	RDMA_USER_CM_QUERY_GID
142 };
143 
144 struct rdma_ucm_query {
145 	__u64 response;
146 	__u32 id;
147 	__u32 option;
148 };
149 
150 struct rdma_ucm_query_route_resp {
151 	__u64 node_guid;
152 	struct ib_user_path_rec ib_route[2];
153 	struct sockaddr_in6 src_addr;
154 	struct sockaddr_in6 dst_addr;
155 	__u32 num_paths;
156 	__u8 port_num;
157 	__u8 reserved[3];
158 };
159 
160 struct rdma_ucm_query_addr_resp {
161 	__u64 node_guid;
162 	__u8  port_num;
163 	__u8  reserved;
164 	__u16 pkey;
165 	__u16 src_size;
166 	__u16 dst_size;
167 	struct __kernel_sockaddr_storage src_addr;
168 	struct __kernel_sockaddr_storage dst_addr;
169 };
170 
171 struct rdma_ucm_query_path_resp {
172 	__u32 num_paths;
173 	__u32 reserved;
174 	struct ib_path_rec_data path_data[0];
175 };
176 
177 struct rdma_ucm_conn_param {
178 	__u32 qp_num;
179 	__u32 qkey;
180 	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
181 	__u8  private_data_len;
182 	__u8  srq;
183 	__u8  responder_resources;
184 	__u8  initiator_depth;
185 	__u8  flow_control;
186 	__u8  retry_count;
187 	__u8  rnr_retry_count;
188 	__u8  valid;
189 };
190 
191 struct rdma_ucm_ud_param {
192 	__u32 qp_num;
193 	__u32 qkey;
194 	struct ib_uverbs_ah_attr ah_attr;
195 	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
196 	__u8  private_data_len;
197 	__u8  reserved[7];
198 };
199 
200 struct rdma_ucm_connect {
201 	struct rdma_ucm_conn_param conn_param;
202 	__u32 id;
203 	__u32 reserved;
204 };
205 
206 struct rdma_ucm_listen {
207 	__u32 id;
208 	__u32 backlog;
209 };
210 
211 struct rdma_ucm_accept {
212 	__u64 uid;
213 	struct rdma_ucm_conn_param conn_param;
214 	__u32 id;
215 	__u32 reserved;
216 };
217 
218 struct rdma_ucm_reject {
219 	__u32 id;
220 	__u8  private_data_len;
221 	__u8  reserved[3];
222 	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
223 };
224 
225 struct rdma_ucm_disconnect {
226 	__u32 id;
227 };
228 
229 struct rdma_ucm_init_qp_attr {
230 	__u64 response;
231 	__u32 id;
232 	__u32 qp_state;
233 };
234 
235 struct rdma_ucm_notify {
236 	__u32 id;
237 	__u32 event;
238 };
239 
240 struct rdma_ucm_join_ip_mcast {
241 	__u64 response;		/* rdma_ucm_create_id_resp */
242 	__u64 uid;
243 	struct sockaddr_in6 addr;
244 	__u32 id;
245 };
246 
247 /* Multicast join flags */
248 enum {
249 	RDMA_MC_JOIN_FLAG_FULLMEMBER,
250 	RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER,
251 	RDMA_MC_JOIN_FLAG_RESERVED,
252 };
253 
254 struct rdma_ucm_join_mcast {
255 	__u64 response;		/* rdma_ucma_create_id_resp */
256 	__u64 uid;
257 	__u32 id;
258 	__u16 addr_size;
259 	__u16 join_flags;
260 	struct __kernel_sockaddr_storage addr;
261 };
262 
263 struct rdma_ucm_get_event {
264 	__u64 response;
265 };
266 
267 struct rdma_ucm_event_resp {
268 	__u64 uid;
269 	__u32 id;
270 	__u32 event;
271 	__u32 status;
272 	union {
273 		struct rdma_ucm_conn_param conn;
274 		struct rdma_ucm_ud_param   ud;
275 	} param;
276 };
277 
278 /* Option levels */
279 enum {
280 	RDMA_OPTION_ID		= 0,
281 	RDMA_OPTION_IB		= 1
282 };
283 
284 /* Option details */
285 enum {
286 	RDMA_OPTION_ID_TOS	 = 0,
287 	RDMA_OPTION_ID_REUSEADDR = 1,
288 	RDMA_OPTION_ID_AFONLY	 = 2,
289 	RDMA_OPTION_IB_PATH	 = 1
290 };
291 
292 struct rdma_ucm_set_option {
293 	__u64 optval;
294 	__u32 id;
295 	__u32 level;
296 	__u32 optname;
297 	__u32 optlen;
298 };
299 
300 struct rdma_ucm_migrate_id {
301 	__u64 response;
302 	__u32 id;
303 	__u32 fd;
304 };
305 
306 struct rdma_ucm_migrate_resp {
307 	__u32 events_reported;
308 };
309 
310 #endif /* RDMA_USER_CM_H */
311