[dpdk-dev,05/10] linuxapp/eal: detect iova mode

Message ID 20170608110513.22548-6-santosh.shukla@caviumnetworks.com (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Santosh Shukla June 8, 2017, 11:05 a.m. UTC
  - Moving late bus scanning to up..just after eal_parsing.
- Detect iova mapping mode based on user provided eal option
  (rte_eal_iova_mode) and result of rte_bus_scan_iommu_class.

Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 lib/librte_eal/linuxapp/eal/eal.c               | 24 ++++++++++++++++++------
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 2 files changed, 19 insertions(+), 6 deletions(-)
  

Comments

Hemant Agrawal July 5, 2017, 1:17 p.m. UTC | #1
On 6/8/2017 4:35 PM, Santosh Shukla wrote:
> - Moving late bus scanning to up..just after eal_parsing.
> - Detect iova mapping mode based on user provided eal option
>   (rte_eal_iova_mode) and result of rte_bus_scan_iommu_class.
>
> Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  lib/librte_eal/linuxapp/eal/eal.c               | 24 ++++++++++++++++++------
>  lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
>  2 files changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
> index 7c78f2dc2..54f42d752 100644
> --- a/lib/librte_eal/linuxapp/eal/eal.c
> +++ b/lib/librte_eal/linuxapp/eal/eal.c
> @@ -122,6 +122,13 @@ struct internal_config internal_config;
>  /* used by rte_rdtsc() */
>  int rte_cycles_vmware_tsc_map;
>
> +/* Get the iova mode */
> +enum rte_iova_mode
> +rte_eal_iova_mode(void)
> +{
> +	return internal_config.iova_mode;
> +}
> +
>  /* Return a pointer to the configuration structure */
>  struct rte_config *
>  rte_eal_get_configuration(void)
> @@ -793,6 +800,17 @@ rte_eal_init(int argc, char **argv)
>  		return -1;
>  	}
>
> +	if (rte_bus_scan()) {
> +		rte_eal_init_alert("Cannot scan the buses for devices\n");
> +		rte_errno = ENODEV;
> +		return -1;
> +	}
> +

The bus scanning includes allocating memory for the devices. It can not 
be moved so early.

I am still testing it out.

> +	if (rte_eal_iova_mode() == RTE_IOVA_VA &&
> +	    rte_bus_get_iommu_class() == RTE_IOVA_VA) {
> +		internal_config.iova_mode = RTE_IOVA_VA;
> +	}
> +
>  	if (internal_config.no_hugetlbfs == 0 &&
>  			internal_config.process_type != RTE_PROC_SECONDARY &&
>  			internal_config.xen_dom0_support == 0 &&
> @@ -890,12 +908,6 @@ rte_eal_init(int argc, char **argv)
>  		return -1;
>  	}
>
> -	if (rte_bus_scan()) {
> -		rte_eal_init_alert("Cannot scan the buses for devices\n");
> -		rte_errno = ENODEV;
> -		return -1;
> -	}
> -
>  	RTE_LCORE_FOREACH_SLAVE(i) {
>
>  		/*
> diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> index 6c016c82e..79b005036 100644
> --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> @@ -204,5 +204,6 @@ DPDK_17.08 {
>
>  	rte_pci_get_iommu_class;
>  	rte_bus_get_iommu_class;
> +	rte_eal_iova_mode;
>
>  } DPDK_17.05;
>
  
Santosh Shukla July 5, 2017, 1:49 p.m. UTC | #2
Hi Hemant,

On Wednesday 05 July 2017 06:47 PM, Hemant Agrawal wrote:

> On 6/8/2017 4:35 PM, Santosh Shukla wrote:
>> - Moving late bus scanning to up..just after eal_parsing.
>> - Detect iova mapping mode based on user provided eal option
>>   (rte_eal_iova_mode) and result of rte_bus_scan_iommu_class.
>>
>> Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
>> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
>> ---
>>  lib/librte_eal/linuxapp/eal/eal.c               | 24 ++++++++++++++++++------
>>  lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
>>  2 files changed, 19 insertions(+), 6 deletions(-)
>>
>> diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
>> index 7c78f2dc2..54f42d752 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal.c
>> @@ -122,6 +122,13 @@ struct internal_config internal_config;
>>  /* used by rte_rdtsc() */
>>  int rte_cycles_vmware_tsc_map;
>>
>> +/* Get the iova mode */
>> +enum rte_iova_mode
>> +rte_eal_iova_mode(void)
>> +{
>> +    return internal_config.iova_mode;
>> +}
>> +
>>  /* Return a pointer to the configuration structure */
>>  struct rte_config *
>>  rte_eal_get_configuration(void)
>> @@ -793,6 +800,17 @@ rte_eal_init(int argc, char **argv)
>>          return -1;
>>      }
>>
>> +    if (rte_bus_scan()) {
>> +        rte_eal_init_alert("Cannot scan the buses for devices\n");
>> +        rte_errno = ENODEV;
>> +        return -1;
>> +    }
>> +
>
> The bus scanning includes allocating memory for the devices. It can not be moved so early.
>
Right and that memory allocation is malloc based. I verified for same for pci_scan_one case.
Also looking at drivers/bus/fslmc/* , IIUC then your not calling rte_mem* api's at the time of
bus scanning, right? And you do dma_mapping at ethdev initialization time which is referring
to memseg, so afaict, prepositioning bus_scan at very early won't effect functionality.
 

> I am still testing it out.

Thanks for testing, Please share you feedback.
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 7c78f2dc2..54f42d752 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -122,6 +122,13 @@  struct internal_config internal_config;
 /* used by rte_rdtsc() */
 int rte_cycles_vmware_tsc_map;
 
+/* Get the iova mode */
+enum rte_iova_mode
+rte_eal_iova_mode(void)
+{
+	return internal_config.iova_mode;
+}
+
 /* Return a pointer to the configuration structure */
 struct rte_config *
 rte_eal_get_configuration(void)
@@ -793,6 +800,17 @@  rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	if (rte_bus_scan()) {
+		rte_eal_init_alert("Cannot scan the buses for devices\n");
+		rte_errno = ENODEV;
+		return -1;
+	}
+
+	if (rte_eal_iova_mode() == RTE_IOVA_VA &&
+	    rte_bus_get_iommu_class() == RTE_IOVA_VA) {
+		internal_config.iova_mode = RTE_IOVA_VA;
+	}
+
 	if (internal_config.no_hugetlbfs == 0 &&
 			internal_config.process_type != RTE_PROC_SECONDARY &&
 			internal_config.xen_dom0_support == 0 &&
@@ -890,12 +908,6 @@  rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	if (rte_bus_scan()) {
-		rte_eal_init_alert("Cannot scan the buses for devices\n");
-		rte_errno = ENODEV;
-		return -1;
-	}
-
 	RTE_LCORE_FOREACH_SLAVE(i) {
 
 		/*
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 6c016c82e..79b005036 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -204,5 +204,6 @@  DPDK_17.08 {
 
 	rte_pci_get_iommu_class;
 	rte_bus_get_iommu_class;
+	rte_eal_iova_mode;
 
 } DPDK_17.05;