app/testpmd: support dump ethdev private cmd

Message ID 20230314115035.33356-1-fengchengwen@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: support dump ethdev private cmd |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

fengchengwen March 14, 2023, 11:50 a.m. UTC
  This patch adds 'dump_eth_priv [port_id]' which could used to dump
the specific ethdev port private info.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 app/test-pmd/cmdline.c                      | 43 +++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  7 ++++
 2 files changed, 50 insertions(+)
  

Comments

Ferruh Yigit March 14, 2023, 1:45 p.m. UTC | #1
On 3/14/2023 11:50 AM, Chengwen Feng wrote:
> This patch adds 'dump_eth_priv [port_id]' which could used to dump
> the specific ethdev port private info.
> 

We have already "show port ..." commands to display various port related
information, what do you think to follow same syntax for port private info.

Something like "show port private_info <port_id>"


Or it is possible to append this to the output of the existing port info
("show port info <port_id>"),
as a new section of output if port has private info?

This can be an addition parameter to existing command but not sure if we
need it, like:
"show port info <port_id> private on"

I think displaying private info as port of port info without additional
parameter is OK, it is simpler.


> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>  app/test-pmd/cmdline.c                      | 43 +++++++++++++++++++++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  7 ++++
>  2 files changed, 50 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 6fa870dc32..3ac7e78aff 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -8439,6 +8439,48 @@ static cmdline_parse_inst_t cmd_dump_one = {
>  	},
>  };
>  
> +/* ******************************************************************************** */
> +
> +struct cmd_dump_eth_priv_result {
> +	cmdline_fixed_string_t dump;
> +	portid_t port_id;
> +};
> +
> +static cmdline_parse_token_string_t cmd_dump_eth_priv_dump =
> +	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
> +				 "dump_eth_priv");
> +static cmdline_parse_token_num_t cmd_dump_eth_priv_port_id =
> +	TOKEN_NUM_INITIALIZER(struct cmd_dump_eth_priv_result,
> +			      port_id, RTE_UINT16);
> +
> +static void cmd_dump_eth_priv_parsed(void *parsed_result, struct cmdline *cl,
> +				     __rte_unused void *data)
> +{
> +	struct cmd_dump_eth_priv_result *res = parsed_result;
> +	int ret;
> +
> +	if (!rte_eth_dev_is_valid_port(res->port_id)) {
> +		cmdline_printf(cl, "Invalid port id %u\n", res->port_id);
> +		return;
> +	}
> +
> +	ret = rte_eth_dev_priv_dump(res->port_id, stdout);
> +	if (ret < 0)
> +		cmdline_printf(cl, "Failed to dump port id %u private info with error (%d): %s\n",
> +			       res->port_id, ret, strerror(-ret));
> +}
> +
> +static cmdline_parse_inst_t cmd_dump_eth_priv = {
> +	.f = cmd_dump_eth_priv_parsed,  /* function to call */
> +	.data = NULL,      /* 2nd arg of func */
> +	.help_str = "dump_eth_priv <port_id>: Dump one ethdev port private info",
> +	.tokens = {        /* token list, NULL terminated */
> +		(void *)&cmd_dump_eth_priv_dump,
> +		(void *)&cmd_dump_eth_priv_port_id,
> +		NULL,
> +	},
> +};
> +
>  /* *** Filters Control *** */
>  
>  #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
> @@ -12854,6 +12896,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
>  	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
>  	(cmdline_parse_inst_t *)&cmd_dump,
>  	(cmdline_parse_inst_t *)&cmd_dump_one,
> +	(cmdline_parse_inst_t *)&cmd_dump_eth_priv,
>  	(cmdline_parse_inst_t *)&cmd_flow,
>  	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
>  	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index 8f23847859..211f41f86d 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -605,6 +605,13 @@ Dumps the log level for all the dpdk modules::
>  
>     testpmd> dump_log_types
>  
> +dump ethdev private
> +~~~~~~~~~~~~~~~~~~~
> +
> +Dumps the specific ethdev port private info::
> +
> +   testpmd> dump_eth_priv [port_id]
> +
>  show (raw_encap|raw_decap)
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~
>
  
fengchengwen March 15, 2023, 2:02 a.m. UTC | #2
On 2023/3/14 21:45, Ferruh Yigit wrote:
> On 3/14/2023 11:50 AM, Chengwen Feng wrote:
>> This patch adds 'dump_eth_priv [port_id]' which could used to dump
>> the specific ethdev port private info.
>>
> 
> We have already "show port ..." commands to display various port related
> information, what do you think to follow same syntax for port private info.
> 
> Something like "show port private_info <port_id>"
> 
> 
> Or it is possible to append this to the output of the existing port info
> ("show port info <port_id>"),
> as a new section of output if port has private info?
> 
> This can be an addition parameter to existing command but not sure if we
> need it, like:
> "show port info <port_id> private on"
> 
> I think displaying private info as port of port info without additional
> parameter is OK, it is simpler.

+1 for this, will send a new patch.

Thanks.

> 
> 

...
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 6fa870dc32..3ac7e78aff 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -8439,6 +8439,48 @@  static cmdline_parse_inst_t cmd_dump_one = {
 	},
 };
 
+/* ******************************************************************************** */
+
+struct cmd_dump_eth_priv_result {
+	cmdline_fixed_string_t dump;
+	portid_t port_id;
+};
+
+static cmdline_parse_token_string_t cmd_dump_eth_priv_dump =
+	TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
+				 "dump_eth_priv");
+static cmdline_parse_token_num_t cmd_dump_eth_priv_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_dump_eth_priv_result,
+			      port_id, RTE_UINT16);
+
+static void cmd_dump_eth_priv_parsed(void *parsed_result, struct cmdline *cl,
+				     __rte_unused void *data)
+{
+	struct cmd_dump_eth_priv_result *res = parsed_result;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->port_id)) {
+		cmdline_printf(cl, "Invalid port id %u\n", res->port_id);
+		return;
+	}
+
+	ret = rte_eth_dev_priv_dump(res->port_id, stdout);
+	if (ret < 0)
+		cmdline_printf(cl, "Failed to dump port id %u private info with error (%d): %s\n",
+			       res->port_id, ret, strerror(-ret));
+}
+
+static cmdline_parse_inst_t cmd_dump_eth_priv = {
+	.f = cmd_dump_eth_priv_parsed,  /* function to call */
+	.data = NULL,      /* 2nd arg of func */
+	.help_str = "dump_eth_priv <port_id>: Dump one ethdev port private info",
+	.tokens = {        /* token list, NULL terminated */
+		(void *)&cmd_dump_eth_priv_dump,
+		(void *)&cmd_dump_eth_priv_port_id,
+		NULL,
+	},
+};
+
 /* *** Filters Control *** */
 
 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
@@ -12854,6 +12896,7 @@  static cmdline_parse_ctx_t builtin_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
 	(cmdline_parse_inst_t *)&cmd_dump,
 	(cmdline_parse_inst_t *)&cmd_dump_one,
+	(cmdline_parse_inst_t *)&cmd_dump_eth_priv,
 	(cmdline_parse_inst_t *)&cmd_flow,
 	(cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
 	(cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 8f23847859..211f41f86d 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -605,6 +605,13 @@  Dumps the log level for all the dpdk modules::
 
    testpmd> dump_log_types
 
+dump ethdev private
+~~~~~~~~~~~~~~~~~~~
+
+Dumps the specific ethdev port private info::
+
+   testpmd> dump_eth_priv [port_id]
+
 show (raw_encap|raw_decap)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~