From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 61857A48F for ; Thu, 15 Mar 2018 18:50:17 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id a20so24177358wmd.1 for ; Thu, 15 Mar 2018 10:50:17 -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=ZKLlmt+MUzx5gUSPifm7M/0XGwKXEFcKyiRGewA0Ykg=; b=JpktMRUJqX8MnugITdoM70yoUUs1DVH7Wp5naq1RXH7xu5WLIk6WNomPLaZF/U09dp 0emfXiIoHTw520z/NZHemiKsJoQfY4EEoxxIrmud1sgb1jbbuW6kYDWpxBA8ooeu0n2L 5Qtil5g0K3aXydLOm0tAPMCzK9Te/ZuHTdVquTn0tqnypHJ0KqAFpjgPH+pe2QiTwMFi YrZJ1pM6CZ+IZ4qofpbCBiseNeKA3VBval95uhhyD6kmX+ISuJFiEwciWbc2BNuIwKUI liG5jCaYOuqklXWiKKiq2VcWm1K2tTnU4C5e3f6aH7kdaTC5LlDHLBaeEdKjP5L/kvrl pW1Q== 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=ZKLlmt+MUzx5gUSPifm7M/0XGwKXEFcKyiRGewA0Ykg=; b=DySKVqE2KIoTcOrJNLuOQjK220BIxxVZXP/epCkyuCflNAVKAikBf+L9mvVk/+tG+I BurYIjlCMOLoHfP5SYORxJsq3dIgsvHzJ0i+M9o4YP93tnDgwSpqu5dnlI5ya5z6vxcv ffmoUCNiK7xkDooKDvpr8J1HQxm+0ElaOys9CPjWydSH1CST3vaXCaPCEZmCUD9FCJdK I6oRaZLP91FvLxbx0/uhZ7V395kXcXwFOFo3X7qNpvhtyQznS7MHCHBgMIWAyhgoMT2t SjBgLAlwcXfY902cWg+O+Vjb0d/jNehiiGpU4CaVMxiRBPjzrgRsB0HwJGDQNkE+Kr6t VIJw== X-Gm-Message-State: AElRT7HkfVug4cgGq1/hFDNbR59cPWTYcU9gc8mExipei/dMUoMvdbKT mapgmYlkKIO9PERKFMMw3D/plnQC X-Google-Smtp-Source: AG47ELtSqlEKZpU/E98gR9Xziis6gM1Gb+dZmFstfQ78WJ0aDrurAsIiYOpUL/C7aPzhgp5q5XSKkg== X-Received: by 10.28.159.209 with SMTP id i200mr5083091wme.87.1521136216614; Thu, 15 Mar 2018 10:50:16 -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 69sm4756596wmp.36.2018.03.15.10.50.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 10:50:15 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 15 Mar 2018 18:49:35 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v1 05/18] eal/dev: add device iterator interface 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: Thu, 15 Mar 2018 17:50:17 -0000 A device iterator allows iterating over a set of devices. This set is defined by the two descriptions offered, * rte_bus * rte_class Only one description can be provided, or both. It is not allowed to provide no description at all. Each layer of abstraction them performs a filter based on the description provided. This filtering allows iterating on their internal set of devices, stopping when a match is valid and storing the current iteration context. This context allows starting the next iteration from the same point and going forward. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/include/rte_dev.h | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index b688f1efd..d272d7191 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -263,6 +263,42 @@ __attribute__((used)) = str static const char DRV_EXP_TAG(name, kmod_dep_export)[] \ __attribute__((used)) = str +/** + * Iteration context. + * + * This context carries over the current iteration state. + */ +struct rte_dev_iterator { + const char *devstr; /**< device string. */ + /* Bus context. */ + struct rte_bus *bus; /**< bus handle. */ + const char *busstr; /**< bus-related part of device string. */ + struct rte_device *device; /**< current position. */ + /* Class context. */ + struct rte_class *cls; /**< class handle. */ + const char *clsstr; /**< class-related part of device string. */ + void *class_device; /**< additional specialized context. */ +}; + +/** + * Device iteration function. + * + * Iterate over a set of devices, defined in comprehension by + * the given iterator. + * + * This function must update the internal rte_dev_iterator ``device`` + * field. The ``context`` field can be used as an additional generic context + * when the current ``rte_device`` is insufficient. + * + * @param it + * Device iterator. + * + * @return + * The address of the current element when the stopping + * condition became valid. + */ +typedef struct rte_device *(*rte_dev_iterate_t)(struct rte_dev_iterator *it); + #ifdef __cplusplus } #endif -- 2.11.0