From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f174.google.com (mail-wr0-f174.google.com [209.85.128.174]) by dpdk.org (Postfix) with ESMTP id C8CC723B for ; Wed, 24 May 2017 18:16:13 +0200 (CEST) Received: by mail-wr0-f174.google.com with SMTP id z52so58082432wrc.2 for ; Wed, 24 May 2017 09:16: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=yQMpD7RZNfqny/Jf4YwrAQJ0yshnxqBEhSPM/4qg3lM=; b=Df57Zwjp1F2OT5GlqGterQwmRAcnFYKofuHICoYOFRSu1ha2OsQZ12oN9LN/Fn9zZj fJ3crHSrt6o6E2OLG38Aa7uzUYNhggn0/9mR7GtHMwWgAOGCYJsDlO4TZu35wjXdLMns Ih6w0RWNNcPvgA04VgHA2u7c+Sb/kW6sQ96ji1Gy0ApYr1RvlsfsD9o8ayEpFWk2n6I1 6p1L5KtJQRku/7MgPDqo7jtO5deLr9g8v7cZiWhyMyHH2tPpK5fBNLlNPr6Tna9e+H5I JlGkz55jKhtFHAp2sW62GpetDWJdrxj1Fgd8WlfLbG5gGb6tUy19ReGz3Tf6VHHajf2N XtAg== 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=rBKThrb2vCNZkAa8m82q4s5xG+wYA5fR6FJA8EmA3dRKd3Z1EinaOei+IDDgXQKCL1 vj74EmB5PwNS9AaH8ajngyJUATdpyd2WOoIFdfp4nC/avWclpa9c/GiwJFgAiAT8lXyc igRI+j5wD8lcIt8Q/n3IA0RFpN6IDNveuZfe+8krqKjRwjhH3H8xGmlnNEsZsmQvMjhA 4JyXCxECRYrWt5nsC26xx00prfVCBnE1X4sKbO9ul56w1uz9U7aXfj2bN3U6dJG3QKrL bNWxws1oHGGAhivxXeVxe/pn5MP6Qq4u2nGZGXYUB1KQlqLXEZj/k1YSweQtWxQ5ns5U czLA== X-Gm-Message-State: AODbwcAtz8RSp+NEzlX76wjbSF0ZxImLklHdmM78p9ZFKAUXFIOE+h+g T+p1k+iTPUK0MCG2 X-Received: by 10.223.142.135 with SMTP id q7mr19911792wrb.180.1495642573543; Wed, 24 May 2017 09:16: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 l7sm7783055wrc.52.2017.05.24.09.16.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 09:16:12 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 24 May 2017 18:15:52 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 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 16:16:14 -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