[dpdk-dev] [PATCH v3 4/4] app/testpmd: display/clear forwarding stats on demand

Ferruh Yigit ferruh.yigit at intel.com
Thu Mar 21 19:50:05 CET 2019


On 3/20/2019 10:02 AM, David Marchand wrote:
> Add a new "show/clear fwd stats all" command to display fwd and port
> statistics on the fly.
> 
> To be able to do so, the (testpmd only) rte_port structure can't be used
> to maintain any statistics.
> Moved the stats dump parts from stop_packet_forwarding() and merge with
> fwd_port_stats_display() into fwd_stats_display().
> fwd engine statistics are then aggregated into a local per port array.
> 
> Signed-off-by: David Marchand <david.marchand at redhat.com>

<...>

> +/* show/clear fwd engine statistics */
> +struct fwd_result {
> +	cmdline_fixed_string_t action;
> +	cmdline_fixed_string_t fwd;
> +	cmdline_fixed_string_t stats;
> +	cmdline_fixed_string_t all;
> +};
> +
> +cmdline_parse_token_string_t cmd_fwd_action =
> +	TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
> +cmdline_parse_token_string_t cmd_fwd_fwd =
> +	TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
> +cmdline_parse_token_string_t cmd_fwd_stats =
> +	TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
> +cmdline_parse_token_string_t cmd_fwd_all =
> +	TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");

Do we need "all"?
Normally we have it when there is selection between specific <port_id> or all,
here only option is all.

> +
> +static void
> +cmd_fwd_parsed(void *parsed_result,
> +	       __rte_unused struct cmdline *cl,
> +	       __rte_unused void *data)
> +{
> +	struct fwd_result *res = parsed_result;
> +
> +	if (!strcmp(res->action, "show"))
> +		fwd_stats_display();
> +	else
> +		fwd_stats_reset();
> +}
> +
> +static cmdline_parse_inst_t cmd_fwdall = {
> +	.f = cmd_fwd_parsed,
> +	.data = NULL,
> +	.help_str = "show|clear fwd stats all",
> +	.tokens = {
> +		(void *)&cmd_fwd_action,
> +		(void *)&cmd_fwd_fwd,
> +		(void *)&cmd_fwd_stats,
> +		(void *)&cmd_fwd_all,
> +		NULL,
> +	},
> +};

in 'app/test-pmd/cmdline.c', there is 'cmd_help_long_parsed()' function to
display the help output, can you please add new command information there too?

> +
>  /* *** READ PORT REGISTER *** */
>  struct cmd_read_reg_result {
>  	cmdline_fixed_string_t read;
> @@ -18559,6 +18602,7 @@ struct cmd_show_tx_metadata_result {
>  	(cmdline_parse_inst_t *)&cmd_showqueue,
>  	(cmdline_parse_inst_t *)&cmd_showportall,
>  	(cmdline_parse_inst_t *)&cmd_showcfg,
> +	(cmdline_parse_inst_t *)&cmd_fwdall,

command name looks misleading 'fwdall', it feels like it is something doing
forwarding more than display, what about following same syntax with above
'cmd_showportall', so 'cmd_showfwdall' or 'cmd_showfwd' based on your answer to
drop "all"?

<...>

> +#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
> +		fwd_cycles += fs->core_cycles;
> +#endif

Ahh, it seems I missed this config option, looks useful :)
I wonder if it is documented anywhere.


More information about the dev mailing list