[IB] uverbs: ABI-breaking fixes for userspace verbs
[safe/jmp/linux-2.6] / include / rdma / ib_user_verbs.h
1 /*
2  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
3  * Copyright (c) 2005 Cisco Systems.  All rights reserved.
4  *
5  * This software is available to you under a choice of one of two
6  * licenses.  You may choose to be licensed under the terms of the GNU
7  * General Public License (GPL) Version 2, available from the file
8  * COPYING in the main directory of this source tree, or the
9  * OpenIB.org BSD license below:
10  *
11  *     Redistribution and use in source and binary forms, with or
12  *     without modification, are permitted provided that the following
13  *     conditions are met:
14  *
15  *      - Redistributions of source code must retain the above
16  *        copyright notice, this list of conditions and the following
17  *        disclaimer.
18  *
19  *      - Redistributions in binary form must reproduce the above
20  *        copyright notice, this list of conditions and the following
21  *        disclaimer in the documentation and/or other materials
22  *        provided with the distribution.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  * SOFTWARE.
32  *
33  * $Id: ib_user_verbs.h 2708 2005-06-24 17:27:21Z roland $
34  */
35
36 #ifndef IB_USER_VERBS_H
37 #define IB_USER_VERBS_H
38
39 #include <linux/types.h>
40
41 /*
42  * Increment this value if any changes that break userspace ABI
43  * compatibility are made.
44  */
45 #define IB_USER_VERBS_ABI_VERSION       3
46
47 enum {
48         IB_USER_VERBS_CMD_GET_CONTEXT,
49         IB_USER_VERBS_CMD_QUERY_DEVICE,
50         IB_USER_VERBS_CMD_QUERY_PORT,
51         IB_USER_VERBS_CMD_ALLOC_PD,
52         IB_USER_VERBS_CMD_DEALLOC_PD,
53         IB_USER_VERBS_CMD_CREATE_AH,
54         IB_USER_VERBS_CMD_MODIFY_AH,
55         IB_USER_VERBS_CMD_QUERY_AH,
56         IB_USER_VERBS_CMD_DESTROY_AH,
57         IB_USER_VERBS_CMD_REG_MR,
58         IB_USER_VERBS_CMD_REG_SMR,
59         IB_USER_VERBS_CMD_REREG_MR,
60         IB_USER_VERBS_CMD_QUERY_MR,
61         IB_USER_VERBS_CMD_DEREG_MR,
62         IB_USER_VERBS_CMD_ALLOC_MW,
63         IB_USER_VERBS_CMD_BIND_MW,
64         IB_USER_VERBS_CMD_DEALLOC_MW,
65         IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
66         IB_USER_VERBS_CMD_CREATE_CQ,
67         IB_USER_VERBS_CMD_RESIZE_CQ,
68         IB_USER_VERBS_CMD_DESTROY_CQ,
69         IB_USER_VERBS_CMD_POLL_CQ,
70         IB_USER_VERBS_CMD_PEEK_CQ,
71         IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
72         IB_USER_VERBS_CMD_CREATE_QP,
73         IB_USER_VERBS_CMD_QUERY_QP,
74         IB_USER_VERBS_CMD_MODIFY_QP,
75         IB_USER_VERBS_CMD_DESTROY_QP,
76         IB_USER_VERBS_CMD_POST_SEND,
77         IB_USER_VERBS_CMD_POST_RECV,
78         IB_USER_VERBS_CMD_ATTACH_MCAST,
79         IB_USER_VERBS_CMD_DETACH_MCAST,
80         IB_USER_VERBS_CMD_CREATE_SRQ,
81         IB_USER_VERBS_CMD_MODIFY_SRQ,
82         IB_USER_VERBS_CMD_QUERY_SRQ,
83         IB_USER_VERBS_CMD_DESTROY_SRQ,
84         IB_USER_VERBS_CMD_POST_SRQ_RECV
85 };
86
87 /*
88  * Make sure that all structs defined in this file remain laid out so
89  * that they pack the same way on 32-bit and 64-bit architectures (to
90  * avoid incompatibility between 32-bit userspace and 64-bit kernels).
91  * In particular do not use pointer types -- pass pointers in __u64
92  * instead.
93  */
94
95 struct ib_uverbs_async_event_desc {
96         __u64 element;
97         __u32 event_type;       /* enum ib_event_type */
98         __u32 reserved;
99 };
100
101 struct ib_uverbs_comp_event_desc {
102         __u64 cq_handle;
103 };
104
105 /*
106  * All commands from userspace should start with a __u32 command field
107  * followed by __u16 in_words and out_words fields (which give the
108  * length of the command block and response buffer if any in 32-bit
109  * words).  The kernel driver will read these fields first and read
110  * the rest of the command struct based on these value.
111  */
112
113 struct ib_uverbs_cmd_hdr {
114         __u32 command;
115         __u16 in_words;
116         __u16 out_words;
117 };
118
119 struct ib_uverbs_get_context {
120         __u64 response;
121         __u64 driver_data[0];
122 };
123
124 struct ib_uverbs_get_context_resp {
125         __u32 async_fd;
126         __u32 num_comp_vectors;
127 };
128
129 struct ib_uverbs_query_device {
130         __u64 response;
131         __u64 driver_data[0];
132 };
133
134 struct ib_uverbs_query_device_resp {
135         __u64 fw_ver;
136         __be64 node_guid;
137         __be64 sys_image_guid;
138         __u64 max_mr_size;
139         __u64 page_size_cap;
140         __u32 vendor_id;
141         __u32 vendor_part_id;
142         __u32 hw_ver;
143         __u32 max_qp;
144         __u32 max_qp_wr;
145         __u32 device_cap_flags;
146         __u32 max_sge;
147         __u32 max_sge_rd;
148         __u32 max_cq;
149         __u32 max_cqe;
150         __u32 max_mr;
151         __u32 max_pd;
152         __u32 max_qp_rd_atom;
153         __u32 max_ee_rd_atom;
154         __u32 max_res_rd_atom;
155         __u32 max_qp_init_rd_atom;
156         __u32 max_ee_init_rd_atom;
157         __u32 atomic_cap;
158         __u32 max_ee;
159         __u32 max_rdd;
160         __u32 max_mw;
161         __u32 max_raw_ipv6_qp;
162         __u32 max_raw_ethy_qp;
163         __u32 max_mcast_grp;
164         __u32 max_mcast_qp_attach;
165         __u32 max_total_mcast_qp_attach;
166         __u32 max_ah;
167         __u32 max_fmr;
168         __u32 max_map_per_fmr;
169         __u32 max_srq;
170         __u32 max_srq_wr;
171         __u32 max_srq_sge;
172         __u16 max_pkeys;
173         __u8  local_ca_ack_delay;
174         __u8  phys_port_cnt;
175         __u8  reserved[4];
176 };
177
178 struct ib_uverbs_query_port {
179         __u64 response;
180         __u8  port_num;
181         __u8  reserved[7];
182         __u64 driver_data[0];
183 };
184
185 struct ib_uverbs_query_port_resp {
186         __u32 port_cap_flags;
187         __u32 max_msg_sz;
188         __u32 bad_pkey_cntr;
189         __u32 qkey_viol_cntr;
190         __u32 gid_tbl_len;
191         __u16 pkey_tbl_len;
192         __u16 lid;
193         __u16 sm_lid;
194         __u8  state;
195         __u8  max_mtu;
196         __u8  active_mtu;
197         __u8  lmc;
198         __u8  max_vl_num;
199         __u8  sm_sl;
200         __u8  subnet_timeout;
201         __u8  init_type_reply;
202         __u8  active_width;
203         __u8  active_speed;
204         __u8  phys_state;
205         __u8  reserved[3];
206 };
207
208 struct ib_uverbs_alloc_pd {
209         __u64 response;
210         __u64 driver_data[0];
211 };
212
213 struct ib_uverbs_alloc_pd_resp {
214         __u32 pd_handle;
215 };
216
217 struct ib_uverbs_dealloc_pd {
218         __u32 pd_handle;
219 };
220
221 struct ib_uverbs_reg_mr {
222         __u64 response;
223         __u64 start;
224         __u64 length;
225         __u64 hca_va;
226         __u32 pd_handle;
227         __u32 access_flags;
228         __u64 driver_data[0];
229 };
230
231 struct ib_uverbs_reg_mr_resp {
232         __u32 mr_handle;
233         __u32 lkey;
234         __u32 rkey;
235 };
236
237 struct ib_uverbs_dereg_mr {
238         __u32 mr_handle;
239 };
240
241 struct ib_uverbs_create_comp_channel {
242         __u64 response;
243 };
244
245 struct ib_uverbs_create_comp_channel_resp {
246         __u32 fd;
247 };
248
249 struct ib_uverbs_create_cq {
250         __u64 response;
251         __u64 user_handle;
252         __u32 cqe;
253         __u32 comp_vector;
254         __s32 comp_channel;
255         __u32 reserved;
256         __u64 driver_data[0];
257 };
258
259 struct ib_uverbs_create_cq_resp {
260         __u32 cq_handle;
261         __u32 cqe;
262 };
263
264 struct ib_uverbs_destroy_cq {
265         __u64 response;
266         __u32 cq_handle;
267         __u32 reserved;
268 };
269
270 struct ib_uverbs_destroy_cq_resp {
271         __u32 comp_events_reported;
272         __u32 async_events_reported;
273 };
274
275 struct ib_uverbs_create_qp {
276         __u64 response;
277         __u64 user_handle;
278         __u32 pd_handle;
279         __u32 send_cq_handle;
280         __u32 recv_cq_handle;
281         __u32 srq_handle;
282         __u32 max_send_wr;
283         __u32 max_recv_wr;
284         __u32 max_send_sge;
285         __u32 max_recv_sge;
286         __u32 max_inline_data;
287         __u8  sq_sig_all;
288         __u8  qp_type;
289         __u8  is_srq;
290         __u8  reserved;
291         __u64 driver_data[0];
292 };
293
294 struct ib_uverbs_create_qp_resp {
295         __u32 qp_handle;
296         __u32 qpn;
297 };
298
299 /*
300  * This struct needs to remain a multiple of 8 bytes to keep the
301  * alignment of the modify QP parameters.
302  */
303 struct ib_uverbs_qp_dest {
304         __u8  dgid[16];
305         __u32 flow_label;
306         __u16 dlid;
307         __u16 reserved;
308         __u8  sgid_index;
309         __u8  hop_limit;
310         __u8  traffic_class;
311         __u8  sl;
312         __u8  src_path_bits;
313         __u8  static_rate;
314         __u8  is_global;
315         __u8  port_num;
316 };
317
318 struct ib_uverbs_modify_qp {
319         struct ib_uverbs_qp_dest dest;
320         struct ib_uverbs_qp_dest alt_dest;
321         __u32 qp_handle;
322         __u32 attr_mask;
323         __u32 qkey;
324         __u32 rq_psn;
325         __u32 sq_psn;
326         __u32 dest_qp_num;
327         __u32 qp_access_flags;
328         __u16 pkey_index;
329         __u16 alt_pkey_index;
330         __u8  qp_state;
331         __u8  cur_qp_state;
332         __u8  path_mtu;
333         __u8  path_mig_state;
334         __u8  en_sqd_async_notify;
335         __u8  max_rd_atomic;
336         __u8  max_dest_rd_atomic;
337         __u8  min_rnr_timer;
338         __u8  port_num;
339         __u8  timeout;
340         __u8  retry_cnt;
341         __u8  rnr_retry;
342         __u8  alt_port_num;
343         __u8  alt_timeout;
344         __u8  reserved[2];
345         __u64 driver_data[0];
346 };
347
348 struct ib_uverbs_modify_qp_resp {
349 };
350
351 struct ib_uverbs_destroy_qp {
352         __u64 response;
353         __u32 qp_handle;
354         __u32 reserved;
355 };
356
357 struct ib_uverbs_destroy_qp_resp {
358         __u32 events_reported;
359 };
360
361 struct ib_uverbs_attach_mcast {
362         __u8  gid[16];
363         __u32 qp_handle;
364         __u16 mlid;
365         __u16 reserved;
366         __u64 driver_data[0];
367 };
368
369 struct ib_uverbs_detach_mcast {
370         __u8  gid[16];
371         __u32 qp_handle;
372         __u16 mlid;
373         __u16 reserved;
374         __u64 driver_data[0];
375 };
376
377 struct ib_uverbs_create_srq {
378         __u64 response;
379         __u64 user_handle;
380         __u32 pd_handle;
381         __u32 max_wr;
382         __u32 max_sge;
383         __u32 srq_limit;
384         __u64 driver_data[0];
385 };
386
387 struct ib_uverbs_create_srq_resp {
388         __u32 srq_handle;
389 };
390
391 struct ib_uverbs_modify_srq {
392         __u32 srq_handle;
393         __u32 attr_mask;
394         __u32 max_wr;
395         __u32 max_sge;
396         __u32 srq_limit;
397         __u32 reserved;
398         __u64 driver_data[0];
399 };
400
401 struct ib_uverbs_destroy_srq {
402         __u64 response;
403         __u32 srq_handle;
404         __u32 reserved;
405 };
406
407 struct ib_uverbs_destroy_srq_resp {
408         __u32 events_reported;
409 };
410
411 #endif /* IB_USER_VERBS_H */