[PATCH v1] bus/pci: get PCI address from rte_device
eagostini at nvidia.com
eagostini at nvidia.com
Tue May 30 13:42:02 CEST 2023
From: Elena Agostini <eagostini at nvidia.com>
In DPDK 22.11 pci bus related structure have been hidden internally
so the application doesn't have a direct access to those info anymore.
This patch introduces a get function to retrieve a PCI address
from an rte_device handler.
Signed-off-by: Elena Agostini <eagostini at nvidia.com>
---
drivers/bus/pci/pci_common.c | 15 +++++++++++++++
drivers/bus/pci/rte_bus_pci.h | 13 +++++++++++++
2 files changed, 28 insertions(+)
diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index e32a9d517a..9ab5256543 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -884,6 +884,21 @@ rte_pci_set_bus_master(struct rte_pci_device *dev, bool enable)
return 0;
}
+const struct rte_pci_addr *
+rte_pci_get_addr(const struct rte_device *dev)
+{
+ const struct rte_pci_device *pci_dev;
+
+ if (!dev) {
+ rte_errno = EINVAL;
+ return NULL;
+ }
+
+ pci_dev = RTE_DEV_TO_PCI_CONST(dev);
+
+ return &pci_dev->addr;
+}
+
struct rte_pci_bus rte_pci_bus = {
.bus = {
.scan = rte_pci_scan,
diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h
index b193114fe5..e18ddb7fd7 100644
--- a/drivers/bus/pci/rte_bus_pci.h
+++ b/drivers/bus/pci/rte_bus_pci.h
@@ -68,6 +68,19 @@ void rte_pci_unmap_device(struct rte_pci_device *dev);
*/
void rte_pci_dump(FILE *f);
+/**
+ * Return PCI device address of an rte_device
+ *
+ * @param dev
+ * A pointer to a rte_device structure describing the device
+ * to use
+ *
+ * @return
+ * PCI address of the device on success, NULL if no driver
+ * is found for the device.
+ */
+const struct rte_pci_addr * rte_pci_get_addr(const struct rte_device *dev);
+
/**
* Find device's extended PCI capability.
*
--
2.34.1
More information about the dev
mailing list