1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018 Mellanox Technologies, Ltd
7 * Interrupts handling for tap driver.
17 #include <rte_eth_tap.h>
18 #include <rte_errno.h>
19 #include <rte_interrupts.h>
23 * Unregister Rx interrupts free the queue interrupt vector.
26 * Pointer to the tap rte_eth_dev structure.
29 tap_rx_intr_vec_uninstall(struct rte_eth_dev *dev)
31 struct pmd_internals *pmd = dev->data->dev_private;
32 struct rte_intr_handle *intr_handle = pmd->intr_handle;
34 rte_intr_free_epoll_fd(intr_handle);
35 rte_intr_vec_list_free(intr_handle);
36 rte_intr_nb_efd_set(intr_handle, 0);
40 * Allocate Rx queue interrupt vector and register Rx interrupts.
43 * Pointer to the tap rte_eth_dev device structure.
46 * 0 on success, negative errno value otherwise and rte_errno is set.
49 tap_rx_intr_vec_install(struct rte_eth_dev *dev)
51 struct pmd_internals *pmd = dev->data->dev_private;
52 struct pmd_process_private *process_private = dev->process_private;
53 unsigned int rxqs_n = pmd->dev->data->nb_rx_queues;
54 struct rte_intr_handle *intr_handle = pmd->intr_handle;
55 unsigned int n = RTE_MIN(rxqs_n, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID);
57 unsigned int count = 0;
59 if (!dev->data->dev_conf.intr_conf.rxq)
62 if (rte_intr_vec_list_alloc(intr_handle, NULL, rxqs_n)) {
65 "failed to allocate memory for interrupt vector,"
66 " Rx interrupts will not be supported");
69 for (i = 0; i < n; i++) {
70 struct rx_queue *rxq = pmd->dev->data->rx_queues[i];
72 /* Skip queues that cannot request interrupts. */
73 if (!rxq || process_private->rxq_fds[i] == -1) {
74 /* Use invalid intr_vec[] index to disable entry. */
75 if (rte_intr_vec_list_index_set(intr_handle, i,
76 RTE_INTR_VEC_RXTX_OFFSET + RTE_MAX_RXTX_INTR_VEC_ID))
80 if (rte_intr_vec_list_index_set(intr_handle, i,
81 RTE_INTR_VEC_RXTX_OFFSET + count))
83 if (rte_intr_efds_index_set(intr_handle, count,
84 process_private->rxq_fds[i]))
89 tap_rx_intr_vec_uninstall(dev);
90 else if (rte_intr_nb_efd_set(intr_handle, count))
96 * Register or unregister the Rx interrupts.
99 * Pointer to the tap rte_eth_dev device structure.
101 * should the operation be register or unregister the interrupts.
104 * 0 on success, negative errno value otherwise and rte_errno is set.
107 tap_rx_intr_vec_set(struct rte_eth_dev *dev, int set)
109 tap_rx_intr_vec_uninstall(dev);
111 return tap_rx_intr_vec_install(dev);