Skip to content

Commit 9415759

Browse files
bruce-richardsonferruhy
authored andcommitted
app/testpmd: display TM parameters when adding nodes
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 <[email protected]> Acked-by: Ferruh Yigit <[email protected]>
1 parent c243d09 commit 9415759

File tree

1 file changed

+57
-3
lines changed

1 file changed

+57
-3
lines changed

app/test-pmd/cmdline_tm.c

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,21 @@ static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_packet_mode
882882
struct cmd_add_port_tm_node_shaper_profile_result,
883883
pkt_mode, RTE_UINT32);
884884

885+
static int
886+
get_printable_rate(uint64_t rate, char *buffer, size_t size)
887+
{
888+
if (rate >= 1000 * 1000 * 1000)
889+
return snprintf(buffer, size, "%.1fG", rate / (1000 * 1000 * 1000.0));
890+
else if (rate >= 1000 * 1000)
891+
return snprintf(buffer, size, "%.1fM", rate / (1000 * 1000.0));
892+
else if (rate >= 1000)
893+
return snprintf(buffer, size, "%.1fK", rate / 1000.0);
894+
else
895+
return snprintf(buffer, size, "%"PRIu64, rate);
896+
}
897+
885898
static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
886-
__rte_unused struct cmdline *cl,
899+
struct cmdline *cl,
887900
__rte_unused void *data)
888901
{
889902
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,
892905
uint32_t shaper_id = res->shaper_id;
893906
uint32_t pkt_len_adjust = res->pktlen_adjust;
894907
portid_t port_id = res->port_id;
908+
char rate_str[20];
895909
int ret;
896910

911+
cmdline_printf(cl, "adding node shaper on port %u, with id %u\n", res->port_id, shaper_id);
912+
get_printable_rate(res->cmit_tb_rate, rate_str, sizeof(rate_str));
913+
cmdline_printf(cl, "# committed rate: %s, t.b. size: %"PRIu64"\n",
914+
rate_str, res->cmit_tb_size);
915+
916+
get_printable_rate(res->peak_tb_rate, rate_str, sizeof(rate_str));
917+
cmdline_printf(cl, "# peak rate: %s, t.b. size: %"PRIu64"\n",
918+
rate_str, res->peak_tb_size);
919+
cmdline_printf(cl, "# pkt length adjust: %u\n", res->pktlen_adjust);
920+
cmdline_printf(cl, "# packet mode: %s\n", res->pkt_mode ? "true" : "false (bytes mode)");
921+
897922
if (port_id_is_invalid(port_id, ENABLED_WARN))
898923
return;
899924

@@ -1635,7 +1660,7 @@ static cmdline_parse_token_string_t
16351660
multi_shared_shaper_id, TOKEN_STRING_MULTI);
16361661

16371662
static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
1638-
__rte_unused struct cmdline *cl,
1663+
struct cmdline *cl,
16391664
__rte_unused void *data)
16401665
{
16411666
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,
16591684
else
16601685
parent_node_id = res->parent_node_id;
16611686

1687+
if (parent_node_id != UINT32_MAX)
1688+
cmdline_printf(cl, "adding node on port %u, with id %u and parent node %u\n",
1689+
port_id, res->node_id, parent_node_id);
1690+
else
1691+
cmdline_printf(cl, "adding node on port %u, with id %u as root node\n",
1692+
port_id, res->node_id);
1693+
cmdline_printf(cl, "# priority: %u\n", res->priority);
1694+
cmdline_printf(cl, "# weight: %u\n", res->weight);
1695+
cmdline_printf(cl, "# level_id: %u\n", res->level_id);
1696+
cmdline_printf(cl, "# shaper_profile_id: %d\n", res->shaper_profile_id);
1697+
cmdline_printf(cl, "# num SP priorities: %u\n", res->n_sp_priorities);
1698+
cmdline_printf(cl, "# stats_mask: %"PRIx64"\n", res->stats_mask);
1699+
cmdline_printf(cl, "# shared shapers: '%s'\n", s_str);
1700+
16621701
shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
16631702
sizeof(uint32_t));
16641703
if (shared_shaper_id == NULL) {
@@ -1964,7 +2003,7 @@ static cmdline_parse_token_string_t
19642003
multi_shared_shaper_id, TOKEN_STRING_MULTI);
19652004

19662005
static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
1967-
__rte_unused struct cmdline *cl,
2006+
struct cmdline *cl,
19682007
__rte_unused void *data)
19692008
{
19702009
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,
19882027
else
19892028
parent_node_id = res->parent_node_id;
19902029

2030+
if (parent_node_id != UINT32_MAX)
2031+
cmdline_printf(cl, "adding leaf node on port %u, with id %u and parent node %u\n",
2032+
port_id, res->node_id, parent_node_id);
2033+
else
2034+
cmdline_printf(cl, "adding leaf node on port %u, with id %u as root node\n",
2035+
port_id, res->node_id);
2036+
cmdline_printf(cl, "# priority: %u\n", res->priority);
2037+
cmdline_printf(cl, "# weight: %u\n", res->weight);
2038+
cmdline_printf(cl, "# level_id: %u\n", res->level_id);
2039+
cmdline_printf(cl, "# shaper_profile_id: %d\n", res->shaper_profile_id);
2040+
cmdline_printf(cl, "# cman_mode: %u\n", res->cman_mode);
2041+
cmdline_printf(cl, "# wred_profile_id: %d\n", res->wred_profile_id);
2042+
cmdline_printf(cl, "# stats_mask: %"PRIx64"\n", res->stats_mask);
2043+
cmdline_printf(cl, "# shared shapers: '%s'\n", s_str);
2044+
19912045
shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
19922046
sizeof(uint32_t));
19932047
if (shared_shaper_id == NULL) {

0 commit comments

Comments
 (0)