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_ethdev.h>
|
||||||
#include <rte_byteorder.h>
|
#include <rte_byteorder.h>
|
||||||
#include <cmdline_parse.h>
|
#include <cmdline_parse.h>
|
||||||
#include <cmdline_parse_etheraddr.h>
|
|
||||||
#include <rte_flow.h>
|
#include <rte_flow.h>
|
||||||
|
|
||||||
#include "testpmd.h"
|
#include "testpmd.h"
|
||||||
@ -4798,8 +4797,8 @@ parse_mac_addr(struct context *ctx, const struct token *token,
|
|||||||
/* Only network endian is supported. */
|
/* Only network endian is supported. */
|
||||||
if (!arg->hton)
|
if (!arg->hton)
|
||||||
goto error;
|
goto error;
|
||||||
ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
|
ret = rte_ether_unformat_addr(str, &tmp);
|
||||||
if (ret < 0 || (unsigned int)ret != len)
|
if (ret < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (!ctx->object)
|
if (!ctx->object)
|
||||||
return len;
|
return len;
|
||||||
|
@ -49,7 +49,6 @@
|
|||||||
#include <rte_pmd_bnxt.h>
|
#include <rte_pmd_bnxt.h>
|
||||||
#endif
|
#endif
|
||||||
#include <rte_gro.h>
|
#include <rte_gro.h>
|
||||||
#include <cmdline_parse_etheraddr.h>
|
|
||||||
#include <rte_config.h>
|
#include <rte_config.h>
|
||||||
|
|
||||||
#include "testpmd.h"
|
#include "testpmd.h"
|
||||||
@ -2278,19 +2277,16 @@ pkt_fwd_config_display(struct fwd_config *cfg)
|
|||||||
void
|
void
|
||||||
set_fwd_eth_peer(portid_t port_id, char *peer_addr)
|
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)) {
|
if (!rte_eth_dev_is_valid_port(port_id)) {
|
||||||
printf("Error: Invalid port number %i\n", port_id);
|
printf("Error: Invalid port number %i\n", port_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cmdline_parse_etheraddr(NULL, peer_addr, &new_peer_addr,
|
if (rte_ether_unformat_addr(peer_addr, &new_peer_addr) < 0) {
|
||||||
sizeof(new_peer_addr)) < 0) {
|
|
||||||
printf("Error: Invalid ethernet address: %s\n", peer_addr);
|
printf("Error: Invalid ethernet address: %s\n", peer_addr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (c = 0; c < 6; c++)
|
peer_eth_addrs[port_id] = new_peer_addr;
|
||||||
peer_eth_addrs[port_id].addr_bytes[c] =
|
|
||||||
new_peer_addr[c];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -39,10 +39,6 @@
|
|||||||
#include <rte_ether.h>
|
#include <rte_ether.h>
|
||||||
#include <rte_ethdev.h>
|
#include <rte_ethdev.h>
|
||||||
#include <rte_string_fns.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
|
#ifdef RTE_LIBRTE_PMD_BOND
|
||||||
#include <rte_eth_bond.h>
|
#include <rte_eth_bond.h>
|
||||||
#endif
|
#endif
|
||||||
@ -227,8 +223,7 @@ init_peer_eth_addrs(char *config_filename)
|
|||||||
if (fgets(buf, sizeof(buf), config_file) == NULL)
|
if (fgets(buf, sizeof(buf), config_file) == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i],
|
if (rte_ether_unformat_addr(buf, &peer_eth_addrs[i]) < 0) {
|
||||||
sizeof(peer_eth_addrs[i])) < 0) {
|
|
||||||
printf("Bad MAC address format on line %d\n", i+1);
|
printf("Bad MAC address format on line %d\n", i+1);
|
||||||
fclose(config_file);
|
fclose(config_file);
|
||||||
return -1;
|
return -1;
|
||||||
@ -727,7 +722,6 @@ launch_args_parse(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
|
if (!strcmp(lgopts[opt_idx].name, "eth-peer")) {
|
||||||
char *port_end;
|
char *port_end;
|
||||||
uint8_t c, peer_addr[6];
|
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
n = strtoul(optarg, &port_end, 10);
|
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",
|
"eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n",
|
||||||
n, RTE_MAX_ETHPORTS);
|
n, RTE_MAX_ETHPORTS);
|
||||||
|
|
||||||
if (cmdline_parse_etheraddr(NULL, port_end,
|
if (rte_ether_unformat_addr(port_end,
|
||||||
&peer_addr, sizeof(peer_addr)) < 0)
|
&peer_eth_addrs[n]) < 0)
|
||||||
rte_exit(EXIT_FAILURE,
|
rte_exit(EXIT_FAILURE,
|
||||||
"Invalid ethernet address: %s\n",
|
"Invalid ethernet address: %s\n",
|
||||||
port_end);
|
port_end);
|
||||||
for (c = 0; c < 6; c++)
|
|
||||||
peer_eth_addrs[n].addr_bytes[c] =
|
|
||||||
peer_addr[c];
|
|
||||||
nb_peer_eth_addrs++;
|
nb_peer_eth_addrs++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user