From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 1D9611E20 for ; Mon, 8 Oct 2018 00:26:00 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 9A7C521F32; Sun, 7 Oct 2018 18:25:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 07 Oct 2018 18:25:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=JwSq4qPK1Qq4bFgvszrUT0+qda1i3gr8VRXdjIwIGQo=; b=YSNB4bx0CGto keIwJEJWaivSQzq8q5DpIdIw8g9Is5L3RJ5u1Ku5VVyMVyTrZeEG3UvBB1aVc8oF cikQFk8BYTBGZHCkR+e1yZI3dE4LEJ+1CjITbdkThDVyvcrm9Pp7E+VYn/6juFPm t+CfdwyerdfkoMJzdSnz5UkeZ7tjrQM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=JwSq4qPK1Qq4bFgvszrUT0+qda1i3gr8VRXdjIwIG Qo=; b=Ac9+btN+ZX5RT9kCwg+R++7AbwhI3Sp4RtHJgtH8dvabsFxdQfcy15E67 GCOrBscR1NWHsu1p+RZrrECww8QHS3/ztjaLgdc/g2y8LsqbAOYxY06mObYfbt9K WLzFrUKRzreAIaSD3I3supZ9vRJtdKwzvscvufi4HXbM0wUdiKe31SyLVvm+tVLF oQSDaF6VF6xaCskNJXSjdJBfE7WLEvkOOvxqMeDbCyR3C7fKVOl5kvETKS8phPCO 8T23t64nH833aQcK3g7kt5ybH23WpCxYPlCni1h2Cib7LQZeqoc3zgIXaDrv9iRz 90vkVl3Xy/r0HD3RG3Abg36p/H6nQ== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id A16AFE49C6; Sun, 7 Oct 2018 18:25:58 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, ferruh.yigit@intel.com, arybchenko@solarflare.com Date: Mon, 8 Oct 2018 00:25:50 +0200 Message-Id: <20181007222554.4886-2-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181007222554.4886-1-thomas@monjalon.net> References: <20181007222554.4886-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 1/5] bus/vdev: add iteration filter on name 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, 07 Oct 2018 22:26:00 -0000 A virtual device can be matched with following syntax: bus=vdev,name=X Signed-off-by: Thomas Monjalon --- drivers/bus/vdev/vdev_params.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c index da270f2ec..133998c3e 100644 --- a/drivers/bus/vdev/vdev_params.c +++ b/drivers/bus/vdev/vdev_params.c @@ -2,6 +2,8 @@ * Copyright 2018 Gaƫtan Rivet */ +#include + #include #include #include @@ -11,10 +13,12 @@ #include "vdev_private.h" enum vdev_params { + RTE_VDEV_PARAM_NAME, RTE_VDEV_PARAM_MAX, }; static const char * const vdev_params_keys[] = { + [RTE_VDEV_PARAM_NAME] = "name", [RTE_VDEV_PARAM_MAX] = NULL, }; @@ -22,11 +26,22 @@ static int vdev_dev_match(const struct rte_device *dev, const void *_kvlist) { + int ret; const struct rte_kvargs *kvlist = _kvlist; + char *name; + + /* cannot pass const dev->name to rte_kvargs_process() */ + name = strdup(dev->name); + if (name == NULL) + return -ENOMEM; /* interpreted as no match */ + ret = rte_kvargs_process(kvlist, + vdev_params_keys[RTE_VDEV_PARAM_NAME], + rte_kvargs_strcmp, name); + free(name); + if (ret != 0) + return -1; - (void) kvlist; - (void) dev; - return 0; + return ret; } void * -- 2.19.0