Merge branch 'master'
[pandora-kernel.git] / 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  * 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_poll_cq {
269         __u64 response;
270         __u32 cq_handle;
271         __u32 ne;
272 };
273
274 struct ib_uverbs_wc {
275         __u64 wr_id;
276         __u32 status;
277         __u32 opcode;
278         __u32 vendor_err;
279         __u32 byte_len;
280         __u32 imm_data;
281         __u32 qp_num;
282         __u32 src_qp;
283         __u32 wc_flags;
284         __u16 pkey_index;
285         __u16 slid;
286         __u8 sl;
287         __u8 dlid_path_bits;
288         __u8 port_num;
289         __u8 reserved;
290 };
291
292 struct ib_uverbs_poll_cq_resp {
293         __u32 count;
294         __u32 reserved;
295         struct ib_uverbs_wc wc[0];
296 };
297
298 struct ib_uverbs_req_notify_cq {
299         __u32 cq_handle;
300         __u32 solicited_only;
301 };
302
303 struct ib_uverbs_destroy_cq {
304         __u64 response;
305         __u32 cq_handle;
306         __u32 reserved;
307 };
308
309 struct ib_uverbs_destroy_cq_resp {
310         __u32 comp_events_reported;
311         __u32 async_events_reported;
312 };
313
314 struct ib_uverbs_create_qp {
315         __u64 response;
316         __u64 user_handle;
317         __u32 pd_handle;
318         __u32 send_cq_handle;
319         __u32 recv_cq_handle;
320         __u32 srq_handle;
321         __u32 max_send_wr;
322         __u32 max_recv_wr;
323         __u32 max_send_sge;
324         __u32 max_recv_sge;
325         __u32 max_inline_data;
326         __u8  sq_sig_all;
327         __u8  qp_type;
328         __u8  is_srq;
329         __u8  reserved;
330         __u64 driver_data[0];
331 };
332
333 struct ib_uverbs_create_qp_resp {
334         __u32 qp_handle;
335         __u32 qpn;
336         __u32 max_send_wr;
337         __u32 max_recv_wr;
338         __u32 max_send_sge;
339         __u32 max_recv_sge;
340         __u32 max_inline_data;
341 };
342
343 /*
344  * This struct needs to remain a multiple of 8 bytes to keep the
345  * alignment of the modify QP parameters.
346  */
347 struct ib_uverbs_qp_dest {
348         __u8  dgid[16];
349         __u32 flow_label;
350         __u16 dlid;
351         __u16 reserved;
352         __u8  sgid_index;
353         __u8  hop_limit;
354         __u8  traffic_class;
355         __u8  sl;
356         __u8  src_path_bits;
357         __u8  static_rate;
358         __u8  is_global;
359         __u8  port_num;
360 };
361
362 struct ib_uverbs_modify_qp {
363         struct ib_uverbs_qp_dest dest;
364         struct ib_uverbs_qp_dest alt_dest;
365         __u32 qp_handle;
366         __u32 attr_mask;
367         __u32 qkey;
368         __u32 rq_psn;
369         __u32 sq_psn;
370         __u32 dest_qp_num;
371         __u32 qp_access_flags;
372         __u16 pkey_index;
373         __u16 alt_pkey_index;
374         __u8  qp_state;
375         __u8  cur_qp_state;
376         __u8  path_mtu;
377         __u8  path_mig_state;
378         __u8  en_sqd_async_notify;
379         __u8  max_rd_atomic;
380         __u8  max_dest_rd_atomic;
381         __u8  min_rnr_timer;
382         __u8  port_num;
383         __u8  timeout;
384         __u8  retry_cnt;
385         __u8  rnr_retry;
386         __u8  alt_port_num;
387         __u8  alt_timeout;
388         __u8  reserved[2];
389         __u64 driver_data[0];
390 };
391
392 struct ib_uverbs_modify_qp_resp {
393 };
394
395 struct ib_uverbs_destroy_qp {
396         __u64 response;
397         __u32 qp_handle;
398         __u32 reserved;
399 };
400
401 struct ib_uverbs_destroy_qp_resp {
402         __u32 events_reported;
403 };
404
405 /*
406  * The ib_uverbs_sge structure isn't used anywhere, since we assume
407  * the ib_sge structure is packed the same way on 32-bit and 64-bit
408  * architectures in both kernel and user space.  It's just here to
409  * document the ABI.
410  */
411 struct ib_uverbs_sge {
412         __u64 addr;
413         __u32 length;
414         __u32 lkey;
415 };
416
417 struct ib_uverbs_send_wr {
418         __u64 wr_id; 
419         __u32 num_sge;
420         __u32 opcode;
421         __u32 send_flags;
422         __u32 imm_data;
423         union {
424                 struct {
425                         __u64 remote_addr;
426                         __u32 rkey;
427                         __u32 reserved;
428                 } rdma;
429                 struct {
430                         __u64 remote_addr;
431                         __u64 compare_add;
432                         __u64 swap;
433                         __u32 rkey;
434                         __u32 reserved;
435                 } atomic;
436                 struct {
437                         __u32 ah;
438                         __u32 remote_qpn;
439                         __u32 remote_qkey;
440                         __u32 reserved;
441                 } ud;
442         } wr;
443 };
444
445 struct ib_uverbs_post_send {
446         __u64 response;
447         __u32 qp_handle;
448         __u32 wr_count;
449         __u32 sge_count;
450         __u32 wqe_size;
451         struct ib_uverbs_send_wr send_wr[0];
452 };
453
454 struct ib_uverbs_post_send_resp {
455         __u32 bad_wr;
456 };
457
458 struct ib_uverbs_recv_wr {
459         __u64 wr_id;
460         __u32 num_sge;
461         __u32 reserved;
462 };
463
464 struct ib_uverbs_post_recv {
465         __u64 response;
466         __u32 qp_handle;
467         __u32 wr_count;
468         __u32 sge_count;
469         __u32 wqe_size;
470         struct ib_uverbs_recv_wr recv_wr[0];
471 };
472
473 struct ib_uverbs_post_recv_resp {
474         __u32 bad_wr;
475 };
476
477 struct ib_uverbs_post_srq_recv {
478         __u64 response;
479         __u32 srq_handle;
480         __u32 wr_count;
481         __u32 sge_count;
482         __u32 wqe_size;
483         struct ib_uverbs_recv_wr recv[0];
484 };
485
486 struct ib_uverbs_post_srq_recv_resp {
487         __u32 bad_wr;
488 };
489
490 struct ib_uverbs_global_route {
491         __u8  dgid[16];
492         __u32 flow_label;    
493         __u8  sgid_index;
494         __u8  hop_limit;
495         __u8  traffic_class;
496         __u8  reserved;
497 };
498
499 struct ib_uverbs_ah_attr {
500         struct ib_uverbs_global_route grh;
501         __u16 dlid;
502         __u8  sl;
503         __u8  src_path_bits;
504         __u8  static_rate;
505         __u8  is_global;
506         __u8  port_num;
507         __u8  reserved;
508 };
509
510 struct ib_uverbs_create_ah {
511         __u64 response;
512         __u64 user_handle;
513         __u32 pd_handle;
514         __u32 reserved;
515         struct ib_uverbs_ah_attr attr;
516 };
517
518 struct ib_uverbs_create_ah_resp {
519         __u32 ah_handle;
520 };
521
522 struct ib_uverbs_destroy_ah {
523         __u32 ah_handle;
524 };
525
526 struct ib_uverbs_attach_mcast {
527         __u8  gid[16];
528         __u32 qp_handle;
529         __u16 mlid;
530         __u16 reserved;
531         __u64 driver_data[0];
532 };
533
534 struct ib_uverbs_detach_mcast {
535         __u8  gid[16];
536         __u32 qp_handle;
537         __u16 mlid;
538         __u16 reserved;
539         __u64 driver_data[0];
540 };
541
542 struct ib_uverbs_create_srq {
543         __u64 response;
544         __u64 user_handle;
545         __u32 pd_handle;
546         __u32 max_wr;
547         __u32 max_sge;
548         __u32 srq_limit;
549         __u64 driver_data[0];
550 };
551
552 struct ib_uverbs_create_srq_resp {
553         __u32 srq_handle;
554 };
555
556 struct ib_uverbs_modify_srq {
557         __u32 srq_handle;
558         __u32 attr_mask;
559         __u32 max_wr;
560         __u32 srq_limit;
561         __u64 driver_data[0];
562 };
563
564 struct ib_uverbs_destroy_srq {
565         __u64 response;
566         __u32 srq_handle;
567         __u32 reserved;
568 };
569
570 struct ib_uverbs_destroy_srq_resp {
571         __u32 events_reported;
572 };
573
574 #endif /* IB_USER_VERBS_H */