From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id EEA352BB8 for ; Thu, 8 Jun 2017 01:53:40 +0200 (CEST) Received: by mail-wm0-f52.google.com with SMTP id x70so67280214wme.0 for ; Wed, 07 Jun 2017 16:53:40 -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=WcUqG+FByKeVJKjOrqj/2E4Zsh6jYX226zCax0QLN+w=; b=09ATk4h7VZyG3U5YNvEBLQwS5w2+921/SD5z5DhnDAz62IBja+O1Tm4z6gHrV/oz10 ulStZx4HCPEdhb+mbOgfRCbxfSqCshZqoWg7NybnuGvB6Vr417b8UJPC1EkFI03LDBv3 Qkm+VEUyy1s0aPGKfiaHu1U9acNl0/XKptobeiEaRcMD85jhpgs755bm2IEEAlwrevy4 cXYV7YZk1EmiN4YaoWDovL0lzHOHu/QM0jBhk1NQVJY4sfU6t2u54j0jOYRj4mP1pbnW 5fRau1z6/jmjRchq1AGJ5hqPKhdMpxV7SR4CsTAzyCeEPibxZqPL2wLz41qdFAgSjaC/ 65Nw== 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=WcUqG+FByKeVJKjOrqj/2E4Zsh6jYX226zCax0QLN+w=; b=eT0zDRUSQVw3Hvn/K3HawoInPOYMXUzy9Fgc12zogCaDYMgGqPXLfpTq0hKRGLEANd 6oUKEU3p+YmF68LOqesvdMRa6QrPCr8FQuxxoVwCxjgBiwY2InwoAI1MyNix5iutB5tM iAMXSjRkzrw9jHLw+Hrxh/BCh8jEtClUt5zhC+OTdYqeQ2CiXCrAiDHpZ9Plx++tC1T8 5qi3d+Yy7Fc6NisH4bC2XtCituk8KVaGEmodURayn+9IWeAV7rkUVT+yTE92udYbsm6K 6bZUprHYVmcdCRfKdUGQvjWfazFzRBcPBbsYxHO2wM7+VX8nTwujkYeu22ybQzU1otRr 8kyQ== X-Gm-Message-State: AODbwcDubmmzcBhJdNBAnz54QbGDOlrchDsMu7y3u+ZLHq21M3i51RjI FByKtj2Ory7eraK+/qw= X-Received: by 10.28.217.136 with SMTP id q130mr1461662wmg.80.1496879620368; Wed, 07 Jun 2017 16:53:40 -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 z23sm4589942wrz.0.2017.06.07.16.53.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 16:53:39 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Thu, 8 Jun 2017 01:53:16 +0200 Message-Id: <850cc8c7dd3465e77e94d8eb2e031fd9b02313bf.1496876710.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 v3 02/10] 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: Wed, 07 Jun 2017 23:53:41 -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 16bcfd9..e3f867f 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