From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by dpdk.org (Postfix) with ESMTP id 723CD7D08 for ; Wed, 24 May 2017 17:12:57 +0200 (CEST) Received: by mail-wr0-f179.google.com with SMTP id z52so56987286wrc.2 for ; Wed, 24 May 2017 08:12:57 -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=bp9l1KIXdEGJ7DJLmV0/GmvFcRJG5jh5AvHwMNpP2s8=; b=i6nzHUZPe73rBZgBccQ3ek5R0c5b+Dfn6RcL5kGqxDp7zhWYjwPdZgLYiMWDfG+xTd 9ZHTIYhyUPeqgEEw+n+NrUjFAg3YkfIQU9JeiKenynRbptUvXyCUaGQ+dWUZBaqR9p81 fjxFQ4LzT9djjhACZ99uaPE0tU5gscbR4LwFAF3xh7cZgexp98AK/toSfnEL4831NLrY 21rDjGaOcXIexStQVBx7Jt1y0tXmt2LI7CmEgjQ1zNNKIItZjjBUmErAC584r1XPuYIr 0NnPt73fokVVTV167qoTBQloPHrc+ikT0yO7pE5xk42Ng73evY8IJq1geM6iWwphvS+z IWqQ== 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=bp9l1KIXdEGJ7DJLmV0/GmvFcRJG5jh5AvHwMNpP2s8=; b=orOBHIYClzQSVbaaiOAQ+HBkRAzHaZFc34NlVAclGRd+0t/xmoOTok+fogiZ96Io11 OZN5uvd7CfVVYMczjsVaHMNlB6YNz7Y1/rgMxMyv26m0r9h6gCBkSHiLnOAJRevFT35S OF1G/aHeJSRfTdwBlP+kIcX5+iO1rVa7ce9SGaiP1MwhlWJXJ20hKQ1j5CDCZDFeE3aJ jOqtzVxYn48YzcRk62gdBbL/uq9qcBv8f8ElvQwpdnsGEkEb6rEALmvkFG9RySAFSJIG ml+hKlN3oiyx1mIR0drn/F0HV70OFtXh/t696mC+yFe4zIlOkxN0Eg7d0941eH1+YGem NmDA== X-Gm-Message-State: AODbwcCDEQxtl5F1lT6d4WvQDlfEv5UvYA8qlvcUQLRrGU3NpBAYP8Bh gpOwXfd3UfWnZeL7 X-Received: by 10.223.161.20 with SMTP id o20mr23722484wro.102.1495638777095; Wed, 24 May 2017 08:12:57 -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 9sm5633351wmh.17.2017.05.24.08.12.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 08:12:56 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet , Jan Blunck , Stephen Hemminger , Maxime Coquelin , Jerin Jacob , David Marchand Date: Wed, 24 May 2017 17:12:36 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 4/9] 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: Wed, 24 May 2017 15:12:57 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_vdev.c | 62 ++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 2095b01..9c9a1de 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -102,6 +102,31 @@ 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; + + TAILQ_FOREACH(driver, &vdev_driver_list, next) { + if (!strncmp(driver->driver.name, name, + strlen(driver->driver.name))) + goto ret; + if (driver->driver.alias && + !strncmp(driver->driver.alias, name, + strlen(driver->driver.alias))) + goto ret; + } + driver = NULL; +ret: + if (addr != NULL) + *out = driver; + return !driver; +} + static int vdev_probe_all_drivers(struct rte_vdev_device *dev) { @@ -116,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; - } - } - - /* 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; @@ -368,6 +371,7 @@ static struct rte_bus rte_vdev_bus = { .find_device = vdev_find_device, /* .attach = NULL, see comment on vdev_detach */ .detach = vdev_detach, + .parse = vdev_parse, }; RTE_INIT(rte_vdev_bus_register); -- 2.1.4