From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5233EA0C47; Sat, 18 Sep 2021 04:39:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1F80E410FE; Sat, 18 Sep 2021 04:39:15 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 9AEE9410F6 for ; Sat, 18 Sep 2021 04:39:12 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10110"; a="222563601" X-IronPort-AV: E=Sophos;i="5.85,303,1624345200"; d="scan'208";a="222563601" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2021 19:39:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,303,1624345200"; d="scan'208";a="546751625" Received: from npg-dpdk-virtio-xiachenbo-nw.sh.intel.com ([10.67.119.53]) by FMSMGA003.fm.intel.com with ESMTP; 17 Sep 2021 19:39:11 -0700 From: Chenbo Xia To: dev@dpdk.org, david.marchand@redhat.com Date: Sat, 18 Sep 2021 10:24:39 +0800 Message-Id: <20210918022443.12719-4-chenbo.xia@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210918022443.12719-1-chenbo.xia@intel.com> References: <20210910022402.26620-1-chenbo.xia@intel.com> <20210918022443.12719-1-chenbo.xia@intel.com> Subject: [dpdk-dev] [PATCH v2 3/7] examples/ethtool: use PCI library API to get PCI address X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- examples/ethtool/lib/rte_ethtool.c | 14 +++++++++----- examples/ethtool/meson.build | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) 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 #include #include -#include +#include #ifdef RTE_NET_IXGBE #include #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 -- 2.17.1