From 0e1b45a284b4e3e55447c7e8a5757917d6b94509 Mon Sep 17 00:00:00 2001 From: Jan Blunck Date: Fri, 23 Dec 2016 16:58:09 +0100 Subject: [PATCH] ethdev: decouple interrupt handling from PCI device The struct rte_intr_handle is an abstraction layer for different types of interrupt mechanisms. It is embedded in the low-level device (e.g. PCI). On allocation of a struct rte_eth_dev a reference to the intr_handle should be stored for devices supporting interrupts. Signed-off-by: Jan Blunck Acked-by: Shreyansh Jain --- lib/librte_ether/rte_ethdev.c | 18 ++++++++++++++++-- lib/librte_ether/rte_ethdev.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 9f60ff397a..b455850713 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -262,6 +262,7 @@ rte_eth_dev_pci_probe(struct rte_pci_driver *pci_drv, rte_panic("Cannot allocate memzone for private port data\n"); } eth_dev->pci_dev = pci_dev; + eth_dev->intr_handle = &pci_dev->intr_handle; eth_dev->driver = eth_drv; /* Invoke PMD device initialization function */ @@ -2591,7 +2592,13 @@ rte_eth_dev_rx_intr_ctl(uint8_t port_id, int epfd, int op, void *data) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; - intr_handle = &dev->pci_dev->intr_handle; + + if (!dev->intr_handle) { + RTE_PMD_DEBUG_TRACE("RX Intr handle unset\n"); + return -ENOTSUP; + } + + intr_handle = dev->intr_handle; if (!intr_handle->intr_vec) { RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n"); return -EPERM; @@ -2651,7 +2658,12 @@ rte_eth_dev_rx_intr_ctl_q(uint8_t port_id, uint16_t queue_id, return -EINVAL; } - intr_handle = &dev->pci_dev->intr_handle; + if (!dev->intr_handle) { + RTE_PMD_DEBUG_TRACE("RX Intr handle unset\n"); + return -ENOTSUP; + } + + intr_handle = dev->intr_handle; if (!intr_handle->intr_vec) { RTE_PMD_DEBUG_TRACE("RX Intr vector unset\n"); return -EPERM; @@ -3253,6 +3265,8 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_de return; } + eth_dev->intr_handle = &pci_dev->intr_handle; + eth_dev->data->dev_flags = 0; if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC) eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 272fd413df..e1eae65851 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1625,6 +1625,7 @@ struct rte_eth_dev { const struct eth_driver *driver;/**< Driver for this device */ const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */ struct rte_pci_device *pci_dev; /**< PCI info. supplied by probing */ + struct rte_intr_handle *intr_handle; /**< Device interrupt handle */ /** User application callbacks for NIC interrupts */ struct rte_eth_dev_cb_list link_intr_cbs; /**