From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f171.google.com (mail-wr0-f171.google.com [209.85.128.171]) by dpdk.org (Postfix) with ESMTP id E8873325A for ; Wed, 21 Jun 2017 01:29:48 +0200 (CEST) Received: by mail-wr0-f171.google.com with SMTP id r103so111470596wrb.0 for ; Tue, 20 Jun 2017 16:29:48 -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=PuBxlAHffvPYvfom8aJjAl6r5gEUw7yko+aTzHZhFhs=; b=wM20KTG6+8AU9VvEaQY8RwJnXz8LgW55GMp84o4MXoq7Zm79sOb40A4CRxM7eFTfAU 6iyS5vswCVe4RuVDXsaGaJe7Pi/EehQ6MF7HmN9/7ME8Zzeacma0fPb0DdMlcjsOI9+G zChuELE/NuE9yIBuQSn45fVHeEPBWJ/m4h6a3AHPopWRDZB+fr7iCygYrp4PDRAGsymC Fbr+h15mQtH3iIwxZbW4C4O8yCseIPtfFiHmDr1tb+31/3woKMuQKIfHc8Pl+jTB8gvi FDeLyMvk+gT/ucTBZU+g9KYWYXXlwTCxucMdzdQtfo7p1XilbkqhYqWD+YlY1OSXLqa5 Hzjg== 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=PuBxlAHffvPYvfom8aJjAl6r5gEUw7yko+aTzHZhFhs=; b=nAiS7izrzFgQUPO8sRosI8myyH9nhaHmLeyT8HT2UsNJoqfMG/5CxO7FDXRJA0hd6i SmN0XDRKXHrPR4VMSdJ7fpM0rZDVHDDWA8faYLrXKtn9uQsXo76MBUCTagGMvpGA9Bui /MY/5H2q3IL/FgdPp8wHtZIx+tvtT8WQstWW8mVczNpxM/IiRJDNiU/TDpNGIBnUzD8k nVVfLIYtds2E+2U4nxJaORJ9HKtm0oHd/lkPgxV/jW/dlDSPmgckiIqEUDLNSxz1xFGE +9XvySJRR9NP3ol4QY8vtlR0kIuXC2fSY8PZ9LQ10P0RL5YyqbB3JoexwR19R/T5zHla HJ8Q== X-Gm-Message-State: AKS2vOy9F/AhdNidgKKfSUUmyuR+jQwu2l8uCSsT711FR0dJDMLlECUy nluy1nGwpQqRw7icYw4= X-Received: by 10.28.69.67 with SMTP id s64mr4634782wma.100.1498001388243; Tue, 20 Jun 2017 16:29:48 -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 l127sm8592248wml.26.2017.06.20.16.29.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 16:29:47 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Wed, 21 Jun 2017 01:29:23 +0200 Message-Id: <24f6e244a99903f543925067aa52baafe10cfc84.1497999601.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 v4 2/9] bus: add device iterator 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, 20 Jun 2017 23:29:49 -0000 From: Jan Blunck Signed-off-by: Jan Blunck Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/include/rte_bus.h | 7 +++++++ lib/librte_eal/common/include/rte_dev.h | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 3e26d4b..fe9573f 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -82,6 +82,12 @@ typedef int (*rte_bus_scan_t)(void); typedef int (*rte_bus_probe_t)(void); /** + * Device iterator to find a particular device on a bus. + */ +typedef struct rte_device * (*rte_bus_find_device_t)(rte_dev_cmp_t match, + const void *data); + +/** * A structure describing a generic bus. */ struct rte_bus { @@ -89,6 +95,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 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..724855e 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -191,6 +191,23 @@ int rte_eal_dev_attach(const char *name, const char *devargs); */ int rte_eal_dev_detach(const char *name); +/** + * Device comparison function. + * + * @param dev + * Device handle. + * + * @param data + * Data to compare against. + * + * @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