examples/ethtool: prefer device name

Rely on the generic device name rather than restrict to only supporting
PCI devices.

Signed-off-by: David Marchand <david.marchand@redhat.com>
This commit is contained in:
David Marchand 2022-07-28 17:26:20 +02:00
parent 18bdf6ab8e
commit d589a8a8a7

View File

@ -8,7 +8,6 @@
#include <rte_version.h>
#include <rte_ethdev.h>
#include <rte_ether.h>
#include <rte_bus_pci.h>
#ifdef RTE_NET_IXGBE
#include <rte_pmd_ixgbe.h>
#endif
@ -23,8 +22,6 @@ rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo)
{
struct rte_eth_dev_info dev_info;
struct rte_dev_reg_info reg_info;
const struct rte_pci_device *pci_dev;
const struct rte_bus *bus = NULL;
int n;
int ret;
@ -52,18 +49,8 @@ rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo)
strlcpy(drvinfo->driver, dev_info.driver_name,
sizeof(drvinfo->driver));
strlcpy(drvinfo->version, rte_version(), sizeof(drvinfo->version));
/* TODO: replace bus_info by rte_devargs.name */
if (dev_info.device)
bus = rte_bus_find_by_device(dev_info.device);
if (bus && !strcmp(bus->name, "pci")) {
pci_dev = RTE_DEV_TO_PCI(dev_info.device);
snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info),
"%04x:%02x:%02x.%x",
pci_dev->addr.domain, pci_dev->addr.bus,
pci_dev->addr.devid, pci_dev->addr.function);
} else {
snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), "N/A");
}
strlcpy(drvinfo->bus_info, dev_info.device->name,
sizeof(drvinfo->bus_info));
memset(&reg_info, 0, sizeof(reg_info));
rte_eth_dev_get_reg_info(port_id, &reg_info);