Blame SOURCES/0001-net-nfp-avoid-sysfs-resource-file-access.patch

702481
From b742910272bb95daf42ab449c1077afa4aa79142 Mon Sep 17 00:00:00 2001
702481
From: Alejandro Lucero <alejandro.lucero@netronome.com>
702481
Date: Tue, 26 Jun 2018 14:25:40 +0100
702481
Subject: [PATCH 1/2] net/nfp: avoid sysfs resource file access
702481
702481
Getting the bar size is required for NFP CPP interface configuration.
702481
However, this information can be obtained from the VFIO or UIO driver
702481
instead of accessing the sysfs resource file.
702481
702481
Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
702481
(cherry picked from commit e3cfaf02dcd88635ac614a1e1a8efe45d38ea4c9)
702481
---
702481
 drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 28 +++++-----------------
702481
 1 file changed, 6 insertions(+), 22 deletions(-)
702481
702481
diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
702481
index 7d132baa9..9accc89cf 100644
702481
--- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
702481
+++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
702481
@@ -761,32 +761,16 @@ nfp6000_set_serial(struct rte_pci_device *dev, struct nfp_cpp *cpp)
702481
 }
702481
 
702481
 static int
702481
-nfp6000_set_barsz(struct nfp_pcie_user *desc)
702481
+nfp6000_set_barsz(struct rte_pci_device *dev, struct nfp_pcie_user *desc)
702481
 {
702481
-	char tmp_str[80];
702481
-	unsigned long start, end, flags, tmp;
702481
-	int i;
702481
-	FILE *fp;
702481
-
702481
-	snprintf(tmp_str, sizeof(tmp_str), "%s/%s/resource", PCI_DEVICES,
702481
-		 desc->busdev);
702481
-
702481
-	fp = fopen(tmp_str, "r");
702481
-	if (!fp)
702481
-		return -1;
702481
+	unsigned long tmp;
702481
+	int i = 0;
702481
 
702481
-	if (fscanf(fp, "0x%lx 0x%lx 0x%lx", &start, &end, &flags) == 0) {
702481
-		printf("error reading resource file for bar size\n");
702481
-		return -1;
702481
-	}
702481
+	tmp = dev->mem_resource[0].len;
702481
 
702481
-	if (fclose(fp) == -1)
702481
-		return -1;
702481
-
702481
-	tmp = (end - start) + 1;
702481
-	i = 0;
702481
 	while (tmp >>= 1)
702481
 		i++;
702481
+
702481
 	desc->barsz = i;
702481
 	return 0;
702481
 }
702481
@@ -839,7 +823,7 @@ nfp6000_init(struct nfp_cpp *cpp, struct rte_pci_device *dev)
702481
 		return -1;
702481
 	if (nfp6000_set_serial(dev, cpp) < 0)
702481
 		return -1;
702481
-	if (nfp6000_set_barsz(desc) < 0)
702481
+	if (nfp6000_set_barsz(dev, desc) < 0)
702481
 		return -1;
702481
 
702481
 	desc->cfg = (char *)mmap(0, 1 << (desc->barsz - 3),
702481
-- 
702481
2.17.1
702481