[RFC,v3,06/26] examples/ethtool: prefer device name
Commit Message
Rely on the generic device name rather than restrict to only supporting
PCI devices.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
examples/ethtool/lib/rte_ethtool.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
Comments
On Thu, Jul 28, 2022 at 05:26:20PM +0200, David Marchand wrote:
> Rely on the generic device name rather than restrict to only supporting
> PCI devices.
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> examples/ethtool/lib/rte_ethtool.c | 17 ++---------------
> 1 file changed, 2 insertions(+), 15 deletions(-)
>
> diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
> index ffaad96498..88dc917b73 100644
> --- a/examples/ethtool/lib/rte_ethtool.c
> +++ b/examples/ethtool/lib/rte_ethtool.c
> @@ -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));
>
Does the bus_info field need to be renamed now? It seems strange coping a
device name to a bus info field.
On Thu, Jul 28, 2022 at 6:32 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> On Thu, Jul 28, 2022 at 05:26:20PM +0200, David Marchand wrote:
> > Rely on the generic device name rather than restrict to only supporting
> > PCI devices.
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> > examples/ethtool/lib/rte_ethtool.c | 17 ++---------------
> > 1 file changed, 2 insertions(+), 15 deletions(-)
> >
> > diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
> > index ffaad96498..88dc917b73 100644
> > --- a/examples/ethtool/lib/rte_ethtool.c
> > +++ b/examples/ethtool/lib/rte_ethtool.c
> > @@ -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));
> >
>
> Does the bus_info field need to be renamed now? It seems strange coping a
> device name to a bus info field.
This bus_info name in the example is copied from ethtool.
So maybe it is the other way, and I should rename the new field I
added in rte_device..
@@ -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(®_info, 0, sizeof(reg_info));
rte_eth_dev_get_reg_info(port_id, ®_info);