[dpdk-dev] [PATCH v3 19/20] ethdev: add device matching field name

Gaetan Rivet gaetan.rivet at 6wind.com
Tue Mar 27 01:18:43 CEST 2018


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 at 6wind.com>
---
 lib/librte_ether/rte_class_eth.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_class_eth.c b/lib/librte_ether/rte_class_eth.c
index 3f1537c2a..08f2b43cb 100644
--- a/lib/librte_ether/rte_class_eth.c
+++ b/lib/librte_ether/rte_class_eth.c
@@ -14,11 +14,25 @@
 #include "rte_ethdev_core.h"
 
 static int
+eth_dev_str_cmp(const char *key __rte_unused,
+		const char *value,
+		void *_str)
+{
+	const char *str = _str;
+
+	return strcmp(str, value);
+}
+
+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",
+			&eth_dev_str_cmp, data->name))
+		return 1;
 	return 0;
 }
 
-- 
2.11.0



More information about the dev mailing list