]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/contrib/rdma/ib_user_verbs.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / contrib / 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  * $Id: ib_user_verbs.h 4019 2005-11-11 00:33:09Z sean.hefty $
36  *
37  * $FreeBSD$
38  */
39
40 #ifndef IB_USER_VERBS_H
41 #define IB_USER_VERBS_H
42
43 #include <contrib/rdma/types.h>
44
45
46 /*
47  * Increment this value if any changes that break userspace ABI
48  * compatibility are made.
49  */
50 #define IB_USER_VERBS_ABI_VERSION       6
51
52 enum {
53         IB_USER_VERBS_CMD_GET_CONTEXT,
54         IB_USER_VERBS_CMD_QUERY_DEVICE,
55         IB_USER_VERBS_CMD_QUERY_PORT,
56         IB_USER_VERBS_CMD_ALLOC_PD,
57         IB_USER_VERBS_CMD_DEALLOC_PD,
58         IB_USER_VERBS_CMD_CREATE_AH,
59         IB_USER_VERBS_CMD_MODIFY_AH,
60         IB_USER_VERBS_CMD_QUERY_AH,
61         IB_USER_VERBS_CMD_DESTROY_AH,
62         IB_USER_VERBS_CMD_REG_MR,
63         IB_USER_VERBS_CMD_REG_SMR,
64         IB_USER_VERBS_CMD_REREG_MR,
65         IB_USER_VERBS_CMD_QUERY_MR,
66         IB_USER_VERBS_CMD_DEREG_MR,
67         IB_USER_VERBS_CMD_ALLOC_MW,
68         IB_USER_VERBS_CMD_BIND_MW,
69         IB_USER_VERBS_CMD_DEALLOC_MW,
70         IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
71         IB_USER_VERBS_CMD_CREATE_CQ,
72         IB_USER_VERBS_CMD_RESIZE_CQ,
73         IB_USER_VERBS_CMD_DESTROY_CQ,
74         IB_USER_VERBS_CMD_POLL_CQ,
75         IB_USER_VERBS_CMD_PEEK_CQ,
76         IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
77         IB_USER_VERBS_CMD_CREATE_QP,
78         IB_USER_VERBS_CMD_QUERY_QP,
79         IB_USER_VERBS_CMD_MODIFY_QP,
80         IB_USER_VERBS_CMD_DESTROY_QP,
81         IB_USER_VERBS_CMD_POST_SEND,
82         IB_USER_VERBS_CMD_POST_RECV,
83         IB_USER_VERBS_CMD_ATTACH_MCAST,
84         IB_USER_VERBS_CMD_DETACH_MCAST,
85         IB_USER_VERBS_CMD_CREATE_SRQ,
86         IB_USER_VERBS_CMD_MODIFY_SRQ,
87         IB_USER_VERBS_CMD_QUERY_SRQ,
88         IB_USER_VERBS_CMD_DESTROY_SRQ,
89         IB_USER_VERBS_CMD_POST_SRQ_RECV
90 };
91
92 /*
93  * Make sure that all structs defined in this file remain laid out so
94  * that they pack the same way on 32-bit and 64-bit architectures (to
95  * avoid incompatibility between 32-bit userspace and 64-bit kernels).
96  * Specifically:
97  *  - Do not use pointer types -- pass pointers in __u64 instead.
98  *  - Make sure that any structure larger than 4 bytes is padded to a
99  *    multiple of 8 bytes.  Otherwise the structure size will be
100  *    different between 32-bit and 64-bit architectures.
101  */
102
103 struct ib_uverbs_async_event_desc {
104         __u64 element;
105         __u32 event_type;       /* enum ib_event_type */
106         __u32 reserved;
107 };
108
109 struct ib_uverbs_comp_event_desc {
110         __u64 cq_handle;
111 };
112
113 /*
114  * All commands from userspace should start with a __u32 command field
115  * followed by __u16 in_words and out_words fields (which give the
116  * length of the command block and response buffer if any in 32-bit
117  * words).  The kernel driver will read these fields first and read
118  * the rest of the command struct based on these value.
119  */
120
121 struct ib_uverbs_cmd_hdr {
122         __u32 command;
123         __u16 in_words;
124         __u16 out_words;
125 };
126
127 struct ib_uverbs_get_context {
128         __u64 response;
129         __u64 driver_data[0];
130 };
131
132 struct ib_uverbs_get_context_resp {
133         __u32 async_fd;
134         __u32 num_comp_vectors;
135 };
136
137 struct ib_uverbs_query_device {
138         __u64 response;
139         __u64 driver_data[0];
140 };
141
142 struct ib_uverbs_query_device_resp {
143         __u64 fw_ver;
144         __be64 node_guid;
145         __be64 sys_image_guid;
146         __u64 max_mr_size;
147         __u64 page_size_cap;
148         __u32 vendor_id;
149         __u32 vendor_part_id;
150         __u32 hw_ver;
151         __u32 max_qp;
152         __u32 max_qp_wr;
153         __u32 device_cap_flags;
154         __u32 max_sge;
155         __u32 max_sge_rd;
156         __u32 max_cq;
157         __u32 max_cqe;
158         __u32 max_mr;
159         __u32 max_pd;
160         __u32 max_qp_rd_atom;
161         __u32 max_ee_rd_atom;
162         __u32 max_res_rd_atom;
163         __u32 max_qp_init_rd_atom;
164         __u32 max_ee_init_rd_atom;
165         __u32 atomic_cap;
166         __u32 max_ee;
167         __u32 max_rdd;
168         __u32 max_mw;
169         __u32 max_raw_ipv6_qp;
170         __u32 max_raw_ethy_qp;
171         __u32 max_mcast_grp;
172         __u32 max_mcast_qp_attach;
173         __u32 max_total_mcast_qp_attach;
174         __u32 max_ah;
175         __u32 max_fmr;
176         __u32 max_map_per_fmr;
177         __u32 max_srq;
178         __u32 max_srq_wr;
179         __u32 max_srq_sge;
180         __u16 max_pkeys;
181         __u8  local_ca_ack_delay;
182         __u8  phys_port_cnt;
183         __u8  reserved[4];
184 };
185
186 struct ib_uverbs_query_port {
187         __u64 response;
188         __u8  port_num;
189         __u8  reserved[7];
190         __u64 driver_data[0];
191 };
192
193 struct ib_uverbs_query_port_resp {
194         __u32 port_cap_flags;
195         __u32 max_msg_sz;
196         __u32 bad_pkey_cntr;
197         __u32 qkey_viol_cntr;
198         __u32 gid_tbl_len;
199         __u16 pkey_tbl_len;
200         __u16 lid;
201         __u16 sm_lid;
202         __u8  state;
203         __u8  max_mtu;
204         __u8  active_mtu;
205         __u8  lmc;
206         __u8  max_vl_num;
207         __u8  sm_sl;
208         __u8  subnet_timeout;
209         __u8  init_type_reply;
210         __u8  active_width;
211         __u8  active_speed;
212         __u8  phys_state;
213         __u8  reserved[3];
214 };
215
216 struct ib_uverbs_alloc_pd {
217         __u64 response;
218         __u64 driver_data[0];
219 };
220
221 struct ib_uverbs_alloc_pd_resp {
222         __u32 pd_handle;
223 };
224
225 struct ib_uverbs_dealloc_pd {
226         __u32 pd_handle;
227 };
228
229 struct ib_uverbs_reg_mr {
230         __u64 response;
231         __u64 start;
232         __u64 length;
233         __u64 hca_va;
234         __u32 pd_handle;
235         __u32 access_flags;
236         __u64 driver_data[0];
237 };
238
239 struct ib_uverbs_reg_mr_resp {
240         __u32 mr_handle;
241         __u32 lkey;
242         __u32 rkey;
243 };
244
245 struct ib_uverbs_dereg_mr {
246         __u32 mr_handle;
247 };
248
249 struct ib_uverbs_create_comp_channel {
250         __u64 response;
251 };
252
253 struct ib_uverbs_create_comp_channel_resp {
254         __u32 fd;
255 };
256
257 struct ib_uverbs_create_cq {
258         __u64 response;
259         __u64 user_handle;
260         __u32 cqe;
261         __u32 comp_vector;
262         __s32 comp_channel;
263         __u32 reserved;
264         __u64 driver_data[0];
265 };
266
267 struct ib_uverbs_create_cq_resp {
268         __u32 cq_handle;
269         __u32 cqe;
270 };
271
272 struct ib_uverbs_resize_cq {
273         __u64 response;
274         __u32 cq_handle;
275         __u32 cqe;
276         __u64 driver_data[0];
277 };
278
279 struct ib_uverbs_resize_cq_resp {
280         __u32 cqe;
281         __u32 reserved;
282         __u64 driver_data[0];
283 };
284
285 struct ib_uverbs_poll_cq {
286         __u64 response;
287         __u32 cq_handle;
288         __u32 ne;
289 };
290
291 struct ib_uverbs_wc {
292         __u64 wr_id;
293         __u32 status;
294         __u32 opcode;
295         __u32 vendor_err;
296         __u32 byte_len;
297         __u32 imm_data;
298         __u32 qp_num;
299         __u32 src_qp;
300         __u32 wc_flags;
301         __u16 pkey_index;
302         __u16 slid;
303         __u8 sl;
304         __u8 dlid_path_bits;
305         __u8 port_num;
306         __u8 reserved;
307 };
308
309 struct ib_uverbs_poll_cq_resp {
310         __u32 count;
311         __u32 reserved;
312         struct ib_uverbs_wc wc[0];
313 };
314
315 struct ib_uverbs_req_notify_cq {
316         __u32 cq_handle;
317         __u32 solicited_only;
318 };
319
320 struct ib_uverbs_destroy_cq {
321         __u64 response;
322         __u32 cq_handle;
323         __u32 reserved;
324 };
325
326 struct ib_uverbs_destroy_cq_resp {
327         __u32 comp_events_reported;
328         __u32 async_events_reported;
329 };
330
331 struct ib_uverbs_global_route {
332         __u8  dgid[16];
333         __u32 flow_label;
334         __u8  sgid_index;
335         __u8  hop_limit;
336         __u8  traffic_class;
337         __u8  reserved;
338 };
339
340 struct ib_uverbs_ah_attr {
341         struct ib_uverbs_global_route grh;
342         __u16 dlid;
343         __u8  sl;
344         __u8  src_path_bits;
345         __u8  static_rate;
346         __u8  is_global;
347         __u8  port_num;
348         __u8  reserved;
349 };
350
351 struct ib_uverbs_qp_attr {
352         __u32   qp_attr_mask;
353         __u32   qp_state;
354         __u32   cur_qp_state;
355         __u32   path_mtu;
356         __u32   path_mig_state;
357         __u32   qkey;
358         __u32   rq_psn;
359         __u32   sq_psn;
360         __u32   dest_qp_num;
361         __u32   qp_access_flags;
362
363         struct ib_uverbs_ah_attr ah_attr;
364         struct ib_uverbs_ah_attr alt_ah_attr;
365
366         /* ib_qp_cap */
367         __u32   max_send_wr;
368         __u32   max_recv_wr;
369         __u32   max_send_sge;
370         __u32   max_recv_sge;
371         __u32   max_inline_data;
372
373         __u16   pkey_index;
374         __u16   alt_pkey_index;
375         __u8    en_sqd_async_notify;
376         __u8    sq_draining;
377         __u8    max_rd_atomic;
378         __u8    max_dest_rd_atomic;
379         __u8    min_rnr_timer;
380         __u8    port_num;
381         __u8    timeout;
382         __u8    retry_cnt;
383         __u8    rnr_retry;
384         __u8    alt_port_num;
385         __u8    alt_timeout;
386         __u8    reserved[5];
387 };
388
389 struct ib_uverbs_create_qp {
390         __u64 response;
391         __u64 user_handle;
392         __u32 pd_handle;
393         __u32 send_cq_handle;
394         __u32 recv_cq_handle;
395         __u32 srq_handle;
396         __u32 max_send_wr;
397         __u32 max_recv_wr;
398         __u32 max_send_sge;
399         __u32 max_recv_sge;
400         __u32 max_inline_data;
401         __u8  sq_sig_all;
402         __u8  qp_type;
403         __u8  is_srq;
404         __u8  reserved;
405         __u64 driver_data[0];
406 };
407
408 struct ib_uverbs_create_qp_resp {
409         __u32 qp_handle;
410         __u32 qpn;
411         __u32 max_send_wr;
412         __u32 max_recv_wr;
413         __u32 max_send_sge;
414         __u32 max_recv_sge;
415         __u32 max_inline_data;
416         __u32 reserved;
417 };
418
419 /*
420  * This struct needs to remain a multiple of 8 bytes to keep the
421  * alignment of the modify QP parameters.
422  */
423 struct ib_uverbs_qp_dest {
424         __u8  dgid[16];
425         __u32 flow_label;
426         __u16 dlid;
427         __u16 reserved;
428         __u8  sgid_index;
429         __u8  hop_limit;
430         __u8  traffic_class;
431         __u8  sl;
432         __u8  src_path_bits;
433         __u8  static_rate;
434         __u8  is_global;
435         __u8  port_num;
436 };
437
438 struct ib_uverbs_query_qp {
439         __u64 response;
440         __u32 qp_handle;
441         __u32 attr_mask;
442         __u64 driver_data[0];
443 };
444
445 struct ib_uverbs_query_qp_resp {
446         struct ib_uverbs_qp_dest dest;
447         struct ib_uverbs_qp_dest alt_dest;
448         __u32 max_send_wr;
449         __u32 max_recv_wr;
450         __u32 max_send_sge;
451         __u32 max_recv_sge;
452         __u32 max_inline_data;
453         __u32 qkey;
454         __u32 rq_psn;
455         __u32 sq_psn;
456         __u32 dest_qp_num;
457         __u32 qp_access_flags;
458         __u16 pkey_index;
459         __u16 alt_pkey_index;
460         __u8  qp_state;
461         __u8  cur_qp_state;
462         __u8  path_mtu;
463         __u8  path_mig_state;
464         __u8  sq_draining;
465         __u8  max_rd_atomic;
466         __u8  max_dest_rd_atomic;
467         __u8  min_rnr_timer;
468         __u8  port_num;
469         __u8  timeout;
470         __u8  retry_cnt;
471         __u8  rnr_retry;
472         __u8  alt_port_num;
473         __u8  alt_timeout;
474         __u8  sq_sig_all;
475         __u8  reserved[5];
476         __u64 driver_data[0];
477 };
478
479 struct ib_uverbs_modify_qp {
480         struct ib_uverbs_qp_dest dest;
481         struct ib_uverbs_qp_dest alt_dest;
482         __u32 qp_handle;
483         __u32 attr_mask;
484         __u32 qkey;
485         __u32 rq_psn;
486         __u32 sq_psn;
487         __u32 dest_qp_num;
488         __u32 qp_access_flags;
489         __u16 pkey_index;
490         __u16 alt_pkey_index;
491         __u8  qp_state;
492         __u8  cur_qp_state;
493         __u8  path_mtu;
494         __u8  path_mig_state;
495         __u8  en_sqd_async_notify;
496         __u8  max_rd_atomic;
497         __u8  max_dest_rd_atomic;
498         __u8  min_rnr_timer;
499         __u8  port_num;
500         __u8  timeout;
501         __u8  retry_cnt;
502         __u8  rnr_retry;
503         __u8  alt_port_num;
504         __u8  alt_timeout;
505         __u8  reserved[2];
506         __u64 driver_data[0];
507 };
508
509 struct ib_uverbs_modify_qp_resp {
510 };
511
512 struct ib_uverbs_destroy_qp {
513         __u64 response;
514         __u32 qp_handle;
515         __u32 reserved;
516 };
517
518 struct ib_uverbs_destroy_qp_resp {
519         __u32 events_reported;
520 };
521
522 /*
523  * The ib_uverbs_sge structure isn't used anywhere, since we assume
524  * the ib_sge structure is packed the same way on 32-bit and 64-bit
525  * architectures in both kernel and user space.  It's just here to
526  * document the ABI.
527  */
528 struct ib_uverbs_sge {
529         __u64 addr;
530         __u32 length;
531         __u32 lkey;
532 };
533
534 struct ib_uverbs_send_wr {
535         __u64 wr_id;
536         __u32 num_sge;
537         __u32 opcode;
538         __u32 send_flags;
539         __u32 imm_data;
540         union {
541                 struct {
542                         __u64 remote_addr;
543                         __u32 rkey;
544                         __u32 reserved;
545                 } rdma;
546                 struct {
547                         __u64 remote_addr;
548                         __u64 compare_add;
549                         __u64 swap;
550                         __u32 rkey;
551                         __u32 reserved;
552                 } atomic;
553                 struct {
554                         __u32 ah;
555                         __u32 remote_qpn;
556                         __u32 remote_qkey;
557                         __u32 reserved;
558                 } ud;
559         } wr;
560 };
561
562 struct ib_uverbs_post_send {
563         __u64 response;
564         __u32 qp_handle;
565         __u32 wr_count;
566         __u32 sge_count;
567         __u32 wqe_size;
568         struct ib_uverbs_send_wr send_wr[0];
569 };
570
571 struct ib_uverbs_post_send_resp {
572         __u32 bad_wr;
573 };
574
575 struct ib_uverbs_recv_wr {
576         __u64 wr_id;
577         __u32 num_sge;
578         __u32 reserved;
579 };
580
581 struct ib_uverbs_post_recv {
582         __u64 response;
583         __u32 qp_handle;
584         __u32 wr_count;
585         __u32 sge_count;
586         __u32 wqe_size;
587         struct ib_uverbs_recv_wr recv_wr[0];
588 };
589
590 struct ib_uverbs_post_recv_resp {
591         __u32 bad_wr;
592 };
593
594 struct ib_uverbs_post_srq_recv {
595         __u64 response;
596         __u32 srq_handle;
597         __u32 wr_count;
598         __u32 sge_count;
599         __u32 wqe_size;
600         struct ib_uverbs_recv_wr recv[0];
601 };
602
603 struct ib_uverbs_post_srq_recv_resp {
604         __u32 bad_wr;
605 };
606
607 struct ib_uverbs_create_ah {
608         __u64 response;
609         __u64 user_handle;
610         __u32 pd_handle;
611         __u32 reserved;
612         struct ib_uverbs_ah_attr attr;
613 };
614
615 struct ib_uverbs_create_ah_resp {
616         __u32 ah_handle;
617 };
618
619 struct ib_uverbs_destroy_ah {
620         __u32 ah_handle;
621 };
622
623 struct ib_uverbs_attach_mcast {
624         __u8  gid[16];
625         __u32 qp_handle;
626         __u16 mlid;
627         __u16 reserved;
628         __u64 driver_data[0];
629 };
630
631 struct ib_uverbs_detach_mcast {
632         __u8  gid[16];
633         __u32 qp_handle;
634         __u16 mlid;
635         __u16 reserved;
636         __u64 driver_data[0];
637 };
638
639 struct ib_uverbs_create_srq {
640         __u64 response;
641         __u64 user_handle;
642         __u32 pd_handle;
643         __u32 max_wr;
644         __u32 max_sge;
645         __u32 srq_limit;
646         __u64 driver_data[0];
647 };
648
649 struct ib_uverbs_create_srq_resp {
650         __u32 srq_handle;
651         __u32 max_wr;
652         __u32 max_sge;
653         __u32 reserved;
654 };
655
656 struct ib_uverbs_modify_srq {
657         __u32 srq_handle;
658         __u32 attr_mask;
659         __u32 max_wr;
660         __u32 srq_limit;
661         __u64 driver_data[0];
662 };
663
664 struct ib_uverbs_query_srq {
665         __u64 response;
666         __u32 srq_handle;
667         __u32 reserved;
668         __u64 driver_data[0];
669 };
670
671 struct ib_uverbs_query_srq_resp {
672         __u32 max_wr;
673         __u32 max_sge;
674         __u32 srq_limit;
675         __u32 reserved;
676 };
677
678 struct ib_uverbs_destroy_srq {
679         __u64 response;
680         __u32 srq_handle;
681         __u32 reserved;
682 };
683
684 struct ib_uverbs_destroy_srq_resp {
685         __u32 events_reported;
686 };
687
688 #endif /* IB_USER_VERBS_H */