1 /*
2  * Copyright (c) 2005-2011 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_CMA_ABI_H
34 #define RDMA_CMA_ABI_H
35 
36 #include <infiniband/kern-abi.h>
37 #include <rdma/ib_user_sa.h>
38 #include <infiniband/sa.h>
39 #include <netinet/in.h>
40 
41 /*
42  * This file must be kept in sync with the kernel's version of rdma_user_cm.h
43  */
44 
45 #define RDMA_USER_CM_MIN_ABI_VERSION	3
46 #define RDMA_USER_CM_MAX_ABI_VERSION	4
47 
48 #define RDMA_MAX_PRIVATE_DATA		256
49 
50 enum {
51 	UCMA_CMD_CREATE_ID,
52 	UCMA_CMD_DESTROY_ID,
53 	UCMA_CMD_BIND_IP,
54 	UCMA_CMD_RESOLVE_IP,
55 	UCMA_CMD_RESOLVE_ROUTE,
56 	UCMA_CMD_QUERY_ROUTE,
57 	UCMA_CMD_CONNECT,
58 	UCMA_CMD_LISTEN,
59 	UCMA_CMD_ACCEPT,
60 	UCMA_CMD_REJECT,
61 	UCMA_CMD_DISCONNECT,
62 	UCMA_CMD_INIT_QP_ATTR,
63 	UCMA_CMD_GET_EVENT,
64 	UCMA_CMD_GET_OPTION,
65 	UCMA_CMD_SET_OPTION,
66 	UCMA_CMD_NOTIFY,
67  	UCMA_CMD_JOIN_IP_MCAST,
68  	UCMA_CMD_LEAVE_MCAST,
69 	UCMA_CMD_MIGRATE_ID,
70 	UCMA_CMD_QUERY,
71 	UCMA_CMD_BIND,
72 	UCMA_CMD_RESOLVE_ADDR,
73 	UCMA_CMD_JOIN_MCAST
74 };
75 
76 struct ucma_abi_cmd_hdr {
77 	__u32 cmd;
78 	__u16 in;
79 	__u16 out;
80 };
81 
82 struct ucma_abi_create_id {
83 	__u32 cmd;
84 	__u16 in;
85 	__u16 out;
86 	__u64 uid;
87 	__u64 response;
88 	__u16 ps;
89 	__u8  qp_type;
90 	__u8  reserved[5];
91 };
92 
93 struct ucma_abi_create_id_resp {
94 	__u32 id;
95 };
96 
97 struct ucma_abi_destroy_id {
98 	__u32 cmd;
99 	__u16 in;
100 	__u16 out;
101 	__u64 response;
102 	__u32 id;
103 	__u32 reserved;
104 };
105 
106 struct ucma_abi_destroy_id_resp {
107 	__u32 events_reported;
108 };
109 
110 struct ucma_abi_bind_ip {
111 	__u32 cmd;
112 	__u16 in;
113 	__u16 out;
114 	__u64 response;
115 	struct sockaddr_in6 addr;
116 	__u32 id;
117 };
118 
119 struct ucma_abi_bind {
120 	__u32 cmd;
121 	__u16 in;
122 	__u16 out;
123 	__u32 id;
124 	__u16 addr_size;
125 	__u16 reserved;
126 	struct sockaddr_storage addr;
127 };
128 
129 struct ucma_abi_resolve_ip {
130 	__u32 cmd;
131 	__u16 in;
132 	__u16 out;
133 	struct sockaddr_in6 src_addr;
134 	struct sockaddr_in6 dst_addr;
135 	__u32 id;
136 	__u32 timeout_ms;
137 };
138 
139 struct ucma_abi_resolve_addr {
140 	__u32 cmd;
141 	__u16 in;
142 	__u16 out;
143 	__u32 id;
144 	__u32 timeout_ms;
145 	__u16 src_size;
146 	__u16 dst_size;
147 	__u32 reserved;
148 	struct sockaddr_storage src_addr;
149 	struct sockaddr_storage dst_addr;
150 };
151 
152 struct ucma_abi_resolve_route {
153 	__u32 cmd;
154 	__u16 in;
155 	__u16 out;
156 	__u32 id;
157 	__u32 timeout_ms;
158 };
159 
160 enum {
161 	UCMA_QUERY_ADDR,
162 	UCMA_QUERY_PATH,
163 	UCMA_QUERY_GID
164 };
165 
166 struct ucma_abi_query {
167 	__u32 cmd;
168 	__u16 in;
169 	__u16 out;
170 	__u64 response;
171 	__u32 id;
172 	__u32 option;
173 };
174 
175 struct ucma_abi_query_route_resp {
176 	__be64 node_guid;
177 	struct ib_user_path_rec ib_route[2];
178 	struct sockaddr_in6 src_addr;
179 	struct sockaddr_in6 dst_addr;
180 	__u32 num_paths;
181 	__u8 port_num;
182 	__u8 reserved[3];
183 };
184 
185 struct ucma_abi_query_addr_resp {
186 	__be64 node_guid;
187 	__u8  port_num;
188 	__u8  reserved;
189 	__be16 pkey;
190 	__u16 src_size;
191 	__u16 dst_size;
192 	struct sockaddr_storage src_addr;
193 	struct sockaddr_storage dst_addr;
194 };
195 
196 struct ucma_abi_query_path_resp {
197 	__u32 num_paths;
198 	__u32 reserved;
199 	struct ibv_path_data path_data[0];
200 };
201 
202 struct ucma_abi_conn_param {
203 	__u32 qp_num;
204 	__u32 reserved;
205 	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
206 	__u8  private_data_len;
207 	__u8  srq;
208 	__u8  responder_resources;
209 	__u8  initiator_depth;
210 	__u8  flow_control;
211 	__u8  retry_count;
212 	__u8  rnr_retry_count;
213 	__u8  valid;
214 };
215 
216 struct ucma_abi_ud_param {
217 	__u32 qp_num;
218 	__u32 qkey;
219 	struct ibv_kern_ah_attr ah_attr;
220 	__u8 private_data[RDMA_MAX_PRIVATE_DATA];
221 	__u8 private_data_len;
222 	__u8 reserved[7];
223 	__u8 reserved2[4];  /* Round to 8-byte boundary to support 32/64 */
224 };
225 
226 struct ucma_abi_connect {
227 	__u32 cmd;
228 	__u16 in;
229 	__u16 out;
230 	struct ucma_abi_conn_param conn_param;
231 	__u32 id;
232 	__u32 reserved;
233 };
234 
235 struct ucma_abi_listen {
236 	__u32 cmd;
237 	__u16 in;
238 	__u16 out;
239 	__u32 id;
240 	__u32 backlog;
241 };
242 
243 struct ucma_abi_accept {
244 	__u32 cmd;
245 	__u16 in;
246 	__u16 out;
247 	__u64 uid;
248 	struct ucma_abi_conn_param conn_param;
249 	__u32 id;
250 	__u32 reserved;
251 };
252 
253 struct ucma_abi_reject {
254 	__u32 cmd;
255 	__u16 in;
256 	__u16 out;
257 	__u32 id;
258 	__u8  private_data_len;
259 	__u8  reserved[3];
260 	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
261 };
262 
263 struct ucma_abi_disconnect {
264 	__u32 cmd;
265 	__u16 in;
266 	__u16 out;
267 	__u32 id;
268 };
269 
270 struct ucma_abi_init_qp_attr {
271 	__u32 cmd;
272 	__u16 in;
273 	__u16 out;
274 	__u64 response;
275 	__u32 id;
276 	__u32 qp_state;
277 };
278 
279 struct ucma_abi_notify {
280 	__u32 cmd;
281 	__u16 in;
282 	__u16 out;
283 	__u32 id;
284 	__u32 event;
285 };
286 
287 struct ucma_abi_join_ip_mcast {
288 	__u32 cmd;
289 	__u16 in;
290 	__u16 out;
291 	__u64 response;		/* ucma_abi_create_id_resp */
292 	__u64 uid;
293 	struct sockaddr_in6 addr;
294 	__u32 id;
295 };
296 
297 struct ucma_abi_join_mcast {
298 	__u32 cmd;
299 	__u16 in;
300 	__u16 out;
301 	__u64 response;		/* rdma_ucma_create_id_resp */
302 	__u64 uid;
303 	__u32 id;
304 	__u16 addr_size;
305 	__u16 reserved;
306 	struct sockaddr_storage addr;
307 };
308 
309 struct ucma_abi_get_event {
310 	__u32 cmd;
311 	__u16 in;
312 	__u16 out;
313 	__u64 response;
314 };
315 
316 struct ucma_abi_event_resp {
317 	__u64 uid;
318 	__u32 id;
319 	__u32 event;
320 	__u32 status;
321 	union {
322 		struct ucma_abi_conn_param conn;
323 		struct ucma_abi_ud_param   ud;
324 	} param;
325 };
326 
327 struct ucma_abi_set_option {
328 	__u32 cmd;
329 	__u16 in;
330 	__u16 out;
331 	__u64 optval;
332 	__u32 id;
333 	__u32 level;
334 	__u32 optname;
335 	__u32 optlen;
336 };
337 
338 struct ucma_abi_migrate_id {
339 	__u32 cmd;
340 	__u16 in;
341 	__u16 out;
342 	__u64 response;
343 	__u32 id;
344 	__u32 fd;
345 };
346 
347 struct ucma_abi_migrate_resp {
348 	__u32 events_reported;
349 };
350 
351 #endif /* RDMA_CMA_ABI_H */
352