From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 6FDE03772 for ; Mon, 6 Mar 2017 11:00:47 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id n11so12814003wma.0 for ; Mon, 06 Mar 2017 02:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=iYq+6H3MbYWRLkA+gBO2bbUJGkuxp5wilAiM1jPUYP0=; b=hgKsx5AILlosmBJDCpRrZfjzJqLrSBbsOCkikD3iupeZUzs5uEPZBr0DP9dDeyZtbL DKAneStgXHWlEb7taPc+AwpE0VsANM+871+1suLPDvNPsLIjDHKf7IRuy0IJdp9NhzFr buJzykOztVJXg/VF2G3knoIWBQQAK8WeV1h7I69JRK/wdM68jd4XGfsImOwKdYkQLeTP RLCz2jZJdNlblmBdu0tubY++5Eb+VF5nHJFq4QU+1DnLIv1btOfAMx9fa2P2iN+dPKna 5wtkKeq55AGAiTNRPw17Qjjx1KGAX5rN4SLe1cKa+DC6ts56/G+ZL7mKzRS0meeSDdfV mj6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=iYq+6H3MbYWRLkA+gBO2bbUJGkuxp5wilAiM1jPUYP0=; b=Mlqp+jzhmKk2aIOCnQ/A7VO96heFTt4Zs78dzfWNjt16kSyjTeruaavg9Mn1WiveLd 7A1f7v1OmvMCDZDug3bGBuTjrN8jL0/ZoaSxhfl1iKJK3cj4k7L4rPzMVeUEYBRIN9kF TSrUIVFM1NDIWPkF2ZvtGDL63BjZe4deMTUhloxnjjzHSWSJC66F9YLBvViPlEdFK0mg dx9YlaVu+bAFhMsk2JoBPlvW61WKKES5Svw0DAhUY9w2mCzmYF2UfW3RZhijQrL1+g/U CjoafYYoCm3+1IhSYeg6Z67XuhZJ7bzovhSuOH7vjS+Ze5m0zkf3PUw5OVOyV6LtmZqc S0eQ== X-Gm-Message-State: AMke39lJLHCDojBTN2sCDXEAzjCkRdXM3N9HJhTu+8xOGlBTyoAViAzQk4b0yWuwDhw4xQ== X-Received: by 10.28.20.148 with SMTP id 142mr5744764wmu.134.1488794447015; Mon, 06 Mar 2017 02:00:47 -0800 (PST) Received: from weierstrass.local.net ([91.200.109.169]) by smtp.gmail.com with ESMTPSA id u145sm3829237wmu.1.2017.03.06.02.00.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Mar 2017 02:00:45 -0800 (PST) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Date: Mon, 6 Mar 2017 10:59:54 +0100 Message-Id: <1488794430-25179-3-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488794430-25179-1-git-send-email-jblunck@infradead.org> References: <1488794430-25179-1-git-send-email-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH 02/38] eal: parse "driver" device argument before probing drivers 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: Mon, 06 Mar 2017 10:00:47 -0000 In some cases the virtual device name should be totally different than the driver being used for the device. Therefore lets parse the devargs for the "driver" argument before probing drivers in vdev_probe_all_drivers(). Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_vdev.c | 48 +++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index c922297..4b5c0eb 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -72,12 +72,48 @@ rte_eal_vdrv_unregister(struct rte_vdev_driver *driver) TAILQ_REMOVE(&vdev_driver_list, driver, next); } +/* + * Parse "driver" devargs without adding a dependency on rte_kvargs.h + */ +static char *parse_driver_arg(const char *args) +{ + char *str, *c; + + if (!args || args[0] == '\0') + return NULL; + + c = str = strdup(args); + + do { + if (strncmp(c, "driver=", 7) == 0) { + c += 7; + break; + } + + c = strchr(c, ','); + if (c) + c++; + } while (c); + + if (!c) + free(str); + + return c; +} + static int vdev_probe_all_drivers(struct rte_vdev_device *dev) { - const char *name = rte_vdev_device_name(dev); + const char *name; + char *drv_name; struct rte_vdev_driver *driver; - int ret; + int ret = 1; + + drv_name = parse_driver_arg(rte_vdev_device_args(dev)); + name = drv_name ? drv_name : rte_vdev_device_name(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) { /* @@ -92,7 +128,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev) ret = driver->probe(dev); if (ret) dev->device.driver = NULL; - return ret; + goto out; } } @@ -105,11 +141,13 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev) ret = driver->probe(dev); if (ret) dev->device.driver = NULL; - return ret; + break; } } - return 1; +out: + free(drv_name); + return ret; } static struct rte_vdev_device * -- 2.7.4