From: <eagostini@nvidia.com>
To: <dev@dpdk.org>
Cc: <stable@dpdk.org>, <thomas@monjalon.net>,
<david.marchand@redhat.com>, <bingz@nvidia.com>,
Elena Agostini <eagostini@nvidia.com>
Subject: [PATCH v1] bus/pci: get PCI address from rte_device
Date: Tue, 30 May 2023 11:42:02 +0000 [thread overview]
Message-ID: <20230530114202.850814-1-eagostini@nvidia.com> (raw)
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
next reply other threads:[~2023-05-30 11:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 11:42 eagostini [this message]
2023-05-30 13:47 ` Thomas Monjalon
2023-05-31 8:03 ` David Marchand
2023-05-31 8:44 ` Elena Agostini
2023-05-31 8:47 ` David Marchand
2023-05-31 8:51 ` Elena Agostini
2023-05-31 9:52 ` David Marchand
2023-10-18 11:00 ` David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230530114202.850814-1-eagostini@nvidia.com \
--to=eagostini@nvidia.com \
--cc=bingz@nvidia.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).