From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) by dpdk.org (Postfix) with ESMTP id 04E31325A for ; Wed, 21 Jun 2017 01:29:47 +0200 (CEST) Received: by mail-wr0-f173.google.com with SMTP id y25so72183545wrd.2 for ; Tue, 20 Jun 2017 16:29:47 -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=6agmKvJXApxXhcNzPyuj1P0FSVuVKZyeUqeDfUKPGTQ=; b=Vy3w6wx5DsOrGO5BHNBZDpIO1f3xpVlBP9ZGW22iIAOa6tZuNirfO8r/23QJU9y+wo Ur6a0x7m+zSgZ3YpIATfk/w8sgCBsjOtXbp73KQrdGiRlefCGLM/TuQIrH7g0DsJcLSQ vBhJZGRbcmkpOxoAILNUtcKjjaRz6gsA2uDC+94UnbyVimvYhQLlHm9pXwiWt0Tpaap/ 9xZ1cMLJsHASraGQ/LGrwYn45W1ee9SM1PfPNXhUtyx9M7Wi6PlT0GqINNLtc45+uOGE PE8QQwh5j1DtqGULPm8RpITHWcq9jKcuNL6YoxynxiI7gm7OV2TwKNigs1ENkBiUo9W/ E8Ew== 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=6agmKvJXApxXhcNzPyuj1P0FSVuVKZyeUqeDfUKPGTQ=; b=lHrF+ijBTyGbHOPmENSk5I9W4ItR5/7Lv4LBknTIzTqDZZCWzYU9UNaXH0Bjq4mELG hLva0c6FHCx4VqQBMR2E8oz5GWoHT3epp8y803cuBYN8kw+2DXhFw5hAHZycUzxZjrA8 KJcIiBFGV5AokWkvJTR6hbwxgbaK6oW3Ds2Qdgun0lLevc7F6INxKenCLBAT0bvUMjZI zfN+ZXfZiMsFin8Gm7FayeoXe6Lktttw4b9x7poHQjqKE9m8EdyI/aDdAKgoMdoXbTCO 64vnEHwMBQtsrcZ3iMGmKrcM05aQJ//wnrq0dcJXV5jdDiSizCxMdiI1ZCEzMnNIcmbU 45RA== X-Gm-Message-State: AKS2vOwG9gxA8SQyz0w4EZV7a7husbogwV+b/tV0JV2pdurmq7pf4IRR P3Lwl9CxWgEYl+OQHvY= X-Received: by 10.28.135.7 with SMTP id j7mr4388100wmd.56.1498001387235; Tue, 20 Jun 2017 16:29:47 -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 l127sm8592248wml.26.2017.06.20.16.29.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 16:29:46 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Wed, 21 Jun 2017 01:29:22 +0200 Message-Id: <7dcba05e933f8779a2fdc9bba0ecea7a25a0848f.1497999601.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 v4 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: Tue, 20 Jun 2017 23:29:48 -0000 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 | 20 ++++++++++++ lib/librte_eal/common/include/rte_bus.h | 41 +++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 63 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..4619eb2 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -145,3 +145,23 @@ rte_bus_dump(FILE *f) } } } + +struct rte_bus * +rte_bus_find(rte_bus_cmp_t cmp, + const void *data, + const struct rte_bus *start) +{ + struct rte_bus *bus = NULL; + int started = start == NULL; + + TAILQ_FOREACH(bus, &rte_bus_list, next) { + if (!started) { + if (bus == start) + started = 1; + continue; + } + 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 5f47b82..3e26d4b 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -141,6 +141,47 @@ 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 zero this function will stop iterating over + * any more buses. + * If the start parameter is non-NULL, the comparison will only be determined + * past this element. + * + * @param cmp + * Comparison function. + * + * @param data + * Data to pass to cmp callback + * + * @param start + * Starting point for the iteration. + * + * @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, + const struct rte_bus *start); + +/** * 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