From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 96C097D63 for ; Wed, 24 May 2017 18:16:08 +0200 (CEST) Received: by mail-wm0-f41.google.com with SMTP id b84so69568113wmh.0 for ; Wed, 24 May 2017 09:16:08 -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=QHsn+Tui/o99ECnmAfZHFqpVd2tu+UPHV2iHoR9HiUPUrNfXc6YLIP+Ikn7vpwPNg1 F1voKPkAH4rVg4uEo9mucgZoEThPugSme67iTWkZrf6QKLwtvNAQPpNpL3glj0p0boku BfiqMJ0qjNg+09OmHZIjQ8CnXGEw42OCXCeJnvIe431Iq2Emcu/No0kv9q6WesvW7JUy e3ki0LnYtfQWwklDb3q2PwuMUWY9HKIrZx3QF6XCYSoQUe9qWGCusqdnryDv/YR2rT0C TwyMSenTAI/Mn2XK4d1vPRYEEhhJgB+toeFu0OLs0tdPRGuprAEdC8w72+Cgm1nyAGRL egMQ== 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=mH5jGPNxaOPHLr8I/TmEqiqMG6v5oMsuuaomItAAAULaOJaxgDYiahhjaHo7k4g0BS k4h5xHMBfAQY4r6lLRg8DUtSZ9dKOQhWawsoHj8BDfgNTc/zfPyf9Rw1amXjB/NvnR9E ke2xXZXCBc2Is4Z2w7GUjfRHg0J3xA2e13WnKNebBYgQyRVZMMXHkRxT6SkG1jQUOUVD 5oplJwg8+xXbueXFboklcUY6ZxwFaSxXszz70Rj9XzE4otZM28OT60KZLqCTncMrZ4BI +VXCdsuVxkGCf5ImomHi/tp9BvRsuV9u08q/zZOC06MKt3QIyjs+Vp5FeNJyBBZoPtHi UoSw== X-Gm-Message-State: AODbwcA7rlpy7mmyEGcB5lf3bXM7A3PWhrY824AT0mkkpAbTrJVVShBg IFXzQLByaDKV3s5e X-Received: by 10.28.181.3 with SMTP id e3mr6351370wmf.41.1495642567976; Wed, 24 May 2017 09:16:07 -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 l7sm7783055wrc.52.2017.05.24.09.16.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 09:16:07 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 24 May 2017 18:15:47 +0200 Message-Id: <977e29101bce9f1c5da79bd7c01c45f77460e657.1495642202.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 v2 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 16:16:09 -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