From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id 2E05E7CC8 for ; Thu, 1 Jun 2017 12:09:19 +0200 (CEST) Received: by mail-wm0-f46.google.com with SMTP id n195so25199957wmg.1 for ; Thu, 01 Jun 2017 03:09:19 -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=cfI0ORX938k1i+ptesliMyhul1I3NBFSEhW2Rh5+jaw=; b=EIn27Q8SYdl5Mv/RXamzc7nasD3W1X3O7nYMkDWf0JP+sjYaCq7WIGGUMg/QWWmQW7 OOcGto7sWpzy7Hd6sQMmaOlnC/X0U46+IUmHYv2Tf29bVxNm9DA77iS9NPk6CA0P9N1G qjhvZNvI8ZXXeABoowvGft5lmIubWIbiMMe1TXX0jxokDmW0BF4qfus3c9lTa/i9NHx3 hCpPxkUrDy/ylPqD6ak84L52HiqO5O50Um5CvfDKFKrNpcGScaxJFQvaY1qcZXZyOjYz GTcaZfeN/uhKCt1bWPG8UgKNvzwaPw2+3ywnC3l1ZHW163b5XnfqUykZte+4yWGiuplZ K3CA== 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=cfI0ORX938k1i+ptesliMyhul1I3NBFSEhW2Rh5+jaw=; b=ddhOb+Y1J3Er70CqymaQphYT/K7POdvldseLgZQteg0rF2P8+2V+2rmPQ5v3RSnEIm 6o2XDLnjejMj0Mqu8uYoNcsZEJbaNPW2OSo122saxCI+wAuec+nhxktZLSfoHsbR70AE 3PhddVtqjlghNATVRTrP/3CNzcmEtvD6jVkXtZzvwR1COsM1S9EC2O25TIi92e4AM1wM nnAGWfy1LJThw0xemKC7Rh68965CX0tVveSaJqehDV0t3tI6L8kw2gtlGT3tVFakfopV LaqUzAaPwTxo/DX2Z1GE7645DsMQQ9AmM3o10zh6/rs2TUNNANd/dGl/0Y8aT2lLg6cd W2jQ== X-Gm-Message-State: AODbwcDRGGRBeM8V4EV0l0A4FWh+AsYV/zLX2j03etGIzEDkwIcf2YQ1 K68ULAh8OUJFWmHSrZk= X-Received: by 10.223.173.23 with SMTP id p23mr709445wrc.117.1496311758612; Thu, 01 Jun 2017 03:09:18 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 03:09:17 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 1 Jun 2017 12:08:59 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 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: Thu, 01 Jun 2017 10:09:19 -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 452f60f..ea58706 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