1/*
2 * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses.  You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 *     Redistribution and use in source and binary forms, with or
11 *     without modification, are permitted provided that the following
12 *     conditions are met:
13 *
14 *      - Redistributions of source code must retain the above
15 *        copyright notice, this list of conditions and the following
16 *        disclaimer.
17 *
18 *      - Redistributions in binary form must reproduce the above
19 *        copyright notice, this list of conditions and the following
20 *        disclaimer in the documentation and/or other materials
21 *        provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33#ifndef RDMA_CMA_ABI_H
34#define RDMA_CMA_ABI_H
35
36#include <infiniband/kern-abi.h>
37#include <infiniband/sa-kern-abi.h>
38
39/*
40 * This file must be kept in sync with the kernel's version of rdma_user_cm.h
41 */
42
43#define RDMA_USER_CM_MIN_ABI_VERSION	3
44#define RDMA_USER_CM_MAX_ABI_VERSION	4
45
46#define RDMA_MAX_PRIVATE_DATA		256
47
48enum {
49	UCMA_CMD_CREATE_ID,
50	UCMA_CMD_DESTROY_ID,
51	UCMA_CMD_BIND_ADDR,
52	UCMA_CMD_RESOLVE_ADDR,
53	UCMA_CMD_RESOLVE_ROUTE,
54	UCMA_CMD_QUERY_ROUTE,
55	UCMA_CMD_CONNECT,
56	UCMA_CMD_LISTEN,
57	UCMA_CMD_ACCEPT,
58	UCMA_CMD_REJECT,
59	UCMA_CMD_DISCONNECT,
60	UCMA_CMD_INIT_QP_ATTR,
61	UCMA_CMD_GET_EVENT,
62	UCMA_CMD_GET_OPTION,
63	UCMA_CMD_SET_OPTION,
64	UCMA_CMD_NOTIFY,
65 	UCMA_CMD_JOIN_MCAST,
66 	UCMA_CMD_LEAVE_MCAST,
67	UCMA_CMD_MIGRATE_ID
68};
69
70struct ucma_abi_cmd_hdr {
71	__u32 cmd;
72	__u16 in;
73	__u16 out;
74};
75
76struct ucma_abi_create_id {
77	__u64 uid;
78	__u64 response;
79	__u16 ps;
80	__u8  reserved[6];
81};
82
83struct ucma_abi_create_id_resp {
84	__u32 id;
85};
86
87struct ucma_abi_destroy_id {
88	__u64 response;
89	__u32 id;
90	__u32 reserved;
91};
92
93struct ucma_abi_destroy_id_resp {
94	__u32 events_reported;
95};
96
97struct ucma_abi_bind_addr {
98	__u64 response;
99	struct sockaddr_in6 addr;
100	__u32 id;
101};
102
103struct ucma_abi_resolve_addr {
104	struct sockaddr_in6 src_addr;
105	struct sockaddr_in6 dst_addr;
106	__u32 id;
107	__u32 timeout_ms;
108};
109
110struct ucma_abi_resolve_route {
111	__u32 id;
112	__u32 timeout_ms;
113};
114
115struct ucma_abi_query_route {
116	__u64 response;
117	__u32 id;
118	__u32 reserved;
119};
120
121struct ucma_abi_query_route_resp {
122	__u64 node_guid;
123	struct ibv_kern_path_rec ib_route[2];
124	struct sockaddr_in6 src_addr;
125	struct sockaddr_in6 dst_addr;
126	__u32 num_paths;
127	__u8 port_num;
128	__u8 reserved[3];
129};
130
131struct ucma_abi_conn_param {
132	__u32 qp_num;
133	__u32 reserved;
134	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
135	__u8  private_data_len;
136	__u8  srq;
137	__u8  responder_resources;
138	__u8  initiator_depth;
139	__u8  flow_control;
140	__u8  retry_count;
141	__u8  rnr_retry_count;
142	__u8  valid;
143};
144
145struct ucma_abi_ud_param {
146	__u32 qp_num;
147	__u32 qkey;
148	struct ibv_kern_ah_attr ah_attr;
149	__u8 private_data[RDMA_MAX_PRIVATE_DATA];
150	__u8 private_data_len;
151	__u8 reserved[7];
152	__u8 reserved2[4];  /* Round to 8-byte boundary to support 32/64 */
153};
154
155struct ucma_abi_connect {
156	struct ucma_abi_conn_param conn_param;
157	__u32 id;
158	__u32 reserved;
159};
160
161struct ucma_abi_listen {
162	__u32 id;
163	__u32 backlog;
164};
165
166struct ucma_abi_accept {
167	__u64 uid;
168	struct ucma_abi_conn_param conn_param;
169	__u32 id;
170	__u32 reserved;
171};
172
173struct ucma_abi_reject {
174	__u32 id;
175	__u8  private_data_len;
176	__u8  reserved[3];
177	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
178};
179
180struct ucma_abi_disconnect {
181	__u32 id;
182};
183
184struct ucma_abi_init_qp_attr {
185	__u64 response;
186	__u32 id;
187	__u32 qp_state;
188};
189
190struct ucma_abi_notify {
191	__u32 id;
192	__u32 event;
193};
194
195struct ucma_abi_join_mcast {
196	__u64 response;		/* ucma_abi_create_id_resp */
197	__u64 uid;
198	struct sockaddr_in6 addr;
199	__u32 id;
200};
201
202struct ucma_abi_get_event {
203	__u64 response;
204};
205
206struct ucma_abi_event_resp {
207	__u64 uid;
208	__u32 id;
209	__u32 event;
210	__u32 status;
211	union {
212		struct ucma_abi_conn_param conn;
213		struct ucma_abi_ud_param   ud;
214	} param;
215};
216
217struct ucma_abi_set_option {
218	__u64 optval;
219	__u32 id;
220	__u32 level;
221	__u32 optname;
222	__u32 optlen;
223};
224
225struct ucma_abi_migrate_id {
226	__u64 response;
227	__u32 id;
228	__u32 fd;
229};
230
231struct ucma_abi_migrate_resp {
232	__u32 events_reported;
233};
234
235#endif /* RDMA_CMA_ABI_H */
236