DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: ferruh.yigit@amd.com,
	Bruce Richardson <bruce.richardson@intel.com>,
	Aman Singh <aman.deep.singh@intel.com>,
	Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Subject: [PATCH 3/3] app/testpmd: add support for querying TM nodes
Date: Tue,  8 Oct 2024 11:53:50 +0100	[thread overview]
Message-ID: <20241008105350.1396216-4-bruce.richardson@intel.com> (raw)
In-Reply-To: <20241008105350.1396216-1-bruce.richardson@intel.com>

Support use of the rte_tm_node_query API to print out details about
previously added TM nodes in testpmd.

Example output, configuring three nodes, and then printing the details:

testpmd> add port tm nonleaf node 0 100 -1 0 1 0 -1 1 0 0
testpmd> add port tm nonleaf node 0 90 100 0 1 1 -1 1 0 0
testpmd> add port tm leaf node    0 0   90 0 1 2 -1 0 0xffffffff 0 0
testpmd>
testpmd> show port tm node 0 100
Port 0 TM Node 100
  Parent Node ID: <NULL>
  Level ID: 0
  Priority: 0
  Weight: 0
  Shaper Profile ID: <none>
  Shared Shaper IDs: <none>
  Stats Mask: 0
  Nonleaf Node Parameters
    Num Strict Priorities: 1
    WFQ Weights Mode: WFQ
testpmd> show port tm node 0 90
Port 0 TM Node 90
  Parent Node ID: 100
  Level ID: 1
  Priority: 0
  Weight: 1
  Shaper Profile ID: <none>
  Shared Shaper IDs: <none>
  Stats Mask: 0
  Nonleaf Node Parameters
    Num Strict Priorities: 1
    WFQ Weights Mode: WFQ
