DPDK patches and discussions
 help / color / mirror / Atom feed
From: <skoteshwar@marvell.com>
To: Aman Singh <aman.deep.singh@intel.com>,
	Yuying Zhang <yuying.zhang@intel.com>
Cc: <dev@dpdk.org>, <ferruh.yigit@amd.com>, <jerinj@marvell.com>,
	Satha Rao <skoteshwar@marvell.com>
Subject: [PATCH v2] app/testpmd: command to get descriptor used count
Date: Thu, 1 Feb 2024 08:52:42 -0500	[thread overview]
Message-ID: <1706795562-7099-1-git-send-email-skoteshwar@marvell.com> (raw)
In-Reply-To: <1706098726-27359-1-git-send-email-skoteshwar@marvell.com>

From: Satha Rao <skoteshwar@marvell.com>

Existing Rx desc used count command extended to get Tx queue
used count.
    testpmd> show port 0 rxq 0 desc used count
    testpmd> show port 0 txq 0 desc used count

Signed-off-by: Satha Rao <skoteshwar@marvell.com>
---
Depends-on: series-30833 ("ethdev: support Tx queue used count")

v2:
 extended rx_queue_desc_used_count command to support Tx
 updated testpmd_app_ug with new command

 app/test-pmd/cmdline.c                      | 184 +++++++++++---------
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  10 +-
 2 files changed, 104 insertions(+), 90 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f704319771..c8c88f3236 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -12638,6 +12638,104 @@ static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
 	},
 };
 
