From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id 7842E567C for ; Tue, 11 Apr 2017 17:44:31 +0200 (CEST) Received: by mail-wm0-f46.google.com with SMTP id t189so4269164wmt.1 for ; Tue, 11 Apr 2017 08:44:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=xsG/qqIQMq8kd4e+ssz6IoFpMQ+u3wgbvHgaVE3f7Ic=; b=nfgohvdBrU+HLvABt80GWbyYFqZ3cvu7TyBlYM7PvnSVALZv3ySJKP6RT/i+iRBoz6 Txkhg7hRCrzGDrTMPki2Jl7TMq95bscXacvydnC41aaQTUX/l7cdgLq35pbQhnUYzUxX KfT6CU+mvIzlEM3Hv8qjxFX5Qy3nFEz4r5YBLJjUgBqRgOL1PJtp00pCJPaVz0/5Yq6m 5Z/jWwYi/nXgKCKorq00BdayNtUiSFuVlWY6GS78TkFNPZb4/nixU2Fi7P7RAvt0GbbU yfZfjgpLf1UMTHIAvaJFC9edrpMrV0V9nhnYzuort8AgIqWcdhsWe/cOFjzz+kwo7wjw aPNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=xsG/qqIQMq8kd4e+ssz6IoFpMQ+u3wgbvHgaVE3f7Ic=; b=LKL2jO/3bPBaeueU+G+MeLxp70jgGphy5pFQhAP6jTb1mKtbXU/Ue3T31En5z031Gs AN2zyKSTpaTq+r7Nzd5kx4LPgtWO/O6K0Lyd6r2vi4+tk1zCzukLZwOi/KNGl1sSdYqI 18NSidyyX4TbA1tcMFXpz27QqBKEV+FZvFctXzbmSd8Nd4kzUvzpK2PwdbaRp6oXbm4U O8fukFozIYhbl3Hzshud5LGHP+cZLgfADsaJHAKXZfZ8t+IgtVwEGkjOdGMbiIjNWcTC S62IXZmwEeMwWnYNEV9TMEIcW1YeHcURqxAVFAAFAQcdGzNNDs6bAMWZFbKnHiPAURhn 5IrA== X-Gm-Message-State: AN3rC/48IP3yeDwIMHsmEZZpeeQ/Vv4vY5zKZw4+y8yxv2mDzerV29St wtl62Me1DvfKzr0zLg0= X-Received: by 10.28.166.143 with SMTP id p137mr12010993wme.113.1491925470610; Tue, 11 Apr 2017 08:44:30 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id v14sm2936830wmv.24.2017.04.11.08.44.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Apr 2017 08:44:29 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck Date: Tue, 11 Apr 2017 17:44:06 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <1488797809-12917-1-git-send-email-jblunck@infradead.org> In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 02/12] eal: move virtual device probing into a bus X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2017 15:44:31 -0000 From: Jan Blunck This is a refactoring of the virtual device probing which moves into into a proper bus structure. Signed-off-by: Jan Blunck Tested-by: Ferruh Yigit Acked-by: Shreyansh Jain --- lib/librte_eal/common/eal_common_dev.c | 25 +------------- lib/librte_eal/common/eal_common_vdev.c | 61 +++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 24 deletions(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index d7d1f3d..522aad3 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -81,30 +81,7 @@ void rte_eal_device_remove(struct rte_device *dev) int rte_eal_dev_init(void) { - struct rte_devargs *devargs; - int ret = 0; - - /* - * 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); - ret = -1; - } - } - - return ret; + return 0; } int rte_eal_dev_attach(const char *name, const char *devargs) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 7d6e54f..a94c4c6 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -37,16 +37,23 @@ #include #include +#include +#include #include #include +#include struct vdev_driver_list vdev_driver_list = TAILQ_HEAD_INITIALIZER(vdev_driver_list); +static void rte_vdev_bus_register(void); + /* register a driver */ void rte_eal_vdrv_register(struct rte_vdev_driver *driver) { + rte_vdev_bus_register(); + TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next); rte_eal_driver_register(&driver->driver); } @@ -122,3 +129,57 @@ 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_INIT(rte_vdev_bus_register); + +static void rte_vdev_bus_register(void) +{ + static int registered; + + if (registered) + return; + + registered = 1; + rte_vdev_bus.name = RTE_STR(virtual); + rte_bus_register(&rte_vdev_bus); +} -- 2.1.4