From patchwork Wed Jun 7 23:53:17 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: 25116 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 92A74374F; Thu, 8 Jun 2017 01:53:48 +0200 (CEST) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id 474C52C19 for ; Thu, 8 Jun 2017 01:53:42 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id m7so35439460wmg.0 for ; Wed, 07 Jun 2017 16:53:42 -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=D8QRomAAaPET+Um5CiczNoMoDWmXxpSrCRnR1R+hCAI=; b=m+SwIxbug56zlG1tCyTertWwTxuN6mVslPzpI+6LkzZkwWyvQ2jKSrA8WnJGhAkGUf ZVX6+Z+tasgPGzabOK14OT3GjH+HHbi85hDM0YbDTBI/ANHTqI9tCm+9E9wZupCrHZ+Y ePTGjpyNnlYTnbDWzFZl4KeTRuctdO2xJx3PN4NjqbF0Z/Fg5ZaBYgojqeFF/Gp6UM55 90T6ePzqKNnzqmVhT679tBQ6lu0qogdj11DUAa9wJAkWachNyh7y7KVZD/1F6pEk3OGq 58cAqtbw4piPr0qgSlEuMyhE3+xmbKq4h6r31Q83Rd5GoYvKY6biLQ4Fv9cUsS1Efacs enXQ== 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=D8QRomAAaPET+Um5CiczNoMoDWmXxpSrCRnR1R+hCAI=; b=eGTUzLXAQOJkkA98WdIVyCRWmUrqyTvmFDp2UX0IXmWAWIFig1ny51R1GwJJTVM257 hTHQIz6yWt6V/lh8zEVSpV+IYx4K0RXLvesQ0SgRSKXfgU/k965+wdkxvMbLeCfUJL6O d3OTYPE3mk5jDBGtcwBr6ycWJU1VItp2jbaIpdYHd4apl/7cVspc8d4X8tC8J9nXQv8V 4JeQ33S0tlQRKF7/15tU9nRCpFQUT2Lrem90fuMejefjlBUTRRw0lWACEASfkFZrTvUJ sXUkZg+qfYag6Di/Yb7aSml0O2BaHSLSYkF75KTqSXlPJDMoYK8qCoI2tCHRP/tttBc/ d2qQ== X-Gm-Message-State: AODbwcDxb/MM4dDsGQev33GZ47P+4dAzLeDnZ+EygVIeLFzi/0H5eSEU tNVheZmn4wyiypudNy4= X-Received: by 10.28.150.200 with SMTP id y191mr1395214wmd.77.1496879621462; Wed, 07 Jun 2017 16:53:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 16:53:40 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Thu, 8 Jun 2017 01:53:17 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 03/10] 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 Signed-off-by: Gaetan Rivet --- 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 a54aeb4..42f1076 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -156,3 +156,27 @@ rte_bus_find(rte_bus_cmp_t cmp, const void *data) break; 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 -1; + 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 e3f867f..b3bc6e8 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -182,6 +182,11 @@ typedef int (*rte_bus_cmp_t)(const struct rte_bus *bus, const void *data); struct rte_bus *rte_bus_find(rte_bus_cmp_t cmp, 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;