From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gaetan.rivet@6wind.com>
Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com
 [209.85.221.51]) by dpdk.org (Postfix) with ESMTP id 92D681BF0D
 for <dev@dpdk.org>; Thu,  5 Jul 2018 13:49:24 +0200 (CEST)
Received: by mail-wr1-f51.google.com with SMTP id t6-v6so1015792wrn.7
 for <dev@dpdk.org>; Thu, 05 Jul 2018 04:49:24 -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;
 bh=IHVbPwTSTQaAHXkciYMdEqxygXilHaYNt1PzQ3kYkLo=;
 b=kCO9liRYv9Fzv2wW+0eTgWfE6uqmT86CbxZI1Xz7P5m7V14wdzHfk5T0DIRtud8apO
 wvfQbRnp31JPUpmAPWJ+4neFWa1uTPhrqRk2A1Jltdj5Dk3X5ogK4c3At3AZpFE42XNC
 TIil1360d9o2MPGlJXx7bFB9mYwrWllJWvEfAikvfhj2esNE2FohFpGCOM6HvinIcWxS
 LMKDaZhunSidHewgldMjHKxe1MEC9jWwqK+jirEGGdw7DfuhvtvnaqQGe8ZQxpvOTwLf
 xAeJVAR9SlSpiR7RPulLyaEMteiHGp8YFF9Wsf1WSM3IHmpWIKcxEkwdBP+Si5/YrPXL
 b76A==
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;
 bh=IHVbPwTSTQaAHXkciYMdEqxygXilHaYNt1PzQ3kYkLo=;
 b=XwzlUFXZ67ZyReBpCNE8Y3qt/f3iKqpAvl58i1TI3j/PjpY3WhU1TpJ8pOvI/+sf8I
 TWHB7stHfvHUo/OfyQokZwY94b79sfIugSjnTle1WD4bYAQ5OJAVU+RfWBPt+h0RwF66
 gXyP3+cDCT2lR8Kyzh7scdKGicEx3F553U2+Ia7pRTLME506YBvTQFPczmx43u0+6qQZ
 xSpJOv5R38KRHxuj4EIe/hsLSWxeeIhodCSYLCipfjZPY0sNRR2xroKLwlnFM3z0Sf83
 aw574zjZrUwA0sXxtLvAjnfpTiGSOq/TI2fXan2SoQqFUvz/9mY1xYogrMQOn5qrwW40
 AP8A==
X-Gm-Message-State: APt69E1sC+kes/YJzZ99zbEQZFBxVsqgvuXsnpznKaM+gYn5GndmJ/br
 SuqOuDo6o1BejupyuYapPPoJTEL0
X-Google-Smtp-Source: AAOMgpfdlam/2Yna2RlHvMhN0YV4u6ZcapB2d8fnZ0cUfLAtJ9PCid4FNahmegJBdpRYNb+WyRKyKg==
X-Received: by 2002:adf:ec02:: with SMTP id
 x2-v6mr4046381wrn.245.1530791363974; 
 Thu, 05 Jul 2018 04:49:23 -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 o42-v6sm15809183wrc.50.2018.07.05.04.49.22
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 05 Jul 2018 04:49:23 -0700 (PDT)
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Date: Thu,  5 Jul 2018 13:48:28 +0200
Message-Id: <2922fb25b3aadf0d0427b5529a4a29b1a4ee8c56.1530791217.git.gaetan.rivet@6wind.com>
X-Mailer: git-send-email 2.18.0
In-Reply-To: <cover.1530791217.git.gaetan.rivet@6wind.com>
References: <cover.1530791217.git.gaetan.rivet@6wind.com>
Subject: [dpdk-dev] [PATCH v10 21/27] ethdev: add device matching field name
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 05 Jul 2018 11:49:24 -0000

The eth device class can now parse a field name,
matching the eth_dev name with one passed as

   "class=eth,name=xxxxxx"

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_ethdev/rte_class_eth.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c
index 32c736d32..d8d8e8845 100644
--- a/lib/librte_ethdev/rte_class_eth.c
+++ b/lib/librte_ethdev/rte_class_eth.c
@@ -15,10 +15,12 @@
 #include "eth_private.h"
 
 enum eth_params {
+	RTE_ETH_PARAMS_NAME,
 	RTE_ETH_PARAMS_MAX,
 };
 
 static const char * const eth_params_keys[] = {
+	[RTE_ETH_PARAMS_NAME] = "name",
 	[RTE_ETH_PARAMS_MAX] = NULL,
 };
 
@@ -39,6 +41,7 @@ eth_dev_match(const struct rte_eth_dev *edev,
 {
 	const struct eth_dev_match_arg *arg = _arg;
 	const struct rte_kvargs *kvlist = arg->kvlist;
+	struct rte_eth_dev_data *data;
 
 	if (edev->state == RTE_ETH_DEV_UNUSED)
 		return -1;
@@ -47,6 +50,10 @@ eth_dev_match(const struct rte_eth_dev *edev,
 	if (kvlist == NULL)
 		/* Empty string matches everything. */
 		return 0;
+	data = edev->data;
+	if (rte_kvargs_process(kvlist, "name",
+			rte_kvargs_strcmp, data->name))
+		return -1;
 	return 0;
 }
 
-- 
2.18.0