1 /*
2  * This file contains definitions used in OFED defined user/kernel
3  * interfaces. These are imported from the OFED header rdma_user_cm.h. Oracle
4  * elects to have and use the contents of rdma_user_cm.h under and governed
5  * by the OpenIB.org BSD license (see below for for full license text).
6  * However, * the following notice accompanied the original version of this
7  * file:
8  */
9 
10 /*
11  * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
12  *
13  * This software is available to you under a choice of one of two
14  * licenses.  You may choose to be licensed under the terms of the GNU
15  * General Public License (GPL) Version 2, available from the file
16  * COPYING in the main directory of this source tree, or the
17  * OpenIB.org BSD license below:
18  *
19  *     Redistribution and use in source and binary forms, with or
20  *     without modification, are permitted provided that the following
21  *     conditions are met:
22  *
23  *      - Redistributions of source code must retain the above
24  *        copyright notice, this list of conditions and the following
25  *        disclaimer.
26  *
27  *      - Redistributions in binary form must reproduce the above
28  *        copyright notice, this list of conditions and the following
29  *        disclaimer in the documentation and/or other materials
30  *        provided with the distribution.
31  *
32  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
36  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
37  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
38  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39  * SOFTWARE.
40  */
41 
42 #ifndef _SYS_IB_CLIENTS_OF_RDMA_RDMA_USER_CM_H
43 #define	_SYS_IB_CLIENTS_OF_RDMA_RDMA_USER_CM_H
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #include <sys/types.h>
50 #include <sys/socket.h>
51 #include <sys/ib/clients/of/rdma/ib_user_verbs.h>
52 #include <sys/ib/clients/of/rdma/ib_user_sa.h>
53 
54 #define	RDMA_USER_CM_ABI_VERSION	4
55 
56 #define	RDMA_MAX_PRIVATE_DATA		256
57 
58 #pragma pack(1)
59 enum {
60 	RDMA_USER_CM_CMD_CREATE_ID,
61 	RDMA_USER_CM_CMD_DESTROY_ID,
62 	RDMA_USER_CM_CMD_BIND_ADDR,
63 	RDMA_USER_CM_CMD_RESOLVE_ADDR,
64 	RDMA_USER_CM_CMD_RESOLVE_ROUTE,
65 	RDMA_USER_CM_CMD_QUERY_ROUTE,
66 	RDMA_USER_CM_CMD_CONNECT,
67 	RDMA_USER_CM_CMD_LISTEN,
68 	RDMA_USER_CM_CMD_ACCEPT,
69 	RDMA_USER_CM_CMD_REJECT,
70 	RDMA_USER_CM_CMD_DISCONNECT,
71 	RDMA_USER_CM_CMD_INIT_QP_ATTR,
72 	RDMA_USER_CM_CMD_GET_EVENT,
73 	RDMA_USER_CM_CMD_GET_OPTION,
74 	RDMA_USER_CM_CMD_SET_OPTION,
75 	RDMA_USER_CM_CMD_NOTIFY,
76 	RDMA_USER_CM_CMD_JOIN_MCAST,
77 	RDMA_USER_CM_CMD_LEAVE_MCAST
78 };
79 
80 /*
81  * command ABI structures.
82  */
83 struct rdma_ucm_cmd_hdr {
84 	uint32_t cmd;
85 	uint16_t in;
86 	uint16_t out;
87 };
88 
89 struct rdma_ucm_create_id {
90 	uint64_t uid;
91 	ofv_resp_addr_t response;
92 	uint16_t ps;
93 	uint8_t  reserved[6];
94 };
95 
96 struct rdma_ucm_create_id_resp {
97 	uint32_t id;
98 };
99 
100 struct rdma_ucm_destroy_id {
101 	ofv_resp_addr_t response;
102 	uint32_t id;
103 	uint32_t reserved;
104 };
105 
106 struct rdma_ucm_destroy_id_resp {
107 	uint32_t events_reported;
108 };
109 
110 struct rdma_ucm_bind_addr {
111 	uint64_t response;
112 	struct sockaddr_in6 addr;
113 	uint32_t id;
114 	uint32_t reserved;
115 };
116 
117 struct rdma_ucm_resolve_addr {
118 	struct sockaddr_in6 src_addr;
119 	struct sockaddr_in6 dst_addr;
120 	uint32_t id;
121 	uint32_t timeout_ms;
122 };
123 
124 struct rdma_ucm_resolve_route {
125 	uint32_t id;
126 	uint32_t timeout_ms;
127 };
128 
129 struct rdma_ucm_query_route {
130 	ofv_resp_addr_t response;
131 	uint32_t id;
132 	uint32_t reserved;
133 };
134 
135 struct rdma_ucm_query_route_resp {
136 	uint64_t node_guid;
137 	struct ib_user_path_rec ib_route[2];
138 	struct sockaddr_in6 src_addr;
139 	struct sockaddr_in6 dst_addr;
140 	uint32_t num_paths;
141 	uint8_t port_num;
142 	uint8_t reserved[3];
143 };
144 
145 struct rdma_ucm_conn_param {
146 	uint32_t qp_num;
147 	uint32_t reserved;
148 	uint8_t  private_data[RDMA_MAX_PRIVATE_DATA];
149 	uint8_t  private_data_len;
150 	uint8_t  srq;
151 	uint8_t  responder_resources;
152 	uint8_t  initiator_depth;
153 	uint8_t  flow_control;
154 	uint8_t  retry_count;
155 	uint8_t  rnr_retry_count;
156 	uint8_t  valid;
157 };
158 
159 struct rdma_ucm_ud_param {
160 	uint32_t qp_num;
161 	uint32_t qkey;
162 	struct ib_uverbs_ah_attr ah_attr;
163 	uint8_t  private_data[RDMA_MAX_PRIVATE_DATA];
164 	uint8_t  private_data_len;
165 	uint8_t  reserved[7];
166 	uint8_t  reserved2[4];
167 };
168 
169 struct rdma_ucm_connect {
170 	struct rdma_ucm_conn_param conn_param;
171 	uint32_t id;
172 	uint32_t reserved;
173 };
174 
175 struct rdma_ucm_listen {
176 	uint32_t id;
177 	uint32_t backlog;
178 };
179 
180 struct rdma_ucm_accept {
181 	uint64_t uid;
182 	struct rdma_ucm_conn_param conn_param;
183 	uint32_t id;
184 	uint32_t reserved;
185 };
186 
187 struct rdma_ucm_reject {
188 	uint32_t id;
189 	uint8_t  private_data_len;
190 	uint8_t  reserved[3];
191 	uint8_t  private_data[RDMA_MAX_PRIVATE_DATA];
192 };
193 
194 struct rdma_ucm_disconnect {
195 	uint32_t id;
196 };
197 
198 struct rdma_ucm_init_qp_attr {
199 	ofv_resp_addr_t response;
200 	uint32_t id;
201 	uint32_t qp_state;
202 };
203 
204 struct rdma_ucm_notify {
205 	uint32_t id;
206 	uint32_t event;
207 };
208 
209 struct rdma_ucm_join_mcast {
210 	ofv_resp_addr_t response;
211 	uint64_t uid;
212 	struct sockaddr_in6 addr;
213 	uint32_t id;
214 	uint32_t reserved;
215 };
216 
217 struct rdma_ucm_get_event {
218 	ofv_resp_addr_t response;
219 };
220 
221 struct rdma_ucm_event_resp {
222 	uint64_t uid;
223 	uint32_t id;
224 	uint32_t event;
225 	uint32_t status;
226 	union {
227 		struct rdma_ucm_conn_param conn;
228 		struct rdma_ucm_ud_param   ud;
229 	} param;
230 };
231 
232 /* Option levels */
233 enum {
234 	RDMA_OPTION_ID		= 0
235 };
236 
237 /* Option details */
238 enum {
239 	RDMA_OPTION_ID_TOS	= 0
240 };
241 
242 struct rdma_ucm_set_option {
243 	uint64_t optval;
244 	uint32_t id;
245 	uint32_t level;
246 	uint32_t optname;
247 	uint32_t optlen;
248 };
249 #pragma	pack()
250 
251 #ifdef __cplusplus
252 }
253 #endif
254 #endif /* _SYS_IB_CLIENTS_OF_RDMA_RDMA_USER_CM_H */
255