This patch adds an IAVF testpmd command "port reinit <port_id>" which will send a request to the PF to reset the given VF, followed by the VF then reinitialising and restarting itself.
Signed-off-by: Ciara Loftus <[email protected]> --- v4: * Rename restore -> reinit --- drivers/net/intel/iavf/iavf_testpmd.c | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/drivers/net/intel/iavf/iavf_testpmd.c b/drivers/net/intel/iavf/iavf_testpmd.c index 775179fc01..4731d0b61b 100644 --- a/drivers/net/intel/iavf/iavf_testpmd.c +++ b/drivers/net/intel/iavf/iavf_testpmd.c @@ -69,6 +69,52 @@ static cmdline_parse_inst_t cmd_enable_tx_lldp = { }, }; +struct cmd_reinit_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t reinit; + portid_t port_id; +}; + +static cmdline_parse_token_string_t cmd_reinit_port = + TOKEN_STRING_INITIALIZER(struct cmd_reinit_result, + port, "port"); +static cmdline_parse_token_string_t cmd_reinit_reinit = + TOKEN_STRING_INITIALIZER(struct cmd_reinit_result, + reinit, "reinit"); +static cmdline_parse_token_num_t cmd_reinit_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_reinit_result, + port_id, RTE_UINT16); + +static void +cmd_reinit_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, __rte_unused void *data) +{ + struct cmd_reinit_result *res = parsed_result; + int ret; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + + ret = rte_pmd_iavf_reinit(res->port_id); + if (ret < 0) + fprintf(stderr, "Request to reinit VF failed for port %u: %s\n", + res->port_id, rte_strerror(-ret)); + else + printf("VF reinit requested for port %u\n", res->port_id); +} + +static cmdline_parse_inst_t cmd_reinit = { + .f = cmd_reinit_parsed, + .data = NULL, + .help_str = "port reinit <port_id>", + .tokens = { + (void *)&cmd_reinit_port, + (void *)&cmd_reinit_reinit, + (void *)&cmd_reinit_port_id, + NULL, + }, +}; + static struct testpmd_driver_commands iavf_cmds = { .commands = { { @@ -76,6 +122,11 @@ static struct testpmd_driver_commands iavf_cmds = { "set tx lldp (on|off)\n" " Set iavf Tx lldp packet(currently only supported on)\n\n", }, + { + &cmd_reinit, + "port reinit (port_id)\n" + " Send a request to the PF to reset the VF, then restore the port\n\n", + }, { NULL, NULL }, }, }; -- 2.34.1

