]> nv-tegra.nvidia Code Review - linux-3.10.git/blob - include/rdma/ib_user_verbs.h
[IB] uverbs: Add ABI structures for more commands
[linux-3.10.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       3
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 };
337
338 /*
339  * This struct needs to remain a multiple of 8 bytes to keep the
340  * alignment of the modify QP parameters.
341  */
342 struct ib_uverbs_qp_dest {
343         __u8  dgid[16];
344         __u32 flow_label;
345         __u16 dlid;
346         __u16 reserved;
347         __u8  sgid_index;
348         __u8  hop_limit;
349         __u8  traffic_class;
350         __u8  sl;
351         __u8  src_path_bits;
352         __u8  static_rate;
353         __u8  is_global;
354         __u8  port_num;
355 };
356
357 struct ib_uverbs_modify_qp {
358         struct ib_uverbs_qp_dest dest;
359         struct ib_uverbs_qp_dest alt_dest;
360         __u32 qp_handle;
361         __u32 attr_mask;
362         __u32 qkey;
363         __u32 rq_psn;
364         __u32 sq_psn;
365         __u32 dest_qp_num;
366         __u32 qp_access_flags;
367         __u16 pkey_index;
368         __u16 alt_pkey_index;
369         __u8  qp_state;
370         __u8  cur_qp_state;
371         __u8  path_mtu;
372         __u8  path_mig_state;
373         __u8  en_sqd_async_notify;
374         __u8  max_rd_atomic;
375         __u8  max_dest_rd_atomic;
376         __u8  min_rnr_timer;
377         __u8  port_num;
378         __u8  timeout;
379         __u8  retry_cnt;
380         __u8  rnr_retry;
381         __u8  alt_port_num;
382         __u8  alt_timeout;
383         __u8  reserved[2];
384         __u64 driver_data[0];
385 };
386
387 struct ib_uverbs_modify_qp_resp {
388 };
389
390 struct ib_uverbs_destroy_qp {
391         __u64 response;
392         __u32 qp_handle;
393         __u32 reserved;
394 };
395
396 struct ib_uverbs_destroy_qp_resp {
397         __u32 events_reported;
398 };
399
400 /*
401  * The ib_uverbs_sge structure isn't used anywhere, since we assume
402  * the ib_sge structure is packed the same way on 32-bit and 64-bit
403  * architectures in both kernel and user space.  It's just here to
404  * document the ABI.
405  */
406 struct ib_uverbs_sge {
407         __u64 addr;
408         __u32 length;
409         __u32 lkey;
410 };
411
412 struct ib_uverbs_send_wr {
413         __u64 wr_id; 
414         __u32 num_sge;
415         __u32 opcode;
416         __u32 send_flags;
417         __u32 imm_data;
418         union {
419                 struct {
420                         __u64 remote_addr;
421                         __u32 rkey;
422                         __u32 reserved;
423                 } rdma;
424                 struct {
425                         __u64 remote_addr;
426                         __u64 compare_add;
427                         __u64 swap;
428                         __u32 rkey;
429                         __u32 reserved;
430                 } atomic;
431                 struct {
432                         __u32 ah;
433                         __u32 remote_qpn;
434                         __u32 remote_qkey;
435                         __u32 reserved;
436                 } ud;
437         } wr;
438 };
439
440 struct ib_uverbs_post_send {
441         __u64 response;
442         __u32 qp_handle;
443         __u32 wr_count;
444         __u32 sge_count;
445         __u32 wqe_size;
446         struct ib_uverbs_send_wr send_wr[0];
447 };
448
449 struct ib_uverbs_post_send_resp {
450         __u32 bad_wr;
451 };
452
453 struct ib_uverbs_recv_wr {
454         __u64 wr_id;
455         __u32 num_sge;
456         __u32 reserved;
457 };
458
459 struct ib_uverbs_post_recv {
460         __u64 response;
461         __u32 qp_handle;
462         __u32 wr_count;
463         __u32 sge_count;
464         __u32 wqe_size;
465         struct ib_uverbs_recv_wr recv_wr[0];
466 };
467
468 struct ib_uverbs_post_recv_resp {
469         __u32 bad_wr;
470 };
471
472 struct ib_uverbs_post_srq_recv {
473         __u64 response;
474         __u32 srq_handle;
475         __u32 wr_count;
476         __u32 sge_count;
477         __u32 wqe_size;
478         struct ib_uverbs_recv_wr recv[0];
479 };
480
481 struct ib_uverbs_post_srq_recv_resp {
482         __u32 bad_wr;
483 };
484
485 struct ib_uverbs_global_route {
486         __u8  dgid[16];
487         __u32 flow_label;    
488         __u8  sgid_index;
489         __u8  hop_limit;
490         __u8  traffic_class;
491         __u8  reserved;
492 };
493
494 struct ib_uverbs_ah_attr {
495         struct ib_uverbs_global_route grh;
496         __u16 dlid;
497         __u8  sl;
498         __u8  src_path_bits;
499         __u8  static_rate;
500         __u8  is_global;
501         __u8  port_num;
502         __u8  reserved;
503 };
504
505 struct ib_uverbs_create_ah {
506         __u64 response;
507         __u64 user_handle;
508         __u32 pd_handle;
509         __u32 reserved;
510         struct ib_uverbs_ah_attr attr;
511 };
512
513 struct ib_uverbs_create_ah_resp {
514         __u32 ah_handle;
515 };
516
517 struct ib_uverbs_destroy_ah {
518         __u32 ah_handle;
519 };
520
521 struct ib_uverbs_attach_mcast {
522         __u8  gid[16];
523         __u32 qp_handle;
524         __u16 mlid;
525         __u16 reserved;
526         __u64 driver_data[0];
527 };
528
529 struct ib_uverbs_detach_mcast {
530         __u8  gid[16];
531         __u32 qp_handle;
532         __u16 mlid;
533         __u16 reserved;
534         __u64 driver_data[0];
535 };
536
537 struct ib_uverbs_create_srq {
538         __u64 response;
539         __u64 user_handle;
540         __u32 pd_handle;
541         __u32 max_wr;
542         __u32 max_sge;
543         __u32 srq_limit;
544         __u64 driver_data[0];
545 };
546
547 struct ib_uverbs_create_srq_resp {
548         __u32 srq_handle;
549 };
550
551 struct ib_uverbs_modify_srq {
552         __u32 srq_handle;
553         __u32 attr_mask;
554         __u32 max_wr;
555         __u32 max_sge;
556         __u32 srq_limit;
557         __u32 reserved;
558         __u64 driver_data[0];
559 };
560
561 struct ib_uverbs_destroy_srq {
562         __u64 response;
563         __u32 srq_handle;
564         __u32 reserved;
565 };
566
567 struct ib_uverbs_destroy_srq_resp {
568         __u32 events_reported;
569 };
570
571 #endif /* IB_USER_VERBS_H */