testpmd> show port tm node 0 0
Port 0 TM Node 0
  Parent Node ID: 90
  Level ID: 2
  Priority: 0
  Weight: 1
  Shaper Profile ID: <none>
  Shared Shaper IDs: <none>
  Stats Mask: 0
  Leaf Node Parameters
    CMAN Mode: Tail Drop
    WRED Profile ID: <none>
    Shared WRED Context Ids: <none>

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/test-pmd/cmdline.c    |   1 +
 app/test-pmd/cmdline_tm.c | 131 ++++++++++++++++++++++++++++++++++++++
 app/test-pmd/cmdline_tm.h |   1 +
 3 files changed, 133 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b7759e38a8..2fbadf1a4d 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -13327,6 +13327,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_set_port_ptypes,
 	(cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
 	(cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
+	(cmdline_parse_inst_t *)&cmd_show_port_tm_node,
 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
 	(cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c
index 6ce074f538..287ae7a489 100644
--- a/app/test-pmd/cmdline_tm.c
+++ b/app/test-pmd/cmdline_tm.c
@@ -2057,6 +2057,137 @@ cmdline_parse_inst_t cmd_add_port_tm_leaf_node = {
 	},
 };
 
+struct cmd_show_port_tm_node_result {
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t tm;
+	cmdline_fixed_string_t node;
+	uint16_t port_id;
+	uint32_t node_id;
+};
+
+static cmdline_parse_token_string_t cmd_show_port_tm_node_show_tok =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, show, "show");
+static cmdline_parse_token_string_t cmd_show_port_tm_node_port_tok =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, port, "port");
+static cmdline_parse_token_string_t cmd_show_port_tm_node_tm_tok =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, tm, "tm");
+static cmdline_parse_token_string_t cmd_show_port_tm_node_node_tok =
+	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, node, "node");
+static cmdline_parse_token_num_t cmd_show_port_tm_node_port_id_tok =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_result, port_id, RTE_UINT16);
+static cmdline_parse_token_num_t cmd_show_port_tm_node_node_id_tok =
+	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_result, node_id, RTE_UINT32);
+
+static void
+cmd_show_port_tm_node_parsed(void *parsed_result, struct cmdline *cl, void *data __rte_unused)
+{
+	const struct cmd_show_port_tm_node_result *res = parsed_result;
+	const portid_t port_id = res->port_id;
+	const uint32_t node_id = res->node_id;
+	struct rte_tm_node_params params = {0};
+	struct rte_tm_error error = {0};
+	uint32_t parent_id, priority, weight, level_id;
+	int is_leaf;
+	int ret;
+
+	if (port_id_is_invalid(port_id, ENABLED_WARN))
+		return;
+
+	ret = rte_tm_node_query(port_id, node_id,
+			&parent_id, &priority, &weight, &level_id, &params, &error);
+	if (ret != 0) {
+		print_err_msg(&error);
+		return;
+	}
+
+	ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
+	if (ret != 0) {
+		print_err_msg(&error);
+		return;
+	}
+
+	cmdline_printf(cl, "Port %u TM Node %u\n", port_id, node_id);
+	if (parent_id == RTE_TM_NODE_ID_NULL)
+		cmdline_printf(cl, "  Parent Node ID: <NULL>\n");
+	else
+		cmdline_printf(cl, "  Parent Node ID: %d\n", parent_id);
+	cmdline_printf(cl, "  Level ID: %u\n", level_id);
+	cmdline_printf(cl, "  Priority: %u\n", priority);
+	cmdline_printf(cl, "  Weight: %u\n", weight);
+	if (params.shaper_profile_id == RTE_TM_SHAPER_PROFILE_ID_NONE)
+		cmdline_printf(cl, "  Shaper Profile ID: <none>\n");
+	else
+		cmdline_printf(cl, "  Shaper Profile ID: %d\n", params.shaper_profile_id);
+	cmdline_printf(cl, "  Shared Shaper IDs: ");
+	if (params.n_shared_shapers == 0)
+		cmdline_printf(cl, "<none>\n");
+	else {
+		for (uint32_t i = 0; i < params.n_shared_shapers; i++)
+			cmdline_printf(cl, "%u ", params.shared_shaper_id[i]);
+		cmdline_printf(cl, "\n");
+	}
+	cmdline_printf(cl, "  Stats Mask: %"PRIu64"\n", params.stats_mask);
+	if (is_leaf) {
+		cmdline_printf(cl, "  Leaf Node Parameters\n");
+		switch (params.leaf.cman) {
+		case RTE_TM_CMAN_TAIL_DROP:
+			cmdline_printf(cl, "    CMAN Mode: Tail Drop\n");
+			break;
+		case RTE_TM_CMAN_HEAD_DROP:
+			cmdline_printf(cl, "    CMAN Mode: Head Drop\n");
+			break;
+		case RTE_TM_CMAN_WRED:
+			cmdline_printf(cl, "    CMAN Mode: WRED\n");
+			break;
+		}
+		if (params.leaf.wred.wred_profile_id == RTE_TM_WRED_PROFILE_ID_NONE)
+			cmdline_printf(cl, "    WRED Profile ID: <none>\n");
+		else
+			cmdline_printf(cl, "    WRED Profile ID: %u\n",
+					params.leaf.wred.wred_profile_id);
+		cmdline_printf(cl, "    Shared WRED Context Ids: ");
+		if (params.leaf.wred.n_shared_wred_contexts == 0)
+			cmdline_printf(cl, "<none>\n");
+		else {
+			for (uint32_t i = 0; i < params.leaf.wred.n_shared_wred_contexts; i++)
+				cmdline_printf(cl, "%u ",
+						params.leaf.wred.shared_wred_context_id[i]);
+			cmdline_printf(cl, "\n");
+		}
+	} else {
+		cmdline_printf(cl, "  Nonleaf Node Parameters\n");
+		cmdline_printf(cl, "    Num Strict Priorities: %u\n",
+				params.nonleaf.n_sp_priorities);
+		cmdline_printf(cl, "    WFQ Weights Mode: ");
+		if (params.nonleaf.wfq_weight_mode == NULL)
+			cmdline_printf(cl, "WFQ\n");
+		else {
+			for (uint32_t i = 0; i < params.nonleaf.n_sp_priorities; i++)
+				cmdline_printf(cl, "%s(%d) ",
+					params.nonleaf.wfq_weight_mode[i] ? "Bytes" : "Packet",
+					params.nonleaf.wfq_weight_mode[i]);
+			cmdline_printf(cl, "\n");
+		}
+	}
+}
+
+
+cmdline_parse_inst_t cmd_show_port_tm_node = {
+	.f = cmd_show_port_tm_node_parsed,
+	.data = NULL,
+	.help_str = "",
+	.tokens = {
+		(void *)&cmd_show_port_tm_node_show_tok,
+		(void *)&cmd_show_port_tm_node_port_tok,
+		(void *)&cmd_show_port_tm_node_tm_tok,
+		(void *)&cmd_show_port_tm_node_node_tok,
+		(void *)&cmd_show_port_tm_node_port_id_tok,
+		(void *)&cmd_show_port_tm_node_node_id_tok,
+		NULL,
+	}
+};
+
 /* *** Delete Port TM Node *** */
 struct cmd_del_port_tm_node_result {
 	cmdline_fixed_string_t del;
diff --git a/app/test-pmd/cmdline_tm.h b/app/test-pmd/cmdline_tm.h
index e59c15c3cc..4ae5fd072f 100644
--- a/app/test-pmd/cmdline_tm.h
+++ b/app/test-pmd/cmdline_tm.h
@@ -9,6 +9,7 @@
 extern cmdline_parse_inst_t cmd_show_port_tm_cap;
 extern cmdline_parse_inst_t cmd_show_port_tm_level_cap;
 extern cmdline_parse_inst_t cmd_show_port_tm_node_cap;
+extern cmdline_parse_inst_t cmd_show_port_tm_node;
 extern cmdline_parse_inst_t cmd_show_port_tm_node_type;
 extern cmdline_parse_inst_t cmd_show_port_tm_node_stats;
 extern cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile;
-- 
2.43.0


  parent reply	other threads:[~2024-10-08 10:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08 10:53 [PATCH 0/3] add support for querying ethdev " Bruce Richardson
2024-10-08 10:53 ` [PATCH 1/3] ethdev: add traffic manager query function Bruce Richardson
2024-10-08 10:53 ` [PATCH 2/3] net/ice: add traffic management node " Bruce Richardson
2024-10-08 10:53 ` Bruce Richardson [this message]
2024-10-08 14:43 ` [PATCH v2 0/3] add support for querying ethdev TM nodes Bruce Richardson
2024-10-08 14:43   ` [PATCH v2 1/3] ethdev: add traffic manager query function Bruce Richardson
2024-10-09  0:57     ` fengchengwen
2024-10-09  8:07       ` Bruce Richardson
2024-10-09  9:38         ` fengchengwen
2024-10-08 14:43   ` [PATCH v2 2/3] net/ice: add traffic management node " Bruce Richardson
2024-10-08 14:43   ` [PATCH v2 3/3] app/testpmd: add support for querying TM nodes Bruce Richardson
2024-10-09  1:02     ` fengchengwen
2024-10-09 10:32       ` Bruce Richardson
2024-10-09 10:32 ` [PATCH v3 0/3] add support for querying ethdev " Bruce Richardson
2024-10-09 10:32   ` [PATCH v3 1/3] ethdev: add traffic manager query function Bruce Richardson
2024-10-10  2:05     ` Ferruh Yigit
2024-10-12  0:28     ` Ferruh Yigit
2024-10-09 10:32   ` [PATCH v3 2/3] net/ice: add traffic management node " Bruce Richardson
2024-10-09 10:32   ` [PATCH v3 3/3] app/testpmd: add support for querying TM nodes Bruce Richardson
2024-10-12  0:33   ` [PATCH v3 0/3] add support for querying ethdev " 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=20241008105350.1396216-4-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=aman.deep.singh@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.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).