Jason Gunthorpe | d50e14a | 2018-04-20 09:49:10 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */ |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [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> |
Doug Ledford | db1044d | 2014-08-12 19:20:11 -0400 | [diff] [blame] | 38 | #include <linux/socket.h> |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 39 | #include <linux/in6.h> |
| 40 | #include <rdma/ib_user_verbs.h> |
| 41 | #include <rdma/ib_user_sa.h> |
| 42 | |
Sean Hefty | c8f6a36 | 2007-02-15 17:00:18 -0800 | [diff] [blame] | 43 | #define RDMA_USER_CM_ABI_VERSION 4 |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 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, |
Sean Hefty | 05ad945 | 2013-05-29 10:09:30 -0700 | [diff] [blame] | 50 | RDMA_USER_CM_CMD_BIND_IP, |
| 51 | RDMA_USER_CM_CMD_RESOLVE_IP, |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [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, |
Sean Hefty | c8f6a36 | 2007-02-15 17:00:18 -0800 | [diff] [blame] | 63 | RDMA_USER_CM_CMD_NOTIFY, |
Sean Hefty | 05ad945 | 2013-05-29 10:09:30 -0700 | [diff] [blame] | 64 | RDMA_USER_CM_CMD_JOIN_IP_MCAST, |
Sean Hefty | 88314e4 | 2007-11-14 00:29:50 -0800 | [diff] [blame] | 65 | RDMA_USER_CM_CMD_LEAVE_MCAST, |
Sean Hefty | ee7aed4 | 2013-05-29 10:09:25 -0700 | [diff] [blame] | 66 | RDMA_USER_CM_CMD_MIGRATE_ID, |
Sean Hefty | eebe4c3 | 2013-05-29 10:09:31 -0700 | [diff] [blame] | 67 | RDMA_USER_CM_CMD_QUERY, |
Sean Hefty | 209cf2a | 2013-05-29 10:09:32 -0700 | [diff] [blame] | 68 | RDMA_USER_CM_CMD_BIND, |
Sean Hefty | 5bc2b7b | 2013-05-29 10:09:33 -0700 | [diff] [blame] | 69 | RDMA_USER_CM_CMD_RESOLVE_ADDR, |
| 70 | RDMA_USER_CM_CMD_JOIN_MCAST |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 71 | }; |
| 72 | |
Steve Wise | 2253fc0 | 2018-03-27 08:38:07 -0700 | [diff] [blame] | 73 | /* See IBTA Annex A11, servies ID bytes 4 & 5 */ |
| 74 | enum rdma_ucm_port_space { |
| 75 | RDMA_PS_IPOIB = 0x0002, |
| 76 | RDMA_PS_IB = 0x013F, |
| 77 | RDMA_PS_TCP = 0x0106, |
| 78 | RDMA_PS_UDP = 0x0111, |
| 79 | }; |
| 80 | |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 81 | /* |
| 82 | * command ABI structures. |
| 83 | */ |
| 84 | struct rdma_ucm_cmd_hdr { |
| 85 | __u32 cmd; |
| 86 | __u16 in; |
| 87 | __u16 out; |
| 88 | }; |
| 89 | |
| 90 | struct rdma_ucm_create_id { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 91 | __aligned_u64 uid; |
| 92 | __aligned_u64 response; |
Steve Wise | 2253fc0 | 2018-03-27 08:38:07 -0700 | [diff] [blame] | 93 | __u16 ps; /* use enum rdma_ucm_port_space */ |
Sean Hefty | 638ef7a | 2011-06-14 16:31:53 -0700 | [diff] [blame] | 94 | __u8 qp_type; |
| 95 | __u8 reserved[5]; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | struct rdma_ucm_create_id_resp { |
| 99 | __u32 id; |
| 100 | }; |
| 101 | |
| 102 | struct rdma_ucm_destroy_id { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 103 | __aligned_u64 response; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 104 | __u32 id; |
| 105 | __u32 reserved; |
| 106 | }; |
| 107 | |
| 108 | struct rdma_ucm_destroy_id_resp { |
| 109 | __u32 events_reported; |
| 110 | }; |
| 111 | |
Sean Hefty | 05ad945 | 2013-05-29 10:09:30 -0700 | [diff] [blame] | 112 | struct rdma_ucm_bind_ip { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 113 | __aligned_u64 response; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 114 | struct sockaddr_in6 addr; |
| 115 | __u32 id; |
| 116 | }; |
| 117 | |
Sean Hefty | eebe4c3 | 2013-05-29 10:09:31 -0700 | [diff] [blame] | 118 | struct rdma_ucm_bind { |
| 119 | __u32 id; |
| 120 | __u16 addr_size; |
| 121 | __u16 reserved; |
Jason Gunthorpe | 3549329 | 2016-10-27 10:51:17 -0600 | [diff] [blame] | 122 | struct __kernel_sockaddr_storage addr; |
Sean Hefty | eebe4c3 | 2013-05-29 10:09:31 -0700 | [diff] [blame] | 123 | }; |
| 124 | |
Sean Hefty | 05ad945 | 2013-05-29 10:09:30 -0700 | [diff] [blame] | 125 | struct rdma_ucm_resolve_ip { |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 126 | struct sockaddr_in6 src_addr; |
| 127 | struct sockaddr_in6 dst_addr; |
| 128 | __u32 id; |
| 129 | __u32 timeout_ms; |
| 130 | }; |
| 131 | |
Sean Hefty | 209cf2a | 2013-05-29 10:09:32 -0700 | [diff] [blame] | 132 | struct rdma_ucm_resolve_addr { |
| 133 | __u32 id; |
| 134 | __u32 timeout_ms; |
| 135 | __u16 src_size; |
| 136 | __u16 dst_size; |
| 137 | __u32 reserved; |
Jason Gunthorpe | 3549329 | 2016-10-27 10:51:17 -0600 | [diff] [blame] | 138 | struct __kernel_sockaddr_storage src_addr; |
| 139 | struct __kernel_sockaddr_storage dst_addr; |
Sean Hefty | 209cf2a | 2013-05-29 10:09:32 -0700 | [diff] [blame] | 140 | }; |
| 141 | |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 142 | struct rdma_ucm_resolve_route { |
| 143 | __u32 id; |
| 144 | __u32 timeout_ms; |
| 145 | }; |
| 146 | |
Sean Hefty | ee7aed4 | 2013-05-29 10:09:25 -0700 | [diff] [blame] | 147 | enum { |
Sean Hefty | ac53b26 | 2013-05-29 10:09:27 -0700 | [diff] [blame] | 148 | RDMA_USER_CM_QUERY_ADDR, |
Sean Hefty | edaa7a5 | 2013-05-29 10:09:29 -0700 | [diff] [blame] | 149 | RDMA_USER_CM_QUERY_PATH, |
| 150 | RDMA_USER_CM_QUERY_GID |
Sean Hefty | ee7aed4 | 2013-05-29 10:09:25 -0700 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | struct rdma_ucm_query { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 154 | __aligned_u64 response; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 155 | __u32 id; |
Sean Hefty | ee7aed4 | 2013-05-29 10:09:25 -0700 | [diff] [blame] | 156 | __u32 option; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 157 | }; |
| 158 | |
| 159 | struct rdma_ucm_query_route_resp { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 160 | __aligned_u64 node_guid; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 161 | struct ib_user_path_rec ib_route[2]; |
| 162 | struct sockaddr_in6 src_addr; |
| 163 | struct sockaddr_in6 dst_addr; |
| 164 | __u32 num_paths; |
| 165 | __u8 port_num; |
| 166 | __u8 reserved[3]; |
| 167 | }; |
| 168 | |
Sean Hefty | ee7aed4 | 2013-05-29 10:09:25 -0700 | [diff] [blame] | 169 | struct rdma_ucm_query_addr_resp { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 170 | __aligned_u64 node_guid; |
Sean Hefty | ee7aed4 | 2013-05-29 10:09:25 -0700 | [diff] [blame] | 171 | __u8 port_num; |
| 172 | __u8 reserved; |
| 173 | __u16 pkey; |
| 174 | __u16 src_size; |
| 175 | __u16 dst_size; |
Jason Gunthorpe | 3549329 | 2016-10-27 10:51:17 -0600 | [diff] [blame] | 176 | struct __kernel_sockaddr_storage src_addr; |
| 177 | struct __kernel_sockaddr_storage dst_addr; |
Sean Hefty | ee7aed4 | 2013-05-29 10:09:25 -0700 | [diff] [blame] | 178 | }; |
| 179 | |
Sean Hefty | ac53b26 | 2013-05-29 10:09:27 -0700 | [diff] [blame] | 180 | struct rdma_ucm_query_path_resp { |
| 181 | __u32 num_paths; |
| 182 | __u32 reserved; |
| 183 | struct ib_path_rec_data path_data[0]; |
| 184 | }; |
| 185 | |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 186 | struct rdma_ucm_conn_param { |
| 187 | __u32 qp_num; |
Sean Hefty | 5c43813 | 2013-05-29 10:09:23 -0700 | [diff] [blame] | 188 | __u32 qkey; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 189 | __u8 private_data[RDMA_MAX_PRIVATE_DATA]; |
| 190 | __u8 private_data_len; |
| 191 | __u8 srq; |
| 192 | __u8 responder_resources; |
| 193 | __u8 initiator_depth; |
| 194 | __u8 flow_control; |
| 195 | __u8 retry_count; |
| 196 | __u8 rnr_retry_count; |
| 197 | __u8 valid; |
| 198 | }; |
| 199 | |
| 200 | struct rdma_ucm_ud_param { |
| 201 | __u32 qp_num; |
| 202 | __u32 qkey; |
| 203 | struct ib_uverbs_ah_attr ah_attr; |
| 204 | __u8 private_data[RDMA_MAX_PRIVATE_DATA]; |
| 205 | __u8 private_data_len; |
| 206 | __u8 reserved[7]; |
| 207 | }; |
| 208 | |
| 209 | struct rdma_ucm_connect { |
| 210 | struct rdma_ucm_conn_param conn_param; |
| 211 | __u32 id; |
| 212 | __u32 reserved; |
| 213 | }; |
| 214 | |
| 215 | struct rdma_ucm_listen { |
| 216 | __u32 id; |
| 217 | __u32 backlog; |
| 218 | }; |
| 219 | |
| 220 | struct rdma_ucm_accept { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 221 | __aligned_u64 uid; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 222 | struct rdma_ucm_conn_param conn_param; |
| 223 | __u32 id; |
| 224 | __u32 reserved; |
| 225 | }; |
| 226 | |
| 227 | struct rdma_ucm_reject { |
| 228 | __u32 id; |
| 229 | __u8 private_data_len; |
| 230 | __u8 reserved[3]; |
| 231 | __u8 private_data[RDMA_MAX_PRIVATE_DATA]; |
| 232 | }; |
| 233 | |
| 234 | struct rdma_ucm_disconnect { |
| 235 | __u32 id; |
| 236 | }; |
| 237 | |
| 238 | struct rdma_ucm_init_qp_attr { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 239 | __aligned_u64 response; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 240 | __u32 id; |
| 241 | __u32 qp_state; |
| 242 | }; |
| 243 | |
| 244 | struct rdma_ucm_notify { |
| 245 | __u32 id; |
| 246 | __u32 event; |
| 247 | }; |
| 248 | |
Sean Hefty | 05ad945 | 2013-05-29 10:09:30 -0700 | [diff] [blame] | 249 | struct rdma_ucm_join_ip_mcast { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 250 | __aligned_u64 response; /* rdma_ucm_create_id_resp */ |
| 251 | __aligned_u64 uid; |
Sean Hefty | c8f6a36 | 2007-02-15 17:00:18 -0800 | [diff] [blame] | 252 | struct sockaddr_in6 addr; |
| 253 | __u32 id; |
| 254 | }; |
| 255 | |
Alex Vesker | ab15c95 | 2016-07-06 16:36:35 +0300 | [diff] [blame] | 256 | /* Multicast join flags */ |
| 257 | enum { |
| 258 | RDMA_MC_JOIN_FLAG_FULLMEMBER, |
| 259 | RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER, |
| 260 | RDMA_MC_JOIN_FLAG_RESERVED, |
| 261 | }; |
| 262 | |
Sean Hefty | 5bc2b7b | 2013-05-29 10:09:33 -0700 | [diff] [blame] | 263 | struct rdma_ucm_join_mcast { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 264 | __aligned_u64 response; /* rdma_ucma_create_id_resp */ |
| 265 | __aligned_u64 uid; |
Sean Hefty | 5bc2b7b | 2013-05-29 10:09:33 -0700 | [diff] [blame] | 266 | __u32 id; |
| 267 | __u16 addr_size; |
Alex Vesker | ab15c95 | 2016-07-06 16:36:35 +0300 | [diff] [blame] | 268 | __u16 join_flags; |
Jason Gunthorpe | 3549329 | 2016-10-27 10:51:17 -0600 | [diff] [blame] | 269 | struct __kernel_sockaddr_storage addr; |
Sean Hefty | 5bc2b7b | 2013-05-29 10:09:33 -0700 | [diff] [blame] | 270 | }; |
| 271 | |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 272 | struct rdma_ucm_get_event { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 273 | __aligned_u64 response; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 274 | }; |
| 275 | |
| 276 | struct rdma_ucm_event_resp { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 277 | __aligned_u64 uid; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 278 | __u32 id; |
| 279 | __u32 event; |
| 280 | __u32 status; |
Jason Gunthorpe | 611cb92 | 2018-03-20 14:19:47 -0600 | [diff] [blame] | 281 | /* |
| 282 | * NOTE: This union is not aligned to 8 bytes so none of the union |
| 283 | * members may contain a u64 or anything with higher alignment than 4. |
| 284 | */ |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 285 | union { |
| 286 | struct rdma_ucm_conn_param conn; |
| 287 | struct rdma_ucm_ud_param ud; |
| 288 | } param; |
Jason Gunthorpe | 611cb92 | 2018-03-20 14:19:47 -0600 | [diff] [blame] | 289 | __u32 reserved; |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 290 | }; |
| 291 | |
Sean Hefty | 7ce8640 | 2007-08-08 15:51:13 -0700 | [diff] [blame] | 292 | /* Option levels */ |
| 293 | enum { |
Sean Hefty | a7ca1f0 | 2009-11-16 09:30:33 -0800 | [diff] [blame] | 294 | RDMA_OPTION_ID = 0, |
| 295 | RDMA_OPTION_IB = 1 |
Sean Hefty | 7ce8640 | 2007-08-08 15:51:13 -0700 | [diff] [blame] | 296 | }; |
| 297 | |
| 298 | /* Option details */ |
| 299 | enum { |
Hefty, Sean | a9bb791 | 2011-05-09 22:06:10 -0700 | [diff] [blame] | 300 | RDMA_OPTION_ID_TOS = 0, |
| 301 | RDMA_OPTION_ID_REUSEADDR = 1, |
Sean Hefty | 6860212 | 2012-06-14 20:31:39 +0000 | [diff] [blame] | 302 | RDMA_OPTION_ID_AFONLY = 2, |
Hefty, Sean | a9bb791 | 2011-05-09 22:06:10 -0700 | [diff] [blame] | 303 | RDMA_OPTION_IB_PATH = 1 |
Sean Hefty | 7ce8640 | 2007-08-08 15:51:13 -0700 | [diff] [blame] | 304 | }; |
| 305 | |
| 306 | struct rdma_ucm_set_option { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 307 | __aligned_u64 optval; |
Sean Hefty | 7ce8640 | 2007-08-08 15:51:13 -0700 | [diff] [blame] | 308 | __u32 id; |
| 309 | __u32 level; |
| 310 | __u32 optname; |
| 311 | __u32 optlen; |
| 312 | }; |
| 313 | |
Sean Hefty | 88314e4 | 2007-11-14 00:29:50 -0800 | [diff] [blame] | 314 | struct rdma_ucm_migrate_id { |
Jason Gunthorpe | 26b9906 | 2018-03-20 14:19:51 -0600 | [diff] [blame] | 315 | __aligned_u64 response; |
Sean Hefty | 88314e4 | 2007-11-14 00:29:50 -0800 | [diff] [blame] | 316 | __u32 id; |
| 317 | __u32 fd; |
| 318 | }; |
| 319 | |
| 320 | struct rdma_ucm_migrate_resp { |
| 321 | __u32 events_reported; |
| 322 | }; |
| 323 | |
Sean Hefty | 7521663 | 2006-11-30 16:53:41 -0800 | [diff] [blame] | 324 | #endif /* RDMA_USER_CM_H */ |