From patchwork Thu Jun 29 18:21:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Blunck X-Patchwork-Id: 26005 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 61FA07CBA; Thu, 29 Jun 2017 20:22:43 +0200 (CEST) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id DC52C58EC for ; Thu, 29 Jun 2017 20:22:33 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id p204so4072530wmg.1 for ; Thu, 29 Jun 2017 11:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9x9YXuhBkGW6ZyFV5PswxMKasjAYnXqGwqXMgxjiCTs=; b=KvjUmKQGfxTuqVQj+mP/eqaLz9c22LITu89lkdjOMcU4IU1ccuPM+6iyibeKUQhp9g HaCU/A1DDj9pos6Gu0mY4mI1JB1bWzjWGEViXeewlgmlwubZslbHjvyr++434/9TArJH 4IFn2ksUuL6emE5qGP0OI6cf9uqIlkutAA4RNMnmfww/HR6UGZ1FeqdjpDjMn4wkYRQq nxEj5me/8sIxyx8SImf+gHauZhxNhJnnbkWT9LDSG15HwGEOX2jZNWeEtIFmaoNT+aq1 XFVTqKY3bNECvWJBTPJb7/e2IdN+v7sTomHfRp29mhw5UHQB73LnzXCmSKAh+6ZR2azk 71OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9x9YXuhBkGW6ZyFV5PswxMKasjAYnXqGwqXMgxjiCTs=; b=KR1LLRCc41rCnC+kkA1S1JDJdg59nVrZg2H16oKnDKUoTx8Jjdg8t6oYjfdGSIj8+q dNrsHJRR8hFJHnHELoC0+MaNtj3bPXie3zx/jEaf0f8hNBRb596v+5SD3GO24D3vZErl uB/qL97p4efY9bMbaAnbHqYjg9zlQNkICAzzuQd4+N0mzjXVqtA0F7ZBX8YumXGfTbuC jzZi1K+wwaeDSPpqm0NVPuGc8iQYrA4NMntRFqDzmfHlQ0tG+FFpsTJOo+ULbT2FAqGV wMAqB5AexiGKUF8uXe0nEITk+zN/ZY3baEAQxP/4MNiIDgpdjemEaHq6gXVgoq6D9jGs Vk1Q== X-Gm-Message-State: AKS2vOz/uQYBJy92Xva2Xoav+eovr4mNClOQr2e6nPAslLNOud8ubKyU 4wuIOwv3CP0Mw9Bx X-Received: by 10.80.145.25 with SMTP id e25mr2717708eda.8.1498760553448; Thu, 29 Jun 2017 11:22:33 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id e28sm1446366ede.14.2017.06.29.11.22.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 11:22:32 -0700 (PDT) From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Thu, 29 Jun 2017 20:21:57 +0200 Message-Id: <20170629182206.1072-7-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170629182206.1072-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v7 06/15] bus: add helper to find which bus holds a 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" 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 | 23 +++++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 5 +++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 30 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 3094daa..276cce6 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -164,3 +164,26 @@ rte_bus_find(const struct rte_bus *start, rte_bus_cmp_t cmp, } return bus; } + +static int +cmp_rte_device(const struct rte_device *dev1, const void *_dev2) +{ + const struct rte_device *dev2 = _dev2; + + return dev1 != dev2; +} + +static int +bus_find_device(const struct rte_bus *bus, const void *_dev) +{ + struct rte_device *dev; + + dev = bus->find_device(NULL, cmp_rte_device, _dev); + return !dev; +} + +struct rte_bus * +rte_bus_find_by_device(const struct rte_device *dev) +{ + return rte_bus_find(NULL, 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 052ac8d..f8b3215 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -210,6 +210,11 @@ struct rte_bus *rte_bus_find(const struct rte_bus *start, 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;