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 * $Id$
34219820Sjeff */
35219820Sjeff
36219820Sjeff#ifndef CM_ABI_H
37219820Sjeff#define CM_ABI_H
38219820Sjeff
39219820Sjeff#include <infiniband/types.h>
40219820Sjeff#include <infiniband/sa.h>
41219820Sjeff#include <infiniband/marshall.h>
42219820Sjeff
43219820Sjeff/*
44219820Sjeff * This file must be kept in sync with the kernel's version of ib_user_cm.h
45219820Sjeff */
46219820Sjeff
47219820Sjeff#define IB_USER_CM_MIN_ABI_VERSION	4
48219820Sjeff#define IB_USER_CM_MAX_ABI_VERSION	5
49219820Sjeff
50219820Sjeffenum {
51219820Sjeff	IB_USER_CM_CMD_CREATE_ID,
52219820Sjeff	IB_USER_CM_CMD_DESTROY_ID,
53219820Sjeff	IB_USER_CM_CMD_ATTR_ID,
54219820Sjeff
55219820Sjeff	IB_USER_CM_CMD_LISTEN,
56219820Sjeff	IB_USER_CM_CMD_NOTIFY,
57219820Sjeff	IB_USER_CM_CMD_ESTABLISH = IB_USER_CM_CMD_NOTIFY, /* ABI 4 support */
58219820Sjeff
59219820Sjeff	IB_USER_CM_CMD_SEND_REQ,
60219820Sjeff	IB_USER_CM_CMD_SEND_REP,
61219820Sjeff	IB_USER_CM_CMD_SEND_RTU,
62219820Sjeff	IB_USER_CM_CMD_SEND_DREQ,
63219820Sjeff	IB_USER_CM_CMD_SEND_DREP,
64219820Sjeff	IB_USER_CM_CMD_SEND_REJ,
65219820Sjeff	IB_USER_CM_CMD_SEND_MRA,
66219820Sjeff	IB_USER_CM_CMD_SEND_LAP,
67219820Sjeff	IB_USER_CM_CMD_SEND_APR,
68219820Sjeff	IB_USER_CM_CMD_SEND_SIDR_REQ,
69219820Sjeff	IB_USER_CM_CMD_SEND_SIDR_REP,
70219820Sjeff
71219820Sjeff	IB_USER_CM_CMD_EVENT,
72219820Sjeff	IB_USER_CM_CMD_INIT_QP_ATTR,
73219820Sjeff};
74219820Sjeff/*
75219820Sjeff * command ABI structures.
76219820Sjeff */
77219820Sjeffstruct cm_abi_cmd_hdr {
78219820Sjeff	__u32 cmd;
79219820Sjeff	__u16 in;
80219820Sjeff	__u16 out;
81219820Sjeff};
82219820Sjeff
83219820Sjeffstruct cm_abi_create_id {
84219820Sjeff	__u64 uid;
85219820Sjeff	__u64 response;
86219820Sjeff};
87219820Sjeff
88219820Sjeffstruct cm_abi_create_id_resp {
89219820Sjeff	__u32 id;
90219820Sjeff};
91219820Sjeff
92219820Sjeffstruct cm_abi_destroy_id {
93219820Sjeff	__u64 response;
94219820Sjeff	__u32 id;
95219820Sjeff	__u32 reserved;
96219820Sjeff};
97219820Sjeff
98219820Sjeffstruct cm_abi_destroy_id_resp {
99219820Sjeff	__u32 events_reported;
100219820Sjeff};
101219820Sjeff
102219820Sjeffstruct cm_abi_attr_id {
103219820Sjeff	__u64 response;
104219820Sjeff	__u32 id;
105219820Sjeff	__u32 reserved;
106219820Sjeff};
107219820Sjeff
108219820Sjeffstruct cm_abi_attr_id_resp {
109219820Sjeff	__u64 service_id;
110219820Sjeff	__u64 service_mask;
111219820Sjeff	__u32 local_id;
112219820Sjeff	__u32 remote_id;
113219820Sjeff};
114219820Sjeff
115219820Sjeffstruct cm_abi_init_qp_attr {
116219820Sjeff	__u64 response;
117219820Sjeff	__u32 id;
118219820Sjeff	__u32 qp_state;
119219820Sjeff};
120219820Sjeff
121219820Sjeffstruct cm_abi_listen {
122219820Sjeff	__u64 service_id;
123219820Sjeff	__u64 service_mask;
124219820Sjeff	__u32 id;
125219820Sjeff	__u32 reserved;
126219820Sjeff};
127219820Sjeff
128219820Sjeffstruct cm_abi_establish {	/* ABI 4 support */
129219820Sjeff	__u32 id;
130219820Sjeff};
131219820Sjeff
132219820Sjeffstruct cm_abi_notify {
133219820Sjeff	__u32 id;
134219820Sjeff	__u32 event;
135219820Sjeff};
136219820Sjeff
137219820Sjeffstruct cm_abi_private_data {
138219820Sjeff	__u64 data;
139219820Sjeff	__u32 id;
140219820Sjeff	__u8  len;
141219820Sjeff	__u8  reserved[3];
142219820Sjeff};
143219820Sjeff
144219820Sjeffstruct cm_abi_req {
145219820Sjeff	__u32 id;
146219820Sjeff	__u32 qpn;
147219820Sjeff	__u32 qp_type;
148219820Sjeff	__u32 psn;
149219820Sjeff	__u64 sid;
150219820Sjeff	__u64 data;
151219820Sjeff	__u64 primary_path;
152219820Sjeff	__u64 alternate_path;
153219820Sjeff	__u8  len;
154219820Sjeff	__u8  peer_to_peer;
155219820Sjeff	__u8  responder_resources;
156219820Sjeff	__u8  initiator_depth;
157219820Sjeff	__u8  remote_cm_response_timeout;
158219820Sjeff	__u8  flow_control;
159219820Sjeff	__u8  local_cm_response_timeout;
160219820Sjeff	__u8  retry_count;
161219820Sjeff	__u8  rnr_retry_count;
162219820Sjeff	__u8  max_cm_retries;
163219820Sjeff	__u8  srq;
164219820Sjeff	__u8  reserved[5];
165219820Sjeff};
166219820Sjeff
167219820Sjeffstruct cm_abi_rep {
168219820Sjeff	__u64 uid;
169219820Sjeff	__u64 data;
170219820Sjeff	__u32 id;
171219820Sjeff	__u32 qpn;
172219820Sjeff	__u32 psn;
173219820Sjeff	__u8  len;
174219820Sjeff	__u8  responder_resources;
175219820Sjeff	__u8  initiator_depth;
176219820Sjeff	__u8  target_ack_delay;
177219820Sjeff	__u8  failover_accepted;
178219820Sjeff	__u8  flow_control;
179219820Sjeff	__u8  rnr_retry_count;
180219820Sjeff	__u8  srq;
181219820Sjeff	__u8  reserved[4];
182219820Sjeff};
183219820Sjeff
184219820Sjeffstruct cm_abi_info {
185219820Sjeff	__u32 id;
186219820Sjeff	__u32 status;
187219820Sjeff	__u64 info;
188219820Sjeff	__u64 data;
189219820Sjeff	__u8  info_len;
190219820Sjeff	__u8  data_len;
191219820Sjeff	__u8  reserved[6];
192219820Sjeff};
193219820Sjeff
194219820Sjeffstruct cm_abi_mra {
195219820Sjeff	__u64 data;
196219820Sjeff	__u32 id;
197219820Sjeff	__u8  len;
198219820Sjeff	__u8  timeout;
199219820Sjeff	__u8  reserved[2];
200219820Sjeff};
201219820Sjeff
202219820Sjeffstruct cm_abi_lap {
203219820Sjeff	__u64 path;
204219820Sjeff	__u64 data;
205219820Sjeff	__u32 id;
206219820Sjeff	__u8  len;
207219820Sjeff	__u8  reserved[3];
208219820Sjeff};
209219820Sjeff
210219820Sjeffstruct cm_abi_sidr_req {
211219820Sjeff	__u32 id;
212219820Sjeff	__u32 timeout;
213219820Sjeff	__u64 sid;
214219820Sjeff	__u64 data;
215219820Sjeff	__u64 path;
216219820Sjeff	__u16 pkey;
217219820Sjeff	__u8  len;
218219820Sjeff	__u8  max_cm_retries;
219219820Sjeff	__u8  reserved[4];
220219820Sjeff};
221219820Sjeff
222219820Sjeffstruct cm_abi_sidr_rep {
223219820Sjeff	__u32 id;
224219820Sjeff	__u32 qpn;
225219820Sjeff	__u32 qkey;
226219820Sjeff	__u32 status;
227219820Sjeff	__u64 info;
228219820Sjeff	__u64 data;
229219820Sjeff	__u8  info_len;
230219820Sjeff	__u8  data_len;
231219820Sjeff	__u8  reserved[6];
232219820Sjeff};
233219820Sjeff/*
234219820Sjeff * event notification ABI structures.
235219820Sjeff */
236219820Sjeffstruct cm_abi_event_get {
237219820Sjeff	__u64 response;
238219820Sjeff	__u64 data;
239219820Sjeff	__u64 info;
240219820Sjeff	__u8  data_len;
241219820Sjeff	__u8  info_len;
242219820Sjeff	__u8  reserved[6];
243219820Sjeff};
244219820Sjeff
245219820Sjeffstruct cm_abi_req_event_resp {
246219820Sjeff	struct ibv_kern_path_rec primary_path;
247219820Sjeff	struct ibv_kern_path_rec alternate_path;
248219820Sjeff	__u64                  remote_ca_guid;
249219820Sjeff	__u32                  remote_qkey;
250219820Sjeff	__u32                  remote_qpn;
251219820Sjeff	__u32                  qp_type;
252219820Sjeff	__u32                  starting_psn;
253219820Sjeff	__u8  responder_resources;
254219820Sjeff	__u8  initiator_depth;
255219820Sjeff	__u8  local_cm_response_timeout;
256219820Sjeff	__u8  flow_control;
257219820Sjeff	__u8  remote_cm_response_timeout;
258219820Sjeff	__u8  retry_count;
259219820Sjeff	__u8  rnr_retry_count;
260219820Sjeff	__u8  srq;
261219820Sjeff	__u8  port;
262219820Sjeff	__u8  reserved[7];
263219820Sjeff};
264219820Sjeff
265219820Sjeffstruct cm_abi_rep_event_resp {
266219820Sjeff	__u64 remote_ca_guid;
267219820Sjeff	__u32 remote_qkey;
268219820Sjeff	__u32 remote_qpn;
269219820Sjeff	__u32 starting_psn;
270219820Sjeff	__u8  responder_resources;
271219820Sjeff	__u8  initiator_depth;
272219820Sjeff	__u8  target_ack_delay;
273219820Sjeff	__u8  failover_accepted;
274219820Sjeff	__u8  flow_control;
275219820Sjeff	__u8  rnr_retry_count;
276219820Sjeff	__u8  srq;
277219820Sjeff	__u8  reserved[5];
278219820Sjeff};
279219820Sjeff
280219820Sjeffstruct cm_abi_rej_event_resp {
281219820Sjeff	__u32 reason;
282219820Sjeff	/* ari in cm_abi_event_get info field. */
283219820Sjeff};
284219820Sjeff
285219820Sjeffstruct cm_abi_mra_event_resp {
286219820Sjeff	__u8  timeout;
287219820Sjeff	__u8  reserved[3];
288219820Sjeff};
289219820Sjeff
290219820Sjeffstruct cm_abi_lap_event_resp {
291219820Sjeff	struct ibv_kern_path_rec path;
292219820Sjeff};
293219820Sjeff
294219820Sjeffstruct cm_abi_apr_event_resp {
295219820Sjeff	__u32 status;
296219820Sjeff	/* apr info in cm_abi_event_get info field. */
297219820Sjeff};
298219820Sjeff
299219820Sjeffstruct cm_abi_sidr_req_event_resp {
300219820Sjeff	__u16 pkey;
301219820Sjeff	__u8  port;
302219820Sjeff	__u8  reserved;
303219820Sjeff};
304219820Sjeff
305219820Sjeffstruct cm_abi_sidr_rep_event_resp {
306219820Sjeff	__u32 status;
307219820Sjeff	__u32 qkey;
308219820Sjeff	__u32 qpn;
309219820Sjeff	/* info in cm_abi_event_get info field. */
310219820Sjeff};
311219820Sjeff
312219820Sjeff#define CM_ABI_PRES_DATA      0x01
313219820Sjeff#define CM_ABI_PRES_INFO      0x02
314219820Sjeff#define CM_ABI_PRES_PRIMARY   0x04
315219820Sjeff#define CM_ABI_PRES_ALTERNATE 0x08
316219820Sjeff
317219820Sjeffstruct cm_abi_event_resp {
318219820Sjeff	__u64 uid;
319219820Sjeff	__u32 id;
320219820Sjeff	__u32 event;
321219820Sjeff	__u32 present;
322219820Sjeff	__u32 reserved;
323219820Sjeff	union {
324219820Sjeff		struct cm_abi_req_event_resp req_resp;
325219820Sjeff		struct cm_abi_rep_event_resp rep_resp;
326219820Sjeff		struct cm_abi_rej_event_resp rej_resp;
327219820Sjeff		struct cm_abi_mra_event_resp mra_resp;
328219820Sjeff		struct cm_abi_lap_event_resp lap_resp;
329219820Sjeff		struct cm_abi_apr_event_resp apr_resp;
330219820Sjeff
331219820Sjeff		struct cm_abi_sidr_req_event_resp sidr_req_resp;
332219820Sjeff		struct cm_abi_sidr_rep_event_resp sidr_rep_resp;
333219820Sjeff
334219820Sjeff		__u32                             send_status;
335219820Sjeff	} u;
336219820Sjeff};
337219820Sjeff
338219820Sjeff#endif /* CM_ABI_H */
339