From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Blunck Subject: [PATCH 3/7] eal: move virtual device probing into a bus Date: Wed, 15 Feb 2017 11:02:05 +0100 Message-ID: <1487152929-23627-4-git-send-email-jblunck@infradead.org> References: <1487152929-23627-1-git-send-email-jblunck@infradead.org> Cc: shreyansh.jain@nxp.com To: dev@dpdk.org Return-path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id EC525A2F for ; Wed, 15 Feb 2017 11:02:26 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id c85so7357456wmi.1 for ; Wed, 15 Feb 2017 02:02:26 -0800 (PST) In-Reply-To: <1487152929-23627-1-git-send-email-jblunck@infradead.org> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This is a refactoring of the virtual device probing which moves into into a proper bus structure. Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_dev.c | 22 ----------------- lib/librte_eal/common/eal_common_vdev.c | 44 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 4f3b493..1ce90f6 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -79,28 +79,6 @@ void rte_eal_device_remove(struct rte_device *dev) int rte_eal_dev_init(void) { - struct rte_devargs *devargs; - - /* - * 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 RTE_PMD_REGISTER_VDEV 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; - } - } - return 0; } diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 7d6e54f..523a3d6 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -37,8 +37,10 @@ #include #include +#include #include #include +#include struct vdev_driver_list vdev_driver_list = TAILQ_HEAD_INITIALIZER(vdev_driver_list); @@ -122,3 +124,45 @@ rte_eal_vdev_uninit(const char *name) RTE_LOG(ERR, EAL, "no driver found for %s\n", name); return -EINVAL; } + +static int +vdev_scan(void) +{ + /* for virtual devices we don't need to scan anything */ + return 0; +} + +static int +vdev_probe(void) +{ + struct rte_devargs *devargs; + + /* + * 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 RTE_PMD_REGISTER_VDEV 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; + } + } + + return 0; +} + +static struct rte_bus rte_vdev_bus = { + .scan = vdev_scan, + .probe = vdev_probe, +}; + +RTE_REGISTER_BUS_LATE(virtual, rte_vdev_bus); -- 2.7.4