1219820Sjeff/*
2219820Sjeff * Copyright (c) 2005 Topspin Communications.  All rights reserved.
3219820Sjeff * Copyright (c) 2005 Intel Corporation.  All rights reserved.
4219820Sjeff *
5219820Sjeff * This software is available to you under a choice of one of two
6219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
7219820Sjeff * General Public License (GPL) Version 2, available from the file
8219820Sjeff * COPYING in the main directory of this source tree, or the
9219820Sjeff * OpenIB.org BSD license below:
10219820Sjeff *
11219820Sjeff *     Redistribution and use in source and binary forms, with or
12219820Sjeff *     without modification, are permitted provided that the following
13219820Sjeff *     conditions are met:
14219820Sjeff *
15219820Sjeff *      - Redistributions of source code must retain the above
16219820Sjeff *        copyright notice, this list of conditions and the following
17219820Sjeff *        disclaimer.
18219820Sjeff *
19219820Sjeff *      - Redistributions in binary form must reproduce the above
20219820Sjeff *        copyright notice, this list of conditions and the following
21219820Sjeff *        disclaimer in the documentation and/or other materials
22219820Sjeff *        provided with the distribution.
23219820Sjeff *
24219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31219820Sjeff * SOFTWARE.
32219820Sjeff */
33219820Sjeff
34219820Sjeff#ifndef IB_USER_CM_H
35219820Sjeff#define IB_USER_CM_H
36219820Sjeff
37273135Shselasky#include <linux/types.h>
38219820Sjeff#include <rdma/ib_user_sa.h>
39219820Sjeff
40219820Sjeff#define IB_USER_CM_ABI_VERSION 5
41219820Sjeff
42219820Sjeffenum {
43219820Sjeff	IB_USER_CM_CMD_CREATE_ID,
44219820Sjeff	IB_USER_CM_CMD_DESTROY_ID,
45219820Sjeff	IB_USER_CM_CMD_ATTR_ID,
46219820Sjeff
47219820Sjeff	IB_USER_CM_CMD_LISTEN,
48219820Sjeff	IB_USER_CM_CMD_NOTIFY,
49219820Sjeff
50219820Sjeff	IB_USER_CM_CMD_SEND_REQ,
51219820Sjeff	IB_USER_CM_CMD_SEND_REP,
52219820Sjeff	IB_USER_CM_CMD_SEND_RTU,
53219820Sjeff	IB_USER_CM_CMD_SEND_DREQ,
54219820Sjeff	IB_USER_CM_CMD_SEND_DREP,
55219820Sjeff	IB_USER_CM_CMD_SEND_REJ,
56219820Sjeff	IB_USER_CM_CMD_SEND_MRA,
57219820Sjeff	IB_USER_CM_CMD_SEND_LAP,
58219820Sjeff	IB_USER_CM_CMD_SEND_APR,
59219820Sjeff	IB_USER_CM_CMD_SEND_SIDR_REQ,
60219820Sjeff	IB_USER_CM_CMD_SEND_SIDR_REP,
61219820Sjeff
62219820Sjeff	IB_USER_CM_CMD_EVENT,
63219820Sjeff	IB_USER_CM_CMD_INIT_QP_ATTR,
64219820Sjeff};
65219820Sjeff/*
66219820Sjeff * command ABI structures.
67219820Sjeff */
68219820Sjeffstruct ib_ucm_cmd_hdr {
69219820Sjeff	__u32 cmd;
70219820Sjeff	__u16 in;
71219820Sjeff	__u16 out;
72219820Sjeff};
73219820Sjeff
74219820Sjeffstruct ib_ucm_create_id {
75219820Sjeff	__u64 uid;
76219820Sjeff	__u64 response;
77219820Sjeff};
78219820Sjeff
79219820Sjeffstruct ib_ucm_create_id_resp {
80219820Sjeff	__u32 id;
81219820Sjeff};
82219820Sjeff
83219820Sjeffstruct ib_ucm_destroy_id {
84219820Sjeff	__u64 response;
85219820Sjeff	__u32 id;
86219820Sjeff	__u32 reserved;
87219820Sjeff};
88219820Sjeff
89219820Sjeffstruct ib_ucm_destroy_id_resp {
90219820Sjeff	__u32 events_reported;
91219820Sjeff};
92219820Sjeff
93219820Sjeffstruct ib_ucm_attr_id {
94219820Sjeff	__u64 response;
95219820Sjeff	__u32 id;
96219820Sjeff	__u32 reserved;
97219820Sjeff};
98219820Sjeff
99219820Sjeffstruct ib_ucm_attr_id_resp {
100219820Sjeff	__be64 service_id;
101219820Sjeff	__be64 service_mask;
102219820Sjeff	__be32 local_id;
103219820Sjeff	__be32 remote_id;
104219820Sjeff};
105219820Sjeff
106219820Sjeffstruct ib_ucm_init_qp_attr {
107219820Sjeff	__u64 response;
108219820Sjeff	__u32 id;
109219820Sjeff	__u32 qp_state;
110219820Sjeff};
111219820Sjeff
112219820Sjeffstruct ib_ucm_listen {
113219820Sjeff	__be64 service_id;
114219820Sjeff	__be64 service_mask;
115219820Sjeff	__u32 id;
116219820Sjeff	__u32 reserved;
117219820Sjeff};
118219820Sjeff
119219820Sjeffstruct ib_ucm_notify {
120219820Sjeff	__u32 id;
121219820Sjeff	__u32 event;
122219820Sjeff};
123219820Sjeff
124219820Sjeffstruct ib_ucm_private_data {
125219820Sjeff	__u64 data;
126219820Sjeff	__u32 id;
127219820Sjeff	__u8  len;
128219820Sjeff	__u8  reserved[3];
129219820Sjeff};
130219820Sjeff
131219820Sjeffstruct ib_ucm_req {
132219820Sjeff	__u32 id;
133219820Sjeff	__u32 qpn;
134219820Sjeff	__u32 qp_type;
135219820Sjeff	__u32 psn;
136219820Sjeff	__be64 sid;
137219820Sjeff	__u64 data;
138219820Sjeff	__u64 primary_path;
139219820Sjeff	__u64 alternate_path;
140219820Sjeff	__u8  len;
141219820Sjeff	__u8  peer_to_peer;
142219820Sjeff	__u8  responder_resources;
143219820Sjeff	__u8  initiator_depth;
144219820Sjeff	__u8  remote_cm_response_timeout;
145219820Sjeff	__u8  flow_control;
146219820Sjeff	__u8  local_cm_response_timeout;
147219820Sjeff	__u8  retry_count;
148219820Sjeff	__u8  rnr_retry_count;
149219820Sjeff	__u8  max_cm_retries;
150219820Sjeff	__u8  srq;
151219820Sjeff	__u8  reserved[5];
152219820Sjeff};
153219820Sjeff
154219820Sjeffstruct ib_ucm_rep {
155219820Sjeff	__u64 uid;
156219820Sjeff	__u64 data;
157219820Sjeff	__u32 id;
158219820Sjeff	__u32 qpn;
159219820Sjeff	__u32 psn;
160219820Sjeff	__u8  len;
161219820Sjeff	__u8  responder_resources;
162219820Sjeff	__u8  initiator_depth;
163219820Sjeff	__u8  target_ack_delay;
164219820Sjeff	__u8  failover_accepted;
165219820Sjeff	__u8  flow_control;
166219820Sjeff	__u8  rnr_retry_count;
167219820Sjeff	__u8  srq;
168219820Sjeff	__u8  reserved[4];
169219820Sjeff};
170219820Sjeff
171219820Sjeffstruct ib_ucm_info {
172219820Sjeff	__u32 id;
173219820Sjeff	__u32 status;
174219820Sjeff	__u64 info;
175219820Sjeff	__u64 data;
176219820Sjeff	__u8  info_len;
177219820Sjeff	__u8  data_len;
178219820Sjeff	__u8  reserved[6];
179219820Sjeff};
180219820Sjeff
181219820Sjeffstruct ib_ucm_mra {
182219820Sjeff	__u64 data;
183219820Sjeff	__u32 id;
184219820Sjeff	__u8  len;
185219820Sjeff	__u8  timeout;
186219820Sjeff	__u8  reserved[2];
187219820Sjeff};
188219820Sjeff
189219820Sjeffstruct ib_ucm_lap {
190219820Sjeff	__u64 path;
191219820Sjeff	__u64 data;
192219820Sjeff	__u32 id;
193219820Sjeff	__u8  len;
194219820Sjeff	__u8  reserved[3];
195219820Sjeff};
196219820Sjeff
197219820Sjeffstruct ib_ucm_sidr_req {
198219820Sjeff	__u32 id;
199219820Sjeff	__u32 timeout;
200219820Sjeff	__be64 sid;
201219820Sjeff	__u64 data;
202219820Sjeff	__u64 path;
203219820Sjeff	__u16 reserved_pkey;
204219820Sjeff	__u8  len;
205219820Sjeff	__u8  max_cm_retries;
206219820Sjeff	__u8  reserved[4];
207219820Sjeff};
208219820Sjeff
209219820Sjeffstruct ib_ucm_sidr_rep {
210219820Sjeff	__u32 id;
211219820Sjeff	__u32 qpn;
212219820Sjeff	__u32 qkey;
213219820Sjeff	__u32 status;
214219820Sjeff	__u64 info;
215219820Sjeff	__u64 data;
216219820Sjeff	__u8  info_len;
217219820Sjeff	__u8  data_len;
218219820Sjeff	__u8  reserved[6];
219219820Sjeff};
220219820Sjeff/*
221219820Sjeff * event notification ABI structures.
222219820Sjeff */
223219820Sjeffstruct ib_ucm_event_get {
224219820Sjeff	__u64 response;
225219820Sjeff	__u64 data;
226219820Sjeff	__u64 info;
227219820Sjeff	__u8  data_len;
228219820Sjeff	__u8  info_len;
229219820Sjeff	__u8  reserved[6];
230219820Sjeff};
231219820Sjeff
232219820Sjeffstruct ib_ucm_req_event_resp {
233219820Sjeff	struct ib_user_path_rec primary_path;
234219820Sjeff	struct ib_user_path_rec alternate_path;
235219820Sjeff	__be64                 remote_ca_guid;
236219820Sjeff	__u32                  remote_qkey;
237219820Sjeff	__u32                  remote_qpn;
238219820Sjeff	__u32                  qp_type;
239219820Sjeff	__u32                  starting_psn;
240219820Sjeff	__u8  responder_resources;
241219820Sjeff	__u8  initiator_depth;
242219820Sjeff	__u8  local_cm_response_timeout;
243219820Sjeff	__u8  flow_control;
244219820Sjeff	__u8  remote_cm_response_timeout;
245219820Sjeff	__u8  retry_count;
246219820Sjeff	__u8  rnr_retry_count;
247219820Sjeff	__u8  srq;
248219820Sjeff	__u8  port;
249219820Sjeff	__u8  reserved[7];
250219820Sjeff};
251219820Sjeff
252219820Sjeffstruct ib_ucm_rep_event_resp {
253219820Sjeff	__be64 remote_ca_guid;
254219820Sjeff	__u32 remote_qkey;
255219820Sjeff	__u32 remote_qpn;
256219820Sjeff	__u32 starting_psn;
257219820Sjeff	__u8  responder_resources;
258219820Sjeff	__u8  initiator_depth;
259219820Sjeff	__u8  target_ack_delay;
260219820Sjeff	__u8  failover_accepted;
261219820Sjeff	__u8  flow_control;
262219820Sjeff	__u8  rnr_retry_count;
263219820Sjeff	__u8  srq;
264219820Sjeff	__u8  reserved[5];
265219820Sjeff};
266219820Sjeff
267219820Sjeffstruct ib_ucm_rej_event_resp {
268219820Sjeff	__u32 reason;
269219820Sjeff	/* ari in ib_ucm_event_get info field. */
270219820Sjeff};
271219820Sjeff
272219820Sjeffstruct ib_ucm_mra_event_resp {
273219820Sjeff	__u8  timeout;
274219820Sjeff	__u8  reserved[3];
275219820Sjeff};
276219820Sjeff
277219820Sjeffstruct ib_ucm_lap_event_resp {
278219820Sjeff	struct ib_user_path_rec path;
279219820Sjeff};
280219820Sjeff
281219820Sjeffstruct ib_ucm_apr_event_resp {
282219820Sjeff	__u32 status;
283219820Sjeff	/* apr info in ib_ucm_event_get info field. */
284219820Sjeff};
285219820Sjeff
286219820Sjeffstruct ib_ucm_sidr_req_event_resp {
287219820Sjeff	__u16 pkey;
288219820Sjeff	__u8  port;
289219820Sjeff	__u8  reserved;
290219820Sjeff};
291219820Sjeff
292219820Sjeffstruct ib_ucm_sidr_rep_event_resp {
293219820Sjeff	__u32 status;
294219820Sjeff	__u32 qkey;
295219820Sjeff	__u32 qpn;
296219820Sjeff	/* info in ib_ucm_event_get info field. */
297219820Sjeff};
298219820Sjeff
299219820Sjeff#define IB_UCM_PRES_DATA      0x01
300219820Sjeff#define IB_UCM_PRES_INFO      0x02
301219820Sjeff#define IB_UCM_PRES_PRIMARY   0x04
302219820Sjeff#define IB_UCM_PRES_ALTERNATE 0x08
303219820Sjeff
304219820Sjeffstruct ib_ucm_event_resp {
305219820Sjeff	__u64 uid;
306219820Sjeff	__u32 id;
307219820Sjeff	__u32 event;
308219820Sjeff	__u32 present;
309219820Sjeff	__u32 reserved;
310219820Sjeff	union {
311219820Sjeff		struct ib_ucm_req_event_resp req_resp;
312219820Sjeff		struct ib_ucm_rep_event_resp rep_resp;
313219820Sjeff		struct ib_ucm_rej_event_resp rej_resp;
314219820Sjeff		struct ib_ucm_mra_event_resp mra_resp;
315219820Sjeff		struct ib_ucm_lap_event_resp lap_resp;
316219820Sjeff		struct ib_ucm_apr_event_resp apr_resp;
317219820Sjeff
318219820Sjeff		struct ib_ucm_sidr_req_event_resp sidr_req_resp;
319219820Sjeff		struct ib_ucm_sidr_rep_event_resp sidr_rep_resp;
320219820Sjeff
321219820Sjeff		__u32                             send_status;
322219820Sjeff	} u;
323219820Sjeff};
324219820Sjeff
325219820Sjeff#endif /* IB_USER_CM_H */
326