From: Ciara Loftus <ciara.loftus@intel.com>
To: dev@dpdk.org
Cc: Ciara Loftus <ciara.loftus@intel.com>
Subject: [RFC 3/3] app/testpmd: support port reinitialisation
Date: Fri, 17 Oct 2025 11:11:09 +0000 [thread overview]
Message-ID: <20251017111109.1734792-4-ciara.loftus@intel.com> (raw)
In-Reply-To: <20251017111109.1734792-1-ciara.loftus@intel.com>
Add a new command for reinitialising the port. It differs from the "port
reset" command in that resets but also reinitialises the device,
restoring it to its original configuration and in some cases restarting
it if the driver supports it.
The command uses the following syntax:
port reinit <port_id>
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
app/test-pmd/cmdline.c | 15 ++++++++++-----
app/test-pmd/testpmd.c | 26 ++++++++++++++++++++++++++
app/test-pmd/testpmd.h | 1 +
3 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 7803e14bdc..b63b614ef9 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1100,7 +1100,7 @@ static cmdline_parse_inst_t cmd_help_long = {
};
-/* *** start/stop/close all ports *** */
+/* *** start/stop/close/reset/reinit all ports *** */
struct cmd_operate_port_result {
cmdline_fixed_string_t keyword;
cmdline_fixed_string_t name;
@@ -1121,6 +1121,8 @@ static void cmd_operate_port_parsed(void *parsed_result,
close_port(RTE_PORT_ALL);
else if (!strcmp(res->name, "reset"))
reset_port(RTE_PORT_ALL);
+ else if (!strcmp(res->name, "reinit"))
+ reinit_port(RTE_PORT_ALL);
else
fprintf(stderr, "Unknown parameter\n");
}
@@ -1130,14 +1132,14 @@ static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
"port");
static cmdline_parse_token_string_t cmd_operate_port_all_port =
TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
- "start#stop#close#reset");
+ "start#stop#close#reset#reinit");
static cmdline_parse_token_string_t cmd_operate_port_all_all =
TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
static cmdline_parse_inst_t cmd_operate_port = {
.f = cmd_operate_port_parsed,
.data = NULL,
- .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
+ .help_str = "port start|stop|close|reset|reinit all: Start/Stop/Close/Reset/Reinit all ports",
.tokens = {
(void *)&cmd_operate_port_all_cmd,
(void *)&cmd_operate_port_all_port,
@@ -1167,6 +1169,8 @@ static void cmd_operate_specific_port_parsed(void *parsed_result,
close_port(res->value);
else if (!strcmp(res->name, "reset"))
reset_port(res->value);
+ else if (!strcmp(res->name, "reinit"))
+ reinit_port(res->value);
else
fprintf(stderr, "Unknown parameter\n");
}
@@ -1176,7 +1180,7 @@ static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
keyword, "port");
static cmdline_parse_token_string_t cmd_operate_specific_port_port =
TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
- name, "start#stop#close#reset");
+ name, "start#stop#close#reset#reinit");
static cmdline_parse_token_num_t cmd_operate_specific_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
value, RTE_UINT8);
@@ -1184,7 +1188,8 @@ static cmdline_parse_token_num_t cmd_operate_specific_port_id =
static cmdline_parse_inst_t cmd_operate_specific_port = {
.f = cmd_operate_specific_port_parsed,
.data = NULL,
- .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
+ .help_str = "port start|stop|close|reset|reinit <port_id>: "
+ "Start/Stop/Close/Reset/Reinit port_id",
.tokens = {
(void *)&cmd_operate_specific_port_cmd,
(void *)&cmd_operate_specific_port_port,
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 1a48b00e93..e1635a3035 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3412,6 +3412,32 @@ reset_port(portid_t pid)
printf("Done\n");
}
+void
+reinit_port(portid_t pid)
+{
+ int diag;
+ portid_t pi;
+
+ if (port_id_is_invalid(pid, ENABLED_WARN))
+ return;
+
+ printf("Reinitializing ports...\n");
+
+ RTE_ETH_FOREACH_DEV(pi) {
+ if (pid != pi && pid != (portid_t)RTE_PORT_ALL)
+ continue;
+
+ if (is_proc_primary()) {
+ diag = rte_eth_dev_reinit(pi);
+ if (diag != 0)
+ fprintf(stderr, "Failed to reinit port %d. diag=%d\n",
+ pi, diag);
+ }
+ }
+
+ printf("Done\n");
+}
+
static char *
convert_pci_address_format(const char *identifier, char *pci_buffer, size_t buf_size)
{
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index fa46865c67..e47dfa3f65 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -1169,6 +1169,7 @@ int start_port(portid_t pid);
void stop_port(portid_t pid);
void close_port(portid_t pid);
void reset_port(portid_t pid);
+void reinit_port(portid_t pid);
void attach_port(char *identifier);
void detach_devargs(char *identifier);
void detach_port_device(portid_t port_id);
--
2.34.1
prev parent reply other threads:[~2025-10-17 11:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 11:11 [RFC 0/3] ethdev: introduce device reinitialisation API Ciara Loftus
2025-10-17 11:11 ` [RFC 1/3] " Ciara Loftus
2025-10-17 11:11 ` [RFC 2/3] net/iavf: implement device reinitialisation callback Ciara Loftus
2025-10-17 11:11 ` Ciara Loftus [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251017111109.1734792-4-ciara.loftus@intel.com \
--to=ciara.loftus@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).