[RFC,v3,22/26] dev: introduce driver accessors
Commit Message
Prepare for making the driver object opaque by adding accessors.
Update existing "external" users.
Internal users may still dereference a rte_driver object.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
app/test-pmd/config.c | 2 +-
lib/eal/common/eal_common_dev.c | 6 ++++++
lib/eal/include/rte_dev.h | 15 +++++++++++++++
lib/eal/version.map | 3 +++
lib/ethdev/rte_ethdev.h | 2 +-
5 files changed, 26 insertions(+), 2 deletions(-)
Comments
On Thu, Jul 28, 2022 at 05:26:36PM +0200, David Marchand wrote:
> Prepare for making the driver object opaque by adding accessors.
> Update existing "external" users.
> Internal users may still dereference a rte_driver object.
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
@@ -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);
@@ -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.
*
@@ -62,6 +62,21 @@ struct rte_driver {
const char *alias; /**< Driver alias. */
};
+/**
+ * Retrieve a driver name.
+ *
+ * @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
@@ -423,6 +423,9 @@ EXPERIMENTAL {
rte_thread_self;
rte_thread_set_affinity_by_id;
rte_thread_set_priority;
+
+ # added in 22.11
+ rte_driver_name;
};
INTERNAL {
@@ -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