net/mlx4: update link status upon probing with LSC
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal_pci.c
index 4350134..7d6f50a 100644 (file)
@@ -99,8 +99,10 @@ rte_eal_pci_map_device(struct rte_pci_device *dev)
                break;
        case RTE_KDRV_IGB_UIO:
        case RTE_KDRV_UIO_GENERIC:
-               /* map resources for devices that use uio */
-               ret = pci_uio_map_resource(dev);
+               if (rte_eal_using_phys_addrs()) {
+                       /* map resources for devices that use uio */
+                       ret = pci_uio_map_resource(dev);
+               }
                break;
        default:
                RTE_LOG(DEBUG, EAL,
@@ -119,7 +121,10 @@ rte_eal_pci_unmap_device(struct rte_pci_device *dev)
        /* try unmapping the NIC resources using VFIO if it exists */
        switch (dev->kdrv) {
        case RTE_KDRV_VFIO:
-               RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n");
+#ifdef VFIO_PRESENT
+               if (pci_vfio_is_enabled())
+                       pci_vfio_unmap_resource(dev);
+#endif
                break;
        case RTE_KDRV_IGB_UIO:
        case RTE_KDRV_UIO_GENERIC:
@@ -228,8 +233,7 @@ error:
 
 /* Scan one pci sysfs entry, and fill the devices list from it. */
 static int
-pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
-            uint8_t devid, uint8_t function)
+pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 {
        char filename[PATH_MAX];
        unsigned long tmp;
@@ -242,10 +246,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
                return -1;
 
        memset(dev, 0, sizeof(*dev));
-       dev->addr.domain = domain;
-       dev->addr.bus = bus;
-       dev->addr.devid = devid;
-       dev->addr.function = function;
+       dev->addr = *addr;
 
        /* get vendor id */
        snprintf(filename, sizeof(filename), "%s/vendor", dirname);
@@ -390,16 +391,14 @@ pci_update_device(const struct rte_pci_addr *addr)
                 pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid,
                 addr->function);
 
-       return pci_scan_one(filename, addr->domain, addr->bus, addr->devid,
-                               addr->function);
+       return pci_scan_one(filename, addr);
 }
 
 /*
  * split up a pci address into its constituent parts.
  */
 static int
-parse_pci_addr_format(const char *buf, int bufsize, uint16_t *domain,
-               uint8_t *bus, uint8_t *devid, uint8_t *function)
+parse_pci_addr_format(const char *buf, int bufsize, struct rte_pci_addr *addr)
 {
        /* first split on ':' */
        union splitaddr {
@@ -427,10 +426,10 @@ parse_pci_addr_format(const char *buf, int bufsize, uint16_t *domain,
 
        /* now convert to int values */
        errno = 0;
-       *domain = (uint16_t)strtoul(splitaddr.domain, NULL, 16);
-       *bus = (uint8_t)strtoul(splitaddr.bus, NULL, 16);
-       *devid = (uint8_t)strtoul(splitaddr.devid, NULL, 16);
-       *function = (uint8_t)strtoul(splitaddr.function, NULL, 10);
+       addr->domain = (uint16_t)strtoul(splitaddr.domain, NULL, 16);
+       addr->bus = (uint8_t)strtoul(splitaddr.bus, NULL, 16);
+       addr->devid = (uint8_t)strtoul(splitaddr.devid, NULL, 16);
+       addr->function = (uint8_t)strtoul(splitaddr.function, NULL, 10);
        if (errno != 0)
                goto error;
 
@@ -451,8 +450,7 @@ rte_eal_pci_scan(void)
        struct dirent *e;
        DIR *dir;
        char dirname[PATH_MAX];
-       uint16_t domain;
-       uint8_t bus, devid, function;
+       struct rte_pci_addr addr;
 
        dir = opendir(pci_get_sysfs_path());
        if (dir == NULL) {
@@ -465,13 +463,12 @@ rte_eal_pci_scan(void)
                if (e->d_name[0] == '.')
                        continue;
 
-               if (parse_pci_addr_format(e->d_name, sizeof(e->d_name), &domain,
-                               &bus, &devid, &function) != 0)
+               if (parse_pci_addr_format(e->d_name, sizeof(e->d_name), &addr) != 0)
                        continue;
 
                snprintf(dirname, sizeof(dirname), "%s/%s",
                                pci_get_sysfs_path(), e->d_name);
-               if (pci_scan_one(dirname, domain, bus, devid, function) < 0)
+               if (pci_scan_one(dirname, &addr) < 0)
                        goto error;
        }
        closedir(dir);