[dpdk-dev,v2,4/5] app/testpmd: add command to test NIC reset
Checks
Commit Message
When a NIC is reset, a message will show it.
And then user can run the command "reset_port port_id"
to process it.
Signed-off-by: Wei Dai <wei.dai@intel.com>
---
app/test-pmd/cmdline.c | 31 +++++++++++++++++++++++++++++++
app/test-pmd/config.c | 13 +++++++++++++
app/test-pmd/testpmd.h | 1 +
3 files changed, 45 insertions(+)
Comments
> -----Original Message-----
> From: Dai, Wei
> Sent: Tuesday, June 27, 2017 10:07 PM
> To: thomas@monjalon.net; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Ananyev,
> Konstantin <konstantin.ananyev@intel.com>; Zhang, Helin
> <helin.zhang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Dai, Wei <wei.dai@intel.com>
> Subject: [PATCH v2 4/5] app/testpmd: add command to test NIC reset
>
> When a NIC is reset, a message will show it.
> And then user can run the command "reset_port port_id"
> to process it.
>
> Signed-off-by: Wei Dai <wei.dai@intel.com>
> ---
> app/test-pmd/cmdline.c | 31 +++++++++++++++++++++++++++++++ app/test-
> pmd/config.c | 13 +++++++++++++ app/test-pmd/testpmd.h | 1 +
> 3 files changed, 45 insertions(+)
>
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> ff8ffd2..90f6bde 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -2588,6 +2588,36 @@ cmdline_parse_inst_t cmd_stop = {
> },
> };
>
> +/* *** reset a port *** */
> +struct cmd_reset_port_result {
> + cmdline_fixed_string_t command;
> + uint8_t port_id;
> +};
> +
> +static void cmd_reset_port_parsed(__attribute__((unused)) void
> *parsed_result,
> + __attribute__((unused)) struct cmdline *cl,
> + __attribute__((unused)) void *data) {
> + struct cmd_reset_port_result *res = parsed_result;
> + reset_port(res->port_id);
> +}
> +
> +cmdline_parse_token_string_t cmd_reset_port_cmd =
> + TOKEN_STRING_INITIALIZER(struct cmd_reset_port_result, command,
> +"reset_port"); cmdline_parse_token_num_t cmd_reset_port_id =
> + TOKEN_NUM_INITIALIZER(struct cmd_reset_port_result, port_id,
> UINT8);
> +
> +cmdline_parse_inst_t cmd_reset_port = {
> + .f = cmd_reset_port_parsed,
> + .data = NULL,
> + .help_str = "reset_port <port_id>",
You can just add one more option in the commands
"port start|stop|close <port_id>" and " port start|stop|close all"
To "port start|stop|close|reset <port_id>" and " port start|stop|close|reset all" instead of defining a new one.
> -----Original Message-----
> From: Wu, Jingjing
> Sent: Wednesday, June 28, 2017 5:11 PM
> To: Dai, Wei <wei.dai@intel.com>; thomas@monjalon.net; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; Zhang, Helin <helin.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v2 4/5] app/testpmd: add command to test NIC reset
>
>
>
> > -----Original Message-----
> > From: Dai, Wei
> > Sent: Tuesday, June 27, 2017 10:07 PM
> > To: thomas@monjalon.net; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Ananyev,
> > Konstantin <konstantin.ananyev@intel.com>; Zhang, Helin
> > <helin.zhang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> > Cc: dev@dpdk.org; Dai, Wei <wei.dai@intel.com>
> > Subject: [PATCH v2 4/5] app/testpmd: add command to test NIC reset
> >
> > When a NIC is reset, a message will show it.
> > And then user can run the command "reset_port port_id"
> > to process it.
> >
> > Signed-off-by: Wei Dai <wei.dai@intel.com>
> > ---
> > app/test-pmd/cmdline.c | 31 +++++++++++++++++++++++++++++++
> > app/test- pmd/config.c | 13 +++++++++++++ app/test-pmd/testpmd.h |
> > 1 +
> > 3 files changed, 45 insertions(+)
> >
> > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> > ff8ffd2..90f6bde 100644
> > --- a/app/test-pmd/cmdline.c
> > +++ b/app/test-pmd/cmdline.c
> > @@ -2588,6 +2588,36 @@ cmdline_parse_inst_t cmd_stop = {
> > },
> > };
> >
> > +/* *** reset a port *** */
> > +struct cmd_reset_port_result {
> > + cmdline_fixed_string_t command;
> > + uint8_t port_id;
> > +};
> > +
> > +static void cmd_reset_port_parsed(__attribute__((unused)) void
> > *parsed_result,
> > + __attribute__((unused)) struct cmdline *cl,
> > + __attribute__((unused)) void *data) {
> > + struct cmd_reset_port_result *res = parsed_result;
> > + reset_port(res->port_id);
> > +}
> > +
> > +cmdline_parse_token_string_t cmd_reset_port_cmd =
> > + TOKEN_STRING_INITIALIZER(struct cmd_reset_port_result, command,
> > +"reset_port"); cmdline_parse_token_num_t cmd_reset_port_id =
> > + TOKEN_NUM_INITIALIZER(struct cmd_reset_port_result, port_id,
> > UINT8);
> > +
> > +cmdline_parse_inst_t cmd_reset_port = {
> > + .f = cmd_reset_port_parsed,
> > + .data = NULL,
> > + .help_str = "reset_port <port_id>",
>
> You can just add one more option in the commands "port start|stop|close
> <port_id>" and " port start|stop|close all"
> To "port start|stop|close|reset <port_id>" and " port start|stop|close|reset
> all" instead of defining a new one.
Thanks for your feedback.
V3 patch set will follow your guide.
@@ -2588,6 +2588,36 @@ cmdline_parse_inst_t cmd_stop = {
},
};
+/* *** reset a port *** */
+struct cmd_reset_port_result {
+ cmdline_fixed_string_t command;
+ uint8_t port_id;
+};
+
+static void cmd_reset_port_parsed(__attribute__((unused)) void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_reset_port_result *res = parsed_result;
+ reset_port(res->port_id);
+}
+
+cmdline_parse_token_string_t cmd_reset_port_cmd =
+ TOKEN_STRING_INITIALIZER(struct cmd_reset_port_result, command, "reset_port");
+cmdline_parse_token_num_t cmd_reset_port_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_reset_port_result, port_id, UINT8);
+
+cmdline_parse_inst_t cmd_reset_port = {
+ .f = cmd_reset_port_parsed,
+ .data = NULL,
+ .help_str = "reset_port <port_id>",
+ .tokens = {
+ (void *)&cmd_reset_port_cmd,
+ (void *)&cmd_reset_port_id,
+ NULL,
+ },
+};
+
/* *** SET CORELIST and PORTLIST CONFIGURATION *** */
unsigned int
@@ -13751,6 +13781,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_write_reg_bit,
(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
(cmdline_parse_inst_t *)&cmd_stop,
+ (cmdline_parse_inst_t *)&cmd_reset_port,
(cmdline_parse_inst_t *)&cmd_mac_addr,
(cmdline_parse_inst_t *)&cmd_set_qmap,
(cmdline_parse_inst_t *)&cmd_operate_port,
@@ -3318,3 +3318,16 @@ close_ddp_package_file(uint8_t *buf)
return -1;
}
+
+void
+reset_port(portid_t port_id)
+{
+ int diag;
+
+ if (port_id_is_invalid(port_id, ENABLED_WARN))
+ return;
+ diag = rte_eth_dev_reset(port_id);
+ if (diag == 0)
+ return;
+ printf("Reset port %d failed. diag=%d\n", port_id, diag);
+}
@@ -598,6 +598,7 @@ void stop_port(portid_t pid);
void close_port(portid_t pid);
void attach_port(char *identifier);
void detach_port(uint8_t port_id);
+void reset_port(portid_t port_id);
int all_ports_stopped(void);
int port_is_started(portid_t port_id);
void pmd_test_exit(void);