From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by dpdk.org (Postfix) with ESMTP id C56A72BE1 for ; Tue, 27 Jun 2017 18:11:37 +0200 (CEST) Received: by mail-wm0-f45.google.com with SMTP id 62so29301712wmw.1 for ; Tue, 27 Jun 2017 09:11:37 -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=4GmqDB0QXe7uZgyaDR5kIhsZ1zbKC+RIx/jvXclgYGE=; b=r7zNg57U+ja1M/NknU1DmNrc1XM+kOH/4tHEXLvQcRhFmgEtutq39XHi5VCv8pKDqb MyGYw3JtZgSk0TZNYeENjDTgwHwj+N5uIiCcLuMxuxmJ2tplf7G1rGJn3SCimLH2e0Ua 6lVrJ6avDJ7To1qsQvUNQyjJc5XoDc6+SAfTjqVkLZUDT6+r974NJnQ+xSOOZnzgiln+ YeY7UDm1WvBUy2pmsUkGHfMWpxtDY63uYnQ0fnaoPLVdbO1vzx3mEi3q0ukxsMQPbQXZ S4HFdGPs7Nv5SXVtpIpwUIGp51we+pjJiYt9BfjXhsDGjGEC/U3Rwl/uHq/NVSVZOhLE y1hw== 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=4GmqDB0QXe7uZgyaDR5kIhsZ1zbKC+RIx/jvXclgYGE=; b=mtCvoeHqlDaiTQuueyx3x9Xg3eMfHZ/SE80ciS/LZoEXtOYtaXbLfPkGV3/9uKZwxE hRfkbvKyqsb7hChAkK3Z7klFgeBxcRKAQqlnWk6nouk+a11P0GvSDm+lsYvnvgKXAg5a uQQCQLh2hhiZfZ6NT1WJyleOiGsKBBz36GvVe4gVJRhPWlImMOhf8H32TclgNaNd1TXH T/YKExJxLxTidjdLfFgY/Lm7Vl4D59r7AwPT9VmPoVGFIPqSpX73aihYbyXKQI4BHFFI iVWwaKZ4wIqd/gL8o4nfbGOWkbMhc+jk0IbVAveCZRjHHZIW8hZYBPlUmoVe4mpPdpmb Oekw== X-Gm-Message-State: AKS2vOyYlBuqfUcrwg0TvuWlLHBVHRJ7mRdwLFsdjUTqmHEovIh0SEzt 6I48mCQqobqrHVUa1uc= X-Received: by 10.28.209.70 with SMTP id i67mr4125650wmg.3.1498579897213; Tue, 27 Jun 2017 09:11:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 09:11:36 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Tue, 27 Jun 2017 18:11:11 +0200 Message-Id: <7cc117b639fa2c7edd095b2955797a695269d7cc.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 04/11] 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: Tue, 27 Jun 2017 16:11:38 -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 | 17 ++++++++++++++++ lib/librte_eal/common/include/rte_bus.h | 26 +++++++++++++++++++++++++ lib/librte_eal/linuxapp/eal/rte_eal_version.map | 1 + 4 files changed, 45 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 e12dfec..dde6c83 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -190,3 +190,20 @@ 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; + + TAILQ_FOREACH(bus, &rte_bus_list, next) { + if (bus->find_device == NULL) + continue; + dev = bus->find_device(cmp, data, start); + 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 ee7b8f0..9aa047d 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -212,6 +212,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