DPDK patches and discussions
 help / color / mirror / Atom feed
From: Alejandro Lucero <alejandro.lucero@netronome.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] net/nfp: avoid sysfs resource file access
Date: Tue, 26 Jun 2018 14:25:40 +0100	[thread overview]
Message-ID: <1530019540-27680-1-git-send-email-alejandro.lucero@netronome.com> (raw)

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 <alejandro.lucero@netronome.com>
---
 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

             reply	other threads:[~2018-06-26 13:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-26 13:25 Alejandro Lucero [this message]
2018-06-27 14:27 ` Ferruh Yigit
2018-06-27 14:31   ` Ferruh Yigit
2018-06-27 14:56 ` Ferruh Yigit
2018-06-27 15:15   ` Alejandro Lucero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1530019540-27680-1-git-send-email-alejandro.lucero@netronome.com \
    --to=alejandro.lucero@netronome.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).