[dpdk-dev] ip_pipeline: add command for multiple execution of run <file>

Message ID 1462561743-76966-1-git-send-email-jasvinder.singh@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Jasvinder Singh May 6, 2016, 7:09 p.m. UTC
  From: Sankar Chokkalingam <sankarx.chokkalingam@intel.com>

The new command enables the execution of script-file for 'n' number of
times in regular intervals. It takes script-file, number of times to be
executed, interval between each execution as inputs.

Syntax: run <file> <count> <interval>

Usage: This command helps to collect statistics of ports and pipelines in
periodic interval.

Example: run port_stats 5 30

The port_stats file may contain the list of port stats commands like
p 1 port in 0 stats
p 1 port out 0 stats
p 2 port in 0 stats
p 2 port out 0 stats
p 2 port in 1 stats
p 2 port out stats.

The list of commands in the file will be executed 5 times with the
interval of 30 seconds.

Signed-off-by: Sankar Chokkalingam <sankarx.chokkalingam@intel.com>
---
 examples/ip_pipeline/pipeline/pipeline_common_fe.c | 50 ++++++++++++++++++++++
 1 file changed, 50 insertions(+)
  

Comments

Cristian Dumitrescu May 24, 2016, 5:20 p.m. UTC | #1
> -----Original Message-----
> From: Singh, Jasvinder
> Sent: Friday, May 6, 2016 8:09 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Chokkalingam,
> SankarX <sankarx.chokkalingam@intel.com>
> Subject: [PATCH] ip_pipeline: add command for multiple execution of run
> <file>
> 
> From: Sankar Chokkalingam <sankarx.chokkalingam@intel.com>
> 
> The new command enables the execution of script-file for 'n' number of
> times in regular intervals. It takes script-file, number of times to be
> executed, interval between each execution as inputs.
> 
> Syntax: run <file> <count> <interval>
> 
> Usage: This command helps to collect statistics of ports and pipelines in
> periodic interval.
> 
> Example: run port_stats 5 30
> 
> The port_stats file may contain the list of port stats commands like
> p 1 port in 0 stats
> p 1 port out 0 stats
> p 2 port in 0 stats
> p 2 port out 0 stats
> p 2 port in 1 stats
> p 2 port out stats.
> 
> The list of commands in the file will be executed 5 times with the
> interval of 30 seconds.
> 
> Signed-off-by: Sankar Chokkalingam <sankarx.chokkalingam@intel.com>
> ---
>  examples/ip_pipeline/pipeline/pipeline_common_fe.c | 50
> ++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.c
> b/examples/ip_pipeline/pipeline/pipeline_common_fe.c
> index a691d42..9f7ef08 100644
> --- a/examples/ip_pipeline/pipeline/pipeline_common_fe.c
> +++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.c
> @@ -1267,9 +1267,59 @@ cmdline_parse_inst_t cmd_run = {
>  	},
>  };
> 
> +struct cmd_multirun_file_result {
> +	cmdline_fixed_string_t run_string;
> +	char file_name[APP_FILE_NAME_SIZE];
> +	uint32_t count;
> +	uint32_t interval;
> +};
> +
> +static void
> +cmd_multirun_parsed(
> +	void *parsed_result,
> +	struct cmdline *cl,
> +	__attribute__((unused)) void *data)
> +{
> +	struct cmd_multirun_file_result *params = parsed_result;
> +	uint32_t i;
> +
> +	for (i = 0; i < params->count; i++) {
> +		app_run_file(cl->ctx, params->file_name);
> +		sleep(params->interval);
> +	}
> +}
> +
> +cmdline_parse_token_string_t cmd_multirun_run_string =
> +	TOKEN_STRING_INITIALIZER(struct cmd_multirun_file_result,
> run_string,
> +		"run");
> +
> +cmdline_parse_token_string_t cmd_multirun_file_name =
> +	TOKEN_STRING_INITIALIZER(struct cmd_multirun_file_result,
> file_name, NULL);
> +
> +static cmdline_parse_token_num_t cmd_multirun_count =
> +	TOKEN_NUM_INITIALIZER(struct cmd_multirun_file_result, count,
> UINT32);
> +
> +static cmdline_parse_token_num_t cmd_multirun_interval =
> +	TOKEN_NUM_INITIALIZER(struct cmd_multirun_file_result, interval,
> UINT32);
> +
> +cmdline_parse_inst_t cmd_multirun = {
> +	.f = cmd_multirun_parsed,
> +	.data = NULL,
> +	.help_str = "Run CLI script file",
> +	.tokens = {
> +		(void *) &cmd_multirun_run_string,
> +		(void *) &cmd_multirun_file_name,
> +		(void *) &cmd_multirun_count,
> +		(void *) &cmd_multirun_interval,
> +		NULL,
> +	},
> +};
> +
> +
>  static cmdline_parse_ctx_t pipeline_common_cmds[] = {
>  	(cmdline_parse_inst_t *) &cmd_quit,
>  	(cmdline_parse_inst_t *) &cmd_run,
> +	(cmdline_parse_inst_t *) &cmd_multirun,
> 
>  	(cmdline_parse_inst_t *) &cmd_link_config,
>  	(cmdline_parse_inst_t *) &cmd_link_up,
> --
> 1.8.3.1

Hi Jasvinder and Sankar,

This patch is now  reworked and included into the ip_pipeline CLI rework patch set that Michal and Piotr sent: http://www.dpdk.org/ml/archives/dev/2016-May/039429.html

So we can safely discard this patch now.

Thanks,
Cristian
  

Patch

diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.c b/examples/ip_pipeline/pipeline/pipeline_common_fe.c
index a691d42..9f7ef08 100644
--- a/examples/ip_pipeline/pipeline/pipeline_common_fe.c
+++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.c
@@ -1267,9 +1267,59 @@  cmdline_parse_inst_t cmd_run = {
 	},
 };
 
