From patchwork Wed Jun 7 23:53:15 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: 25114 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 584842C2F; Thu, 8 Jun 2017 01:53:43 +0200 (CEST) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by dpdk.org (Postfix) with ESMTP id 4377C2BB8 for ; Thu, 8 Jun 2017 01:53:39 +0200 (CEST) Received: by mail-wm0-f43.google.com with SMTP id m7so35439420wmg.0 for ; Wed, 07 Jun 2017 16:53:39 -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=QikQ0n/UtBDAgb3J2ICjX/nUL/fEqaYSEmK0VIz2S/8=; b=ncAAHNdNQacLRmsB1wXFIwucj3ym+0Z94pxmmInBPfH8k9zrXqtTM1xFzDyRFSq+Qy 5tBjFb7IZv+BY2xChRWpD1jLI7Frrx9YIH5GE0muh/7OVIASldy607yG3zhtBsBMO2Qm GTnP2blMNKKOcEmSSKqTrSb12LbigP+mpvepQQ3LsLhqSlrsBWbzIGy5SQoPf12bXhvk UPcYNP3Zg26aB9x/5Kxi4XDKb1Yu3zkOtdi0RLG5VqMm8P278wMHbMMxpF9IG0ghGjwK iJs2r4sPHdOBJ5bU1Tm0rkEx7lKEFIbl1H7JwTHPmsTHlkHfVKfK/jbxgc89b41IyuxR 8m9g== 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=QikQ0n/UtBDAgb3J2ICjX/nUL/fEqaYSEmK0VIz2S/8=; b=rcf03SLKKViX+hoGm24HuOZgS6E6i/xzMJ8l6Xy/gO5o+arQIPFKQscf7B/rpDoO9z 6e5mVRBTiwzgGVwWhl4VObamXCttSQi0/Pad4X/8/C0Ebk1nMK6qZlZCr0yp00eBmh1s OkXt21YACNrRCaa2OjAPxmRvlxhbCukRIJUZ+W87FickVZGmqfiCO4QMvE0bxsJQIFzx XioZ8WAy9falvk9+xiaICf2LpBUwnlBWB81OQrtTFxZLzrGfaA0IYV14ryaU8KTH7LXS wIE32QfDL60xhNluR6DBVg3l/GcdGwZOmSl+oXiarVowf7MXjUexZvsDcOa7Y9UUSFbp TgOg== X-Gm-Message-State: AODbwcAEDavE6xOkwbNYTBncl9rgtUPM9LPwIQ3H8fgM8FxfSi7Us+7T 1M/iRrDgtkyvBDQxHiQ= X-Received: by 10.28.135.82 with SMTP id j79mr1495709wmd.10.1496879619343; Wed, 07 Jun 2017 16:53:39 -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 z23sm4589942wrz.0.2017.06.07.16.53.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 16:53:38 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Thu, 8 Jun 2017 01:53:15 +0200 Message-Id: <64ba7d394994bf8f1b6e82d16f59da02ae1ad312.1496876710.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 v3 01/10] 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 | 11 ++++++++ lib/librte_eal/common/include/rte_bus.h | 34 +++++++++++++++++++++++++ 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..a54aeb4 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -145,3 +145,14 @@ rte_bus_dump(FILE *f) } } } + +struct rte_bus * +rte_bus_find(rte_bus_cmp_t cmp, const void *data) +{ + struct rte_bus *bus = NULL; + + TAILQ_FOREACH(bus, &rte_bus_list, next) + if (cmp(bus, data) == 0) + 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..16bcfd9 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -141,6 +141,40 @@ int rte_bus_probe(void); void rte_bus_dump(FILE *f); /** + * Bus comparison function. + * + * @param bus + * Bus under test. + * + * @param data + * Data to compare against. + * + * @return + * 0 if the bus matches the data. + * !0 if the bus does not match. + * <0 if ordering is possible and the bus is lower than the data. + * >0 if ordering is possible and the bus is greater than the data. + */ +typedef int (*rte_bus_cmp_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 cmp + * Comparison function. + * + * @param data + * Data to pass to cmp callback + * + * @return + * A pointer to a rte_bus structure or NULL in case no bus matches + */ +struct rte_bus *rte_bus_find(rte_bus_cmp_t cmp, 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;