dev: introduce driver accessors

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>
This commit is contained in:
David Marchand 2022-07-28 17:26:36 +02:00
parent a04322f616
commit 97bbdba31d
5 changed files with 26 additions and 2 deletions

View File

@ -656,7 +656,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);

View File

@ -20,6 +20,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.
*

View File

@ -76,6 +76,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

View File

@ -424,6 +424,9 @@ EXPERIMENTAL {
rte_thread_self;
rte_thread_set_affinity_by_id;
rte_thread_set_priority;
# added in 22.11
rte_driver_name;
};
INTERNAL {

View File

@ -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