From patchwork Wed May 31 13:17:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 24895 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B2BF3567C; Wed, 31 May 2017 15:18:18 +0200 (CEST) Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id 270813252 for ; Wed, 31 May 2017 15:18:11 +0200 (CEST) Received: by mail-wm0-f49.google.com with SMTP id b84so118887638wmh.0 for ; Wed, 31 May 2017 06:18:11 -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=k5kiA00D0yq3KQzTeI3dn/kYZacunCSGT+CrfuZ0+gc=; b=vOrL37Ye4jGeH/EqL2cJa9zcNedxQPQEg8T7Zv2GwmTxAXBvnQERdocrSXboKUB/w0 55oFrgAJ/CfA1DKR8eyu4mWKSG1xsR9t47mQrDT3H4mk3ANodTkAjEabGvmdwkUWeTfU vTrcWSxxi1jZZRnoUyP18NbBydk9dbhdu8WmHsABysFfaj0njiPoCeu91RmPNVlKgiHw WzkA6hTGBzHd4ie125DEjPBb6sBl+yauLWW0CkU+kaRK6LhGkkmWiZpzQk1JYfo1oxEY Swuxpcdo0ayCUOsv1+HSO+iqwcD6VQvpFOLoyrD8tZajGg7pipS/LFppgX//7+RK2JhQ kDBA== 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=k5kiA00D0yq3KQzTeI3dn/kYZacunCSGT+CrfuZ0+gc=; b=U2KtnDRrjBgAXsZoaK81UzG+qZUxC0NzRatImDxPmVTICeO3EePNDSdNAw7iygg/aa uzbf2C9Ei+bDDPHpp14bodadIhujC5QduvxNbcQ7qaj3q85tiZxojcxKL1r1ertSqIng Xx/7fzDFVFtSaz5O2ZnMYoDiRRdd/wIrmt43Z9da7gVoegewGuGdXEKSaHGREVGQKkCa /ydcWTL419CP2kS3vhmjLXTNAtIxW0bBGImxmvR5XozN5QyKpXQmc6Odcl/qYA9QV7Bn 1kjgcqYFYaR0ehKjwo3JvMqOJSFQZYwXeUCXahczUdJiWbnOo6UMtpvAo4ZFHCDYR4bl jqKA== X-Gm-Message-State: AODbwcDHr2MtMTj7r4XHLa3O4FTy04jgXhpyA4xw2ZANc18eOvkp/d+Q j7UqgxYDyrFzei37+Wc= X-Received: by 10.28.136.85 with SMTP id k82mr5106663wmd.55.1496236691097; Wed, 31 May 2017 06:18:11 -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 g77sm10045744wmd.19.2017.05.31.06.18.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 May 2017 06:18:09 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Wed, 31 May 2017 15:17:47 +0200 Message-Id: <7ec2fab156377a36c6f3911aaef4d3c8a54e4bda.1496235017.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 v2 02/11] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index 006feca..4545b03 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_match_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..f017814 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -191,6 +191,21 @@ int rte_eal_dev_attach(const char *name, const char *devargs); */ int rte_eal_dev_detach(const char *name); +/** + * Device match function. + * + * @param dev + * Device handle. + * + * @param data + * Data to match against. + * + * @return + * 0 if the device does not match. + * !0 otherwise. + */ +typedef int (*rte_dev_match_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) \