pci: remove unused unbind support
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal_pci.c
index bb5f513..4350134 100644 (file)
  * IGB_UIO driver (or doesn't initialize, if the device wasn't bound to it).
  */
 
-/* unbind kernel driver for this device */
-int
-pci_unbind_kernel_driver(struct rte_pci_device *dev)
-{
-       int n;
-       FILE *f;
-       char filename[PATH_MAX];
-       char buf[BUFSIZ];
-       struct rte_pci_addr *loc = &dev->addr;
-
-       /* open /sys/bus/pci/devices/AAAA:BB:CC.D/driver */
-       snprintf(filename, sizeof(filename),
-               "%s/" PCI_PRI_FMT "/driver/unbind", pci_get_sysfs_path(),
-               loc->domain, loc->bus, loc->devid, loc->function);
-
-       f = fopen(filename, "w");
-       if (f == NULL) /* device was not bound */
-               return 0;
-
-       n = snprintf(buf, sizeof(buf), PCI_PRI_FMT "\n",
-                    loc->domain, loc->bus, loc->devid, loc->function);
-       if ((n < 0) || (n >= (int)sizeof(buf))) {
-               RTE_LOG(ERR, EAL, "%s(): snprintf failed\n", __func__);
-               goto error;
-       }
-       if (fwrite(buf, n, 1, f) == 0) {
-               RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__,
-                               filename);
-               goto error;
-       }
-
-       fclose(f);
-       return 0;
-
-error:
-       fclose(f);
-       return -1;
-}
-
 static int
 pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
 {
@@ -193,7 +154,7 @@ pci_find_max_end_va(void)
 /* parse one line of the "resource" sysfs file (note that the 'line'
  * string is modified)
  */
-static int
+int
 pci_parse_one_sysfs_resource(char *line, size_t len, uint64_t *phys_addr,
        uint64_t *end_addr, uint64_t *flags)
 {
@@ -350,13 +311,13 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
                 dirname);
        if (access(filename, R_OK) != 0) {
                /* if no NUMA support, set default to 0 */
-               dev->numa_node = 0;
+               dev->device.numa_node = 0;
        } else {
                if (eal_parse_sysfs_value(filename, &tmp) < 0) {
                        free(dev);
                        return -1;
                }
-               dev->numa_node = tmp;
+               dev->device.numa_node = tmp;
        }
 
        /* parse resources */
@@ -390,6 +351,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 
        /* device is valid, add in list (sorted) */
        if (TAILQ_EMPTY(&pci_device_list)) {
+               rte_eal_device_insert(&dev->device);
                TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
        } else {
                struct rte_pci_device *dev2;
@@ -402,6 +364,7 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 
                        if (ret < 0) {
                                TAILQ_INSERT_BEFORE(dev2, dev, next);
+                               rte_eal_device_insert(&dev->device);
                        } else { /* already registered */
                                dev2->kdrv = dev->kdrv;
                                dev2->max_vfs = dev->max_vfs;
@@ -411,12 +374,26 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
                        }
                        return 0;
                }
+               rte_eal_device_insert(&dev->device);
                TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
        }
 
        return 0;
 }
 
+int
+pci_update_device(const struct rte_pci_addr *addr)
+{
+       char filename[PATH_MAX];
+
+       snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT,
+                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);
+}
+
 /*
  * split up a pci address into its constituent parts.
  */
@@ -743,9 +720,6 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 int
 rte_eal_pci_init(void)
 {
-       TAILQ_INIT(&pci_driver_list);
-       TAILQ_INIT(&pci_device_list);
-
        /* for debug purposes, PCI can be disabled */
        if (internal_config.no_pci)
                return 0;
@@ -754,21 +728,6 @@ rte_eal_pci_init(void)
                RTE_LOG(ERR, EAL, "%s(): Cannot scan PCI bus\n", __func__);
                return -1;
        }
-#ifdef VFIO_PRESENT
-       pci_vfio_enable();
-
-       if (pci_vfio_is_enabled()) {
-
-               /* if we are primary process, create a thread to communicate with
-                * secondary processes. the thread will use a socket to wait for
-                * requests from secondary process to send open file descriptors,
-                * because VFIO does not allow multiple open descriptors on a group or
-                * VFIO container.
-                */
-               if (internal_config.process_type == RTE_PROC_PRIMARY &&
-                               pci_vfio_mp_sync_setup() < 0)
-                       return -1;
-       }
-#endif
+
        return 0;
 }