.. | .. |
---|
37 | 37 | |
---|
38 | 38 | #include <rdma/ib_user_verbs.h> |
---|
39 | 39 | #include <rdma/ib_addr.h> |
---|
| 40 | +#include <rdma/uverbs_ioctl.h> |
---|
40 | 41 | |
---|
41 | 42 | #include "usnic_abi.h" |
---|
42 | 43 | #include "usnic_ib.h" |
---|
.. | .. |
---|
159 | 160 | |
---|
160 | 161 | err = ib_copy_to_udata(udata, &resp, sizeof(resp)); |
---|
161 | 162 | if (err) { |
---|
162 | | - usnic_err("Failed to copy udata for %s", us_ibdev->ib_dev.name); |
---|
| 163 | + usnic_err("Failed to copy udata for %s", |
---|
| 164 | + dev_name(&us_ibdev->ib_dev.dev)); |
---|
163 | 165 | return err; |
---|
164 | 166 | } |
---|
165 | 167 | |
---|
.. | .. |
---|
192 | 194 | return ERR_CAST(dev_list); |
---|
193 | 195 | for (i = 0; dev_list[i]; i++) { |
---|
194 | 196 | dev = dev_list[i]; |
---|
195 | | - vf = pci_get_drvdata(to_pci_dev(dev)); |
---|
| 197 | + vf = dev_get_drvdata(dev); |
---|
196 | 198 | spin_lock(&vf->lock); |
---|
197 | 199 | vnic = vf->vnic; |
---|
198 | 200 | if (!usnic_vnic_check_room(vnic, res_spec)) { |
---|
199 | 201 | usnic_dbg("Found used vnic %s from %s\n", |
---|
200 | | - us_ibdev->ib_dev.name, |
---|
| 202 | + dev_name(&us_ibdev->ib_dev.dev), |
---|
201 | 203 | pci_name(usnic_vnic_get_pdev( |
---|
202 | 204 | vnic))); |
---|
203 | 205 | qp_grp = usnic_ib_qp_grp_create(us_ibdev->ufdev, |
---|
.. | .. |
---|
231 | 233 | spin_unlock(&vf->lock); |
---|
232 | 234 | } |
---|
233 | 235 | |
---|
234 | | - usnic_info("No free qp grp found on %s\n", us_ibdev->ib_dev.name); |
---|
| 236 | + usnic_info("No free qp grp found on %s\n", |
---|
| 237 | + dev_name(&us_ibdev->ib_dev.dev)); |
---|
235 | 238 | return ERR_PTR(-ENOMEM); |
---|
236 | 239 | |
---|
237 | 240 | qp_grp_check: |
---|
.. | .. |
---|
322 | 325 | props->max_mcast_grp = 0; |
---|
323 | 326 | props->max_mcast_qp_attach = 0; |
---|
324 | 327 | props->max_total_mcast_qp_attach = 0; |
---|
325 | | - props->max_map_per_fmr = 0; |
---|
326 | 328 | /* Owned by Userspace |
---|
327 | 329 | * max_qp_wr, max_sge, max_sge_rd, max_cqe */ |
---|
328 | 330 | mutex_unlock(&us_ibdev->usdev_lock); |
---|
.. | .. |
---|
356 | 358 | |
---|
357 | 359 | if (!us_ibdev->ufdev->link_up) { |
---|
358 | 360 | props->state = IB_PORT_DOWN; |
---|
359 | | - props->phys_state = 3; |
---|
| 361 | + props->phys_state = IB_PORT_PHYS_STATE_DISABLED; |
---|
360 | 362 | } else if (!us_ibdev->ufdev->inaddr) { |
---|
361 | 363 | props->state = IB_PORT_INIT; |
---|
362 | | - props->phys_state = 4; |
---|
| 364 | + props->phys_state = |
---|
| 365 | + IB_PORT_PHYS_STATE_PORT_CONFIGURATION_TRAINING; |
---|
363 | 366 | } else { |
---|
364 | 367 | props->state = IB_PORT_ACTIVE; |
---|
365 | | - props->phys_state = 5; |
---|
| 368 | + props->phys_state = IB_PORT_PHYS_STATE_LINK_UP; |
---|
366 | 369 | } |
---|
367 | 370 | |
---|
368 | 371 | props->port_cap_flags = 0; |
---|
369 | 372 | props->gid_tbl_len = 1; |
---|
370 | | - props->pkey_tbl_len = 1; |
---|
371 | 373 | props->bad_pkey_cntr = 0; |
---|
372 | 374 | props->qkey_viol_cntr = 0; |
---|
373 | 375 | props->max_mtu = IB_MTU_4096; |
---|
.. | .. |
---|
437 | 439 | return 0; |
---|
438 | 440 | } |
---|
439 | 441 | |
---|
440 | | -struct net_device *usnic_get_netdev(struct ib_device *device, u8 port_num) |
---|
| 442 | +int usnic_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata) |
---|
441 | 443 | { |
---|
442 | | - struct usnic_ib_dev *us_ibdev = to_usdev(device); |
---|
443 | | - |
---|
444 | | - if (us_ibdev->netdev) |
---|
445 | | - dev_hold(us_ibdev->netdev); |
---|
446 | | - |
---|
447 | | - return us_ibdev->netdev; |
---|
448 | | -} |
---|
449 | | - |
---|
450 | | -int usnic_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index, |
---|
451 | | - u16 *pkey) |
---|
452 | | -{ |
---|
453 | | - if (index > 0) |
---|
454 | | - return -EINVAL; |
---|
455 | | - |
---|
456 | | - *pkey = 0xffff; |
---|
457 | | - return 0; |
---|
458 | | -} |
---|
459 | | - |
---|
460 | | -struct ib_pd *usnic_ib_alloc_pd(struct ib_device *ibdev, |
---|
461 | | - struct ib_ucontext *context, |
---|
462 | | - struct ib_udata *udata) |
---|
463 | | -{ |
---|
464 | | - struct usnic_ib_pd *pd; |
---|
| 444 | + struct usnic_ib_pd *pd = to_upd(ibpd); |
---|
465 | 445 | void *umem_pd; |
---|
466 | | - |
---|
467 | | - usnic_dbg("\n"); |
---|
468 | | - |
---|
469 | | - pd = kzalloc(sizeof(*pd), GFP_KERNEL); |
---|
470 | | - if (!pd) |
---|
471 | | - return ERR_PTR(-ENOMEM); |
---|
472 | 446 | |
---|
473 | 447 | umem_pd = pd->umem_pd = usnic_uiom_alloc_pd(); |
---|
474 | 448 | if (IS_ERR_OR_NULL(umem_pd)) { |
---|
475 | | - kfree(pd); |
---|
476 | | - return ERR_PTR(umem_pd ? PTR_ERR(umem_pd) : -ENOMEM); |
---|
| 449 | + return umem_pd ? PTR_ERR(umem_pd) : -ENOMEM; |
---|
477 | 450 | } |
---|
478 | 451 | |
---|
479 | | - usnic_info("domain 0x%p allocated for context 0x%p and device %s\n", |
---|
480 | | - pd, context, ibdev->name); |
---|
481 | | - return &pd->ibpd; |
---|
| 452 | + return 0; |
---|
482 | 453 | } |
---|
483 | 454 | |
---|
484 | | -int usnic_ib_dealloc_pd(struct ib_pd *pd) |
---|
| 455 | +int usnic_ib_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata) |
---|
485 | 456 | { |
---|
486 | | - usnic_info("freeing domain 0x%p\n", pd); |
---|
487 | | - |
---|
488 | 457 | usnic_uiom_dealloc_pd((to_upd(pd))->umem_pd); |
---|
489 | | - kfree(pd); |
---|
490 | 458 | return 0; |
---|
491 | 459 | } |
---|
492 | 460 | |
---|
.. | .. |
---|
497 | 465 | int err; |
---|
498 | 466 | struct usnic_ib_dev *us_ibdev; |
---|
499 | 467 | struct usnic_ib_qp_grp *qp_grp; |
---|
500 | | - struct usnic_ib_ucontext *ucontext; |
---|
| 468 | + struct usnic_ib_ucontext *ucontext = rdma_udata_to_drv_context( |
---|
| 469 | + udata, struct usnic_ib_ucontext, ibucontext); |
---|
501 | 470 | int cq_cnt; |
---|
502 | 471 | struct usnic_vnic_res_spec res_spec; |
---|
503 | 472 | struct usnic_ib_create_qp_cmd cmd; |
---|
.. | .. |
---|
505 | 474 | |
---|
506 | 475 | usnic_dbg("\n"); |
---|
507 | 476 | |
---|
508 | | - ucontext = to_uucontext(pd->uobject->context); |
---|
509 | 477 | us_ibdev = to_usdev(pd->device); |
---|
510 | 478 | |
---|
511 | 479 | if (init_attr->create_flags) |
---|
.. | .. |
---|
514 | 482 | err = ib_copy_from_udata(&cmd, udata, sizeof(cmd)); |
---|
515 | 483 | if (err) { |
---|
516 | 484 | usnic_err("%s: cannot copy udata for create_qp\n", |
---|
517 | | - us_ibdev->ib_dev.name); |
---|
| 485 | + dev_name(&us_ibdev->ib_dev.dev)); |
---|
518 | 486 | return ERR_PTR(-EINVAL); |
---|
519 | 487 | } |
---|
520 | 488 | |
---|
521 | 489 | err = create_qp_validate_user_data(cmd); |
---|
522 | 490 | if (err) { |
---|
523 | 491 | usnic_err("%s: Failed to validate user data\n", |
---|
524 | | - us_ibdev->ib_dev.name); |
---|
| 492 | + dev_name(&us_ibdev->ib_dev.dev)); |
---|
525 | 493 | return ERR_PTR(-EINVAL); |
---|
526 | 494 | } |
---|
527 | 495 | |
---|
528 | 496 | if (init_attr->qp_type != IB_QPT_UD) { |
---|
529 | 497 | usnic_err("%s asked to make a non-UD QP: %d\n", |
---|
530 | | - us_ibdev->ib_dev.name, init_attr->qp_type); |
---|
531 | | - return ERR_PTR(-EINVAL); |
---|
| 498 | + dev_name(&us_ibdev->ib_dev.dev), init_attr->qp_type); |
---|
| 499 | + return ERR_PTR(-EOPNOTSUPP); |
---|
532 | 500 | } |
---|
533 | 501 | |
---|
534 | 502 | trans_spec = cmd.spec; |
---|
.. | .. |
---|
563 | 531 | return ERR_PTR(err); |
---|
564 | 532 | } |
---|
565 | 533 | |
---|
566 | | -int usnic_ib_destroy_qp(struct ib_qp *qp) |
---|
| 534 | +int usnic_ib_destroy_qp(struct ib_qp *qp, struct ib_udata *udata) |
---|
567 | 535 | { |
---|
568 | 536 | struct usnic_ib_qp_grp *qp_grp; |
---|
569 | 537 | struct usnic_ib_vf *vf; |
---|
.. | .. |
---|
612 | 580 | return status; |
---|
613 | 581 | } |
---|
614 | 582 | |
---|
615 | | -struct ib_cq *usnic_ib_create_cq(struct ib_device *ibdev, |
---|
616 | | - const struct ib_cq_init_attr *attr, |
---|
617 | | - struct ib_ucontext *context, |
---|
618 | | - struct ib_udata *udata) |
---|
| 583 | +int usnic_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, |
---|
| 584 | + struct ib_udata *udata) |
---|
619 | 585 | { |
---|
620 | | - struct ib_cq *cq; |
---|
621 | | - |
---|
622 | | - usnic_dbg("\n"); |
---|
623 | 586 | if (attr->flags) |
---|
624 | | - return ERR_PTR(-EINVAL); |
---|
| 587 | + return -EINVAL; |
---|
625 | 588 | |
---|
626 | | - cq = kzalloc(sizeof(*cq), GFP_KERNEL); |
---|
627 | | - if (!cq) |
---|
628 | | - return ERR_PTR(-EBUSY); |
---|
629 | | - |
---|
630 | | - return cq; |
---|
| 589 | + return 0; |
---|
631 | 590 | } |
---|
632 | 591 | |
---|
633 | | -int usnic_ib_destroy_cq(struct ib_cq *cq) |
---|
| 592 | +int usnic_ib_destroy_cq(struct ib_cq *cq, struct ib_udata *udata) |
---|
634 | 593 | { |
---|
635 | | - usnic_dbg("\n"); |
---|
636 | | - kfree(cq); |
---|
637 | 594 | return 0; |
---|
638 | 595 | } |
---|
639 | 596 | |
---|
.. | .. |
---|
666 | 623 | return ERR_PTR(err); |
---|
667 | 624 | } |
---|
668 | 625 | |
---|
669 | | -int usnic_ib_dereg_mr(struct ib_mr *ibmr) |
---|
| 626 | +int usnic_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) |
---|
670 | 627 | { |
---|
671 | 628 | struct usnic_ib_mr *mr = to_umr(ibmr); |
---|
672 | 629 | |
---|
673 | 630 | usnic_dbg("va 0x%lx length 0x%zx\n", mr->umem->va, mr->umem->length); |
---|
674 | 631 | |
---|
675 | | - usnic_uiom_reg_release(mr->umem, ibmr->uobject->context); |
---|
| 632 | + usnic_uiom_reg_release(mr->umem); |
---|
676 | 633 | kfree(mr); |
---|
677 | 634 | return 0; |
---|
678 | 635 | } |
---|
679 | 636 | |
---|
680 | | -struct ib_ucontext *usnic_ib_alloc_ucontext(struct ib_device *ibdev, |
---|
681 | | - struct ib_udata *udata) |
---|
| 637 | +int usnic_ib_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata) |
---|
682 | 638 | { |
---|
683 | | - struct usnic_ib_ucontext *context; |
---|
| 639 | + struct ib_device *ibdev = uctx->device; |
---|
| 640 | + struct usnic_ib_ucontext *context = to_ucontext(uctx); |
---|
684 | 641 | struct usnic_ib_dev *us_ibdev = to_usdev(ibdev); |
---|
685 | 642 | usnic_dbg("\n"); |
---|
686 | | - |
---|
687 | | - context = kmalloc(sizeof(*context), GFP_KERNEL); |
---|
688 | | - if (!context) |
---|
689 | | - return ERR_PTR(-ENOMEM); |
---|
690 | 643 | |
---|
691 | 644 | INIT_LIST_HEAD(&context->qp_grp_list); |
---|
692 | 645 | mutex_lock(&us_ibdev->usdev_lock); |
---|
693 | 646 | list_add_tail(&context->link, &us_ibdev->ctx_list); |
---|
694 | 647 | mutex_unlock(&us_ibdev->usdev_lock); |
---|
695 | 648 | |
---|
696 | | - return &context->ibucontext; |
---|
| 649 | + return 0; |
---|
697 | 650 | } |
---|
698 | 651 | |
---|
699 | | -int usnic_ib_dealloc_ucontext(struct ib_ucontext *ibcontext) |
---|
| 652 | +void usnic_ib_dealloc_ucontext(struct ib_ucontext *ibcontext) |
---|
700 | 653 | { |
---|
701 | 654 | struct usnic_ib_ucontext *context = to_uucontext(ibcontext); |
---|
702 | 655 | struct usnic_ib_dev *us_ibdev = to_usdev(ibcontext->device); |
---|
703 | 656 | usnic_dbg("\n"); |
---|
704 | 657 | |
---|
705 | 658 | mutex_lock(&us_ibdev->usdev_lock); |
---|
706 | | - BUG_ON(!list_empty(&context->qp_grp_list)); |
---|
| 659 | + WARN_ON_ONCE(!list_empty(&context->qp_grp_list)); |
---|
707 | 660 | list_del(&context->link); |
---|
708 | 661 | mutex_unlock(&us_ibdev->usdev_lock); |
---|
709 | | - kfree(context); |
---|
710 | | - return 0; |
---|
711 | 662 | } |
---|
712 | 663 | |
---|
713 | 664 | int usnic_ib_mmap(struct ib_ucontext *context, |
---|
.. | .. |
---|
761 | 712 | return -EINVAL; |
---|
762 | 713 | } |
---|
763 | 714 | |
---|
764 | | -/* In ib callbacks section - Start of stub funcs */ |
---|
765 | | -struct ib_ah *usnic_ib_create_ah(struct ib_pd *pd, |
---|
766 | | - struct rdma_ah_attr *ah_attr, |
---|
767 | | - struct ib_udata *udata) |
---|
768 | | - |
---|
769 | | -{ |
---|
770 | | - usnic_dbg("\n"); |
---|
771 | | - return ERR_PTR(-EPERM); |
---|
772 | | -} |
---|
773 | | - |
---|
774 | | -int usnic_ib_destroy_ah(struct ib_ah *ah) |
---|
775 | | -{ |
---|
776 | | - usnic_dbg("\n"); |
---|
777 | | - return -EINVAL; |
---|
778 | | -} |
---|
779 | | - |
---|
780 | | -int usnic_ib_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr, |
---|
781 | | - const struct ib_send_wr **bad_wr) |
---|
782 | | -{ |
---|
783 | | - usnic_dbg("\n"); |
---|
784 | | - return -EINVAL; |
---|
785 | | -} |
---|
786 | | - |
---|
787 | | -int usnic_ib_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr, |
---|
788 | | - const struct ib_recv_wr **bad_wr) |
---|
789 | | -{ |
---|
790 | | - usnic_dbg("\n"); |
---|
791 | | - return -EINVAL; |
---|
792 | | -} |
---|
793 | | - |
---|
794 | | -int usnic_ib_poll_cq(struct ib_cq *ibcq, int num_entries, |
---|
795 | | - struct ib_wc *wc) |
---|
796 | | -{ |
---|
797 | | - usnic_dbg("\n"); |
---|
798 | | - return -EINVAL; |
---|
799 | | -} |
---|
800 | | - |
---|
801 | | -int usnic_ib_req_notify_cq(struct ib_cq *cq, |
---|
802 | | - enum ib_cq_notify_flags flags) |
---|
803 | | -{ |
---|
804 | | - usnic_dbg("\n"); |
---|
805 | | - return -EINVAL; |
---|
806 | | -} |
---|
807 | | - |
---|
808 | | -struct ib_mr *usnic_ib_get_dma_mr(struct ib_pd *pd, int acc) |
---|
809 | | -{ |
---|
810 | | - usnic_dbg("\n"); |
---|
811 | | - return ERR_PTR(-ENOMEM); |
---|
812 | | -} |
---|
813 | | - |
---|
814 | | - |
---|
815 | | -/* In ib callbacks section - End of stub funcs */ |
---|
816 | | -/* End of ib callbacks section */ |
---|