pci: fix max VFs for non igb_uio drivers
authorMichael Qiu <michael.qiu@intel.com>
Wed, 11 Feb 2015 13:25:55 +0000 (21:25 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 13 Feb 2015 13:48:16 +0000 (14:48 +0100)
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>
Acked-by: David Marchand <david.marchand@6wind.com>
lib/librte_eal/linuxapp/eal/eal_pci.c

index b5f5410..15db9c4 100644 (file)
@@ -272,8 +272,15 @@ 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 non igb_uio driver, need kernel version >= 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 */