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
37219820Sjeff#include <rdma/ib_user_sa.h>
38219820Sjeff
39219820Sjeff#define IB_USER_CM_ABI_VERSION 5
40219820Sjeff
41219820Sjeffenum {
42219820Sjeff	IB_USER_CM_CMD_CREATE_ID,
43219820Sjeff	IB_USER_CM_CMD_DESTROY_ID,
44219820Sjeff	IB_USER_CM_CMD_ATTR_ID,
45219820Sjeff
46219820Sjeff	IB_USER_CM_CMD_LISTEN,
47219820Sjeff	IB_USER_CM_CMD_NOTIFY,
48219820Sjeff
49219820Sjeff	IB_USER_CM_CMD_SEND_REQ,
50219820Sjeff	IB_USER_CM_CMD_SEND_REP,
51219820Sjeff	IB_USER_CM_CMD_SEND_RTU,
52219820Sjeff	IB_USER_CM_CMD_SEND_DREQ,
53219820Sjeff	IB_USER_CM_CMD_SEND_DREP,
54219820Sjeff	IB_USER_CM_CMD_SEND_REJ,
55219820Sjeff	IB_USER_CM_CMD_SEND_MRA,
56219820Sjeff	IB_USER_CM_CMD_SEND_LAP,
57219820Sjeff	IB_USER_CM_CMD_SEND_APR,
58219820Sjeff	IB_USER_CM_CMD_SEND_SIDR_REQ,
59219820Sjeff	IB_USER_CM_CMD_SEND_SIDR_REP,
60219820Sjeff
61219820Sjeff	IB_USER_CM_CMD_EVENT,
62219820Sjeff	IB_USER_CM_CMD_INIT_QP_ATTR,
63219820Sjeff};
64219820Sjeff/*
65219820Sjeff * command ABI structures.
66219820Sjeff */
67219820Sjeffstruct ib_ucm_cmd_hdr {
68219820Sjeff	__u32 cmd;
69219820Sjeff	__u16 in;
70219820Sjeff	__u16 out;
71219820Sjeff};
72219820Sjeff
73219820Sjeffstruct ib_ucm_create_id {
74219820Sjeff	__u64 uid;
75219820Sjeff	__u64 response;
76219820Sjeff};
77219820Sjeff
78219820Sjeffstruct ib_ucm_create_id_resp {
79219820Sjeff	__u32 id;
80219820Sjeff};
81219820Sjeff
82219820Sjeffstruct ib_ucm_destroy_id {
83219820Sjeff	__u64 response;
84219820Sjeff	__u32 id;
85219820Sjeff	__u32 reserved;
86219820Sjeff};
87219820Sjeff
88219820Sjeffstruct ib_ucm_destroy_id_resp {
89219820Sjeff	__u32 events_reported;
90219820Sjeff};
91219820Sjeff
92219820Sjeffstruct ib_ucm_attr_id {
93219820Sjeff	__u64 response;
94219820Sjeff	__u32 id;
95219820Sjeff	__u32 reserved;
96219820Sjeff};
97219820Sjeff
98219820Sjeffstruct ib_ucm_attr_id_resp {
99219820Sjeff	__be64 service_id;
100219820Sjeff	__be64 service_mask;
101219820Sjeff	__be32 local_id;
102219820Sjeff	__be32 remote_id;
103219820Sjeff};
104219820Sjeff
105219820Sjeffstruct ib_ucm_init_qp_attr {
106219820Sjeff	__u64 response;
107219820Sjeff	__u32 id;
108219820Sjeff	__u32 qp_state;
109219820Sjeff};
110219820Sjeff
111219820Sjeffstruct ib_ucm_listen {
112219820Sjeff	__be64 service_id;
113219820Sjeff	__be64 service_mask;
114219820Sjeff	__u32 id;
115219820Sjeff	__u32 reserved;
116219820Sjeff};
117219820Sjeff
118219820Sjeffstruct ib_ucm_notify {
119219820Sjeff	__u32 id;
120219820Sjeff	__u32 event;
121219820Sjeff};
122219820Sjeff
123219820Sjeffstruct ib_ucm_private_data {
124219820Sjeff	__u64 data;
125219820Sjeff	__u32 id;
126219820Sjeff	__u8  len;
127219820Sjeff	__u8  reserved[3];
128219820Sjeff};
129219820Sjeff
130219820Sjeffstruct ib_ucm_req {
131219820Sjeff	__u32 id;
132219820Sjeff	__u32 qpn;
133219820Sjeff	__u32 qp_type;
134219820Sjeff	__u32 psn;
135219820Sjeff	__be64 sid;
136219820Sjeff	__u64 data;
137219820Sjeff	__u64 primary_path;
138219820Sjeff	__u64 alternate_path;
139219820Sjeff	__u8  len;
140219820Sjeff	__u8  peer_to_peer;
141219820Sjeff	__u8  responder_resources;
142219820Sjeff	__u8  initiator_depth;
143219820Sjeff	__u8  remote_cm_response_timeout;
144219820Sjeff	__u8  flow_control;
145219820Sjeff	__u8  local_cm_response_timeout;
146219820Sjeff	__u8  retry_count;
147219820Sjeff	__u8  rnr_retry_count;
148219820Sjeff	__u8  max_cm_retries;
149219820Sjeff	__u8  srq;
150219820Sjeff	__u8  reserved[5];
151219820Sjeff};
152219820Sjeff
153219820Sjeffstruct ib_ucm_rep {
154219820Sjeff	__u64 uid;
155219820Sjeff	__u64 data;
156219820Sjeff	__u32 id;
157219820Sjeff	__u32 qpn;
158219820Sjeff	__u32 psn;
159219820Sjeff	__u8  len;
160219820Sjeff	__u8  responder_resources;
161219820Sjeff	__u8  initiator_depth;
162219820Sjeff	__u8  target_ack_delay;
163219820Sjeff	__u8  failover_accepted;
164219820Sjeff	__u8  flow_control;
165219820Sjeff	__u8  rnr_retry_count;
166219820Sjeff	__u8  srq;
167219820Sjeff	__u8  reserved[4];
168219820Sjeff};
169219820Sjeff
170219820Sjeffstruct ib_ucm_info {
171219820Sjeff	__u32 id;
172219820Sjeff	__u32 status;
173219820Sjeff	__u64 info;
174219820Sjeff	__u64 data;
175219820Sjeff	__u8  info_len;
176219820Sjeff	__u8  data_len;
177219820Sjeff	__u8  reserved[6];
178219820Sjeff};
179219820Sjeff
180219820Sjeffstruct ib_ucm_mra {
181219820Sjeff	__u64 data;
182219820Sjeff	__u32 id;
183219820Sjeff	__u8  len;
184219820Sjeff	__u8  timeout;
185219820Sjeff	__u8  reserved[2];
186219820Sjeff};
187219820Sjeff
188219820Sjeffstruct ib_ucm_lap {
189219820Sjeff	__u64 path;
190219820Sjeff	__u64 data;
191219820Sjeff	__u32 id;
192219820Sjeff	__u8  len;
193219820Sjeff	__u8  reserved[3];
194219820Sjeff};
195219820Sjeff
196219820Sjeffstruct ib_ucm_sidr_req {
197219820Sjeff	__u32 id;
198219820Sjeff	__u32 timeout;
199219820Sjeff	__be64 sid;
200219820Sjeff	__u64 data;
201219820Sjeff	__u64 path;
202219820Sjeff	__u16 reserved_pkey;
203219820Sjeff	__u8  len;
204219820Sjeff	__u8  max_cm_retries;
205219820Sjeff	__u8  reserved[4];
206219820Sjeff};
207219820Sjeff
208219820Sjeffstruct ib_ucm_sidr_rep {
209219820Sjeff	__u32 id;
210219820Sjeff	__u32 qpn;
211219820Sjeff	__u32 qkey;
212219820Sjeff	__u32 status;
213219820Sjeff	__u64 info;
214219820Sjeff	__u64 data;
215219820Sjeff	__u8  info_len;
216219820Sjeff	__u8  data_len;
217219820Sjeff	__u8  reserved[6];
218219820Sjeff};
219219820Sjeff/*
220219820Sjeff * event notification ABI structures.
221219820Sjeff */
222219820Sjeffstruct ib_ucm_event_get {
223219820Sjeff	__u64 response;
224219820Sjeff	__u64 data;
225219820Sjeff	__u64 info;
226219820Sjeff	__u8  data_len;
227219820Sjeff	__u8  info_len;
228219820Sjeff	__u8  reserved[6];
229219820Sjeff};
230219820Sjeff
231219820Sjeffstruct ib_ucm_req_event_resp {
232219820Sjeff	struct ib_user_path_rec primary_path;
233219820Sjeff	struct ib_user_path_rec alternate_path;
234219820Sjeff	__be64                 remote_ca_guid;
235219820Sjeff	__u32                  remote_qkey;
236219820Sjeff	__u32                  remote_qpn;
237219820Sjeff	__u32                  qp_type;
238219820Sjeff	__u32                  starting_psn;
239219820Sjeff	__u8  responder_resources;
240219820Sjeff	__u8  initiator_depth;
241219820Sjeff	__u8  local_cm_response_timeout;
242219820Sjeff	__u8  flow_control;
243219820Sjeff	__u8  remote_cm_response_timeout;
244219820Sjeff	__u8  retry_count;
245219820Sjeff	__u8  rnr_retry_count;
246219820Sjeff	__u8  srq;
247219820Sjeff	__u8  port;
248219820Sjeff	__u8  reserved[7];
249219820Sjeff};
250219820Sjeff
251219820Sjeffstruct ib_ucm_rep_event_resp {
252219820Sjeff	__be64 remote_ca_guid;
253219820Sjeff	__u32 remote_qkey;
254219820Sjeff	__u32 remote_qpn;
255219820Sjeff	__u32 starting_psn;
256219820Sjeff	__u8  responder_resources;
257219820Sjeff	__u8  initiator_depth;
258219820Sjeff	__u8  target_ack_delay;
259219820Sjeff	__u8  failover_accepted;
260219820Sjeff	__u8  flow_control;
261219820Sjeff	__u8  rnr_retry_count;
262219820Sjeff	__u8  srq;
263219820Sjeff	__u8  reserved[5];
264219820Sjeff};
265219820Sjeff
266219820Sjeffstruct ib_ucm_rej_event_resp {
267219820Sjeff	__u32 reason;
268219820Sjeff	/* ari in ib_ucm_event_get info field. */
269219820Sjeff};
270219820Sjeff
271219820Sjeffstruct ib_ucm_mra_event_resp {
272219820Sjeff	__u8  timeout;
273219820Sjeff	__u8  reserved[3];
274219820Sjeff};
275219820Sjeff
276219820Sjeffstruct ib_ucm_lap_event_resp {
277219820Sjeff	struct ib_user_path_rec path;
278219820Sjeff};
279219820Sjeff
280219820Sjeffstruct ib_ucm_apr_event_resp {
281219820Sjeff	__u32 status;
282219820Sjeff	/* apr info in ib_ucm_event_get info field. */
283219820Sjeff};
284219820Sjeff
285219820Sjeffstruct ib_ucm_sidr_req_event_resp {
286219820Sjeff	__u16 pkey;
287219820Sjeff	__u8  port;
288219820Sjeff	__u8  reserved;
289219820Sjeff};
290219820Sjeff
291219820Sjeffstruct ib_ucm_sidr_rep_event_resp {
292219820Sjeff	__u32 status;
293219820Sjeff	__u32 qkey;
294219820Sjeff	__u32 qpn;
295219820Sjeff	/* info in ib_ucm_event_get info field. */
296219820Sjeff};
297219820Sjeff
298219820Sjeff#define IB_UCM_PRES_DATA      0x01
299219820Sjeff#define IB_UCM_PRES_INFO      0x02
300219820Sjeff#define IB_UCM_PRES_PRIMARY   0x04
301219820Sjeff#define IB_UCM_PRES_ALTERNATE 0x08
302219820Sjeff
303219820Sjeffstruct ib_ucm_event_resp {
304219820Sjeff	__u64 uid;
305219820Sjeff	__u32 id;
306219820Sjeff	__u32 event;
307219820Sjeff	__u32 present;
308219820Sjeff	__u32 reserved;
309219820Sjeff	union {
310219820Sjeff		struct ib_ucm_req_event_resp req_resp;
311219820Sjeff		struct ib_ucm_rep_event_resp rep_resp;
312219820Sjeff		struct ib_ucm_rej_event_resp rej_resp;
313219820Sjeff		struct ib_ucm_mra_event_resp mra_resp;
314219820Sjeff		struct ib_ucm_lap_event_resp lap_resp;
315219820Sjeff		struct ib_ucm_apr_event_resp apr_resp;
316219820Sjeff
317219820Sjeff		struct ib_ucm_sidr_req_event_resp sidr_req_resp;
318219820Sjeff		struct ib_ucm_sidr_rep_event_resp sidr_rep_resp;
319219820Sjeff
320219820Sjeff		__u32                             send_status;
321219820Sjeff	} u;
322219820Sjeff};
323219820Sjeff
324219820Sjeff#endif /* IB_USER_CM_H */
325