From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id B68B8D0B8 for ; Tue, 11 Apr 2017 17:45:05 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id o81so66903088wmb.1 for ; Tue, 11 Apr 2017 08:45:05 -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=kSRfFHpHh+ieXf2WU7ujuvZMyZN13nKBiRnIGZAO+bA=; b=zQV/AKjGel9Fl+48Cuzl/k8Ioayl5x+3zKjmMqhl/kCcfhR/8PH5Jub5l140mu4Q26 t+pauvZ/BPO+SO55v4eFJHCg1pv8zyRoCknhUjafNVicJ0gph/4VNO9kvP5xVZq+C4LH h/6O88LF+8su9/lPW5ga3eHGY0q6r256s90IdCNgyM4RNzcIl1f5EdsVOkijfHOHHP0H xYNUZw79Sz6AWS6+d1RZyK6bKxZwvdQJpG1XIo1kcaUdroMtyY1avVk7hIKDctlEvnoq uauWMA/MG6QcujLtBgvGbRA5N+h1aNsK/22BBO7p3AbgXdKKr0e9SpCOnGmJ7/mTdpxR 6J8Q== 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=kSRfFHpHh+ieXf2WU7ujuvZMyZN13nKBiRnIGZAO+bA=; b=srqwTO+1A92utLUHY8Eb/jpev7pgSDewKFDmgCYW8NLbzEFt6TDB5jAwImm10xG0P7 tMhHwR4LvEmGeT0+HtLSfPTJZJ0ZlXZhhqO5eEyFuQMmq0v33RPqsUgwFdIgLL0BjGeD VPKy2KiplJoUk+o56gBgPqnJRnK+OOmFbWUzRY6mCvDxKPah3apo/5exhrQ/Ps8R+ydb KHneFO9lAEcg0jotF0lGCZtxA342CpkFTcZ27U3g+6tzDmqEENz5ZxzCyO7t1btJxgbT IGGA33aoADalPvfTifYP9pbJHJYwFuc01Zk7uzSssEFFxL7pCEhNmvhn0TK6MyoGK24M eeUg== X-Gm-Message-State: AN3rC/6YxSuQEK3IKxpKTUBlMaQjJ4cpWf96oc3wHD0FXv4Z32XuV/3k KYCaP4wSgK6gs0ve X-Received: by 10.28.23.194 with SMTP id 185mr15313182wmx.52.1491925505449; Tue, 11 Apr 2017 08:45:05 -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 u63sm2933738wmu.22.2017.04.11.08.45.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Apr 2017 08:45:04 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck Date: Tue, 11 Apr 2017 17:44:09 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <1488794430-25179-1-git-send-email-jblunck@infradead.org> In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 02/42] 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: Tue, 11 Apr 2017 15:45:06 -0000 From: Jan Blunck 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 | 51 +++++++++++++++++++++++++++++---- 1 file changed, 46 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..9158a1c 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -72,12 +72,51 @@ 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) +{ + const char *c; + char *str; + + if (!args || args[0] == '\0') + return NULL; + + c = args; + + do { + if (strncmp(c, "driver=", 7) == 0) { + c += 7; + break; + } + + c = strchr(c, ','); + if (c) + c++; + } while (c); + + if (c) + str = strdup(c); + else + str = NULL; + + return str; +} + 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 +131,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 +144,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.1.4