From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by dpdk.org (Postfix) with ESMTP id C016A6841 for ; Thu, 1 Jun 2017 12:09:13 +0200 (CEST) Received: by mail-wm0-f51.google.com with SMTP id n195so25197053wmg.1 for ; Thu, 01 Jun 2017 03:09:13 -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=GwY9zhAyD8mB2nSrF6dvqRZaDEUdfvti+kS93iO0DcY=; b=MrsNHUclMZqj1hpOzPqS/mfqEE/UR+GEkbazxAqH0tONNQLIvhuCUawekmHtNhwLpi LFeIhfC79CYXnP6pqwltLE9HuyV8xnKtD3XM5waZI0yMl+nDZz51Yb8S5RJaFiQ4sxA3 9owBU85vPi4bfkAjVckh/nqJzO+SG11QDf9oP6RZAJYlRC7xVZQ16xJuhSWE6rhyUNXF De0Y6AtetZgcuCEgEXTvQk4jL206dXm0tZIMYwpMmn8HkppeEIf7URuJuVkRwmUJJ5sa Vp2wSk6gNkX3C53j/6rj617IdaLh81a5o1QJeyWK8POamlq0+5MBzn2gOeVPDBPgvr+9 77jw== 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=GwY9zhAyD8mB2nSrF6dvqRZaDEUdfvti+kS93iO0DcY=; b=P74NHMI4wb+KVVrdz1+dR9DJ9Bqujs5SZ7goeB3643prQnaYflD7GZvQRhiAzdOjuQ QLCG6wFAi82paxqIoIwFZm1ga08F6kSxnupOBhRGiC5L5ZDS/2A8MDstt1v+dR/h8L4x LBF0/eETlVnHLreMBqptLbHQTK0/vnkRgKMzq+uDyYlvbah1jCP68N+IVS4Qe1D9uxMl rfU46DjNEHuqUyQr3No3whdvGPuBWRrh1ux8OG8+ALhD6D7xT1UTLLXpc6i4Qi1pZ3pQ AAtUUP6rlGVmahsZR55jQ6gMzY0n2CwdlZnJdAeEKpnfWWP9po7AuQaKI4mMIwbbnSPs 6/iA== X-Gm-Message-State: AODbwcAwEEviMweBkboz6AsY4i4Mwe3SqUrO4q/JGZa5WVRAm1eX29ik 6lcqFASIYI66Qia6KoQ= X-Received: by 10.223.146.98 with SMTP id 89mr631404wrj.152.1496311753144; Thu, 01 Jun 2017 03:09:13 -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 r10sm24305457wmd.9.2017.06.01.03.09.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 03:09:12 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 1 Jun 2017 12:08:54 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 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: Thu, 01 Jun 2017 10:09:14 -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 67c6fff..131e0c2 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, .plug = vdev_plug, .unplug = vdev_unplug, + .parse = vdev_parse, }; RTE_INIT(rte_vdev_bus_register); -- 2.1.4