IB: Whitespace cleanups
[pandora-kernel.git] / include / rdma / ib_user_verbs.h
1 /*
2  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
3  * Copyright (c) 2005, 2006 Cisco Systems.  All rights reserved.
4  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
5  *
6  * This software is available to you under a choice of one of two
7  * licenses.  You may choose to be licensed under the terms of the GNU
8  * General Public License (GPL) Version 2, available from the file
9  * COPYING in the main directory of this source tree, or the
10  * OpenIB.org BSD license below:
11  *
12  *     Redistribution and use in source and binary forms, with or
13  *     without modification, are permitted provided that the following
14  *     conditions are met:
15  *
16  *      - Redistributions of source code must retain the above
17  *        copyright notice, this list of conditions and the following
18  *        disclaimer.
19  *
20  *      - Redistributions in binary form must reproduce the above
21  *        copyright notice, this list of conditions and the following
22  *        disclaimer in the documentation and/or other materials
23  *        provided with the distribution.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  * SOFTWARE.
33  *
34  * $Id: ib_user_verbs.h 2708 2005-06-24 17:27:21Z roland $
35  */
36
37 #ifndef IB_USER_VERBS_H
38 #define IB_USER_VERBS_H
39
40 #include <linux/types.h>
41
42 /*
43  * Increment this value if any changes that break userspace ABI
44  * compatibility are made.
45  */
46 #define IB_USER_VERBS_ABI_VERSION       4
47
48 enum {
49         IB_USER_VERBS_CMD_GET_CONTEXT,
50         IB_USER_VERBS_CMD_QUERY_DEVICE,
51         IB_USER_VERBS_CMD_QUERY_PORT,
52         IB_USER_VERBS_CMD_ALLOC_PD,
53         IB_USER_VERBS_CMD_DEALLOC_PD,
54         IB_USER_VERBS_CMD_CREATE_AH,
55         IB_USER_VERBS_CMD_MODIFY_AH,
56         IB_USER_VERBS_CMD_QUERY_AH,
57         IB_USER_VERBS_CMD_DESTROY_AH,
58         IB_USER_VERBS_CMD_REG_MR,
59         IB_USER_VERBS_CMD_REG_SMR,
60         IB_USER_VERBS_CMD_REREG_MR,
61         IB_USER_VERBS_CMD_QUERY_MR,
62         IB_USER_VERBS_CMD_DEREG_MR,
63         IB_USER_VERBS_CMD_ALLOC_MW,
64         IB_USER_VERBS_CMD_BIND_MW,
65         IB_USER_VERBS_CMD_DEALLOC_MW,
66         IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
67         IB_USER_VERBS_CMD_CREATE_CQ,
68         IB_USER_VERBS_CMD_RESIZE_CQ,
69         IB_USER_VERBS_CMD_DESTROY_CQ,
70         IB_USER_VERBS_CMD_POLL_CQ,
71         IB_USER_VERBS_CMD_PEEK_CQ,
72         IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
73         IB_USER_VERBS_CMD_CREATE_QP,
74         IB_USER_VERBS_CMD_QUERY_QP,
75         IB_USER_VERBS_CMD_MODIFY_QP,
76         IB_USER_VERBS_CMD_DESTROY_QP,
77         IB_USER_VERBS_CMD_POST_SEND,
78         IB_USER_VERBS_CMD_POST_RECV,
79         IB_USER_VERBS_CMD_ATTACH_MCAST,
80         IB_USER_VERBS_CMD_DETACH_MCAST,
81         IB_USER_VERBS_CMD_CREATE_SRQ,
82         IB_USER_VERBS_CMD_MODIFY_SRQ,
83         IB_USER_VERBS_CMD_QUERY_SRQ,
84         IB_USER_VERBS_CMD_DESTROY_SRQ,
85         IB_USER_VERBS_CMD_POST_SRQ_RECV
86 };
87
88 /*
89  * Make sure that all structs defined in this file remain laid out so
90  * that they pack the same way on 32-bit and 64-bit architectures (to
91  * avoid incompatibility between 32-bit userspace and 64-bit kernels).
92  * Specifically:
93  *  - Do not use pointer types -- pass pointers in __u64 instead.
94  *  - Make sure that any structure larger than 4 bytes is padded to a
95  *    multiple of 8 bytes.  Otherwise the structure size will be
96  *    different between 32-bit and 64-bit architectures.
97  */
98
99 struct ib_uverbs_async_event_desc {
100         __u64 element;
101         __u32 event_type;       /* enum ib_event_type */
102         __u32 reserved;
103 };
104
105 struct ib_uverbs_comp_event_desc {
106         __u64 cq_handle;
107 };
108
109 /*
110  * All commands from userspace should start with a __u32 command field
111  * followed by __u16 in_words and out_words fields (which give the
112  * length of the command block and response buffer if any in 32-bit
113  * words).  The kernel driver will read these fields first and read
114  * the rest of the command struct based on these value.
115  */
116
117 struct ib_uverbs_cmd_hdr {
118         __u32 command;
119         __u16 in_words;
120         __u16 out_words;
121 };
122
123 struct ib_uverbs_get_context {
124         __u64 response;
125         __u64 driver_data[0];
126 };
127
128 struct ib_uverbs_get_context_resp {
129         __u32 async_fd;
130         __u32 num_comp_vectors;
131 };
132
133 struct ib_uverbs_query_device {
134         __u64 response;
135         __u64 driver_data[0];
136 };
137
138 struct ib_uverbs_query_device_resp {
139         __u64 fw_ver;
140         __be64 node_guid;
141         __be64 sys_image_guid;
142         __u64 max_mr_size;
143         __u64 page_size_cap;
144         __u32 vendor_id;
145         __u32 vendor_part_id;
146         __u32 hw_ver;
147         __u32 max_qp;
148         __u32 max_qp_wr;
149         __u32 device_cap_flags;
150         __u32 max_sge;
151         __u32 max_sge_rd;
152         __u32 max_cq;
153         __u32 max_cqe;
154         __u32 max_mr;
155         __u32 max_pd;
156         __u32 max_qp_rd_atom;
157         __u32 max_ee_rd_atom;
158         __u32 max_res_rd_atom;
159         __u32 max_qp_init_rd_atom;
160         __u32 max_ee_init_rd_atom;
161         __u32 atomic_cap;
162         __u32 max_ee;
163         __u32 max_rdd;
164         __u32 max_mw;
165         __u32 max_raw_ipv6_qp;
166         __u32 max_raw_ethy_qp;
167         __u32 max_mcast_grp;
168         __u32 max_mcast_qp_attach;
169         __u32 max_total_mcast_qp_attach;
170         __u32 max_ah;
171         __u32 max_fmr;
172         __u32 max_map_per_fmr;
173         __u32 max_srq;
174         __u32 max_srq_wr;
175         __u32 max_srq_sge;
176         __u16 max_pkeys;
177         __u8  local_ca_ack_delay;
178         __u8  phys_port_cnt;
179         __u8  reserved[4];
180 };
181
182 struct ib_uverbs_query_port {
183         __u64 response;
184         __u8  port_num;
185         __u8  reserved[7];
186         __u64 driver_data[0];
187 };
188
189 struct ib_uverbs_query_port_resp {
190         __u32 port_cap_flags;
191         __u32 max_msg_sz;
192         __u32 bad_pkey_cntr;
193         __u32 qkey_viol_cntr;
194         __u32 gid_tbl_len;
195         __u16 pkey_tbl_len;
196         __u16 lid;
197         __u16 sm_lid;
198         __u8  state;
199         __u8  max_mtu;
200         __u8  active_mtu;
201         __u8  lmc;
202         __u8  max_vl_num;
203         __u8  sm_sl;
204         __u8  subnet_timeout;
205         __u8  init_type_reply;
206         __u8  active_width;
207         __u8  active_speed;
208         __u8  phys_state;
209         __u8  reserved[3];
210 };
211
212 struct ib_uverbs_alloc_pd {
213         __u64 response;
214         __u64 driver_data[0];
215 };
216
217 struct ib_uverbs_alloc_pd_resp {
218         __u32 pd_handle;
219 };
220
221 struct ib_uverbs_dealloc_pd {
222         __u32 pd_handle;
223 };
224
225 struct ib_uverbs_reg_mr {
226         __u64 response;
227         __u64 start;
228         __u64 length;
229         __u64 hca_va;
230         __u32 pd_handle;
231         __u32 access_flags;
232         __u64 driver_data[0];
233 };
234
235 struct ib_uverbs_reg_mr_resp {
236         __u32 mr_handle;
237         __u32 lkey;
238         __u32 rkey;
239 };
240
241 struct ib_uverbs_dereg_mr {
242         __u32 mr_handle;
243 };
244
245 struct ib_uverbs_create_comp_channel {
246         __u64 response;
247 };
248
249 struct ib_uverbs_create_comp_channel_resp {
250         __u32 fd;
251 };
252
253 struct ib_uverbs_create_cq {
254         __u64 response;
255         __u64 user_handle;
256         __u32 cqe;
257         __u32 comp_vector;
258         __s32 comp_channel;
259         __u32 reserved;
260         __u64 driver_data[0];
261 };
262
263 struct ib_uverbs_create_cq_resp {
264         __u32 cq_handle;
265         __u32 cqe;
266 };
267
268 struct ib_uverbs_resize_cq {
269         __u64 response;
270         __u32 cq_handle;
271         __u32 cqe;
272         __u64 driver_data[0];
273 };
274
275 struct ib_uverbs_resize_cq_resp {
276         __u32 cqe;
277 };
278
279 struct ib_uverbs_poll_cq {
280         __u64 response;
281         __u32 cq_handle;
282         __u32 ne;
283 };
284
285 struct ib_uverbs_wc {
286         __u64 wr_id;
287         __u32 status;
288         __u32 opcode;
289         __u32 vendor_err;
290         __u32 byte_len;
291         __u32 imm_data;
292         __u32 qp_num;
293         __u32 src_qp;
294         __u32 wc_flags;
295         __u16 pkey_index;
296         __u16 slid;
297         __u8 sl;
298         __u8 dlid_path_bits;
299         __u8 port_num;
300         __u8 reserved;
301 };
302
303 struct ib_uverbs_poll_cq_resp {
304         __u32 count;
305         __u32 reserved;
306         struct ib_uverbs_wc wc[0];
307 };
308
309 struct ib_uverbs_req_notify_cq {
310         __u32 cq_handle;
311         __u32 solicited_only;
312 };
313
314 struct ib_uverbs_destroy_cq {
315         __u64 response;
316         __u32 cq_handle;
317         __u32 reserved;
318 };
319
320 struct ib_uverbs_destroy_cq_resp {
321         __u32 comp_events_reported;
322         __u32 async_events_reported;
323 };
324
325 struct ib_uverbs_create_qp {
326         __u64 response;
327         __u64 user_handle;
328         __u32 pd_handle;
329         __u32 send_cq_handle;
330         __u32 recv_cq_handle;
331         __u32 srq_handle;
332         __u32 max_send_wr;
333         __u32 max_recv_wr;
334         __u32 max_send_sge;
335         __u32 max_recv_sge;
336         __u32 max_inline_data;
337         __u8  sq_sig_all;
338         __u8  qp_type;
339         __u8  is_srq;
340         __u8  reserved;
341         __u64 driver_data[0];
342 };
343
344 struct ib_uverbs_create_qp_resp {
345         __u32 qp_handle;
346         __u32 qpn;
347         __u32 max_send_wr;
348         __u32 max_recv_wr;
349         __u32 max_send_sge;
350         __u32 max_recv_sge;
351         __u32 max_inline_data;
352 };
353
354 /*
355  * This struct needs to remain a multiple of 8 bytes to keep the
356  * alignment of the modify QP parameters.
357  */
358 struct ib_uverbs_qp_dest {
359         __u8  dgid[16];
360         __u32 flow_label;
361         __u16 dlid;
362         __u16 reserved;
363         __u8  sgid_index;
364         __u8  hop_limit;
365         __u8  traffic_class;
366         __u8  sl;
367         __u8  src_path_bits;
368         __u8  static_rate;
369         __u8  is_global;
370         __u8  port_num;
371 };
372
373 struct ib_uverbs_modify_qp {
374         struct ib_uverbs_qp_dest dest;
375         struct ib_uverbs_qp_dest alt_dest;
376         __u32 qp_handle;
377         __u32 attr_mask;
378         __u32 qkey;
379         __u32 rq_psn;
380         __u32 sq_psn;
381         __u32 dest_qp_num;
382         __u32 qp_access_flags;
383         __u16 pkey_index;
384         __u16 alt_pkey_index;
385         __u8  qp_state;
386         __u8  cur_qp_state;
387         __u8  path_mtu;
388         __u8  path_mig_state;
389         __u8  en_sqd_async_notify;
390         __u8  max_rd_atomic;
391         __u8  max_dest_rd_atomic;
392         __u8  min_rnr_timer;
393         __u8  port_num;
394         __u8  timeout;
395         __u8  retry_cnt;
396         __u8  rnr_retry;
397         __u8  alt_port_num;
398         __u8  alt_timeout;
399         __u8  reserved[2];
400         __u64 driver_data[0];
401 };
402
403 struct ib_uverbs_modify_qp_resp {
404 };
405
406 struct ib_uverbs_destroy_qp {
407         __u64 response;
408         __u32 qp_handle;
409         __u32 reserved;
410 };
411
412 struct ib_uverbs_destroy_qp_resp {
413         __u32 events_reported;
414 };
415
416 /*
417  * The ib_uverbs_sge structure isn't used anywhere, since we assume
418  * the ib_sge structure is packed the same way on 32-bit and 64-bit
419  * architectures in both kernel and user space.  It's just here to
420  * document the ABI.
421  */
422 struct ib_uverbs_sge {
423         __u64 addr;
424         __u32 length;
425         __u32 lkey;
426 };
427
428 struct ib_uverbs_send_wr {
429         __u64 wr_id;
430         __u32 num_sge;
431         __u32 opcode;
432         __u32 send_flags;
433         __u32 imm_data;
434         union {
435                 struct {
436                         __u64 remote_addr;
437                         __u32 rkey;
438                         __u32 reserved;
439                 } rdma;
440                 struct {
441                         __u64 remote_addr;
442                         __u64 compare_add;
443                         __u64 swap;
444                         __u32 rkey;
445                         __u32 reserved;
446                 } atomic;
447                 struct {
448                         __u32 ah;
449                         __u32 remote_qpn;
450                         __u32 remote_qkey;
451                         __u32 reserved;
452                 } ud;
453         } wr;
454 };
455
456 struct ib_uverbs_post_send {
457         __u64 response;
458         __u32 qp_handle;
459         __u32 wr_count;
460         __u32 sge_count;
461         __u32 wqe_size;
462         struct ib_uverbs_send_wr send_wr[0];
463 };
464
465 struct ib_uverbs_post_send_resp {
466         __u32 bad_wr;
467 };
468
469 struct ib_uverbs_recv_wr {
470         __u64 wr_id;
471         __u32 num_sge;
472         __u32 reserved;
473 };
474
475 struct ib_uverbs_post_recv {
476         __u64 response;
477         __u32 qp_handle;
478         __u32 wr_count;
479         __u32 sge_count;
480         __u32 wqe_size;
481         struct ib_uverbs_recv_wr recv_wr[0];
482 };
483
484 struct ib_uverbs_post_recv_resp {
485         __u32 bad_wr;
486 };
487
488 struct ib_uverbs_post_srq_recv {
489         __u64 response;
490         __u32 srq_handle;
491         __u32 wr_count;
492         __u32 sge_count;
493         __u32 wqe_size;
494         struct ib_uverbs_recv_wr recv[0];
495 };
496
497 struct ib_uverbs_post_srq_recv_resp {
498         __u32 bad_wr;
499 };
500
501 struct ib_uverbs_global_route {
502         __u8  dgid[16];
503         __u32 flow_label;
504         __u8  sgid_index;
505         __u8  hop_limit;
506         __u8  traffic_class;
507         __u8  reserved;
508 };
509
510 struct ib_uverbs_ah_attr {
511         struct ib_uverbs_global_route grh;
512         __u16 dlid;
513         __u8  sl;
514         __u8  src_path_bits;
515         __u8  static_rate;
516         __u8  is_global;
517         __u8  port_num;
518         __u8  reserved;
519 };
520
521 struct ib_uverbs_create_ah {
522         __u64 response;
523         __u64 user_handle;
524         __u32 pd_handle;
525         __u32 reserved;
526         struct ib_uverbs_ah_attr attr;
527 };
528
529 struct ib_uverbs_create_ah_resp {
530         __u32 ah_handle;
531 };
532
533 struct ib_uverbs_destroy_ah {
534         __u32 ah_handle;
535 };
536
537 struct ib_uverbs_attach_mcast {
538         __u8  gid[16];
539         __u32 qp_handle;
540         __u16 mlid;
541         __u16 reserved;
542         __u64 driver_data[0];
543 };
544
545 struct ib_uverbs_detach_mcast {
546         __u8  gid[16];
547         __u32 qp_handle;
548         __u16 mlid;
549         __u16 reserved;
550         __u64 driver_data[0];
551 };
552
553 struct ib_uverbs_create_srq {
554         __u64 response;
555         __u64 user_handle;
556         __u32 pd_handle;
557         __u32 max_wr;
558         __u32 max_sge;
559         __u32 srq_limit;
560         __u64 driver_data[0];
561 };
562
563 struct ib_uverbs_create_srq_resp {
564         __u32 srq_handle;
565 };
566
567 struct ib_uverbs_modify_srq {
568         __u32 srq_handle;
569         __u32 attr_mask;
570         __u32 max_wr;
571         __u32 srq_limit;
572         __u64 driver_data[0];
573 };
574
575 struct ib_uverbs_destroy_srq {
576         __u64 response;
577         __u32 srq_handle;
578         __u32 reserved;
579 };
580
581 struct ib_uverbs_destroy_srq_resp {
582         __u32 events_reported;
583 };
584
585 #endif /* IB_USER_VERBS_H */