From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id 14C341BAEA for ; Wed, 11 Apr 2018 02:05:01 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id d19so44640wre.1 for ; Tue, 10 Apr 2018 17:05:01 -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=z4rhRJqBnU7qja4ZTddxefJC+ZdmkrmjR/4GOGRYszI=; b=SClg2usx18zNg9uokzEhJeE7nEOivjOZJVm6XW/WKJGXQV+6TJNbXUkAlPhWDaVaef 6f5NJowTlzX0RJ1oPdbTeiV/W6jnCYJWGE/wIe1B20HAipRVhxJEbSguEvSgCY1xFmt1 fRb1mgsG39PKu3YsPif7vX1m6q1VD1E/RJCCqU5cP4/oMsUSFbVVBKekGs/aLwe7X4h0 hdJtWJ16DQw6em2FYJum2eHj6S2KcafsxUDPhe29dMGNCPA3+hwsq6yvavvR/uymuvI7 B5/IeGvQ9DLrNnXG8pzAHCEfMMciTKSGSZyRP4h1cjLZjax3lZ8EUUnplwYzGcRZfzVM xfaQ== 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=z4rhRJqBnU7qja4ZTddxefJC+ZdmkrmjR/4GOGRYszI=; b=KB95rYhB3HQTh74rPoNGV7BF8VkTPUv7ud2Jrq62+yojbgM/ljsw45xJkpdvq27e0N eZiukRxkVDDVhsFPLUJVpw6LpFaxFKwsFgDeBTd+8T4dtLyAbd2EjXgUEuXt4Kf2VfT1 JjfFpcEcmGEloDCKSZ/Mv3H9cIOa6t/A2Nf5Ybs3MvMux5NuXoXU55eRnPby/1vdbRhU vEmoaB7gXslg6htVtClr+MQ1+L5iEXIxt8maNoBVpwanWDFkkbcEBOtPjpwQhNySIpxy olQtVtonJG9/PwZnwBgqZp5nQMXTDsL7e8w8amHfjQ6XBfCGtHeuyFCxJPkXVlHXZG4i 5drQ== X-Gm-Message-State: ALQs6tAGO+2K0+D3aEEwCRG7g+Uxg2cePELBZDdOdYo3KXm7q2uKW6ss sEvTUFrUTd5l98M2idGpcrvYfcpC X-Google-Smtp-Source: AIpwx49oMpxl3MgaTmA4g1BjgyWYLxsbf5UWow8IaalzJRX8wdE9lXPh9EEzS/J2yPUS3VgMgXdgcg== X-Received: by 10.223.182.13 with SMTP id f13mr1650470wre.262.1523405100485; Tue, 10 Apr 2018 17:05:00 -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 39sm7626563wry.89.2018.04.10.17.04.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 17:04:59 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 11 Apr 2018 02:04:17 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 16/21] 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, 11 Apr 2018 00:05:01 -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 66fe63e85..1cc469da0 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,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, @@ -422,6 +463,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