xref: /openbmc/linux/include/uapi/rdma/rdma_user_cm.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1d50e14abSJason Gunthorpe /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
27235aa79SDavid Howells /*
37235aa79SDavid Howells  * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
47235aa79SDavid Howells  *
57235aa79SDavid Howells  * This software is available to you under a choice of one of two
67235aa79SDavid Howells  * licenses.  You may choose to be licensed under the terms of the GNU
77235aa79SDavid Howells  * General Public License (GPL) Version 2, available from the file
87235aa79SDavid Howells  * COPYING in the main directory of this source tree, or the
97235aa79SDavid Howells  * OpenIB.org BSD license below:
107235aa79SDavid Howells  *
117235aa79SDavid Howells  *     Redistribution and use in source and binary forms, with or
127235aa79SDavid Howells  *     without modification, are permitted provided that the following
137235aa79SDavid Howells  *     conditions are met:
147235aa79SDavid Howells  *
157235aa79SDavid Howells  *      - Redistributions of source code must retain the above
167235aa79SDavid Howells  *        copyright notice, this list of conditions and the following
177235aa79SDavid Howells  *        disclaimer.
187235aa79SDavid Howells  *
197235aa79SDavid Howells  *      - Redistributions in binary form must reproduce the above
207235aa79SDavid Howells  *        copyright notice, this list of conditions and the following
217235aa79SDavid Howells  *        disclaimer in the documentation and/or other materials
227235aa79SDavid Howells  *        provided with the distribution.
237235aa79SDavid Howells  *
247235aa79SDavid Howells  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
257235aa79SDavid Howells  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
267235aa79SDavid Howells  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
277235aa79SDavid Howells  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
287235aa79SDavid Howells  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
297235aa79SDavid Howells  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
307235aa79SDavid Howells  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
317235aa79SDavid Howells  * SOFTWARE.
327235aa79SDavid Howells  */
337235aa79SDavid Howells 
347235aa79SDavid Howells #ifndef RDMA_USER_CM_H
357235aa79SDavid Howells #define RDMA_USER_CM_H
367235aa79SDavid Howells 
377235aa79SDavid Howells #include <linux/types.h>
38db1044d4SDoug Ledford #include <linux/socket.h>
397235aa79SDavid Howells #include <linux/in6.h>
407235aa79SDavid Howells #include <rdma/ib_user_verbs.h>
417235aa79SDavid Howells #include <rdma/ib_user_sa.h>
427235aa79SDavid Howells 
437235aa79SDavid Howells #define RDMA_USER_CM_ABI_VERSION	4
447235aa79SDavid Howells 
457235aa79SDavid Howells #define RDMA_MAX_PRIVATE_DATA		256
467235aa79SDavid Howells 
477235aa79SDavid Howells enum {
487235aa79SDavid Howells 	RDMA_USER_CM_CMD_CREATE_ID,
497235aa79SDavid Howells 	RDMA_USER_CM_CMD_DESTROY_ID,
5005ad9457SSean Hefty 	RDMA_USER_CM_CMD_BIND_IP,
5105ad9457SSean Hefty 	RDMA_USER_CM_CMD_RESOLVE_IP,
527235aa79SDavid Howells 	RDMA_USER_CM_CMD_RESOLVE_ROUTE,
537235aa79SDavid Howells 	RDMA_USER_CM_CMD_QUERY_ROUTE,
547235aa79SDavid Howells 	RDMA_USER_CM_CMD_CONNECT,
557235aa79SDavid Howells 	RDMA_USER_CM_CMD_LISTEN,
567235aa79SDavid Howells 	RDMA_USER_CM_CMD_ACCEPT,
577235aa79SDavid Howells 	RDMA_USER_CM_CMD_REJECT,
587235aa79SDavid Howells 	RDMA_USER_CM_CMD_DISCONNECT,
597235aa79SDavid Howells 	RDMA_USER_CM_CMD_INIT_QP_ATTR,
607235aa79SDavid Howells 	RDMA_USER_CM_CMD_GET_EVENT,
617235aa79SDavid Howells 	RDMA_USER_CM_CMD_GET_OPTION,
627235aa79SDavid Howells 	RDMA_USER_CM_CMD_SET_OPTION,
637235aa79SDavid Howells 	RDMA_USER_CM_CMD_NOTIFY,
6405ad9457SSean Hefty 	RDMA_USER_CM_CMD_JOIN_IP_MCAST,
657235aa79SDavid Howells 	RDMA_USER_CM_CMD_LEAVE_MCAST,
66ee7aed45SSean Hefty 	RDMA_USER_CM_CMD_MIGRATE_ID,
67eebe4c3aSSean Hefty 	RDMA_USER_CM_CMD_QUERY,
68209cf2a7SSean Hefty 	RDMA_USER_CM_CMD_BIND,
695bc2b7b3SSean Hefty 	RDMA_USER_CM_CMD_RESOLVE_ADDR,
705bc2b7b3SSean Hefty 	RDMA_USER_CM_CMD_JOIN_MCAST
717235aa79SDavid Howells };
727235aa79SDavid Howells 
732253fc0cSSteve Wise /* See IBTA Annex A11, servies ID bytes 4 & 5 */
742253fc0cSSteve Wise enum rdma_ucm_port_space {
752253fc0cSSteve Wise 	RDMA_PS_IPOIB = 0x0002,
762253fc0cSSteve Wise 	RDMA_PS_IB    = 0x013F,
772253fc0cSSteve Wise 	RDMA_PS_TCP   = 0x0106,
782253fc0cSSteve Wise 	RDMA_PS_UDP   = 0x0111,
792253fc0cSSteve Wise };
802253fc0cSSteve Wise 
817235aa79SDavid Howells /*
827235aa79SDavid Howells  * command ABI structures.
837235aa79SDavid Howells  */
847235aa79SDavid Howells struct rdma_ucm_cmd_hdr {
857235aa79SDavid Howells 	__u32 cmd;
867235aa79SDavid Howells 	__u16 in;
877235aa79SDavid Howells 	__u16 out;
887235aa79SDavid Howells };
897235aa79SDavid Howells 
907235aa79SDavid Howells struct rdma_ucm_create_id {
9126b99066SJason Gunthorpe 	__aligned_u64 uid;
9226b99066SJason Gunthorpe 	__aligned_u64 response;
932253fc0cSSteve Wise 	__u16 ps;                  /* use enum rdma_ucm_port_space */
947235aa79SDavid Howells 	__u8  qp_type;
957235aa79SDavid Howells 	__u8  reserved[5];
967235aa79SDavid Howells };
977235aa79SDavid Howells 
987235aa79SDavid Howells struct rdma_ucm_create_id_resp {
997235aa79SDavid Howells 	__u32 id;
1007235aa79SDavid Howells };
1017235aa79SDavid Howells 
1027235aa79SDavid Howells struct rdma_ucm_destroy_id {
10326b99066SJason Gunthorpe 	__aligned_u64 response;
1047235aa79SDavid Howells 	__u32 id;
1057235aa79SDavid Howells 	__u32 reserved;
1067235aa79SDavid Howells };
1077235aa79SDavid Howells 
1087235aa79SDavid Howells struct rdma_ucm_destroy_id_resp {
1097235aa79SDavid Howells 	__u32 events_reported;
1107235aa79SDavid Howells };
1117235aa79SDavid Howells 
11205ad9457SSean Hefty struct rdma_ucm_bind_ip {
11326b99066SJason Gunthorpe 	__aligned_u64 response;
1147235aa79SDavid Howells 	struct sockaddr_in6 addr;
1157235aa79SDavid Howells 	__u32 id;
1167235aa79SDavid Howells };
1177235aa79SDavid Howells 
118eebe4c3aSSean Hefty struct rdma_ucm_bind {
119eebe4c3aSSean Hefty 	__u32 id;
120eebe4c3aSSean Hefty 	__u16 addr_size;
121eebe4c3aSSean Hefty 	__u16 reserved;
12235493294SJason Gunthorpe 	struct __kernel_sockaddr_storage addr;
123eebe4c3aSSean Hefty };
124eebe4c3aSSean Hefty 
12505ad9457SSean Hefty struct rdma_ucm_resolve_ip {
1267235aa79SDavid Howells 	struct sockaddr_in6 src_addr;
1277235aa79SDavid Howells 	struct sockaddr_in6 dst_addr;
1287235aa79SDavid Howells 	__u32 id;
1297235aa79SDavid Howells 	__u32 timeout_ms;
1307235aa79SDavid Howells };
1317235aa79SDavid Howells 
132209cf2a7SSean Hefty struct rdma_ucm_resolve_addr {
133209cf2a7SSean Hefty 	__u32 id;
134209cf2a7SSean Hefty 	__u32 timeout_ms;
135209cf2a7SSean Hefty 	__u16 src_size;
136209cf2a7SSean Hefty 	__u16 dst_size;
137209cf2a7SSean Hefty 	__u32 reserved;
13835493294SJason Gunthorpe 	struct __kernel_sockaddr_storage src_addr;
13935493294SJason Gunthorpe 	struct __kernel_sockaddr_storage dst_addr;
140209cf2a7SSean Hefty };
141209cf2a7SSean Hefty 
1427235aa79SDavid Howells struct rdma_ucm_resolve_route {
1437235aa79SDavid Howells 	__u32 id;
1447235aa79SDavid Howells 	__u32 timeout_ms;
1457235aa79SDavid Howells };
1467235aa79SDavid Howells 
147ee7aed45SSean Hefty enum {
148ac53b264SSean Hefty 	RDMA_USER_CM_QUERY_ADDR,
149edaa7a55SSean Hefty 	RDMA_USER_CM_QUERY_PATH,
150edaa7a55SSean Hefty 	RDMA_USER_CM_QUERY_GID
151ee7aed45SSean Hefty };
152ee7aed45SSean Hefty 
153ee7aed45SSean Hefty struct rdma_ucm_query {
15426b99066SJason Gunthorpe 	__aligned_u64 response;
1557235aa79SDavid Howells 	__u32 id;
156ee7aed45SSean Hefty 	__u32 option;
1577235aa79SDavid Howells };
1587235aa79SDavid Howells 
1597235aa79SDavid Howells struct rdma_ucm_query_route_resp {
16026b99066SJason Gunthorpe 	__aligned_u64 node_guid;
1617235aa79SDavid Howells 	struct ib_user_path_rec ib_route[2];
1627235aa79SDavid Howells 	struct sockaddr_in6 src_addr;
1637235aa79SDavid Howells 	struct sockaddr_in6 dst_addr;
1647235aa79SDavid Howells 	__u32 num_paths;
1657235aa79SDavid Howells 	__u8 port_num;
1667235aa79SDavid Howells 	__u8 reserved[3];
16717793833SLeon Romanovsky 	__u32 ibdev_index;
16817793833SLeon Romanovsky 	__u32 reserved1;
1697235aa79SDavid Howells };
1707235aa79SDavid Howells 
171ee7aed45SSean Hefty struct rdma_ucm_query_addr_resp {
17226b99066SJason Gunthorpe 	__aligned_u64 node_guid;
173ee7aed45SSean Hefty 	__u8  port_num;
174ee7aed45SSean Hefty 	__u8  reserved;
175ee7aed45SSean Hefty 	__u16 pkey;
176ee7aed45SSean Hefty 	__u16 src_size;
177ee7aed45SSean Hefty 	__u16 dst_size;
17835493294SJason Gunthorpe 	struct __kernel_sockaddr_storage src_addr;
17935493294SJason Gunthorpe 	struct __kernel_sockaddr_storage dst_addr;
18017793833SLeon Romanovsky 	__u32 ibdev_index;
18117793833SLeon Romanovsky 	__u32 reserved1;
182ee7aed45SSean Hefty };
183ee7aed45SSean Hefty 
184ac53b264SSean Hefty struct rdma_ucm_query_path_resp {
185ac53b264SSean Hefty 	__u32 num_paths;
186ac53b264SSean Hefty 	__u32 reserved;
187*94dfc73eSGustavo A. R. Silva 	struct ib_path_rec_data path_data[];
188ac53b264SSean Hefty };
189ac53b264SSean Hefty 
1907235aa79SDavid Howells struct rdma_ucm_conn_param {
1917235aa79SDavid Howells 	__u32 qp_num;
1925c438135SSean Hefty 	__u32 qkey;
1937235aa79SDavid Howells 	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
1947235aa79SDavid Howells 	__u8  private_data_len;
1957235aa79SDavid Howells 	__u8  srq;
1967235aa79SDavid Howells 	__u8  responder_resources;
1977235aa79SDavid Howells 	__u8  initiator_depth;
1987235aa79SDavid Howells 	__u8  flow_control;
1997235aa79SDavid Howells 	__u8  retry_count;
2007235aa79SDavid Howells 	__u8  rnr_retry_count;
2017235aa79SDavid Howells 	__u8  valid;
2027235aa79SDavid Howells };
2037235aa79SDavid Howells 
2047235aa79SDavid Howells struct rdma_ucm_ud_param {
2057235aa79SDavid Howells 	__u32 qp_num;
2067235aa79SDavid Howells 	__u32 qkey;
2077235aa79SDavid Howells 	struct ib_uverbs_ah_attr ah_attr;
2087235aa79SDavid Howells 	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
2097235aa79SDavid Howells 	__u8  private_data_len;
2107235aa79SDavid Howells 	__u8  reserved[7];
2117235aa79SDavid Howells };
2127235aa79SDavid Howells 
21334e2ab57SLeon Romanovsky struct rdma_ucm_ece {
21434e2ab57SLeon Romanovsky 	__u32 vendor_id;
21534e2ab57SLeon Romanovsky 	__u32 attr_mod;
21634e2ab57SLeon Romanovsky };
21734e2ab57SLeon Romanovsky 
2187235aa79SDavid Howells struct rdma_ucm_connect {
2197235aa79SDavid Howells 	struct rdma_ucm_conn_param conn_param;
2207235aa79SDavid Howells 	__u32 id;
2217235aa79SDavid Howells 	__u32 reserved;
22234e2ab57SLeon Romanovsky 	struct rdma_ucm_ece ece;
2237235aa79SDavid Howells };
2247235aa79SDavid Howells 
2257235aa79SDavid Howells struct rdma_ucm_listen {
2267235aa79SDavid Howells 	__u32 id;
2277235aa79SDavid Howells 	__u32 backlog;
2287235aa79SDavid Howells };
2297235aa79SDavid Howells 
2307235aa79SDavid Howells struct rdma_ucm_accept {
23126b99066SJason Gunthorpe 	__aligned_u64 uid;
2327235aa79SDavid Howells 	struct rdma_ucm_conn_param conn_param;
2337235aa79SDavid Howells 	__u32 id;
2347235aa79SDavid Howells 	__u32 reserved;
2350cb15372SLeon Romanovsky 	struct rdma_ucm_ece ece;
2367235aa79SDavid Howells };
2377235aa79SDavid Howells 
2387235aa79SDavid Howells struct rdma_ucm_reject {
2397235aa79SDavid Howells 	__u32 id;
2407235aa79SDavid Howells 	__u8  private_data_len;
2418094ba0aSLeon Romanovsky 	__u8  reason;
2428094ba0aSLeon Romanovsky 	__u8  reserved[2];
2437235aa79SDavid Howells 	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
2447235aa79SDavid Howells };
2457235aa79SDavid Howells 
2467235aa79SDavid Howells struct rdma_ucm_disconnect {
2477235aa79SDavid Howells 	__u32 id;
2487235aa79SDavid Howells };
2497235aa79SDavid Howells 
2507235aa79SDavid Howells struct rdma_ucm_init_qp_attr {
25126b99066SJason Gunthorpe 	__aligned_u64 response;
2527235aa79SDavid Howells 	__u32 id;
2537235aa79SDavid Howells 	__u32 qp_state;
2547235aa79SDavid Howells };
2557235aa79SDavid Howells 
2567235aa79SDavid Howells struct rdma_ucm_notify {
2577235aa79SDavid Howells 	__u32 id;
2587235aa79SDavid Howells 	__u32 event;
2597235aa79SDavid Howells };
2607235aa79SDavid Howells 
26105ad9457SSean Hefty struct rdma_ucm_join_ip_mcast {
26226b99066SJason Gunthorpe 	__aligned_u64 response;		/* rdma_ucm_create_id_resp */
26326b99066SJason Gunthorpe 	__aligned_u64 uid;
2647235aa79SDavid Howells 	struct sockaddr_in6 addr;
2657235aa79SDavid Howells 	__u32 id;
2667235aa79SDavid Howells };
2677235aa79SDavid Howells 
268ab15c95aSAlex Vesker /* Multicast join flags */
269ab15c95aSAlex Vesker enum {
270ab15c95aSAlex Vesker 	RDMA_MC_JOIN_FLAG_FULLMEMBER,
271ab15c95aSAlex Vesker 	RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER,
272ab15c95aSAlex Vesker 	RDMA_MC_JOIN_FLAG_RESERVED,
273ab15c95aSAlex Vesker };
274ab15c95aSAlex Vesker 
2755bc2b7b3SSean Hefty struct rdma_ucm_join_mcast {
27626b99066SJason Gunthorpe 	__aligned_u64 response;		/* rdma_ucma_create_id_resp */
27726b99066SJason Gunthorpe 	__aligned_u64 uid;
2785bc2b7b3SSean Hefty 	__u32 id;
2795bc2b7b3SSean Hefty 	__u16 addr_size;
280ab15c95aSAlex Vesker 	__u16 join_flags;
28135493294SJason Gunthorpe 	struct __kernel_sockaddr_storage addr;
2825bc2b7b3SSean Hefty };
2835bc2b7b3SSean Hefty 
2847235aa79SDavid Howells struct rdma_ucm_get_event {
28526b99066SJason Gunthorpe 	__aligned_u64 response;
2867235aa79SDavid Howells };
2877235aa79SDavid Howells 
2887235aa79SDavid Howells struct rdma_ucm_event_resp {
28926b99066SJason Gunthorpe 	__aligned_u64 uid;
2907235aa79SDavid Howells 	__u32 id;
2917235aa79SDavid Howells 	__u32 event;
2927235aa79SDavid Howells 	__u32 status;
293611cb92bSJason Gunthorpe 	/*
294611cb92bSJason Gunthorpe 	 * NOTE: This union is not aligned to 8 bytes so none of the union
295611cb92bSJason Gunthorpe 	 * members may contain a u64 or anything with higher alignment than 4.
296611cb92bSJason Gunthorpe 	 */
2977235aa79SDavid Howells 	union {
2987235aa79SDavid Howells 		struct rdma_ucm_conn_param conn;
2997235aa79SDavid Howells 		struct rdma_ucm_ud_param   ud;
3007235aa79SDavid Howells 	} param;
301611cb92bSJason Gunthorpe 	__u32 reserved;
30293531ee7SLeon Romanovsky 	struct rdma_ucm_ece ece;
3037235aa79SDavid Howells };
3047235aa79SDavid Howells 
3057235aa79SDavid Howells /* Option levels */
3067235aa79SDavid Howells enum {
3077235aa79SDavid Howells 	RDMA_OPTION_ID		= 0,
3087235aa79SDavid Howells 	RDMA_OPTION_IB		= 1
3097235aa79SDavid Howells };
3107235aa79SDavid Howells 
3117235aa79SDavid Howells /* Option details */
3127235aa79SDavid Howells enum {
3137235aa79SDavid Howells 	RDMA_OPTION_ID_TOS	 = 0,
3147235aa79SDavid Howells 	RDMA_OPTION_ID_REUSEADDR = 1,
3157235aa79SDavid Howells 	RDMA_OPTION_ID_AFONLY	 = 2,
3162c1619edSDanit Goldberg 	RDMA_OPTION_ID_ACK_TIMEOUT = 3
3172c1619edSDanit Goldberg };
3182c1619edSDanit Goldberg 
3192c1619edSDanit Goldberg enum {
3207235aa79SDavid Howells 	RDMA_OPTION_IB_PATH	 = 1
3217235aa79SDavid Howells };
3227235aa79SDavid Howells 
3237235aa79SDavid Howells struct rdma_ucm_set_option {
32426b99066SJason Gunthorpe 	__aligned_u64 optval;
3257235aa79SDavid Howells 	__u32 id;
3267235aa79SDavid Howells 	__u32 level;
3277235aa79SDavid Howells 	__u32 optname;
3287235aa79SDavid Howells 	__u32 optlen;
3297235aa79SDavid Howells };
3307235aa79SDavid Howells 
3317235aa79SDavid Howells struct rdma_ucm_migrate_id {
33226b99066SJason Gunthorpe 	__aligned_u64 response;
3337235aa79SDavid Howells 	__u32 id;
3347235aa79SDavid Howells 	__u32 fd;
3357235aa79SDavid Howells };
3367235aa79SDavid Howells 
3377235aa79SDavid Howells struct rdma_ucm_migrate_resp {
3387235aa79SDavid Howells 	__u32 events_reported;
3397235aa79SDavid Howells };
3407235aa79SDavid Howells 
3417235aa79SDavid Howells #endif /* RDMA_USER_CM_H */
342