From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id 9710269C3 for ; Sat, 25 Feb 2017 11:28:32 +0100 (CET) Received: by mail-wr0-f194.google.com with SMTP id 89so4905690wrr.1 for ; Sat, 25 Feb 2017 02:28:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=1d59FjFTmT1xzF6uzyChMUiMhUua5QHnFe3+o7XDErw=; b=CQYUShrEnnHGB2hD7nd6wleoMdkA3lSj5RoigUGsLVP+f1V31JhV/3n6lR3bpH1z3R MS8GPpFKW+k1J7OlswWW+GP9XOxw0rZ4sRwjrMJqRltyK2wgKfg57SkSwUH6TJe/Zrj5 YIfiQzytorCeMs12E+cbf7QquHhCJ6Z+W77JHutUL4/qPf9u4yf03RfzikcPTnafRjVQ rQja/udfm3gSzPM74G9vzrlVbkMLTLOqI7zZMSSNsAeePU0DApZl/igNpizeIoP0yYZy zKA1mvhDNXONKXc+Bz/K9Z0gTCPjuTR8/pPQLh5txJ3MpPw8dE89scD3hk6Zlqi1QZZJ nZqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=1d59FjFTmT1xzF6uzyChMUiMhUua5QHnFe3+o7XDErw=; b=r8cBstt3WZGtwaxOp0oFN1uptb0D6tfq0OoRjN4VTkeJSPCv4fEQbT9kE2h/Bf4dPu niRedX2PTWrCgZFEEyxc23q2WQgC3CS1QPKiQjwJqUYbU8fb1APx0B/nk+YOsQFGXx01 +YH7eD/slmL7umscYbUtCMF+vOTKDdewvd8mzknHhe46srZyECyiBnPjbBlqQiWMdKvs YIBDXQ62Qd8dkgMOcsF3Qu1wKXcWxUODf6iEwoNM+RSqMErDyG76TNJQo3GQVT+rssh2 SNalruk+FUSvoSsI4CiHEXriBjp22EdwnagNZ9uxS7FUWsHVqXOf00J+BbV9jTU2sGgW 3+VA== X-Gm-Message-State: AMke39lY+727Vyks/ypvIS1pR++mrVRMV2pjrKFa255VjICdQm30NM4vejSnllLl44O2jg== X-Received: by 10.223.172.210 with SMTP id o76mr6321218wrc.21.1488018512429; Sat, 25 Feb 2017 02:28:32 -0800 (PST) Received: from weierstrass.local.net ([91.200.109.169]) by smtp.gmail.com with ESMTPSA id e72sm5830893wma.16.2017.02.25.02.28.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Feb 2017 02:28:31 -0800 (PST) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: david.marchand@6wind.com, shreyansh.jain@nxp.com, ferruh.yigit@intel.com Date: Sat, 25 Feb 2017 11:28:09 +0100 Message-Id: <1488018496-995-4-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488018496-995-1-git-send-email-jblunck@infradead.org> References: <1488018496-995-1-git-send-email-jblunck@infradead.org> In-Reply-To: <1487600262-14382-1-git-send-email-jblunck@infradead.org> References: <1487600262-14382-1-git-send-email-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v3 03/10] 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: Sat, 25 Feb 2017 10:28:32 -0000 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 | 22 ------------- lib/librte_eal/common/eal_common_vdev.c | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 58 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..0fcfdd7 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -37,16 +37,22 @@ #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 +128,55 @@ 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, +}; + +static void rte_vdev_bus_register(void) +{ + static int registered = 0; + + if (registered) + return; + + registered = 1; + rte_vdev_bus.name = RTE_STR(virtual); + rte_bus_register(&rte_vdev_bus); +} -- 2.7.4