[v6,25/27] dev: provide bus specific information

Message ID 20220914075841.51555-26-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series Bus and device cleanup for 22.11 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand Sept. 14, 2022, 7:58 a.m. UTC
  For diagnostic, it may be useful to provide a description of the device
with bus specific information.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
Changes since RFC v3:
- split patch in two, as per Thomas offlist request,

---
 app/test-pmd/config.c           |  2 ++
 lib/eal/common/eal_common_dev.c |  6 ++++++
 lib/eal/include/rte_dev.h       | 16 ++++++++++++++++
 lib/eal/version.map             |  1 +
 4 files changed, 25 insertions(+)
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index de74690f06..c5e5a66fa4 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -654,6 +654,8 @@  device_infos_display(const char *identifier)
 			printf("\n%s Infos for device %s %s\n",
 			       info_border, rte_dev_name(dev), info_border);
 			printf("Bus name: %s", rte_bus_name(rte_dev_bus(dev)));
+			printf("\nBus information: %s",
+				rte_dev_bus_info(dev) ? rte_dev_bus_info(dev) : "");
 			printf("\nDriver name: %s", rte_driver_name(rte_dev_driver(dev)));
 			printf("\nDevargs: %s",
 			       rte_dev_devargs(dev) ? rte_dev_devargs(dev)->args : "");
diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c
index 7b12d6e531..a190bd37af 100644
--- a/lib/eal/common/eal_common_dev.c
+++ b/lib/eal/common/eal_common_dev.c
@@ -31,6 +31,12 @@  rte_dev_bus(const struct rte_device *dev)
 	return dev->bus;
 }
 
+const char *
+rte_dev_bus_info(const struct rte_device *dev)
+{
+	return dev->bus_info;
+}
+
 const struct rte_devargs *
 rte_dev_devargs(const struct rte_device *dev)
 {
diff --git a/lib/eal/include/rte_dev.h b/lib/eal/include/rte_dev.h
index ce97ee1086..f010dd6441 100644
--- a/lib/eal/include/rte_dev.h
+++ b/lib/eal/include/rte_dev.h
@@ -98,6 +98,21 @@  __rte_experimental
 const struct rte_bus *
 rte_dev_bus(const struct rte_device *dev);
 
+/**
+ * Retrieve bus specific information for a device.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * @param dev
+ *   A pointer to a device structure.
+ * @return
+ *   A string describing this device or NULL if none is available.
+ */
+__rte_experimental
+const char *
+rte_dev_bus_info(const struct rte_device *dev);
+
 /**
  * Retrieve a device arguments.
  *
@@ -170,6 +185,7 @@  rte_dev_numa_node(const struct rte_device *dev);
 struct rte_device {
 	RTE_TAILQ_ENTRY(rte_device) next; /**< Next device */
 	const char *name;             /**< Device name */
+	const char *bus_info;         /**< Device bus specific information */
 	const struct rte_driver *driver; /**< Driver assigned after probing */
 	const struct rte_bus *bus;    /**< Bus handle assigned on scan */
 	int numa_node;                /**< NUMA node connection */
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 719789b8d1..0cf321605e 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -427,6 +427,7 @@  EXPERIMENTAL {
 
 	# added in 22.11
 	rte_dev_bus;
+	rte_dev_bus_info;
 	rte_dev_devargs;
 	rte_dev_driver;
 	rte_dev_name;