From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id 42CC51B5C5 for ; Tue, 26 Jun 2018 15:26:07 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w5QDPeNC027720 for ; Tue, 26 Jun 2018 14:25:40 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id w5QDPeBS027719 for dev@dpdk.org; Tue, 26 Jun 2018 14:25:40 +0100 From: Alejandro Lucero To: dev@dpdk.org Date: Tue, 26 Jun 2018 14:25:40 +0100 Message-Id: <1530019540-27680-1-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] net/nfp: avoid sysfs resource file access X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2018 13:26:07 -0000 Getting the bar size is required for NFP CPP interface configuration. However, this information can be obtained from the VFIO or UIO driver instead of accessing the sysfs resource file. Signed-off-by: Alejandro Lucero --- drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c index 2a1ec96..b0beb8d 100644 --- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c +++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c @@ -762,33 +762,16 @@ struct nfp6000_area_priv { } static int -nfp6000_set_barsz(struct nfp_pcie_user *desc) +nfp6000_set_barsz(struct rte_pci_device *dev, struct nfp_pcie_user *desc) { - char tmp_str[80]; - unsigned long start, end, flags, tmp; - int i; - FILE *fp; - - snprintf(tmp_str, sizeof(tmp_str), "%s/%s/resource", PCI_DEVICES, - desc->busdev); - - fp = fopen(tmp_str, "r"); - if (!fp) - return -1; + unsigned long tmp; + int i = 0; - if (fscanf(fp, "0x%lx 0x%lx 0x%lx", &start, &end, &flags) == 0) { - printf("error reading resource file for bar size\n"); - fclose(fp); - return -1; - } + tmp = dev->mem_resource[0].len; - if (fclose(fp) == -1) - return -1; - - tmp = (end - start) + 1; - i = 0; while (tmp >>= 1) i++; + desc->barsz = i; return 0; } -- 1.9.1