From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id AAD79A488 for ; Thu, 29 Mar 2018 23:24:33 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id v21so13025718wmc.1 for ; Thu, 29 Mar 2018 14:24:33 -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=4wtXIRBDlX0Xz+wfZddjoQZvq9OBa0EatRhV9K/lAt0=; b=WoCbz70Xl8/A52wCoq68Irw+xkVpZR1vzbBYVUfM5Pdb01AkuTw5fY+MS+RGZLsVEy jRtZUhRN7s7uavHZ9GgewFRyWBWMyUrpg4rWsTjCu4HNJ53MlAeMrBv85/RNEkqivAg1 VA4ZfqFlPDZWqr0BiAgJuZdxd90yeBhBhdxFb5Z+DUuiI670kddAQKjTLA6CKs6XXjHJ 9vvjWb1wLBQTbux7SpL4A3jqkMSxaddrWQ1p3tljMuZ9rA970mkVByjqanLmHrYgjFzT dqy2XowioWP/zVjpD5X8u+ZLQG78qrytfIk+PQlm6+lsHCDvNW8ezmIWo51v6K2K6Rp6 TN/w== 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=4wtXIRBDlX0Xz+wfZddjoQZvq9OBa0EatRhV9K/lAt0=; b=RwKyQdWXoHIchnuuwvPpswT78lw6HKznMH0dWJGYERmdGx27sYNwt/j6vP7PfzhJFL p41DkI/yfi23VcdrzywNnXPScVh2sGera06KfHa7RwHINOtqhG02z449RBAIpP31zqPI c9clX+J30XdNg936C7MRUWdMVPMPPsg+GSRO1uA24JKObBWDlXrVXLL/v9rNq1akjs0A X4gOL5LEtdEKWuEt3O/Cxfy10W27us+tMyNV+RxBTgsLK7gbTDD4LS3kAdOTTR45Kac/ jfVR+dAchXtwZ7RkC/kk1Xwvxguj6S2TTAVpnJT5Qik1GsCZwZp6eKujJt4AdJxYBel7 NjBw== X-Gm-Message-State: ALQs6tB3u7M7twtDHNbRNp08hpvTYSpQDNUXhLVpuFUqDyKdrzvAnrDj e+pAKrFA/mDKOsxoAZkeJP1DM9YM X-Google-Smtp-Source: AIpwx48DO9rHqEE+iEJAviOk9+wXF2u5ALaitp8EN5sxSVYPXd9sZ/1at8fk8HvhaZtn/QsjwKmwIA== X-Received: by 10.28.129.86 with SMTP id c83mr393514wmd.37.1522358672012; Thu, 29 Mar 2018 14:24:32 -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 m35sm11907457wrm.59.2018.03.29.14.24.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 14:24:31 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Thu, 29 Mar 2018 23:23:40 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 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: Thu, 29 Mar 2018 21:24:37 -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..5d77cc369 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 *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