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