From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f172.google.com (mail-wr0-f172.google.com [209.85.128.172]) by dpdk.org (Postfix) with ESMTP id ACAFB3258 for ; Mon, 26 Jun 2017 02:22:28 +0200 (CEST) Received: by mail-wr0-f172.google.com with SMTP id c11so131613959wrc.3 for ; Sun, 25 Jun 2017 17:22:28 -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=Kq7iPym762/r6xBV5IVbQxJS8ePY2wKtxqQwUqrdo2E=; b=mm9Tle3BSY8yYXe/Qzl62q8lj/LHfiTuB0ojrT63r5+3aMOZEZiOURap1H1ieCD7uS FnGMvJOgVUBrkCk2TPI1q4tsA71zykv0Smr86RCoCj6z9h5CG/V/e6qBdsBykjLZ0rIK 9rLnHPozUrgN56robu7BLHEhR2hZvXFu8uyWI+XFd2iZ+qMcfivuq46OIylH7KD/Vg+s b+zeW5MtFHh2G1JBR2CMssQD3pxHjjqO2+qhQWXwBp3OdU9bOY6XRJOfk1vENADKiXT2 dfqgS7Dvbs7B0cldaGhFrEuCqWEcGf77E6A8neq2cpe3S9ERYc/PK2Nen90U2a/ghCox IQ8Q== 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=Kq7iPym762/r6xBV5IVbQxJS8ePY2wKtxqQwUqrdo2E=; b=qGNikNH209ZtU6pUjtZtAx2q6HOjm8azz3I7/782eRvJHfrvwnoNVQQTiuvzmTrCQc s+QVOZpPbLvblHEaAFWQUHIzG7h3pjYzgLw7MjD2Jfc9pt30BAzD69PsbOKqC/XzwneW JCAsvbgg21Ortcld1E5REkIbAAVN+vMJz4uwbq0kguIvDKuY4wZPa3X2WBibKTFZqsGF D+0+/0dnlf0m3Nst2X5OzoWTdcqIbLsy3WlMUxuVWQtVWxgfG2CO0hxiE4NJZbN0sPXM KBR3C4kJx6Dxemx6hgap6SKAy1rAqaI2oHCt12XKPRW8HD62OQ8N4bjEKdNAuJa67gKZ 9wXQ== X-Gm-Message-State: AKS2vOxk5141ijMTvrF/S1wsPk8dvlx5zZcH6d2oCxelqdt+/TP7B67Q pOBKNA9z9XfvWGV8+UM= X-Received: by 10.223.176.253 with SMTP id j58mr11357950wra.65.1498436548131; Sun, 25 Jun 2017 17:22:28 -0700 (PDT) Received: from bidouze.dev.6wind.com ([62.23.145.78]) by smtp.gmail.com with ESMTPSA id 19sm16061626wrx.26.2017.06.25.17.22.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Jun 2017 17:22:27 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Mon, 26 Jun 2017 02:22:01 +0200 Message-Id: <7250ec82b1b0a8ce1852327dc35d7155c08c7570.1498436062.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 v5 03/12] 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: , X-List-Received-Date: Mon, 26 Jun 2017 00:22:29 -0000 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 4619eb2..d208214 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); + 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 5efb76e..5441af9 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -203,6 +203,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; -- 2.1.4