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 80F771B64C for ; Sun, 15 Apr 2018 17:08:32 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id l49so19296400wrl.4 for ; Sun, 15 Apr 2018 08:08:32 -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=Q19d/NN59dgWucw1vHRHUpwrUsoBhii9sTq9UKiyyjc=; b=XJjFGS4FgpYcVZhseVk3P7fvCwk2cvC3dZVYLinVsPAI5I+ED0y8/Yk2rY/kI153Hw 7ypA26NjlXZu1ZtT+cUYZO34TGdusZcgouQXir0EfzDwX50ziYYLqVscU3MUo0YN0CsR dH05ZyEtsJVy96w2YgyODJrjdi47xrNs95lFu/VG16vNzB2KPcX8zRL2wiEkSYpdGKHb mVm3q5lHr1HwTPO75QpzWrHiBIkuo07p+0A2S2Fhdqz42CZtkVxEbtwi7/Ht6FhG/kIE K72MQcOdprC9ZowkQ3TM4A7uI9/T692VSJtp15v5osxy2GgrNpfQ5k0hWhmzKSa3k9Vz JroA== 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=Q19d/NN59dgWucw1vHRHUpwrUsoBhii9sTq9UKiyyjc=; b=XRkEOWtfphLVrw0nQqv/3RFDaE2amIYa6gBOfW2C/3FL3jQEp3ND4pNZi1c5ORRwUm tQPWkaIBRjceQdJnItD9/CEg8aMAMWCgk/aS7u3C6jdN2Wt6VD8ck72w0HOijkadv4Pc YQ0GSGA8TZ9tfzDMkcDKZIBX77cIi8+UetuFr8C9NmQ4X6WY7+5mEcCsYJn8G6cNuUzc oMkCq4zS1G5DqsbaPK99WcceCU+aU0gaFWqVtCYWN4RDV0cCjf9D0F+O+h6c5C8+3BSO 08eosDYXVhZjVkBzXG8HvoGnfau4aLVTFAhjYy8nu6Xw8EJYqgefj0bMTpiQsGfFnaVr zJdA== X-Gm-Message-State: ALQs6tDR5SnBGNGXro8noStjIBmjy5IBOY3e8+2aMRJR0geqOY0HxQgD vV5IPpDUTFHq0E9WFA1gUeE5xlxJ X-Google-Smtp-Source: AIpwx4/MmsB2li7oMbRLEDZ2yrhmpX2UB+gzu14iSc5+DQjLzLE6W4wrvP98ThtU/My0u2uS6PMuuQ== X-Received: by 10.28.197.205 with SMTP id v196mr8647614wmf.39.1523804911869; Sun, 15 Apr 2018 08:08:31 -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 r200sm13673438wmb.39.2018.04.15.08.08.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Apr 2018 08:08:30 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Sun, 15 Apr 2018 17:07:46 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v7 17/22] 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: Sun, 15 Apr 2018 15:08:32 -0000 Signed-off-by: Gaetan Rivet --- drivers/bus/vdev/Makefile | 2 +- drivers/bus/vdev/vdev.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 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 c135554c0..5bb87af28 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -387,6 +388,46 @@ vdev_unplug(struct rte_device *dev) return rte_vdev_uninit(dev->name); } +enum vdev_params { + RTE_VDEV_PARAMS_MAX, +}; + +static const char * const vdev_params_keys[] = { + [RTE_VDEV_PARAMS_MAX] = NULL, +}; + +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, vdev_params_keys); + 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, @@ -394,6 +435,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