ethdev: add device fields from PCI layer
authorBernard Iremonger <bernard.iremonger@intel.com>
Tue, 3 Nov 2015 13:01:55 +0000 (13:01 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 3 Nov 2015 17:39:23 +0000 (18:39 +0100)
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 <bernard.iremonger@intel.com>
[Thomas: remove useless flags]

lib/librte_ether/rte_ethdev.c
lib/librte_ether/rte_ethdev.h
lib/librte_ether/rte_ether_version.map

index 58aaeb2..56b97cc 100644 (file)
@@ -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;
+}
index 7cf4af8..4f7b64b 100644 (file)
@@ -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
index 7b04e95..9149aa7 100644 (file)
@@ -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;