[dpdk-dev] [PATCH v4 8/8] app/testpmd: use rte_ether_unformat_addr

Stephen Hemminger stephen at networkplumber.org
Thu Jun 20 18:12:35 CEST 2019


On Thu, 20 Jun 2019 14:18:18 +0000
"Iremonger, Bernard" <bernard.iremonger at intel.com> wrote:

> Hi Stephen,
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen
> > Hemminger
> > Sent: Wednesday, June 5, 2019 7:10 PM
> > To: dev at dpdk.org
> > Cc: Stephen Hemminger <stephen at networkplumber.org>
> > Subject: [dpdk-dev] [PATCH v4 8/8] app/testpmd: use
> > rte_ether_unformat_addr
> > 
> > The cmdline_parse_ether_addr does not need to be used everywhere in
> > testpmd. Can use rte_ether_unformat_addr instead.
> > As an added bonus it eliminates some code for copying.
> > 
> > Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> > ---
> >  app/test-pmd/cmdline_flow.c |  5 ++---
> >  app/test-pmd/config.c       | 10 +++-------
> >  app/test-pmd/parameters.c   | 15 +++------------
> >  3 files changed, 8 insertions(+), 22 deletions(-)
> > 
> > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> > index 201bd9de56e0..2b02ca29b7ac 100644
> > --- a/app/test-pmd/cmdline_flow.c
> > +++ b/app/test-pmd/cmdline_flow.c
> > @@ -18,7 +18,6 @@
> >  #include <rte_ethdev.h>
> >  #include <rte_byteorder.h>
> >  #include <cmdline_parse.h>
> > -#include <cmdline_parse_etheraddr.h>
> >  #include <rte_flow.h>
> > 
> >  #include "testpmd.h"
> > @@ -4627,8 +4626,8 @@ parse_mac_addr(struct context *ctx, const struct
> > token *token,
> >  	/* Only network endian is supported. */
> >  	if (!arg->hton)
> >  		goto error;
> > -	ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
> > -	if (ret < 0 || (unsigned int)ret != len)
> > +	ret = rte_ether_unformat_addr(str, &tmp);
> > +	if (ret < 0)
> >  		goto error;
> >  	if (!ctx->object)
> >  		return len;
> > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> > ab458c8d2837..1d804705d96c 100644
> > --- a/app/test-pmd/config.c
> > +++ b/app/test-pmd/config.c
> > @@ -49,7 +49,6 @@
> >  #include <rte_pmd_bnxt.h>
> >  #endif
> >  #include <rte_gro.h>
> > -#include <cmdline_parse_etheraddr.h>
> >  #include <rte_config.h>
> > 
> >  #include "testpmd.h"
> > @@ -2278,19 +2277,16 @@ pkt_fwd_config_display(struct fwd_config *cfg)
> > void  set_fwd_eth_peer(portid_t port_id, char *peer_addr)  {
> > -	uint8_t c, new_peer_addr[6];
> > +	struct rte_ether_addr new_peer_addr;
> >  	if (!rte_eth_dev_is_valid_port(port_id)) {
> >  		printf("Error: Invalid port number %i\n", port_id);
> >  		return;
> >  	}
> > -	if (cmdline_parse_etheraddr(NULL, peer_addr, &new_peer_addr,
> > -					sizeof(new_peer_addr)) < 0) {
> > +	if (rte_ether_unformat_addr(peer_addr, &new_peer_addr) < 0) {
> >  		printf("Error: Invalid ethernet address: %s\n", peer_addr);
> >  		return;
> >  	}
> > -	for (c = 0; c < 6; c++)
> > -		peer_eth_addrs[port_id].addr_bytes[c] =
> > -			new_peer_addr[c];
> > +	peer_eth_addrs[port_id] = new_peer_addr;
> >  }
> > 
> >  int
> > diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index
> > 245b610641ee..975a97807009 100644
> > --- a/app/test-pmd/parameters.c
> > +++ b/app/test-pmd/parameters.c
> > @@ -39,10 +39,6 @@
> >  #include <rte_ether.h>
> >  #include <rte_ethdev.h>
> >  #include <rte_string_fns.h>
> > -#ifdef RTE_LIBRTE_CMDLINE
> > -#include <cmdline_parse.h>
> > -#include <cmdline_parse_etheraddr.h>
> > -#endif
> >  #ifdef RTE_LIBRTE_PMD_BOND
> >  #include <rte_eth_bond.h>
> >  #endif
> > @@ -227,8 +223,7 @@ init_peer_eth_addrs(char *config_filename)
> >  		if (fgets(buf, sizeof(buf), config_file) == NULL)
> >  			break;
> > 
> > -		if (cmdline_parse_etheraddr(NULL, buf,
> > &peer_eth_addrs[i],
> > -				sizeof(peer_eth_addrs[i])) < 0) {
> > +		if (rte_ether_unformat_addr(buf, &peer_eth_addrs[i]) < 0) {
> >  			printf("Bad MAC address format on line %d\n", i+1);
> >  			fclose(config_file);
> >  			return -1;
> > @@ -727,7 +722,6 @@ launch_args_parse(int argc, char** argv)
> >  			}
> >  			if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
> >  				char *port_end;
> > -				uint8_t c, peer_addr[6];
> > 
> >  				errno = 0;
> >  				n = strtoul(optarg, &port_end, 10); @@ -
> > 739,14 +733,11 @@ launch_args_parse(int argc, char** argv)
> >  						 "eth-peer: port %d >=
> > RTE_MAX_ETHPORTS(%d)\n",
> >  						 n, RTE_MAX_ETHPORTS);
> > 
> > -				if (cmdline_parse_etheraddr(NULL,
> > port_end,
> > -						&peer_addr,
> > sizeof(peer_addr)) < 0)
> > +				if (rte_ether_unformat_addr(port_end,
> > +
> > &peer_eth_addrs[n]) < 0)
> >  					rte_exit(EXIT_FAILURE,
> >  						 "Invalid ethernet address:
> > %s\n",
> >  						 port_end);
> > -				for (c = 0; c < 6; c++)
> > -					peer_eth_addrs[n].addr_bytes[c] =
> > -						peer_addr[c];
> >  				nb_peer_eth_addrs++;
> >  			}
> >  #endif
> > --
> > 2.20.1  
> 
> ./devtools/check-git-log.sh -1
> Wrong headline format:
>         app/testpmd: use rte_ether_unformat_addr
> 
> Does not like the "_" in the commit message.
> This also affects four of the other patches in the set.

The tool is broken, not the patch.
This is not a restriction in other projects.

> /devtools/checkpatches.sh  v4-8-8-app-testpmd-use-rte_ether_unformat_addr.patch
> 
> WARNING:LONG_LINE: line over 80 characters
> #125: FILE: app/test-pmd/parameters.c:737:
> +                                                           &peer_eth_addrs[n]) < 0)
> 
> total: 0 errors, 1 warnings, 88 lines checked
> 
> Long line should probably be fixed.

The pre-existing code had a long line already.


More information about the dev mailing list