DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/nfp: avoid sysfs resource file access
@ 2018-06-26 13:25 Alejandro Lucero
  2018-06-27 14:27 ` Ferruh Yigit
  2018-06-27 14:56 ` Ferruh Yigit
  0 siblings, 2 replies; 5+ messages in thread
From: Alejandro Lucero @ 2018-06-26 13:25 UTC (permalink / raw)
  To: dev

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] net/nfp: avoid sysfs resource file access
  2018-06-26 13:25 [dpdk-dev] [PATCH] net/nfp: avoid sysfs resource file access Alejandro Lucero
@ 2018-06-27 14:27 ` Ferruh Yigit
  2018-06-27 14:31   ` Ferruh Yigit
  2018-06-27 14:56 ` Ferruh Yigit
  1 sibling, 1 reply; 5+ messages in thread
From: Ferruh Yigit @ 2018-06-27 14:27 UTC (permalink / raw)
  To: Alejandro Lucero, dev

On 6/26/2018 2:25 PM, Alejandro Lucero wrote:
> 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)

Need to update caller of this function.

>  {
> -	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;
>  }
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] net/nfp: avoid sysfs resource file access
  2018-06-27 14:27 ` Ferruh Yigit
@ 2018-06-27 14:31   ` Ferruh Yigit
  0 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2018-06-27 14:31 UTC (permalink / raw)
  To: Alejandro Lucero, dev

On 6/27/2018 3:27 PM, Ferruh Yigit wrote:
> On 6/26/2018 2:25 PM, Alejandro Lucero wrote:
>> 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)
> 
> Need to update caller of this function.

I can see the that it has been modified in other patch [1], I will move the
change from other patch to here, please double check and confirm the final commits.

[1]
https://patches.dpdk.org/patch/41573/

> 
>>  {
>> -	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;
>>  }
>>
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] net/nfp: avoid sysfs resource file access
  2018-06-26 13:25 [dpdk-dev] [PATCH] net/nfp: avoid sysfs resource file access Alejandro Lucero
  2018-06-27 14:27 ` Ferruh Yigit
@ 2018-06-27 14:56 ` Ferruh Yigit
  2018-06-27 15:15   ` Alejandro Lucero
  1 sibling, 1 reply; 5+ messages in thread
From: Ferruh Yigit @ 2018-06-27 14:56 UTC (permalink / raw)
  To: Alejandro Lucero, dev

On 6/26/2018 2:25 PM, Alejandro Lucero wrote:
> 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>

Applied to dpdk-next-net/master, thanks.

(With applying commented change, please double check)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] net/nfp: avoid sysfs resource file access
  2018-06-27 14:56 ` Ferruh Yigit
@ 2018-06-27 15:15   ` Alejandro Lucero
  0 siblings, 0 replies; 5+ messages in thread
From: Alejandro Lucero @ 2018-06-27 15:15 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

On Wed, Jun 27, 2018 at 3:56 PM, Ferruh Yigit <ferruh.yigit@intel.com>
wrote:

> On 6/26/2018 2:25 PM, Alejandro Lucero wrote:
> > 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>
>
> Applied to dpdk-next-net/master, thanks.
>
> (With applying commented change, please double check)
>

Hi Ferruh,

Yes, that change seems good.

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-06-27 15:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-26 13:25 [dpdk-dev] [PATCH] net/nfp: avoid sysfs resource file access Alejandro Lucero
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

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).