From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id B5F61AAA4 for ; Tue, 27 Mar 2018 01:19:24 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id u46so20509237wrc.11 for ; Mon, 26 Mar 2018 16:19:24 -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=UG99PNhBWn0dooLZ/PY+QrvUMr2vPnKJsH4dx8dVEoQ=; b=2CrjlTTMei+D5o2dyh9uMBvjbm6XNbucRFdt+/AVu/rgcXoKDlQTcaoHwmAZq4az15 +h25iKVwyuFEbaBOwr6n/dCV2pPHngFXgsAHYIh8qdp93FvF+OWR2/GF7iioTPRK1h8C fUJCNt6KgG+xkM32tDRCmzGYmt0MINpACIMea9KKi7oEsbkDOB7XLV+vvlF3PcvokQ2X d/i4LhKUXo8zsDLdZGbR1XgSmx+wvFMZDzmj2K90n28FenMPuyyqMG9h6gZRNxs/acv0 A7GFou8aosGUY1pwPrIes39/TLtJ8WxK8HA9AUI6mUPR8YaaND03j5GI8krfljGDGtze ouXw== 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=UG99PNhBWn0dooLZ/PY+QrvUMr2vPnKJsH4dx8dVEoQ=; b=FRLVJZBM76ElLTk+w20pYaWJa2E6RG07l/v9ET7Qi1cqT9KP3QDV1OSaYZdrVJBJFT /jdPvNfNEgaPdhUWz4CfYzXF+l+mUlRUy9VwWB4wxjUkV3G1DBCdT4dWnWrm/0zzR3kt jvIk6ZuM+LqwPdXAjI5/0RUcYr2kVsii77sLfCCBPCb9U6V4CQXYtBRgk1DQvmGLEgj1 qJ0Ui9/CUsysoMZ4PFpfoXSJ/h9weVjwtR8KDjNzdXIRBp4MmGG4AzCKkC8zJrL0LTU4 4FQRHxezIN/WoNYEqIFKFrqY6mDxI0uzZL2jveY8Fsoz/uKtvhKM048CvekPjfs+bziS LeSw== X-Gm-Message-State: AElRT7FPHAaxqlB5dh06+Baf6sN8RYchFQ6Pufq7PQAGL6yrxNDLj+M5 W6Aupd2htSVVdwDlNemd2JyA/QLY X-Google-Smtp-Source: AG47ELvtXQFrKDyj3ebB15qHbDpJPWPJpal3UjdkutNC5TFnf07MaKGcY5BV1Sw+q8waESkJlYtJCg== X-Received: by 10.223.129.199 with SMTP id 65mr26836095wra.159.1522106364012; Mon, 26 Mar 2018 16:19:24 -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 67sm343712wra.9.2018.03.26.16.19.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 16:19:23 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 27 Mar 2018 01:18:40 +0200 Message-Id: <4ee87120d6cdc4425fec7b84b0b6b87f5fe0dea1.1522105876.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 16/20] bus/vdev: implement device iteration 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 Mar 2018 23:19:25 -0000 Signed-off-by: Gaetan Rivet --- drivers/bus/vdev/Makefile | 2 +- drivers/bus/vdev/vdev.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/bus/vdev/Makefile b/drivers/bus/vdev/Makefile index 24d424a38..52728833c 100644 --- a/drivers/bus/vdev/Makefile +++ b/drivers/bus/vdev/Makefile @@ -19,7 +19,7 @@ LIBABIVER := 1 SRCS-y += vdev.c -LDLIBS += -lrte_eal +LDLIBS += -lrte_eal -lrte_kvargs # # Export include files diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 68306f4eb..699ce01e6 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -415,6 +416,38 @@ vdev_unplug(struct rte_device *dev) return rte_vdev_uninit(dev->name); } +static int +vdev_dev_match(const struct rte_device *dev, + const void *_kvlist) +{ + const struct rte_kvargs *kvlist = _kvlist; + + (void) kvlist; + (void) dev; + return 0; +} + +static void * +vdev_dev_iterate(const void *start, + const char *str, + const struct rte_dev_iterator *it __rte_unused) +{ + struct rte_kvargs *kvargs = NULL; + struct rte_device *dev; + + if (str != NULL) { + kvargs = rte_kvargs_parse(str, NULL); + if (kvargs == NULL) { + VDEV_LOG(ERR, "cannot parse argument list\n"); + rte_errno = EINVAL; + return NULL; + } + } + dev = vdev_find_device(start, vdev_dev_match, kvargs); + rte_kvargs_free(kvargs); + return dev; +} + static struct rte_bus rte_vdev_bus = { .scan = vdev_scan, .probe = vdev_probe, @@ -422,6 +455,7 @@ static struct rte_bus rte_vdev_bus = { .plug = vdev_plug, .unplug = vdev_unplug, .parse = vdev_parse, + .dev_iterate = vdev_dev_iterate, }; RTE_REGISTER_BUS(vdev, rte_vdev_bus); -- 2.11.0