nfsd: track last inode only in use_wgather case
[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, 2006 Cisco Systems.  All rights reserved.
4  * Copyright (c) 2005 PathScale, Inc.  All rights reserved.
5  * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.
6  *
7  * This software is available to you under a choice of one of two
8  * licenses.  You may choose to be licensed under the terms of the GNU
9  * General Public License (GPL) Version 2, available from the file
10  * COPYING in the main directory of this source tree, or the
11  * OpenIB.org BSD license below:
12  *
13  *     Redistribution and use in source and binary forms, with or
14  *     without modification, are permitted provided that the following
15  *     conditions are met:
16  *
17  *      - Redistributions of source code must retain the above
18  *        copyright notice, this list of conditions and the following
19  *        disclaimer.
20  *
21  *      - Redistributions in binary form must reproduce the above
22  *        copyright notice, this list of conditions and the following
23  *        disclaimer in the documentation and/or other materials
24  *        provided with the distribution.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33  * SOFTWARE.
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       6
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  * Specifically:
92  *  - Do not use pointer types -- pass pointers in __u64 instead.
93  *  - Make sure that any structure larger than 4 bytes is padded to a
94  *    multiple of 8 bytes.  Otherwise the structure size will be
95  *    different between 32-bit and 64-bit architectures.
96  */
97
98 struct ib_uverbs_async_event_desc {
99         __u64 element;
100         __u32 event_type;       /* enum ib_event_type */
101         __u32 reserved;
102 };
103
104 struct ib_uverbs_comp_event_desc {
105         __u64 cq_handle;
106 };
107
108 /*
109  * All commands from userspace should start with a __u32 command field
110  * followed by __u16 in_words and out_words fields (which give the
111  * length of the command block and response buffer if any in 32-bit
112  * words).  The kernel driver will read these fields first and read
113  * the rest of the command struct based on these value.
114  */
115
116 struct ib_uverbs_cmd_hdr {
117         __u32 command;
118         __u16 in_words;
119         __u16 out_words;
120 };
121
122 struct ib_uverbs_get_context {
123         __u64 response;
124         __u64 driver_data[0];
125 };
126
127 struct ib_uverbs_get_context_resp {
128         __u32 async_fd;
129         __u32 num_comp_vectors;
130 };
131
132 struct ib_uverbs_query_device {
133         __u64 response;
134         __u64 driver_data[0];
135 };
136
137 struct ib_uverbs_query_device_resp {
138         __u64 fw_ver;
139         __be64 node_guid;
140         __be64 sys_image_guid;
141         __u64 max_mr_size;
142         __u64 page_size_cap;
143         __u32 vendor_id;
144         __u32 vendor_part_id;
145         __u32 hw_ver;
146         __u32 max_qp;
147         __u32 max_qp_wr;
148         __u32 device_cap_flags;
149         __u32 max_sge;
150         __u32 max_sge_rd;
151         __u32 max_cq;
152         __u32 max_cqe;
153         __u32 max_mr;
154         __u32 max_pd;
155         __u32 max_qp_rd_atom;
156         __u32 max_ee_rd_atom;
157         __u32 max_res_rd_atom;
158         __u32 max_qp_init_rd_atom;
159         __u32 max_ee_init_rd_atom;
160         __u32 atomic_cap;
161         __u32 max_ee;
162         __u32 max_rdd;
163         __u32 max_mw;
164         __u32 max_raw_ipv6_qp;
165         __u32 max_raw_ethy_qp;
166         __u32 max_mcast_grp;
167         __u32 max_mcast_qp_attach;
168         __u32 max_total_mcast_qp_attach;
169         __u32 max_ah;
170         __u32 max_fmr;
171         __u32 max_map_per_fmr;
172         __u32 max_srq;
173         __u32 max_srq_wr;
174         __u32 max_srq_sge;
175         __u16 max_pkeys;
176         __u8  local_ca_ack_delay;
177         __u8  phys_port_cnt;
178         __u8  reserved[4];
179 };
180
181 struct ib_uverbs_query_port {
182         __u64 response;
183         __u8  port_num;
184         __u8  reserved[7];
185         __u64 driver_data[0];
186 };
187
188 struct ib_uverbs_query_port_resp {
189         __u32 port_cap_flags;
190         __u32 max_msg_sz;
191         __u32 bad_pkey_cntr;
192         __u32 qkey_viol_cntr;
193         __u32 gid_tbl_len;
194         __u16 pkey_tbl_len;
195         __u16 lid;
196         __u16 sm_lid;
197         __u8  state;
198         __u8  max_mtu;
199         __u8  active_mtu;
200         __u8  lmc;
201         __u8  max_vl_num;
202         __u8  sm_sl;
203         __u8  subnet_timeout;
204         __u8  init_type_reply;
205         __u8  active_width;
206         __u8  active_speed;
207         __u8  phys_state;
208         __u8  reserved[3];
209 };
210
211 struct ib_uverbs_alloc_pd {
212         __u64 response;
213         __u64 driver_data[0];
214 };
215
216 struct ib_uverbs_alloc_pd_resp {
217         __u32 pd_handle;
218 };
219
220 struct ib_uverbs_dealloc_pd {
221         __u32 pd_handle;
222 };
223
224 struct ib_uverbs_reg_mr {
225         __u64 response;
226         __u64 start;
227         __u64 length;
228         __u64 hca_va;
229         __u32 pd_handle;
230         __u32 access_flags;
231         __u64 driver_data[0];
232 };
233
234 struct ib_uverbs_reg_mr_resp {
235         __u32 mr_handle;
236         __u32 lkey;
237         __u32 rkey;
238 };
239
240 struct ib_uverbs_dereg_mr {
241         __u32 mr_handle;
242 };
243
244 struct ib_uverbs_create_comp_channel {
245         __u64 response;
246 };
247
248 struct ib_uverbs_create_comp_channel_resp {
249         __u32 fd;
250 };
251
252 struct ib_uverbs_create_cq {
253         __u64 response;
254         __u64 user_handle;
255         __u32 cqe;
256         __u32 comp_vector;
257         __s32 comp_channel;
258         __u32 reserved;
259         __u64 driver_data[0];
260 };
261
262 struct ib_uverbs_create_cq_resp {
263         __u32 cq_handle;
264         __u32 cqe;
265 };
266
267 struct ib_uverbs_resize_cq {
268         __u64 response;
269         __u32 cq_handle;
270         __u32 cqe;
271         __u64 driver_data[0];
272 };
273
274 struct ib_uverbs_resize_cq_resp {
275         __u32 cqe;
276         __u32 reserved;
277         __u64 driver_data[0];
278 };
279
280 struct ib_uverbs_poll_cq {
281         __u64 response;
282         __u32 cq_handle;
283         __u32 ne;
284 };
285
286 struct ib_uverbs_wc {
287         __u64 wr_id;
288         __u32 status;
289         __u32 opcode;
290         __u32 vendor_err;
291         __u32 byte_len;
292         union {
293                 __u32 imm_data;
294                 __u32 invalidate_rkey;
295         } ex;
296         __u32 qp_num;
297         __u32 src_qp;
298         __u32 wc_flags;
299         __u16 pkey_index;
300         __u16 slid;
301         __u8 sl;
302         __u8 dlid_path_bits;
303         __u8 port_num;
304         __u8 reserved;
305 };
306
307 struct ib_uverbs_poll_cq_resp {
308         __u32 count;
309         __u32 reserved;
310         struct ib_uverbs_wc wc[0];
311 };
312
313 struct ib_uverbs_req_notify_cq {
314         __u32 cq_handle;
315         __u32 solicited_only;
316 };
317
318 struct ib_uverbs_destroy_cq {
319         __u64 response;
320         __u32 cq_handle;
321         __u32 reserved;
322 };
323
324 struct ib_uverbs_destroy_cq_resp {
325         __u32 comp_events_reported;
326         __u32 async_events_reported;
327 };
328
329 struct ib_uverbs_global_route {
330         __u8  dgid[16];
331         __u32 flow_label;
332         __u8  sgid_index;
333         __u8  hop_limit;
334         __u8  traffic_class;
335         __u8  reserved;
336 };
337
338 struct ib_uverbs_ah_attr {
339         struct ib_uverbs_global_route grh;
340         __u16 dlid;
341         __u8  sl;
342         __u8  src_path_bits;
343         __u8  static_rate;
344         __u8  is_global;
345         __u8  port_num;
346         __u8  reserved;
347 };
348
349 struct ib_uverbs_qp_attr {
350         __u32   qp_attr_mask;
351         __u32   qp_state;
352         __u32   cur_qp_state;
353         __u32   path_mtu;
354         __u32   path_mig_state;
355         __u32   qkey;
356         __u32   rq_psn;
357         __u32   sq_psn;
358         __u32   dest_qp_num;
359         __u32   qp_access_flags;
360
361         struct ib_uverbs_ah_attr ah_attr;
362         struct ib_uverbs_ah_attr alt_ah_attr;
363
364         /* ib_qp_cap */
365         __u32   max_send_wr;
366         __u32   max_recv_wr;
367         __u32   max_send_sge;
368         __u32   max_recv_sge;
369         __u32   max_inline_data;
370
371         __u16   pkey_index;
372         __u16   alt_pkey_index;
373         __u8    en_sqd_async_notify;
374         __u8    sq_draining;
375         __u8    max_rd_atomic;
376         __u8    max_dest_rd_atomic;
377         __u8    min_rnr_timer;
378         __u8    port_num;
379         __u8    timeout;
380         __u8    retry_cnt;
381         __u8    rnr_retry;
382         __u8    alt_port_num;
383         __u8    alt_timeout;
384         __u8    reserved[5];
385 };
386
387 struct ib_uverbs_create_qp {
388         __u64 response;
389         __u64 user_handle;
390         __u32 pd_handle;
391         __u32 send_cq_handle;
392         __u32 recv_cq_handle;
393         __u32 srq_handle;
394         __u32 max_send_wr;
395         __u32 max_recv_wr;
396         __u32 max_send_sge;
397         __u32 max_recv_sge;
398         __u32 max_inline_data;
399         __u8  sq_sig_all;
400         __u8  qp_type;
401         __u8  is_srq;
402         __u8  reserved;
403         __u64 driver_data[0];
404 };
405
406 struct ib_uverbs_create_qp_resp {
407         __u32 qp_handle;
408         __u32 qpn;
409         __u32 max_send_wr;
410         __u32 max_recv_wr;
411         __u32 max_send_sge;
412         __u32 max_recv_sge;
413         __u32 max_inline_data;
414         __u32 reserved;
415 };
416
417 /*
418  * This struct needs to remain a multiple of 8 bytes to keep the
419  * alignment of the modify QP parameters.
420  */
421 struct ib_uverbs_qp_dest {
422         __u8  dgid[16];
423         __u32 flow_label;
424         __u16 dlid;
425         __u16 reserved;
426         __u8  sgid_index;
427         __u8  hop_limit;
428         __u8  traffic_class;
429         __u8  sl;
430         __u8  src_path_bits;
431         __u8  static_rate;
432         __u8  is_global;
433         __u8  port_num;
434 };
435
436 struct ib_uverbs_query_qp {
437         __u64 response;
438         __u32 qp_handle;
439         __u32 attr_mask;
440         __u64 driver_data[0];
441 };
442
443 struct ib_uverbs_query_qp_resp {
444         struct ib_uverbs_qp_dest dest;
445         struct ib_uverbs_qp_dest alt_dest;
446         __u32 max_send_wr;
447         __u32 max_recv_wr;
448         __u32 max_send_sge;
449         __u32 max_recv_sge;
450         __u32 max_inline_data;
451         __u32 qkey;
452         __u32 rq_psn;
453         __u32 sq_psn;
454         __u32 dest_qp_num;
455         __u32 qp_access_flags;
456         __u16 pkey_index;
457         __u16 alt_pkey_index;
458         __u8  qp_state;
459         __u8  cur_qp_state;
460         __u8  path_mtu;
461         __u8  path_mig_state;
462         __u8  sq_draining;
463         __u8  max_rd_atomic;
464         __u8  max_dest_rd_atomic;
465         __u8  min_rnr_timer;
466         __u8  port_num;
467         __u8  timeout;
468         __u8  retry_cnt;
469         __u8  rnr_retry;
470         __u8  alt_port_num;
471         __u8  alt_timeout;
472         __u8  sq_sig_all;
473         __u8  reserved[5];
474         __u64 driver_data[0];
475 };
476
477 struct ib_uverbs_modify_qp {
478         struct ib_uverbs_qp_dest dest;
479         struct ib_uverbs_qp_dest alt_dest;
480         __u32 qp_handle;
481         __u32 attr_mask;
482         __u32 qkey;
483         __u32 rq_psn;
484         __u32 sq_psn;
485         __u32 dest_qp_num;
486         __u32 qp_access_flags;
487         __u16 pkey_index;
488         __u16 alt_pkey_index;
489         __u8  qp_state;
490         __u8  cur_qp_state;
491         __u8  path_mtu;
492         __u8  path_mig_state;
493         __u8  en_sqd_async_notify;
494         __u8  max_rd_atomic;
495         __u8  max_dest_rd_atomic;
496         __u8  min_rnr_timer;
497         __u8  port_num;
498         __u8  timeout;
499         __u8  retry_cnt;
500         __u8  rnr_retry;
501         __u8  alt_port_num;
502         __u8  alt_timeout;
503         __u8  reserved[2];
504         __u64 driver_data[0];
505 };
506
507 struct ib_uverbs_modify_qp_resp {
508 };
509
510 struct ib_uverbs_destroy_qp {
511         __u64 response;
512         __u32 qp_handle;
513         __u32 reserved;
514 };
515
516 struct ib_uverbs_destroy_qp_resp {
517         __u32 events_reported;
518 };
519
520 /*
521  * The ib_uverbs_sge structure isn't used anywhere, since we assume
522  * the ib_sge structure is packed the same way on 32-bit and 64-bit
523  * architectures in both kernel and user space.  It's just here to
524  * document the ABI.
525  */
526 struct ib_uverbs_sge {
527         __u64 addr;
528         __u32 length;
529         __u32 lkey;
530 };
531
532 struct ib_uverbs_send_wr {
533         __u64 wr_id;
534         __u32 num_sge;
535         __u32 opcode;
536         __u32 send_flags;
537         union {
538                 __u32 imm_data;
539                 __u32 invalidate_rkey;
540         } ex;
541         union {
542                 struct {
543                         __u64 remote_addr;
544                         __u32 rkey;
545                         __u32 reserved;
546                 } rdma;
547                 struct {
548                         __u64 remote_addr;
549                         __u64 compare_add;
550                         __u64 swap;
551                         __u32 rkey;
552                         __u32 reserved;
553                 } atomic;
554                 struct {
555                         __u32 ah;
556                         __u32 remote_qpn;
557                         __u32 remote_qkey;
558                         __u32 reserved;
559                 } ud;
560         } wr;
561 };
562
563 struct ib_uverbs_post_send {
564         __u64 response;
565         __u32 qp_handle;
566         __u32 wr_count;
567         __u32 sge_count;
568         __u32 wqe_size;
569         struct ib_uverbs_send_wr send_wr[0];
570 };
571
572 struct ib_uverbs_post_send_resp {
573         __u32 bad_wr;
574 };
575
576 struct ib_uverbs_recv_wr {
577         __u64 wr_id;
578         __u32 num_sge;
579         __u32 reserved;
580 };
581
582 struct ib_uverbs_post_recv {
583         __u64 response;
584         __u32 qp_handle;
585         __u32 wr_count;
586         __u32 sge_count;
587         __u32 wqe_size;
588         struct ib_uverbs_recv_wr recv_wr[0];
589 };
590
591 struct ib_uverbs_post_recv_resp {
592         __u32 bad_wr;
593 };
594
595 struct ib_uverbs_post_srq_recv {
596         __u64 response;
597         __u32 srq_handle;
598         __u32 wr_count;
599         __u32 sge_count;
600         __u32 wqe_size;
601         struct ib_uverbs_recv_wr recv[0];
602 };
603
604 struct ib_uverbs_post_srq_recv_resp {
605         __u32 bad_wr;
606 };
607
608 struct ib_uverbs_create_ah {
609         __u64 response;
610         __u64 user_handle;
611         __u32 pd_handle;
612         __u32 reserved;
613         struct ib_uverbs_ah_attr attr;
614 };
615
616 struct ib_uverbs_create_ah_resp {
617         __u32 ah_handle;
618 };
619
620 struct ib_uverbs_destroy_ah {
621         __u32 ah_handle;
622 };
623
624 struct ib_uverbs_attach_mcast {
625         __u8  gid[16];
626         __u32 qp_handle;
627         __u16 mlid;
628         __u16 reserved;
629         __u64 driver_data[0];
630 };
631
632 struct ib_uverbs_detach_mcast {
633         __u8  gid[16];
634         __u32 qp_handle;
635         __u16 mlid;
636         __u16 reserved;
637         __u64 driver_data[0];
638 };
639
640 struct ib_uverbs_create_srq {
641         __u64 response;
642         __u64 user_handle;
643         __u32 pd_handle;
644         __u32 max_wr;
645         __u32 max_sge;
646         __u32 srq_limit;
647         __u64 driver_data[0];
648 };
649
650 struct ib_uverbs_create_srq_resp {
651         __u32 srq_handle;
652         __u32 max_wr;
653         __u32 max_sge;
654         __u32 reserved;
655 };
656
657 struct ib_uverbs_modify_srq {
658         __u32 srq_handle;
659         __u32 attr_mask;
660         __u32 max_wr;
661         __u32 srq_limit;
662         __u64 driver_data[0];
663 };
664
665 struct ib_uverbs_query_srq {
666         __u64 response;
667         __u32 srq_handle;
668         __u32 reserved;
669         __u64 driver_data[0];
670 };
671
672 struct ib_uverbs_query_srq_resp {
673         __u32 max_wr;
674         __u32 max_sge;
675         __u32 srq_limit;
676         __u32 reserved;
677 };
678
679 struct ib_uverbs_destroy_srq {
680         __u64 response;
681         __u32 srq_handle;
682         __u32 reserved;
683 };
684
685 struct ib_uverbs_destroy_srq_resp {
686         __u32 events_reported;
687 };
688
689 #endif /* IB_USER_VERBS_H */