885254f20bb361edcc93f5f15b56d9f96c48480f
[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         __u32 imm_data;
293         __u32 qp_num;
294         __u32 src_qp;
295         __u32 wc_flags;
296         __u16 pkey_index;
297         __u16 slid;
298         __u8 sl;
299         __u8 dlid_path_bits;
300         __u8 port_num;
301         __u8 reserved;
302 };
303
304 struct ib_uverbs_poll_cq_resp {
305         __u32 count;
306         __u32 reserved;
307         struct ib_uverbs_wc wc[0];
308 };
309
310 struct ib_uverbs_req_notify_cq {
311         __u32 cq_handle;
312         __u32 solicited_only;
313 };
314
315 struct ib_uverbs_destroy_cq {
316         __u64 response;
317         __u32 cq_handle;
318         __u32 reserved;
319 };
320
321 struct ib_uverbs_destroy_cq_resp {
322         __u32 comp_events_reported;
323         __u32 async_events_reported;
324 };
325
326 struct ib_uverbs_global_route {
327         __u8  dgid[16];
328         __u32 flow_label;
329         __u8  sgid_index;
330         __u8  hop_limit;
331         __u8  traffic_class;
332         __u8  reserved;
333 };
334
335 struct ib_uverbs_ah_attr {
336         struct ib_uverbs_global_route grh;
337         __u16 dlid;
338         __u8  sl;
339         __u8  src_path_bits;
340         __u8  static_rate;
341         __u8  is_global;
342         __u8  port_num;
343         __u8  reserved;
344 };
345
346 struct ib_uverbs_qp_attr {
347         __u32   qp_attr_mask;
348         __u32   qp_state;
349         __u32   cur_qp_state;
350         __u32   path_mtu;
351         __u32   path_mig_state;
352         __u32   qkey;
353         __u32   rq_psn;
354         __u32   sq_psn;
355         __u32   dest_qp_num;
356         __u32   qp_access_flags;
357
358         struct ib_uverbs_ah_attr ah_attr;
359         struct ib_uverbs_ah_attr alt_ah_attr;
360
361         /* ib_qp_cap */
362         __u32   max_send_wr;
363         __u32   max_recv_wr;
364         __u32   max_send_sge;
365         __u32   max_recv_sge;
366         __u32   max_inline_data;
367
368         __u16   pkey_index;
369         __u16   alt_pkey_index;
370         __u8    en_sqd_async_notify;
371         __u8    sq_draining;
372         __u8    max_rd_atomic;
373         __u8    max_dest_rd_atomic;
374         __u8    min_rnr_timer;
375         __u8    port_num;
376         __u8    timeout;
377         __u8    retry_cnt;
378         __u8    rnr_retry;
379         __u8    alt_port_num;
380         __u8    alt_timeout;
381         __u8    reserved[5];
382 };
383
384 struct ib_uverbs_create_qp {
385         __u64 response;
386         __u64 user_handle;
387         __u32 pd_handle;
388         __u32 send_cq_handle;
389         __u32 recv_cq_handle;
390         __u32 srq_handle;
391         __u32 max_send_wr;
392         __u32 max_recv_wr;
393         __u32 max_send_sge;
394         __u32 max_recv_sge;
395         __u32 max_inline_data;
396         __u8  sq_sig_all;
397         __u8  qp_type;
398         __u8  is_srq;
399         __u8  reserved;
400         __u64 driver_data[0];
401 };
402
403 struct ib_uverbs_create_qp_resp {
404         __u32 qp_handle;
405         __u32 qpn;
406         __u32 max_send_wr;
407         __u32 max_recv_wr;
408         __u32 max_send_sge;
409         __u32 max_recv_sge;
410         __u32 max_inline_data;
411         __u32 reserved;
412 };
413
414 /*
415  * This struct needs to remain a multiple of 8 bytes to keep the
416  * alignment of the modify QP parameters.
417  */
418 struct ib_uverbs_qp_dest {
419         __u8  dgid[16];
420         __u32 flow_label;
421         __u16 dlid;
422         __u16 reserved;
423         __u8  sgid_index;
424         __u8  hop_limit;
425         __u8  traffic_class;
426         __u8  sl;
427         __u8  src_path_bits;
428         __u8  static_rate;
429         __u8  is_global;
430         __u8  port_num;
431 };
432
433 struct ib_uverbs_query_qp {
434         __u64 response;
435         __u32 qp_handle;
436         __u32 attr_mask;
437         __u64 driver_data[0];
438 };
439
440 struct ib_uverbs_query_qp_resp {
441         struct ib_uverbs_qp_dest dest;
442         struct ib_uverbs_qp_dest alt_dest;
443         __u32 max_send_wr;
444         __u32 max_recv_wr;
445         __u32 max_send_sge;
446         __u32 max_recv_sge;
447         __u32 max_inline_data;
448         __u32 qkey;
449         __u32 rq_psn;
450         __u32 sq_psn;
451         __u32 dest_qp_num;
452         __u32 qp_access_flags;
453         __u16 pkey_index;
454         __u16 alt_pkey_index;
455         __u8  qp_state;
456         __u8  cur_qp_state;
457         __u8  path_mtu;
458         __u8  path_mig_state;
459         __u8  sq_draining;
460         __u8  max_rd_atomic;
461         __u8  max_dest_rd_atomic;
462         __u8  min_rnr_timer;
463         __u8  port_num;
464         __u8  timeout;
465         __u8  retry_cnt;
466         __u8  rnr_retry;
467         __u8  alt_port_num;
468         __u8  alt_timeout;
469         __u8  sq_sig_all;
470         __u8  reserved[5];
471         __u64 driver_data[0];
472 };
473
474 struct ib_uverbs_modify_qp {
475         struct ib_uverbs_qp_dest dest;
476         struct ib_uverbs_qp_dest alt_dest;
477         __u32 qp_handle;
478         __u32 attr_mask;
479         __u32 qkey;
480         __u32 rq_psn;
481         __u32 sq_psn;
482         __u32 dest_qp_num;
483         __u32 qp_access_flags;
484         __u16 pkey_index;
485         __u16 alt_pkey_index;
486         __u8  qp_state;
487         __u8  cur_qp_state;
488         __u8  path_mtu;
489         __u8  path_mig_state;
490         __u8  en_sqd_async_notify;
491         __u8  max_rd_atomic;
492         __u8  max_dest_rd_atomic;
493         __u8  min_rnr_timer;
494         __u8  port_num;
495         __u8  timeout;
496         __u8  retry_cnt;
497         __u8  rnr_retry;
498         __u8  alt_port_num;
499         __u8  alt_timeout;
500         __u8  reserved[2];
501         __u64 driver_data[0];
502 };
503
504 struct ib_uverbs_modify_qp_resp {
505 };
506
507 struct ib_uverbs_destroy_qp {
508         __u64 response;
509         __u32 qp_handle;
510         __u32 reserved;
511 };
512
513 struct ib_uverbs_destroy_qp_resp {
514         __u32 events_reported;
515 };
516
517 /*
518  * The ib_uverbs_sge structure isn't used anywhere, since we assume
519  * the ib_sge structure is packed the same way on 32-bit and 64-bit
520  * architectures in both kernel and user space.  It's just here to
521  * document the ABI.
522  */
523 struct ib_uverbs_sge {
524         __u64 addr;
525         __u32 length;
526         __u32 lkey;
527 };
528
529 struct ib_uverbs_send_wr {
530         __u64 wr_id;
531         __u32 num_sge;
532         __u32 opcode;
533         __u32 send_flags;
534         union {
535                 __u32 imm_data;
536                 __u32 invalidate_rkey;
537         } ex;
538         union {
539                 struct {
540                         __u64 remote_addr;
541                         __u32 rkey;
542                         __u32 reserved;
543                 } rdma;
544                 struct {
545                         __u64 remote_addr;
546                         __u64 compare_add;
547                         __u64 swap;
548                         __u32 rkey;
549                         __u32 reserved;
550                 } atomic;
551                 struct {
552                         __u32 ah;
553                         __u32 remote_qpn;
554                         __u32 remote_qkey;
555                         __u32 reserved;
556                 } ud;
557         } wr;
558 };
559
560 struct ib_uverbs_post_send {
561         __u64 response;
562         __u32 qp_handle;
563         __u32 wr_count;
564         __u32 sge_count;
565         __u32 wqe_size;
566         struct ib_uverbs_send_wr send_wr[0];
567 };
568
569 struct ib_uverbs_post_send_resp {
570         __u32 bad_wr;
571 };
572
573 struct ib_uverbs_recv_wr {
574         __u64 wr_id;
575         __u32 num_sge;
576         __u32 reserved;
577 };
578
579 struct ib_uverbs_post_recv {
580         __u64 response;
581         __u32 qp_handle;
582         __u32 wr_count;
583         __u32 sge_count;
584         __u32 wqe_size;
585         struct ib_uverbs_recv_wr recv_wr[0];
586 };
587
588 struct ib_uverbs_post_recv_resp {
589         __u32 bad_wr;
590 };
591
592 struct ib_uverbs_post_srq_recv {
593         __u64 response;
594         __u32 srq_handle;
595         __u32 wr_count;
596         __u32 sge_count;
597         __u32 wqe_size;
598         struct ib_uverbs_recv_wr recv[0];
599 };
600
601 struct ib_uverbs_post_srq_recv_resp {
602         __u32 bad_wr;
603 };
604
605 struct ib_uverbs_create_ah {
606         __u64 response;
607         __u64 user_handle;
608         __u32 pd_handle;
609         __u32 reserved;
610         struct ib_uverbs_ah_attr attr;
611 };
612
613 struct ib_uverbs_create_ah_resp {
614         __u32 ah_handle;
615 };
616
617 struct ib_uverbs_destroy_ah {
618         __u32 ah_handle;
619 };
620
621 struct ib_uverbs_attach_mcast {
622         __u8  gid[16];
623         __u32 qp_handle;
624         __u16 mlid;
625         __u16 reserved;
626         __u64 driver_data[0];
627 };
628
629 struct ib_uverbs_detach_mcast {
630         __u8  gid[16];
631         __u32 qp_handle;
632         __u16 mlid;
633         __u16 reserved;
634         __u64 driver_data[0];
635 };
636
637 struct ib_uverbs_create_srq {
638         __u64 response;
639         __u64 user_handle;
640         __u32 pd_handle;
641         __u32 max_wr;
642         __u32 max_sge;
643         __u32 srq_limit;
644         __u64 driver_data[0];
645 };
646
647 struct ib_uverbs_create_srq_resp {
648         __u32 srq_handle;
649         __u32 max_wr;
650         __u32 max_sge;
651         __u32 reserved;
652 };
653
654 struct ib_uverbs_modify_srq {
655         __u32 srq_handle;
656         __u32 attr_mask;
657         __u32 max_wr;
658         __u32 srq_limit;
659         __u64 driver_data[0];
660 };
661
662 struct ib_uverbs_query_srq {
663         __u64 response;
664         __u32 srq_handle;
665         __u32 reserved;
666         __u64 driver_data[0];
667 };
668
669 struct ib_uverbs_query_srq_resp {
670         __u32 max_wr;
671         __u32 max_sge;
672         __u32 srq_limit;
673         __u32 reserved;
674 };
675
676 struct ib_uverbs_destroy_srq {
677         __u64 response;
678         __u32 srq_handle;
679         __u32 reserved;
680 };
681
682 struct ib_uverbs_destroy_srq_resp {
683         __u32 events_reported;
684 };
685
686 #endif /* IB_USER_VERBS_H */