Christopher Ferris | 2598113 | 2017-11-14 16:53:49 -0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */ |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 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> |
Christopher Ferris | 10bd522 | 2014-09-18 13:16:47 -0700 | [diff] [blame] | 38 | #include <linux/socket.h> |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 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, |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 50 | RDMA_USER_CM_CMD_BIND_IP, |
| 51 | RDMA_USER_CM_CMD_RESOLVE_IP, |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 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, |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 64 | RDMA_USER_CM_CMD_JOIN_IP_MCAST, |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 65 | RDMA_USER_CM_CMD_LEAVE_MCAST, |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 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 |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | /* |
| 74 | * command ABI structures. |
| 75 | */ |
| 76 | struct rdma_ucm_cmd_hdr { |
| 77 | __u32 cmd; |
| 78 | __u16 in; |
| 79 | __u16 out; |
| 80 | }; |
| 81 | |
| 82 | struct rdma_ucm_create_id { |
| 83 | __u64 uid; |
| 84 | __u64 response; |
| 85 | __u16 ps; |
| 86 | __u8 qp_type; |
| 87 | __u8 reserved[5]; |
| 88 | }; |
| 89 | |
| 90 | struct rdma_ucm_create_id_resp { |
| 91 | __u32 id; |
| 92 | }; |
| 93 | |
| 94 | struct rdma_ucm_destroy_id { |
| 95 | __u64 response; |
| 96 | __u32 id; |
| 97 | __u32 reserved; |
| 98 | }; |
| 99 | |
| 100 | struct rdma_ucm_destroy_id_resp { |
| 101 | __u32 events_reported; |
| 102 | }; |
| 103 | |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 104 | struct rdma_ucm_bind_ip { |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 105 | __u64 response; |
| 106 | struct sockaddr_in6 addr; |
| 107 | __u32 id; |
| 108 | }; |
| 109 | |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 110 | struct rdma_ucm_bind { |
| 111 | __u32 id; |
| 112 | __u16 addr_size; |
| 113 | __u16 reserved; |
Christopher Ferris | 2fd4b3c | 2017-02-21 12:32:08 -0800 | [diff] [blame] | 114 | struct __kernel_sockaddr_storage addr; |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | struct rdma_ucm_resolve_ip { |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 118 | struct sockaddr_in6 src_addr; |
| 119 | struct sockaddr_in6 dst_addr; |
| 120 | __u32 id; |
| 121 | __u32 timeout_ms; |
| 122 | }; |
| 123 | |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 124 | struct rdma_ucm_resolve_addr { |
| 125 | __u32 id; |
| 126 | __u32 timeout_ms; |
| 127 | __u16 src_size; |
| 128 | __u16 dst_size; |
| 129 | __u32 reserved; |
Christopher Ferris | 2fd4b3c | 2017-02-21 12:32:08 -0800 | [diff] [blame] | 130 | struct __kernel_sockaddr_storage src_addr; |
| 131 | struct __kernel_sockaddr_storage dst_addr; |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 132 | }; |
| 133 | |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 134 | struct rdma_ucm_resolve_route { |
| 135 | __u32 id; |
| 136 | __u32 timeout_ms; |
| 137 | }; |
| 138 | |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 139 | enum { |
| 140 | RDMA_USER_CM_QUERY_ADDR, |
| 141 | RDMA_USER_CM_QUERY_PATH, |
| 142 | RDMA_USER_CM_QUERY_GID |
| 143 | }; |
| 144 | |
| 145 | struct rdma_ucm_query { |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 146 | __u64 response; |
| 147 | __u32 id; |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 148 | __u32 option; |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 149 | }; |
| 150 | |
| 151 | struct rdma_ucm_query_route_resp { |
| 152 | __u64 node_guid; |
| 153 | struct ib_user_path_rec ib_route[2]; |
| 154 | struct sockaddr_in6 src_addr; |
| 155 | struct sockaddr_in6 dst_addr; |
| 156 | __u32 num_paths; |
| 157 | __u8 port_num; |
| 158 | __u8 reserved[3]; |
| 159 | }; |
| 160 | |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 161 | struct rdma_ucm_query_addr_resp { |
| 162 | __u64 node_guid; |
| 163 | __u8 port_num; |
| 164 | __u8 reserved; |
| 165 | __u16 pkey; |
| 166 | __u16 src_size; |
| 167 | __u16 dst_size; |
Christopher Ferris | 2fd4b3c | 2017-02-21 12:32:08 -0800 | [diff] [blame] | 168 | struct __kernel_sockaddr_storage src_addr; |
| 169 | struct __kernel_sockaddr_storage dst_addr; |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | struct rdma_ucm_query_path_resp { |
| 173 | __u32 num_paths; |
| 174 | __u32 reserved; |
| 175 | struct ib_path_rec_data path_data[0]; |
| 176 | }; |
| 177 | |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 178 | struct rdma_ucm_conn_param { |
| 179 | __u32 qp_num; |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 180 | __u32 qkey; |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 181 | __u8 private_data[RDMA_MAX_PRIVATE_DATA]; |
| 182 | __u8 private_data_len; |
| 183 | __u8 srq; |
| 184 | __u8 responder_resources; |
| 185 | __u8 initiator_depth; |
| 186 | __u8 flow_control; |
| 187 | __u8 retry_count; |
| 188 | __u8 rnr_retry_count; |
| 189 | __u8 valid; |
| 190 | }; |
| 191 | |
| 192 | struct rdma_ucm_ud_param { |
| 193 | __u32 qp_num; |
| 194 | __u32 qkey; |
| 195 | struct ib_uverbs_ah_attr ah_attr; |
| 196 | __u8 private_data[RDMA_MAX_PRIVATE_DATA]; |
| 197 | __u8 private_data_len; |
| 198 | __u8 reserved[7]; |
| 199 | }; |
| 200 | |
| 201 | struct rdma_ucm_connect { |
| 202 | struct rdma_ucm_conn_param conn_param; |
| 203 | __u32 id; |
| 204 | __u32 reserved; |
| 205 | }; |
| 206 | |
| 207 | struct rdma_ucm_listen { |
| 208 | __u32 id; |
| 209 | __u32 backlog; |
| 210 | }; |
| 211 | |
| 212 | struct rdma_ucm_accept { |
| 213 | __u64 uid; |
| 214 | struct rdma_ucm_conn_param conn_param; |
| 215 | __u32 id; |
| 216 | __u32 reserved; |
| 217 | }; |
| 218 | |
| 219 | struct rdma_ucm_reject { |
| 220 | __u32 id; |
| 221 | __u8 private_data_len; |
| 222 | __u8 reserved[3]; |
| 223 | __u8 private_data[RDMA_MAX_PRIVATE_DATA]; |
| 224 | }; |
| 225 | |
| 226 | struct rdma_ucm_disconnect { |
| 227 | __u32 id; |
| 228 | }; |
| 229 | |
| 230 | struct rdma_ucm_init_qp_attr { |
| 231 | __u64 response; |
| 232 | __u32 id; |
| 233 | __u32 qp_state; |
| 234 | }; |
| 235 | |
| 236 | struct rdma_ucm_notify { |
| 237 | __u32 id; |
| 238 | __u32 event; |
| 239 | }; |
| 240 | |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 241 | struct rdma_ucm_join_ip_mcast { |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 242 | __u64 response; /* rdma_ucm_create_id_resp */ |
| 243 | __u64 uid; |
| 244 | struct sockaddr_in6 addr; |
| 245 | __u32 id; |
| 246 | }; |
| 247 | |
Christopher Ferris | 6e3550f | 2016-12-12 14:51:18 -0800 | [diff] [blame] | 248 | /* Multicast join flags */ |
| 249 | enum { |
| 250 | RDMA_MC_JOIN_FLAG_FULLMEMBER, |
| 251 | RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER, |
| 252 | RDMA_MC_JOIN_FLAG_RESERVED, |
| 253 | }; |
| 254 | |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 255 | struct rdma_ucm_join_mcast { |
| 256 | __u64 response; /* rdma_ucma_create_id_resp */ |
| 257 | __u64 uid; |
| 258 | __u32 id; |
| 259 | __u16 addr_size; |
Christopher Ferris | 6e3550f | 2016-12-12 14:51:18 -0800 | [diff] [blame] | 260 | __u16 join_flags; |
Christopher Ferris | 2fd4b3c | 2017-02-21 12:32:08 -0800 | [diff] [blame] | 261 | struct __kernel_sockaddr_storage addr; |
Christopher Ferris | e084501 | 2014-07-09 14:58:51 -0700 | [diff] [blame] | 262 | }; |
| 263 | |
Ben Cheng | 224b54f | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 264 | struct rdma_ucm_get_event { |
| 265 | __u64 response; |
| 266 | }; |
| 267 | |
| 268 | struct rdma_ucm_event_resp { |
| 269 | __u64 uid; |
| 270 | __u32 id; |
| 271 | __u32 event; |
| 272 | __u32 status; |
| 273 | union { |
| 274 | struct rdma_ucm_conn_param conn; |
| 275 | struct rdma_ucm_ud_param ud; |
| 276 | } param; |
| 277 | }; |
| 278 | |
| 279 | /* Option levels */ |
| 280 | enum { |
| 281 | RDMA_OPTION_ID = 0, |
| 282 | RDMA_OPTION_IB = 1 |
| 283 | }; |
| 284 | |
| 285 | /* Option details */ |
| 286 | enum { |
| 287 | RDMA_OPTION_ID_TOS = 0, |
| 288 | RDMA_OPTION_ID_REUSEADDR = 1, |
| 289 | RDMA_OPTION_ID_AFONLY = 2, |
| 290 | RDMA_OPTION_IB_PATH = 1 |
| 291 | }; |
| 292 | |
| 293 | struct rdma_ucm_set_option { |
| 294 | __u64 optval; |
| 295 | __u32 id; |
| 296 | __u32 level; |
| 297 | __u32 optname; |
| 298 | __u32 optlen; |
| 299 | }; |
| 300 | |
| 301 | struct rdma_ucm_migrate_id { |
| 302 | __u64 response; |
| 303 | __u32 id; |
| 304 | __u32 fd; |
| 305 | }; |
| 306 | |
| 307 | struct rdma_ucm_migrate_resp { |
| 308 | __u32 events_reported; |
| 309 | }; |
| 310 | |
| 311 | #endif /* RDMA_USER_CM_H */ |