app/testpmd: use new ethernet address parser
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@networkplumber.org> Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
This commit is contained in:
parent
1c774fe44c
commit
b5ddce8959
@ -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"
|
||||
@ -4798,8 +4797,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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user