From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com [209.85.128.178]) by dpdk.org (Postfix) with ESMTP id 379467CD7 for ; Wed, 24 May 2017 17:05:37 +0200 (CEST) Received: by mail-wr0-f178.google.com with SMTP id w50so56828082wrc.0 for ; Wed, 24 May 2017 08:05:37 -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=7CSiL2TucmQADPLJCoM5zmOMQHyWlNd90jgs/0XB21c=; b=KWyOosW4LX078eSzRfnjvA/bvk9wef3PgiDtgx+XHtsc7j8Rq1ezzIJ7SbxiQGh9y7 9r8ulOwpqSA5wosfLjTLT4dNfsv6G/S0chxAGOJslDCdzaoq/bGrv2TGAUbDY4khhwK9 ym7GOUtU+uCjTIH/W1HWzvBkRoZR2CcA8xMCQlfJpUvoTO5bzEHknhMNootODrU1F6bs h/qZxqn8S4He7Dj3NJQA99J7HVmRUaIn5YreGjtZEZ1wPPwOeXT6HT49T5Hc9oi9vSis V6stOJGt5S8YkKz0FUMLOubCs8bfB2CDJv2OzknFm87hXlfWprkka862s2JaVPy0Fpcv aFOA== 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=7CSiL2TucmQADPLJCoM5zmOMQHyWlNd90jgs/0XB21c=; b=VatneMwzpCXpQsEcA0RNBXYu6f3oUFDsWmV+WAMMvzcoCeKvZo4SozORpkpCx+8Wmi eK3mgKcv2B4dqs/rovNN4UdfulKIlZFYH9IQLVSw3SvtjXA1RmhNQEEi/msX7E+tOnjT H7nagh8wcsUucupUWVtqg8UIx2cnGZXRwldMGL3seoOt/1aTkl0maL/ZeZ8YtHkn5QhW GxLm/LkUDyNUVyfs2EjL+psbnr72xwCebrQC54ukufqgWSjizgHdEMSfmjDQdhPXH42j bvMCCP2ZBgt7OL9Dzl5S3IfCJiI7d6rPNwCxpxRQKqXZBkcm3APdLo2icudtc4NtDC9o jWZA== X-Gm-Message-State: AODbwcBqTOQGGlRiVn7p/JTBrO/e+kMDrNvZuVy+WzbCne4C3zLphznL qy6LIAAuUzK/4WP3r4s= X-Received: by 10.223.177.215 with SMTP id r23mr23179796wra.97.1495638336592; Wed, 24 May 2017 08:05:36 -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 25sm4076017wrz.8.2017.05.24.08.05.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 08:05:35 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck Date: Wed, 24 May 2017 17:04:53 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 1/9] 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: , X-List-Received-Date: Wed, 24 May 2017 15:05:37 -0000 From: Jan Blunck Signed-off-by: Jan Blunck --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_bus.c | 14 ++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 20 ++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 36 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..5e33129 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -145,3 +145,17 @@ rte_bus_dump(FILE *f) } } } + +struct rte_bus * +rte_bus_find(int (*match)(const struct rte_bus *bus, const void *data), + 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..66856bb 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -141,6 +141,26 @@ int rte_bus_probe(void); void rte_bus_dump(FILE *f); /** + * Bus iterator to find a particular bus. + * + * The callback function should return 0 if the bus doesn't match and non-zero + * if it does. 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( + int (*match)(const struct rte_bus *bus, const void *data), + 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; -- 2.1.4