app/testpmd: add command to get Tx queue used count

Message ID 1706098726-27359-1-git-send-email-skoteshwar@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: add command to get Tx queue used count |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build fail github build: failed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-compile-amd64-testing fail Testing issues
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Satha Koteswara Rao Kottidi Jan. 24, 2024, 12:18 p.m. UTC
  From: Satha Rao <skoteshwar@marvell.com>

Fastpath API to get txq used count.

   testpmd> show port 0 txq 0 desc count

Signed-off-by: Satha Rao <skoteshwar@marvell.com>
---
 app/test-pmd/cmdline.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
  

Comments

fengchengwen Jan. 25, 2024, 1:01 p.m. UTC | #1
Please doc this command in doc/guides/testpmd_app_ug/testpmd_funcs.rst
Also why not extend "show port rxq xxx" command to support txq ?

On 2024/1/24 20:18, skoteshwar@marvell.com wrote:
> From: Satha Rao <skoteshwar@marvell.com>
> 
> Fastpath API to get txq used count.
> 
>    testpmd> show port 0 txq 0 desc count
> 
> Signed-off-by: Satha Rao <skoteshwar@marvell.com>
> ---
>  app/test-pmd/cmdline.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 78 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index f704319..1d09633 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -12638,6 +12638,83 @@ struct cmd_show_port_supported_ptypes_result {
>  	},
>  };
>  
> +/* *** display tx queue desc used count *** */
> +struct cmd_show_tx_queue_desc_count_result {
> +	cmdline_fixed_string_t cmd_show;
> +	cmdline_fixed_string_t cmd_port;
> +	cmdline_fixed_string_t cmd_txq;
> +	cmdline_fixed_string_t cmd_desc;
> +	cmdline_fixed_string_t cmd_count;
> +	portid_t cmd_pid;
> +	portid_t cmd_qid;
> +};
> +
> +static void
> +cmd_show_tx_queue_desc_count_parsed(void *parsed_result,
> +		__rte_unused struct cmdline *cl,
> +		__rte_unused void *data)
> +{
> +	struct cmd_show_tx_queue_desc_count_result *res = parsed_result;
> +	int rc;
> +
> +	if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
> +		fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",	res->cmd_pid,
> +			res->cmd_qid);
> +		return;
> +	}
> +
> +	rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
> +	if (rc < 0) {
> +		fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc, res->cmd_qid);
> +		return;
> +	}
> +	printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
> +}
> +
> +static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_show =
> +	TOKEN_STRING_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_show, "show");
> +static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_port =
> +	TOKEN_STRING_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_port, "port");
> +static cmdline_parse_token_num_t cmd_show_tx_queue_desc_count_pid =
> +	TOKEN_NUM_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_pid, RTE_UINT16);
> +static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_txq =
> +	TOKEN_STRING_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_txq, "txq");
> +static cmdline_parse_token_num_t cmd_show_tx_queue_desc_count_qid =
> +	TOKEN_NUM_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_qid, RTE_UINT16);
> +static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_desc =
> +	TOKEN_STRING_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_desc, "desc");
> +static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_count =
> +	TOKEN_STRING_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_count, "count");
> +static cmdline_parse_inst_t cmd_show_tx_queue_desc_count = {
> +	.f = cmd_show_tx_queue_desc_count_parsed,
> +	.data = NULL,
> +	.help_str = "show port <port_id> txq <queue_id> desc count",
> +	.tokens = {
> +		(void *)&cmd_show_tx_queue_desc_count_show,
> +		(void *)&cmd_show_tx_queue_desc_count_port,
> +		(void *)&cmd_show_tx_queue_desc_count_pid,
> +		(void *)&cmd_show_tx_queue_desc_count_txq,
> +		(void *)&cmd_show_tx_queue_desc_count_qid,
> +		(void *)&cmd_show_tx_queue_desc_count_desc,
> +		(void *)&cmd_show_tx_queue_desc_count_count,
> +		NULL,
> +	},
> +};
> +
>  /* *** display rx/tx descriptor status *** */
>  struct cmd_show_rx_tx_desc_status_result {
>  	cmdline_fixed_string_t cmd_show;
> @@ -13346,6 +13423,7 @@ struct cmd_config_tx_affinity_map {
>  	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
>  	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
>  	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
> +	(cmdline_parse_inst_t *)&cmd_show_tx_queue_desc_count,
>  	(cmdline_parse_inst_t *)&cmd_set_raw,
>  	(cmdline_parse_inst_t *)&cmd_show_set_raw,
>  	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
>
  
Satha Koteswara Rao Kottidi Jan. 29, 2024, 6:37 a.m. UTC | #2
----------------------------------------------------------------------
Please doc this command in doc/guides/testpmd_app_ug/testpmd_funcs.rst

>> Thanks, will update in next version

Also why not extend "show port rxq xxx" command to support txq ?

>> txq and rxq are different directions, so  extended "show port " command to support txq similar to rxq command. Could you please give more details if I missed something here.

Thanks,
Satha

On 2024/1/24 20:18, skoteshwar@marvell.com wrote:
> From: Satha Rao <skoteshwar@marvell.com>
> 
> Fastpath API to get txq used count.
> 
>    testpmd> show port 0 txq 0 desc count
> 
> Signed-off-by: Satha Rao <skoteshwar@marvell.com>
> ---
>  app/test-pmd/cmdline.c | 78 
> ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 78 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 
> f704319..1d09633 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -12638,6 +12638,83 @@ struct cmd_show_port_supported_ptypes_result {
>  	},
>  };
>  
> +/* *** display tx queue desc used count *** */ struct 
> +cmd_show_tx_queue_desc_count_result {
> +	cmdline_fixed_string_t cmd_show;
> +	cmdline_fixed_string_t cmd_port;
> +	cmdline_fixed_string_t cmd_txq;
> +	cmdline_fixed_string_t cmd_desc;
> +	cmdline_fixed_string_t cmd_count;
> +	portid_t cmd_pid;
> +	portid_t cmd_qid;
> +};
> +
> +static void
> +cmd_show_tx_queue_desc_count_parsed(void *parsed_result,
> +		__rte_unused struct cmdline *cl,
> +		__rte_unused void *data)
> +{
> +	struct cmd_show_tx_queue_desc_count_result *res = parsed_result;
> +	int rc;
> +
> +	if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
> +		fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",	res->cmd_pid,
> +			res->cmd_qid);
> +		return;
> +	}
> +
> +	rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
> +	if (rc < 0) {
> +		fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc, res->cmd_qid);
> +		return;
> +	}
> +	printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc); }
> +
> +static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_show =
> +	TOKEN_STRING_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_show, "show");
> +static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_port =
> +	TOKEN_STRING_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_port, "port");
> +static cmdline_parse_token_num_t cmd_show_tx_queue_desc_count_pid =
> +	TOKEN_NUM_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_pid, RTE_UINT16);
> +static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_txq =
> +	TOKEN_STRING_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_txq, "txq");
> +static cmdline_parse_token_num_t cmd_show_tx_queue_desc_count_qid =
> +	TOKEN_NUM_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_qid, RTE_UINT16);
> +static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_desc =
> +	TOKEN_STRING_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_desc, "desc");
> +static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_count =
> +	TOKEN_STRING_INITIALIZER
> +		(struct cmd_show_tx_queue_desc_count_result,
> +		 cmd_count, "count");
> +static cmdline_parse_inst_t cmd_show_tx_queue_desc_count = {
> +	.f = cmd_show_tx_queue_desc_count_parsed,
> +	.data = NULL,
> +	.help_str = "show port <port_id> txq <queue_id> desc count",
> +	.tokens = {
> +		(void *)&cmd_show_tx_queue_desc_count_show,
> +		(void *)&cmd_show_tx_queue_desc_count_port,
> +		(void *)&cmd_show_tx_queue_desc_count_pid,
> +		(void *)&cmd_show_tx_queue_desc_count_txq,
> +		(void *)&cmd_show_tx_queue_desc_count_qid,
> +		(void *)&cmd_show_tx_queue_desc_count_desc,
> +		(void *)&cmd_show_tx_queue_desc_count_count,
> +		NULL,
> +	},
> +};
> +
>  /* *** display rx/tx descriptor status *** */  struct 
> cmd_show_rx_tx_desc_status_result {
>  	cmdline_fixed_string_t cmd_show;
> @@ -13346,6 +13423,7 @@ struct cmd_config_tx_affinity_map {
>  	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
>  	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
>  	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
> +	(cmdline_parse_inst_t *)&cmd_show_tx_queue_desc_count,
>  	(cmdline_parse_inst_t *)&cmd_set_raw,
>  	(cmdline_parse_inst_t *)&cmd_show_set_raw,
>  	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,
>
  
Ferruh Yigit Jan. 29, 2024, 11:55 a.m. UTC | #3
On 1/29/2024 6:37 AM, Satha Koteswara Rao Kottidi wrote:
>> 
>> ----------------------------------------------------------------------
>> Please doc this command in doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> 
>
> Thanks, will update in next version
>
>> 
>> Also why not extend "show port rxq xxx" command to support txq ?
> 
> txq and rxq are different directions, so  extended "show port " command to support txq similar to rxq command. Could you please give more details if I missed something here.
> 

There is an existing "show port <port_id> rxq <queue_id> desc used
count" command, which is for Rx.

As you are adding support for Tx, instead of adding it as a new command,
existing 'cmd_show_rx_queue_desc_used_count_parsed()' can be extended to
support both Rx and Tx.
You can check 'cmd_show_rx_tx_desc_status_parsed()' as sample.

This also helps to have a unified syntax for Rx and Tx, as your version
is slightly diverging from the Rx one.


And please update 'cmd_help_long_parsed()' help string with relevant change.
  
Satha Koteswara Rao Kottidi Jan. 29, 2024, 11:59 a.m. UTC | #4
>> 
>> ---------------------------------------------------------------------
>> - Please doc this command in 
>> doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> 
>
> Thanks, will update in next version
>
>> 
>> Also why not extend "show port rxq xxx" command to support txq ?
> 
> txq and rxq are different directions, so  extended "show port " command to support txq similar to rxq command. Could you please give more details if I missed something here.
> 

There is an existing "show port <port_id> rxq <queue_id> desc used count" command, which is for Rx.

As you are adding support for Tx, instead of adding it as a new command, existing 'cmd_show_rx_queue_desc_used_count_parsed()' can be extended to support both Rx and Tx.
You can check 'cmd_show_rx_tx_desc_status_parsed()' as sample.

This also helps to have a unified syntax for Rx and Tx, as your version is slightly diverging from the Rx one.


And please update 'cmd_help_long_parsed()' help string with relevant change.

>>> Thanks Ferruh, will update unified command for Rx/Tx in next version.
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f704319..1d09633 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -12638,6 +12638,83 @@  struct cmd_show_port_supported_ptypes_result {
 	},
 };
 
+/* *** display tx queue desc used count *** */
+struct cmd_show_tx_queue_desc_count_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_txq;
+	cmdline_fixed_string_t cmd_desc;
+	cmdline_fixed_string_t cmd_count;
+	portid_t cmd_pid;
+	portid_t cmd_qid;
+};
+
+static void
+cmd_show_tx_queue_desc_count_parsed(void *parsed_result,
+		__rte_unused struct cmdline *cl,
+		__rte_unused void *data)
+{
+	struct cmd_show_tx_queue_desc_count_result *res = parsed_result;
+	int rc;
+
+	if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
+		fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",	res->cmd_pid,
+			res->cmd_qid);
+		return;
+	}
+
+	rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
+	if (rc < 0) {
+		fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc, res->cmd_qid);
+		return;
+	}
+	printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
+}
+
+static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_show =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_tx_queue_desc_count_result,
+		 cmd_show, "show");
+static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_tx_queue_desc_count_result,
+		 cmd_port, "port");
+static cmdline_parse_token_num_t cmd_show_tx_queue_desc_count_pid =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_show_tx_queue_desc_count_result,
+		 cmd_pid, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_txq =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_tx_queue_desc_count_result,
+		 cmd_txq, "txq");
+static cmdline_parse_token_num_t cmd_show_tx_queue_desc_count_qid =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_show_tx_queue_desc_count_result,
+		 cmd_qid, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_desc =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_tx_queue_desc_count_result,
+		 cmd_desc, "desc");
+static cmdline_parse_token_string_t cmd_show_tx_queue_desc_count_count =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_tx_queue_desc_count_result,
+		 cmd_count, "count");
+static cmdline_parse_inst_t cmd_show_tx_queue_desc_count = {
+	.f = cmd_show_tx_queue_desc_count_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> txq <queue_id> desc count",
+	.tokens = {
+		(void *)&cmd_show_tx_queue_desc_count_show,
+		(void *)&cmd_show_tx_queue_desc_count_port,
+		(void *)&cmd_show_tx_queue_desc_count_pid,
+		(void *)&cmd_show_tx_queue_desc_count_txq,
+		(void *)&cmd_show_tx_queue_desc_count_qid,
+		(void *)&cmd_show_tx_queue_desc_count_desc,
+		(void *)&cmd_show_tx_queue_desc_count_count,
+		NULL,
+	},
+};
+
 /* *** display rx/tx descriptor status *** */
 struct cmd_show_rx_tx_desc_status_result {
 	cmdline_fixed_string_t cmd_show;
@@ -13346,6 +13423,7 @@  struct cmd_config_tx_affinity_map {
 	(cmdline_parse_inst_t *)&cmd_show_tx_metadata,
 	(cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
 	(cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
+	(cmdline_parse_inst_t *)&cmd_show_tx_queue_desc_count,
 	(cmdline_parse_inst_t *)&cmd_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw,
 	(cmdline_parse_inst_t *)&cmd_show_set_raw_all,