Skip to contentSkip to conversation

eal_pci: Fix max_vfs missing for none igb_uio driver

PATCH Superseded Michael Qiu 3 participants 11 messages Feb 11, 2015 – Feb 13, 2015 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal_pci: Fix max_vfs missing for none igb_uio driver

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.

---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/linuxapp/eal/eal_pci.c +1 -1
index 1f43688..3da4b69 100644
@@ -305,7 +305,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 
 	/* get max_vfs */
 	dev->max_vfs = 0;
-	snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
+	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;
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1423653001-11660-1-git-send-email-michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw

Hello Michael,

Quoted 25 lines · 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.

---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/linuxapp/eal/eal_pci.c +1 -1
index 1f43688..3da4b69 100644
@@ -305,7 +305,7 @@ pci_scan_one(const char *dirname, uint16_t domain,
 uint8_t bus,
 
        /* get max_vfs */
        dev->max_vfs = 0;
-       snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
+       snprintf(filename, sizeof(filename), "%s/sriov_numvfs", dirname);
        if (!access(filename, F_OK) &&
            eal_parse_sysfs_value(filename, &tmp) == 0) {
Quoted 3 lines
                dev->max_vfs = (uint16_t)tmp;

Not too sure about this change.
Quickly looked, and as far as I can see, sriov_numvfs has been introduced by 1789382a ("PCI: SRIOV control and status via sysfs").

Won't your change break anything that uses a kernel < 3.8 (not backported) ?

Signature · 1 line
David Marchand
#3 lore raw
Quoted 35 lines · David Marchand

Hello Michael,

On Wed, Feb 11, 2015 at 12:10 PM, Michael Qiu <[email protected] <mailto:[email protected]>> 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 <[email protected]
    <mailto:[email protected]>>
    ---
     lib/librte_eal/linuxapp/eal/eal_pci.c | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c
    b/lib/librte_eal/linuxapp/eal/eal_pci.c
    index 1f43688..3da4b69 100644
    --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
    +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
    @@ -305,7 +305,7 @@ pci_scan_one(const char *dirname, uint16_t
    domain, uint8_t bus,

            /* get max_vfs */
            dev->max_vfs = 0;
    -       snprintf(filename, sizeof(filename), "%s/max_vfs", dirname);
    +       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;
Quoted 6 lines

Not too sure about this change.
Quickly looked, and as far as I can see, sriov_numvfs has been introduced by 1789382a ("PCI: SRIOV control and status via sysfs").

Won't your change break anything that uses a kernel < 3.8 (not backported) ?

OK, you are right, I will fix this in v2, actually it will break nothing as the code already done accessing check.

But not enough, for kernel version less than 3.8 and driver is igb_uio, it is indeed not suitable for leaving max_vfs zero.

BTW, for kernel version less than 3.8 and driver is vfio or pci_uio_generic, how could we fill this field?

Thanks,
Michael

Quoted 4 lines
Signature · 2 lines
-- 
David Marchand
#4 lore raw

PATCH v2 1/1 eal_pci: Fix max_vfs missing for none igb_uio driver

In reply to a message not in the archive

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.

---
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(-)
lib/librte_eal/linuxapp/eal/eal_pci.c +9 -1
index b5f5410..fcf5511 100644
@@ -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 */
Signature · 1 line
1.9.3
#5 lore raw

[+cc] David

Quoted 36 lines · Michael

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.

---
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(-)
lib/librte_eal/linuxapp/eal/eal_pci.c +9 -1
index b5f5410..fcf5511 100644
@@ -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 */

A message that is not in the archive (sent off-list or not yet received): 1423661155-16645-1-git-send-email-michael.qiu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#7 lore raw
Quoted 37 lines · 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.

---
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(-)
lib/librte_eal/linuxapp/eal/eal_pci.c +9 -1
index b5f5410..fcf5511 100644
@@ -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;
        }
 
Quoted 2 lines
        /* 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).

Signature · 1 line
David Marchand
#8 lore raw
Quoted 41 lines · David Marchand

On Wed, Feb 11, 2015 at 2:25 PM, Michael Qiu <[email protected] <mailto:[email protected]>> 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.

<mailto:[email protected]>>
---
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;
}

Quoted 6 lines

/* 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.

Quoted 6 lines

But your solution is more straightforward (and we don't need to update documentation and/or existing scripts afaik).

<mailto:[email protected]>>

Thanks David for reviewing this patch and your good comments

Thanks,
Michale

Quoted 2 lines
Signature · 1 line
David Marchand

A message that is not in the archive (sent off-list or not yet received): CALwxeUsGP-GOi7buBhaj3B4c67=w413=LqPTJ7G1VVGbdQf4-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#10 lore raw
Quoted 8 lines
Quoted 7 lines

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.

Quoted 7 lines

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

Applied, thanks

#11 lore raw
In reply to a message not in the archive

2015-02-11 21:25, Michael Qiu:

Quoted 7 lines

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.

[...]

lib/librte_eal/linuxapp/eal/eal_pci.c pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, · line 278

Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +3 -1
 	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"?

Quoted 10 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +6 -0
+		 * 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 */
#12 lore raw
Quoted 9 lines · Thomas Monjalon

2015-02-11 21:25, Michael Qiu:

Quoted 7 lines

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.

[...]

Quoted 8 lines

lib/librte_eal/linuxapp/eal/eal_pci.c pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, · line 278

Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +3 -1
 	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

Quoted 12 lines
Quoted 11 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +6 -0
+		 * 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 */

A message that is not in the archive (sent off-list or not yet received): 533710CFB86FA344BFBF2D6802E60286CE8F2C-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org

#14 lore raw

2015-02-13 02:56, Qiu, Michael:

Quoted 19 lines · Thomas Monjalon
Quoted 9 lines

2015-02-11 21:25, Michael Qiu:

Quoted 7 lines

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.

[...]

Quoted 8 lines

lib/librte_eal/linuxapp/eal/eal_pci.c pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, · line 278

Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_pci.c +3 -1
 	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"?

Quoted 5 lines

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.