+struct cmd_multirun_file_result {
+	cmdline_fixed_string_t run_string;
+	char file_name[APP_FILE_NAME_SIZE];
+	uint32_t count;
+	uint32_t interval;
+};
+
+static void
+cmd_multirun_parsed(
+	void *parsed_result,
+	struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_multirun_file_result *params = parsed_result;
+	uint32_t i;
+
+	for (i = 0; i < params->count; i++) {
+		app_run_file(cl->ctx, params->file_name);
+		sleep(params->interval);
+	}
+}
+
+cmdline_parse_token_string_t cmd_multirun_run_string =
+	TOKEN_STRING_INITIALIZER(struct cmd_multirun_file_result, run_string,
+		"run");
+
+cmdline_parse_token_string_t cmd_multirun_file_name =
+	TOKEN_STRING_INITIALIZER(struct cmd_multirun_file_result, file_name, NULL);
+
+static cmdline_parse_token_num_t cmd_multirun_count =
+	TOKEN_NUM_INITIALIZER(struct cmd_multirun_file_result, count, UINT32);
+
+static cmdline_parse_token_num_t cmd_multirun_interval =
+	TOKEN_NUM_INITIALIZER(struct cmd_multirun_file_result, interval, UINT32);
+
+cmdline_parse_inst_t cmd_multirun = {
+	.f = cmd_multirun_parsed,
+	.data = NULL,
+	.help_str = "Run CLI script file",
+	.tokens = {
+		(void *) &cmd_multirun_run_string,
+		(void *) &cmd_multirun_file_name,
+		(void *) &cmd_multirun_count,
+		(void *) &cmd_multirun_interval,
+		NULL,
+	},
+};
+
+
 static cmdline_parse_ctx_t pipeline_common_cmds[] = {
 	(cmdline_parse_inst_t *) &cmd_quit,
 	(cmdline_parse_inst_t *) &cmd_run,
+	(cmdline_parse_inst_t *) &cmd_multirun,
 
 	(cmdline_parse_inst_t *) &cmd_link_config,
 	(cmdline_parse_inst_t *) &cmd_link_up,