support more ethdev iterator filters
Subsystems (3)
cover support more ethdev iterator filters
The new ethdev iterator lacks the support of filtering by representor port id or by MAC address.
This series is not fully tested yet.
Thomas Monjalon (4):
kvargs: support list value
mk: remove broken check
ethdev: move representor parsing functions
ethdev: support representor id for iterating ports
drivers/net/i40e/i40e_vf_representor.c | 1 + drivers/net/ixgbe/ixgbe_vf_representor.c | 1 + drivers/net/mlx5/mlx5.c | 4 +- lib/librte_ethdev/ethdev_private.c | 82 +++++++++++++++++++++++ lib/librte_ethdev/ethdev_private.h | 6 ++ lib/librte_ethdev/rte_class_eth.c | 44 ++++++++++++ lib/librte_ethdev/rte_ethdev.c | 85 ------------------------ lib/librte_ethdev/rte_ethdev_core.h | 2 + lib/librte_kvargs/rte_kvargs.c | 10 +++ mk/internal/rte.compile-pre.mk | 1 - test/test/test_kvargs.c | 17 +++++ 11 files changed, 166 insertions(+), 87 deletions(-)
Signature · 1 line
2.19.0
PATCH 1/4 kvargs: support list value
If a value contains a comma, rte_kvargs_tokenize() will split here. In order to support list syntax [a,b] as value, an extra parsing of the square brackets is added.
--- lib/librte_kvargs/rte_kvargs.c | 10 ++++++++++ test/test/test_kvargs.c | 17 +++++++++++++++++ 2 files changed, 27 insertions(+)
lib/librte_kvargs/rte_kvargs.c +10 -0
@@ -44,6 +44,16 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params) kvlist->pairs[i].value == NULL)return -1 ; +/* Detect list [a,b] to skip comma delimiter in list. */ +if (kvlist->pairs[i].value[0 ] =='[' ) { +/* Parse the end of the list. */ + str =strtok_r (NULL ,"]" , &ctx1); +if (str ==NULL ) +return -1 ;/* no closing bracket */ +/* Add back the bracket erased by strtok_t(). */ + *(str -1 ) =']' ; + } + kvlist->count++; str =NULL ; }
test/test/test_kvargs.c +17 -0
@@ -137,6 +137,22 @@ static int test_valid_kvargs(void) }rte_kvargs_free (kvlist); +/* third test using list as value */ + args ="foo=[0,1],check=value2" ; + valid_keys = valid_keys_list; + kvlist =rte_kvargs_parse (args, valid_keys); +if (kvlist ==NULL ) { +printf ("rte_kvargs_parse() error" ); + goto fail; + } + count = kvlist->count; +if (count !=2 ) { +printf ("invalid count value %d\n" , count); +rte_kvargs_free (kvlist); + goto fail; + } +rte_kvargs_free (kvlist); +return 0 ; fail:
@@ -162,6 +178,7 @@ static int test_invalid_kvargs(void)"foo=1,,foo=2" ,/* empty key/value */ "foo=1,foo" ,/* no value */ "foo=1,=2" ,/* no key */ +"foo=[1,2" ,/* no closing bracket in value */ ",=" ,/* also test with a smiley */ NULL };const char **args;
Signature · 1 line
2.19.0
PATCH 2/4 mk: remove broken check
In reply to Thomas MonjalonNext patch does not pass the experimental check
because it has an (unrelated) experimental function in his context.
--- mk/internal/rte.compile-pre.mk | 1 - 1 file changed, 1 deletion(-)
mk/internal/rte.compile-pre.mk +0 -1
@@ -75,7 +75,6 @@ C_TO_O_DO = @set -e; \ echo $(C_TO_O_DISP); \ $(C_TO_O) && \ $(PMDINFO_TO_O) && \ - $(CHECK_EXPERIMENTAL) && \ echo $(C_TO_O_CMD) > $(call obj2cmd,$(@)) && \ sed 's,'$@':,dep_'$@' =,' $(call obj2dep,$(@)).tmp > $(call obj2dep,$(@)) && \ rm -f $(call obj2dep,$(@)).tmp
Signature · 1 line
2.19.0
PATCH 3/4 ethdev: move representor parsing functions
In reply to Thomas MonjalonThe functions for representor devargs parsing were static in the file rte_ethdev.c.
In order to reuse them in the file rte_class_eth.c, they are moved to the files ethdev_private.c/.h.
--- lib/librte_ethdev/ethdev_private.c | 82 ++++++++++++++++++++++++++++ lib/librte_ethdev/ethdev_private.h | 6 +++ lib/librte_ethdev/rte_ethdev.c | 85 ------------------------------ 3 files changed, 88 insertions(+), 85 deletions(-)
lib/librte_ethdev/ethdev_private.c +82 -0
@@ -3,6 +3,7 @@*/ #include "rte_ethdev.h" +#include "rte_ethdev_driver.h" #include "ethdev_private.h" uint16_t
@@ -37,3 +38,84 @@ eth_find_device(const struct rte_eth_dev *start, rte_eth_cmp_t cmp,return NULL ; } +int +rte_eth_devargs_parse_list (char *str,rte_eth_devargs_callback_t callback, +void *data) +{ +char *str_start; +int state; +int result; + +if (*str !='[' ) +/* Single element, not a list */ +return callback (str, data); + +/* Sanity check, then strip the brackets */ + str_start = &str[strlen (str) -1 ]; +if (*str_start !=']' ) { +RTE_LOG (ERR ,EAL ,"(%s): List does not end with ']'" , str); +return -EINVAL ; + } + str++; + *str_start ='\0' ; + +/* Process list elements */ + state =0 ; +while (1 ) { +if (state ==0 ) { +if (*str =='\0' ) +break ; +if (*str !=',' ) { + str_start = str; + state =1 ; + } + }else if (state ==1 ) { +if (*str ==',' || *str =='\0' ) { +if (str > str_start) { +/* Non-empty string fragment */ + *str ='\0' ; + result =callback (str_start, data); +if (result <0 ) +return result; + } + state =0 ; + } + } + str++; + } +return 0 ; +} + +static int +rte_eth_devargs_process_range (char *str,uint16_t *list,uint16_t *len_list, +const uint16_t max_list) +{ +uint16_t lo, hi, val; +int result; + + result =sscanf (str,"%hu-%hu" , &lo, &hi); +if (result ==1 ) { +if (*len_list >= max_list) +return -ENOMEM ; + list[(*len_list)++] = lo; + }else if (result ==2 ) { +if (lo >= hi || lo >RTE_MAX_ETHPORTS || hi >RTE_MAX_ETHPORTS ) +return -EINVAL ; +for (val = lo; val <= hi; val++) { +if (*len_list >= max_list) +return -ENOMEM ; + list[(*len_list)++] = val; + } + }else +return -EINVAL ; +return 0 ; +} + +int +rte_eth_devargs_parse_representor_ports (char *str,void *data) +{ +struct rte_eth_devargs *eth_da = data; + +return rte_eth_devargs_process_range (str, eth_da->representor_ports, + ð_da->nb_representor_ports,RTE_MAX_ETHPORTS ); +}
lib/librte_ethdev/ethdev_private.h +6 -0
@@ -25,6 +25,12 @@ struct rte_eth_dev * eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp, const void *data); +/* Parse devargs value for representor parameter. */ +typedef int (*rte_eth_devargs_callback_t )(char *str,void *data); +int rte_eth_devargs_parse_list (char *str,rte_eth_devargs_callback_t callback, +void *data); +int rte_eth_devargs_parse_representor_ports (char *str,void *data); + #ifdef __cplusplus }#endif
lib/librte_ethdev/rte_ethdev.c +0 -85
97 lines not on this page · raw message
Signature · 1 line
2.19.0
PATCH 4/4 ethdev: support representor id for iterating ports
In reply to Thomas MonjalonThe representor id is added in rte_eth_dev_data in order to be able to match a port with its representor id in devargs.
--- drivers/net/i40e/i40e_vf_representor.c | 1 + drivers/net/ixgbe/ixgbe_vf_representor.c | 1 + drivers/net/mlx5/mlx5.c | 4 ++- lib/librte_ethdev/rte_class_eth.c | 44 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 2 ++ 5 files changed, 51 insertions(+), 1 deletion(-)
drivers/net/i40e/i40e_vf_representor.c +1 -0
@@ -504,6 +504,7 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) } ethdev->data->dev_flags |=RTE_ETH_DEV_REPRESENTOR ; + ethdev->data->representor_id = representor->vf_id;/* Setting the number queues allocated to the VF */ ethdev->data->nb_rx_queues = vf->vsi->nb_qps;
drivers/net/ixgbe/ixgbe_vf_representor.c +1 -0
@@ -192,6 +192,7 @@ ixgbe_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)return -ENODEV ; ethdev->data->dev_flags |=RTE_ETH_DEV_REPRESENTOR ; + ethdev->data->representor_id = representor->vf_id;/* Set representor device ops */ ethdev->dev_ops = &ixgbe_vf_representor_dev_ops;
drivers/net/mlx5/mlx5.c +3 -1
@@ -1075,8 +1075,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err =ENOMEM ; goto error; } -if (priv->representor) +if (priv->representor) { eth_dev->data->dev_flags |=RTE_ETH_DEV_REPRESENTOR ; + eth_dev->data->representor_id = priv->representor_id; + } eth_dev->data->dev_private = priv; priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac;
lib/librte_ethdev/rte_class_eth.c +44 -0
73 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_core.h +2 -0
@@ -613,6 +613,8 @@ struct rte_eth_dev_data {struct rte_vlan_filter_conf vlan_filter_conf;/**< VLAN filter configuration. */ struct rte_eth_dev_owner owner;/**< The port owner. */ +uint16_t representor_id; +/**< switch specific identifier - valid if RTE_ETH_DEV_REPRESENTOR */ } __rte_cache_aligned;/**
Signature · 1 line
2.19.0
Re: [PATCH 3/4] ethdev: move representor parsing functions
In reply to Thomas MonjalonQuoted 6 lines · Thomas Monjalon
The functions for representor devargs parsing were static in the file
rte_ethdev.c.
In order to reuse them in the filerte_class_eth.c, they are moved to the files ethdev_private.c/.h.Signed-off-by Thomas Monjalon <[email protected]>
Re: [PATCH 4/4] ethdev: support representor id for iterating ports
In reply to Thomas MonjalonQuoted 4 lines · Thomas Monjalon
The representor id is added in
rte_eth_dev_datain order to be able to match a port with its representor id in devargs.Signed-off-by Thomas Monjalon <[email protected]>
Neil Horman
NAKRe: [PATCH 2/4] mk: remove broken check
In reply to Thomas MonjalonQuoted 26 lines · Thomas Monjalon
Next patch does not pass the experimental check
because it has an (unrelated) experimental function in his context.Cc Neil Horman <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>--- mk/internal/rte.compile-pre.mk | 1 - 1 file changed, 1 deletion(-)mk/internal/rte.compile-pre.mk +0
-1@@ -75,7 +75,6 @@ C_TO_O_DO = @set -e; \ echo $(C_TO_O_DISP); \ $(C_TO_O) && \ $(PMDINFO_TO_O) && \ - $(CHECK_EXPERIMENTAL) && \ echo $(C_TO_O_CMD) > $(call obj2cmd,$(@)) && \ sed 's,'$@':,dep_'$@' =,' $(call obj2dep,$(@)).tmp > $(call obj2dep,$(@)) && \ rm -f $(call obj2dep,$(@)).tmpSignature · 1 line
2.19.0
NACK.
Its a bit vague to get the meaning of your changelog, but based on the context of the actual other patch I think what you're saying is that patch 3/4 in this series has the __rte_experimental token in it as part of the context of a diff, rather than as a change itself, and the check-experimental-syms script is matching on that when it shouldn't. The correct fix is to teach the difference between changes and context to the check-experimental-syms.sh script, not to break the whole thing by just removing the call to the script.
Neil
Re: [PATCH 2/4] mk: remove broken check
09/10/2018 13:43, Neil Horman:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
Next patch does not pass the experimental check
because it has an (unrelated) experimental function in his context.Cc Neil Horman <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>--- mk/internal/rte.compile-pre.mk | 1 - 1 file changed, 1 deletion(-)
Quoted 14 lines
mk/internal/rte.compile-pre.mk C_TO_O_DO = @set -e; \ · line 80
Quoted 12 lines
mk/internal/rte.compile-pre.mk +0
-1@@ -75,7 +75,6 @@ C_TO_O_DO = @set -e; \ echo $(C_TO_O_DISP); \ $(C_TO_O) && \ $(PMDINFO_TO_O) && \ - $(CHECK_EXPERIMENTAL) && \ echo $(C_TO_O_CMD) > $(call obj2cmd,$(@)) && \ sed 's,'$@':,dep_'$@' =,' $(call obj2dep,$(@)).tmp > $(call obj2dep,$(@)) && \ rm -f $(call obj2dep,$(@)).tmpNACK.
Yes, of course.
I have added this patch in the series in order to allow building the patches.
Quoted 7 lines
Its a bit vague to get the meaning of your changelog, but based on the context of the actual other patch I think what you're saying is that patch 3/4 in this series has the
__rte_experimentaltoken in it as part of the context of a diff, rather than as a change itself, and the check-experimental-syms script is matching on that when it shouldn't. The correct fix is to teach the difference between changes and context to thecheck-experimental-syms.shscript, not to break the whole thing by just removing the call to the script.
I agree, but I don't understand how the patch context is related to the checks done in buildtools.
Please could you fix it? It is blocking the integration of this series.
Thanks
Re: [PATCH 3/4] ethdev: move representor parsing functions
In reply to Thomas MonjalonQuoted 6 lines · Thomas Monjalon
The functions for representor devargs parsing were static in the file
rte_ethdev.c.
In order to reuse them in the filerte_class_eth.c, they are moved to the files ethdev_private.c/.h.Signed-off-by Thomas Monjalon <[email protected]>
There is overlap between these functions and some of the rte_kvargs_*() functions. Is it feasible/desirable to combine them?
..Remy
Re: [PATCH 3/4] ethdev: move representor parsing functions
09/10/2018 14:38, Remy Horton:
Quoted 11 lines · Thomas Monjalon
Quoted 6 lines
The functions for representor devargs parsing were static in the file
rte_ethdev.c.
In order to reuse them in the filerte_class_eth.c, they are moved to the files ethdev_private.c/.h.Signed-off-by Thomas Monjalon <[email protected]>There is overlap between these functions and some of the rte_kvargs_*() functions. Is it feasible/desirable to combine them?
Yes!
This is what I wanted to suggest.
I think we should parse list and range as part of the kvargs library. Would you be interested to rework those functions in a next release?
Re: [PATCH 1/4] kvargs: support list value
In reply to Thomas MonjalonHi Thomas,
Quoted 4 lines · Thomas Monjalon
If a value contains a comma,
rte_kvargs_tokenize()will split here. In order to support list syntax [a,b] as value, an extra parsing of the square brackets is added.
Nice, I was actually planning to do this.
I think it could be useful to also support () and {}, as well as recursive lists, but it is best to have a first version to support representor and go from this.
Quoted 6 lines
Signed-off-by Thomas Monjalon <[email protected]>--- lib/librte_kvargs/rte_kvargs.c | 10 ++++++++++ test/test/test_kvargs.c | 17 +++++++++++++++++ 2 files changed, 27 insertions(+)
Signature · 2 lines
Gaëtan Rivet 6WIND
Re: [PATCH 1/4] kvargs: support list value
09/10/2018 16:14, Gaëtan Rivet:
Quoted 8 lines
Hi Thomas,
Quoted 4 lines · Thomas Monjalon
If a value contains a comma,
rte_kvargs_tokenize()will split here. In order to support list syntax [a,b] as value, an extra parsing of the square brackets is added.
Quoted 5 lines
Nice, I was actually planning to do this.
I think it could be useful to also support () and {}, as well as recursive lists, but it is best to have a first version to support representor and go from this.
Yes, we have no usage of () and {} so far.
Re: [PATCH 1/4] kvargs: support list value
Quoted 9 lines · On Tue, 09 Oct 2018 16:31:24 +0200 Thomas Monjalon <[email protected]> wrote:
09/10/2018 16:14, Gaëtan Rivet:
Quoted 8 lines
Hi Thomas,
Quoted 4 lines · Thomas Monjalon
If a value contains a comma,
rte_kvargs_tokenize()will split here. In order to support list syntax [a,b] as value, an extra parsing of the square brackets is added.
Quoted 7 lines
Quoted 5 lines
Nice, I was actually planning to do this.
I think it could be useful to also support () and {}, as well as recursive lists, but it is best to have a first version to support representor and go from this.
Yes, we have no usage of () and {} so far.
This is getting complex enough that doing a real parser maybe necessary. Why not lex/yacc?
Or better yet go to real syntax like JSON.
Re: [PATCH 1/4] kvargs: support list value
09/10/2018 17:11, Stephen Hemminger:
Quoted 14 lines
Quoted 11 lines · On Tue, 09 Oct 2018 16:31:24 +0200 Thomas Monjalon <[email protected]> wrote:
09/10/2018 16:14, Gaëtan Rivet:
Quoted 10 lines
Hi Thomas,
Quoted 4 lines · Thomas Monjalon
If a value contains a comma,
rte_kvargs_tokenize()will split here. In order to support list syntax [a,b] as value, an extra parsing of the square brackets is added.Nice, I was actually planning to do this.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I think it could be useful to also support () and {}, as well as recursive lists, but it is best to have a first version to support representor and go from this.
Yes, we have no usage of () and {} so far.
This is getting complex enough that doing a real parser maybe necessary. Why not lex/yacc?
I don't know how much it fits with our needs for devargs.
Quoted 1 line
Or better yet go to real syntax like JSON.
JSON is not suitable for one-line string as devargs.
Re: [PATCH 2/4] mk: remove broken check
In reply to Thomas MonjalonQuoted 38 lines · Thomas Monjalon
09/10/2018 13:43, Neil Horman:
Quoted 11 lines · Thomas Monjalon
Quoted 10 lines
Next patch does not pass the experimental check
because it has an (unrelated) experimental function in his context.Cc Neil Horman <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>--- mk/internal/rte.compile-pre.mk | 1 - 1 file changed, 1 deletion(-)Quoted 14 lines
mk/internal/rte.compile-pre.mk C_TO_O_DO = @set -e; \ · line 80
Quoted 12 lines
mk/internal/rte.compile-pre.mk +0
-1@@ -75,7 +75,6 @@ C_TO_O_DO = @set -e; \ echo $(C_TO_O_DISP); \ $(C_TO_O) && \ $(PMDINFO_TO_O) && \ - $(CHECK_EXPERIMENTAL) && \ echo $(C_TO_O_CMD) > $(call obj2cmd,$(@)) && \ sed 's,'$@':,dep_'$@' =,' $(call obj2dep,$(@)).tmp > $(call obj2dep,$(@)) && \ rm -f $(call obj2dep,$(@)).tmpNACK.
Yes, of course.
I have added this patch in the series in order to allow building the patches.Quoted 7 lines
Its a bit vague to get the meaning of your changelog, but based on the context of the actual other patch I think what you're saying is that patch 3/4 in this series has the
__rte_experimentaltoken in it as part of the context of a diff, rather than as a change itself, and the check-experimental-syms script is matching on that when it shouldn't. The correct fix is to teach the difference between changes and context to thecheck-experimental-syms.shscript, not to break the whole thing by just removing the call to the script.
Quoted 4 lines
I agree, but I don't understand how the patch context is related to the checks done in buildtools.
Please could you fix it? It is blocking the integration of this series.
Yeah, I'll get to it as soon as possible, but please lead with this rather than just dismantling the feature :)
Neil
Quoted 4 lines
Thanks
Re: [PATCH 1/4] kvargs: support list value
In reply to Stephen HemmingerQuoted 1 line · Stephen Hemminger
On Tue, 09 Oct 2018 16:31:24 +0200
[..]
Quoted 1 line
This is getting complex enough that doing a real parser maybe necessary.
I thought the same thing back in April with the port representor patchsets. Quickly run out of things to use as delimiters otherwise.
Quoted 1 line
Why not lex/yacc?
Think Yacc/Bison are vastly overcomplex and a bit of a pain to integrate. The sort of config grammar needed here will most likely be LL(1), so fairly easy to do by hand anyway.
Quoted 2 lines
Or better yet go to real syntax like JSON.
v2 cover support more ethdev iterator filters
In reply to Thomas MonjalonThe new ethdev iterator lacks the support of filtering by representor port id or by MAC address.
Changes in v2:
- fix list parsing in kvargs
- support mac= parameter
Thomas Monjalon (4):
kvargs: support list value
ethdev: move representor parsing functions
ethdev: support representor id as iterator filter
ethdev: support MAC address as iterator filter
drivers/net/i40e/i40e_vf_representor.c | 1 + drivers/net/ixgbe/ixgbe_vf_representor.c | 1 + drivers/net/mlx5/mlx5.c | 4 +- lib/Makefile | 1 + lib/librte_cmdline/meson.build | 4 ++ lib/librte_ethdev/Makefile | 2 +- lib/librte_ethdev/ethdev_private.c | 82 +++++++++++++++++++++++ lib/librte_ethdev/ethdev_private.h | 6 ++ lib/librte_ethdev/meson.build | 2 +- lib/librte_ethdev/rte_class_eth.c | 80 ++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 85 ------------------------ lib/librte_ethdev/rte_ethdev_core.h | 2 + lib/librte_kvargs/rte_kvargs.c | 14 ++++ lib/meson.build | 5 +- test/test/test_kvargs.c | 21 ++++++ 15 files changed, 220 insertions(+), 90 deletions(-)
Signature · 1 line
2.19.0
PATCH v2 1/4 kvargs: support list value
If a value contains a comma, rte_kvargs_tokenize() will split here. In order to support list syntax [a,b] as value, an extra parsing of the square brackets is added.
--- lib/librte_kvargs/rte_kvargs.c | 14 ++++++++++++++ test/test/test_kvargs.c | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+)
lib/librte_kvargs/rte_kvargs.c +14 -0
@@ -44,6 +44,20 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params) kvlist->pairs[i].value == NULL)return -1 ; +/* Detect list [a,b] to skip comma delimiter in list. */ + str = kvlist->pairs[i].value; +if (str[0 ] =='[' ) { +/* Find the end of the list. */ +while (str[strlen (str) -1 ] !=']' ) { +/* Restore the comma erased by strtok_r(). */ + str[strlen (str)] =',' ; +/* Parse until next comma. */ + str =strtok_r (NULL ,RTE_KVARGS_PAIRS_DELIM , &ctx1); +if (str ==NULL ) +return -1 ;/* no closing bracket */ + } + } + kvlist->count++; str =NULL ; }
test/test/test_kvargs.c +21 -0
@@ -137,6 +137,26 @@ static int test_valid_kvargs(void) }rte_kvargs_free (kvlist); +/* third test using list as value */ + args ="foo=[0,1],check=value2" ; + valid_keys = valid_keys_list; + kvlist =rte_kvargs_parse (args, valid_keys); +if (kvlist ==NULL ) { +printf ("rte_kvargs_parse() error" ); + goto fail; + } +if (strcmp (kvlist->pairs[0 ].value,"[0,1]" ) !=0 ) { +printf ("wrong value %s" , kvlist->pairs[0 ].value); + goto fail; + } + count = kvlist->count; +if (count !=2 ) { +printf ("invalid count value %d\n" , count); +rte_kvargs_free (kvlist); + goto fail; + } +rte_kvargs_free (kvlist); +return 0 ; fail:
@@ -162,6 +182,7 @@ static int test_invalid_kvargs(void)"foo=1,,foo=2" ,/* empty key/value */ "foo=1,foo" ,/* no value */ "foo=1,=2" ,/* no key */ +"foo=[1,2" ,/* no closing bracket in value */ ",=" ,/* also test with a smiley */ NULL };const char **args;
Signature · 1 line
2.19.0
PATCH v2 2/4 ethdev: move representor parsing functions
In reply to Thomas MonjalonThe functions for representor devargs parsing were static in the file rte_ethdev.c.
In order to reuse them in the file rte_class_eth.c, they are moved to the files ethdev_private.c/.h.
A log is fixed by adding a missing line feed.
--- lib/librte_ethdev/ethdev_private.c | 82 ++++++++++++++++++++++++++++ lib/librte_ethdev/ethdev_private.h | 6 +++ lib/librte_ethdev/rte_ethdev.c | 85 ------------------------------ 3 files changed, 88 insertions(+), 85 deletions(-)
lib/librte_ethdev/ethdev_private.c +82 -0
@@ -3,6 +3,7 @@*/ #include "rte_ethdev.h" +#include "rte_ethdev_driver.h" #include "ethdev_private.h" uint16_t
@@ -37,3 +38,84 @@ eth_find_device(const struct rte_eth_dev *start, rte_eth_cmp_t cmp,return NULL ; } +int +rte_eth_devargs_parse_list (char *str,rte_eth_devargs_callback_t callback, +void *data) +{ +char *str_start; +int state; +int result; + +if (*str !='[' ) +/* Single element, not a list */ +return callback (str, data); + +/* Sanity check, then strip the brackets */ + str_start = &str[strlen (str) -1 ]; +if (*str_start !=']' ) { +RTE_LOG (ERR ,EAL ,"(%s): List does not end with ']'\n" , str); +return -EINVAL ; + } + str++; + *str_start ='\0' ; + +/* Process list elements */ + state =0 ; +while (1 ) { +if (state ==0 ) { +if (*str =='\0' ) +break ; +if (*str !=',' ) { + str_start = str; + state =1 ; + } + }else if (state ==1 ) { +if (*str ==',' || *str =='\0' ) { +if (str > str_start) { +/* Non-empty string fragment */ + *str ='\0' ; + result =callback (str_start, data); +if (result <0 ) +return result; + } + state =0 ; + } + } + str++; + } +return 0 ; +} + +static int +rte_eth_devargs_process_range (char *str,uint16_t *list,uint16_t *len_list, +const uint16_t max_list) +{ +uint16_t lo, hi, val; +int result; + + result =sscanf (str,"%hu-%hu" , &lo, &hi); +if (result ==1 ) { +if (*len_list >= max_list) +return -ENOMEM ; + list[(*len_list)++] = lo; + }else if (result ==2 ) { +if (lo >= hi || lo >RTE_MAX_ETHPORTS || hi >RTE_MAX_ETHPORTS ) +return -EINVAL ; +for (val = lo; val <= hi; val++) { +if (*len_list >= max_list) +return -ENOMEM ; + list[(*len_list)++] = val; + } + }else +return -EINVAL ; +return 0 ; +} + +int +rte_eth_devargs_parse_representor_ports (char *str,void *data) +{ +struct rte_eth_devargs *eth_da = data; + +return rte_eth_devargs_process_range (str, eth_da->representor_ports, + ð_da->nb_representor_ports,RTE_MAX_ETHPORTS ); +}
lib/librte_ethdev/ethdev_private.h +6 -0
@@ -25,6 +25,12 @@ struct rte_eth_dev * eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp, const void *data); +/* Parse devargs value for representor parameter. */ +typedef int (*rte_eth_devargs_callback_t )(char *str,void *data); +int rte_eth_devargs_parse_list (char *str,rte_eth_devargs_callback_t callback, +void *data); +int rte_eth_devargs_parse_representor_ports (char *str,void *data); + #ifdef __cplusplus }#endif
lib/librte_ethdev/rte_ethdev.c +0 -85
97 lines not on this page · raw message
Signature · 1 line
2.19.0
PATCH v2 3/4 ethdev: support representor id as iterator filter
In reply to Thomas MonjalonThe representor id is added in rte_eth_dev_data in order to be able to match a port with its representor id in devargs.
--- drivers/net/i40e/i40e_vf_representor.c | 1 + drivers/net/ixgbe/ixgbe_vf_representor.c | 1 + drivers/net/mlx5/mlx5.c | 4 ++- lib/librte_ethdev/rte_class_eth.c | 44 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 2 ++ 5 files changed, 51 insertions(+), 1 deletion(-)
drivers/net/i40e/i40e_vf_representor.c +1 -0
@@ -504,6 +504,7 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) } ethdev->data->dev_flags |=RTE_ETH_DEV_REPRESENTOR ; + ethdev->data->representor_id = representor->vf_id;/* Setting the number queues allocated to the VF */ ethdev->data->nb_rx_queues = vf->vsi->nb_qps;
drivers/net/ixgbe/ixgbe_vf_representor.c +1 -0
@@ -192,6 +192,7 @@ ixgbe_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)return -ENODEV ; ethdev->data->dev_flags |=RTE_ETH_DEV_REPRESENTOR ; + ethdev->data->representor_id = representor->vf_id;/* Set representor device ops */ ethdev->dev_ops = &ixgbe_vf_representor_dev_ops;
drivers/net/mlx5/mlx5.c +3 -1
@@ -1075,8 +1075,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err =ENOMEM ; goto error; } -if (priv->representor) +if (priv->representor) { eth_dev->data->dev_flags |=RTE_ETH_DEV_REPRESENTOR ; + eth_dev->data->representor_id = priv->representor_id; + } eth_dev->data->dev_private = priv; priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac;
lib/librte_ethdev/rte_class_eth.c +44 -0
73 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_core.h +2 -0
@@ -613,6 +613,8 @@ struct rte_eth_dev_data {struct rte_vlan_filter_conf vlan_filter_conf;/**< VLAN filter configuration. */ struct rte_eth_dev_owner owner;/**< The port owner. */ +uint16_t representor_id; +/**< switch specific identifier - valid if RTE_ETH_DEV_REPRESENTOR */ } __rte_cache_aligned;/**
Signature · 1 line
2.19.0
PATCH v2 4/4 ethdev: support MAC address as iterator filter
In reply to Thomas MonjalonThe MAC addresses of a port can be matched with devargs.
As the conflict between rte_ether.h and netinet/ether.h is not resolved, the MAC parsing is done with a rte_cmdline function.
As a result, cmdline library becomes a dependency of ethdev.
--- lib/Makefile | 1 + lib/librte_cmdline/meson.build | 4 ++++ lib/librte_ethdev/Makefile | 2 +- lib/librte_ethdev/meson.build | 2 +- lib/librte_ethdev/rte_class_eth.c | 36 +++++++++++++++++++++++++++++++ lib/meson.build | 5 +++-- 6 files changed, 46 insertions(+), 4 deletions(-)
lib/Makefile +1 -0
@@ -25,6 +25,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ethdev DEPDIRS-librte_ethdev := librte_net librte_eal librte_mempool librte_ring DEPDIRS-librte_ethdev += librte_mbuf DEPDIRS-librte_ethdev += librte_kvargs +DEPDIRS-librte_ethdev += librte_cmdline DIRS-$(CONFIG_RTE_LIBRTE_BBDEV) += librte_bbdev DEPDIRS-librte_bbdev := librte_eal librte_mempool librte_mbuf DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += librte_cryptodev
lib/librte_cmdline/meson.build +4 -0
@@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +# This library is processed before EAL +includes = [global_inc] +includes += include_directories('../librte_eal/common/include') + version = 2 sources = files('cmdline.c', 'cmdline_cirbuf.c',
lib/librte_ethdev/Makefile +1 -1
@@ -12,7 +12,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_net -lrte_eal -lrte_mempool -lrte_ring -LDLIBS += -lrte_mbuf -lrte_kvargs +LDLIBS += -lrte_mbuf -lrte_kvargs -lrte_cmdline EXPORT_MAP := rte_ethdev_version.map
lib/librte_ethdev/meson.build +1 -1
@@ -26,4 +26,4 @@ headers = files('rte_ethdev.h', 'rte_tm.h', 'rte_tm_driver.h') -deps += ['net', 'kvargs'] +deps += ['net', 'kvargs', 'cmdline']
lib/librte_ethdev/rte_class_eth.c +36 -0
@@ -4,6 +4,7 @@#include <string.h> +#include <cmdline_parse_etheraddr.h> #include <rte_class.h> #include <rte_compat.h> #include <rte_errno.h>
@@ -16,11 +17,13 @@#include "ethdev_private.h" enum eth_params { +RTE_ETH_PARAM_MAC ,RTE_ETH_PARAM_REPRESENTOR ,RTE_ETH_PARAM_MAX , };static const char *const eth_params_keys[] = { + [RTE_ETH_PARAM_MAC ] ="mac" , [RTE_ETH_PARAM_REPRESENTOR ] ="representor" , [RTE_ETH_PARAM_MAX ] =NULL , };
@@ -36,6 +39,33 @@ struct eth_dev_match_arg { .kvlist = (k), \ }) +static int +eth_mac_cmp(const char *key __rte_unused, +const char *value,void *opaque) +{ +int ret; +struct ether_addr mac; +const struct rte_eth_dev_data *data = opaque; +struct rte_eth_dev_info dev_info; +uint32_t index; + +/* Parse devargs MAC address. */ +/* +* cannot use ether_aton_r(value, &mac) +* because of include conflict with rte_ether.h +*/ + ret =cmdline_parse_etheraddr (NULL , value, &mac,sizeof (mac)); +if (ret <0 ) +return -1 ;/* invalid devargs value */ + +/* Return 0 if devargs MAC is matching one of the device MACs. */ +rte_eth_dev_info_get (data->port_id, &dev_info); +for (index =0 ; index < dev_info.max_mac_addrs; index++) +if (is_same_ether_addr (&mac, &data->mac_addrs[index])) +return 0 ; +return -1 ;/* no match */ +} +static int eth_representor_cmp(const char *key __rte_unused,const char *value,void *opaque)
@@ -85,6 +115,12 @@ eth_dev_match(const struct rte_eth_dev *edev,/* Empty string matches everything. */ return 0 ; + ret =rte_kvargs_process (kvlist, + eth_params_keys[RTE_ETH_PARAM_MAC ], + eth_mac_cmp, edev->data); +if (ret !=0 ) +return -1 ; + ret =rte_kvargs_process (kvlist, eth_params_keys[RTE_ETH_PARAM_REPRESENTOR ], eth_representor_cmp, edev->data);
lib/meson.build +3 -2
@@ -9,13 +9,14 @@ # given as a dep, no need to mention ring. This is especially true for the # core libs which are widely reused, so their deps are kept to a minimum. libraries = [ 'compat', # just a header, used for versioning - 'kvargs', + 'cmdline', # ethdev depends on cmdline for parsing functions + 'kvargs', # eal depends on kvargs 'eal', 'ring', 'mempool', 'mbuf', 'net', 'ethdev', 'pci', # core 'metrics', # bitrate/latency stats depends on this 'hash', # efd depends on this 'timer', # eventdev depends on this 'acl', 'bbdev', 'bitratestats', 'cfgfile', - 'cmdline', 'compressdev', 'cryptodev', + 'compressdev', 'cryptodev', 'distributor', 'efd', 'eventdev', 'gro', 'gso', 'ip_frag', 'jobstats', 'kni', 'latencystats', 'lpm', 'member',
Signature · 1 line
2.19.0
v3 cover support more ethdev iterator filters
In reply to Thomas MonjalonThe new ethdev iterator lacks the support of filtering by representor port id or by MAC address.
Changes in v3:
- improve comment for representor_id
Changes in v2:
- fix list parsing in kvargs
- support mac= parameter
Thomas Monjalon (4):
kvargs: support list value
ethdev: move representor parsing functions
ethdev: support representor id as iterator filter
ethdev: support MAC address as iterator filter
drivers/net/i40e/i40e_vf_representor.c | 1 + drivers/net/ixgbe/ixgbe_vf_representor.c | 1 + drivers/net/mlx5/mlx5.c | 4 +- lib/Makefile | 1 + lib/librte_cmdline/meson.build | 4 ++ lib/librte_ethdev/Makefile | 2 +- lib/librte_ethdev/ethdev_private.c | 82 +++++++++++++++++++++++ lib/librte_ethdev/ethdev_private.h | 6 ++ lib/librte_ethdev/meson.build | 2 +- lib/librte_ethdev/rte_class_eth.c | 80 ++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 85 ------------------------ lib/librte_ethdev/rte_ethdev_core.h | 4 ++ lib/librte_kvargs/rte_kvargs.c | 14 ++++ lib/meson.build | 5 +- test/test/test_kvargs.c | 21 ++++++ 15 files changed, 222 insertions(+), 90 deletions(-)
Signature · 1 line
2.19.0
PATCH v3 1/4 kvargs: support list value
If a value contains a comma, rte_kvargs_tokenize() will split here. In order to support list syntax [a,b] as value, an extra parsing of the square brackets is added.
--- lib/librte_kvargs/rte_kvargs.c | 14 ++++++++++++++ test/test/test_kvargs.c | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+)
lib/librte_kvargs/rte_kvargs.c +14 -0
@@ -44,6 +44,20 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params) kvlist->pairs[i].value == NULL)return -1 ; +/* Detect list [a,b] to skip comma delimiter in list. */ + str = kvlist->pairs[i].value; +if (str[0 ] =='[' ) { +/* Find the end of the list. */ +while (str[strlen (str) -1 ] !=']' ) { +/* Restore the comma erased by strtok_r(). */ + str[strlen (str)] =',' ; +/* Parse until next comma. */ + str =strtok_r (NULL ,RTE_KVARGS_PAIRS_DELIM , &ctx1); +if (str ==NULL ) +return -1 ;/* no closing bracket */ + } + } + kvlist->count++; str =NULL ; }
test/test/test_kvargs.c +21 -0
@@ -137,6 +137,26 @@ static int test_valid_kvargs(void) }rte_kvargs_free (kvlist); +/* third test using list as value */ + args ="foo=[0,1],check=value2" ; + valid_keys = valid_keys_list; + kvlist =rte_kvargs_parse (args, valid_keys); +if (kvlist ==NULL ) { +printf ("rte_kvargs_parse() error" ); + goto fail; + } +if (strcmp (kvlist->pairs[0 ].value,"[0,1]" ) !=0 ) { +printf ("wrong value %s" , kvlist->pairs[0 ].value); + goto fail; + } + count = kvlist->count; +if (count !=2 ) { +printf ("invalid count value %d\n" , count); +rte_kvargs_free (kvlist); + goto fail; + } +rte_kvargs_free (kvlist); +return 0 ; fail:
@@ -162,6 +182,7 @@ static int test_invalid_kvargs(void)"foo=1,,foo=2" ,/* empty key/value */ "foo=1,foo" ,/* no value */ "foo=1,=2" ,/* no key */ +"foo=[1,2" ,/* no closing bracket in value */ ",=" ,/* also test with a smiley */ NULL };const char **args;
Signature · 1 line
2.19.0
PATCH v3 2/4 ethdev: move representor parsing functions
In reply to Thomas MonjalonThe functions for representor devargs parsing were static in the file rte_ethdev.c.
In order to reuse them in the file rte_class_eth.c, they are moved to the files ethdev_private.c/.h.
A log is fixed by adding a missing line feed.
--- lib/librte_ethdev/ethdev_private.c | 82 ++++++++++++++++++++++++++++ lib/librte_ethdev/ethdev_private.h | 6 +++ lib/librte_ethdev/rte_ethdev.c | 85 ------------------------------ 3 files changed, 88 insertions(+), 85 deletions(-)
lib/librte_ethdev/ethdev_private.c +82 -0
@@ -3,6 +3,7 @@*/ #include "rte_ethdev.h" +#include "rte_ethdev_driver.h" #include "ethdev_private.h" uint16_t
@@ -37,3 +38,84 @@ eth_find_device(const struct rte_eth_dev *start, rte_eth_cmp_t cmp,return NULL ; } +int +rte_eth_devargs_parse_list (char *str,rte_eth_devargs_callback_t callback, +void *data) +{ +char *str_start; +int state; +int result; + +if (*str !='[' ) +/* Single element, not a list */ +return callback (str, data); + +/* Sanity check, then strip the brackets */ + str_start = &str[strlen (str) -1 ]; +if (*str_start !=']' ) { +RTE_LOG (ERR ,EAL ,"(%s): List does not end with ']'\n" , str); +return -EINVAL ; + } + str++; + *str_start ='\0' ; + +/* Process list elements */ + state =0 ; +while (1 ) { +if (state ==0 ) { +if (*str =='\0' ) +break ; +if (*str !=',' ) { + str_start = str; + state =1 ; + } + }else if (state ==1 ) { +if (*str ==',' || *str =='\0' ) { +if (str > str_start) { +/* Non-empty string fragment */ + *str ='\0' ; + result =callback (str_start, data); +if (result <0 ) +return result; + } + state =0 ; + } + } + str++; + } +return 0 ; +} + +static int +rte_eth_devargs_process_range (char *str,uint16_t *list,uint16_t *len_list, +const uint16_t max_list) +{ +uint16_t lo, hi, val; +int result; + + result =sscanf (str,"%hu-%hu" , &lo, &hi); +if (result ==1 ) { +if (*len_list >= max_list) +return -ENOMEM ; + list[(*len_list)++] = lo; + }else if (result ==2 ) { +if (lo >= hi || lo >RTE_MAX_ETHPORTS || hi >RTE_MAX_ETHPORTS ) +return -EINVAL ; +for (val = lo; val <= hi; val++) { +if (*len_list >= max_list) +return -ENOMEM ; + list[(*len_list)++] = val; + } + }else +return -EINVAL ; +return 0 ; +} + +int +rte_eth_devargs_parse_representor_ports (char *str,void *data) +{ +struct rte_eth_devargs *eth_da = data; + +return rte_eth_devargs_process_range (str, eth_da->representor_ports, + ð_da->nb_representor_ports,RTE_MAX_ETHPORTS ); +}
lib/librte_ethdev/ethdev_private.h +6 -0
@@ -25,6 +25,12 @@ struct rte_eth_dev * eth_find_device(const struct rte_eth_dev *_start, rte_eth_cmp_t cmp, const void *data); +/* Parse devargs value for representor parameter. */ +typedef int (*rte_eth_devargs_callback_t )(char *str,void *data); +int rte_eth_devargs_parse_list (char *str,rte_eth_devargs_callback_t callback, +void *data); +int rte_eth_devargs_parse_representor_ports (char *str,void *data); + #ifdef __cplusplus }#endif
lib/librte_ethdev/rte_ethdev.c +0 -85
97 lines not on this page · raw message
Signature · 1 line
2.19.0
PATCH v3 3/4 ethdev: support representor id as iterator filter
In reply to Thomas MonjalonThe representor id is added in rte_eth_dev_data in order to be able to match a port with its representor id in devargs.
--- drivers/net/i40e/i40e_vf_representor.c | 1 + drivers/net/ixgbe/ixgbe_vf_representor.c | 1 + drivers/net/mlx5/mlx5.c | 4 ++- lib/librte_ethdev/rte_class_eth.c | 44 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 4 +++ 5 files changed, 53 insertions(+), 1 deletion(-)
drivers/net/i40e/i40e_vf_representor.c +1 -0
@@ -504,6 +504,7 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) } ethdev->data->dev_flags |=RTE_ETH_DEV_REPRESENTOR ; + ethdev->data->representor_id = representor->vf_id;/* Setting the number queues allocated to the VF */ ethdev->data->nb_rx_queues = vf->vsi->nb_qps;
drivers/net/ixgbe/ixgbe_vf_representor.c +1 -0
@@ -192,6 +192,7 @@ ixgbe_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)return -ENODEV ; ethdev->data->dev_flags |=RTE_ETH_DEV_REPRESENTOR ; + ethdev->data->representor_id = representor->vf_id;/* Set representor device ops */ ethdev->dev_ops = &ixgbe_vf_representor_dev_ops;
drivers/net/mlx5/mlx5.c +3 -1
@@ -1084,8 +1084,10 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, err =ENOMEM ; goto error; } -if (priv->representor) +if (priv->representor) { eth_dev->data->dev_flags |=RTE_ETH_DEV_REPRESENTOR ; + eth_dev->data->representor_id = priv->representor_id; + } eth_dev->data->dev_private = priv; priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac;
lib/librte_ethdev/rte_class_eth.c +44 -0
73 lines not on this page · raw message
lib/librte_ethdev/rte_ethdev_core.h +4 -0
@@ -625,6 +625,10 @@ struct rte_eth_dev_data {struct rte_vlan_filter_conf vlan_filter_conf;/**< VLAN filter configuration. */ struct rte_eth_dev_owner owner;/**< The port owner. */ +uint16_t representor_id; +/**< Switch-specific identifier. +* Valid if RTE_ETH_DEV_REPRESENTOR in dev_flags. +*/ } __rte_cache_aligned;/**
Signature · 1 line
2.19.0
PATCH v3 4/4 ethdev: support MAC address as iterator filter
In reply to Thomas MonjalonThe MAC addresses of a port can be matched with devargs.
As the conflict between rte_ether.h and netinet/ether.h is not resolved, the MAC parsing is done with a rte_cmdline function.
As a result, cmdline library becomes a dependency of ethdev.
--- lib/Makefile | 1 + lib/librte_cmdline/meson.build | 4 ++++ lib/librte_ethdev/Makefile | 2 +- lib/librte_ethdev/meson.build | 2 +- lib/librte_ethdev/rte_class_eth.c | 36 +++++++++++++++++++++++++++++++ lib/meson.build | 5 +++-- 6 files changed, 46 insertions(+), 4 deletions(-)
lib/Makefile +1 -0
@@ -25,6 +25,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ethdev DEPDIRS-librte_ethdev := librte_net librte_eal librte_mempool librte_ring DEPDIRS-librte_ethdev += librte_mbuf DEPDIRS-librte_ethdev += librte_kvargs +DEPDIRS-librte_ethdev += librte_cmdline DIRS-$(CONFIG_RTE_LIBRTE_BBDEV) += librte_bbdev DEPDIRS-librte_bbdev := librte_eal librte_mempool librte_mbuf DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += librte_cryptodev
lib/librte_cmdline/meson.build +4 -0
@@ -1,6 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation +# This library is processed before EAL +includes = [global_inc] +includes += include_directories('../librte_eal/common/include') + version = 2 sources = files('cmdline.c', 'cmdline_cirbuf.c',
lib/librte_ethdev/Makefile +1 -1
@@ -12,7 +12,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_net -lrte_eal -lrte_mempool -lrte_ring -LDLIBS += -lrte_mbuf -lrte_kvargs +LDLIBS += -lrte_mbuf -lrte_kvargs -lrte_cmdline EXPORT_MAP := rte_ethdev_version.map
lib/librte_ethdev/meson.build +1 -1
@@ -26,4 +26,4 @@ headers = files('rte_ethdev.h', 'rte_tm.h', 'rte_tm_driver.h') -deps += ['net', 'kvargs'] +deps += ['net', 'kvargs', 'cmdline']
lib/librte_ethdev/rte_class_eth.c +36 -0
@@ -4,6 +4,7 @@#include <string.h> +#include <cmdline_parse_etheraddr.h> #include <rte_class.h> #include <rte_compat.h> #include <rte_errno.h>
@@ -16,11 +17,13 @@#include "ethdev_private.h" enum eth_params { +RTE_ETH_PARAM_MAC ,RTE_ETH_PARAM_REPRESENTOR ,RTE_ETH_PARAM_MAX , };static const char *const eth_params_keys[] = { + [RTE_ETH_PARAM_MAC ] ="mac" , [RTE_ETH_PARAM_REPRESENTOR ] ="representor" , [RTE_ETH_PARAM_MAX ] =NULL , };
@@ -36,6 +39,33 @@ struct eth_dev_match_arg { .kvlist = (k), \ }) +static int +eth_mac_cmp(const char *key __rte_unused, +const char *value,void *opaque) +{ +int ret; +struct ether_addr mac; +const struct rte_eth_dev_data *data = opaque; +struct rte_eth_dev_info dev_info; +uint32_t index; + +/* Parse devargs MAC address. */ +/* +* cannot use ether_aton_r(value, &mac) +* because of include conflict with rte_ether.h +*/ + ret =cmdline_parse_etheraddr (NULL , value, &mac,sizeof (mac)); +if (ret <0 ) +return -1 ;/* invalid devargs value */ + +/* Return 0 if devargs MAC is matching one of the device MACs. */ +rte_eth_dev_info_get (data->port_id, &dev_info); +for (index =0 ; index < dev_info.max_mac_addrs; index++) +if (is_same_ether_addr (&mac, &data->mac_addrs[index])) +return 0 ; +return -1 ;/* no match */ +} +static int eth_representor_cmp(const char *key __rte_unused,const char *value,void *opaque)
@@ -85,6 +115,12 @@ eth_dev_match(const struct rte_eth_dev *edev,/* Empty string matches everything. */ return 0 ; + ret =rte_kvargs_process (kvlist, + eth_params_keys[RTE_ETH_PARAM_MAC ], + eth_mac_cmp, edev->data); +if (ret !=0 ) +return -1 ; + ret =rte_kvargs_process (kvlist, eth_params_keys[RTE_ETH_PARAM_REPRESENTOR ], eth_representor_cmp, edev->data);
lib/meson.build +3 -2
@@ -9,13 +9,14 @@ # given as a dep, no need to mention ring. This is especially true for the # core libs which are widely reused, so their deps are kept to a minimum. libraries = [ 'compat', # just a header, used for versioning - 'kvargs', + 'cmdline', # ethdev depends on cmdline for parsing functions + 'kvargs', # eal depends on kvargs 'eal', 'ring', 'mempool', 'mbuf', 'net', 'ethdev', 'pci', # core 'metrics', # bitrate/latency stats depends on this 'hash', # efd depends on this 'timer', # eventdev depends on this 'acl', 'bbdev', 'bitratestats', 'cfgfile', - 'cmdline', 'compressdev', 'cryptodev', + 'compressdev', 'cryptodev', 'distributor', 'efd', 'eventdev', 'gro', 'gso', 'ip_frag', 'jobstats', 'kni', 'latencystats', 'lpm', 'member',
Signature · 1 line
2.19.0
Re: [PATCH v3 4/4] ethdev: support MAC address as iterator filter
Quoted 7 lines · Thomas Monjalon
The MAC addresses of a port can be matched with devargs.
As the conflict between
rte_ether.handnetinet/ether.his not resolved, the MAC parsing is done with arte_cmdlinefunction.
As a result, cmdline library becomes a dependency of ethdev.Signed-off-by Thomas Monjalon <[email protected]>
I'd like to share my thought about a new dependency. Looking at cmdline I think that it is a bad and strange dependency for kvargs. IMHO, even duplication of the code to parse MAC address it less evil in this case.
May be it is possible to provide internal wrapper which is implemented using ether_aton_r() and located in a separate C file which does not include rte_ether.h etc?
Andrew.
Re: [PATCH v3 4/4] ethdev: support MAC address as iterator filter
22/10/2018 15:37, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
The MAC addresses of a port can be matched with devargs.
As the conflict between
rte_ether.handnetinet/ether.his not resolved, the MAC parsing is done with arte_cmdlinefunction.
As a result, cmdline library becomes a dependency of ethdev.
Quoted 6 lines
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'd like to share my thought about a new dependency. Looking at cmdline I think that it is a bad and strange dependency for kvargs. IMHO, even duplication of the code to parse MAC address it less evil in this case.
cmdline is not a dependency for kvargs.
I have added it as a dependency for ethdev.
Quoted 3 lines
May be it is possible to provide internal wrapper which is implemented using
ether_aton_r()and located in a separate C file which does not includerte_ether.hetc?
I raised the issue in technical board and it has been decided to fix the conflict with libc in the next release (with Olivier's help). So Bruce and me decided to use cmdline function in the meantime.
Re: [PATCH v3 4/4] ethdev: support MAC address as iterator filter
Quoted 16 lines · Thomas Monjalon
22/10/2018 15:37, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
The MAC addresses of a port can be matched with devargs.
As the conflict between
rte_ether.handnetinet/ether.his not resolved, the MAC parsing is done with arte_cmdlinefunction.
As a result, cmdline library becomes a dependency of ethdev.Quoted 5 lines
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'd like to share my thought about a new dependency. Looking at cmdline I think that it is a bad and strange dependency for kvargs. IMHO, even duplication of the code to parse MAC address it less evil in this case.
cmdline is not a dependency for kvargs.
I have added it as a dependency for ethdev.
Quoted 6 lines
Quoted 3 lines
May be it is possible to provide internal wrapper which is implemented using
ether_aton_r()and located in a separate C file which does not includerte_ether.hetc?I raised the issue in technical board and it has been decided to fix the conflict with libc in the next release (with Olivier's help). So Bruce and me decided to use cmdline function in the meantime.
OK, I see. Thanks for explanations.
Re: [PATCH v3 4/4] ethdev: support MAC address as iterator filter
In reply to Thomas MonjalonQuoted 7 lines · Thomas Monjalon
The MAC addresses of a port can be matched with devargs.
As the conflict between
rte_ether.handnetinet/ether.his not resolved, the MAC parsing is done with arte_cmdlinefunction.
As a result, cmdline library becomes a dependency of ethdev.Signed-off-by Thomas Monjalon <[email protected]>
Re: [PATCH v3 4/4] ethdev: support MAC address as iterator filter
In reply to Thomas MonjalonQuoted 28 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, October 22, 2018 3:02 PM
To: Andrew Rybchenko <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Horton, Remy <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 4/4] ethdev: support MAC address as iterator filter22/10/2018 15:37, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
The MAC addresses of a port can be matched with devargs.
As the conflict between
rte_ether.handnetinet/ether.his not resolved, the MAC parsing is done with arte_cmdlinefunction.
As a result, cmdline library becomes a dependency of ethdev.Quoted 6 lines
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'd like to share my thought about a new dependency. Looking at cmdline I think that it is a bad and strange dependency for kvargs. IMHO, even duplication of the code to parse MAC address it less evil in this case.
cmdline is not a dependency for kvargs.
I have added it as a dependency for ethdev.
Quoted 7 lines
Quoted 3 lines
May be it is possible to provide internal wrapper which is implemented using
ether_aton_r()and located in a separate C file which does not includerte_ether.hetc?I raised the issue in technical board and it has been decided to fix the conflict with libc in the next release (with Olivier's help). So Bruce and me decided to use cmdline function in the meantime.
As I can see, cmdline_parse_etheraddr() uses
static struct ether_addr *my_ether_aton(const char *a)
internally.
Why not to make it public, rename to rte_ethet_aton(), and move into rte_net?
And use that one instead?
Later if/when we'll have name conflict with libc resolved, It can become just a wrapper around ether_aton_r(). Konstantin
Re: [PATCH v3 4/4] ethdev: support MAC address as iterator filter
22/10/2018 23:24, Ananyev, Konstantin:
Quoted 27 lines
From: Thomas Monjalon
Quoted 18 lines
22/10/2018 15:37, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
The MAC addresses of a port can be matched with devargs.
As the conflict between
rte_ether.handnetinet/ether.his not resolved, the MAC parsing is done with arte_cmdlinefunction.
As a result, cmdline library becomes a dependency of ethdev.Quoted 6 lines
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'd like to share my thought about a new dependency. Looking at cmdline I think that it is a bad and strange dependency for kvargs. IMHO, even duplication of the code to parse MAC address it less evil in this case.
cmdline is not a dependency for kvargs.
I have added it as a dependency for ethdev.Quoted 7 lines
Quoted 3 lines
May be it is possible to provide internal wrapper which is implemented using
ether_aton_r()and located in a separate C file which does not includerte_ether.hetc?I raised the issue in technical board and it has been decided to fix the conflict with libc in the next release (with Olivier's help). So Bruce and me decided to use cmdline function in the meantime.
Quoted 10 lines
As I can see,
cmdline_parse_etheraddr()uses
static structether_addr*my_ether_aton(const char *a)
internally.
Why not to make it public, rename torte_ethet_aton(), and move intorte_net?
And use that one instead?
Later if/when we'll have name conflict with libc resolved, It can become just a wrapper aroundether_aton_r(). Konstantin
Several reasons:
- It would be one more (useless) wrapper
- cmdline_parse_etheraddr is already used in several places
- ether_aton_r and my_ether_aton may have a different behaviour
When the libc conflict will be solved, I prefer replacing uses of cmdline_parse_etheraddr one by one.
Re: [PATCH v3 4/4] ethdev: support MAC address as iterator filter
Quoted 50 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Tuesday, October 23, 2018 8:21 AM
To: Ananyev, Konstantin <[email protected]>
Cc: Andrew Rybchenko <[email protected]>; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; Horton, Remy <[email protected]>; Richardson, Bruce <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 4/4] ethdev: support MAC address as iterator filter22/10/2018 23:24, Ananyev, Konstantin:
Quoted 27 lines
From: Thomas Monjalon
Quoted 18 lines
22/10/2018 15:37, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
The MAC addresses of a port can be matched with devargs.
As the conflict between
rte_ether.handnetinet/ether.his not resolved, the MAC parsing is done with arte_cmdlinefunction.
As a result, cmdline library becomes a dependency of ethdev.Quoted 6 lines
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'd like to share my thought about a new dependency. Looking at cmdline I think that it is a bad and strange dependency for kvargs. IMHO, even duplication of the code to parse MAC address it less evil in this case.
cmdline is not a dependency for kvargs.
I have added it as a dependency for ethdev.Quoted 7 lines
Quoted 3 lines
May be it is possible to provide internal wrapper which is implemented using
ether_aton_r()and located in a separate C file which does not includerte_ether.hetc?I raised the issue in technical board and it has been decided to fix the conflict with libc in the next release (with Olivier's help). So Bruce and me decided to use cmdline function in the meantime.
Quoted 10 lines
As I can see,
cmdline_parse_etheraddr()uses
static structether_addr*my_ether_aton(const char *a)
internally.
Why not to make it public, rename torte_ethet_aton(), and move intorte_net?
And use that one instead?
Later if/when we'll have name conflict with libc resolved, It can become just a wrapper aroundether_aton_r(). Konstantin
Quoted 2 lines
Several reasons:
- It would be one more (useless) wrapper
Well, it would be *when* will have libc naming conflict resolved. Till that it would be pretty useful I think.
Quoted 1 line
-
cmdline_parse_etheraddris already used in several places
As I can see right now it is used just by bond PMD:
$ find lib drivers -type f | xargs grep -l cmdline_parse_etheraddr | grep -v librte_cmdline drivers/net/bonding/rte_eth_bond_args.c
Again if that function is *really* used in several places to convert string to mac, then I suppose it is an indication that rte_ether_aton() would be useful. Without forcing cmdline dependency.
Quoted 1 line
-
ether_aton_randmy_ether_atonmay have a different behavior
Could you elaborate here?
What exactly would be different?
Both supposed to convert string to ether addr.
If our function can't do that properly, then I think it is a bug in our side. If ether_aton_r() just supports extra formats(XXXX:XXXX:XXXX), then it would be extension to current behavior.
Quoted 3 lines
When the libc conflict will be solved, I prefer replacing uses of
cmdline_parse_etheraddrone by one.
We can do the same with rte_ether_aton() too, if we really want to.
Re: [PATCH v3 4/4] ethdev: support MAC address as iterator filter
23/10/2018 10:33, Ananyev, Konstantin:
Quoted 40 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 39 lines
22/10/2018 23:24, Ananyev, Konstantin:
Quoted 37 lines
From: Thomas Monjalon
Quoted 18 lines
22/10/2018 15:37, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
The MAC addresses of a port can be matched with devargs.
As the conflict between
rte_ether.handnetinet/ether.his not resolved, the MAC parsing is done with arte_cmdlinefunction.
As a result, cmdline library becomes a dependency of ethdev.Quoted 6 lines
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'd like to share my thought about a new dependency. Looking at cmdline I think that it is a bad and strange dependency for kvargs. IMHO, even duplication of the code to parse MAC address it less evil in this case.
cmdline is not a dependency for kvargs.
I have added it as a dependency for ethdev.Quoted 7 lines
Quoted 3 lines
May be it is possible to provide internal wrapper which is implemented using
ether_aton_r()and located in a separate C file which does not includerte_ether.hetc?I raised the issue in technical board and it has been decided to fix the conflict with libc in the next release (with Olivier's help). So Bruce and me decided to use cmdline function in the meantime.
As I can see,
cmdline_parse_etheraddr()uses
static structether_addr*my_ether_aton(const char *a)
internally.
Why not to make it public, rename torte_ethet_aton(), and move intorte_net?
And use that one instead?
Later if/when we'll have name conflict with libc resolved, It can become just a wrapper aroundether_aton_r(). Konstantin
Quoted 5 lines
Quoted 2 lines
Several reasons:
- It would be one more (useless) wrapperWell, it would be *when* will have libc naming conflict resolved. Till that it would be pretty useful I think.
It is planned to be fixed in the next release.
Quoted 5 lines
Quoted 1 line
-
cmdline_parse_etheraddris already used in several placesAs I can see right now it is used just by bond PMD:
$ find lib drivers -type f | xargs grep -l cmdline_parse_etheraddr | grep -v librte_cmdline drivers/net/bonding/rte_eth_bond_args.c
It is also used in examples:
examples/bond/main.c examples/ethtool/ethtool-app/ethapp.c examples/l3fwd/main.c examples/performance-thread/l3fwd-thread/main.c
Quoted 3 lines
Again if that function is *really* used in several places to convert string to mac, then I suppose it is an indication that
rte_ether_aton()would be useful. Without forcing cmdline dependency.
I don't like wrappers and reinventing the wheel.
If we introduce this new wrapper, then we will have to deprecate it, and break the API to remove it.
Quoted 4 lines
Quoted 1 line
-
ether_aton_randmy_ether_atonmay have a different behaviorCould you elaborate here?
What exactly would be different?
The error path might be slightly different,
and...
Quoted 4 lines
Both supposed to convert string to ether addr.
If our function can't do that properly, then I think it is a bug in our side. Ifether_aton_r()just supports extra formats(XXXX:XXXX:XXXX), then it would be extension to current behavior.
... yes there is this extension.
Quoted 4 lines
Quoted 2 lines
When the libc conflict will be solved, I prefer replacing uses of
cmdline_parse_etheraddrone by one.We can do the same with
rte_ether_aton()too, if we really want to.
At the price of breaking the API again.
Re: [PATCH v3 4/4] ethdev: support MAC address as iterator filter
Quoted 86 lines
23/10/2018 10:33, Ananyev, Konstantin:
Quoted 40 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 39 lines
22/10/2018 23:24, Ananyev, Konstantin:
Quoted 37 lines
From: Thomas Monjalon
Quoted 18 lines
22/10/2018 15:37, Andrew Rybchenko:
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines
The MAC addresses of a port can be matched with devargs.
As the conflict between
rte_ether.handnetinet/ether.his not resolved, the MAC parsing is done with arte_cmdlinefunction.
As a result, cmdline library becomes a dependency of ethdev.Quoted 6 lines
Quoted 1 line
Signed-off-by Thomas Monjalon <[email protected]>I'd like to share my thought about a new dependency. Looking at cmdline I think that it is a bad and strange dependency for kvargs. IMHO, even duplication of the code to parse MAC address it less evil in this case.
cmdline is not a dependency for kvargs.
I have added it as a dependency for ethdev.Quoted 7 lines
Quoted 3 lines
May be it is possible to provide internal wrapper which is implemented using
ether_aton_r()and located in a separate C file which does not includerte_ether.hetc?I raised the issue in technical board and it has been decided to fix the conflict with libc in the next release (with Olivier's help). So Bruce and me decided to use cmdline function in the meantime.
As I can see,
cmdline_parse_etheraddr()uses
static structether_addr*my_ether_aton(const char *a)
internally.
Why not to make it public, rename torte_ethet_aton(), and move intorte_net?
And use that one instead?
Later if/when we'll have name conflict with libc resolved, It can become just a wrapper aroundether_aton_r(). KonstantinQuoted 5 lines
Quoted 2 lines
Several reasons:
- It would be one more (useless) wrapperWell, it would be *when* will have libc naming conflict resolved. Till that it would be pretty useful I think.
It is planned to be fixed in the next release.
Quoted 5 lines
Quoted 1 line
-
cmdline_parse_etheraddris already used in several placesAs I can see right now it is used just by bond PMD:
$ find lib drivers -type f | xargs grep -l cmdline_parse_etheraddr | grep -v librte_cmdline drivers/net/bonding/rte_eth_bond_args.cIt is also used in examples:
examples/bond/main.cexamples/ethtool/ethtool-app/ethapp.cexamples/l3fwd/main.cexamples/performance-thread/l3fwd-thread/main.cQuoted 3 lines
Again if that function is *really* used in several places to convert string to mac, then I suppose it is an indication that
rte_ether_aton()would be useful. Without forcing cmdline dependency.I don't like wrappers and reinventing the wheel.
If we introduce this new wrapper, then we will have to deprecate it, and break the API to remove it.Quoted 4 lines
Quoted 1 line
-
ether_aton_randmy_ether_atonmay have a different behaviorCould you elaborate here?
What exactly would be different?The error path might be slightly different,
and...Quoted 4 lines
Both supposed to convert string to ether addr.
If our function can't do that properly, then I think it is a bug in our side. Ifether_aton_r()just supports extra formats(XXXX:XXXX:XXXX), then it would be extension to current behavior.
Quoted 8 lines
... yes there is this extension.
Quoted 4 lines
Quoted 2 lines
When the libc conflict will be solved, I prefer replacing uses of
cmdline_parse_etheraddrone by one.We can do the same with
rte_ether_aton()too, if we really want to.At the price of breaking the API again.
Probably you are right - extra dependency is a less evil here. Konstantin
Quoted 12 lines · Thomas Monjalon
The new ethdev iterator lacks the support of filtering by representor port id or by MAC address.
Changes in v3:
- improve comment forrepresentor_idChanges in v2:
- fix list parsing in kvargs
- support mac= parameter
Quoted 5 lines
Thomas Monjalon (4):
kvargs: support list value
ethdev: move representor parsing functions
ethdev: support representor id as iterator filter
ethdev: support MAC address as iterator filter
Series applied to dpdk-next-net/master, thanks.