From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id 42857A2F for ; Wed, 15 Feb 2017 11:02:29 +0100 (CET) Received: by mail-wr0-f195.google.com with SMTP id k90so30439521wrc.3 for ; Wed, 15 Feb 2017 02:02:29 -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; bh=GTTPNj3K21wBjUaOLsMv2w4Q9GdAzlck+sQH3WRTRKk=; b=G2/OrjGOfiP+ibeLvpTpiOgi5xZuwQJ5bH/YICk8iHcIoYV2IQkofZUrmqzceiPEiM tKsk6QedldRjmmeISBeizagCCzg1eMaegIsd+lTK8rwnq4q9KcdPNiaxkb0fOLYSvrrQ VBvU1YgWYn00UE0Tdqx+CQyBtUFWZs41ver/6+DvW2b0NQRe8i9SByVcaskJoMmVz9QC mGrO5ZKIEIjLsN16LW0Iu/KNKbibg34wIgQOeYA2PYi8vvB6cRff28NwoXTLWgAeGBf7 5ByY9TMNkwFJ1R0CpIuELbmx0FaYFl+1eWUBp7613GCrHPNzXUJj5Ako4RJeLHJsRL/c 554g== 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; bh=GTTPNj3K21wBjUaOLsMv2w4Q9GdAzlck+sQH3WRTRKk=; b=EMjsd47lxkI3Tri218GeoSB1wo1FDxUzoIbwC4gFU27ILPyA6TDSdZpJ/FmWKwgxsa DxODx2WgxGRCv+OBWQm2UjuU7NiPMsAJg5Q/rlsft8Nk9kvWYOgmf2NL7hwZHp2UjpKf j6SjXkEVG09atRreXd7nF5rSNukfRtUsaYSr4/ZOXiLNo/gCONFz8+CVn0ZAGF3kh3s2 odMyy1RuaBhkItI6595jEeeWHx9+vefHlrXS7VnPPc2WoeXHwddDdx4OVaH6G4mMGhgk DsdyHA8V9GAGIrZQVMlBGsZ3Izbt21aItokIOjj7Ig/qA9HXSx7rvDz76A/1WnzEBZPS nSYQ== X-Gm-Message-State: AMke39letH9jcQBLbCk92VxdjEO5v83H5tvSc+r9qSweC+FLqjKy3j4Pnz/tYHLaC+Kbgg== X-Received: by 10.223.172.17 with SMTP id v17mr28395372wrc.115.1487152948890; Wed, 15 Feb 2017 02:02:28 -0800 (PST) Received: from weierstrass.local.net ([91.200.109.169]) by smtp.gmail.com with ESMTPSA id k195sm4716061wmd.7.2017.02.15.02.02.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Feb 2017 02:02:28 -0800 (PST) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: shreyansh.jain@nxp.com Date: Wed, 15 Feb 2017 11:02:07 +0100 Message-Id: <1487152929-23627-6-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487152929-23627-1-git-send-email-jblunck@infradead.org> References: <1487152929-23627-1-git-send-email-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH 5/7] eal: Refactor vdev driver probe/remove 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: Wed, 15 Feb 2017 10:02:29 -0000 This is a preparation for the introduction of the struct rte_vdev_device. Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_vdev.c | 44 ++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 523a3d6..6ba3c91 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -61,14 +61,11 @@ rte_eal_vdrv_unregister(struct rte_vdev_driver *driver) TAILQ_REMOVE(&vdev_driver_list, driver, next); } -int -rte_eal_vdev_init(const char *name, const char *args) +static int +vdev_probe_all_drivers(const char *name, const char *args) { struct rte_vdev_driver *driver; - if (name == NULL) - return -EINVAL; - TAILQ_FOREACH(driver, &vdev_driver_list, next) { /* * search a driver prefix in virtual device name. @@ -89,18 +86,29 @@ rte_eal_vdev_init(const char *name, const char *args) return driver->probe(name, args); } - RTE_LOG(ERR, EAL, "no driver found for %s\n", name); - return -EINVAL; + return 1; } int -rte_eal_vdev_uninit(const char *name) +rte_eal_vdev_init(const char *name, const char *args) { - struct rte_vdev_driver *driver; + int ret; if (name == NULL) return -EINVAL; + ret = vdev_probe_all_drivers(name, args); + if (ret > 0) + RTE_LOG(ERR, EAL, "no driver found for %s\n", name); + + return ret; +} + +static int +vdev_remove_driver(const char *name) +{ + struct rte_vdev_driver *driver; + TAILQ_FOREACH(driver, &vdev_driver_list, next) { /* * search a driver prefix in virtual device name. @@ -121,8 +129,22 @@ rte_eal_vdev_uninit(const char *name) return driver->remove(name); } - RTE_LOG(ERR, EAL, "no driver found for %s\n", name); - return -EINVAL; + return 1; +} + +int +rte_eal_vdev_uninit(const char *name) +{ + int ret; + + if (name == NULL) + return -EINVAL; + + ret = vdev_remove_driver(name); + if (ret > 0) + RTE_LOG(ERR, EAL, "no driver found for %s\n", name); + + return ret; } static int -- 2.7.4