From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Blunck Subject: [PATCH v8 03/14] vdev: implement find_device bus operation Date: Fri, 30 Jun 2017 20:19:32 +0200 Message-ID: <20170630181943.23929-4-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> <20170630181943.23929-1-jblunck@infradead.org> Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com To: dev@dpdk.org 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 F384B532C for ; Fri, 30 Jun 2017 20:20:04 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id p204so9336067wmg.1 for ; Fri, 30 Jun 2017 11:20:04 -0700 (PDT) In-Reply-To: <20170630181943.23929-1-jblunck@infradead.org> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Jan Blunck Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_vdev.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index b4db2be..9bb7427 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -334,9 +335,29 @@ vdev_probe(void) return 0; } +static struct rte_device * +vdev_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, + const void *data) +{ + struct rte_vdev_device *dev; + bool start_found = !start; + + TAILQ_FOREACH(dev, &vdev_device_list, next) { + if (start_found == 0) { + if (&dev->device == start) + start_found = 1; + continue; + } + if (cmp(&dev->device, data) == 0) + return &dev->device; + } + return NULL; +} + static struct rte_bus rte_vdev_bus = { .scan = vdev_scan, .probe = vdev_probe, + .find_device = vdev_find_device, }; RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus); -- 2.9.4