From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by dpdk.org (Postfix) with ESMTP id AA2DA2C72 for ; Tue, 4 Jul 2017 02:58:50 +0200 (CEST) Received: by mail-wm0-f43.google.com with SMTP id f67so69180420wmh.1 for ; Mon, 03 Jul 2017 17:58:50 -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=kwPBU5VAOYdx7Av8CGTY+zhYpphTItJASsc0at41a80=; b=yN2SMxnc9GCVOg0hf+n70N2XPppeuBnjhxwsz70YlBo+7BxG2RM+iHHcqW3J4tohlJ 6Us+wD8W5WVxjH+jSYosWZLKptpahW5FdWPyBEWVQV70dqZAK2xPRzi2mwmCtdsw05lo F0xN9oPaoZsW1+VjE6sVAZbqR2yYpyKSFBuetPbur8LHKVMEIOq6RX3mxOQUAgbkg7FG aL5vdZ73kHbUErrp9zAPBO2GKx1bvLV/lsw38byYw2LpUn2pDdG9/iTwuJZv4E0t8Myp km4CnGxztu12A4oRc4O66jePI46Mc2qL+TwWM46w3q6Iq68z2C525n0Qvl8fI2nlKCUH edVg== 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=kwPBU5VAOYdx7Av8CGTY+zhYpphTItJASsc0at41a80=; b=b50iFl748JosCCNyoqNtjhP0bzHVd7sDFIwW59OGW6bHbDv5ibR2B1UiDrw5t1wzbr VDCwUG62jeEoOzyBMEtxNjk/TLKy1baXoSxp2ezdJleB12z36O7QLKV8uNI21lu65trT 91N0DumEtOzeCpXstlr9PNlsLpUGAr5e3Q5UBn3hzgglhL3mCQVvS+xfczvpcixBn5j9 13wNIexOYh97i7/SQNKR/WsRB8TH5ReT9uhPcg4X9I6jNUeHKwrrol8Cc7BoBGX0uhbl Peo5ifa1/n9OVvnMtgLtvqKTY+adKgqPcnB7NGfZgoorQEHDs7VtLcomO9ZoeLGwuM0g K6Lg== X-Gm-Message-State: AKS2vOzEHBoI9C4cjay1s7689XprP5uU3dAt1iwEiXBAiiDtr8YhgQB+ KOQM2yODQMJ4msp/5FE= X-Received: by 10.28.175.17 with SMTP id y17mr15939187wme.100.1499129930127; Mon, 03 Jul 2017 17:58:50 -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 n189sm15162731wmd.0.2017.07.03.17.58.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Jul 2017 17:58:49 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 4 Jul 2017 02:58:30 +0200 Message-Id: <6cd7f9e263d5c4c90d1ceb7a876d69616cc4b6b2.1499127915.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v6 3/6] vdev: implement parse bus operation 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, 04 Jul 2017 00:58:51 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_vdev.c | 58 ++++++++++++++++----------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index baf3c5b..75a7b93 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -102,6 +102,27 @@ static char *parse_driver_arg(const char *args) } static int +vdev_parse(const char *name, void *addr) +{ + struct rte_vdev_driver **out = addr; + struct rte_vdev_driver *driver = NULL; + + TAILQ_FOREACH(driver, &vdev_driver_list, next) { + if (strncmp(driver->driver.name, name, + strlen(driver->driver.name)) == 0) + break; + if (driver->driver.alias && + strncmp(driver->driver.alias, name, + strlen(driver->driver.alias)) == 0) + break; + } + if (driver != NULL && + addr != NULL) + *out = driver; + return driver == NULL; +} + +static int vdev_probe_all_drivers(struct rte_vdev_device *dev) { const char *name; @@ -115,36 +136,14 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev) RTE_LOG(DEBUG, EAL, "Search driver %s to probe device %s\n", name, rte_vdev_device_name(dev)); - TAILQ_FOREACH(driver, &vdev_driver_list, next) { - /* - * search a driver prefix in virtual device name. - * For example, if the driver is pcap PMD, driver->name - * will be "net_pcap", but "name" will be "net_pcapN". - * So use strncmp to compare. - */ - if (!strncmp(driver->driver.name, name, - strlen(driver->driver.name))) { - dev->device.driver = &driver->driver; - ret = driver->probe(dev); - if (ret) - dev->device.driver = NULL; - goto out; - } - } - - /* Give new names precedence over aliases. */ - TAILQ_FOREACH(driver, &vdev_driver_list, next) { - if (driver->driver.alias && - !strncmp(driver->driver.alias, name, - strlen(driver->driver.alias))) { - dev->device.driver = &driver->driver; - ret = driver->probe(dev); - if (ret) - dev->device.driver = NULL; - break; - } + if (vdev_parse(name, &driver)) { + ret = -1; + goto out; } - + dev->device.driver = &driver->driver; + ret = driver->probe(dev); + if (ret) + dev->device.driver = NULL; out: free(drv_name); return ret; @@ -372,6 +371,7 @@ static struct rte_bus rte_vdev_bus = { .find_device = vdev_find_device, /* .plug = NULL, see comment on vdev_unplug */ .unplug = vdev_unplug, + .parse = vdev_parse, }; RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus); -- 2.1.4