| 1511 | } |
| 1512 | |
| 1513 | int |
| 1514 | rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd) |
| 1515 | { |
| 1516 | uint32_t i; |
| 1517 | int fd; |
| 1518 | uint32_t n = RTE_MIN(nb_efd, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID); |
| 1519 | |
| 1520 | assert(nb_efd != 0); |
| 1521 | |
| 1522 | if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX) { |
| 1523 | for (i = 0; i < n; i++) { |
| 1524 | fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); |
| 1525 | if (fd < 0) { |
| 1526 | RTE_LOG(ERR, EAL, |
| 1527 | "can't setup eventfd, error %i (%s)\n", |
| 1528 | errno, strerror(errno)); |
| 1529 | return -errno; |
| 1530 | } |
| 1531 | |
| 1532 | if (rte_intr_efds_index_set(intr_handle, i, fd)) |
| 1533 | return -rte_errno; |
| 1534 | } |
| 1535 | |
| 1536 | if (rte_intr_nb_efd_set(intr_handle, n)) |
| 1537 | return -rte_errno; |
| 1538 | |
| 1539 | if (rte_intr_max_intr_set(intr_handle, NB_OTHER_INTR + n)) |
| 1540 | return -rte_errno; |
| 1541 | } else if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VDEV) { |
| 1542 | /* only check, initialization would be done in vdev driver.*/ |
| 1543 | if ((uint64_t)rte_intr_efd_counter_size_get(intr_handle) > |
| 1544 | sizeof(union rte_intr_read_buffer)) { |
| 1545 | RTE_LOG(ERR, EAL, "the efd_counter_size is oversized\n"); |
| 1546 | return -EINVAL; |
| 1547 | } |
| 1548 | } else { |
| 1549 | if (rte_intr_efds_index_set(intr_handle, 0, rte_intr_fd_get(intr_handle))) |
| 1550 | return -rte_errno; |
| 1551 | if (rte_intr_nb_efd_set(intr_handle, RTE_MIN(nb_efd, 1U))) |
| 1552 | return -rte_errno; |
| 1553 | if (rte_intr_max_intr_set(intr_handle, NB_OTHER_INTR)) |
| 1554 | return -rte_errno; |
| 1555 | } |
| 1556 | |
| 1557 | return 0; |
| 1558 | } |
| 1559 | |
| 1560 | void |
| 1561 | rte_intr_efd_disable(struct rte_intr_handle *intr_handle) |
no test coverage detected