[dpdk-dev,v4,19/20] ethdev: add device matching field name

Message ID b8c0d0e8ff8271a17fa5a2f24ab9bc7968d1bbe5.1522358422.git.gaetan.rivet@6wind.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Gaëtan Rivet March 29, 2018, 9:23 p.m. UTC
  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_ether/rte_class_eth.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
  

Patch

diff --git a/lib/librte_ether/rte_class_eth.c b/lib/librte_ether/rte_class_eth.c
index 97d24781d..99aff372e 100644
--- a/lib/librte_ether/rte_class_eth.c
+++ b/lib/librte_ether/rte_class_eth.c
@@ -14,10 +14,12 @@ 
 #include "rte_ethdev_core.h"
 
 enum eth_params {
+	RTE_ETH_PARAMS_NAME,
 	RTE_ETH_PARAMS_MAX,
 };
 
 static const char *eth_params_keys[] = {
+	[RTE_ETH_PARAMS_NAME] = "name",
 	[RTE_ETH_PARAMS_MAX] = NULL,
 };
 
@@ -25,8 +27,12 @@  static int
 eth_dev_match(struct rte_eth_dev *edev,
 	      struct rte_kvargs *kvlist)
 {
-	(void) kvlist;
-	(void) edev;
+	struct rte_eth_dev_data *data;
+
+	data = edev->data;
+	if (rte_kvargs_process(kvlist, "name",
+			&rte_kvargs_strcmp, data->name))
+		return -1;
 	return 0;
 }