+/* *** display rx/tx queue descriptor used count *** */
+struct cmd_show_rx_tx_queue_desc_used_count_result {
+	cmdline_fixed_string_t cmd_show;
+	cmdline_fixed_string_t cmd_port;
+	cmdline_fixed_string_t cmd_dir;
+	cmdline_fixed_string_t cmd_desc;
+	cmdline_fixed_string_t cmd_used;
+	cmdline_fixed_string_t cmd_count;
+	portid_t cmd_pid;
+	portid_t cmd_qid;
+};
+
+static void
+cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
+					    __rte_unused void *data)
+{
+	struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
+	int rc;
+
+	if (!strcmp(res->cmd_dir, "rxq")) {
+		if (rte_eth_rx_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_rx_queue_count(res->cmd_pid, res->cmd_qid);
+		if (rc < 0) {
+			fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
+			return;
+		}
+		printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
+	} else if (!strcmp(res->cmd_dir, "txq")) {
+		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_rx_tx_queue_desc_used_count_show =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_rx_tx_queue_desc_used_count_result,
+		 cmd_show, "show");
+static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_rx_tx_queue_desc_used_count_result,
+		 cmd_port, "port");
+static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_show_rx_tx_queue_desc_used_count_result,
+		 cmd_pid, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_rx_tx_queue_desc_used_count_result,
+		 cmd_dir, "rxq#txq");
+static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_show_rx_tx_queue_desc_used_count_result,
+		 cmd_qid, RTE_UINT16);
+static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_rx_tx_queue_desc_used_count_result,
+		 cmd_desc, "desc");
+static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_rx_tx_queue_desc_used_count_result,
+		 cmd_count, "used");
+static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_rx_tx_queue_desc_used_count_result,
+		 cmd_count, "count");
+static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
+	.f = cmd_show_rx_tx_queue_desc_used_count_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
+	.tokens = {
+		(void *)&cmd_show_rx_tx_queue_desc_used_count_show,
+		(void *)&cmd_show_rx_tx_queue_desc_used_count_port,
+		(void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
+		(void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
+		(void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
+		(void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
+		(void *)&cmd_show_rx_tx_queue_desc_used_count_used,
+		(void *)&cmd_show_rx_tx_queue_desc_used_count_count,
+		NULL,
+	},
+};
+
 /* *** display rx/tx descriptor status *** */
 struct cmd_show_rx_tx_desc_status_result {
 	cmdline_fixed_string_t cmd_show;
@@ -12745,90 +12843,6 @@ static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
 	},
 };
 
-/* *** display rx queue desc used count *** */
-struct cmd_show_rx_queue_desc_used_count_result {
-	cmdline_fixed_string_t cmd_show;
-	cmdline_fixed_string_t cmd_port;
-	cmdline_fixed_string_t cmd_rxq;
-	cmdline_fixed_string_t cmd_desc;
-	cmdline_fixed_string_t cmd_used;
-	cmdline_fixed_string_t cmd_count;
-	portid_t cmd_pid;
-	portid_t cmd_qid;
-};
-
-static void
-cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
-		__rte_unused struct cmdline *cl,
-		__rte_unused void *data)
-{
-	struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
-	int rc;
-
-	if (rte_eth_rx_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_rx_queue_count(res->cmd_pid, res->cmd_qid);
-	if (rc < 0) {
-		fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
-		return;
-	}
-	printf("Used desc count = %d\n", rc);
-}
-
-static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
-	TOKEN_STRING_INITIALIZER
-		(struct cmd_show_rx_queue_desc_used_count_result,
-		 cmd_show, "show");
-static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
-	TOKEN_STRING_INITIALIZER
-		(struct cmd_show_rx_queue_desc_used_count_result,
-		 cmd_port, "port");
-static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
-	TOKEN_NUM_INITIALIZER
-		(struct cmd_show_rx_queue_desc_used_count_result,
-		 cmd_pid, RTE_UINT16);
-static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
-	TOKEN_STRING_INITIALIZER
-		(struct cmd_show_rx_queue_desc_used_count_result,
-		 cmd_rxq, "rxq");
-static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
-	TOKEN_NUM_INITIALIZER
-		(struct cmd_show_rx_queue_desc_used_count_result,
-		 cmd_qid, RTE_UINT16);
-static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
-	TOKEN_STRING_INITIALIZER
-		(struct cmd_show_rx_queue_desc_used_count_result,
-		 cmd_count, "desc");
-static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
-	TOKEN_STRING_INITIALIZER
-		(struct cmd_show_rx_queue_desc_used_count_result,
-		 cmd_count, "used");
-static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
-	TOKEN_STRING_INITIALIZER
-		(struct cmd_show_rx_queue_desc_used_count_result,
-		 cmd_count, "count");
-static cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
-	.f = cmd_show_rx_queue_desc_used_count_parsed,
-	.data = NULL,
-	.help_str = "show port <port_id> rxq <queue_id> desc used count",
-	.tokens = {
-		(void *)&cmd_show_rx_queue_desc_used_count_show,
-		(void *)&cmd_show_rx_queue_desc_used_count_port,
-		(void *)&cmd_show_rx_queue_desc_used_count_pid,
-		(void *)&cmd_show_rx_queue_desc_used_count_rxq,
-		(void *)&cmd_show_rx_queue_desc_used_count_qid,
-		(void *)&cmd_show_rx_queue_desc_used_count_desc,
-		(void *)&cmd_show_rx_queue_desc_used_count_used,
-		(void *)&cmd_show_rx_queue_desc_used_count_count,
-		NULL,
-	},
-};
-
 /* Common result structure for set port ptypes */
 struct cmd_set_port_ptypes_result {
 	cmdline_fixed_string_t set;
@@ -13345,7 +13359,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
 	(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_rx_tx_queue_desc_used_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,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index ab18a80b30..6369ee337e 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -264,13 +264,13 @@ Display information for a given port's RX/TX descriptor status::
 
    testpmd> show port (port_id) (rxq|txq) (queue_id) desc (desc_id) status
 
-show rxq desc used count
-~~~~~~~~~~~~~~~~~~~~~~~~
+show desc used count(rxq|txq)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Display the number of receive packet descriptors currently filled by hardware
-and ready to be processed by the driver on a given RX queue::
+Display the number of packet descriptors currently used by hardware for a given
+port's RX/TX queue::
 
-   testpmd> show port (port_id) rxq (queue_id) desc used count
+   testpmd> show port (port_id) (rxq|txq) (queue_id) desc used count
 
 show config
 ~~~~~~~~~~~
-- 
2.25.1


  parent reply	other threads:[~2024-02-01 13:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 12:18 [PATCH] app/testpmd: add command to get Tx queue " skoteshwar
2024-01-25 13:01 ` fengchengwen
2024-01-29  6:37   ` [EXT] " Satha Koteswara Rao Kottidi
2024-01-29 11:55     ` Ferruh Yigit
2024-01-29 11:59       ` Satha Koteswara Rao Kottidi
2024-02-01 13:52 ` skoteshwar [this message]
2024-02-06 23:10   ` [PATCH v2] app/testpmd: command to get descriptor " Ferruh Yigit
2024-02-07 17:04   ` [PATCH v3] " skoteshwar
2024-02-07 18:30     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1706795562-7099-1-git-send-email-skoteshwar@marvell.com \
    --to=skoteshwar@marvell.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=jerinj@marvell.com \
    --cc=yuying.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).