app/testpmd: add commands for link up and down
This patch adds commands to test the functionality of setting link up and down. Signed-off-by: Ouyang Changchun <changchun.ouyang@intel.com> Tested-by: Waterman Cao <waterman.cao@intel.com> Acked by: Ivan Boule <ivan.boule@6wind.com>
This commit is contained in:
parent
c38f4f83ed
commit
cfae07fdaa
@ -3930,6 +3930,85 @@ cmdline_parse_inst_t cmd_start_tx_first = {
|
||||
},
|
||||
};
|
||||
|
||||
/* *** SET LINK UP *** */
|
||||
struct cmd_set_link_up_result {
|
||||
cmdline_fixed_string_t set;
|
||||
cmdline_fixed_string_t link_up;
|
||||
cmdline_fixed_string_t port;
|
||||
uint8_t port_id;
|
||||
};
|
||||
|
||||
cmdline_parse_token_string_t cmd_set_link_up_set =
|
||||
TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
|
||||
cmdline_parse_token_string_t cmd_set_link_up_link_up =
|
||||
TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
|
||||
"link-up");
|
||||
cmdline_parse_token_string_t cmd_set_link_up_port =
|
||||
TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
|
||||
cmdline_parse_token_num_t cmd_set_link_up_port_id =
|
||||
TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT8);
|
||||
|
||||
static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
|
||||
__attribute__((unused)) struct cmdline *cl,
|
||||
__attribute__((unused)) void *data)
|
||||
{
|
||||
struct cmd_set_link_up_result *res = parsed_result;
|
||||
dev_set_link_up(res->port_id);
|
||||
}
|
||||
|
||||
cmdline_parse_inst_t cmd_set_link_up = {
|
||||
.f = cmd_set_link_up_parsed,
|
||||
.data = NULL,
|
||||
.help_str = "set link-up port (port id)",
|
||||
.tokens = {
|
||||
(void *)&cmd_set_link_up_set,
|
||||
(void *)&cmd_set_link_up_link_up,
|
||||
(void *)&cmd_set_link_up_port,
|
||||
(void *)&cmd_set_link_up_port_id,
|
||||
NULL,
|
||||
},
|
||||
};
|
||||
|
||||
/* *** SET LINK DOWN *** */
|
||||
struct cmd_set_link_down_result {
|
||||
cmdline_fixed_string_t set;
|
||||
cmdline_fixed_string_t link_down;
|
||||
cmdline_fixed_string_t port;
|
||||
uint8_t port_id;
|
||||
};
|
||||
|
||||
cmdline_parse_token_string_t cmd_set_link_down_set =
|
||||
TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
|
||||
cmdline_parse_token_string_t cmd_set_link_down_link_down =
|
||||
TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
|
||||
"link-down");
|
||||
cmdline_parse_token_string_t cmd_set_link_down_port =
|
||||
TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
|
||||
cmdline_parse_token_num_t cmd_set_link_down_port_id =
|
||||
TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT8);
|
||||
|
||||
static void cmd_set_link_down_parsed(
|
||||
__attribute__((unused)) void *parsed_result,
|
||||
__attribute__((unused)) struct cmdline *cl,
|
||||
__attribute__((unused)) void *data)
|
||||
{
|
||||
struct cmd_set_link_down_result *res = parsed_result;
|
||||
dev_set_link_down(res->port_id);
|
||||
}
|
||||
|
||||
cmdline_parse_inst_t cmd_set_link_down = {
|
||||
.f = cmd_set_link_down_parsed,
|
||||
.data = NULL,
|
||||
.help_str = "set link-down port (port id)",
|
||||
.tokens = {
|
||||
(void *)&cmd_set_link_down_set,
|
||||
(void *)&cmd_set_link_down_link_down,
|
||||
(void *)&cmd_set_link_down_port,
|
||||
(void *)&cmd_set_link_down_port_id,
|
||||
NULL,
|
||||
},
|
||||
};
|
||||
|
||||
/* *** SHOW CFG *** */
|
||||
struct cmd_showcfg_result {
|
||||
cmdline_fixed_string_t show;
|
||||
@ -5314,6 +5393,8 @@ cmdline_parse_ctx_t main_ctx[] = {
|
||||
(cmdline_parse_inst_t *)&cmd_showcfg,
|
||||
(cmdline_parse_inst_t *)&cmd_start,
|
||||
(cmdline_parse_inst_t *)&cmd_start_tx_first,
|
||||
(cmdline_parse_inst_t *)&cmd_set_link_up,
|
||||
(cmdline_parse_inst_t *)&cmd_set_link_down,
|
||||
(cmdline_parse_inst_t *)&cmd_reset,
|
||||
(cmdline_parse_inst_t *)&cmd_set_numbers,
|
||||
(cmdline_parse_inst_t *)&cmd_set_txpkts,
|
||||
|
@ -1208,6 +1208,20 @@ stop_packet_forwarding(void)
|
||||
test_done = 1;
|
||||
}
|
||||
|
||||
void
|
||||
dev_set_link_up(portid_t pid)
|
||||
{
|
||||
if (rte_eth_dev_set_link_up((uint8_t)pid) < 0)
|
||||
printf("\nSet link up fail.\n");
|
||||
}
|
||||
|
||||
void
|
||||
dev_set_link_down(portid_t pid)
|
||||
{
|
||||
if (rte_eth_dev_set_link_down((uint8_t)pid) < 0)
|
||||
printf("\nSet link down fail.\n");
|
||||
}
|
||||
|
||||
static int
|
||||
all_ports_started(void)
|
||||
{
|
||||
|
@ -499,6 +499,8 @@ char *list_pkt_forwarding_modes(void);
|
||||
void set_pkt_forwarding_mode(const char *fwd_mode);
|
||||
void start_packet_forwarding(int with_tx_first);
|
||||
void stop_packet_forwarding(void);
|
||||
void dev_set_link_up(portid_t pid);
|
||||
void dev_set_link_down(portid_t pid);
|
||||
void init_port_config(void);
|
||||
int init_port_dcb_config(portid_t pid,struct dcb_config *dcb_conf);
|
||||
int start_port(portid_t pid);
|
||||
|
Loading…
Reference in New Issue
Block a user