DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
	Cristian Dumitrescu <cristian.dumitrescu@intel.com>,
	Aman Singh <aman.deep.singh@intel.com>
Subject: [RFC PATCH] app/testpmd: display TM parameters when adding nodes
Date: Mon, 12 Aug 2024 14:26:43 +0100	[thread overview]
Message-ID: <20240812132643.160567-2-bruce.richardson@intel.com> (raw)

The commands to add TM nodes and shapers take many parameters without
any descriptive words in between to identify what parameter is what. To
help make it clear what a command is actually doing, and to help catch
any issues with parameters put in the wrong order, print out the
parameters for each command after it is entered.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test-pmd/cmdline_tm.c | 60 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c
index 6ce074f538..aa917edb6c 100644
--- a/app/test-pmd/cmdline_tm.c
+++ b/app/test-pmd/cmdline_tm.c
@@ -882,8 +882,21 @@ static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_packet_mode
 		struct cmd_add_port_tm_node_shaper_profile_result,
 			pkt_mode, RTE_UINT32);
 
+static int
+get_printable_rate(uint64_t rate, char *buffer, size_t size)
+{
+	if (rate >= 1000 * 1000 * 1000)
+		return snprintf(buffer, size, "%.1fG", rate / (1000 * 1000 * 1000.0));
+	else if (rate >= 1000 * 1000)
+		return snprintf(buffer, size, "%.1fM", rate / (1000 * 1000.0));
+	else if (rate >= 1000)
+		return snprintf(buffer, size, "%.1fK", rate / 1000.0);
+	else
+		return snprintf(buffer, size, "%"PRIu64, rate);
+}
+
 static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
-	__rte_unused struct cmdline *cl,
+	struct cmdline *cl,
 	__rte_unused void *data)
 {
 	struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result;
@@ -892,8 +905,20 @@ static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
 	uint32_t shaper_id = res->shaper_id;
 	uint32_t pkt_len_adjust = res->pktlen_adjust;
 	portid_t port_id = res->port_id;
+	char rate_str[20];
 	int ret;
 
+	cmdline_printf(cl, "adding node shaper on port %u, with id %u\n", res->port_id, shaper_id);
+	get_printable_rate(res->cmit_tb_rate, rate_str, sizeof(rate_str));
+	cmdline_printf(cl, "# committed rate: %s, t.b. size: %"PRIu64"\n",
+			rate_str, res->cmit_tb_size);
+
+	get_printable_rate(res->peak_tb_rate, rate_str, sizeof(rate_str));
+	cmdline_printf(cl, "# peak rate: %s, t.b. size: %"PRIu64"\n",
+			rate_str, res->peak_tb_size);
+	cmdline_printf(cl, "# pkt length adjust: %u\n", res->pktlen_adjust);
+	cmdline_printf(cl, "# packet mode: %s\n", res->pkt_mode ? "true" : "false (bytes mode)");
+
 	if (port_id_is_invalid(port_id, ENABLED_WARN))
 		return;
 
@@ -1635,7 +1660,7 @@ static cmdline_parse_token_string_t
 		 multi_shared_shaper_id, TOKEN_STRING_MULTI);
 
 static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
-	__rte_unused struct cmdline *cl,
+	struct cmdline *cl,
 	__rte_unused void *data)
 {
 	struct cmd_add_port_tm_nonleaf_node_result *res = parsed_result;
@@ -1659,6 +1684,20 @@ static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
 	else
 		parent_node_id = res->parent_node_id;
 
+	if (parent_node_id != UINT32_MAX)
+		cmdline_printf(cl, "adding node on port %u, with id %u and parent node %u\n",
+				port_id, res->node_id, parent_node_id);
+	else
+		cmdline_printf(cl, "adding node on port %u, with id %u as root node\n",
+				port_id, res->node_id);
+	cmdline_printf(cl, "# priority: %u\n", res->priority);
+	cmdline_printf(cl, "# weight: %u\n", res->weight);
+	cmdline_printf(cl, "# level_id: %u\n", res->level_id);
+	cmdline_printf(cl, "# shaper_profile_id: %d\n", res->shaper_profile_id);
+	cmdline_printf(cl, "# num SP priorities: %u\n", res->n_sp_priorities);
+	cmdline_printf(cl, "# stats_mask: %"PRIx64"\n", res->stats_mask);
+	cmdline_printf(cl, "# shared shapers: '%s'\n", s_str);
+
 	shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
 		sizeof(uint32_t));
 	if (shared_shaper_id == NULL) {
@@ -1964,7 +2003,7 @@ static cmdline_parse_token_string_t
 		 multi_shared_shaper_id, TOKEN_STRING_MULTI);
 
 static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
-	__rte_unused struct cmdline *cl,
+	struct cmdline *cl,
 	__rte_unused void *data)
 {
 	struct cmd_add_port_tm_leaf_node_result *res = parsed_result;
@@ -1988,6 +2027,21 @@ static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
 	else
 		parent_node_id = res->parent_node_id;
 
+	if (parent_node_id != UINT32_MAX)
+		cmdline_printf(cl, "adding leaf node on port %u, with id %u and parent node %u\n",
+				port_id, res->node_id, parent_node_id);
+	else
+		cmdline_printf(cl, "adding leaf node on port %u, with id %u as root node\n",
+				port_id, res->node_id);
+	cmdline_printf(cl, "# priority: %u\n", res->priority);
+	cmdline_printf(cl, "# weight: %u\n", res->weight);
+	cmdline_printf(cl, "# level_id: %u\n", res->level_id);
+	cmdline_printf(cl, "# shaper_profile_id: %d\n", res->shaper_profile_id);
+	cmdline_printf(cl, "# cman_mode: %u\n", res->cman_mode);
+	cmdline_printf(cl, "# wred_profile_id: %d\n", res->wred_profile_id);
+	cmdline_printf(cl, "# stats_mask: %"PRIx64"\n", res->stats_mask);
+	cmdline_printf(cl, "# shared shapers: '%s'\n", s_str);
+
 	shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
 		sizeof(uint32_t));
 	if (shared_shaper_id == NULL) {
-- 
2.43.0


                 reply	other threads:[~2024-08-12 13:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240812132643.160567-2-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=aman.deep.singh@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    /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).