[1/4] app/testpmd: add queue deferred start switch

Message ID 1535526966-32456-2-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series net/failsafe: support deferred queue start |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Andrew Rybchenko Aug. 29, 2018, 7:16 a.m. UTC
  From: Ian Dolzhansky <Ian.Dolzhansky@oktetlabs.ru>

Signed-off-by: Ian Dolzhansky <Ian.Dolzhansky@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 app/test-pmd/cmdline.c                 | 91 ++++++++++++++++++++++++++
 doc/guides/rel_notes/release_18_11.rst |  6 ++
 2 files changed, 97 insertions(+)
  

Comments

Ferruh Yigit Sept. 3, 2018, 4:56 p.m. UTC | #1
On 8/29/2018 8:16 AM, Andrew Rybchenko wrote:
> From: Ian Dolzhansky <Ian.Dolzhansky@oktetlabs.ru>
> 
> Signed-off-by: Ian Dolzhansky <Ian.Dolzhansky@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
>  app/test-pmd/cmdline.c                 | 91 ++++++++++++++++++++++++++
>  doc/guides/rel_notes/release_18_11.rst |  6 ++
>  2 files changed, 97 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 589121d69..f47ec99f1 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -883,6 +883,10 @@ static void cmd_help_long_parsed(void *parsed_result,
>  			"    Start/stop a rx/tx queue of port X. Only take effect"
>  			" when port X is started\n\n"
>  
> +			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
> +			"    Switch on/off a deferred start of port X rx/tx queue. Only"
> +			" take effect when port X is stopped.\n\n"

Overall looks good to me.

But testpmd doc needs to be updated to add new command.
doc/guides/testpmd_app_ug/testpmd_funcs.rst

Also is there a way to see the current deferred_start status of a port, either
with a specific command or as part of other command like "show port info"?
If not does it make sense to have a way to see it?
  
Andrew Rybchenko Sept. 20, 2018, 1:24 p.m. UTC | #2
On 9/3/18 7:56 PM, Ferruh Yigit wrote:
> On 8/29/2018 8:16 AM, Andrew Rybchenko wrote:
>> From: Ian Dolzhansky <Ian.Dolzhansky@oktetlabs.ru>
>>
>> Signed-off-by: Ian Dolzhansky <Ian.Dolzhansky@oktetlabs.ru>
>> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
>> ---
>>   app/test-pmd/cmdline.c                 | 91 ++++++++++++++++++++++++++
>>   doc/guides/rel_notes/release_18_11.rst |  6 ++
>>   2 files changed, 97 insertions(+)
>>
>> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
>> index 589121d69..f47ec99f1 100644
>> --- a/app/test-pmd/cmdline.c
>> +++ b/app/test-pmd/cmdline.c
>> @@ -883,6 +883,10 @@ static void cmd_help_long_parsed(void *parsed_result,
>>   			"    Start/stop a rx/tx queue of port X. Only take effect"
>>   			" when port X is started\n\n"
>>   
>> +			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
>> +			"    Switch on/off a deferred start of port X rx/tx queue. Only"
>> +			" take effect when port X is stopped.\n\n"
> Overall looks good to me.
>
> But testpmd doc needs to be updated to add new command.
> doc/guides/testpmd_app_ug/testpmd_funcs.rst

Will fix in v2

> Also is there a way to see the current deferred_start status of a port, either
> with a specific command or as part of other command like "show port info"?
> If not does it make sense to have a way to see it?

The following command does it:
show rxq|txq info <port_id> <queue_id>

Thanks,
Andrew.
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 589121d69..f47ec99f1 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -883,6 +883,10 @@  static void cmd_help_long_parsed(void *parsed_result,
 			"    Start/stop a rx/tx queue of port X. Only take effect"
 			" when port X is started\n\n"
 
+			"port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
+			"    Switch on/off a deferred start of port X rx/tx queue. Only"
+			" take effect when port X is stopped.\n\n"
+
 			"port (port_id) (rxq|txq) (queue_id) setup\n"
 			"    Setup a rx/tx queue of port X.\n\n"
 
@@ -2441,6 +2445,92 @@  cmdline_parse_inst_t cmd_config_rxtx_queue = {
 	},
 };
 
+/* *** configure port rxq/txq deferred start on/off *** */
+struct cmd_config_deferred_start_rxtx_queue {
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t rxtxq;
+	uint16_t qid;
+	cmdline_fixed_string_t opname;
+	cmdline_fixed_string_t state;
+};
+
+static void
+cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
+			__attribute__((unused)) struct cmdline *cl,
+			__attribute__((unused)) void *data)
+{
+	struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
+	struct rte_port *port;
+	uint8_t isrx;
+	uint8_t ison;
+	uint8_t needreconfig = 0;
+
+	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+		return;
+
+	if (port_is_started(res->port_id) != 0) {
+		printf("Please stop port %u first\n", res->port_id);
+		return;
+	}
+
+	port = &ports[res->port_id];
+
+	isrx = !strcmp(res->rxtxq, "rxq");
+
+	if (isrx && rx_queue_id_is_invalid(res->qid))
+		return;
+	else if (!isrx && tx_queue_id_is_invalid(res->qid))
+		return;
+
+	ison = !strcmp(res->state, "on");
+
+	if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
+		port->rx_conf[res->qid].rx_deferred_start = ison;
+		needreconfig = 1;
+	} else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
+		port->tx_conf[res->qid].tx_deferred_start = ison;
+		needreconfig = 1;
+	}
+
+	if (needreconfig)
+		cmd_reconfig_device_queue(res->port_id, 0, 1);
+}
+
+cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
+						port, "port");
+cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
+						port_id, UINT16);
+cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
+						rxtxq, "rxq#txq");
+cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
+	TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
+						qid, UINT16);
+cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
+						opname, "deferred_start");
+cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
+						state, "on#off");
+
+cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
+	.f = cmd_config_deferred_start_rxtx_queue_parsed,
+	.data = NULL,
+	.help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
+	.tokens = {
+		(void *)&cmd_config_deferred_start_rxtx_queue_port,
+		(void *)&cmd_config_deferred_start_rxtx_queue_port_id,
+		(void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
+		(void *)&cmd_config_deferred_start_rxtx_queue_qid,
+		(void *)&cmd_config_deferred_start_rxtx_queue_opname,
+		(void *)&cmd_config_deferred_start_rxtx_queue_state,
+		NULL,
+	},
+};
+
 /* *** configure port rxq/txq setup *** */
 struct cmd_setup_rxtx_queue {
 	cmdline_fixed_string_t port;
@@ -17711,6 +17801,7 @@  cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_config_rss,
 	(cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
 	(cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
+	(cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
 	(cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
 	(cmdline_parse_inst_t *)&cmd_config_rss_reta,
 	(cmdline_parse_inst_t *)&cmd_showport_reta,
diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst
index 24204e67b..1f17befd8 100644
--- a/doc/guides/rel_notes/release_18_11.rst
+++ b/doc/guides/rel_notes/release_18_11.rst
@@ -54,6 +54,12 @@  New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added ability to switch queue deferred start flag on testpmd app.**
+
+  Added a console command to testpmd app, giving ability to switch
+  ``rx_deferred_start`` or ``tx_deferred_start`` flag of the specified queue of
+  the specified port. The port must be stopped before the command call in order
+  to reconfigure queues.
 
 API Changes
 -----------