| .. | .. |
|---|
| 91 | 91 | { |
|---|
| 92 | 92 | struct rvt_dev_info *rdi; |
|---|
| 93 | 93 | |
|---|
| 94 | | - rdi = (struct rvt_dev_info *)ib_alloc_device(size); |
|---|
| 94 | + rdi = container_of(_ib_alloc_device(size), struct rvt_dev_info, ibdev); |
|---|
| 95 | 95 | if (!rdi) |
|---|
| 96 | 96 | return rdi; |
|---|
| 97 | 97 | |
|---|
| .. | .. |
|---|
| 282 | 282 | &gid->global.interface_id); |
|---|
| 283 | 283 | } |
|---|
| 284 | 284 | |
|---|
| 285 | | -struct rvt_ucontext { |
|---|
| 286 | | - struct ib_ucontext ibucontext; |
|---|
| 287 | | -}; |
|---|
| 288 | | - |
|---|
| 289 | | -static inline struct rvt_ucontext *to_iucontext(struct ib_ucontext |
|---|
| 290 | | - *ibucontext) |
|---|
| 291 | | -{ |
|---|
| 292 | | - return container_of(ibucontext, struct rvt_ucontext, ibucontext); |
|---|
| 293 | | -} |
|---|
| 294 | | - |
|---|
| 295 | 285 | /** |
|---|
| 296 | 286 | * rvt_alloc_ucontext - Allocate a user context |
|---|
| 297 | | - * @ibdev: Verbs IB dev |
|---|
| 287 | + * @uctx: Verbs context |
|---|
| 298 | 288 | * @udata: User data allocated |
|---|
| 299 | 289 | */ |
|---|
| 300 | | -static struct ib_ucontext *rvt_alloc_ucontext(struct ib_device *ibdev, |
|---|
| 301 | | - struct ib_udata *udata) |
|---|
| 290 | +static int rvt_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata) |
|---|
| 302 | 291 | { |
|---|
| 303 | | - struct rvt_ucontext *context; |
|---|
| 304 | | - |
|---|
| 305 | | - context = kmalloc(sizeof(*context), GFP_KERNEL); |
|---|
| 306 | | - if (!context) |
|---|
| 307 | | - return ERR_PTR(-ENOMEM); |
|---|
| 308 | | - return &context->ibucontext; |
|---|
| 292 | + return 0; |
|---|
| 309 | 293 | } |
|---|
| 310 | 294 | |
|---|
| 311 | 295 | /** |
|---|
| 312 | | - *rvt_dealloc_ucontext - Free a user context |
|---|
| 313 | | - *@context - Free this |
|---|
| 296 | + * rvt_dealloc_ucontext - Free a user context |
|---|
| 297 | + * @context - Free this |
|---|
| 314 | 298 | */ |
|---|
| 315 | | -static int rvt_dealloc_ucontext(struct ib_ucontext *context) |
|---|
| 299 | +static void rvt_dealloc_ucontext(struct ib_ucontext *context) |
|---|
| 316 | 300 | { |
|---|
| 317 | | - kfree(to_iucontext(context)); |
|---|
| 318 | | - return 0; |
|---|
| 301 | + return; |
|---|
| 319 | 302 | } |
|---|
| 320 | 303 | |
|---|
| 321 | 304 | static int rvt_get_port_immutable(struct ib_device *ibdev, u8 port_num, |
|---|
| .. | .. |
|---|
| 390 | 373 | _VERB_IDX_MAX /* Must always be last! */ |
|---|
| 391 | 374 | }; |
|---|
| 392 | 375 | |
|---|
| 393 | | -static inline int check_driver_override(struct rvt_dev_info *rdi, |
|---|
| 394 | | - size_t offset, void *func) |
|---|
| 395 | | -{ |
|---|
| 396 | | - if (!*(void **)((void *)&rdi->ibdev + offset)) { |
|---|
| 397 | | - *(void **)((void *)&rdi->ibdev + offset) = func; |
|---|
| 398 | | - return 0; |
|---|
| 399 | | - } |
|---|
| 376 | +static const struct ib_device_ops rvt_dev_ops = { |
|---|
| 377 | + .uverbs_abi_ver = RVT_UVERBS_ABI_VERSION, |
|---|
| 400 | 378 | |
|---|
| 401 | | - return 1; |
|---|
| 402 | | -} |
|---|
| 379 | + .alloc_mr = rvt_alloc_mr, |
|---|
| 380 | + .alloc_pd = rvt_alloc_pd, |
|---|
| 381 | + .alloc_ucontext = rvt_alloc_ucontext, |
|---|
| 382 | + .attach_mcast = rvt_attach_mcast, |
|---|
| 383 | + .create_ah = rvt_create_ah, |
|---|
| 384 | + .create_cq = rvt_create_cq, |
|---|
| 385 | + .create_qp = rvt_create_qp, |
|---|
| 386 | + .create_srq = rvt_create_srq, |
|---|
| 387 | + .dealloc_pd = rvt_dealloc_pd, |
|---|
| 388 | + .dealloc_ucontext = rvt_dealloc_ucontext, |
|---|
| 389 | + .dereg_mr = rvt_dereg_mr, |
|---|
| 390 | + .destroy_ah = rvt_destroy_ah, |
|---|
| 391 | + .destroy_cq = rvt_destroy_cq, |
|---|
| 392 | + .destroy_qp = rvt_destroy_qp, |
|---|
| 393 | + .destroy_srq = rvt_destroy_srq, |
|---|
| 394 | + .detach_mcast = rvt_detach_mcast, |
|---|
| 395 | + .get_dma_mr = rvt_get_dma_mr, |
|---|
| 396 | + .get_port_immutable = rvt_get_port_immutable, |
|---|
| 397 | + .map_mr_sg = rvt_map_mr_sg, |
|---|
| 398 | + .mmap = rvt_mmap, |
|---|
| 399 | + .modify_ah = rvt_modify_ah, |
|---|
| 400 | + .modify_device = rvt_modify_device, |
|---|
| 401 | + .modify_port = rvt_modify_port, |
|---|
| 402 | + .modify_qp = rvt_modify_qp, |
|---|
| 403 | + .modify_srq = rvt_modify_srq, |
|---|
| 404 | + .poll_cq = rvt_poll_cq, |
|---|
| 405 | + .post_recv = rvt_post_recv, |
|---|
| 406 | + .post_send = rvt_post_send, |
|---|
| 407 | + .post_srq_recv = rvt_post_srq_recv, |
|---|
| 408 | + .query_ah = rvt_query_ah, |
|---|
| 409 | + .query_device = rvt_query_device, |
|---|
| 410 | + .query_gid = rvt_query_gid, |
|---|
| 411 | + .query_pkey = rvt_query_pkey, |
|---|
| 412 | + .query_port = rvt_query_port, |
|---|
| 413 | + .query_qp = rvt_query_qp, |
|---|
| 414 | + .query_srq = rvt_query_srq, |
|---|
| 415 | + .reg_user_mr = rvt_reg_user_mr, |
|---|
| 416 | + .req_notify_cq = rvt_req_notify_cq, |
|---|
| 417 | + .resize_cq = rvt_resize_cq, |
|---|
| 418 | + |
|---|
| 419 | + INIT_RDMA_OBJ_SIZE(ib_ah, rvt_ah, ibah), |
|---|
| 420 | + INIT_RDMA_OBJ_SIZE(ib_cq, rvt_cq, ibcq), |
|---|
| 421 | + INIT_RDMA_OBJ_SIZE(ib_pd, rvt_pd, ibpd), |
|---|
| 422 | + INIT_RDMA_OBJ_SIZE(ib_srq, rvt_srq, ibsrq), |
|---|
| 423 | + INIT_RDMA_OBJ_SIZE(ib_ucontext, rvt_ucontext, ibucontext), |
|---|
| 424 | +}; |
|---|
| 403 | 425 | |
|---|
| 404 | 426 | static noinline int check_support(struct rvt_dev_info *rdi, int verb) |
|---|
| 405 | 427 | { |
|---|
| .. | .. |
|---|
| 409 | 431 | * These functions are not part of verbs specifically but are |
|---|
| 410 | 432 | * required for rdmavt to function. |
|---|
| 411 | 433 | */ |
|---|
| 412 | | - if ((!rdi->driver_f.port_callback) || |
|---|
| 434 | + if ((!rdi->ibdev.ops.init_port) || |
|---|
| 413 | 435 | (!rdi->driver_f.get_pci_dev)) |
|---|
| 414 | 436 | return -EINVAL; |
|---|
| 415 | | - break; |
|---|
| 416 | | - |
|---|
| 417 | | - case QUERY_DEVICE: |
|---|
| 418 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 419 | | - query_device), |
|---|
| 420 | | - rvt_query_device); |
|---|
| 421 | 437 | break; |
|---|
| 422 | 438 | |
|---|
| 423 | 439 | case MODIFY_DEVICE: |
|---|
| .. | .. |
|---|
| 425 | 441 | * rdmavt does not support modify device currently drivers must |
|---|
| 426 | 442 | * provide. |
|---|
| 427 | 443 | */ |
|---|
| 428 | | - if (!check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 429 | | - modify_device), |
|---|
| 430 | | - rvt_modify_device)) |
|---|
| 444 | + if (!rdi->ibdev.ops.modify_device) |
|---|
| 431 | 445 | return -EOPNOTSUPP; |
|---|
| 432 | 446 | break; |
|---|
| 433 | 447 | |
|---|
| 434 | 448 | case QUERY_PORT: |
|---|
| 435 | | - if (!check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 436 | | - query_port), |
|---|
| 437 | | - rvt_query_port)) |
|---|
| 449 | + if (!rdi->ibdev.ops.query_port) |
|---|
| 438 | 450 | if (!rdi->driver_f.query_port_state) |
|---|
| 439 | 451 | return -EINVAL; |
|---|
| 440 | 452 | break; |
|---|
| 441 | 453 | |
|---|
| 442 | 454 | case MODIFY_PORT: |
|---|
| 443 | | - if (!check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 444 | | - modify_port), |
|---|
| 445 | | - rvt_modify_port)) |
|---|
| 455 | + if (!rdi->ibdev.ops.modify_port) |
|---|
| 446 | 456 | if (!rdi->driver_f.cap_mask_chg || |
|---|
| 447 | 457 | !rdi->driver_f.shut_down_port) |
|---|
| 448 | 458 | return -EINVAL; |
|---|
| 449 | 459 | break; |
|---|
| 450 | 460 | |
|---|
| 451 | | - case QUERY_PKEY: |
|---|
| 452 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 453 | | - query_pkey), |
|---|
| 454 | | - rvt_query_pkey); |
|---|
| 455 | | - break; |
|---|
| 456 | | - |
|---|
| 457 | 461 | case QUERY_GID: |
|---|
| 458 | | - if (!check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 459 | | - query_gid), |
|---|
| 460 | | - rvt_query_gid)) |
|---|
| 462 | + if (!rdi->ibdev.ops.query_gid) |
|---|
| 461 | 463 | if (!rdi->driver_f.get_guid_be) |
|---|
| 462 | 464 | return -EINVAL; |
|---|
| 463 | 465 | break; |
|---|
| 464 | 466 | |
|---|
| 465 | | - case ALLOC_UCONTEXT: |
|---|
| 466 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 467 | | - alloc_ucontext), |
|---|
| 468 | | - rvt_alloc_ucontext); |
|---|
| 469 | | - break; |
|---|
| 470 | | - |
|---|
| 471 | | - case DEALLOC_UCONTEXT: |
|---|
| 472 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 473 | | - dealloc_ucontext), |
|---|
| 474 | | - rvt_dealloc_ucontext); |
|---|
| 475 | | - break; |
|---|
| 476 | | - |
|---|
| 477 | | - case GET_PORT_IMMUTABLE: |
|---|
| 478 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 479 | | - get_port_immutable), |
|---|
| 480 | | - rvt_get_port_immutable); |
|---|
| 481 | | - break; |
|---|
| 482 | | - |
|---|
| 483 | 467 | case CREATE_QP: |
|---|
| 484 | | - if (!check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 485 | | - create_qp), |
|---|
| 486 | | - rvt_create_qp)) |
|---|
| 468 | + if (!rdi->ibdev.ops.create_qp) |
|---|
| 487 | 469 | if (!rdi->driver_f.qp_priv_alloc || |
|---|
| 488 | 470 | !rdi->driver_f.qp_priv_free || |
|---|
| 489 | 471 | !rdi->driver_f.notify_qp_reset || |
|---|
| .. | .. |
|---|
| 494 | 476 | break; |
|---|
| 495 | 477 | |
|---|
| 496 | 478 | case MODIFY_QP: |
|---|
| 497 | | - if (!check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 498 | | - modify_qp), |
|---|
| 499 | | - rvt_modify_qp)) |
|---|
| 479 | + if (!rdi->ibdev.ops.modify_qp) |
|---|
| 500 | 480 | if (!rdi->driver_f.notify_qp_reset || |
|---|
| 501 | 481 | !rdi->driver_f.schedule_send || |
|---|
| 502 | 482 | !rdi->driver_f.get_pmtu_from_attr || |
|---|
| .. | .. |
|---|
| 510 | 490 | break; |
|---|
| 511 | 491 | |
|---|
| 512 | 492 | case DESTROY_QP: |
|---|
| 513 | | - if (!check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 514 | | - destroy_qp), |
|---|
| 515 | | - rvt_destroy_qp)) |
|---|
| 493 | + if (!rdi->ibdev.ops.destroy_qp) |
|---|
| 516 | 494 | if (!rdi->driver_f.qp_priv_free || |
|---|
| 517 | 495 | !rdi->driver_f.notify_qp_reset || |
|---|
| 518 | 496 | !rdi->driver_f.flush_qp_waiters || |
|---|
| .. | .. |
|---|
| 521 | 499 | return -EINVAL; |
|---|
| 522 | 500 | break; |
|---|
| 523 | 501 | |
|---|
| 524 | | - case QUERY_QP: |
|---|
| 525 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 526 | | - query_qp), |
|---|
| 527 | | - rvt_query_qp); |
|---|
| 528 | | - break; |
|---|
| 529 | | - |
|---|
| 530 | 502 | case POST_SEND: |
|---|
| 531 | | - if (!check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 532 | | - post_send), |
|---|
| 533 | | - rvt_post_send)) |
|---|
| 503 | + if (!rdi->ibdev.ops.post_send) |
|---|
| 534 | 504 | if (!rdi->driver_f.schedule_send || |
|---|
| 535 | 505 | !rdi->driver_f.do_send || |
|---|
| 536 | 506 | !rdi->post_parms) |
|---|
| 537 | 507 | return -EINVAL; |
|---|
| 538 | 508 | break; |
|---|
| 539 | 509 | |
|---|
| 540 | | - case POST_RECV: |
|---|
| 541 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 542 | | - post_recv), |
|---|
| 543 | | - rvt_post_recv); |
|---|
| 544 | | - break; |
|---|
| 545 | | - case POST_SRQ_RECV: |
|---|
| 546 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 547 | | - post_srq_recv), |
|---|
| 548 | | - rvt_post_srq_recv); |
|---|
| 549 | | - break; |
|---|
| 550 | | - |
|---|
| 551 | | - case CREATE_AH: |
|---|
| 552 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 553 | | - create_ah), |
|---|
| 554 | | - rvt_create_ah); |
|---|
| 555 | | - break; |
|---|
| 556 | | - |
|---|
| 557 | | - case DESTROY_AH: |
|---|
| 558 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 559 | | - destroy_ah), |
|---|
| 560 | | - rvt_destroy_ah); |
|---|
| 561 | | - break; |
|---|
| 562 | | - |
|---|
| 563 | | - case MODIFY_AH: |
|---|
| 564 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 565 | | - modify_ah), |
|---|
| 566 | | - rvt_modify_ah); |
|---|
| 567 | | - break; |
|---|
| 568 | | - |
|---|
| 569 | | - case QUERY_AH: |
|---|
| 570 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 571 | | - query_ah), |
|---|
| 572 | | - rvt_query_ah); |
|---|
| 573 | | - break; |
|---|
| 574 | | - |
|---|
| 575 | | - case CREATE_SRQ: |
|---|
| 576 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 577 | | - create_srq), |
|---|
| 578 | | - rvt_create_srq); |
|---|
| 579 | | - break; |
|---|
| 580 | | - |
|---|
| 581 | | - case MODIFY_SRQ: |
|---|
| 582 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 583 | | - modify_srq), |
|---|
| 584 | | - rvt_modify_srq); |
|---|
| 585 | | - break; |
|---|
| 586 | | - |
|---|
| 587 | | - case DESTROY_SRQ: |
|---|
| 588 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 589 | | - destroy_srq), |
|---|
| 590 | | - rvt_destroy_srq); |
|---|
| 591 | | - break; |
|---|
| 592 | | - |
|---|
| 593 | | - case QUERY_SRQ: |
|---|
| 594 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 595 | | - query_srq), |
|---|
| 596 | | - rvt_query_srq); |
|---|
| 597 | | - break; |
|---|
| 598 | | - |
|---|
| 599 | | - case ATTACH_MCAST: |
|---|
| 600 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 601 | | - attach_mcast), |
|---|
| 602 | | - rvt_attach_mcast); |
|---|
| 603 | | - break; |
|---|
| 604 | | - |
|---|
| 605 | | - case DETACH_MCAST: |
|---|
| 606 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 607 | | - detach_mcast), |
|---|
| 608 | | - rvt_detach_mcast); |
|---|
| 609 | | - break; |
|---|
| 610 | | - |
|---|
| 611 | | - case GET_DMA_MR: |
|---|
| 612 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 613 | | - get_dma_mr), |
|---|
| 614 | | - rvt_get_dma_mr); |
|---|
| 615 | | - break; |
|---|
| 616 | | - |
|---|
| 617 | | - case REG_USER_MR: |
|---|
| 618 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 619 | | - reg_user_mr), |
|---|
| 620 | | - rvt_reg_user_mr); |
|---|
| 621 | | - break; |
|---|
| 622 | | - |
|---|
| 623 | | - case DEREG_MR: |
|---|
| 624 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 625 | | - dereg_mr), |
|---|
| 626 | | - rvt_dereg_mr); |
|---|
| 627 | | - break; |
|---|
| 628 | | - |
|---|
| 629 | | - case ALLOC_FMR: |
|---|
| 630 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 631 | | - alloc_fmr), |
|---|
| 632 | | - rvt_alloc_fmr); |
|---|
| 633 | | - break; |
|---|
| 634 | | - |
|---|
| 635 | | - case ALLOC_MR: |
|---|
| 636 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 637 | | - alloc_mr), |
|---|
| 638 | | - rvt_alloc_mr); |
|---|
| 639 | | - break; |
|---|
| 640 | | - |
|---|
| 641 | | - case MAP_MR_SG: |
|---|
| 642 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 643 | | - map_mr_sg), |
|---|
| 644 | | - rvt_map_mr_sg); |
|---|
| 645 | | - break; |
|---|
| 646 | | - |
|---|
| 647 | | - case MAP_PHYS_FMR: |
|---|
| 648 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 649 | | - map_phys_fmr), |
|---|
| 650 | | - rvt_map_phys_fmr); |
|---|
| 651 | | - break; |
|---|
| 652 | | - |
|---|
| 653 | | - case UNMAP_FMR: |
|---|
| 654 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 655 | | - unmap_fmr), |
|---|
| 656 | | - rvt_unmap_fmr); |
|---|
| 657 | | - break; |
|---|
| 658 | | - |
|---|
| 659 | | - case DEALLOC_FMR: |
|---|
| 660 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 661 | | - dealloc_fmr), |
|---|
| 662 | | - rvt_dealloc_fmr); |
|---|
| 663 | | - break; |
|---|
| 664 | | - |
|---|
| 665 | | - case MMAP: |
|---|
| 666 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 667 | | - mmap), |
|---|
| 668 | | - rvt_mmap); |
|---|
| 669 | | - break; |
|---|
| 670 | | - |
|---|
| 671 | | - case CREATE_CQ: |
|---|
| 672 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 673 | | - create_cq), |
|---|
| 674 | | - rvt_create_cq); |
|---|
| 675 | | - break; |
|---|
| 676 | | - |
|---|
| 677 | | - case DESTROY_CQ: |
|---|
| 678 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 679 | | - destroy_cq), |
|---|
| 680 | | - rvt_destroy_cq); |
|---|
| 681 | | - break; |
|---|
| 682 | | - |
|---|
| 683 | | - case POLL_CQ: |
|---|
| 684 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 685 | | - poll_cq), |
|---|
| 686 | | - rvt_poll_cq); |
|---|
| 687 | | - break; |
|---|
| 688 | | - |
|---|
| 689 | | - case REQ_NOTFIY_CQ: |
|---|
| 690 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 691 | | - req_notify_cq), |
|---|
| 692 | | - rvt_req_notify_cq); |
|---|
| 693 | | - break; |
|---|
| 694 | | - |
|---|
| 695 | | - case RESIZE_CQ: |
|---|
| 696 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 697 | | - resize_cq), |
|---|
| 698 | | - rvt_resize_cq); |
|---|
| 699 | | - break; |
|---|
| 700 | | - |
|---|
| 701 | | - case ALLOC_PD: |
|---|
| 702 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 703 | | - alloc_pd), |
|---|
| 704 | | - rvt_alloc_pd); |
|---|
| 705 | | - break; |
|---|
| 706 | | - |
|---|
| 707 | | - case DEALLOC_PD: |
|---|
| 708 | | - check_driver_override(rdi, offsetof(struct ib_device, |
|---|
| 709 | | - dealloc_pd), |
|---|
| 710 | | - rvt_dealloc_pd); |
|---|
| 711 | | - break; |
|---|
| 712 | | - |
|---|
| 713 | | - default: |
|---|
| 714 | | - return -EINVAL; |
|---|
| 715 | 510 | } |
|---|
| 716 | 511 | |
|---|
| 717 | 512 | return 0; |
|---|
| .. | .. |
|---|
| 726 | 521 | * |
|---|
| 727 | 522 | * Return: 0 on success otherwise an errno. |
|---|
| 728 | 523 | */ |
|---|
| 729 | | -int rvt_register_device(struct rvt_dev_info *rdi, u32 driver_id) |
|---|
| 524 | +int rvt_register_device(struct rvt_dev_info *rdi) |
|---|
| 730 | 525 | { |
|---|
| 731 | 526 | int ret = 0, i; |
|---|
| 732 | 527 | |
|---|
| .. | .. |
|---|
| 743 | 538 | return -EINVAL; |
|---|
| 744 | 539 | } |
|---|
| 745 | 540 | |
|---|
| 541 | + ib_set_device_ops(&rdi->ibdev, &rvt_dev_ops); |
|---|
| 746 | 542 | |
|---|
| 747 | 543 | /* Once we get past here we can use rvt_pr macros and tracepoints */ |
|---|
| 748 | 544 | trace_rvt_dbg(rdi, "Driver attempting registration"); |
|---|
| .. | .. |
|---|
| 772 | 568 | goto bail_no_mr; |
|---|
| 773 | 569 | } |
|---|
| 774 | 570 | |
|---|
| 571 | + /* Memory Working Set Size */ |
|---|
| 572 | + ret = rvt_wss_init(rdi); |
|---|
| 573 | + if (ret) { |
|---|
| 574 | + rvt_pr_err(rdi, "Error in WSS init.\n"); |
|---|
| 575 | + goto bail_mr; |
|---|
| 576 | + } |
|---|
| 577 | + |
|---|
| 775 | 578 | /* Completion queues */ |
|---|
| 776 | 579 | spin_lock_init(&rdi->n_cqs_lock); |
|---|
| 777 | | - |
|---|
| 778 | | - /* DMA Operations */ |
|---|
| 779 | | - rdi->ibdev.dev.dma_ops = rdi->ibdev.dev.dma_ops ? : &dma_virt_ops; |
|---|
| 780 | 580 | |
|---|
| 781 | 581 | /* Protection Domain */ |
|---|
| 782 | 582 | spin_lock_init(&rdi->n_pds_lock); |
|---|
| .. | .. |
|---|
| 788 | 588 | * exactly which functions rdmavt supports, nor do they know the ABI |
|---|
| 789 | 589 | * version, so we do all of this sort of stuff here. |
|---|
| 790 | 590 | */ |
|---|
| 791 | | - rdi->ibdev.uverbs_abi_ver = RVT_UVERBS_ABI_VERSION; |
|---|
| 792 | 591 | rdi->ibdev.uverbs_cmd_mask = |
|---|
| 793 | 592 | (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | |
|---|
| 794 | 593 | (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) | |
|---|
| .. | .. |
|---|
| 824 | 623 | if (!rdi->ibdev.num_comp_vectors) |
|---|
| 825 | 624 | rdi->ibdev.num_comp_vectors = 1; |
|---|
| 826 | 625 | |
|---|
| 827 | | - rdi->ibdev.driver_id = driver_id; |
|---|
| 828 | 626 | /* We are now good to announce we exist */ |
|---|
| 829 | | - ret = ib_register_device(&rdi->ibdev, rdi->driver_f.port_callback); |
|---|
| 627 | + ret = ib_register_device(&rdi->ibdev, dev_name(&rdi->ibdev.dev), NULL); |
|---|
| 830 | 628 | if (ret) { |
|---|
| 831 | 629 | rvt_pr_err(rdi, "Failed to register driver with ib core.\n"); |
|---|
| 832 | | - goto bail_mr; |
|---|
| 630 | + goto bail_wss; |
|---|
| 833 | 631 | } |
|---|
| 834 | 632 | |
|---|
| 835 | 633 | rvt_create_mad_agents(rdi); |
|---|
| .. | .. |
|---|
| 837 | 635 | rvt_pr_info(rdi, "Registration with rdmavt done.\n"); |
|---|
| 838 | 636 | return ret; |
|---|
| 839 | 637 | |
|---|
| 638 | +bail_wss: |
|---|
| 639 | + rvt_wss_exit(rdi); |
|---|
| 840 | 640 | bail_mr: |
|---|
| 841 | 641 | rvt_mr_exit(rdi); |
|---|
| 842 | 642 | |
|---|
| .. | .. |
|---|
| 860 | 660 | rvt_free_mad_agents(rdi); |
|---|
| 861 | 661 | |
|---|
| 862 | 662 | ib_unregister_device(&rdi->ibdev); |
|---|
| 663 | + rvt_wss_exit(rdi); |
|---|
| 863 | 664 | rvt_mr_exit(rdi); |
|---|
| 864 | 665 | rvt_qp_exit(rdi); |
|---|
| 865 | 666 | } |
|---|
| .. | .. |
|---|
| 867 | 668 | |
|---|
| 868 | 669 | /** |
|---|
| 869 | 670 | * rvt_init_port - init internal data for driver port |
|---|
| 870 | | - * @rdi: rvt dev strut |
|---|
| 671 | + * @rdi: rvt_dev_info struct |
|---|
| 871 | 672 | * @port: rvt port |
|---|
| 872 | 673 | * @port_index: 0 based index of ports, different from IB core port num |
|---|
| 674 | + * @pkey_table: pkey_table for @port |
|---|
| 873 | 675 | * |
|---|
| 874 | 676 | * Keep track of a list of ports. No need to have a detach port. |
|---|
| 875 | 677 | * They persist until the driver goes away. |
|---|