[v1,07/13] ethdev: add device matching field name

Message ID 96bc18c75198d6644f87f7e4e16f343fcbbc18ee.1535633784.git.gaetan.rivet@6wind.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Implement new devargs framework |

Checks

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

Commit Message

Gaëtan Rivet Aug. 30, 2018, 1:41 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_ethdev/rte_class_eth.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Andrew Rybchenko Aug. 31, 2018, 10:10 a.m. UTC | #1
On 08/30/2018 04:41 PM, Gaetan Rivet wrote:
> 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>

Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
  

Patch

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;
 }