From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f174.google.com (mail-wr0-f174.google.com [209.85.128.174]) by dpdk.org (Postfix) with ESMTP id D3E32968 for ; Mon, 26 Jun 2017 02:22:27 +0200 (CEST) Received: by mail-wr0-f174.google.com with SMTP id c11so131613724wrc.3 for ; Sun, 25 Jun 2017 17:22:27 -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=hyWM8OnA92WyfT2G/SlYh971+jemHYegLCnSpLNvYJo=; b=elr2PfeOd+pJHg+NhgwnWAlZRJbnslCDcQ/J77VbOCYEdtm40fOobF8/kGmUEhYvW3 pWz9sAi8INYbcW7wEXAbXZFDHc8RMk3TavKvt+V4TOD5mwjr+38jFAL1KPpbBn9eKL8U lnXGVORCFn4BQxQ4Dd9URiHbaqEoBvS59/AZ3+PHbmBguwc5w07jO/wKiPmPIZpQWCl9 ZQ0HnQwDh3jQt4N7Gtv7tKKJeqwAA6knjtOZGMxGAJy0CqYT4ZUdvyIGq6X5DiERtgSl 2+sI+Bu3MvLHJKVci9kO5/MoFqFJBsFh74058Kjp0amCRD+Xea616vGzQ5ng6gwBy+Ft rdKA== 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=hyWM8OnA92WyfT2G/SlYh971+jemHYegLCnSpLNvYJo=; b=AKBf+vy1mgs9NuT8ysi7oWT2dzCergmP22kV1h0gsATeny3Utq00gFx4PAtc27Qz2O 9hNn8c1HXzXcQz5UknWI6QGPl8T1pZtNfjFhLsN4pa2iwRIAx3IAisUmM8d0ygA4gH1q YrH5piI33ufIcfVmnT3/DbjZ6rkhs+FY7DdRKau7qMLCbrKyIWKoj1xdC4Wn7QDYzy41 oFqzs/TEwFa0nDhwQcYcwcKNiWhG8gN17tUiifj6A5KnlYfmkn8ailSMGoo4QfVZPNIR oa7ndcmAEb3a7CX/xFxjvwqNRJ5rHHWn9m85L6RX+rkQwC7RS4WhKN+nb3jnmaxvxQ8x uxHA== X-Gm-Message-State: AKS2vOwt/NerUnInESJgprBfzMzSbsPFaWMntTeiIgPXNRBRhNc6sXRo 4kBamk+Dsr2Zdp7emD4= X-Received: by 10.223.144.134 with SMTP id i6mr13238788wri.92.1498436547131; Sun, 25 Jun 2017 17:22:27 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Jun 2017 17:22:26 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Mon, 26 Jun 2017 02:22:00 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 02/12] bus: add device iterator method 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:28 -0000 From: Jan Blunck Signed-off-by: Jan Blunck Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/include/rte_bus.h | 19 +++++++++++++++++++ lib/librte_eal/common/include/rte_dev.h | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index ecf839b..5efb76e 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -82,6 +82,24 @@ typedef int (*rte_bus_scan_t)(void); typedef int (*rte_bus_probe_t)(void); /** + * Device iterator to find a device on a bus. + * + * This function returns an rte_device if one of those held by the bus + * matches the data passed as parameter. + * + * @param cmp + * Comparison function. + * + * @param data + * Data to compare each device against. + * + * @return + * The first device matching the data, NULL if none exists. + */ +typedef struct rte_device * (*rte_bus_find_device_t)(rte_dev_cmp_t cmp, + const void *data); + +/** * A structure describing a generic bus. */ struct rte_bus { @@ -89,6 +107,7 @@ struct rte_bus { const char *name; /**< Name of the bus */ rte_bus_scan_t scan; /**< Scan for devices attached to bus */ rte_bus_probe_t probe; /**< Probe devices on bus */ + rte_bus_find_device_t find_device; /**< Find a device on bus */ }; /** diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index de20c06..04d9c28 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -191,6 +191,27 @@ int rte_eal_dev_attach(const char *name, const char *devargs); */ int rte_eal_dev_detach(const char *name); +/** + * Device comparison function. + * + * This type of function is used to compare an rte_device with arbitrary + * data. + * + * @param dev + * Device handle. + * + * @param data + * Data to compare against. The type of this parameter is determined by + * the kind of comparison performed by the function. + * + * @return + * 0 if the device matches the data. + * !0 if the device does not match. + * <0 if ordering is possible and the device is lower than the data. + * >0 if ordering is possible and the device is greater than the data. + */ +typedef int (*rte_dev_cmp_t)(const struct rte_device *dev, const void *data); + #define RTE_PMD_EXPORT_NAME_ARRAY(n, idx) n##idx[] #define RTE_PMD_EXPORT_NAME(name, idx) \ -- 2.1.4