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 E00D26841 for ; Thu, 1 Jun 2017 12:09:16 +0200 (CEST) Received: by mail-wm0-f51.google.com with SMTP id n195so25198729wmg.1 for ; Thu, 01 Jun 2017 03:09:16 -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=es3UCZ8cyJxAZSfOIvTirlEhPLfCdtuJzbfeLIpudzE=; b=iwER5tMJLNDEygR0x3Mr6Ht6ec3j07/c3ZkO1yV6T3lSemRINltXb1GkCt5ys2GQOf /arwN7qddgWQI8kqUITjcOze0kwoeDv4r75hEFP0+0mKC4YGOmJbelWYJHU/1mjx727b 0nRYQ6VuXhdDuChFzYoLPqxTkHRlzJcm59qj4/7Cv2HIbhLQmB1D4upOZmv02uOBirGN z8ZEaN1Fomexfpzpwf9V6sRIgbQ/l8Xc3NjxXVZimncbgXhs610YIhcQQi7PZ5ZRgu3d 2CwwuYmsdItNOkTiNymGWSIJfTo4twk21FvwsMn4RnRDm2/QNZpDorBMsrMzhCZlIkr9 HpIw== 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=es3UCZ8cyJxAZSfOIvTirlEhPLfCdtuJzbfeLIpudzE=; b=Bj/2Nep5JGzFgcay+/o2imk3uor5hGon5fvYN6a+EsWR8JiTjjPGaLaytulOZOLxhE cbbYAyHTwi1ZCo7mR6/nK5OWr8TMGB4oVYNRbKvyKc2uiBnaApfBCNNw1N1Y/qczfJDX Yhr7M3RPf6rFG26mpVNec2cJ54ByYikXXpoF3smVx7H7QPNOwA7I/NdDoNBFsjrq4/xC 2pOxTKbwqnlSb3Z0aLu1sFz1KT1Xnch7qW7zK1fxpqiB+tH67GwS1qPzUu2E7eLkCkPW RTYKUqJW5crb9pqNqR0ji+yOpb49mdf5TWQmrXZlB9fhDRDF5xBwTvjYO156si3daX9t SnIw== X-Gm-Message-State: AODbwcBXwoL4QWhBDkPbdOHR39seK2EAXOJlHRrty5VQPynTAPxKo7Hi 7HOneFaIlbp08EGmbRY= X-Received: by 10.223.136.151 with SMTP id f23mr644806wrf.134.1496311756341; Thu, 01 Jun 2017 03:09:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Jun 2017 03:09:15 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 1 Jun 2017 12:08:57 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 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: Thu, 01 Jun 2017 10:09:17 -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 063fcea..e9e4e1b 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 0eacd88..4489d1d 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -263,6 +263,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