diff mbox series

[v2,3/7] examples/ethtool: use PCI library API to get PCI address

Message ID 20210918022443.12719-4-chenbo.xia@intel.com (mailing list archive)
State New
Delegated to: David Marchand
Headers show
Series Removal of PCI bus ABIs | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Xia, Chenbo Sept. 18, 2021, 2:24 a.m. UTC
Currently ethtool example uses struct rte_pci_device to know PCI
address of a device. As this API will be removed later in PCI bus,
this patch uses PCI library API to get the PCI address.

Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
---
 examples/ethtool/lib/rte_ethtool.c | 14 +++++++++-----
 examples/ethtool/meson.build       |  2 +-
 2 files changed, 10 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index 4132516307..89727c9f72 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -8,7 +8,7 @@ 
 #include <rte_version.h>
 #include <rte_ethdev.h>
 #include <rte_ether.h>
-#include <rte_bus_pci.h>
+#include <rte_pci.h>
 #ifdef RTE_NET_IXGBE
 #include <rte_pmd_ixgbe.h>
 #endif
@@ -23,8 +23,9 @@  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;
+	char name[RTE_ETH_NAME_MAX_LEN];
+	struct rte_pci_addr addr;
 	int n;
 	int ret;
 
@@ -56,11 +57,14 @@  rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo)
 	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);
+		rte_eth_dev_get_name_by_port(port_id, name);
+		if (rte_pci_addr_parse(name, &addr)) {
+			printf("Failed to parse pci address\n");
+			return -1;
+		}
 		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);
+			addr.domain, addr.bus, addr.devid, addr.function);
 	} else {
 		snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), "N/A");
 	}
diff --git a/examples/ethtool/meson.build b/examples/ethtool/meson.build
index d7f63d48af..c2dbf8ae5a 100644
--- a/examples/ethtool/meson.build
+++ b/examples/ethtool/meson.build
@@ -18,7 +18,7 @@  sources = files(
 )
 includes = include_directories('lib', 'ethtool-app')
 
-deps += 'bus_pci'
+deps += 'pci'
 if dpdk_conf.has('RTE_NET_IXGBE')
     deps += 'net_ixgbe'
 endif