From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by dpdk.org (Postfix) with ESMTP id 7A7D63250 for ; Thu, 8 Jun 2017 01:56:26 +0200 (CEST) Received: by mail-wr0-f182.google.com with SMTP id g76so11980100wrd.1 for ; Wed, 07 Jun 2017 16:56:26 -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=R3FcbR5qwL1mI8EvbYO7RkaC9Mju760plVuiG3tMSmHszat2fW0FIJD9I/jpY0xDh0 Q7lZ8EvQ1xmd9TemNc5WLkp8pb5/b2YaAawhB8Tz2Gy+UrgxB39yV1PnstPSvMX7WEmZ Bc+K8PxJ3A4un+jl85K96AkZo3FjGEU5Y/e+6ZuuJRXz2AR4xSEvKc6P7YHyb+bYIIMD Py03JUvKsGTrvGmOCCuR+hxbyF7bZFsgVSgflh7VjxGgsDYKYa5VU/HAGJVNCwFVOPWS ZZpeTqoK/vKcE8QLHN8xEMu+GfpX19CaLdvqo+149unKu5zGwFgOo6koegL6WxtBl0Df QmEA== 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=fqfaSLT6umV/sK/3iGpwOaqCTJCBi72/b42gv0iEpOuDFx5Phkb9aKA6c2t7gEYm9h /ZsOjAgV2x4GcdzHJSSYS7BKN5C64G9su+x1lGQvQsYAu3D2E5iNvD+FP/VVjjum8Q3D 6fCs9KoL9jTV5IzauVfFpVv3ZdWQFy5tCvRWan8D49Dj1b4XqNlHfnULsslCI3VXp9c4 IQltzksax1lTG/UIEWGWkUKJPuLwnMLLY6zxnPBRxpPHWGjaUI4LL5WzA0yns4M63IGs QUg4xVSg2fF0YDYMF9f9RAAYzUcYgQFs14V3KkHxnznRSlXrfe1Fr/mxDOT1WIjHGRA7 EtYg== X-Gm-Message-State: AODbwcDF3/6S0x3Jk+HYLOxdyaShEzDGXz0ib6tIuQmlJV2Y6TnDHaYJ 2+61YAvuDP81acF9f3Q= X-Received: by 10.223.161.139 with SMTP id u11mr22491796wru.145.1496879785955; Wed, 07 Jun 2017 16:56:25 -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 m40sm2624808wrm.4.2017.06.07.16.56.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 16:56:25 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 8 Jun 2017 01:56:04 +0200 Message-Id: <58601b4e5332e5ddfecb5afa94ac75ed291e5003.1496876810.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 v4 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, 07 Jun 2017 23:56:26 -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