From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by dpdk.org (Postfix) with ESMTP id A1E127D01 for ; Wed, 24 May 2017 18:16:11 +0200 (CEST) Received: by mail-wm0-f54.google.com with SMTP id 7so68866892wmo.1 for ; Wed, 24 May 2017 09:16:11 -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=So+lXVXW0jFj+Dwe2zqHbdnfFFZq4jql7m0aJ9gt+6A=; b=gzEhS20uNxBUaQZhc7fJY+064SKO7tixWoi7QBDtOwco1IPvel9AjL04RSl4ldsI7O 2U1nKH0qtzaKomusGndTD6joRFdFXxanQyxpW1qUTw0DfLS6STIXS+z8DQsUf61r6B2z 0FqKb1B/H2e5r6MPe1iCv/2INIyo+hPzPVbHTBHjko9p38fyOB8WIM0ENV3FJ4CRzk4N xYKQqYkWAPGOFOjgZtKJdudmcKkehAV0LHMTsaOpA6psPeK8AwTuFMk6UfjYPOYrYnip 9wU+u1a20ZcWsxv3p+YY5t1yXSLtr8WIwQRPnY0OTsVgv7O+Cng9ShjY0O3mimcfmkFJ 09Cw== 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=So+lXVXW0jFj+Dwe2zqHbdnfFFZq4jql7m0aJ9gt+6A=; b=qoq7+OFLeXY7Smb8RTSCbVgxFJvcUetFhiRvPU/5gs6QmR3ILCf2uKmGiweZOeLSW0 cqoUbOnn/uMhZZcKxguqJibtsFNwEmABCeu8y+UA3a3TiI9eBX7lJ+3ZIGMuicE6Bs/C obvL+yRGB7aKcgHJyolZQGcPdXyy4dQf0R8NnM4aZmuVEvztoM/n/xxdyfW2nrAP/V0H a5kjpcDA8ywdajlDpJ8lSZ9tHzJo/kgpJbpxRLTmA8qPqnm/iprpXmEJszuq5yk8mAPl VEZSs1FoXzn593K1L2EElBMYmDM93Qv23UjSaLZMnHmxB+PYDh4oXXYffdbEJIAoytd+ aQFA== X-Gm-Message-State: AODbwcAROYwY3lbSIZ7eEcxll527Q0Rhlq9uu+g5K7f3hmDdkXxtXeoI 61UEbGx9U/DU/wGa X-Received: by 10.28.170.11 with SMTP id t11mr6500758wme.44.1495642571372; Wed, 24 May 2017 09:16:11 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 09:16:10 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 24 May 2017 18:15:50 +0200 Message-Id: <4fad48f19d3153db4cc50c25c724b6391735b00a.1495642202.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 v2 7/9] bus: add helper to find a bus from a device name 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:12 -0000 Find which bus should be able to parse this device name into an internal device representation. Signed-off-by: Gaetan Rivet --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_bus.c | 15 +++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 12 ++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 29 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 3517d74..04fa882 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -202,5 +202,6 @@ DPDK_17.08 { global: rte_bus_from_name; + rte_bus_from_dev; } DPDK_17.05; diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 7977190..08fff60 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -242,3 +242,18 @@ rte_bus_from_name(const char *str) return NULL; return rte_bus_find(bus_cmp_name, str); } + +static int +bus_can_parse(const struct rte_bus *bus, const void *_name) +{ + const char *name = _name; + + return (bus->parse && !bus->parse(name, NULL)); +} + +/* find a bus capable of parsing a device description */ +struct rte_bus * +rte_bus_from_dev(const char *str) +{ + return rte_bus_find(bus_can_parse, str); +} diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 5b87ac4..0b48e66 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -251,6 +251,18 @@ struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev); struct rte_bus *rte_bus_from_name(const char *str); /** + * Find a bus capable of identifying a device. + * + * @param str + * A device identifier (PCI address, virtual PMD name, ...). + * + * @return + * A valid bus structure if found. + * NULL if no bus is able to parse this device. + */ +struct rte_bus *rte_bus_from_dev(const char *str); + +/** * Helper for Bus registration. * The constructor has higher priority than PMD constructors. */ diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 6607acc..a5127d6 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -206,5 +206,6 @@ DPDK_17.08 { global: rte_bus_from_name; + rte_bus_from_dev; } DPDK_17.05; -- 2.1.4