From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) by dpdk.org (Postfix) with ESMTP id 86D444CC5 for ; Wed, 21 Jun 2017 01:30:53 +0200 (CEST) Received: by mail-wr0-f175.google.com with SMTP id y25so72207323wrd.2 for ; Tue, 20 Jun 2017 16:30:53 -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=1YrK7aiJJNknQ+h896EMIdKZFkCju2Gs4NJGmm2/PBs=; b=YaUu3j85rpYKw++Y0JFGYTYePggPUA/IFXtsCUyhmPg5+uwaUs46LjKUZUNIq8Ojkx qqZsmwuZpX8k/u/enddmJDNtkYgwWoJKPgm/OjwzPkHCPCtu8+8KbBZrohax5bSf12C4 Ua0W1Svzoep34/ys+lY9mgfXcap1HPeaFJyaAaNSItxSNr1AeHyvMWK0w2K9sVbgzTtU KdXDs0b1BiZtDRCcRF7aSdYPyr07RwldCOQwX/gRQEnF4UyS777Wps6mJzrX1Jo8DR8z 2Z1WamyMTDrwxw7dF3g0/eZzuNFeK2+gJLh/QSkqGcSLT+AurYlvxyJYwJMYdGIaeQMj UAaQ== 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=1YrK7aiJJNknQ+h896EMIdKZFkCju2Gs4NJGmm2/PBs=; b=B1TXEavtJlTpTgCS0pY/gDKd2dyURHdgP52YPqPckK67zRHToY8Y1vDfSZfjpdFmGc PX0kgH53bwC0my7wXXlC20XEk8jZj40taKPzFVouEZAXnkLMHaf+sJWHo9S5cdUuzmka l+9wXLh5Y473LpsLdKMDswhIzn4D/WGY0KSseGUXHRZWfth7kvecdvHJNCSdiwpCOHI3 Y+bCrbvI2MWvRpblkSmefvvyfBJeq9yHTcWIovnYIK0qF1au+Y5xXGSuj1tHGMm5j000 kGOqhMWuHcLBgFxCUHyRYx4TuQ10KZlW2sFfFVWZXNq8rIvqIjGjSLiB14jz7Ts64mJ5 a6Pg== X-Gm-Message-State: AKS2vOyWUt2uYKSd7AcKSynhsT+P4TkP1Jm4vfrtBCYAeMqCv6XpJ7IF dc75Tdfal2m86vlYtfE= X-Received: by 10.28.182.214 with SMTP id g205mr4568924wmf.44.1498001452935; Tue, 20 Jun 2017 16:30:52 -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 w30sm17593338wrb.49.2017.06.20.16.30.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 16:30:52 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 21 Jun 2017 01:30:32 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 3/7] 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, 20 Jun 2017 23:30:53 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_vdev.c | 60 +++++++++++++++++---------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 22e4640..8dd4c88 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -104,6 +104,29 @@ static char *parse_driver_arg(const char *args) return str; } +/* + * typeof(addr): (struct rte_vdev_driver **) + */ +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))) + break; + if (driver->driver.alias && + !strncmp(driver->driver.alias, name, + strlen(driver->driver.alias))) + break; + } + if (addr != NULL) + *out = driver; + return !driver; +} + static int vdev_probe_all_drivers(struct rte_vdev_device *dev) { @@ -118,36 +141,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; - } + if (vdev_parse(name, &driver)) { + ret = -1; + 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; - } - } - + dev->device.driver = &driver->driver; + ret = driver->probe(dev); + if (ret) + dev->device.driver = NULL; out: free(drv_name); return ret; @@ -390,6 +391,7 @@ static struct rte_bus rte_vdev_bus = { .find_device = vdev_find_device, .plug = vdev_plug, .unplug = vdev_unplug, + .parse = vdev_parse, }; RTE_INIT(rte_vdev_bus_register); -- 2.1.4