blob: 338ed433306381c543aa963058804caddb48d7ed [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.
Dotan Barak8bdb0e82006-02-13 16:31:57 -08005 * Copyright (c) 2006 Mellanox Technologies. All rights reserved.
Roland Dreier8a96b3f2005-07-07 17:57:12 -07006 *
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 2708 2005-06-24 17:27:21Z roland $
36 */
37
38#ifndef IB_USER_VERBS_H
39#define IB_USER_VERBS_H
40
41#include <linux/types.h>
42
43/*
44 * Increment this value if any changes that break userspace ABI
45 * compatibility are made.
46 */
Dotan Barakea88fd12006-02-23 12:36:18 -080047#define IB_USER_VERBS_ABI_VERSION 6
Roland Dreier8a96b3f2005-07-07 17:57:12 -070048
49enum {
Roland Dreier8a96b3f2005-07-07 17:57:12 -070050 IB_USER_VERBS_CMD_GET_CONTEXT,
51 IB_USER_VERBS_CMD_QUERY_DEVICE,
52 IB_USER_VERBS_CMD_QUERY_PORT,
Roland Dreier8a96b3f2005-07-07 17:57:12 -070053 IB_USER_VERBS_CMD_ALLOC_PD,
54 IB_USER_VERBS_CMD_DEALLOC_PD,
55 IB_USER_VERBS_CMD_CREATE_AH,
56 IB_USER_VERBS_CMD_MODIFY_AH,
57 IB_USER_VERBS_CMD_QUERY_AH,
58 IB_USER_VERBS_CMD_DESTROY_AH,
59 IB_USER_VERBS_CMD_REG_MR,
60 IB_USER_VERBS_CMD_REG_SMR,
61 IB_USER_VERBS_CMD_REREG_MR,
62 IB_USER_VERBS_CMD_QUERY_MR,
63 IB_USER_VERBS_CMD_DEREG_MR,
64 IB_USER_VERBS_CMD_ALLOC_MW,
65 IB_USER_VERBS_CMD_BIND_MW,
66 IB_USER_VERBS_CMD_DEALLOC_MW,
Roland Dreier6b73597e2005-09-26 13:53:25 -070067 IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
Roland Dreier8a96b3f2005-07-07 17:57:12 -070068 IB_USER_VERBS_CMD_CREATE_CQ,
69 IB_USER_VERBS_CMD_RESIZE_CQ,
70 IB_USER_VERBS_CMD_DESTROY_CQ,
71 IB_USER_VERBS_CMD_POLL_CQ,
72 IB_USER_VERBS_CMD_PEEK_CQ,
73 IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
74 IB_USER_VERBS_CMD_CREATE_QP,
75 IB_USER_VERBS_CMD_QUERY_QP,
76 IB_USER_VERBS_CMD_MODIFY_QP,
77 IB_USER_VERBS_CMD_DESTROY_QP,
78 IB_USER_VERBS_CMD_POST_SEND,
79 IB_USER_VERBS_CMD_POST_RECV,
80 IB_USER_VERBS_CMD_ATTACH_MCAST,
Roland Dreierf520ba52005-08-18 12:24:13 -070081 IB_USER_VERBS_CMD_DETACH_MCAST,
82 IB_USER_VERBS_CMD_CREATE_SRQ,
83 IB_USER_VERBS_CMD_MODIFY_SRQ,
84 IB_USER_VERBS_CMD_QUERY_SRQ,
85 IB_USER_VERBS_CMD_DESTROY_SRQ,
86 IB_USER_VERBS_CMD_POST_SRQ_RECV
Roland Dreier8a96b3f2005-07-07 17:57:12 -070087};
88
89/*
90 * Make sure that all structs defined in this file remain laid out so
91 * that they pack the same way on 32-bit and 64-bit architectures (to
92 * avoid incompatibility between 32-bit userspace and 64-bit kernels).
Roland Dreier91ecd4a2005-10-14 15:21:44 -070093 * Specifically:
94 * - Do not use pointer types -- pass pointers in __u64 instead.
95 * - Make sure that any structure larger than 4 bytes is padded to a
96 * multiple of 8 bytes. Otherwise the structure size will be
97 * different between 32-bit and 64-bit architectures.
Roland Dreier8a96b3f2005-07-07 17:57:12 -070098 */
99
100struct ib_uverbs_async_event_desc {
101 __u64 element;
102 __u32 event_type; /* enum ib_event_type */
103 __u32 reserved;
104};
105
106struct ib_uverbs_comp_event_desc {
107 __u64 cq_handle;
108};
109
110/*
111 * All commands from userspace should start with a __u32 command field
112 * followed by __u16 in_words and out_words fields (which give the
113 * length of the command block and response buffer if any in 32-bit
114 * words). The kernel driver will read these fields first and read
115 * the rest of the command struct based on these value.
116 */
117
118struct ib_uverbs_cmd_hdr {
119 __u32 command;
120 __u16 in_words;
121 __u16 out_words;
122};
123
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700124struct ib_uverbs_get_context {
125 __u64 response;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700126 __u64 driver_data[0];
127};
128
129struct ib_uverbs_get_context_resp {
130 __u32 async_fd;
Roland Dreier6b73597e2005-09-26 13:53:25 -0700131 __u32 num_comp_vectors;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700132};
133
134struct ib_uverbs_query_device {
135 __u64 response;
136 __u64 driver_data[0];
137};
138
139struct ib_uverbs_query_device_resp {
140 __u64 fw_ver;
Sean Hefty97f52eb2005-08-13 21:05:57 -0700141 __be64 node_guid;
142 __be64 sys_image_guid;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700143 __u64 max_mr_size;
144 __u64 page_size_cap;
145 __u32 vendor_id;
146 __u32 vendor_part_id;
147 __u32 hw_ver;
148 __u32 max_qp;
149 __u32 max_qp_wr;
150 __u32 device_cap_flags;
151 __u32 max_sge;
152 __u32 max_sge_rd;
153 __u32 max_cq;
154 __u32 max_cqe;
155 __u32 max_mr;
156 __u32 max_pd;
157 __u32 max_qp_rd_atom;
158 __u32 max_ee_rd_atom;
159 __u32 max_res_rd_atom;
160 __u32 max_qp_init_rd_atom;
161 __u32 max_ee_init_rd_atom;
162 __u32 atomic_cap;
163 __u32 max_ee;
164 __u32 max_rdd;
165 __u32 max_mw;
166 __u32 max_raw_ipv6_qp;
167 __u32 max_raw_ethy_qp;
168 __u32 max_mcast_grp;
169 __u32 max_mcast_qp_attach;
170 __u32 max_total_mcast_qp_attach;
171 __u32 max_ah;
172 __u32 max_fmr;
173 __u32 max_map_per_fmr;
174 __u32 max_srq;
175 __u32 max_srq_wr;
176 __u32 max_srq_sge;
177 __u16 max_pkeys;
178 __u8 local_ca_ack_delay;
179 __u8 phys_port_cnt;
180 __u8 reserved[4];
181};
182
183struct ib_uverbs_query_port {
184 __u64 response;
185 __u8 port_num;
186 __u8 reserved[7];
187 __u64 driver_data[0];
188};
189
190struct ib_uverbs_query_port_resp {
191 __u32 port_cap_flags;
192 __u32 max_msg_sz;
193 __u32 bad_pkey_cntr;
194 __u32 qkey_viol_cntr;
195 __u32 gid_tbl_len;
196 __u16 pkey_tbl_len;
197 __u16 lid;
198 __u16 sm_lid;
199 __u8 state;
200 __u8 max_mtu;
201 __u8 active_mtu;
202 __u8 lmc;
203 __u8 max_vl_num;
204 __u8 sm_sl;
205 __u8 subnet_timeout;
206 __u8 init_type_reply;
207 __u8 active_width;
208 __u8 active_speed;
209 __u8 phys_state;
210 __u8 reserved[3];
211};
212
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700213struct ib_uverbs_alloc_pd {
214 __u64 response;
215 __u64 driver_data[0];
216};
217
218struct ib_uverbs_alloc_pd_resp {
219 __u32 pd_handle;
220};
221
222struct ib_uverbs_dealloc_pd {
223 __u32 pd_handle;
224};
225
226struct ib_uverbs_reg_mr {
227 __u64 response;
228 __u64 start;
229 __u64 length;
230 __u64 hca_va;
231 __u32 pd_handle;
232 __u32 access_flags;
233 __u64 driver_data[0];
234};
235
236struct ib_uverbs_reg_mr_resp {
237 __u32 mr_handle;
238 __u32 lkey;
239 __u32 rkey;
240};
241
242struct ib_uverbs_dereg_mr {
243 __u32 mr_handle;
244};
245
Roland Dreier6b73597e2005-09-26 13:53:25 -0700246struct ib_uverbs_create_comp_channel {
247 __u64 response;
248};
249
250struct ib_uverbs_create_comp_channel_resp {
251 __u32 fd;
252};
253
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700254struct ib_uverbs_create_cq {
255 __u64 response;
256 __u64 user_handle;
257 __u32 cqe;
Roland Dreier6b73597e2005-09-26 13:53:25 -0700258 __u32 comp_vector;
259 __s32 comp_channel;
260 __u32 reserved;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700261 __u64 driver_data[0];
262};
263
264struct ib_uverbs_create_cq_resp {
265 __u32 cq_handle;
266 __u32 cqe;
267};
268
Roland Dreier33b9b3e2006-01-30 14:29:21 -0800269struct ib_uverbs_resize_cq {
270 __u64 response;
271 __u32 cq_handle;
272 __u32 cqe;
273 __u64 driver_data[0];
274};
275
276struct ib_uverbs_resize_cq_resp {
277 __u32 cqe;
278};
279
Roland Dreier91ecd4a2005-10-14 15:21:44 -0700280struct ib_uverbs_poll_cq {
281 __u64 response;
282 __u32 cq_handle;
283 __u32 ne;
284};
285
286struct 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
304struct ib_uverbs_poll_cq_resp {
305 __u32 count;
306 __u32 reserved;
307 struct ib_uverbs_wc wc[0];
308};
309
310struct ib_uverbs_req_notify_cq {
311 __u32 cq_handle;
312 __u32 solicited_only;
313};
314
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700315struct ib_uverbs_destroy_cq {
Roland Dreier63aaf642005-09-09 15:55:08 -0700316 __u64 response;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700317 __u32 cq_handle;
Roland Dreier63aaf642005-09-09 15:55:08 -0700318 __u32 reserved;
319};
320
321struct ib_uverbs_destroy_cq_resp {
322 __u32 comp_events_reported;
323 __u32 async_events_reported;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700324};
325
326struct ib_uverbs_create_qp {
327 __u64 response;
328 __u64 user_handle;
329 __u32 pd_handle;
330 __u32 send_cq_handle;
331 __u32 recv_cq_handle;
332 __u32 srq_handle;
333 __u32 max_send_wr;
334 __u32 max_recv_wr;
335 __u32 max_send_sge;
336 __u32 max_recv_sge;
337 __u32 max_inline_data;
338 __u8 sq_sig_all;
339 __u8 qp_type;
340 __u8 is_srq;
341 __u8 reserved;
342 __u64 driver_data[0];
343};
344
345struct ib_uverbs_create_qp_resp {
346 __u32 qp_handle;
347 __u32 qpn;
Jack Morgenstein77369ed2005-11-09 11:26:07 -0800348 __u32 max_send_wr;
349 __u32 max_recv_wr;
350 __u32 max_send_sge;
351 __u32 max_recv_sge;
352 __u32 max_inline_data;
Roland Dreier4d9781c2006-02-16 09:26:19 -0800353 __u32 reserved;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700354};
355
356/*
357 * This struct needs to remain a multiple of 8 bytes to keep the
358 * alignment of the modify QP parameters.
359 */
360struct ib_uverbs_qp_dest {
361 __u8 dgid[16];
362 __u32 flow_label;
363 __u16 dlid;
364 __u16 reserved;
365 __u8 sgid_index;
366 __u8 hop_limit;
367 __u8 traffic_class;
368 __u8 sl;
369 __u8 src_path_bits;
370 __u8 static_rate;
371 __u8 is_global;
372 __u8 port_num;
373};
374
Dotan Barak7ccc9a22006-02-13 16:31:25 -0800375struct ib_uverbs_query_qp {
376 __u64 response;
377 __u32 qp_handle;
378 __u32 attr_mask;
379 __u64 driver_data[0];
380};
381
382struct ib_uverbs_query_qp_resp {
383 struct ib_uverbs_qp_dest dest;
384 struct ib_uverbs_qp_dest alt_dest;
385 __u32 max_send_wr;
386 __u32 max_recv_wr;
387 __u32 max_send_sge;
388 __u32 max_recv_sge;
389 __u32 max_inline_data;
390 __u32 qkey;
391 __u32 rq_psn;
392 __u32 sq_psn;
393 __u32 dest_qp_num;
394 __u32 qp_access_flags;
395 __u16 pkey_index;
396 __u16 alt_pkey_index;
397 __u8 qp_state;
398 __u8 cur_qp_state;
399 __u8 path_mtu;
400 __u8 path_mig_state;
401 __u8 en_sqd_async_notify;
402 __u8 max_rd_atomic;
403 __u8 max_dest_rd_atomic;
404 __u8 min_rnr_timer;
405 __u8 port_num;
406 __u8 timeout;
407 __u8 retry_cnt;
408 __u8 rnr_retry;
409 __u8 alt_port_num;
410 __u8 alt_timeout;
411 __u8 sq_sig_all;
412 __u8 reserved[5];
413 __u64 driver_data[0];
414};
415
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700416struct ib_uverbs_modify_qp {
417 struct ib_uverbs_qp_dest dest;
418 struct ib_uverbs_qp_dest alt_dest;
419 __u32 qp_handle;
420 __u32 attr_mask;
421 __u32 qkey;
422 __u32 rq_psn;
423 __u32 sq_psn;
424 __u32 dest_qp_num;
425 __u32 qp_access_flags;
426 __u16 pkey_index;
427 __u16 alt_pkey_index;
428 __u8 qp_state;
429 __u8 cur_qp_state;
430 __u8 path_mtu;
431 __u8 path_mig_state;
432 __u8 en_sqd_async_notify;
433 __u8 max_rd_atomic;
434 __u8 max_dest_rd_atomic;
435 __u8 min_rnr_timer;
436 __u8 port_num;
437 __u8 timeout;
438 __u8 retry_cnt;
439 __u8 rnr_retry;
440 __u8 alt_port_num;
441 __u8 alt_timeout;
442 __u8 reserved[2];
443 __u64 driver_data[0];
444};
445
446struct ib_uverbs_modify_qp_resp {
447};
448
449struct ib_uverbs_destroy_qp {
Roland Dreier63aaf642005-09-09 15:55:08 -0700450 __u64 response;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700451 __u32 qp_handle;
Roland Dreier63aaf642005-09-09 15:55:08 -0700452 __u32 reserved;
453};
454
455struct ib_uverbs_destroy_qp_resp {
456 __u32 events_reported;
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700457};
458
Roland Dreier91ecd4a2005-10-14 15:21:44 -0700459/*
460 * The ib_uverbs_sge structure isn't used anywhere, since we assume
461 * the ib_sge structure is packed the same way on 32-bit and 64-bit
462 * architectures in both kernel and user space. It's just here to
463 * document the ABI.
464 */
465struct ib_uverbs_sge {
466 __u64 addr;
467 __u32 length;
468 __u32 lkey;
469};
470
471struct ib_uverbs_send_wr {
Roland Dreiera74cd4a2006-02-13 16:30:49 -0800472 __u64 wr_id;
Roland Dreier91ecd4a2005-10-14 15:21:44 -0700473 __u32 num_sge;
474 __u32 opcode;
475 __u32 send_flags;
476 __u32 imm_data;
477 union {
478 struct {
479 __u64 remote_addr;
480 __u32 rkey;
481 __u32 reserved;
482 } rdma;
483 struct {
484 __u64 remote_addr;
485 __u64 compare_add;
486 __u64 swap;
487 __u32 rkey;
488 __u32 reserved;
489 } atomic;
490 struct {
491 __u32 ah;
492 __u32 remote_qpn;
493 __u32 remote_qkey;
494 __u32 reserved;
495 } ud;
496 } wr;
497};
498
499struct ib_uverbs_post_send {
500 __u64 response;
501 __u32 qp_handle;
502 __u32 wr_count;
503 __u32 sge_count;
504 __u32 wqe_size;
505 struct ib_uverbs_send_wr send_wr[0];
506};
507
508struct ib_uverbs_post_send_resp {
509 __u32 bad_wr;
510};
511
512struct ib_uverbs_recv_wr {
513 __u64 wr_id;
514 __u32 num_sge;
515 __u32 reserved;
516};
517
518struct ib_uverbs_post_recv {
519 __u64 response;
520 __u32 qp_handle;
521 __u32 wr_count;
522 __u32 sge_count;
523 __u32 wqe_size;
524 struct ib_uverbs_recv_wr recv_wr[0];
525};
526
527struct ib_uverbs_post_recv_resp {
528 __u32 bad_wr;
529};
530
531struct ib_uverbs_post_srq_recv {
532 __u64 response;
533 __u32 srq_handle;
534 __u32 wr_count;
535 __u32 sge_count;
536 __u32 wqe_size;
537 struct ib_uverbs_recv_wr recv[0];
538};
539
540struct ib_uverbs_post_srq_recv_resp {
541 __u32 bad_wr;
542};
543
544struct ib_uverbs_global_route {
545 __u8 dgid[16];
Roland Dreiera74cd4a2006-02-13 16:30:49 -0800546 __u32 flow_label;
Roland Dreier91ecd4a2005-10-14 15:21:44 -0700547 __u8 sgid_index;
548 __u8 hop_limit;
549 __u8 traffic_class;
550 __u8 reserved;
551};
552
553struct ib_uverbs_ah_attr {
554 struct ib_uverbs_global_route grh;
555 __u16 dlid;
556 __u8 sl;
557 __u8 src_path_bits;
558 __u8 static_rate;
559 __u8 is_global;
560 __u8 port_num;
561 __u8 reserved;
562};
563
564struct ib_uverbs_create_ah {
565 __u64 response;
566 __u64 user_handle;
567 __u32 pd_handle;
568 __u32 reserved;
569 struct ib_uverbs_ah_attr attr;
570};
571
572struct ib_uverbs_create_ah_resp {
573 __u32 ah_handle;
574};
575
576struct ib_uverbs_destroy_ah {
577 __u32 ah_handle;
578};
579
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700580struct ib_uverbs_attach_mcast {
581 __u8 gid[16];
582 __u32 qp_handle;
583 __u16 mlid;
584 __u16 reserved;
585 __u64 driver_data[0];
586};
587
588struct ib_uverbs_detach_mcast {
589 __u8 gid[16];
590 __u32 qp_handle;
591 __u16 mlid;
592 __u16 reserved;
593 __u64 driver_data[0];
594};
595
Roland Dreierf520ba52005-08-18 12:24:13 -0700596struct ib_uverbs_create_srq {
597 __u64 response;
598 __u64 user_handle;
599 __u32 pd_handle;
600 __u32 max_wr;
601 __u32 max_sge;
602 __u32 srq_limit;
603 __u64 driver_data[0];
604};
605
606struct ib_uverbs_create_srq_resp {
607 __u32 srq_handle;
Dotan Barakea88fd12006-02-23 12:36:18 -0800608 __u32 max_wr;
609 __u32 max_sge;
610 __u32 reserved;
Roland Dreierf520ba52005-08-18 12:24:13 -0700611};
612
613struct ib_uverbs_modify_srq {
614 __u32 srq_handle;
615 __u32 attr_mask;
616 __u32 max_wr;
Roland Dreierf520ba52005-08-18 12:24:13 -0700617 __u32 srq_limit;
Roland Dreierf520ba52005-08-18 12:24:13 -0700618 __u64 driver_data[0];
619};
620
Dotan Barak8bdb0e82006-02-13 16:31:57 -0800621struct ib_uverbs_query_srq {
622 __u64 response;
623 __u32 srq_handle;
624 __u32 reserved;
625 __u64 driver_data[0];
626};
627
628struct ib_uverbs_query_srq_resp {
629 __u32 max_wr;
630 __u32 max_sge;
631 __u32 srq_limit;
632 __u32 reserved;
633};
634
Roland Dreierf520ba52005-08-18 12:24:13 -0700635struct ib_uverbs_destroy_srq {
Roland Dreier63aaf642005-09-09 15:55:08 -0700636 __u64 response;
Roland Dreierf520ba52005-08-18 12:24:13 -0700637 __u32 srq_handle;
Roland Dreier63aaf642005-09-09 15:55:08 -0700638 __u32 reserved;
639};
640
641struct ib_uverbs_destroy_srq_resp {
642 __u32 events_reported;
Roland Dreierf520ba52005-08-18 12:24:13 -0700643};
644
Roland Dreier8a96b3f2005-07-07 17:57:12 -0700645#endif /* IB_USER_VERBS_H */