From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by dpdk.org (Postfix) with ESMTP id A151C3252 for ; Thu, 8 Jun 2017 01:56:31 +0200 (CEST) Received: by mail-wm0-f51.google.com with SMTP id d73so20749671wma.0 for ; Wed, 07 Jun 2017 16:56:31 -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=wIxAa9HmyF7X9x1JBusB9t//2iCGxsV4RYQwS8vWZGc=; b=jYRxu/6cHxkHFDVsPDRgcle49i7S0Z5ee/KrPuPkIhNA+WGMR4SY4AXqi9EZ4Q9mHp 65p6wucBGa0iIBEP0xhjpV5SK7u6hTOlw9AtEMWppbh9tRF8Miy5J4R+voFbFRkFDdCM 13iVPUsvGtayGoPDYmQ30seAl4veI+yeA/MJww9fM1JYsawwkAFyIrkL5GaobTIGS2KZ f+9bB+MEVZVmyufV90cTnFq4tyHbplWh5ZLREVAFKVteVinpDTGPWwsmh3Cv7KAoNFWO 1t4GXrLjJ7tHNwODZz3HbiSySKpPllBnDOY11Cp3QtpNvnYf9FRzCSoIT3aNFRiaLUEw 4KBA== 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=wIxAa9HmyF7X9x1JBusB9t//2iCGxsV4RYQwS8vWZGc=; b=i6WejluHLVqFEzyVIaeKiZ8whp7dvWNa0fGrjA5H2ZOvh9MtU69+4Znrft/z15ljKD 2gvDwYDMU6NOCSiLZpgFa/mor8rqM8iq3NM9pj7USdVfVMUEXuwsW1G/oo7QHEAg9Pa+ VHWKv4jS3fyQCF9Cisis+JMcDplUoC8OXrXciJCveDt5AeZra455CpOxcDHZW7wpzay9 52v+io56F+4p3FTuQurqsYAzYzLYgdTXXZvzaxF9c6iSfiPiRtbc007ixcNIc4QoQDWb VCG2t9nDTUfincHLnM37UzPncLfoK76cM4PfuvsVtAquwR2d9WZHu+puA+BMUW8YrCvz OiJA== X-Gm-Message-State: AKS2vOxKexeitlHj0Jf1EZ6OJ5jlhwbhdjNaUcdenHFvT812CR257C9q 5Xn0ze648BAbddwnQCg= X-Received: by 10.28.94.82 with SMTP id s79mr1319022wmb.92.1496879791117; Wed, 07 Jun 2017 16:56:31 -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 m40sm2624808wrm.4.2017.06.07.16.56.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 16:56:30 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 8 Jun 2017 01:56:09 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 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, 07 Jun 2017 23:56:32 -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 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