[PATCH v2 2/2] net/iavf: add restore command to testpmd
Ciara Loftus
ciara.loftus at intel.com
Fri Oct 3 12:23:59 CEST 2025
This patch adds an IAVF testpmd command "port restore <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 <ciara.loftus at intel.com>
---
drivers/net/intel/iavf/iavf_testpmd.c | 52 +++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/drivers/net/intel/iavf/iavf_testpmd.c b/drivers/net/intel/iavf/iavf_testpmd.c
index 775179fc01..2432e015b3 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_restore_result {
+ cmdline_fixed_string_t port;
+ cmdline_fixed_string_t restore;
+ portid_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_restore_port =
+ TOKEN_STRING_INITIALIZER(struct cmd_restore_result,
+ port, "port");
+static cmdline_parse_token_string_t cmd_restore_restore =
+ TOKEN_STRING_INITIALIZER(struct cmd_restore_result,
+ restore, "restore");
+static cmdline_parse_token_num_t cmd_restore_port_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_restore_result,
+ port_id, RTE_UINT16);
+
+static void
+cmd_restore_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl, __rte_unused void *data)
+{
+ struct cmd_restore_result *res = parsed_result;
+ int ret;
+
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
+ ret = rte_pmd_iavf_restore(res->port_id);
+ if (ret < 0)
+ fprintf(stderr, "Request to restore VF failed for port %u: %s\n",
+ res->port_id, rte_strerror(-ret));
+ else
+ printf("VF restore requested for port %u\n", res->port_id);
+}
+
+static cmdline_parse_inst_t cmd_restore = {
+ .f = cmd_restore_parsed,
+ .data = NULL,
+ .help_str = "port restore <port_id>",
+ .tokens = {
+ (void *)&cmd_restore_port,
+ (void *)&cmd_restore_restore,
+ (void *)&cmd_restore_port_id,
+ NULL,
+ },
+};
+
static struct testpmd_driver_commands iavf_cmds = {
.commands = {
{
@@ -76,7 +122,13 @@ 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_restore,
+ "port restore (port_id)\n"
+ " Send a request to the PF to reset the VF, then restore the port\n\n",
+ },
{ NULL, NULL },
},
};
+
TESTPMD_ADD_DRIVER_COMMANDS(iavf_cmds)
--
2.34.1
More information about the dev
mailing list