blob: 58662c34a3de80df463300a8be0ce2e0df723653 [file] [log] [blame]
Roland Dreier8a96b3f2005-07-07 17:57:12 -07001/*
2 * Copyright (c) 2005 Topspin Communications. All rights reserved.
Roland Dreier33b9b3e2006-01-30 14:29:21 -08003 * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
Roland Dreier91ecd4a2005-10-14 15:21:44 -07004 * Copyright (c) 2005 PathScale, Inc. All rights reserved.
Roland Dreier8a96b3f2005-07-07 17:57:12 -07005 *
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 */
Jack Morgenstein77369ed2005-11-09 11:26:07 -080046#define IB_USER_VERBS_ABI_VERSION 4
Roland Dreier8a96b3f2005-07-07 17:57:12 -070047
48enum {
Roland Dreier8a96b3f2005-07-07 17:57:12 -070049 IB_USER_VERBS_CMD_GET_CONTEXT,
50 IB_USER_VERBS_CMD_QUERY_DEVICE,
51 IB_USER_VERBS_CMD_QUERY_PORT,
Roland Dreier8a96b3f2005-07-07 17:57:12 -070052 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,
Roland Dreier6b73597e2005-09-26 13:53:25 -070066 IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
Roland Dreier8a96b3f2005-07-07 17:57:12 -070067 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,
Roland Dreierf520ba52005-08-18 12:24:13 -070080 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
Roland Dreier8a96b3f2005-07-07 17:57:12 -070086};
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).
Roland Dreier91ecd4a2005-10-14 15:21:44 -070092 * 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.
Roland Dreier8a96b3f2005-07-07 17:57:12 -070097 */
98
99struct ib_uverbs_async_event_desc {
100 __u64 element;
101 __u32 event_type; /* enum ib_event_type */
102 __u32 reserved;
103};
104
105struct 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
117struct ib_uverbs_cmd_hdr {
118 __u32 command;
119 __u16 in_words;
120 __u16 out_words;
121};
122
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700123struct ib_uverbs_get_context {
124 __u64 response;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700125 __u64 driver_data[0];
126};
127
128struct ib_uverbs_get_context_resp {
129 __u32 async_fd;
Roland Dreier6b73597e2005-09-26 13:53:25 -0700130 __u32 num_comp_vectors;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700131};
132
133struct ib_uverbs_query_device {
134 __u64 response;
135 __u64 driver_data[0];
136};
137
138struct ib_uverbs_query_device_resp {
139 __u64 fw_ver;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700140 __be64 node_guid;
141 __be64 sys_image_guid;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700142 __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
182struct ib_uverbs_query_port {
183 __u64 response;
184 __u8 port_num;
185 __u8 reserved[7];
186 __u64 driver_data[0];
187};
188
189struct 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
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700212struct ib_uverbs_alloc_pd {
213 __u64 response;
214 __u64 driver_data[0];
215};
216
217struct ib_uverbs_alloc_pd_resp {
218 __u32 pd_handle;
219};
220
221struct ib_uverbs_dealloc_pd {
222 __u32 pd_handle;
223};
224
225struct 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
235struct ib_uverbs_reg_mr_resp {
236 __u32 mr_handle;
237 __u32 lkey;
238 __u32 rkey;
239};
240
241struct ib_uverbs_dereg_mr {
242 __u32 mr_handle;
243};
244
Roland Dreier6b73597e2005-09-26 13:53:25 -0700245struct ib_uverbs_create_comp_channel {
246 __u64 response;
247};
248
249struct ib_uverbs_create_comp_channel_resp {
250 __u32 fd;
251};
252
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700253struct ib_uverbs_create_cq {
254 __u64 response;
255 __u64 user_handle;
256 __u32 cqe;
Roland Dreier6b73597e2005-09-26 13:53:25 -0700257 __u32 comp_vector;
258 __s32 comp_channel;
259 __u32 reserved;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700260 __u64 driver_data[0];
261};
262
263struct ib_uverbs_create_cq_resp {
264 __u32 cq_handle;
265 __u32 cqe;
266};
267
Roland Dreier33b9b3e2006-01-30 14:29:21 -0800268struct ib_uverbs_resize_cq {
269 __u64 response;
270 __u32 cq_handle;
271 __u32 cqe;
272 __u64 driver_data[0];
273};
274
275struct ib_uverbs_resize_cq_resp {
276 __u32 cqe;
277};
278
Roland Dreier91ecd4a2005-10-14 15:21:44 -0700279struct ib_uverbs_poll_cq {
280 __u64 response;
281 __u32 cq_handle;
282 __u32 ne;
283};
284
285struct ib_uverbs_wc {
286 __u64 wr_id;
287 __u32 status;
288 __u32 opcode;
289 __u32 vendor_err;
290 __u32 byte_len;
291 __u32 imm_data;
292 __u32 qp_num;
293 __u32 src_qp;
294 __u32 wc_flags;
295 __u16 pkey_index;
296 __u16 slid;
297 __u8 sl;
298 __u8 dlid_path_bits;
299 __u8 port_num;
300 __u8 reserved;
301};
302
303struct ib_uverbs_poll_cq_resp {
304 __u32 count;
305 __u32 reserved;
306 struct ib_uverbs_wc wc[0];
307};
308
309struct ib_uverbs_req_notify_cq {
310 __u32 cq_handle;
311 __u32 solicited_only;
312};
313
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700314struct ib_uverbs_destroy_cq {
Roland Dreier63aaf642005-09-09 15:55:08 -0700315 __u64 response;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700316 __u32 cq_handle;
Roland Dreier63aaf642005-09-09 15:55:08 -0700317 __u32 reserved;
318};
319
320struct ib_uverbs_destroy_cq_resp {
321 __u32 comp_events_reported;
322 __u32 async_events_reported;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700323};
324
325struct ib_uverbs_create_qp {
326 __u64 response;
327 __u64 user_handle;
328 __u32 pd_handle;
329 __u32 send_cq_handle;
330 __u32 recv_cq_handle;
331 __u32 srq_handle;
332 __u32 max_send_wr;
333 __u32 max_recv_wr;
334 __u32 max_send_sge;
335 __u32 max_recv_sge;
336 __u32 max_inline_data;
337 __u8 sq_sig_all;
338 __u8 qp_type;
339 __u8 is_srq;
340 __u8 reserved;
341 __u64 driver_data[0];
342};
343
344struct ib_uverbs_create_qp_resp {
345 __u32 qp_handle;
346 __u32 qpn;
Jack Morgenstein77369ed2005-11-09 11:26:07 -0800347 __u32 max_send_wr;
348 __u32 max_recv_wr;
349 __u32 max_send_sge;
350 __u32 max_recv_sge;
351 __u32 max_inline_data;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700352};
353
354/*
355 * This struct needs to remain a multiple of 8 bytes to keep the
356 * alignment of the modify QP parameters.
357 */
358struct ib_uverbs_qp_dest {
359 __u8 dgid[16];
360 __u32 flow_label;
361 __u16 dlid;
362 __u16 reserved;
363 __u8 sgid_index;
364 __u8 hop_limit;
365 __u8 traffic_class;
366 __u8 sl;
367 __u8 src_path_bits;
368 __u8 static_rate;
369 __u8 is_global;
370 __u8 port_num;
371};
372
Dotan Barak7ccc9a22006-02-13 16:31:25 -0800373struct ib_uverbs_query_qp {
374 __u64 response;
375 __u32 qp_handle;
376 __u32 attr_mask;
377 __u64 driver_data[0];
378};
379
380struct ib_uverbs_query_qp_resp {
381 struct ib_uverbs_qp_dest dest;
382 struct ib_uverbs_qp_dest alt_dest;
383 __u32 max_send_wr;
384 __u32 max_recv_wr;
385 __u32 max_send_sge;
386 __u32 max_recv_sge;
387 __u32 max_inline_data;
388 __u32 qkey;
389 __u32 rq_psn;
390 __u32 sq_psn;
391 __u32 dest_qp_num;
392 __u32 qp_access_flags;
393 __u16 pkey_index;
394 __u16 alt_pkey_index;
395 __u8 qp_state;
396 __u8 cur_qp_state;
397 __u8 path_mtu;
398 __u8 path_mig_state;
399 __u8 en_sqd_async_notify;
400 __u8 max_rd_atomic;
401 __u8 max_dest_rd_atomic;
402 __u8 min_rnr_timer;
403 __u8 port_num;
404 __u8 timeout;
405 __u8 retry_cnt;
406 __u8 rnr_retry;
407 __u8 alt_port_num;
408 __u8 alt_timeout;
409 __u8 sq_sig_all;
410 __u8 reserved[5];
411 __u64 driver_data[0];
412};
413
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700414struct ib_uverbs_modify_qp {
415 struct ib_uverbs_qp_dest dest;
416 struct ib_uverbs_qp_dest alt_dest;
417 __u32 qp_handle;
418 __u32 attr_mask;
419 __u32 qkey;
420 __u32 rq_psn;
421 __u32 sq_psn;
422 __u32 dest_qp_num;
423 __u32 qp_access_flags;
424 __u16 pkey_index;
425 __u16 alt_pkey_index;
426 __u8 qp_state;
427 __u8 cur_qp_state;
428 __u8 path_mtu;
429 __u8 path_mig_state;
430 __u8 en_sqd_async_notify;
431 __u8 max_rd_atomic;
432 __u8 max_dest_rd_atomic;
433 __u8 min_rnr_timer;
434 __u8 port_num;
435 __u8 timeout;
436 __u8 retry_cnt;
437 __u8 rnr_retry;
438 __u8 alt_port_num;
439 __u8 alt_timeout;
440 __u8 reserved[2];
441 __u64 driver_data[0];
442};
443
444struct ib_uverbs_modify_qp_resp {
445};
446
447struct ib_uverbs_destroy_qp {
Roland Dreier63aaf642005-09-09 15:55:08 -0700448 __u64 response;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700449 __u32 qp_handle;
Roland Dreier63aaf642005-09-09 15:55:08 -0700450 __u32 reserved;
451};
452
453struct ib_uverbs_destroy_qp_resp {
454 __u32 events_reported;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700455};
456
Roland Dreier91ecd4a2005-10-14 15:21:44 -0700457/*
458 * The ib_uverbs_sge structure isn't used anywhere, since we assume
459 * the ib_sge structure is packed the same way on 32-bit and 64-bit
460 * architectures in both kernel and user space. It's just here to
461 * document the ABI.
462 */
463struct ib_uverbs_sge {
464 __u64 addr;
465 __u32 length;
466 __u32 lkey;
467};
468
469struct ib_uverbs_send_wr {
Roland Dreiera74cd4a2006-02-13 16:30:49 -0800470 __u64 wr_id;
Roland Dreier91ecd4a2005-10-14 15:21:44 -0700471 __u32 num_sge;
472 __u32 opcode;
473 __u32 send_flags;
474 __u32 imm_data;
475 union {
476 struct {
477 __u64 remote_addr;
478 __u32 rkey;
479 __u32 reserved;
480 } rdma;
481 struct {
482 __u64 remote_addr;
483 __u64 compare_add;
484 __u64 swap;
485 __u32 rkey;
486 __u32 reserved;
487 } atomic;
488 struct {
489 __u32 ah;
490 __u32 remote_qpn;
491 __u32 remote_qkey;
492 __u32 reserved;
493 } ud;
494 } wr;
495};
496
497struct ib_uverbs_post_send {
498 __u64 response;
499 __u32 qp_handle;
500 __u32 wr_count;
501 __u32 sge_count;
502 __u32 wqe_size;
503 struct ib_uverbs_send_wr send_wr[0];
504};
505
506struct ib_uverbs_post_send_resp {
507 __u32 bad_wr;
508};
509
510struct ib_uverbs_recv_wr {
511 __u64 wr_id;
512 __u32 num_sge;
513 __u32 reserved;
514};
515
516struct ib_uverbs_post_recv {
517 __u64 response;
518 __u32 qp_handle;
519 __u32 wr_count;
520 __u32 sge_count;
521 __u32 wqe_size;
522 struct ib_uverbs_recv_wr recv_wr[0];
523};
524
525struct ib_uverbs_post_recv_resp {
526 __u32 bad_wr;
527};
528
529struct ib_uverbs_post_srq_recv {
530 __u64 response;
531 __u32 srq_handle;
532 __u32 wr_count;
533 __u32 sge_count;
534 __u32 wqe_size;
535 struct ib_uverbs_recv_wr recv[0];
536};
537
538struct ib_uverbs_post_srq_recv_resp {
539 __u32 bad_wr;
540};
541
542struct ib_uverbs_global_route {
543 __u8 dgid[16];
Roland Dreiera74cd4a2006-02-13 16:30:49 -0800544 __u32 flow_label;
Roland Dreier91ecd4a2005-10-14 15:21:44 -0700545 __u8 sgid_index;
546 __u8 hop_limit;
547 __u8 traffic_class;
548 __u8 reserved;
549};
550
551struct ib_uverbs_ah_attr {
552 struct ib_uverbs_global_route grh;
553 __u16 dlid;
554 __u8 sl;
555 __u8 src_path_bits;
556 __u8 static_rate;
557 __u8 is_global;
558 __u8 port_num;
559 __u8 reserved;
560};
561
562struct ib_uverbs_create_ah {
563 __u64 response;
564 __u64 user_handle;
565 __u32 pd_handle;
566 __u32 reserved;
567 struct ib_uverbs_ah_attr attr;
568};
569
570struct ib_uverbs_create_ah_resp {
571 __u32 ah_handle;
572};
573
574struct ib_uverbs_destroy_ah {
575 __u32 ah_handle;
576};
577
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700578struct ib_uverbs_attach_mcast {
579 __u8 gid[16];
580 __u32 qp_handle;
581 __u16 mlid;
582 __u16 reserved;
583 __u64 driver_data[0];
584};
585
586struct ib_uverbs_detach_mcast {
587 __u8 gid[16];
588 __u32 qp_handle;
589 __u16 mlid;
590 __u16 reserved;
591 __u64 driver_data[0];
592};
593
Roland Dreierf520ba52005-08-18 12:24:13 -0700594struct ib_uverbs_create_srq {
595 __u64 response;
596 __u64 user_handle;
597 __u32 pd_handle;
598 __u32 max_wr;
599 __u32 max_sge;
600 __u32 srq_limit;
601 __u64 driver_data[0];
602};
603
604struct ib_uverbs_create_srq_resp {
605 __u32 srq_handle;
606};
607
608struct ib_uverbs_modify_srq {
609 __u32 srq_handle;
610 __u32 attr_mask;
611 __u32 max_wr;
Roland Dreierf520ba52005-08-18 12:24:13 -0700612 __u32 srq_limit;
Roland Dreierf520ba52005-08-18 12:24:13 -0700613 __u64 driver_data[0];
614};
615
616struct ib_uverbs_destroy_srq {
Roland Dreier63aaf642005-09-09 15:55:08 -0700617 __u64 response;
Roland Dreierf520ba52005-08-18 12:24:13 -0700618 __u32 srq_handle;
Roland Dreier63aaf642005-09-09 15:55:08 -0700619 __u32 reserved;
620};
621
622struct ib_uverbs_destroy_srq_resp {
623 __u32 events_reported;
Roland Dreierf520ba52005-08-18 12:24:13 -0700624};
625
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700626#endif /* IB_USER_VERBS_H */