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