From patchwork Tue Jun 20 23:29:24 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: 25466 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 2D1985583; Wed, 21 Jun 2017 01:29:58 +0200 (CEST) Received: from mail-wr0-f169.google.com (mail-wr0-f169.google.com [209.85.128.169]) by dpdk.org (Postfix) with ESMTP id D2F14374C for ; Wed, 21 Jun 2017 01:29:49 +0200 (CEST) Received: by mail-wr0-f169.google.com with SMTP id r103so111470988wrb.0 for ; Tue, 20 Jun 2017 16:29:49 -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=RWXiNPbKI1m2POko7el+yQpXbf4nbzaf1xYqHrRhfo0=; b=ddHL9jWcWPDva7yXFUUnp86M+kor1Pf/XT8Jy04R9kmhkMynWuHZx9NBXLhohXZdlI CYS90BCepUq1y+5TId2aBZ6CByQb3aa0Hy8lxMH5Je5eyORl2xD0A9D9FDS4qW9Qh2Wa 1Ui9rGBHd6aDipDqEpCfuyaKp/MdqrH8v7E8LOcm5dszP4f9kFGxtzmb+ZDBOtJBWBID TNligGhKqf4pX9xDVzSLAoykt2usIGoOCRB1+fGIJ4UqiwjCa1Ew/j9h8JIBY7MEZID9 bZ8Q7//PIwbJMJ0ftGUL9j2FhuXk4Bd3mU3ShMHvC+GpKB3kOrOh8OfYYDk+Y6z1VOVU vxAQ== 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=RWXiNPbKI1m2POko7el+yQpXbf4nbzaf1xYqHrRhfo0=; b=dtITdCBIsB5YDh+YJJxlMKpMVcC1uDhHUmFTFI9oM7JHIYHQkXuxk/4wbJEVMwWkXJ sMDtjan4lNRIpzfF2oW2kA81yUfF2Nl0Yd3Rtmic01+qDoOx5X4MgtBI0RVJ1yLPvPyq 6ngbX1LIv85za3eJqlu6OpFFzgRNajvTe++yrfUQfe1SO2u3GQEPu/mqLp6shLqhF4Sy wvnXFHjuMA4S25Sck0WyodyN644swoFzmgBfuIFMbpj1KHDcYeJwzHC8pEygAtpoypjK kz3eM8+CaonCDLzBLnBC8kSvV6nrzJWfqNO+n9mSMPwJ+YZsEYczZC5KGIBUkH/2LwnM tuqQ== X-Gm-Message-State: AKS2vOzmCsVGyV2iY0olKsyNdyiV9Lv/3deokmNHOWgMniOU0Xw4kF8v wE5CD952/Q0p6lcmBnw= X-Received: by 10.28.174.131 with SMTP id x125mr4442026wme.47.1498001389239; Tue, 20 Jun 2017 16:29:49 -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 l127sm8592248wml.26.2017.06.20.16.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 16:29:48 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Wed, 21 Jun 2017 01:29:24 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 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: , 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 4619eb2..a38b576 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -165,3 +165,27 @@ rte_bus_find(rte_bus_cmp_t cmp, } 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, NULL); +} diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index fe9573f..fa12f55 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -189,6 +189,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;