[dpdk-dev] [PATCH v8 01/11] librte_ether: add fields from rte_pci_driver to rte_eth_dev_data

Bernard Iremonger bernard.iremonger at intel.com
Tue Nov 3 14:01:55 CET 2015


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
remove branches on pci_dev

librte_eal: add RTE_KDRV_NONE for vdevs

Signed-off-by: Bernard Iremonger <bernard.iremonger at intel.com>
---
 lib/librte_eal/common/include/rte_pci.h |  3 ++-
 lib/librte_ether/rte_ethdev.c           | 24 ++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 27 +++++++++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map  |  1 +
 4 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 83e3c28..334c12e 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -149,6 +149,7 @@ enum rte_kernel_driver {
 	RTE_KDRV_VFIO,
 	RTE_KDRV_UIO_GENERIC,
 	RTE_KDRV_NIC_UIO,
+	RTE_KDRV_NONE,
 };
 
 /**
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 39f65bf..04eff73 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3229,3 +3229,27 @@ 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_NEED_MAPPING)
+		eth_dev->data->dev_flags |= RTE_ETH_DEV_DRV_NEED_MAPPING;
+	if (pci_dev->driver->drv_flags &  RTE_PCI_DRV_FORCE_UNBIND)
+		eth_dev->data->dev_flags |= RTE_ETH_DEV_DRV_FORCE_UNBIND;
+	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 c835a2f..2e5b9b8 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1551,8 +1551,21 @@ 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; /**< Flags controlling handling of device. */
+	enum rte_kernel_driver kdrv;    /**< Kernel driver passthrough */
+	int numa_node;  /**< NUMA node connection */
+	const char *drv_name;   /**< Driver name */
 };
 
+/** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */
+#define RTE_ETH_DEV_DRV_NEED_MAPPING 0x0001
+/** Device needs to be unbound even if no module is provided */
+#define RTE_ETH_DEV_DRV_FORCE_UNBIND 0x0002
+/** Device supports link state interrupt */
+#define RTE_ETH_DEV_INTR_LSC 0x0003
+/** Device  supports detaching capability */
+#define RTE_ETH_DEV_DETACHABLE 0x0004
+
 /**
  * @internal
  * The pool of *rte_eth_dev* structures. The size of the pool
@@ -3733,6 +3746,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 7b04e95..08c97f4 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -134,5 +134,6 @@ DPDK_2.2 {
 	rte_eth_dev_get_dcb_info;
 	rte_eth_rx_queue_info_get;
 	rte_eth_tx_queue_info_get;
+	rte_eth_copy_pci_info;
 
 } DPDK_2.1;
-- 
1.9.1



More information about the dev mailing list