xref: /freebsd/sys/ofed/include/uapi/rdma/ib_user_cm.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3  *
4  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
5  * Copyright (c) 2005 Intel Corporation.  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_CM_H
37 #define IB_USER_CM_H
38 
39 #ifdef _KERNEL
40 #include <linux/types.h>
41 #else
42 #include <infiniband/types.h>
43 #endif
44 #include <rdma/ib_user_sa.h>
45 
46 #define IB_USER_CM_ABI_VERSION 5
47 
48 enum {
49 	IB_USER_CM_CMD_CREATE_ID,
50 	IB_USER_CM_CMD_DESTROY_ID,
51 	IB_USER_CM_CMD_ATTR_ID,
52 
53 	IB_USER_CM_CMD_LISTEN,
54 	IB_USER_CM_CMD_NOTIFY,
55 
56 	IB_USER_CM_CMD_SEND_REQ,
57 	IB_USER_CM_CMD_SEND_REP,
58 	IB_USER_CM_CMD_SEND_RTU,
59 	IB_USER_CM_CMD_SEND_DREQ,
60 	IB_USER_CM_CMD_SEND_DREP,
61 	IB_USER_CM_CMD_SEND_REJ,
62 	IB_USER_CM_CMD_SEND_MRA,
63 	IB_USER_CM_CMD_SEND_LAP,
64 	IB_USER_CM_CMD_SEND_APR,
65 	IB_USER_CM_CMD_SEND_SIDR_REQ,
66 	IB_USER_CM_CMD_SEND_SIDR_REP,
67 
68 	IB_USER_CM_CMD_EVENT,
69 	IB_USER_CM_CMD_INIT_QP_ATTR,
70 };
71 /*
72  * command ABI structures.
73  */
74 struct ib_ucm_cmd_hdr {
75 	__u32 cmd;
76 	__u16 in;
77 	__u16 out;
78 };
79 
80 struct ib_ucm_create_id {
81 	__u64 uid;
82 	__u64 response;
83 };
84 
85 struct ib_ucm_create_id_resp {
86 	__u32 id;
87 };
88 
89 struct ib_ucm_destroy_id {
90 	__u64 response;
91 	__u32 id;
92 	__u32 reserved;
93 };
94 
95 struct ib_ucm_destroy_id_resp {
96 	__u32 events_reported;
97 };
98 
99 struct ib_ucm_attr_id {
100 	__u64 response;
101 	__u32 id;
102 	__u32 reserved;
103 };
104 
105 struct ib_ucm_attr_id_resp {
106 	__be64 service_id;
107 	__be64 service_mask;
108 	__be32 local_id;
109 	__be32 remote_id;
110 };
111 
112 struct ib_ucm_init_qp_attr {
113 	__u64 response;
114 	__u32 id;
115 	__u32 qp_state;
116 };
117 
118 struct ib_ucm_listen {
119 	__be64 service_id;
120 	__be64 service_mask;
121 	__u32 id;
122 	__u32 reserved;
123 };
124 
125 struct ib_ucm_notify {
126 	__u32 id;
127 	__u32 event;
128 };
129 
130 struct ib_ucm_private_data {
131 	__u64 data;
132 	__u32 id;
133 	__u8  len;
134 	__u8  reserved[3];
135 };
136 
137 struct ib_ucm_req {
138 	__u32 id;
139 	__u32 qpn;
140 	__u32 qp_type;
141 	__u32 psn;
142 	__be64 sid;
143 	__u64 data;
144 	__u64 primary_path;
145 	__u64 alternate_path;
146 	__u8  len;
147 	__u8  peer_to_peer;
148 	__u8  responder_resources;
149 	__u8  initiator_depth;
150 	__u8  remote_cm_response_timeout;
151 	__u8  flow_control;
152 	__u8  local_cm_response_timeout;
153 	__u8  retry_count;
154 	__u8  rnr_retry_count;
155 	__u8  max_cm_retries;
156 	__u8  srq;
157 	__u8  reserved[5];
158 };
159 
160 struct ib_ucm_rep {
161 	__u64 uid;
162 	__u64 data;
163 	__u32 id;
164 	__u32 qpn;
165 	__u32 psn;
166 	__u8  len;
167 	__u8  responder_resources;
168 	__u8  initiator_depth;
169 	__u8  target_ack_delay;
170 	__u8  failover_accepted;
171 	__u8  flow_control;
172 	__u8  rnr_retry_count;
173 	__u8  srq;
174 	__u8  reserved[4];
175 };
176 
177 struct ib_ucm_info {
178 	__u32 id;
179 	__u32 status;
180 	__u64 info;
181 	__u64 data;
182 	__u8  info_len;
183 	__u8  data_len;
184 	__u8  reserved[6];
185 };
186 
187 struct ib_ucm_mra {
188 	__u64 data;
189 	__u32 id;
190 	__u8  len;
191 	__u8  timeout;
192 	__u8  reserved[2];
193 };
194 
195 struct ib_ucm_lap {
196 	__u64 path;
197 	__u64 data;
198 	__u32 id;
199 	__u8  len;
200 	__u8  reserved[3];
201 };
202 
203 struct ib_ucm_sidr_req {
204 	__u32 id;
205 	__u32 timeout;
206 	__be64 sid;
207 	__u64 data;
208 	__u64 path;
209 	__u16 reserved_pkey;
210 	__u8  len;
211 	__u8  max_cm_retries;
212 	__u8  reserved[4];
213 };
214 
215 struct ib_ucm_sidr_rep {
216 	__u32 id;
217 	__u32 qpn;
218 	__u32 qkey;
219 	__u32 status;
220 	__u64 info;
221 	__u64 data;
222 	__u8  info_len;
223 	__u8  data_len;
224 	__u8  reserved[6];
225 };
226 /*
227  * event notification ABI structures.
228  */
229 struct ib_ucm_event_get {
230 	__u64 response;
231 	__u64 data;
232 	__u64 info;
233 	__u8  data_len;
234 	__u8  info_len;
235 	__u8  reserved[6];
236 };
237 
238 struct ib_ucm_req_event_resp {
239 	struct ib_user_path_rec primary_path;
240 	struct ib_user_path_rec alternate_path;
241 	__be64                 remote_ca_guid;
242 	__u32                  remote_qkey;
243 	__u32                  remote_qpn;
244 	__u32                  qp_type;
245 	__u32                  starting_psn;
246 	__u8  responder_resources;
247 	__u8  initiator_depth;
248 	__u8  local_cm_response_timeout;
249 	__u8  flow_control;
250 	__u8  remote_cm_response_timeout;
251 	__u8  retry_count;
252 	__u8  rnr_retry_count;
253 	__u8  srq;
254 	__u8  port;
255 	__u8  reserved[7];
256 };
257 
258 struct ib_ucm_rep_event_resp {
259 	__be64 remote_ca_guid;
260 	__u32 remote_qkey;
261 	__u32 remote_qpn;
262 	__u32 starting_psn;
263 	__u8  responder_resources;
264 	__u8  initiator_depth;
265 	__u8  target_ack_delay;
266 	__u8  failover_accepted;
267 	__u8  flow_control;
268 	__u8  rnr_retry_count;
269 	__u8  srq;
270 	__u8  reserved[5];
271 };
272 
273 struct ib_ucm_rej_event_resp {
274 	__u32 reason;
275 	/* ari in ib_ucm_event_get info field. */
276 };
277 
278 struct ib_ucm_mra_event_resp {
279 	__u8  timeout;
280 	__u8  reserved[3];
281 };
282 
283 struct ib_ucm_lap_event_resp {
284 	struct ib_user_path_rec path;
285 };
286 
287 struct ib_ucm_apr_event_resp {
288 	__u32 status;
289 	/* apr info in ib_ucm_event_get info field. */
290 };
291 
292 struct ib_ucm_sidr_req_event_resp {
293 	__u16 pkey;
294 	__u8  port;
295 	__u8  reserved;
296 };
297 
298 struct ib_ucm_sidr_rep_event_resp {
299 	__u32 status;
300 	__u32 qkey;
301 	__u32 qpn;
302 	/* info in ib_ucm_event_get info field. */
303 };
304 
305 #define IB_UCM_PRES_DATA      0x01
306 #define IB_UCM_PRES_INFO      0x02
307 #define IB_UCM_PRES_PRIMARY   0x04
308 #define IB_UCM_PRES_ALTERNATE 0x08
309 
310 struct ib_ucm_event_resp {
311 	__u64 uid;
312 	__u32 id;
313 	__u32 event;
314 	__u32 present;
315 	__u32 reserved;
316 	union {
317 		struct ib_ucm_req_event_resp req_resp;
318 		struct ib_ucm_rep_event_resp rep_resp;
319 		struct ib_ucm_rej_event_resp rej_resp;
320 		struct ib_ucm_mra_event_resp mra_resp;
321 		struct ib_ucm_lap_event_resp lap_resp;
322 		struct ib_ucm_apr_event_resp apr_resp;
323 
324 		struct ib_ucm_sidr_req_event_resp sidr_req_resp;
325 		struct ib_ucm_sidr_rep_event_resp sidr_rep_resp;
326 
327 		__u32                             send_status;
328 	} u;
329 };
330 
331 #endif /* IB_USER_CM_H */
332