patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH v1] bus/pci: get PCI address from rte_device
@ 2023-05-30 11:42 eagostini
  2023-05-30 13:47 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: eagostini @ 2023-05-30 11:42 UTC (permalink / raw)
  To: dev; +Cc: stable, thomas, david.marchand, bingz, Elena Agostini

From: Elena Agostini <eagostini@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@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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] bus/pci: get PCI address from rte_device
  2023-05-30 11:42 [PATCH v1] bus/pci: get PCI address from rte_device eagostini
@ 2023-05-30 13:47 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2023-05-30 13:47 UTC (permalink / raw)
  To: Elena Agostini; +Cc: dev, stable, david.marchand, bingz

30/05/2023 13:42, eagostini@nvidia.com:
> This patch introduces a get function to retrieve a PCI address
> from an rte_device handler.
[...]
> +const struct rte_pci_addr *
> +rte_pci_get_addr(const struct rte_device *dev)
> +{
> +	const struct rte_pci_device *pci_dev;
> +
> +	if (!dev) {

Please compare pointer with == NULL

> +		rte_errno = EINVAL;
> +		return NULL;
> +	}

Can we check the bus type here?

> +
> +	pci_dev = RTE_DEV_TO_PCI_CONST(dev);
> +
> +	return &pci_dev->addr;
> +}
[...]
> +/**
> + * Return PCI device address of an rte_device

You can replace rte_device with "generic device" and add a dot :)

> + *
> + * @param dev
> + *   A pointer to a rte_device structure describing the device
> + *   to use

Do it simpler: pointer to the generic device structure.

> + *
> + * @return
> + *   PCI address of the device on success, NULL if no driver
> + *   is found for the device.

Not exactly, it can return NULL if the device is not PCI.

> + */
> +const struct rte_pci_addr * rte_pci_get_addr(const struct rte_device *dev);




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-30 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30 11:42 [PATCH v1] bus/pci: get PCI address from rte_device eagostini
2023-05-30 13:47 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).