[v2,07/13] ethdev: add device matching field name
diff mbox series

Message ID f92677bd76573f543b6486c6b1e8d5c4a6c3fa45.1537372746.git.gaetan.rivet@6wind.com
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • Implement new devargs framework
Related show

Checks

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

Commit Message

Gaëtan Rivet Sept. 19, 2018, 4:03 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>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 lib/librte_ethdev/rte_class_eth.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Thomas Monjalon Sept. 20, 2018, 4:17 p.m. UTC | #1
19/09/2018 18:03, Gaetan Rivet:
> The eth device class can now parse a field name,
> matching the eth_dev name with one passed as
> 
>    "class=eth,name=xxxxxx"

I am not sure what is the purpose of the "name" property.
I think we should not need it to choose a port by its ethdev name.
If you are thinking about a vdev, we can use the rte_device name (at bus level).
Gaëtan Rivet Sept. 21, 2018, 12:16 p.m. UTC | #2
On Thu, Sep 20, 2018 at 06:17:13PM +0200, Thomas Monjalon wrote:
> 19/09/2018 18:03, Gaetan Rivet:
> > The eth device class can now parse a field name,
> > matching the eth_dev name with one passed as
> > 
> >    "class=eth,name=xxxxxx"
> 
> I am not sure what is the purpose of the "name" property.
> I think we should not need it to choose a port by its ethdev name.

rte_eth_dev_get_port_by_name seems pretty close.
Which fields do you think should be proposed first as a getter on the eth class?
Or do you have a list of fields the eth class should be restricted to?

> If you are thinking about a vdev, we can use the rte_device name (at bus level).

This patch is only about eth class, it has no impact on buses.
Thomas Monjalon Sept. 21, 2018, 1:06 p.m. UTC | #3
21/09/2018 14:16, Gaëtan Rivet:
> On Thu, Sep 20, 2018 at 06:17:13PM +0200, Thomas Monjalon wrote:
> > 19/09/2018 18:03, Gaetan Rivet:
> > > The eth device class can now parse a field name,
> > > matching the eth_dev name with one passed as
> > > 
> > >    "class=eth,name=xxxxxx"
> > 
> > I am not sure what is the purpose of the "name" property.
> > I think we should not need it to choose a port by its ethdev name.
> 
> rte_eth_dev_get_port_by_name seems pretty close.

Exact, this function already exists to get a port id by name.
I think we should discourage the use of ethdev "internal" name.
The point of the devargs is to match device with explicit known properties.

> Which fields do you think should be proposed first as a getter on the eth class?
> Or do you have a list of fields the eth class should be restricted to?

In other words, which ethdev properties can help to match a port?
I think about "mac=" (which is already implemented in OVS devargs),
and "representor=" (which requires a new field in ethdev).
About representors, we could also match all representor ports of a switch
(see rte_eth_switch_info).
We could also have a property for the kernel netdev we are (or were) bound.

Does it make sense?

> > If you are thinking about a vdev, we can use the rte_device name (at bus level).
> 
> This patch is only about eth class, it has no impact on buses.

So we agree :)

Patch
diff mbox series

diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c
index b6557db97..66fd48dc2 100644
--- a/lib/librte_ethdev/rte_class_eth.c
+++ b/lib/librte_ethdev/rte_class_eth.c
@@ -15,10 +15,12 @@ 
 #include "ethdev_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;
 }