From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f179.google.com (mail-wr0-f179.google.com [209.85.128.179]) by dpdk.org (Postfix) with ESMTP id 0D2FF7D1C for ; Wed, 24 May 2017 17:13:03 +0200 (CEST) Received: by mail-wr0-f179.google.com with SMTP id w50so56964869wrc.0 for ; Wed, 24 May 2017 08:13:03 -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=yQMpD7RZNfqny/Jf4YwrAQJ0yshnxqBEhSPM/4qg3lM=; b=UXMfEdK7rTwh+mD4Aw+zXKEr7/rUdwxfkGvyBtlscUq6N3IoTGWh6ggbeLeqvezn+b R1kAa48553lsztcZHqOCYqll2zSLYYhK/dlPOua6Wqg/uM7BMpQQHjjGFEvi+oxfqN0Q OvnczOVcrj9F9bqxFb5Rxui2PxnZpMg1/GI6AJow+SJCfya1ESs5/gfbM4nETUNgNeNz I9sAR73r2q4GzIREVCc5sB8E7IpDQlEp8iFZTD76IjSUm0IpZvgx3FgivD3i9RecBQCZ cobqma+Xex+tp84sxlQYZllvllMooeNcbNGmqCpceLoJik7nESTRazg/MxCbv39fxuv+ 54WQ== 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=yQMpD7RZNfqny/Jf4YwrAQJ0yshnxqBEhSPM/4qg3lM=; b=tbdP1UMKOz2qFioI6bIcB8MCzzx46lW8odU8EtdQ4aJUj16WNd6sbYQyCRJHflDK9m /H72BWYzb+bs8Xefw8fCzFYx0mFNWbwshPATVXweJfHgU6y+GrAIUeQswqPIIPqaN7s+ TW75/TZ+g+zKolNOcM3Hsw1TnJZFhPkIJm6dColC4aC8b4jzRGiUChT+g2h/Lw0vXQJb K8H48LLWs7osvEe1YN8MJ+73aZMWYE91ps+rGayDRpQ0o16B7lqxeo5abl9NBQq1mXFk nqZJw61B9Q4bMiB/7bt1nC8fV/c1ugkFmLYm3Tx6Z2w2Fk569LaC7K+jz17kh3CeUzBh RVFg== X-Gm-Message-State: AODbwcAOm+u+DQBgxhWoLsc0EKfGmG57jlBZ7o26VTJQCXXdDVLBjPNb YU879+i0D7A1s2Wr X-Received: by 10.223.163.91 with SMTP id d27mr24454422wrb.27.1495638782655; Wed, 24 May 2017 08:13:02 -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 9sm5633351wmh.17.2017.05.24.08.13.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 08:13:01 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet , Jan Blunck , Stephen Hemminger , Maxime Coquelin , Jerin Jacob , David Marchand Date: Wed, 24 May 2017 17:12:41 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 9/9] devargs: parse bus info 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 15:13:03 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_devargs.c | 17 ++++++++++++++++- lib/librte_eal/common/eal_common_vdev.c | 6 ++++-- lib/librte_eal/common/include/rte_devargs.h | 3 +++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index ffa8ad9..8bb72a2 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -83,7 +83,10 @@ int rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) { struct rte_devargs *devargs = NULL; + const char *dev = devargs_str; + struct rte_bus *bus; char *buf = NULL; + size_t i; int ret; /* use malloc instead of rte_malloc as it's called early at init */ @@ -94,7 +97,19 @@ rte_eal_devargs_add(enum rte_devtype devtype, const char *devargs_str) memset(devargs, 0, sizeof(*devargs)); devargs->type = devtype; - if (rte_eal_parse_devargs_str(devargs_str, &buf, &devargs->args)) + bus = rte_bus_from_name(dev); + if (bus) { + i = rte_bus_name_valid(dev); + dev += i + 1; + } else { + bus = rte_bus_from_dev(dev); + if (!bus) { + fprintf(stderr, "ERROR: failed to parse bus info from device declaration\n"); + goto fail; + } + } + devargs->bus = bus; + if (rte_eal_parse_devargs_str(dev, &buf, &devargs->args)) goto fail; switch (devargs->type) { diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 5580295..539835a 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -182,6 +182,7 @@ alloc_devargs(const char *name, const char *args) return NULL; devargs->type = RTE_DEVTYPE_VIRTUAL; + devargs->bus = rte_bus_from_name(VIRTUAL_BUS_NAME); if (args) devargs->args = strdup(args); @@ -294,12 +295,13 @@ vdev_scan(void) { struct rte_vdev_device *dev; struct rte_devargs *devargs; + struct rte_bus *vbus; /* for virtual devices we scan the devargs_list populated via cmdline */ - + vbus = rte_bus_from_name(VIRTUAL_BUS_NAME); TAILQ_FOREACH(devargs, &devargs_list, next) { - if (devargs->type != RTE_DEVTYPE_VIRTUAL) + if (devargs->bus != vbus) continue; dev = find_vdev(devargs->virt.drv_name); diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h index 88120a1..1f50a24 100644 --- a/lib/librte_eal/common/include/rte_devargs.h +++ b/lib/librte_eal/common/include/rte_devargs.h @@ -51,6 +51,7 @@ extern "C" { #include #include #include +#include /** * Type of generic device @@ -89,6 +90,8 @@ struct rte_devargs { char drv_name[32]; } virt; }; + /** Bus handle for the device. */ + struct rte_bus *bus; /** Arguments string as given by user or "" for no argument. */ char *args; }; -- 2.1.4