From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) by dpdk.org (Postfix) with ESMTP id 3A7A87CD7 for ; Wed, 24 May 2017 17:05:38 +0200 (CEST) Received: by mail-wr0-f175.google.com with SMTP id j27so3018479wre.1 for ; Wed, 24 May 2017 08:05:38 -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=+x3Ocdz1aYI2vDMM+PZQFdFvnPhQGkX1aafp0dvAvY8=; b=uN8q4NUg4f8TyzWXvVHRSfIfIB8wvTpEfuXhloo5PwXgp4S+HpumystC6nPwJA68Tb j3mIwbZYFZVmBV4hbhwZXK8s01UsKDTbao3ZQ9jZk/cI2wUTU+9Nn0g7Xk+vxP/7dZni neNxbjw6eLMPzHge9ASQjB+jkf21RoQFOXY+b8/Qm9FE9/oSEt5oPgxl3YqoOXWG8pG9 n+tC+ZhuRDekfmHYp71P+Rl8dfm4o+KZC0Atksk/LrrkR7VQh/ePkFUN3+LZ/gtMx1hc GERo9t21uU7Ia8peJNuGlHme1oipHYsAUlw/2X562GYcrjyl2fNX8DjR8Pejwv+a/O5l 7oYA== 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=+x3Ocdz1aYI2vDMM+PZQFdFvnPhQGkX1aafp0dvAvY8=; b=LzJlVgSs7KBS+aIvpXBK1RhbN1ttQJJcu/qJRuIQcJSIZJavhwYbvL+ooENK20nrgP azWzyU0vnBOOMLOjlQDpDWnczd7He2sc4vQ8ISSW1Ft6srSV46RHqZTXBsGaIDzYB5l9 TgzpivAEbItdTaybvr2Mj7dXZYMNZBTWFVQj4FNd6BdM+zA2huPjcMXVNELR4lLosJxG ruKAEqBmyPdc7Azv0VTSrcNoZ5rvtTJVo+eF/XY6u1oK3KHPHwKR5F4HsNiN5gP9uxXk AeyKOS0oXpYorXo0Z4gKqWuDi/ckDIH0ui1fS+sdVMgTRtCc+aGFL9VvRjuDTKEifPkV Qk4w== X-Gm-Message-State: AODbwcCPWI89KHON3mq1cjckbENvgLq9Jp/swpmO0EucwbSSjrzAMzG+ NDDwNQQ2fCB1X7iy X-Received: by 10.223.171.79 with SMTP id r15mr22949797wrc.149.1495638338555; Wed, 24 May 2017 08:05:38 -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 25sm4076017wrz.8.2017.05.24.08.05.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 May 2017 08:05:37 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck Date: Wed, 24 May 2017 17:04:55 +0200 Message-Id: <22ab2fb7576a941e7d6f3bd7c05acf7c25520b7f.1495637723.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 3/9] 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: , X-List-Received-Date: Wed, 24 May 2017 15:05:40 -0000 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 | 22 ++++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 5 +++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 29 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 41926fb..97bcd65 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -160,3 +160,25 @@ rte_bus_find(int (*match)(const struct rte_bus *bus, 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; + + 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 fe31f03..1707a1f 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -169,6 +169,11 @@ struct rte_bus *rte_bus_find( 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; -- 2.1.4