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 63AB21BB81 for ; Fri, 13 Apr 2018 15:23:19 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id b127so5196726wmf.5 for ; Fri, 13 Apr 2018 06:23:19 -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=M89daIjbmUAMbP4rgykbfGl8O+ehsjYc2TM3gjD/FTIuyxNODW9QjqCLI0LFqYYZd4 SeJ3yD2B44TVY3iXc4jdNxmYNwiS170qWj/Kb6PoainA+F4upF09sAuAE/EQ8/3Wxeoq h3VUCX6r8cCCZUPuB1y7Eue3ZtU13SaX14z9Jvl+M4mnGAwmPu9A23328dNX4B7yjQct FUjClDlur130I8Xs+G7RmE+jvn48CAzuMcQsxjzYeV6hqgH2fKrYF3zOc9C+Dc+O329q C68JWiRw4JSjei/0dHDZ60xKF5TMiHriw85jLfEo+JX/BpoGasdPTjsmuMiA7kDnmX8j mjUA== 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=oH2Sl8l7rAfm/qLcLHpljANNeA5qCVS7B4C0j0aIFKtcE7GpjkEUo4i1XhbXO4Cz66 lGEYLMoEFcJHlCUqod/h/PKCBTBFPrxBL79ulgZVS2J8aLV+aMpQiODc09TsVdxQXIQD H0sJIIAq4WLnxPyuhsk8Ca71G8sfOZkJSmAkZu55xjwECvTzoHhXBl8Ujq50eYyE1Nc6 AgTGbUxPOa0BXMPdFOTd2bheSNE5pjgFBYYMSrz7yHGoUOBKwdFoUrHy/m1sE6MmuuUX uWV0Qswc4voHciFNvKFKsf3cp2u0oAW19ZTgsGz8ZfNxojnIKtQIWTkxhZakY744fuN/ 00cA== X-Gm-Message-State: ALQs6tClvx3uTOT+NV9EnLwzE6DPyN31Yd3iEaDTKvEPa0+zHkLtXAWc NvHeZoFhD98nv6liX5UCWkqfQK03 X-Google-Smtp-Source: AIpwx4+yosZVWdaZebwPx5tV3Q3J0HPjVIaEJI9pe13kTkTprvu/pdx4K1jmwGWllvhBgunKyxKzmQ== X-Received: by 10.28.69.133 with SMTP id l5mr3430072wmi.152.1523625798716; Fri, 13 Apr 2018 06:23:18 -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 r200sm2377244wmb.9.2018.04.13.06.23.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Apr 2018 06:23:17 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Fri, 13 Apr 2018 15:22:32 +0200 Message-Id: <763b29861b722528e1a86a7c402009c3293b6a95.1523625525.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 v6 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: Fri, 13 Apr 2018 13:23:19 -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