bus/pci: fix probing for non-netuio bound devices

Message ID 20210210014008.11112-1-pallavi.kadam@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series bus/pci: fix probing for non-netuio bound devices |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-mellanox-Functional success Functional Testing PASS
ci/checkpatch success coding style OK

Commit Message

Kadam, Pallavi Feb. 10, 2021, 1:40 a.m. UTC
  Implement rte_pci_map_device() to distinguish between the devices bound
to netuio and NDIS devices.
Only return success for the netuio devices.

Suggested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
 drivers/bus/pci/windows/pci.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
  

Comments

Tal Shnaiderman Feb. 10, 2021, 6 a.m. UTC | #1
> Subject: [PATCH] bus/pci: fix probing for non-netuio bound devices
> 
> External email: Use caution opening links or attachments
> 
> 
> Implement rte_pci_map_device() to distinguish between the devices bound
> to netuio and NDIS devices.
> Only return success for the netuio devices.
> 
> Suggested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
>  drivers/bus/pci/windows/pci.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
> index f66258452..16edaa769 100644
> --- a/drivers/bus/pci/windows/pci.c
> +++ b/drivers/bus/pci/windows/pci.c
> @@ -23,20 +23,19 @@
> DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40,
> 0x45bc,
>   * the registry hive for PCI devices.
>   */
> 
> -/* The functions below are not implemented on Windows,
> +/* Some of the functions below are not implemented on Windows,
>   * but need to be defined for compilation purposes
>   */
> 
>  /* Map pci device */
>  int
> -rte_pci_map_device(struct rte_pci_device *dev __rte_unused)
> +rte_pci_map_device(struct rte_pci_device *dev)
>  {
> -       /* This function is not implemented on Windows.
> -        * We really should short-circuit the call to these functions by
> -        * clearing the RTE_PCI_DRV_NEED_MAPPING flag
> -        * in the rte_pci_driver flags.
> -        */
> -       return 0;
> +       /* Only return success for devices bound to netuio */

Maybe extend this comment to mention where the mapping is actually done?

> +       if (dev->kdrv == RTE_PCI_KDRV_NIC_UIO)
> +               return 0;
> +       else
> +               return -EINVAL;	

The function should return -1 here to match the behavior with other OS implementations.

>  }
> 
>  /* Unmap pci device */
> --
> 2.18.0.windows.1
  
Kadam, Pallavi Feb. 10, 2021, 8:47 p.m. UTC | #2
On 2/9/2021 10:00 PM, Tal Shnaiderman wrote:
>> Subject: [PATCH] bus/pci: fix probing for non-netuio bound devices
>>
>> External email: Use caution opening links or attachments
>>
>>
>> Implement rte_pci_map_device() to distinguish between the devices bound
>> to netuio and NDIS devices.
>> Only return success for the netuio devices.
>>
>> Suggested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
>> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
>> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
>> ---
>>   drivers/bus/pci/windows/pci.c | 15 +++++++--------
>>   1 file changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
>> index f66258452..16edaa769 100644
>> --- a/drivers/bus/pci/windows/pci.c
>> +++ b/drivers/bus/pci/windows/pci.c
>> @@ -23,20 +23,19 @@
>> DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40,
>> 0x45bc,
>>    * the registry hive for PCI devices.
>>    */
>>
>> -/* The functions below are not implemented on Windows,
>> +/* Some of the functions below are not implemented on Windows,
>>    * but need to be defined for compilation purposes
>>    */
>>
>>   /* Map pci device */
>>   int
>> -rte_pci_map_device(struct rte_pci_device *dev __rte_unused)
>> +rte_pci_map_device(struct rte_pci_device *dev)
>>   {
>> -       /* This function is not implemented on Windows.
>> -        * We really should short-circuit the call to these functions by
>> -        * clearing the RTE_PCI_DRV_NEED_MAPPING flag
>> -        * in the rte_pci_driver flags.
>> -        */
>> -       return 0;
>> +       /* Only return success for devices bound to netuio */
> Maybe extend this comment to mention where the mapping is actually done?

Modified the comment in v2.

>
>> +       if (dev->kdrv == RTE_PCI_KDRV_NIC_UIO)
>> +               return 0;
>> +       else
>> +               return -EINVAL;	
> The function should return -1 here to match the behavior with other OS implementations.

Replaced the return value in v2.

Thanks.

>
>>   }
>>
>>   /* Unmap pci device */
>> --
>> 2.18.0.windows.1
  
Narcisa Ana Maria Vasile March 5, 2021, 2:02 a.m. UTC | #3
On Tue, Feb 09, 2021 at 05:40:08PM -0800, Pallavi Kadam wrote:
> Implement rte_pci_map_device() to distinguish between the devices bound
> to netuio and NDIS devices.
> Only return success for the netuio devices.
> 
> Suggested-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> ---
>  drivers/bus/pci/windows/pci.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c

Tested-by: Narcisa Vasile <navasile@linux.microsoft.com>
Acked-by: Narcisa Vasile <navasile@linux.microsoft.com>
  

Patch

diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c
index f66258452..16edaa769 100644
--- a/drivers/bus/pci/windows/pci.c
+++ b/drivers/bus/pci/windows/pci.c
@@ -23,20 +23,19 @@  DEFINE_DEVPROPKEY(DEVPKEY_Device_Numa_Node, 0x540b947e, 0x8b40, 0x45bc,
  * the registry hive for PCI devices.
  */
 
-/* The functions below are not implemented on Windows,
+/* Some of the functions below are not implemented on Windows,
  * but need to be defined for compilation purposes
  */
 
 /* Map pci device */
 int
-rte_pci_map_device(struct rte_pci_device *dev __rte_unused)
+rte_pci_map_device(struct rte_pci_device *dev)
 {
-	/* This function is not implemented on Windows.
-	 * We really should short-circuit the call to these functions by
-	 * clearing the RTE_PCI_DRV_NEED_MAPPING flag
-	 * in the rte_pci_driver flags.
-	 */
-	return 0;
+	/* Only return success for devices bound to netuio */
+	if (dev->kdrv == RTE_PCI_KDRV_NIC_UIO)
+		return 0;
+	else
+		return -EINVAL;
 }
 
 /* Unmap pci device */