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 35 #ifndef RDMA_USER_CM_H 36 #define RDMA_USER_CM_H 37 38 #ifdef _KERNEL 39 #include <linux/types.h> 40 #include <linux/socket.h> 41 #include <linux/in6.h> 42 #else 43 #include <infiniband/types.h> 44 #include <netinet/in.h> 45 #endif 46 47 #include <rdma/ib_user_verbs.h> 48 #include <rdma/ib_user_sa.h> 49 50 #define RDMA_USER_CM_ABI_VERSION 4 51 52 #define RDMA_MAX_PRIVATE_DATA 256 53 54 enum { 55 RDMA_USER_CM_CMD_CREATE_ID, 56 RDMA_USER_CM_CMD_DESTROY_ID, 57 RDMA_USER_CM_CMD_BIND_IP, 58 RDMA_USER_CM_CMD_RESOLVE_IP, 59 RDMA_USER_CM_CMD_RESOLVE_ROUTE, 60 RDMA_USER_CM_CMD_QUERY_ROUTE, 61 RDMA_USER_CM_CMD_CONNECT, 62 RDMA_USER_CM_CMD_LISTEN, 63 RDMA_USER_CM_CMD_ACCEPT, 64 RDMA_USER_CM_CMD_REJECT, 65 RDMA_USER_CM_CMD_DISCONNECT, 66 RDMA_USER_CM_CMD_INIT_QP_ATTR, 67 RDMA_USER_CM_CMD_GET_EVENT, 68 RDMA_USER_CM_CMD_GET_OPTION, 69 RDMA_USER_CM_CMD_SET_OPTION, 70 RDMA_USER_CM_CMD_NOTIFY, 71 RDMA_USER_CM_CMD_JOIN_IP_MCAST, 72 RDMA_USER_CM_CMD_LEAVE_MCAST, 73 RDMA_USER_CM_CMD_MIGRATE_ID, 74 RDMA_USER_CM_CMD_QUERY, 75 RDMA_USER_CM_CMD_BIND, 76 RDMA_USER_CM_CMD_RESOLVE_ADDR, 77 RDMA_USER_CM_CMD_JOIN_MCAST 78 }; 79 80 /* 81 * command ABI structures. 82 */ 83 struct rdma_ucm_cmd_hdr { 84 __u32 cmd; 85 __u16 in; 86 __u16 out; 87 }; 88 89 struct rdma_ucm_create_id { 90 __u64 uid; 91 __u64 response; 92 __u16 ps; 93 __u8 qp_type; 94 __u8 reserved[5]; 95 }; 96 97 struct rdma_ucm_create_id_resp { 98 __u32 id; 99 }; 100 101 struct rdma_ucm_destroy_id { 102 __u64 response; 103 __u32 id; 104 __u32 reserved; 105 }; 106 107 struct rdma_ucm_destroy_id_resp { 108 __u32 events_reported; 109 }; 110 111 struct rdma_ucm_bind_ip { 112 __u64 response; 113 struct sockaddr_in6 addr; 114 __u32 id; 115 }; 116 117 struct rdma_ucm_bind { 118 __u32 id; 119 __u16 addr_size; 120 __u16 reserved; 121 struct sockaddr_storage addr; 122 }; 123 124 struct rdma_ucm_resolve_ip { 125 struct sockaddr_in6 src_addr; 126 struct sockaddr_in6 dst_addr; 127 __u32 id; 128 __u32 timeout_ms; 129 }; 130 131 struct rdma_ucm_resolve_addr { 132 __u32 id; 133 __u32 timeout_ms; 134 __u16 src_size; 135 __u16 dst_size; 136 __u32 reserved; 137 struct sockaddr_storage src_addr; 138 struct sockaddr_storage dst_addr; 139 }; 140 141 struct rdma_ucm_resolve_route { 142 __u32 id; 143 __u32 timeout_ms; 144 }; 145 146 enum { 147 RDMA_USER_CM_QUERY_ADDR, 148 RDMA_USER_CM_QUERY_PATH, 149 RDMA_USER_CM_QUERY_GID 150 }; 151 152 struct rdma_ucm_query { 153 __u64 response; 154 __u32 id; 155 __u32 option; 156 }; 157 158 struct rdma_ucm_query_route_resp { 159 __u64 node_guid; 160 struct ib_user_path_rec ib_route[2]; 161 struct sockaddr_in6 src_addr; 162 struct sockaddr_in6 dst_addr; 163 __u32 num_paths; 164 __u8 port_num; 165 __u8 reserved[3]; 166 }; 167 168 struct rdma_ucm_query_addr_resp { 169 __u64 node_guid; 170 __u8 port_num; 171 __u8 reserved; 172 __u16 pkey; 173 __u16 src_size; 174 __u16 dst_size; 175 struct sockaddr_storage src_addr; 176 struct sockaddr_storage dst_addr; 177 }; 178 179 struct rdma_ucm_query_path_resp { 180 __u32 num_paths; 181 __u32 reserved; 182 struct ib_path_rec_data path_data[0]; 183 }; 184 185 struct rdma_ucm_conn_param { 186 __u32 qp_num; 187 __u32 qkey; 188 __u8 private_data[RDMA_MAX_PRIVATE_DATA]; 189 __u8 private_data_len; 190 __u8 srq; 191 __u8 responder_resources; 192 __u8 initiator_depth; 193 __u8 flow_control; 194 __u8 retry_count; 195 __u8 rnr_retry_count; 196 __u8 valid; 197 }; 198 199 struct rdma_ucm_ud_param { 200 __u32 qp_num; 201 __u32 qkey; 202 struct ib_uverbs_ah_attr ah_attr; 203 __u8 private_data[RDMA_MAX_PRIVATE_DATA]; 204 __u8 private_data_len; 205 __u8 reserved[7]; 206 }; 207 208 struct rdma_ucm_connect { 209 struct rdma_ucm_conn_param conn_param; 210 __u32 id; 211 __u32 reserved; 212 }; 213 214 struct rdma_ucm_listen { 215 __u32 id; 216 __u32 backlog; 217 }; 218 219 struct rdma_ucm_accept { 220 __u64 uid; 221 struct rdma_ucm_conn_param conn_param; 222 __u32 id; 223 __u32 reserved; 224 }; 225 226 struct rdma_ucm_reject { 227 __u32 id; 228 __u8 private_data_len; 229 __u8 reserved[3]; 230 __u8 private_data[RDMA_MAX_PRIVATE_DATA]; 231 }; 232 233 struct rdma_ucm_disconnect { 234 __u32 id; 235 }; 236 237 struct rdma_ucm_init_qp_attr { 238 __u64 response; 239 __u32 id; 240 __u32 qp_state; 241 }; 242 243 struct rdma_ucm_notify { 244 __u32 id; 245 __u32 event; 246 }; 247 248 struct rdma_ucm_join_ip_mcast { 249 __u64 response; /* rdma_ucm_create_id_resp */ 250 __u64 uid; 251 struct sockaddr_in6 addr; 252 __u32 id; 253 }; 254 255 /* Multicast join flags */ 256 enum { 257 RDMA_MC_JOIN_FLAG_FULLMEMBER, 258 RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER, 259 RDMA_MC_JOIN_FLAG_RESERVED, 260 }; 261 262 struct rdma_ucm_join_mcast { 263 __u64 response; /* rdma_ucma_create_id_resp */ 264 __u64 uid; 265 __u32 id; 266 __u16 addr_size; 267 __u16 join_flags; 268 struct sockaddr_storage addr; 269 }; 270 271 struct rdma_ucm_get_event { 272 __u64 response; 273 }; 274 275 struct rdma_ucm_event_resp { 276 __u64 uid; 277 __u32 id; 278 __u32 event; 279 __u32 status; 280 union { 281 struct rdma_ucm_conn_param conn; 282 struct rdma_ucm_ud_param ud; 283 } param; 284 }; 285 286 /* Option levels */ 287 enum { 288 RDMA_OPTION_ID = 0, 289 RDMA_OPTION_IB = 1 290 }; 291 292 /* Option details */ 293 enum { 294 RDMA_OPTION_ID_TOS = 0, 295 RDMA_OPTION_ID_REUSEADDR = 1, 296 RDMA_OPTION_ID_AFONLY = 2, 297 RDMA_OPTION_ID_ACK_TIMEOUT = 3 298 }; 299 300 enum { 301 RDMA_OPTION_IB_PATH = 1 302 }; 303 304 struct rdma_ucm_set_option { 305 __u64 optval; 306 __u32 id; 307 __u32 level; 308 __u32 optname; 309 __u32 optlen; 310 }; 311 312 struct rdma_ucm_migrate_id { 313 __u64 response; 314 __u32 id; 315 __u32 fd; 316 }; 317 318 struct rdma_ucm_migrate_resp { 319 __u32 events_reported; 320 }; 321 322 #endif /* RDMA_USER_CM_H */ 323