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