1219820Sjeff/*
2219820Sjeff * Copyright (c) 2005-2006 Intel Corporation.  All rights reserved.
3219820Sjeff *
4219820Sjeff * This software is available to you under a choice of one of two
5219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
6219820Sjeff * General Public License (GPL) Version 2, available from the file
7219820Sjeff * COPYING in the main directory of this source tree, or the
8219820Sjeff * OpenIB.org BSD license below:
9219820Sjeff *
10219820Sjeff *     Redistribution and use in source and binary forms, with or
11219820Sjeff *     without modification, are permitted provided that the following
12219820Sjeff *     conditions are met:
13219820Sjeff *
14219820Sjeff *      - Redistributions of source code must retain the above
15219820Sjeff *        copyright notice, this list of conditions and the following
16219820Sjeff *        disclaimer.
17219820Sjeff *
18219820Sjeff *      - Redistributions in binary form must reproduce the above
19219820Sjeff *        copyright notice, this list of conditions and the following
20219820Sjeff *        disclaimer in the documentation and/or other materials
21219820Sjeff *        provided with the distribution.
22219820Sjeff *
23219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30219820Sjeff * SOFTWARE.
31219820Sjeff */
32219820Sjeff
33219820Sjeff#ifndef RDMA_CMA_ABI_H
34219820Sjeff#define RDMA_CMA_ABI_H
35219820Sjeff
36219820Sjeff#include <infiniband/kern-abi.h>
37219820Sjeff#include <infiniband/sa-kern-abi.h>
38219820Sjeff
39219820Sjeff/*
40219820Sjeff * This file must be kept in sync with the kernel's version of rdma_user_cm.h
41219820Sjeff */
42219820Sjeff
43219820Sjeff#define RDMA_USER_CM_MIN_ABI_VERSION	3
44219820Sjeff#define RDMA_USER_CM_MAX_ABI_VERSION	4
45219820Sjeff
46219820Sjeff#define RDMA_MAX_PRIVATE_DATA		256
47219820Sjeff
48219820Sjeffenum {
49219820Sjeff	UCMA_CMD_CREATE_ID,
50219820Sjeff	UCMA_CMD_DESTROY_ID,
51219820Sjeff	UCMA_CMD_BIND_ADDR,
52219820Sjeff	UCMA_CMD_RESOLVE_ADDR,
53219820Sjeff	UCMA_CMD_RESOLVE_ROUTE,
54219820Sjeff	UCMA_CMD_QUERY_ROUTE,
55219820Sjeff	UCMA_CMD_CONNECT,
56219820Sjeff	UCMA_CMD_LISTEN,
57219820Sjeff	UCMA_CMD_ACCEPT,
58219820Sjeff	UCMA_CMD_REJECT,
59219820Sjeff	UCMA_CMD_DISCONNECT,
60219820Sjeff	UCMA_CMD_INIT_QP_ATTR,
61219820Sjeff	UCMA_CMD_GET_EVENT,
62219820Sjeff	UCMA_CMD_GET_OPTION,
63219820Sjeff	UCMA_CMD_SET_OPTION,
64219820Sjeff	UCMA_CMD_NOTIFY,
65219820Sjeff 	UCMA_CMD_JOIN_MCAST,
66219820Sjeff 	UCMA_CMD_LEAVE_MCAST,
67219820Sjeff	UCMA_CMD_MIGRATE_ID
68219820Sjeff};
69219820Sjeff
70219820Sjeffstruct ucma_abi_cmd_hdr {
71219820Sjeff	__u32 cmd;
72219820Sjeff	__u16 in;
73219820Sjeff	__u16 out;
74219820Sjeff};
75219820Sjeff
76219820Sjeffstruct ucma_abi_create_id {
77219820Sjeff	__u64 uid;
78219820Sjeff	__u64 response;
79219820Sjeff	__u16 ps;
80219820Sjeff	__u8  reserved[6];
81219820Sjeff};
82219820Sjeff
83219820Sjeffstruct ucma_abi_create_id_resp {
84219820Sjeff	__u32 id;
85219820Sjeff};
86219820Sjeff
87219820Sjeffstruct ucma_abi_destroy_id {
88219820Sjeff	__u64 response;
89219820Sjeff	__u32 id;
90219820Sjeff	__u32 reserved;
91219820Sjeff};
92219820Sjeff
93219820Sjeffstruct ucma_abi_destroy_id_resp {
94219820Sjeff	__u32 events_reported;
95219820Sjeff};
96219820Sjeff
97219820Sjeffstruct ucma_abi_bind_addr {
98219820Sjeff	__u64 response;
99219820Sjeff	struct sockaddr_in6 addr;
100219820Sjeff	__u32 id;
101219820Sjeff};
102219820Sjeff
103219820Sjeffstruct ucma_abi_resolve_addr {
104219820Sjeff	struct sockaddr_in6 src_addr;
105219820Sjeff	struct sockaddr_in6 dst_addr;
106219820Sjeff	__u32 id;
107219820Sjeff	__u32 timeout_ms;
108219820Sjeff};
109219820Sjeff
110219820Sjeffstruct ucma_abi_resolve_route {
111219820Sjeff	__u32 id;
112219820Sjeff	__u32 timeout_ms;
113219820Sjeff};
114219820Sjeff
115219820Sjeffstruct ucma_abi_query_route {
116219820Sjeff	__u64 response;
117219820Sjeff	__u32 id;
118219820Sjeff	__u32 reserved;
119219820Sjeff};
120219820Sjeff
121219820Sjeffstruct ucma_abi_query_route_resp {
122219820Sjeff	__u64 node_guid;
123219820Sjeff	struct ibv_kern_path_rec ib_route[2];
124219820Sjeff	struct sockaddr_in6 src_addr;
125219820Sjeff	struct sockaddr_in6 dst_addr;
126219820Sjeff	__u32 num_paths;
127219820Sjeff	__u8 port_num;
128219820Sjeff	__u8 reserved[3];
129219820Sjeff};
130219820Sjeff
131219820Sjeffstruct ucma_abi_conn_param {
132219820Sjeff	__u32 qp_num;
133219820Sjeff	__u32 reserved;
134219820Sjeff	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
135219820Sjeff	__u8  private_data_len;
136219820Sjeff	__u8  srq;
137219820Sjeff	__u8  responder_resources;
138219820Sjeff	__u8  initiator_depth;
139219820Sjeff	__u8  flow_control;
140219820Sjeff	__u8  retry_count;
141219820Sjeff	__u8  rnr_retry_count;
142219820Sjeff	__u8  valid;
143219820Sjeff};
144219820Sjeff
145219820Sjeffstruct ucma_abi_ud_param {
146219820Sjeff	__u32 qp_num;
147219820Sjeff	__u32 qkey;
148219820Sjeff	struct ibv_kern_ah_attr ah_attr;
149219820Sjeff	__u8 private_data[RDMA_MAX_PRIVATE_DATA];
150219820Sjeff	__u8 private_data_len;
151219820Sjeff	__u8 reserved[7];
152219820Sjeff	__u8 reserved2[4];  /* Round to 8-byte boundary to support 32/64 */
153219820Sjeff};
154219820Sjeff
155219820Sjeffstruct ucma_abi_connect {
156219820Sjeff	struct ucma_abi_conn_param conn_param;
157219820Sjeff	__u32 id;
158219820Sjeff	__u32 reserved;
159219820Sjeff};
160219820Sjeff
161219820Sjeffstruct ucma_abi_listen {
162219820Sjeff	__u32 id;
163219820Sjeff	__u32 backlog;
164219820Sjeff};
165219820Sjeff
166219820Sjeffstruct ucma_abi_accept {
167219820Sjeff	__u64 uid;
168219820Sjeff	struct ucma_abi_conn_param conn_param;
169219820Sjeff	__u32 id;
170219820Sjeff	__u32 reserved;
171219820Sjeff};
172219820Sjeff
173219820Sjeffstruct ucma_abi_reject {
174219820Sjeff	__u32 id;
175219820Sjeff	__u8  private_data_len;
176219820Sjeff	__u8  reserved[3];
177219820Sjeff	__u8  private_data[RDMA_MAX_PRIVATE_DATA];
178219820Sjeff};
179219820Sjeff
180219820Sjeffstruct ucma_abi_disconnect {
181219820Sjeff	__u32 id;
182219820Sjeff};
183219820Sjeff
184219820Sjeffstruct ucma_abi_init_qp_attr {
185219820Sjeff	__u64 response;
186219820Sjeff	__u32 id;
187219820Sjeff	__u32 qp_state;
188219820Sjeff};
189219820Sjeff
190219820Sjeffstruct ucma_abi_notify {
191219820Sjeff	__u32 id;
192219820Sjeff	__u32 event;
193219820Sjeff};
194219820Sjeff
195219820Sjeffstruct ucma_abi_join_mcast {
196219820Sjeff	__u64 response;		/* ucma_abi_create_id_resp */
197219820Sjeff	__u64 uid;
198219820Sjeff	struct sockaddr_in6 addr;
199219820Sjeff	__u32 id;
200219820Sjeff};
201219820Sjeff
202219820Sjeffstruct ucma_abi_get_event {
203219820Sjeff	__u64 response;
204219820Sjeff};
205219820Sjeff
206219820Sjeffstruct ucma_abi_event_resp {
207219820Sjeff	__u64 uid;
208219820Sjeff	__u32 id;
209219820Sjeff	__u32 event;
210219820Sjeff	__u32 status;
211219820Sjeff	union {
212219820Sjeff		struct ucma_abi_conn_param conn;
213219820Sjeff		struct ucma_abi_ud_param   ud;
214219820Sjeff	} param;
215219820Sjeff};
216219820Sjeff
217219820Sjeffstruct ucma_abi_set_option {
218219820Sjeff	__u64 optval;
219219820Sjeff	__u32 id;
220219820Sjeff	__u32 level;
221219820Sjeff	__u32 optname;
222219820Sjeff	__u32 optlen;
223219820Sjeff};
224219820Sjeff
225219820Sjeffstruct ucma_abi_migrate_id {
226219820Sjeff	__u64 response;
227219820Sjeff	__u32 id;
228219820Sjeff	__u32 fd;
229219820Sjeff};
230219820Sjeff
231219820Sjeffstruct ucma_abi_migrate_resp {
232219820Sjeff	__u32 events_reported;
233219820Sjeff};
234219820Sjeff
235219820Sjeff#endif /* RDMA_CMA_ABI_H */
236