diff mbox

[dpdk-dev,v2] eal_pci: Fix max_vfs missing for none igb_uio driver

Message ID 1423661155-16645-1-git-send-email-michael.qiu@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Michael Qiu Feb. 11, 2015, 1:25 p.m. UTC
max_vfs will only be created by igb_uio driver, for other
drivers like vfio or pci_uio_generic, max_vfs will miss.

But sriov_numvfs is not driver related, just get the vf numbers
from that field.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
v2 --> v1:
	backport for kernel version less than 3.8

 lib/librte_eal/linuxapp/eal/eal_pci.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Michael Qiu Feb. 11, 2015, 1:27 p.m. UTC | #1
[+cc] David

On 2/11/2015 9:26 PM, Qiu, Michael wrote:
> max_vfs will only be created by igb_uio driver, for other
> drivers like vfio or pci_uio_generic, max_vfs will miss.
>
> But sriov_numvfs is not driver related, just get the vf numbers
> from that field.
>
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
> v2 --> v1:
> 	backport for kernel version less than 3.8
>
>  lib/librte_eal/linuxapp/eal/eal_pci.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index b5f5410..fcf5511 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -272,8 +272,16 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
>  	dev->max_vfs = 0;
>  	snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
>  	if (!access(filename, F_OK) &&
> -	    eal_parse_sysfs_value(filename, &tmp) == 0) {
> +	    eal_parse_sysfs_value(filename, &tmp) == 0)
>  		dev->max_vfs = (uint16_t)tmp;
> +	else {
> +		/* for none igb_uio driver, need kernel
> +		 * version greater than 3.8 */
> +		snprintf(filename, sizeof(filename),
> +			 "%s/sriov_numvfs", dirname);
> +		if (!access(filename, F_OK) &&
> +		    eal_parse_sysfs_value(filename, &tmp) == 0)
> +			dev->max_vfs = (uint16_t)tmp;
>  	}
>  
>  	/* get numa node */
David Marchand Feb. 12, 2015, 5:50 a.m. UTC | #2
On Wed, Feb 11, 2015 at 2:25 PM, Michael Qiu <michael.qiu@intel.com> wrote:

> max_vfs will only be created by igb_uio driver, for other
> drivers like vfio or pci_uio_generic, max_vfs will miss.
>
> But sriov_numvfs is not driver related, just get the vf numbers
> from that field.
>
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
> v2 --> v1:
>         backport for kernel version less than 3.8
>
>  lib/librte_eal/linuxapp/eal/eal_pci.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c
> b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index b5f5410..fcf5511 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -272,8 +272,16 @@ pci_scan_one(const char *dirname, uint16_t domain,
> uint8_t bus,
>         dev->max_vfs = 0;
>         snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
>         if (!access(filename, F_OK) &&
> -           eal_parse_sysfs_value(filename, &tmp) == 0) {
> +           eal_parse_sysfs_value(filename, &tmp) == 0)
>                 dev->max_vfs = (uint16_t)tmp;
> +       else {
> +               /* for none igb_uio driver, need kernel
> +                * version greater than 3.8 */
> +               snprintf(filename, sizeof(filename),
> +                        "%s/sriov_numvfs", dirname);
> +               if (!access(filename, F_OK) &&
> +                   eal_parse_sysfs_value(filename, &tmp) == 0)
> +                       dev->max_vfs = (uint16_t)tmp;
>         }
>
>         /* get numa node */
>

I can see a different solution : maybe faking a sriov_numvfs parameter from
igb_uio for kernels that don't have it and doing nothing for kernels that
already provide sriov_numvfs.
But your solution is more straightforward (and we don't need to update
documentation and/or existing scripts afaik).

Acked-by: David Marchand <david.marchand@6wind.com>
Thomas Monjalon Feb. 12, 2015, 4:25 p.m. UTC | #3
2015-02-11 21:25, Michael Qiu:
> max_vfs will only be created by igb_uio driver, for other
> drivers like vfio or pci_uio_generic, max_vfs will miss.
> 
> But sriov_numvfs is not driver related, just get the vf numbers
> from that field.
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
[...]
>  	snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
>  	if (!access(filename, F_OK) &&
> -	    eal_parse_sysfs_value(filename, &tmp) == 0) {
> +	    eal_parse_sysfs_value(filename, &tmp) == 0)
>  		dev->max_vfs = (uint16_t)tmp;
> +	else {
> +		/* for none igb_uio driver, need kernel

I think it's a typo. Do you mean "for non igb_uio driver"?

> +		 * version greater than 3.8 */
> +		snprintf(filename, sizeof(filename),
> +			 "%s/sriov_numvfs", dirname);
> +		if (!access(filename, F_OK) &&
> +		    eal_parse_sysfs_value(filename, &tmp) == 0)
> +			dev->max_vfs = (uint16_t)tmp;
>  	}
>  
>  	/* get numa node */
>
Michael Qiu Feb. 13, 2015, 2:56 a.m. UTC | #4
On 2/13/2015 12:26 AM, Thomas Monjalon wrote:
> 2015-02-11 21:25, Michael Qiu:
>> max_vfs will only be created by igb_uio driver, for other
>> drivers like vfio or pci_uio_generic, max_vfs will miss.
>>
>> But sriov_numvfs is not driver related, just get the vf numbers
>> from that field.
>>
>> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> [...]
>>  	snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
>>  	if (!access(filename, F_OK) &&
>> -	    eal_parse_sysfs_value(filename, &tmp) == 0) {
>> +	    eal_parse_sysfs_value(filename, &tmp) == 0)
>>  		dev->max_vfs = (uint16_t)tmp;
>> +	else {
>> +		/* for none igb_uio driver, need kernel
> I think it's a typo. Do you mean "for non igb_uio driver"?

Hi, Thomas

Yes, you are right.

Did I need to send out V3 patch for this typo?

Thanks,
Michael
>
>> +		 * version greater than 3.8 */
>> +		snprintf(filename, sizeof(filename),
>> +			 "%s/sriov_numvfs", dirname);
>> +		if (!access(filename, F_OK) &&
>> +		    eal_parse_sysfs_value(filename, &tmp) == 0)
>> +			dev->max_vfs = (uint16_t)tmp;
>>  	}
>>  
>>  	/* get numa node */
>>
>
Michael Qiu Feb. 13, 2015, 3:01 a.m. UTC | #5
On 2/12/2015 1:50 PM, David Marchand wrote:
> On Wed, Feb 11, 2015 at 2:25 PM, Michael Qiu <michael.qiu@intel.com
> <mailto:michael.qiu@intel.com>> wrote:
>
>     max_vfs will only be created by igb_uio driver, for other
>     drivers like vfio or pci_uio_generic, max_vfs will miss.
>
>     But sriov_numvfs is not driver related, just get the vf numbers
>     from that field.
>
>     Signed-off-by: Michael Qiu <michael.qiu@intel.com
>     <mailto:michael.qiu@intel.com>>
>     ---
>     v2 --> v1:
>             backport for kernel version less than 3.8
>
>      lib/librte_eal/linuxapp/eal/eal_pci.c | 10 +++++++++-
>      1 file changed, 9 insertions(+), 1 deletion(-)
>
>     diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c
>     b/lib/librte_eal/linuxapp/eal/eal_pci.c
>     index b5f5410..fcf5511 100644
>     --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
>     +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
>     @@ -272,8 +272,16 @@ pci_scan_one(const char *dirname, uint16_t
>     domain, uint8_t bus,
>             dev->max_vfs = 0;
>             snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
>             if (!access(filename, F_OK) &&
>     -           eal_parse_sysfs_value(filename, &tmp) == 0) {
>     +           eal_parse_sysfs_value(filename, &tmp) == 0)
>                     dev->max_vfs = (uint16_t)tmp;
>     +       else {
>     +               /* for none igb_uio driver, need kernel
>     +                * version greater than 3.8 */
>     +               snprintf(filename, sizeof(filename),
>     +                        "%s/sriov_numvfs", dirname);
>     +               if (!access(filename, F_OK) &&
>     +                   eal_parse_sysfs_value(filename, &tmp) == 0)
>     +                       dev->max_vfs = (uint16_t)tmp;
>             }
>
>             /* get numa node */
>
>
> I can see a different solution : maybe faking a sriov_numvfs parameter
> from igb_uio for kernels that don't have it and doing nothing for
> kernels that already provide sriov_numvfs.

Yes, your solution is much more better, but little complex. My solution
can be a quick fix.

> But your solution is more straightforward (and we don't need to update
> documentation and/or existing scripts afaik).
>
> Acked-by: David Marchand <david.marchand@6wind.com
> <mailto:david.marchand@6wind.com>>
>

Thanks David for reviewing this patch and your good comments

Thanks,
Michale
> -- 
> David Marchand
Thomas Monjalon Feb. 13, 2015, 9:20 a.m. UTC | #6
2015-02-13 02:56, Qiu, Michael:
> On 2/13/2015 12:26 AM, Thomas Monjalon wrote:
> > 2015-02-11 21:25, Michael Qiu:
> >> max_vfs will only be created by igb_uio driver, for other
> >> drivers like vfio or pci_uio_generic, max_vfs will miss.
> >>
> >> But sriov_numvfs is not driver related, just get the vf numbers
> >> from that field.
> >>
> >> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> > [...]
> >>  	snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
> >>  	if (!access(filename, F_OK) &&
> >> -	    eal_parse_sysfs_value(filename, &tmp) == 0) {
> >> +	    eal_parse_sysfs_value(filename, &tmp) == 0)
> >>  		dev->max_vfs = (uint16_t)tmp;
> >> +	else {
> >> +		/* for none igb_uio driver, need kernel
> > I think it's a typo. Do you mean "for non igb_uio driver"?
> 
> Hi, Thomas
> 
> Yes, you are right.
> 
> Did I need to send out V3 patch for this typo?

No, thanks. Your agreement is enough. I'll fix it.
Thomas Monjalon Feb. 13, 2015, 1:49 p.m. UTC | #7
> > max_vfs will only be created by igb_uio driver, for other
> > drivers like vfio or pci_uio_generic, max_vfs will miss.
> >
> > But sriov_numvfs is not driver related, just get the vf numbers
> > from that field.
> >
> > Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> 
> I can see a different solution : maybe faking a sriov_numvfs parameter from
> igb_uio for kernels that don't have it and doing nothing for kernels that
> already provide sriov_numvfs.
> But your solution is more straightforward (and we don't need to update
> documentation and/or existing scripts afaik).
> 
> Acked-by: David Marchand <david.marchand@6wind.com>

Applied, thanks
diff mbox

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index b5f5410..fcf5511 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -272,8 +272,16 @@  pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 	dev->max_vfs = 0;
 	snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
 	if (!access(filename, F_OK) &&
-	    eal_parse_sysfs_value(filename, &tmp) == 0) {
+	    eal_parse_sysfs_value(filename, &tmp) == 0)
 		dev->max_vfs = (uint16_t)tmp;
+	else {
+		/* for none igb_uio driver, need kernel
+		 * version greater than 3.8 */
+		snprintf(filename, sizeof(filename),
+			 "%s/sriov_numvfs", dirname);
+		if (!access(filename, F_OK) &&
+		    eal_parse_sysfs_value(filename, &tmp) == 0)
+			dev->max_vfs = (uint16_t)tmp;
 	}
 
 	/* get numa node */