From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by dpdk.org (Postfix) with ESMTP id 0BC943259 for ; Mon, 26 Jun 2017 02:22:29 +0200 (CEST) Received: by mail-wr0-f182.google.com with SMTP id r103so131767986wrb.0 for ; Sun, 25 Jun 2017 17:22:29 -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=ty/p8/hDPmV/TEtfPDppb+xiE9AYh1qBm/InbxFwgIo=; b=lG5FVODp5/1Z7M/ri11YSXQ0k0a5Wh0IElN5d8GW4tTwxzCltRXqu/OTIXZ4oleWVr M0uMILrRFd5mgibr9/wID0GDm2UOtXXgw+4kdy6khtZJjRSmAxmNfQ6W+Qa6Zvvt4v/x 0wOiqScJ4rVQWA0ybzJJyywubQZpNEFLDoQY1z3zK8knnEVsl2AyefmJjyCNpKIN9SVl a2cBsVZ9YONuY5DN1vo4DMXPiPBAf3lOkFGK79ZtQzKMzGKw4j1VG4cvTFP5Z/C8A37d 75hV4/SjQ+e2rhl9TvkJlvfh1mGQLB/kmYiuDfZU57P1E3fUs+stM/A88RV5ddBd7wxi FDOw== 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=ty/p8/hDPmV/TEtfPDppb+xiE9AYh1qBm/InbxFwgIo=; b=Rw2APL4Z+opwGNeEV7bzr/1JHzRNIupRm7xX6ksIjSpSA87YZC2msTw8wYpXNDioNv rBX7t8wxCNGajYmrrNe+Ls6xx3ICEk4Em7oxXUh1EuFZSktbLjIujYWWz8sqOkcKgQRL JsMmjh/2cfB5U5mjjsgmeJlTAZ4ZTo0qd34KiTWESdRa7/xT/4MCPv5ulodvSEZJr3JP EoDdqoJ7JLc9Jtwa8E5SIskceJZq/4Yww10eFPDb6z8mlXGXg2KK1ckS7WkfP1wwKqfe +plVkVs6qiGM6DPtth46HjMFU0ccgmWDwcxwcqpijZKqTqqiRrKOsH/ZHYDWQ8rJqi+V x3Mg== X-Gm-Message-State: AKS2vOwgY8nZ+blLCOlncIx0o+QLAWULwORrcuFBnIt5K6JJVyrjiFfY XqG1+1ur/+Zmx/PWuWY= X-Received: by 10.28.126.133 with SMTP id z127mr11304259wmc.46.1498436549246; Sun, 25 Jun 2017 17:22:29 -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.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Jun 2017 17:22:28 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Mon, 26 Jun 2017 02:22:02 +0200 Message-Id: <0094d130d0bc93de5d676b67aa28acf6dc81d37b.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 04/12] bus: add bus iterator to find 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:30 -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 | 24 +++++++++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 26 +++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 52 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map index f1a0765..21640d6 100644 --- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map +++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map @@ -164,6 +164,7 @@ DPDK_17.05 { rte_bus_find; rte_bus_find_by_device; + rte_bus_find_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 d208214..63fd9f1 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -190,3 +190,27 @@ rte_bus_find_by_device(const struct rte_device *dev) { return rte_bus_find(bus_find_device, (const void *)dev, NULL); } + +struct rte_device * +rte_bus_find_device(rte_dev_cmp_t cmp, const void *data, + const struct rte_device *start) +{ + struct rte_bus *bus; + struct rte_device *dev = NULL; + int started = start == NULL; + + TAILQ_FOREACH(bus, &rte_bus_list, next) { + if (!bus->find_device) + continue; + if (!started) { + dev = bus->find_device(cmp_rte_device, start); + if (dev) + started = 1; + continue; + } + dev = bus->find_device(cmp, data); + if (dev) + break; + } + return dev; +} diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 5441af9..3e83227 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -203,6 +203,32 @@ struct rte_bus *rte_bus_find(rte_bus_cmp_t cmp, const struct rte_bus *start); /** + * Bus iterator to find a particular device. + * + * This function searches each registered bus to find a device that matches + * the data passed as parameter. + * + * If the comparison function returns zero this function will stop iterating + * over any more buses and devices. To continue a search the device of + * a previous search can be passed via the start parameter. + * + * @param cmp + * Comparison function. + * + * @param data + * Data to pass to comparison function. + * + * @param start + * Starting point for the iteration. + * + * @return + * A pointer to an rte_bus structure or NULL in case no device matches. + */ +struct rte_device *rte_bus_find_device(rte_dev_cmp_t cmp, + const void *data, + const struct rte_device *start); + +/** * Find the registered bus for a particular device. */ struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev); diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map index 6f77222..e0a056d 100644 --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map @@ -168,6 +168,7 @@ DPDK_17.05 { rte_bus_find; rte_bus_find_by_device; + rte_bus_find_device; rte_cpu_is_supported; rte_intr_free_epoll_fd; rte_log_dump; -- 2.1.4