From: Bernard Iremonger Date: Tue, 3 Nov 2015 13:01:55 +0000 (+0000) Subject: ethdev: add device fields from PCI layer X-Git-Tag: spdx-start~8167 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=494adb7f63f20bbe1e98504085c7bda66c418c85;p=dpdk.git ethdev: add device fields from PCI layer The driver fields have been added the rte_eth_dev_data so that it is no longer necessary access this data through the pci_dev pointer. The following fields have been added to rte_eth_dev_data: dev_flags, and macros for dev_flags. kdrv numa_node drv_name Add function rte_eth_copy_pci_info Signed-off-by: Bernard Iremonger [Thomas: remove useless flags] --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 58aaeb273a..56b97cc2e0 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3247,3 +3247,22 @@ rte_eth_dev_get_dcb_info(uint8_t port_id, FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_dcb_info, -ENOTSUP); return (*dev->dev_ops->get_dcb_info)(dev, dcb_info); } + +void +rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev) +{ + if ((eth_dev == NULL) || (pci_dev == NULL)) { + PMD_DEBUG_TRACE("NULL pointer eth_dev=%p pci_dev=%p\n", + eth_dev, pci_dev); + } + + 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; + if (pci_dev->driver->drv_flags & RTE_PCI_DRV_DETACHABLE) + eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE; + + eth_dev->data->kdrv = pci_dev->kdrv; + eth_dev->data->numa_node = pci_dev->numa_node; + eth_dev->data->drv_name = pci_dev->driver->name; +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 7cf4af8634..4f7b64b9dc 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1553,8 +1553,17 @@ struct rte_eth_dev_data { all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */ dev_started : 1, /**< Device state: STARTED(1) / STOPPED(0). */ lro : 1; /**< RX LRO is ON(1) / OFF(0) */ + uint32_t dev_flags; /**< Capabilities */ + enum rte_kernel_driver kdrv; /**< Kernel driver passthrough */ + int numa_node; /**< NUMA node connection */ + const char *drv_name; /**< Driver name */ }; +/** Device supports hotplug detach */ +#define RTE_ETH_DEV_DETACHABLE 0x0001 +/** Device supports link state interrupt */ +#define RTE_ETH_DEV_INTR_LSC 0x0002 + /** * @internal * The pool of *rte_eth_dev* structures. The size of the pool @@ -3735,6 +3744,20 @@ extern int rte_eth_timesync_read_rx_timestamp(uint8_t port_id, extern int rte_eth_timesync_read_tx_timestamp(uint8_t port_id, struct timespec *timestamp); +/** + * Copy pci device info to the Ethernet device data. + * + * @param eth_dev + * The *eth_dev* pointer is the address of the *rte_eth_dev* structure. + * @param pci_dev + * The *pci_dev* pointer is the address of the *rte_pci_device* structure. + * + * @return + * - 0 on success, negative on error + */ +extern void rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, struct rte_pci_device *pci_dev); + + #ifdef __cplusplus } #endif diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index 7b04e95491..9149aa7059 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -131,6 +131,7 @@ DPDK_2.1 { DPDK_2.2 { global: + rte_eth_copy_pci_info; rte_eth_dev_get_dcb_info; rte_eth_rx_queue_info_get; rte_eth_tx_queue_info_get;