net/sfc/base: fix error code usage in common code
[dpdk.git] / lib / librte_eal / common / eal_common_dev.c
index 88f9d3f..a400ddd 100644 (file)
 
 #include "eal_private.h"
 
-/** Global list of device drivers. */
-static struct rte_driver_list dev_driver_list =
-       TAILQ_HEAD_INITIALIZER(dev_driver_list);
-
-/* register a driver */
-void
-rte_eal_driver_register(struct rte_driver *driver)
-{
-       TAILQ_INSERT_TAIL(&dev_driver_list, driver, next);
-}
-
-/* unregister a driver */
-void
-rte_eal_driver_unregister(struct rte_driver *driver)
-{
-       TAILQ_REMOVE(&dev_driver_list, driver, next);
-}
-
-int
-rte_eal_vdev_init(const char *name, const char *args)
-{
-       struct rte_driver *driver;
-
-       if (name == NULL)
-               return -EINVAL;
-
-       TAILQ_FOREACH(driver, &dev_driver_list, next) {
-               if (driver->type != PMD_VDEV)
-                       continue;
-
-               /*
-                * search a driver prefix in virtual device name.
-                * For example, if the driver is pcap PMD, driver->name
-                * will be "eth_pcap", but "name" will be "eth_pcapN".
-                * So use strncmp to compare.
-                */
-               if (!strncmp(driver->name, name, strlen(driver->name)))
-                       return driver->init(name, args);
-       }
-
-       RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
-       return -EINVAL;
-}
-
-int
-rte_eal_dev_init(void)
-{
-       struct rte_devargs *devargs;
-       struct rte_driver *driver;
-
-       /*
-        * Note that the dev_driver_list is populated here
-        * from calls made to rte_eal_driver_register from constructor functions
-        * embedded into PMD modules via the PMD_REGISTER_DRIVER macro
-        */
-
-       /* call the init function for each virtual device */
-       TAILQ_FOREACH(devargs, &devargs_list, next) {
-
-               if (devargs->type != RTE_DEVTYPE_VIRTUAL)
-                       continue;
-
-               if (rte_eal_vdev_init(devargs->virt.drv_name,
-                                       devargs->args)) {
-                       RTE_LOG(ERR, EAL, "failed to initialize %s device\n",
-                                       devargs->virt.drv_name);
-                       return -1;
-               }
-       }
-
-       /* Once the vdevs are initalized, start calling all the pdev drivers */
-       TAILQ_FOREACH(driver, &dev_driver_list, next) {
-               if (driver->type != PMD_PDEV)
-                       continue;
-               /* PDEV drivers don't get passed any parameters */
-               driver->init(NULL, NULL);
-       }
-       return 0;
-}
-
-int
-rte_eal_vdev_uninit(const char *name)
-{
-       struct rte_driver *driver;
-
-       if (name == NULL)
-               return -EINVAL;
-
-       TAILQ_FOREACH(driver, &dev_driver_list, next) {
-               if (driver->type != PMD_VDEV)
-                       continue;
-
-               /*
-                * search a driver prefix in virtual device name.
-                * For example, if the driver is pcap PMD, driver->name
-                * will be "eth_pcap", but "name" will be "eth_pcapN".
-                * So use strncmp to compare.
-                */
-               if (!strncmp(driver->name, name, strlen(driver->name)))
-                       return driver->uninit(name);
-       }
-
-       RTE_LOG(ERR, EAL, "no driver found for %s\n", name);
-       return -EINVAL;
-}
-
 int rte_eal_dev_attach(const char *name, const char *devargs)
 {
        struct rte_pci_addr addr;
@@ -161,11 +55,11 @@ int rte_eal_dev_attach(const char *name, const char *devargs)
        }
 
        if (eal_parse_pci_DomBDF(name, &addr) == 0) {
-               if (rte_eal_pci_probe_one(&addr) < 0)
+               if (rte_pci_probe_one(&addr) < 0)
                        goto err;
 
        } else {
-               if (rte_eal_vdev_init(name, devargs))
+               if (rte_vdev_init(name, devargs))
                        goto err;
        }
 
@@ -186,10 +80,10 @@ int rte_eal_dev_detach(const char *name)
        }
 
        if (eal_parse_pci_DomBDF(name, &addr) == 0) {
-               if (rte_eal_pci_detach(&addr) < 0)
+               if (rte_pci_detach(&addr) < 0)
                        goto err;
        } else {
-               if (rte_eal_vdev_uninit(name))
+               if (rte_vdev_uninit(name))
                        goto err;
        }
        return 0;