From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) by dpdk.org (Postfix) with ESMTP id 0E9627CC2 for ; Wed, 21 Jun 2017 01:30:57 +0200 (CEST) Received: by mail-wr0-f173.google.com with SMTP id c11so56016480wrc.3 for ; Tue, 20 Jun 2017 16:30:57 -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=MmFLTTvo4I/MciagLOoq/V80VtUmFU9W9CCF5JeDbfU=; b=czX4he3zwtnks/v5pAGvYb7PYOdFC5pbkvhHURUK1CQpvWGjl8QSkSmftoHVuMb/Tw 9uH8Ke3EAbeumZf2ChXDbzPwchthWp6nGpTMa/7kygF4q0Uhzx8G2p8X1zEJPuU6YZWd pAq1QWNWTvLAfladcUV9o78FuaQTK59yV0rF/LJvU4Gk5dYoFQUifBpoauKsFiwIZgxx CmHby9AjsqD+gxm4+iqDYp2GJiGd2pP4lcdMjY63GzP+3dBYxiCIoHowPL1x+m0xUBmx KBui9F4t6XGfsrsm4HyFMUc0QcbrPqUMpMU4C7jlzE+prZFjbff4R/rZicyC+9QPaZcx BRgg== 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=MmFLTTvo4I/MciagLOoq/V80VtUmFU9W9CCF5JeDbfU=; b=c2GrtwHJolW+Qhft/+6Sw/zT1g2Dlh4Nrb6fs3gSavtughpcXtAeTcSO1yeQCrG5LH tqarLeSTsBWeCVBkLgG3WnLCNvrQ44nt1NRIt4AipDyv10XroTUCo3dThTnDq9E1L+GP 8+9gqiRWB+LN8XKzkc6aADd8SMCZ+PLQPZlbBietG3NsPPjyO/ROpzKzC6xRqQ2EUuzw ZFy5AKtHyRF12RV6P0oYH2HUsSZInHrP1Gp1kqqmi7GblyXe/TCQLScPhWFcW1sEuwor /rr02exfW2w+EuqBXASqFO4N4DVeDKHjFEznO8X2HX4DbH2z3P1bCeELGIDuqHlQPP36 K+Rw== X-Gm-Message-State: AKS2vOxoHeTNuVOhIlAxBZR+zeSW0MJ4/FlSyOiIwZZBUZXBZRpkPMif +tJI/NUe+w13cS++BS8= X-Received: by 10.28.88.3 with SMTP id m3mr4530277wmb.28.1498001457411; Tue, 20 Jun 2017 16:30:57 -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 w30sm17593338wrb.49.2017.06.20.16.30.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 16:30:56 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 21 Jun 2017 01:30:36 +0200 Message-Id: <5409db7ca846104d6008ea05d2293b6d9fa7b102.1497999826.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 7/7] 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: Tue, 20 Jun 2017 23:30:58 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_devargs.c | 15 ++++++++++++++- lib/librte_eal/common/eal_common_vdev.c | 6 ++++-- lib/librte_eal/common/include/rte_devargs.h | 3 +++ 3 files changed, 21 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..d5f297d 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -83,6 +83,8 @@ 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; int ret; @@ -94,7 +96,18 @@ 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) { + dev += strlen(bus->name) + 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 221146e..7cc3c6c 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