Add a helper to get a rte_driver object name.
This will be used externally.
Internal users may still dereference a rte_driver object.

Signed-off-by: David Marchand <david.march...@redhat.com>
---
 app/test-pmd/config.c           |  2 +-
 lib/eal/common/eal_common_dev.c |  6 ++++++
 lib/eal/include/rte_dev.h       | 13 +++++++++++++
 lib/eal/version.map             |  1 +
 lib/ethdev/rte_ethdev.h         |  2 +-
 5 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index bc154e8bf7..22aa086ef1 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -654,7 +654,7 @@ device_infos_display(const char *identifier)
                        printf("\n%s Infos for device %s %s\n",
                               info_border, dev->name, info_border);
                        printf("Bus name: %s", rte_bus_name(dev->bus));
-                       printf("\nDriver name: %s", dev->driver->name);
+                       printf("\nDriver name: %s", 
rte_driver_name(dev->driver));
                        printf("\nDevargs: %s",
                               dev->devargs ? dev->devargs->args : "");
                        printf("\nConnect to socket: %d", dev->numa_node);
diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c
index 62a598957c..16c5aef1d8 100644
--- a/lib/eal/common/eal_common_dev.c
+++ b/lib/eal/common/eal_common_dev.c
@@ -19,6 +19,12 @@
 #include "eal_private.h"
 #include "hotplug_mp.h"
 
+const char *
+rte_driver_name(const struct rte_driver *driver)
+{
+       return driver->name;
+}
+
 /**
  * The device event callback description.
  *
diff --git a/lib/eal/include/rte_dev.h b/lib/eal/include/rte_dev.h
index 24f9122558..871a046ffe 100644
--- a/lib/eal/include/rte_dev.h
+++ b/lib/eal/include/rte_dev.h
@@ -62,6 +62,19 @@ struct rte_driver {
        const char *alias;              /**< Driver alias. */
 };
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * @param driver
+ *   A pointer to a driver structure.
+ * @return
+ *   A pointer to the driver name string.
+ */
+__rte_experimental
+const char *
+rte_driver_name(const struct rte_driver *driver);
+
 /*
  * Internal identifier length
  * Sufficiently large to allow for UUID or PCI address
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 48c8a2f511..54f85ab01f 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -425,6 +425,7 @@ EXPERIMENTAL {
 
        # added in 22.11
        rte_bus_name;
+       rte_driver_name;
 };
 
 INTERNAL {
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index de9e970d4d..e9574f646f 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -3380,7 +3380,7 @@ int rte_eth_macaddrs_get(uint16_t port_id, struct 
rte_ether_addr *ma,
  * exists for the device and the rte_eth_dev 'dev' has been populated
  * successfully with a call to it:
  *
- * driver_name = dev->device->driver->name
+ * driver_name = rte_driver_name(dev->device->driver)
  * nb_rx_queues = dev->data->nb_rx_queues
  * nb_tx_queues = dev->data->nb_tx_queues
  * dev_flags = &dev->data->dev_flags
-- 
2.36.1

Reply via email to