| 694 | } |
| 695 | |
| 696 | int |
| 697 | rte_intr_enable(const struct rte_intr_handle *intr_handle) |
| 698 | { |
| 699 | int rc = 0, uio_cfg_fd; |
| 700 | |
| 701 | if (intr_handle == NULL) |
| 702 | return -1; |
| 703 | |
| 704 | if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VDEV) { |
| 705 | rc = 0; |
| 706 | goto out; |
| 707 | } |
| 708 | |
| 709 | uio_cfg_fd = rte_intr_dev_fd_get(intr_handle); |
| 710 | if (rte_intr_fd_get(intr_handle) < 0 || uio_cfg_fd < 0) { |
| 711 | rc = -1; |
| 712 | goto out; |
| 713 | } |
| 714 | |
| 715 | switch (rte_intr_type_get(intr_handle)) { |
| 716 | /* write to the uio fd to enable the interrupt */ |
| 717 | case RTE_INTR_HANDLE_UIO: |
| 718 | if (uio_intr_enable(intr_handle)) |
| 719 | rc = -1; |
| 720 | break; |
| 721 | case RTE_INTR_HANDLE_UIO_INTX: |
| 722 | if (uio_intx_intr_enable(intr_handle)) |
| 723 | rc = -1; |
| 724 | break; |
| 725 | /* not used at this moment */ |
| 726 | case RTE_INTR_HANDLE_ALARM: |
| 727 | rc = -1; |
| 728 | break; |
| 729 | #ifdef VFIO_PRESENT |
| 730 | case RTE_INTR_HANDLE_VFIO_MSIX: |
| 731 | if (vfio_enable_msix(intr_handle)) |
| 732 | rc = -1; |
| 733 | break; |
| 734 | case RTE_INTR_HANDLE_VFIO_MSI: |
| 735 | if (vfio_enable_msi(intr_handle)) |
| 736 | rc = -1; |
| 737 | break; |
| 738 | case RTE_INTR_HANDLE_VFIO_LEGACY: |
| 739 | if (vfio_enable_intx(intr_handle)) |
| 740 | rc = -1; |
| 741 | break; |
| 742 | #ifdef HAVE_VFIO_DEV_REQ_INTERFACE |
| 743 | case RTE_INTR_HANDLE_VFIO_REQ: |
| 744 | if (vfio_enable_req(intr_handle)) |
| 745 | rc = -1; |
| 746 | break; |
| 747 | #endif |
| 748 | #endif |
| 749 | /* not used at this moment */ |
| 750 | case RTE_INTR_HANDLE_DEV_EVENT: |
| 751 | rc = -1; |
| 752 | break; |
| 753 | /* unknown handle type */ |