From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id A2B77728B for ; Wed, 21 Mar 2018 18:16:17 +0100 (CET) Received: by mail-wm0-f67.google.com with SMTP id a20so22896401wmd.1 for ; Wed, 21 Mar 2018 10:16:17 -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=F7CWqimizdZ7pZGVWnU2bIYmk7PwdkGZ2m1f9SeOPHAAnD9eg78WqK0ODWxnpO840Q VCyglLHmhJOr0MBP/TwJmxGjRxFZC3FRouE6ARmxT2eFdGBIRj+fLhbB+lyxfQ246s3v vTW61EwCSgvgIhS/ywJvmya1Pzu5IJdOV5XKQCGnK3bq/OjDroN+3bW252Uoaz81iG9l wfNl2ry8Kj7B00eSaXSwXHtMG0603xGhCL9FDsHIcDsPmQDBNWXcBqLTgvz/anLH0iMC 5/LknxlXl111g/iPwNeQdBgvkprd/+K4RfEdcivUk0tj7Y2m+wpuuKYaUblYDkYhsZze X95w== 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=ZN4bka6jCR98LiN/D42kG2Se4qGGORf+eaXnyBuX9ToVuffTCm/iq8RY4vQRPaPwSC LV2uw2gm88cPs2wwEiqd+9xn3AHx29bcSIk1SAR9BK7o4vsHOhl9wLP0ub218pGGPJwv O6Bv78d6sXOWYLM3rDeAOvK+el2IcDFehWhYQ/SOCcwAqeOg2iKiRsgZMy4cQ+aZkT2R gsW5oGCToEXnOopoxXgswugrnhaM1KBC3EghkYFOYiRFs+gh7jcP9wwIi1+hb3w9FaGp 0QIlYq5FNXcbDZhWprWlcEtqyZl64fns1ekkzpSCfQzFJWA85/zbPfmejDGSaCFeJCbs Ql5A== X-Gm-Message-State: AElRT7GTAIcrzrZ4WHt9cgcIhoMygrGX7Po+mnxdDgzTWgn+kINZ67gT UplMlfaZSJbsz/5YjzBUqnymw7dk X-Google-Smtp-Source: AG47ELuYjclwk+9nYi/l2aWffthVFsMsNJRaQlGab9JgG0n7rMrShpo0u6KQ7Hz7T0arkLNAPcJXTA== X-Received: by 10.28.181.16 with SMTP id e16mr3590311wmf.97.1521652576855; Wed, 21 Mar 2018 10:16:16 -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 l10sm4224101wrf.37.2018.03.21.10.16.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Mar 2018 10:16:15 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 21 Mar 2018 18:15:35 +0100 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 14/18] 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: Wed, 21 Mar 2018 17:16:17 -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