From patchwork Tue Jun 27 16:11:10 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: 25829 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 576475699; Tue, 27 Jun 2017 18:11:43 +0200 (CEST) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id 918322C2E for ; Tue, 27 Jun 2017 18:11:36 +0200 (CEST) Received: by mail-wm0-f42.google.com with SMTP id b184so31870197wme.1 for ; Tue, 27 Jun 2017 09:11:36 -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=igk2lgY2LpeYERdRwKEiHml8kJNt0zp82/N0abvPIrI=; b=AoX62SATGjaU3yqK6q9U1aqddh228OwxRE7sBIpk/hmMKTq+lYKQXoDDbm1I9aJSfB KjWoRuFGpfHCZ9ITYLfxHotb9HsGsmY7Y707w2/dtYkH1o7BJW52k8gia+M3364qy0DR ucXCBExtapDQThJ0rXGc4G4awyc6UOfLj3V/h2hJjnzOyr0BciZAFnzVSyTADon6cJMx 19uS++aftyzu/WUxMn1w7jSi4cmt2I+ELuS28+dRN6UpqcHabuESB6xHG0GgbeJ/WicO M4hD+NDrF778dE6hWphzxLFnTd/jXngJTjEkz5p/0sKGJyRr1J3hF5mKK1rL9o6AyxwH 1a+A== 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=igk2lgY2LpeYERdRwKEiHml8kJNt0zp82/N0abvPIrI=; b=kvEFZtfOCXvfpSh3oglqDg/C/PdlUInC6zrThPwh9JROV040hJg3e7hbHuB2827E2Y g5mbWXIO6/jgSsuCIiXEmz53/OYD/lesA5zO1R6o5xfWZNziTJhWHP2UVqRDOi1ebGA1 mSC0FuTJMfsb8KDlXgduGw3pB9veXHQZpirWPpErsCQA86bdYIvzMJqCKbTid9DFRBC7 IcdJ0vdkWxtsFSeFBeiApTLNgCkRes/cLskvRf1UPK3/rFpBuyY/2HT1W6GzE8IPHk2b 0AmJkoSWZNamjb/VItoFsv+IK9km1EBZGMeCwZik/UfpwQlfcAJsZZM0huPw2QavYQOa gPlw== X-Gm-Message-State: AKS2vOy98GIIx0S10MVqbMck+WucCj7R6rNX6/Ny9KuPx0Q7vP51O9fB vztrxTHGWPPM5ub66Ig= X-Received: by 10.28.144.6 with SMTP id s6mr4122293wmd.118.1498579895989; Tue, 27 Jun 2017 09:11:35 -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 v13sm4080465wmd.5.2017.06.27.09.11.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 09:11:35 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Tue, 27 Jun 2017 18:11:10 +0200 Message-Id: <0063566dbd036f566a844dd12e0346b3a4412f4a.1498577192.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 v6 03/11] 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" 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 | 25 +++++++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 5 +++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 32 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 86a54d1..e12dfec 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -165,3 +165,28 @@ rte_bus_find(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; + + if (bus->find_device == NULL) + return -1; + dev = bus->find_device(cmp_rte_device, _dev, NULL); + return dev == NULL; +} + +struct rte_bus * +rte_bus_find_by_device(const struct rte_device *dev) +{ + return rte_bus_find(bus_find_device, (const void *)dev, NULL); +} diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 51f41d9..ee7b8f0 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -212,6 +212,11 @@ struct rte_bus *rte_bus_find(rte_bus_cmp_t cmp, const struct rte_bus *start); /** + * 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;