From patchwork Wed May 31 13:17:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 24894 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id E623537B2; Wed, 31 May 2017 15:18:16 +0200 (CEST) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id D566A3251 for ; Wed, 31 May 2017 15:18:11 +0200 (CEST) Received: by mail-wm0-f42.google.com with SMTP id d127so19247149wmf.0 for ; Wed, 31 May 2017 06:18: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=n3DiFQ2RnPLspSUZxrAveyedb88aMDNG3kiXv/wJIB0=; b=XwQAd8RzAS6Zm5TnZjX92/xvD9tqVkuPm7Tb/GVqs5oa4surfS1A1a+jj0Jl8SQqt8 RrQ15y4TI+pM7nU2DN6hSwlSAYxdpXV84KfwmcS+Ckc3x7a6ThrVs4lsdYCVkUB67RI8 1UpEPczg8w3x1p7hXmcL+RfmIQ1HJGxBRr/SgYOxrrkK1StXvcbLW8pPA369dFudQMEc usDDFsLcA8+g8IvX5oApczJTw5WBlLpZSRLwk0BhcoPBLSqv6OqK2B0wwapmgH50+lnG aUA3EWAjZVgqW3FaUkSsSQiADg9Z4j1A6zwLW0e6GN/E7voJvMw9ib0wRlEcdO/A/iV2 rxaQ== 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=n3DiFQ2RnPLspSUZxrAveyedb88aMDNG3kiXv/wJIB0=; b=huhgWqTUP0XVSjUN9tt9lKGaNRW0jUTnTmOpuiKcnGwJngoQ4T2LbNHJenl2aqohUd kT/VsxamVqkUj20paO+zgRdRouBOVLgd+NGfflljgca+airXNlgz32AT5OeaWltED7My Rex7dio2PCjq1ZeMfXNyONui8jp/+vtmBsGh6vXX/F775tLwVhs/W2KvirLZ4CAsMHwu ASugmMLFi0Us4qOWl32rYrV7eaUxtNIUeEbXvM3g/dY3s/ERSXkHp/TOWeS8he1ENuC/ sZQ8x/DDjVK6/R2MuFwlkMvsYs+ZxfRDFmWptjol1tomDH7VmXYnqfT8vDd5YdjIhNnX vEZA== X-Gm-Message-State: AODbwcAcKJ0A7I1VJie1nYkgT/LZz/7IMAKtdopG1SQV6Mre86jgv54W hNF2Wfyd3YhpOJBozz4= X-Received: by 10.28.28.146 with SMTP id c140mr5611559wmc.122.1496236689572; Wed, 31 May 2017 06:18:09 -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 g77sm10045744wmd.19.2017.05.31.06.18.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 May 2017 06:18:08 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Wed, 31 May 2017 15:17:46 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 01/11] bus: add bus iterator to find a particular bus 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jan Blunck Signed-off-by: Jan Blunck Signed-off-by: Gaetan Rivet --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_bus.c | 13 ++++++++++ lib/librte_eal/common/include/rte_bus.h | 32 +++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 47 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index 2e48a73..ed09ab2 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -162,6 +162,7 @@ DPDK_17.02 { DPDK_17.05 { global: + rte_bus_find; rte_cpu_is_supported; rte_log_dump; rte_log_register; diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 8f9baf8..68f70d0 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -145,3 +145,16 @@ rte_bus_dump(FILE *f) } } } + +struct rte_bus * +rte_bus_find(rte_bus_match_t match, const void *data) +{ + struct rte_bus *bus = NULL; + + TAILQ_FOREACH(bus, &rte_bus_list, next) { + if (match(bus, data)) + break; + } + + return bus; +} diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 7c36969..006feca 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -141,6 +141,38 @@ int rte_bus_probe(void); void rte_bus_dump(FILE *f); /** + * Bus match function. + * + * @param bus + * bus under test. + * + * @param data + * data matched + * + * @return + * 0 if the bus does not match. + * !0 if the bus matches. + */ +typedef int (*rte_bus_match_t)(const struct rte_bus *bus, const void *data); + +/** + * Bus iterator to find a particular bus. + * + * If the callback returns non-zero this function will stop iterating over + * any more buses. + * + * @param match + * Callback function to check bus + * + * @param data + * Data to pass to match callback + * + * @return + * A pointer to a rte_bus structure or NULL in case no bus matches + */ +struct rte_bus *rte_bus_find(rte_bus_match_t match, const void *data); + +/** * 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 670bab3..6efa517 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -166,6 +166,7 @@ DPDK_17.02 { DPDK_17.05 { global: + rte_bus_find; rte_cpu_is_supported; rte_intr_free_epoll_fd; rte_log_dump;