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