X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_eal%2Fcommon%2Feal_common_dev.c;h=92a5a941848e291dfa2244f181cdf0cb47518ba6;hb=2a0911ec8bb64b09c9697a63cf3ea96d78e12e59;hp=11944196961b143c3c38ae3860b1901a94110e39;hpb=a155d430119d947d3cb03136ce50924a642dbfe0;p=dpdk.git diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 1194419696..92a5a94184 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -32,6 +32,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include #include "eal_private.h" @@ -62,7 +64,33 @@ rte_eal_driver_unregister(struct rte_driver *driver) } int -rte_eal_dev_init(uint8_t init_pri) +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; @@ -79,53 +107,48 @@ rte_eal_dev_init(uint8_t init_pri) if (devargs->type != RTE_DEVTYPE_VIRTUAL) continue; - TAILQ_FOREACH(driver, &dev_driver_list, next) { - /* RTE_DEVTYPE_VIRTUAL can only be a virtual or bonded device, - * virtual devices are initialized pre PCI probing and bonded - * device are post pci probing */ - if ((driver->type == PMD_VDEV && init_pri == - PMD_INIT_PRE_PCI_PROBE) || - (driver->type == PMD_BDEV && init_pri == - PMD_INIT_POST_PCI_PROBE)) { - - /* search a driver prefix in virtual device name */ - if (!strncmp(driver->name, devargs->virtual.drv_name, - strlen(driver->name))) { - printf("init (%u) %s\n", init_pri, devargs->virtual.drv_name); - driver->init(devargs->virtual.drv_name, - devargs->args); - break; - } - } - } - - /* If initializing pre PCI probe, then we don't expect a bonded driver - * to be found */ - if (init_pri == PMD_INIT_PRE_PCI_PROBE && - strncmp(PMD_BOND_NAME, devargs->virtual.drv_name, - strlen(PMD_BOND_NAME)) != 0) { - if (driver == NULL) { - rte_panic("no driver found for virtual device %s\n", - devargs->virtual.drv_name); - } - } else if (init_pri == PMD_INIT_POST_PCI_PROBE && - strncmp(PMD_BOND_NAME, devargs->virtual.drv_name, - strlen(PMD_BOND_NAME)) == 0) { - if (driver == NULL) { - rte_panic("no driver found for bonded device %s\n", + if (rte_eal_vdev_init(devargs->virtual.drv_name, + devargs->args)) { + RTE_LOG(ERR, EAL, "failed to initialize %s device\n", devargs->virtual.drv_name); - } + return -1; } } - /* Once the vdevs are initialized, start calling all the pdev drivers */ - if (init_pri == PMD_INIT_PRE_PCI_PROBE) { - 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); - } + /* 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; } + +#ifdef RTE_LIBRTE_EAL_HOTPLUG +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; +} +#endif /* RTE_LIBRTE_EAL_HOTPLUG */