From patchwork Wed May 31 13:17:48 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: 24896 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 7786E56A1; Wed, 31 May 2017 15:18:20 +0200 (CEST) Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id DF7CC37B2 for ; Wed, 31 May 2017 15:18:12 +0200 (CEST) Received: by mail-wm0-f46.google.com with SMTP id 7so118494879wmo.1 for ; Wed, 31 May 2017 06:18:12 -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=nWA762cI+CRNEddQdDUvwh1MYHMyTpS39KHRJGc+Slw=; b=ZmUqFPZ1vCqLSugHUMg/UEtCmhDF+d3EiSrCTcez7unefsPAQn7hMQVE28/q8CAlm2 SbjQ+PtvFuowuVkJOewb7USRXNNW2euHLNcwbl+Hm2Uka2Mom/CaWTPeko+AGhE9+YsT HB4okezWpVbMhJKZSmcpC6YDrCBZtIDPeBqFwE4cANiGe28DGgjfYB2rSQVYOB5VQHwV KOeoDm2yWDWEF9u4EpPRDV7USvHq1vayf0TNxnW60MeC/UjkgEmMFP75vn122xQNSoKK e5DzWuUFo/DcGyKlszDLOeW9Cb8dDsruIQIWiKYDkQsXzNhmN33PkXZ5J39e4T/IkORS egaw== 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=nWA762cI+CRNEddQdDUvwh1MYHMyTpS39KHRJGc+Slw=; b=ukGFvilJml8FW1vjHeoy9CjRwYH0UwavPVtGPdRPcXn4ihWF03lgVSdtbNZhJPaDRn RLe11AsZUbKaRlH0WQnIN2TE7NF0IralWxP5eOjhG/wn0IRbvRf8jtKs6tcYXEQQmgXi /ua1uinqDMSb8qkV1KKrmrCxWmAs0PlCGMM2SnL+qBTiONoyM06VQD48NVnymQpCg9+h 5d0ajnWdBMNqWOdoR34WZM5QQkCvtaOwARUCaklv0e7Tq7ccoVPt5JxUkfr3XdAN1g5k 0KP1m8e0XMMBV1y3MdoqgnN7QRiYNdfBJb1rkztToIMg7dc5zSTBRiViQUMxYw/U1Veh Mo4g== X-Gm-Message-State: AODbwcDw8ypSz36ImGoYZruqrQ/CopDmg20GI0oULjIP1EkzuzzMUmKM 6Y/zQgwOpxyXK0hlzB4= X-Received: by 10.28.21.13 with SMTP id 13mr5692476wmv.13.1496236692172; Wed, 31 May 2017 06:18:12 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 May 2017 06:18:11 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck Date: Wed, 31 May 2017 15:17:48 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 03/11] bus: add helper to find bus for a particular device 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 --- lib/librte_eal/bsdapp/eal/rte_eal_version.map | 1 + lib/librte_eal/common/eal_common_bus.c | 24 ++++++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 5 +++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 31 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index ed09ab2..f1a0765 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -163,6 +163,7 @@ DPDK_17.05 { global: rte_bus_find; + rte_bus_find_by_device; 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 68f70d0..811aff3 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -158,3 +158,27 @@ rte_bus_find(rte_bus_match_t match, const void *data) return bus; } + +static int +cmp_rte_device(const struct rte_device *dev, const void *_dev2) +{ + const struct rte_device *dev2 = _dev2; + + return dev == dev2; +} + +static int +bus_find_device(const struct rte_bus *bus, const void *_dev) +{ + struct rte_device *dev; + + if (!bus->find_device) + return 0; + dev = bus->find_device(cmp_rte_device, _dev); + return !!dev; +} + +struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev) +{ + return rte_bus_find(bus_find_device, (const void *)dev); +} diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 4545b03..0664662 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -180,6 +180,11 @@ typedef int (*rte_bus_match_t)(const struct rte_bus *bus, const void *data); struct rte_bus *rte_bus_find(rte_bus_match_t match, const void *data); /** + * Find the registered bus for a particular device. + */ +struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev); + +/** * 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 6efa517..6f77222 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -167,6 +167,7 @@ DPDK_17.05 { global: rte_bus_find; + rte_bus_find_by_device; rte_cpu_is_supported; rte_intr_free_epoll_fd; rte_log_dump;