LCOV - code coverage report
Current view: top level - app/test-pmd - cmdline_tm.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 602 0.0 %
Date: 2024-12-01 18:57:19 Functions: 0 28 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2017 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <ctype.h>
       6                 :            : #include <stdlib.h>
       7                 :            : 
       8                 :            : #include <cmdline_parse.h>
       9                 :            : #include <cmdline_parse_num.h>
      10                 :            : #include <cmdline_parse_string.h>
      11                 :            : 
      12                 :            : #include <rte_ethdev.h>
      13                 :            : #include <rte_flow.h>
      14                 :            : #include <rte_string_fns.h>
      15                 :            : #include <rte_tm.h>
      16                 :            : 
      17                 :            : #include "testpmd.h"
      18                 :            : #include "cmdline_tm.h"
      19                 :            : 
      20                 :            : #define PARSE_DELIMITER                         " \f\n\r\t\v"
      21                 :            : #define MAX_NUM_SHARED_SHAPERS          256
      22                 :            : 
      23                 :            : /** Display TM Error Message */
      24                 :            : static void
      25                 :          0 : print_err_msg(struct rte_tm_error *error)
      26                 :            : {
      27                 :            :         static const char *const errstrlist[] = {
      28                 :            :                 [RTE_TM_ERROR_TYPE_NONE] = "no error",
      29                 :            :                 [RTE_TM_ERROR_TYPE_UNSPECIFIED] = "cause unspecified",
      30                 :            :                 [RTE_TM_ERROR_TYPE_CAPABILITIES]
      31                 :            :                         = "capability parameter null",
      32                 :            :                 [RTE_TM_ERROR_TYPE_LEVEL_ID] = "level id",
      33                 :            :                 [RTE_TM_ERROR_TYPE_WRED_PROFILE]
      34                 :            :                         = "wred profile null",
      35                 :            :                 [RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN] = "wred profile(green)",
      36                 :            :                 [RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW]
      37                 :            :                         = "wred profile(yellow)",
      38                 :            :                 [RTE_TM_ERROR_TYPE_WRED_PROFILE_RED] = "wred profile(red)",
      39                 :            :                 [RTE_TM_ERROR_TYPE_WRED_PROFILE_ID] = "wred profile id",
      40                 :            :                 [RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID]
      41                 :            :                         = "shared wred context id",
      42                 :            :                 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE] = "shaper profile null",
      43                 :            :                 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE]
      44                 :            :                         = "committed rate field (shaper profile)",
      45                 :            :                 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE]
      46                 :            :                         = "committed size field (shaper profile)",
      47                 :            :                 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE]
      48                 :            :                         = "peak rate field (shaper profile)",
      49                 :            :                 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE]
      50                 :            :                         = "peak size field (shaper profile)",
      51                 :            :                 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN]
      52                 :            :                         = "packet adjust length field (shaper profile)",
      53                 :            :                 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PACKET_MODE]
      54                 :            :                         = "packet mode field (shaper profile)",
      55                 :            :                 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID] = "shaper profile id",
      56                 :            :                 [RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID] = "shared shaper id",
      57                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID] = "parent node id",
      58                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PRIORITY] = "node priority",
      59                 :            :                 [RTE_TM_ERROR_TYPE_NODE_WEIGHT] = "node weight",
      60                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS] = "node parameter null",
      61                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID]
      62                 :            :                         = "shaper profile id field (node params)",
      63                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID]
      64                 :            :                         = "shared shaper id field (node params)",
      65                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS]
      66                 :            :                         = "num shared shapers field (node params)",
      67                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE]
      68                 :            :                         = "wfq weight mode field (node params)",
      69                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES]
      70                 :            :                         = "num strict priorities field (node params)",
      71                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN]
      72                 :            :                         = "congestion management mode field (node params)",
      73                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID] =
      74                 :            :                         "wred profile id field (node params)",
      75                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID]
      76                 :            :                         = "shared wred context id field (node params)",
      77                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS]
      78                 :            :                         = "num shared wred contexts field (node params)",
      79                 :            :                 [RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS]
      80                 :            :                         = "stats field (node params)",
      81                 :            :                 [RTE_TM_ERROR_TYPE_NODE_ID] = "node id",
      82                 :            :         };
      83                 :            : 
      84                 :            :         const char *errstr;
      85                 :            :         char buf[64];
      86                 :            : 
      87                 :          0 :         if ((unsigned int)error->type >= RTE_DIM(errstrlist) ||
      88                 :          0 :                 !errstrlist[error->type])
      89                 :            :                 errstr = "unknown type";
      90                 :            :         else
      91                 :            :                 errstr = errstrlist[error->type];
      92                 :            : 
      93                 :          0 :         if (error->cause)
      94                 :            :                 snprintf(buf, sizeof(buf), "cause: %p, ", error->cause);
      95                 :            : 
      96                 :          0 :         fprintf(stderr, "%s: %s%s (error %d)\n",
      97                 :          0 :                 errstr, error->cause ? buf : "",
      98                 :          0 :                 error->message ? error->message : "(no stated reason)",
      99                 :          0 :                 error->type);
     100                 :          0 : }
     101                 :            : 
     102                 :            : static int
     103                 :          0 : read_uint64(uint64_t *value, const char *p)
     104                 :            : {
     105                 :            :         char *next;
     106                 :            :         uint64_t val;
     107                 :            : 
     108                 :          0 :         p = rte_str_skip_leading_spaces(p);
     109                 :          0 :         if (!isdigit(*p))
     110                 :            :                 return -EINVAL;
     111                 :            : 
     112                 :          0 :         val = strtoul(p, &next, 10);
     113                 :          0 :         if (p == next)
     114                 :            :                 return -EINVAL;
     115                 :            : 
     116                 :            :         p = next;
     117                 :          0 :         switch (*p) {
     118                 :          0 :         case 'T':
     119                 :          0 :                 val *= 1024ULL;
     120                 :            :                 /* fall through */
     121                 :          0 :         case 'G':
     122                 :          0 :                 val *= 1024ULL;
     123                 :            :                 /* fall through */
     124                 :          0 :         case 'M':
     125                 :          0 :                 val *= 1024ULL;
     126                 :            :                 /* fall through */
     127                 :          0 :         case 'k':
     128                 :            :         case 'K':
     129                 :          0 :                 val *= 1024ULL;
     130                 :          0 :                 p++;
     131                 :          0 :                 break;
     132                 :            :         }
     133                 :            : 
     134                 :          0 :         p = rte_str_skip_leading_spaces(p);
     135                 :          0 :         if (*p != '\0')
     136                 :            :                 return -EINVAL;
     137                 :            : 
     138                 :          0 :         *value = val;
     139                 :          0 :         return 0;
     140                 :            : }
     141                 :            : 
     142                 :            : static int
     143                 :            : read_uint32(uint32_t *value, const char *p)
     144                 :            : {
     145                 :          0 :         uint64_t val = 0;
     146                 :          0 :         int ret = read_uint64(&val, p);
     147                 :            : 
     148                 :          0 :         if (ret < 0)
     149                 :            :                 return ret;
     150                 :            : 
     151                 :          0 :         if (val > UINT32_MAX)
     152                 :            :                 return -ERANGE;
     153                 :            : 
     154                 :          0 :         *value = val;
     155                 :            :         return 0;
     156                 :            : }
     157                 :            : 
     158                 :            : static int
     159                 :          0 : parse_multi_ss_id_str(char *s_str, uint32_t *n_ssp, uint32_t shaper_id[])
     160                 :            : {
     161                 :            :         uint32_t n_shared_shapers = 0, i = 0;
     162                 :            :         char *token;
     163                 :            : 
     164                 :            :         /* First token: num of shared shapers */
     165                 :          0 :         token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
     166                 :          0 :         if (token ==  NULL)
     167                 :            :                 return -1;
     168                 :            : 
     169                 :            :         if (read_uint32(&n_shared_shapers, token))
     170                 :          0 :                 return -1;
     171                 :            : 
     172                 :            :         /* Check: num of shared shaper */
     173                 :          0 :         if (n_shared_shapers >= MAX_NUM_SHARED_SHAPERS) {
     174                 :          0 :                 fprintf(stderr,
     175                 :            :                         " Number of shared shapers exceed the max (error)\n");
     176                 :          0 :                 return -1;
     177                 :            :         }
     178                 :            : 
     179                 :            :         /* Parse shared shaper ids */
     180                 :            :         while (1) {
     181                 :          0 :                 token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
     182                 :          0 :                 if ((token !=  NULL && n_shared_shapers == 0) ||
     183                 :          0 :                         (token == NULL && i < n_shared_shapers))
     184                 :            :                         return -1;
     185                 :            : 
     186                 :          0 :                 if (token == NULL)
     187                 :            :                         break;
     188                 :            : 
     189                 :          0 :                 if (read_uint32(&shaper_id[i], token))
     190                 :          0 :                         return -1;
     191                 :          0 :                 i++;
     192                 :            :         }
     193                 :          0 :         *n_ssp = n_shared_shapers;
     194                 :            : 
     195                 :          0 :         return 0;
     196                 :            : }
     197                 :            : /* *** Port TM Capability *** */
     198                 :            : struct cmd_show_port_tm_cap_result {
     199                 :            :         cmdline_fixed_string_t show;
     200                 :            :         cmdline_fixed_string_t port;
     201                 :            :         cmdline_fixed_string_t tm;
     202                 :            :         cmdline_fixed_string_t cap;
     203                 :            :         uint16_t port_id;
     204                 :            : };
     205                 :            : 
     206                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_cap_show =
     207                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
     208                 :            :                 show, "show");
     209                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_cap_port =
     210                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
     211                 :            :                 port, "port");
     212                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_cap_tm =
     213                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
     214                 :            :                 tm, "tm");
     215                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_cap_cap =
     216                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
     217                 :            :                 cap, "cap");
     218                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_cap_port_id =
     219                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_cap_result,
     220                 :            :                  port_id, RTE_UINT16);
     221                 :            : 
     222                 :          0 : static void cmd_show_port_tm_cap_parsed(void *parsed_result,
     223                 :            :         __rte_unused struct cmdline *cl,
     224                 :            :         __rte_unused void *data)
     225                 :            : {
     226                 :            :         struct cmd_show_port_tm_cap_result *res = parsed_result;
     227                 :            :         struct rte_tm_capabilities cap;
     228                 :            :         struct rte_tm_error error;
     229                 :          0 :         portid_t port_id = res->port_id;
     230                 :            :         uint32_t i;
     231                 :            :         int ret;
     232                 :            : 
     233                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     234                 :          0 :                 return;
     235                 :            : 
     236                 :            :         memset(&cap, 0, sizeof(struct rte_tm_capabilities));
     237                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
     238                 :          0 :         ret = rte_tm_capabilities_get(port_id, &cap, &error);
     239                 :          0 :         if (ret) {
     240                 :          0 :                 print_err_msg(&error);
     241                 :          0 :                 return;
     242                 :            :         }
     243                 :            : 
     244                 :            :         printf("\n****   Port TM Capabilities ****\n\n");
     245                 :          0 :         printf("cap.n_nodes_max %" PRIu32 "\n", cap.n_nodes_max);
     246                 :          0 :         printf("cap.n_levels_max %" PRIu32 "\n", cap.n_levels_max);
     247                 :          0 :         printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
     248                 :            :                 cap.non_leaf_nodes_identical);
     249                 :          0 :         printf("cap.leaf_nodes_identical %" PRId32 "\n",
     250                 :            :                 cap.leaf_nodes_identical);
     251                 :          0 :         printf("cap.shaper_n_max %u\n", cap.shaper_n_max);
     252                 :          0 :         printf("cap.shaper_private_n_max %" PRIu32 "\n",
     253                 :            :                 cap.shaper_private_n_max);
     254                 :          0 :         printf("cap.shaper_private_dual_rate_n_max %" PRId32 "\n",
     255                 :            :                 cap.shaper_private_dual_rate_n_max);
     256                 :          0 :         printf("cap.shaper_private_rate_min %" PRIu64 "\n",
     257                 :            :                 cap.shaper_private_rate_min);
     258                 :          0 :         printf("cap.shaper_private_rate_max %" PRIu64 "\n",
     259                 :            :                 cap.shaper_private_rate_max);
     260                 :          0 :         printf("cap.shaper_private_packet_mode_supported %" PRId32 "\n",
     261                 :            :                 cap.shaper_private_packet_mode_supported);
     262                 :          0 :         printf("cap.shaper_private_byte_mode_supported %" PRId32 "\n",
     263                 :            :                 cap.shaper_private_byte_mode_supported);
     264                 :          0 :         printf("cap.shaper_shared_n_max %" PRIu32 "\n",
     265                 :            :                 cap.shaper_shared_n_max);
     266                 :          0 :         printf("cap.shaper_shared_n_nodes_per_shaper_max %" PRIu32 "\n",
     267                 :            :                 cap.shaper_shared_n_nodes_per_shaper_max);
     268                 :          0 :         printf("cap.shaper_shared_n_shapers_per_node_max %" PRIu32 "\n",
     269                 :            :                 cap.shaper_shared_n_shapers_per_node_max);
     270                 :          0 :         printf("cap.shaper_shared_dual_rate_n_max %" PRIu32 "\n",
     271                 :            :                 cap.shaper_shared_dual_rate_n_max);
     272                 :          0 :         printf("cap.shaper_shared_rate_min %" PRIu64 "\n",
     273                 :            :                 cap.shaper_shared_rate_min);
     274                 :          0 :         printf("cap.shaper_shared_rate_max %" PRIu64 "\n",
     275                 :            :                 cap.shaper_shared_rate_max);
     276                 :          0 :         printf("cap.shaper_shared_packet_mode_supported %" PRId32 "\n",
     277                 :            :                 cap.shaper_shared_packet_mode_supported);
     278                 :          0 :         printf("cap.shaper_shared_byte_mode_supported %" PRId32 "\n",
     279                 :            :                 cap.shaper_shared_byte_mode_supported);
     280                 :          0 :         printf("cap.shaper_pkt_length_adjust_min %" PRId32 "\n",
     281                 :            :                 cap.shaper_pkt_length_adjust_min);
     282                 :          0 :         printf("cap.shaper_pkt_length_adjust_max %" PRId32 "\n",
     283                 :            :                 cap.shaper_pkt_length_adjust_max);
     284                 :          0 :         printf("cap.sched_n_children_max %" PRIu32 "\n",
     285                 :            :                 cap.sched_n_children_max);
     286                 :          0 :         printf("cap.sched_sp_n_priorities_max %" PRIu32 "\n",
     287                 :            :                 cap.sched_sp_n_priorities_max);
     288                 :          0 :         printf("cap.sched_wfq_n_children_per_group_max %" PRIu32 "\n",
     289                 :            :                 cap.sched_wfq_n_children_per_group_max);
     290                 :          0 :         printf("cap.sched_wfq_n_groups_max %" PRIu32 "\n",
     291                 :            :                 cap.sched_wfq_n_groups_max);
     292                 :          0 :         printf("cap.sched_wfq_weight_max %" PRIu32 "\n",
     293                 :            :                 cap.sched_wfq_weight_max);
     294                 :          0 :         printf("cap.sched_wfq_packet_mode_supported %" PRId32 "\n",
     295                 :            :                 cap.sched_wfq_packet_mode_supported);
     296                 :          0 :         printf("cap.sched_wfq_byte_mode_supported %" PRId32 "\n",
     297                 :            :                 cap.sched_wfq_byte_mode_supported);
     298                 :          0 :         printf("cap.cman_head_drop_supported %" PRId32 "\n",
     299                 :            :                 cap.cman_head_drop_supported);
     300                 :          0 :         printf("cap.cman_wred_context_n_max %" PRIu32 "\n",
     301                 :            :                 cap.cman_wred_context_n_max);
     302                 :          0 :         printf("cap.cman_wred_context_private_n_max %" PRIu32 "\n",
     303                 :            :                 cap.cman_wred_context_private_n_max);
     304                 :          0 :         printf("cap.cman_wred_context_shared_n_max %" PRIu32 "\n",
     305                 :            :                 cap.cman_wred_context_shared_n_max);
     306                 :          0 :         printf("cap.cman_wred_context_shared_n_nodes_per_context_max %" PRIu32
     307                 :            :                 "\n", cap.cman_wred_context_shared_n_nodes_per_context_max);
     308                 :          0 :         printf("cap.cman_wred_context_shared_n_contexts_per_node_max %" PRIu32
     309                 :            :                 "\n", cap.cman_wred_context_shared_n_contexts_per_node_max);
     310                 :            : 
     311                 :          0 :         for (i = 0; i < RTE_COLORS; i++) {
     312                 :          0 :                 printf("cap.mark_vlan_dei_supported %" PRId32 "\n",
     313                 :            :                         cap.mark_vlan_dei_supported[i]);
     314                 :          0 :                 printf("cap.mark_ip_ecn_tcp_supported %" PRId32 "\n",
     315                 :            :                         cap.mark_ip_ecn_tcp_supported[i]);
     316                 :          0 :                 printf("cap.mark_ip_ecn_sctp_supported %" PRId32 "\n",
     317                 :            :                         cap.mark_ip_ecn_sctp_supported[i]);
     318                 :          0 :                 printf("cap.mark_ip_dscp_supported %" PRId32 "\n",
     319                 :            :                         cap.mark_ip_dscp_supported[i]);
     320                 :            :         }
     321                 :            : 
     322                 :          0 :         printf("cap.dynamic_update_mask %" PRIx64 "\n",
     323                 :            :                 cap.dynamic_update_mask);
     324                 :          0 :         printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
     325                 :            : }
     326                 :            : 
     327                 :            : cmdline_parse_inst_t cmd_show_port_tm_cap = {
     328                 :            :         .f = cmd_show_port_tm_cap_parsed,
     329                 :            :         .data = NULL,
     330                 :            :         .help_str = "Show Port TM Capabilities",
     331                 :            :         .tokens = {
     332                 :            :                 (void *)&cmd_show_port_tm_cap_show,
     333                 :            :                 (void *)&cmd_show_port_tm_cap_port,
     334                 :            :                 (void *)&cmd_show_port_tm_cap_tm,
     335                 :            :                 (void *)&cmd_show_port_tm_cap_cap,
     336                 :            :                 (void *)&cmd_show_port_tm_cap_port_id,
     337                 :            :                 NULL,
     338                 :            :         },
     339                 :            : };
     340                 :            : 
     341                 :            : /* *** Port TM Hierarchical Level Capability *** */
     342                 :            : struct cmd_show_port_tm_level_cap_result {
     343                 :            :         cmdline_fixed_string_t show;
     344                 :            :         cmdline_fixed_string_t port;
     345                 :            :         cmdline_fixed_string_t tm;
     346                 :            :         cmdline_fixed_string_t level;
     347                 :            :         cmdline_fixed_string_t cap;
     348                 :            :         uint16_t port_id;
     349                 :            :         uint32_t level_id;
     350                 :            : };
     351                 :            : 
     352                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_show =
     353                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
     354                 :            :                 show, "show");
     355                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_port =
     356                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
     357                 :            :                 port, "port");
     358                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_tm =
     359                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
     360                 :            :                 tm, "tm");
     361                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_level =
     362                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
     363                 :            :                 level, "level");
     364                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_cap =
     365                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
     366                 :            :                 cap, "cap");
     367                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_level_cap_port_id =
     368                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
     369                 :            :                  port_id, RTE_UINT16);
     370                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_level_cap_level_id =
     371                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
     372                 :            :                  level_id, RTE_UINT32);
     373                 :            : 
     374                 :            : 
     375                 :          0 : static void cmd_show_port_tm_level_cap_parsed(void *parsed_result,
     376                 :            :         __rte_unused struct cmdline *cl,
     377                 :            :         __rte_unused void *data)
     378                 :            : {
     379                 :            :         struct cmd_show_port_tm_level_cap_result *res = parsed_result;
     380                 :            :         struct rte_tm_level_capabilities lcap;
     381                 :            :         struct rte_tm_error error;
     382                 :          0 :         portid_t port_id = res->port_id;
     383                 :          0 :         uint32_t level_id = res->level_id;
     384                 :            :         int ret;
     385                 :            : 
     386                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     387                 :          0 :                 return;
     388                 :            : 
     389                 :            :         memset(&lcap, 0, sizeof(struct rte_tm_level_capabilities));
     390                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
     391                 :          0 :         ret = rte_tm_level_capabilities_get(port_id, level_id, &lcap, &error);
     392                 :          0 :         if (ret) {
     393                 :          0 :                 print_err_msg(&error);
     394                 :          0 :                 return;
     395                 :            :         }
     396                 :            :         printf("\n**   Port TM Hierarchy level %" PRIu32 " Capability **\n\n",
     397                 :            :                 level_id);
     398                 :            : 
     399                 :          0 :         printf("cap.n_nodes_max %" PRIu32 "\n", lcap.n_nodes_max);
     400                 :          0 :         printf("cap.n_nodes_nonleaf_max %" PRIu32 "\n",
     401                 :            :                 lcap.n_nodes_nonleaf_max);
     402                 :          0 :         printf("cap.n_nodes_leaf_max %" PRIu32 "\n", lcap.n_nodes_leaf_max);
     403                 :          0 :         printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
     404                 :            :                 lcap.non_leaf_nodes_identical);
     405                 :          0 :         printf("cap.leaf_nodes_identical %" PRId32 "\n",
     406                 :            :                 lcap.leaf_nodes_identical);
     407                 :          0 :         if (level_id <= 3) {
     408                 :          0 :                 printf("cap.nonleaf.shaper_private_supported %" PRId32 "\n",
     409                 :            :                         lcap.nonleaf.shaper_private_supported);
     410                 :          0 :                 printf("cap.nonleaf.shaper_private_dual_rate_supported %" PRId32
     411                 :            :                         "\n", lcap.nonleaf.shaper_private_dual_rate_supported);
     412                 :          0 :                 printf("cap.nonleaf.shaper_private_rate_min %" PRIu64 "\n",
     413                 :            :                         lcap.nonleaf.shaper_private_rate_min);
     414                 :          0 :                 printf("cap.nonleaf.shaper_private_rate_max %" PRIu64 "\n",
     415                 :            :                         lcap.nonleaf.shaper_private_rate_max);
     416                 :          0 :                 printf("cap.nonleaf.shaper_private_packet_mode_supported %"
     417                 :            :                        PRId32 "\n",
     418                 :            :                         lcap.nonleaf.shaper_private_packet_mode_supported);
     419                 :          0 :                 printf("cap.nonleaf.shaper_private_byte_mode_supported %" PRId32
     420                 :            :                        "\n", lcap.nonleaf.shaper_private_byte_mode_supported);
     421                 :          0 :                 printf("cap.nonleaf.shaper_shared_n_max %" PRIu32 "\n",
     422                 :            :                         lcap.nonleaf.shaper_shared_n_max);
     423                 :          0 :                 printf("cap.nonleaf.shaper_shared_packet_mode_supported %"
     424                 :            :                        PRId32 "\n",
     425                 :            :                        lcap.nonleaf.shaper_shared_packet_mode_supported);
     426                 :          0 :                 printf("cap.nonleaf.shaper_shared_byte_mode_supported %"
     427                 :            :                        PRId32 "\n",
     428                 :            :                        lcap.nonleaf.shaper_shared_byte_mode_supported);
     429                 :          0 :                 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
     430                 :            :                         lcap.nonleaf.sched_n_children_max);
     431                 :          0 :                 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
     432                 :            :                         lcap.nonleaf.sched_sp_n_priorities_max);
     433                 :          0 :                 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
     434                 :            :                         "\n", lcap.nonleaf.sched_wfq_n_children_per_group_max);
     435                 :          0 :                 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
     436                 :            :                         lcap.nonleaf.sched_wfq_n_groups_max);
     437                 :          0 :                 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
     438                 :            :                         lcap.nonleaf.sched_wfq_weight_max);
     439                 :          0 :                 printf("cap.nonleaf.sched_wfq_packet_mode_supported %" PRId32 "\n",
     440                 :            :                         lcap.nonleaf.sched_wfq_packet_mode_supported);
     441                 :          0 :                 printf("cap.nonleaf.sched_wfq_byte_mode_supported %" PRId32
     442                 :            :                        "\n", lcap.nonleaf.sched_wfq_byte_mode_supported);
     443                 :          0 :                 printf("cap.nonleaf.stats_mask %" PRIx64 "\n",
     444                 :            :                         lcap.nonleaf.stats_mask);
     445                 :            :         } else {
     446                 :          0 :                 printf("cap.leaf.shaper_private_supported %" PRId32 "\n",
     447                 :            :                         lcap.leaf.shaper_private_supported);
     448                 :          0 :                 printf("cap.leaf.shaper_private_dual_rate_supported %" PRId32
     449                 :            :                         "\n", lcap.leaf.shaper_private_dual_rate_supported);
     450                 :          0 :                 printf("cap.leaf.shaper_private_rate_min %" PRIu64 "\n",
     451                 :            :                         lcap.leaf.shaper_private_rate_min);
     452                 :          0 :                 printf("cap.leaf.shaper_private_rate_max %" PRIu64 "\n",
     453                 :            :                         lcap.leaf.shaper_private_rate_max);
     454                 :          0 :                 printf("cap.leaf.shaper_private_packet_mode_supported %" PRId32
     455                 :            :                        "\n", lcap.leaf.shaper_private_packet_mode_supported);
     456                 :          0 :                 printf("cap.leaf.shaper_private_byte_mode_supported %" PRId32 "\n",
     457                 :            :                         lcap.leaf.shaper_private_byte_mode_supported);
     458                 :          0 :                 printf("cap.leaf.shaper_shared_n_max %" PRIu32 "\n",
     459                 :            :                         lcap.leaf.shaper_shared_n_max);
     460                 :          0 :                 printf("cap.leaf.shaper_shared_packet_mode_supported %" PRId32 "\n",
     461                 :            :                        lcap.leaf.shaper_shared_packet_mode_supported);
     462                 :          0 :                 printf("cap.leaf.shaper_shared_byte_mode_supported %" PRId32 "\n",
     463                 :            :                        lcap.leaf.shaper_shared_byte_mode_supported);
     464                 :          0 :                 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
     465                 :            :                         lcap.leaf.cman_head_drop_supported);
     466                 :          0 :                 printf("cap.leaf.cman_wred_context_private_supported %"       PRId32
     467                 :            :                         "\n", lcap.leaf.cman_wred_context_private_supported);
     468                 :          0 :                 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
     469                 :            :                         lcap.leaf.cman_wred_context_shared_n_max);
     470                 :          0 :                 printf("cap.leaf.stats_mask %" PRIx64 "\n",
     471                 :            :                         lcap.leaf.stats_mask);
     472                 :            :         }
     473                 :            : }
     474                 :            : 
     475                 :            : cmdline_parse_inst_t cmd_show_port_tm_level_cap = {
     476                 :            :         .f = cmd_show_port_tm_level_cap_parsed,
     477                 :            :         .data = NULL,
     478                 :            :         .help_str = "Show port TM hierarchical level capabilities",
     479                 :            :         .tokens = {
     480                 :            :                 (void *)&cmd_show_port_tm_level_cap_show,
     481                 :            :                 (void *)&cmd_show_port_tm_level_cap_port,
     482                 :            :                 (void *)&cmd_show_port_tm_level_cap_tm,
     483                 :            :                 (void *)&cmd_show_port_tm_level_cap_level,
     484                 :            :                 (void *)&cmd_show_port_tm_level_cap_cap,
     485                 :            :                 (void *)&cmd_show_port_tm_level_cap_port_id,
     486                 :            :                 (void *)&cmd_show_port_tm_level_cap_level_id,
     487                 :            :                 NULL,
     488                 :            :         },
     489                 :            : };
     490                 :            : 
     491                 :            : /* *** Port TM Hierarchy Node Capability *** */
     492                 :            : struct cmd_show_port_tm_node_cap_result {
     493                 :            :         cmdline_fixed_string_t show;
     494                 :            :         cmdline_fixed_string_t port;
     495                 :            :         cmdline_fixed_string_t tm;
     496                 :            :         cmdline_fixed_string_t node;
     497                 :            :         cmdline_fixed_string_t cap;
     498                 :            :         uint16_t port_id;
     499                 :            :         uint32_t node_id;
     500                 :            : };
     501                 :            : 
     502                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_show =
     503                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
     504                 :            :                 show, "show");
     505                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_port =
     506                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
     507                 :            :                 port, "port");
     508                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_tm =
     509                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
     510                 :            :                 tm, "tm");
     511                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_node =
     512                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
     513                 :            :                 node, "node");
     514                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_cap =
     515                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
     516                 :            :                 cap, "cap");
     517                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_node_cap_port_id =
     518                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
     519                 :            :                  port_id, RTE_UINT16);
     520                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_node_cap_node_id =
     521                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
     522                 :            :                  node_id, RTE_UINT32);
     523                 :            : 
     524                 :          0 : static void cmd_show_port_tm_node_cap_parsed(void *parsed_result,
     525                 :            :         __rte_unused struct cmdline *cl,
     526                 :            :         __rte_unused void *data)
     527                 :            : {
     528                 :            :         struct cmd_show_port_tm_node_cap_result *res = parsed_result;
     529                 :            :         struct rte_tm_node_capabilities ncap;
     530                 :            :         struct rte_tm_error error;
     531                 :          0 :         uint32_t node_id = res->node_id;
     532                 :          0 :         portid_t port_id = res->port_id;
     533                 :          0 :         int ret, is_leaf = 0;
     534                 :            : 
     535                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     536                 :          0 :                 return;
     537                 :            : 
     538                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
     539                 :            :         /* Node id must be valid */
     540                 :          0 :         ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
     541                 :          0 :         if (ret != 0) {
     542                 :          0 :                 print_err_msg(&error);
     543                 :          0 :                 return;
     544                 :            :         }
     545                 :            : 
     546                 :            :         memset(&ncap, 0, sizeof(struct rte_tm_node_capabilities));
     547                 :          0 :         ret = rte_tm_node_capabilities_get(port_id, node_id, &ncap, &error);
     548                 :          0 :         if (ret != 0) {
     549                 :          0 :                 print_err_msg(&error);
     550                 :          0 :                 return;
     551                 :            :         }
     552                 :            :         printf("\n**   Port TM Hierarchy node %" PRIu32 " Capability **\n\n",
     553                 :            :                 node_id);
     554                 :          0 :         printf("cap.shaper_private_supported %" PRId32 "\n",
     555                 :            :                 ncap.shaper_private_supported);
     556                 :          0 :         printf("cap.shaper_private_dual_rate_supported %" PRId32 "\n",
     557                 :            :                 ncap.shaper_private_dual_rate_supported);
     558                 :          0 :         printf("cap.shaper_private_rate_min %" PRIu64 "\n",
     559                 :            :                 ncap.shaper_private_rate_min);
     560                 :          0 :         printf("cap.shaper_private_rate_max %" PRIu64 "\n",
     561                 :            :                 ncap.shaper_private_rate_max);
     562                 :          0 :         printf("cap.shaper_private_packet_mode_supported %" PRId32 "\n",
     563                 :            :                 ncap.shaper_private_packet_mode_supported);
     564                 :          0 :         printf("cap.shaper_private_byte_mode_supported %" PRId32 "\n",
     565                 :            :                 ncap.shaper_private_byte_mode_supported);
     566                 :          0 :         printf("cap.shaper_shared_n_max %" PRIu32 "\n",
     567                 :            :                 ncap.shaper_shared_n_max);
     568                 :          0 :         printf("cap.shaper_shared_packet_mode_supported %" PRId32 "\n",
     569                 :            :                 ncap.shaper_shared_packet_mode_supported);
     570                 :          0 :         printf("cap.shaper_shared_byte_mode_supported %" PRId32 "\n",
     571                 :            :                 ncap.shaper_shared_byte_mode_supported);
     572                 :          0 :         if (!is_leaf) {
     573                 :          0 :                 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
     574                 :            :                         ncap.nonleaf.sched_n_children_max);
     575                 :          0 :                 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
     576                 :            :                         ncap.nonleaf.sched_sp_n_priorities_max);
     577                 :          0 :                 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
     578                 :            :                         "\n", ncap.nonleaf.sched_wfq_n_children_per_group_max);
     579                 :          0 :                 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
     580                 :            :                         ncap.nonleaf.sched_wfq_n_groups_max);
     581                 :          0 :                 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
     582                 :            :                         ncap.nonleaf.sched_wfq_weight_max);
     583                 :          0 :                 printf("cap.nonleaf.sched_wfq_packet_mode_supported %" PRId32 "\n",
     584                 :            :                         ncap.nonleaf.sched_wfq_packet_mode_supported);
     585                 :          0 :                 printf("cap.nonleaf.sched_wfq_byte_mode_supported %" PRId32 "\n",
     586                 :            :                         ncap.nonleaf.sched_wfq_byte_mode_supported);
     587                 :            :         } else {
     588                 :          0 :                 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
     589                 :            :                         ncap.leaf.cman_head_drop_supported);
     590                 :          0 :                 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
     591                 :            :                         "\n", ncap.leaf.cman_wred_context_private_supported);
     592                 :          0 :                 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
     593                 :            :                         ncap.leaf.cman_wred_context_shared_n_max);
     594                 :            :         }
     595                 :          0 :         printf("cap.stats_mask %" PRIx64 "\n", ncap.stats_mask);
     596                 :            : }
     597                 :            : 
     598                 :            : cmdline_parse_inst_t cmd_show_port_tm_node_cap = {
     599                 :            :         .f = cmd_show_port_tm_node_cap_parsed,
     600                 :            :         .data = NULL,
     601                 :            :         .help_str = "Show Port TM Hierarchy node capabilities",
     602                 :            :         .tokens = {
     603                 :            :                 (void *)&cmd_show_port_tm_node_cap_show,
     604                 :            :                 (void *)&cmd_show_port_tm_node_cap_port,
     605                 :            :                 (void *)&cmd_show_port_tm_node_cap_tm,
     606                 :            :                 (void *)&cmd_show_port_tm_node_cap_node,
     607                 :            :                 (void *)&cmd_show_port_tm_node_cap_cap,
     608                 :            :                 (void *)&cmd_show_port_tm_node_cap_port_id,
     609                 :            :                 (void *)&cmd_show_port_tm_node_cap_node_id,
     610                 :            :                 NULL,
     611                 :            :         },
     612                 :            : };
     613                 :            : 
     614                 :            : /* *** Show Port TM Node Statistics *** */
     615                 :            : struct cmd_show_port_tm_node_stats_result {
     616                 :            :         cmdline_fixed_string_t show;
     617                 :            :         cmdline_fixed_string_t port;
     618                 :            :         cmdline_fixed_string_t tm;
     619                 :            :         cmdline_fixed_string_t node;
     620                 :            :         cmdline_fixed_string_t stats;
     621                 :            :         uint16_t port_id;
     622                 :            :         uint32_t node_id;
     623                 :            :         uint32_t clear;
     624                 :            : };
     625                 :            : 
     626                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_show =
     627                 :            :         TOKEN_STRING_INITIALIZER(
     628                 :            :                 struct cmd_show_port_tm_node_stats_result, show, "show");
     629                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_port =
     630                 :            :         TOKEN_STRING_INITIALIZER(
     631                 :            :                 struct cmd_show_port_tm_node_stats_result, port, "port");
     632                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_tm =
     633                 :            :         TOKEN_STRING_INITIALIZER(
     634                 :            :                 struct cmd_show_port_tm_node_stats_result, tm, "tm");
     635                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_node =
     636                 :            :         TOKEN_STRING_INITIALIZER(
     637                 :            :                 struct cmd_show_port_tm_node_stats_result, node, "node");
     638                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_stats =
     639                 :            :         TOKEN_STRING_INITIALIZER(
     640                 :            :                 struct cmd_show_port_tm_node_stats_result, stats, "stats");
     641                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_node_stats_port_id =
     642                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_stats_result,
     643                 :            :                         port_id, RTE_UINT16);
     644                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_node_stats_node_id =
     645                 :            :         TOKEN_NUM_INITIALIZER(
     646                 :            :                 struct cmd_show_port_tm_node_stats_result,
     647                 :            :                         node_id, RTE_UINT32);
     648                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_node_stats_clear =
     649                 :            :         TOKEN_NUM_INITIALIZER(
     650                 :            :                 struct cmd_show_port_tm_node_stats_result, clear, RTE_UINT32);
     651                 :            : 
     652                 :          0 : static void cmd_show_port_tm_node_stats_parsed(void *parsed_result,
     653                 :            :         __rte_unused struct cmdline *cl,
     654                 :            :         __rte_unused void *data)
     655                 :            : {
     656                 :            :         struct cmd_show_port_tm_node_stats_result *res = parsed_result;
     657                 :            :         struct rte_tm_node_stats stats;
     658                 :            :         struct rte_tm_error error;
     659                 :          0 :         uint64_t stats_mask = 0;
     660                 :          0 :         uint32_t node_id = res->node_id;
     661                 :          0 :         uint32_t clear = res->clear;
     662                 :          0 :         portid_t port_id = res->port_id;
     663                 :            :         int ret;
     664                 :            : 
     665                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     666                 :          0 :                 return;
     667                 :            : 
     668                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
     669                 :            :         /* Port status */
     670                 :          0 :         if (!port_is_started(port_id)) {
     671                 :          0 :                 fprintf(stderr, " Port %u not started (error)\n", port_id);
     672                 :          0 :                 return;
     673                 :            :         }
     674                 :            : 
     675                 :            :         memset(&stats, 0, sizeof(struct rte_tm_node_stats));
     676                 :          0 :         ret = rte_tm_node_stats_read(port_id, node_id, &stats,
     677                 :            :                         &stats_mask, clear, &error);
     678                 :          0 :         if (ret != 0) {
     679                 :          0 :                 print_err_msg(&error);
     680                 :          0 :                 return;
     681                 :            :         }
     682                 :            : 
     683                 :            :         /* Display stats */
     684                 :          0 :         if (stats_mask & RTE_TM_STATS_N_PKTS)
     685                 :          0 :                 printf("\tPkts scheduled from node: %" PRIu64 "\n",
     686                 :            :                         stats.n_pkts);
     687                 :          0 :         if (stats_mask & RTE_TM_STATS_N_BYTES)
     688                 :          0 :                 printf("\tBytes scheduled from node: %" PRIu64 "\n",
     689                 :            :                         stats.n_bytes);
     690                 :          0 :         if (stats_mask & RTE_TM_STATS_N_PKTS_GREEN_DROPPED)
     691                 :          0 :                 printf("\tPkts dropped (green): %" PRIu64 "\n",
     692                 :            :                         stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN]);
     693                 :          0 :         if (stats_mask & RTE_TM_STATS_N_PKTS_YELLOW_DROPPED)
     694                 :          0 :                 printf("\tPkts dropped (yellow): %" PRIu64 "\n",
     695                 :            :                         stats.leaf.n_pkts_dropped[RTE_COLOR_YELLOW]);
     696                 :          0 :         if (stats_mask & RTE_TM_STATS_N_PKTS_RED_DROPPED)
     697                 :          0 :                 printf("\tPkts dropped (red): %" PRIu64 "\n",
     698                 :            :                         stats.leaf.n_pkts_dropped[RTE_COLOR_RED]);
     699                 :          0 :         if (stats_mask & RTE_TM_STATS_N_BYTES_GREEN_DROPPED)
     700                 :          0 :                 printf("\tBytes dropped (green): %" PRIu64 "\n",
     701                 :            :                         stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN]);
     702                 :          0 :         if (stats_mask & RTE_TM_STATS_N_BYTES_YELLOW_DROPPED)
     703                 :          0 :                 printf("\tBytes dropped (yellow): %" PRIu64 "\n",
     704                 :            :                         stats.leaf.n_bytes_dropped[RTE_COLOR_YELLOW]);
     705                 :          0 :         if (stats_mask & RTE_TM_STATS_N_BYTES_RED_DROPPED)
     706                 :          0 :                 printf("\tBytes dropped (red): %" PRIu64 "\n",
     707                 :            :                         stats.leaf.n_bytes_dropped[RTE_COLOR_RED]);
     708                 :          0 :         if (stats_mask & RTE_TM_STATS_N_PKTS_QUEUED)
     709                 :          0 :                 printf("\tPkts queued: %" PRIu64 "\n",
     710                 :            :                         stats.leaf.n_pkts_queued);
     711                 :          0 :         if (stats_mask & RTE_TM_STATS_N_BYTES_QUEUED)
     712                 :          0 :                 printf("\tBytes queued: %" PRIu64 "\n",
     713                 :            :                         stats.leaf.n_bytes_queued);
     714                 :            : }
     715                 :            : 
     716                 :            : cmdline_parse_inst_t cmd_show_port_tm_node_stats = {
     717                 :            :         .f = cmd_show_port_tm_node_stats_parsed,
     718                 :            :         .data = NULL,
     719                 :            :         .help_str = "Show port tm node stats",
     720                 :            :         .tokens = {
     721                 :            :                 (void *)&cmd_show_port_tm_node_stats_show,
     722                 :            :                 (void *)&cmd_show_port_tm_node_stats_port,
     723                 :            :                 (void *)&cmd_show_port_tm_node_stats_tm,
     724                 :            :                 (void *)&cmd_show_port_tm_node_stats_node,
     725                 :            :                 (void *)&cmd_show_port_tm_node_stats_stats,
     726                 :            :                 (void *)&cmd_show_port_tm_node_stats_port_id,
     727                 :            :                 (void *)&cmd_show_port_tm_node_stats_node_id,
     728                 :            :                 (void *)&cmd_show_port_tm_node_stats_clear,
     729                 :            :                 NULL,
     730                 :            :         },
     731                 :            : };
     732                 :            : 
     733                 :            : /* *** Show Port TM Node Type *** */
     734                 :            : struct cmd_show_port_tm_node_type_result {
     735                 :            :         cmdline_fixed_string_t show;
     736                 :            :         cmdline_fixed_string_t port;
     737                 :            :         cmdline_fixed_string_t tm;
     738                 :            :         cmdline_fixed_string_t node;
     739                 :            :         cmdline_fixed_string_t type;
     740                 :            :         uint16_t port_id;
     741                 :            :         uint32_t node_id;
     742                 :            : };
     743                 :            : 
     744                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_type_show =
     745                 :            :         TOKEN_STRING_INITIALIZER(
     746                 :            :                 struct cmd_show_port_tm_node_type_result, show, "show");
     747                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_type_port =
     748                 :            :         TOKEN_STRING_INITIALIZER(
     749                 :            :                 struct cmd_show_port_tm_node_type_result, port, "port");
     750                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_type_tm =
     751                 :            :         TOKEN_STRING_INITIALIZER(
     752                 :            :                 struct cmd_show_port_tm_node_type_result, tm, "tm");
     753                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_type_node =
     754                 :            :         TOKEN_STRING_INITIALIZER(
     755                 :            :                 struct cmd_show_port_tm_node_type_result, node, "node");
     756                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_type_type =
     757                 :            :         TOKEN_STRING_INITIALIZER(
     758                 :            :                 struct cmd_show_port_tm_node_type_result, type, "type");
     759                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_node_type_port_id =
     760                 :            :         TOKEN_NUM_INITIALIZER(
     761                 :            :                 struct cmd_show_port_tm_node_type_result,
     762                 :            :                         port_id, RTE_UINT16);
     763                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_node_type_node_id =
     764                 :            :         TOKEN_NUM_INITIALIZER(
     765                 :            :                 struct cmd_show_port_tm_node_type_result,
     766                 :            :                         node_id, RTE_UINT32);
     767                 :            : 
     768                 :          0 : static void cmd_show_port_tm_node_type_parsed(void *parsed_result,
     769                 :            :         __rte_unused struct cmdline *cl,
     770                 :            :         __rte_unused void *data)
     771                 :            : {
     772                 :            :         struct cmd_show_port_tm_node_type_result *res = parsed_result;
     773                 :            :         struct rte_tm_error error;
     774                 :          0 :         uint32_t node_id = res->node_id;
     775                 :          0 :         portid_t port_id = res->port_id;
     776                 :          0 :         int ret, is_leaf = 0;
     777                 :            : 
     778                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     779                 :          0 :                 return;
     780                 :            : 
     781                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
     782                 :          0 :         ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
     783                 :          0 :         if (ret != 0) {
     784                 :          0 :                 print_err_msg(&error);
     785                 :          0 :                 return;
     786                 :            :         }
     787                 :            : 
     788                 :          0 :         if (is_leaf == 1)
     789                 :            :                 printf("leaf node\n");
     790                 :            :         else
     791                 :            :                 printf("nonleaf node\n");
     792                 :            : 
     793                 :            : }
     794                 :            : 
     795                 :            : cmdline_parse_inst_t cmd_show_port_tm_node_type = {
     796                 :            :         .f = cmd_show_port_tm_node_type_parsed,
     797                 :            :         .data = NULL,
     798                 :            :         .help_str = "Show port tm node type",
     799                 :            :         .tokens = {
     800                 :            :                 (void *)&cmd_show_port_tm_node_type_show,
     801                 :            :                 (void *)&cmd_show_port_tm_node_type_port,
     802                 :            :                 (void *)&cmd_show_port_tm_node_type_tm,
     803                 :            :                 (void *)&cmd_show_port_tm_node_type_node,
     804                 :            :                 (void *)&cmd_show_port_tm_node_type_type,
     805                 :            :                 (void *)&cmd_show_port_tm_node_type_port_id,
     806                 :            :                 (void *)&cmd_show_port_tm_node_type_node_id,
     807                 :            :                 NULL,
     808                 :            :         },
     809                 :            : };
     810                 :            : 
     811                 :            : /* *** Add Port TM Private Shaper Profile *** */
     812                 :            : struct cmd_add_port_tm_node_shaper_profile_result {
     813                 :            :         cmdline_fixed_string_t add;
     814                 :            :         cmdline_fixed_string_t port;
     815                 :            :         cmdline_fixed_string_t tm;
     816                 :            :         cmdline_fixed_string_t node;
     817                 :            :         cmdline_fixed_string_t shaper;
     818                 :            :         cmdline_fixed_string_t profile;
     819                 :            :         uint16_t port_id;
     820                 :            :         uint32_t shaper_id;
     821                 :            :         uint64_t cmit_tb_rate;
     822                 :            :         uint64_t cmit_tb_size;
     823                 :            :         uint64_t peak_tb_rate;
     824                 :            :         uint64_t peak_tb_size;
     825                 :            :         uint32_t pktlen_adjust;
     826                 :            :         int pkt_mode;
     827                 :            : };
     828                 :            : 
     829                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add =
     830                 :            :         TOKEN_STRING_INITIALIZER(
     831                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result, add, "add");
     832                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port =
     833                 :            :         TOKEN_STRING_INITIALIZER(
     834                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     835                 :            :                         port, "port");
     836                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm =
     837                 :            :         TOKEN_STRING_INITIALIZER(
     838                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     839                 :            :                         tm, "tm");
     840                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node =
     841                 :            :         TOKEN_STRING_INITIALIZER(
     842                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     843                 :            :                         node, "node");
     844                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper =
     845                 :            :         TOKEN_STRING_INITIALIZER(
     846                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     847                 :            :                         shaper, "shaper");
     848                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile =
     849                 :            :         TOKEN_STRING_INITIALIZER(
     850                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     851                 :            :                         profile, "profile");
     852                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id =
     853                 :            :         TOKEN_NUM_INITIALIZER(
     854                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     855                 :            :                         port_id, RTE_UINT16);
     856                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id =
     857                 :            :         TOKEN_NUM_INITIALIZER(
     858                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     859                 :            :                         shaper_id, RTE_UINT32);
     860                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_rate =
     861                 :            :         TOKEN_NUM_INITIALIZER(
     862                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     863                 :            :                         cmit_tb_rate, RTE_UINT64);
     864                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_size =
     865                 :            :         TOKEN_NUM_INITIALIZER(
     866                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     867                 :            :                         cmit_tb_size, RTE_UINT64);
     868                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_rate =
     869                 :            :         TOKEN_NUM_INITIALIZER(
     870                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     871                 :            :                         peak_tb_rate, RTE_UINT64);
     872                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_size =
     873                 :            :         TOKEN_NUM_INITIALIZER(
     874                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     875                 :            :                         peak_tb_size, RTE_UINT64);
     876                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust =
     877                 :            :         TOKEN_NUM_INITIALIZER(
     878                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     879                 :            :                         pktlen_adjust, RTE_UINT32);
     880                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_packet_mode =
     881                 :            :         TOKEN_NUM_INITIALIZER(
     882                 :            :                 struct cmd_add_port_tm_node_shaper_profile_result,
     883                 :            :                         pkt_mode, RTE_UINT32);
     884                 :            : 
     885                 :            : static int
     886                 :          0 : get_printable_rate(uint64_t rate, char *buffer, size_t size)
     887                 :            : {
     888                 :          0 :         if (rate >= 1000 * 1000 * 1000)
     889                 :          0 :                 return snprintf(buffer, size, "%.1fG", rate / (1000 * 1000 * 1000.0));
     890                 :          0 :         else if (rate >= 1000 * 1000)
     891                 :          0 :                 return snprintf(buffer, size, "%.1fM", rate / (1000 * 1000.0));
     892                 :          0 :         else if (rate >= 1000)
     893                 :          0 :                 return snprintf(buffer, size, "%.1fK", rate / 1000.0);
     894                 :            :         else
     895                 :          0 :                 return snprintf(buffer, size, "%"PRIu64, rate);
     896                 :            : }
     897                 :            : 
     898                 :          0 : static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
     899                 :            :         struct cmdline *cl,
     900                 :            :         __rte_unused void *data)
     901                 :            : {
     902                 :            :         struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result;
     903                 :            :         struct rte_tm_shaper_params sp;
     904                 :            :         struct rte_tm_error error;
     905                 :          0 :         uint32_t shaper_id = res->shaper_id;
     906                 :          0 :         uint32_t pkt_len_adjust = res->pktlen_adjust;
     907                 :          0 :         portid_t port_id = res->port_id;
     908                 :            :         char rate_str[20];
     909                 :            :         int ret;
     910                 :            : 
     911                 :          0 :         cmdline_printf(cl, "adding node shaper on port %u, with id %u\n", res->port_id, shaper_id);
     912                 :          0 :         get_printable_rate(res->cmit_tb_rate, rate_str, sizeof(rate_str));
     913                 :          0 :         cmdline_printf(cl, "# committed rate: %s, t.b. size: %"PRIu64"\n",
     914                 :            :                         rate_str, res->cmit_tb_size);
     915                 :            : 
     916                 :          0 :         get_printable_rate(res->peak_tb_rate, rate_str, sizeof(rate_str));
     917                 :          0 :         cmdline_printf(cl, "# peak rate: %s, t.b. size: %"PRIu64"\n",
     918                 :            :                         rate_str, res->peak_tb_size);
     919                 :          0 :         cmdline_printf(cl, "# pkt length adjust: %u\n", res->pktlen_adjust);
     920                 :          0 :         cmdline_printf(cl, "# packet mode: %s\n", res->pkt_mode ? "true" : "false (bytes mode)");
     921                 :            : 
     922                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     923                 :          0 :                 return;
     924                 :            : 
     925                 :            :         /* Private shaper profile params */
     926                 :            :         memset(&sp, 0, sizeof(struct rte_tm_shaper_params));
     927                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
     928                 :          0 :         sp.committed.rate = res->cmit_tb_rate;
     929                 :          0 :         sp.committed.size = res->cmit_tb_size;
     930                 :          0 :         sp.peak.rate = res->peak_tb_rate;
     931                 :          0 :         sp.peak.size = res->peak_tb_size;
     932                 :          0 :         sp.pkt_length_adjust = pkt_len_adjust;
     933                 :          0 :         sp.packet_mode = res->pkt_mode;
     934                 :            : 
     935                 :          0 :         ret = rte_tm_shaper_profile_add(port_id, shaper_id, &sp, &error);
     936                 :          0 :         if (ret != 0) {
     937                 :          0 :                 print_err_msg(&error);
     938                 :          0 :                 return;
     939                 :            :         }
     940                 :            : }
     941                 :            : 
     942                 :            : cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile = {
     943                 :            :         .f = cmd_add_port_tm_node_shaper_profile_parsed,
     944                 :            :         .data = NULL,
     945                 :            :         .help_str = "Add port tm node private shaper profile",
     946                 :            :         .tokens = {
     947                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_add,
     948                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_port,
     949                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_tm,
     950                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_node,
     951                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_shaper,
     952                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_profile,
     953                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_port_id,
     954                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_shaper_id,
     955                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_rate,
     956                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_size,
     957                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_rate,
     958                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_size,
     959                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust,
     960                 :            :                 (void *)&cmd_add_port_tm_node_shaper_profile_packet_mode,
     961                 :            :                 NULL,
     962                 :            :         },
     963                 :            : };
     964                 :            : 
     965                 :            : /* *** Delete Port TM Private Shaper Profile *** */
     966                 :            : struct cmd_del_port_tm_node_shaper_profile_result {
     967                 :            :         cmdline_fixed_string_t del;
     968                 :            :         cmdline_fixed_string_t port;
     969                 :            :         cmdline_fixed_string_t tm;
     970                 :            :         cmdline_fixed_string_t node;
     971                 :            :         cmdline_fixed_string_t shaper;
     972                 :            :         cmdline_fixed_string_t profile;
     973                 :            :         uint16_t port_id;
     974                 :            :         uint32_t shaper_id;
     975                 :            : };
     976                 :            : 
     977                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del =
     978                 :            :         TOKEN_STRING_INITIALIZER(
     979                 :            :                 struct cmd_del_port_tm_node_shaper_profile_result, del, "del");
     980                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port =
     981                 :            :         TOKEN_STRING_INITIALIZER(
     982                 :            :                 struct cmd_del_port_tm_node_shaper_profile_result,
     983                 :            :                         port, "port");
     984                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm =
     985                 :            :         TOKEN_STRING_INITIALIZER(
     986                 :            :                 struct cmd_del_port_tm_node_shaper_profile_result, tm, "tm");
     987                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node =
     988                 :            :         TOKEN_STRING_INITIALIZER(
     989                 :            :                 struct cmd_del_port_tm_node_shaper_profile_result,
     990                 :            :                         node, "node");
     991                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper =
     992                 :            :         TOKEN_STRING_INITIALIZER(
     993                 :            :                 struct cmd_del_port_tm_node_shaper_profile_result,
     994                 :            :                         shaper, "shaper");
     995                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile =
     996                 :            :         TOKEN_STRING_INITIALIZER(
     997                 :            :                 struct cmd_del_port_tm_node_shaper_profile_result,
     998                 :            :                         profile, "profile");
     999                 :            : static cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id =
    1000                 :            :         TOKEN_NUM_INITIALIZER(
    1001                 :            :                 struct cmd_del_port_tm_node_shaper_profile_result,
    1002                 :            :                         port_id, RTE_UINT16);
    1003                 :            : static cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id =
    1004                 :            :         TOKEN_NUM_INITIALIZER(
    1005                 :            :                 struct cmd_del_port_tm_node_shaper_profile_result,
    1006                 :            :                         shaper_id, RTE_UINT32);
    1007                 :            : 
    1008                 :          0 : static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result,
    1009                 :            :         __rte_unused struct cmdline *cl,
    1010                 :            :         __rte_unused void *data)
    1011                 :            : {
    1012                 :            :         struct cmd_del_port_tm_node_shaper_profile_result *res = parsed_result;
    1013                 :            :         struct rte_tm_error error;
    1014                 :          0 :         uint32_t shaper_id = res->shaper_id;
    1015                 :          0 :         portid_t port_id = res->port_id;
    1016                 :            :         int ret;
    1017                 :            : 
    1018                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1019                 :          0 :                 return;
    1020                 :            : 
    1021                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    1022                 :          0 :         ret = rte_tm_shaper_profile_delete(port_id, shaper_id, &error);
    1023                 :          0 :         if (ret != 0) {
    1024                 :          0 :                 print_err_msg(&error);
    1025                 :          0 :                 return;
    1026                 :            :         }
    1027                 :            : }
    1028                 :            : 
    1029                 :            : cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile = {
    1030                 :            :         .f = cmd_del_port_tm_node_shaper_profile_parsed,
    1031                 :            :         .data = NULL,
    1032                 :            :         .help_str = "Delete port tm node private shaper profile",
    1033                 :            :         .tokens = {
    1034                 :            :                 (void *)&cmd_del_port_tm_node_shaper_profile_del,
    1035                 :            :                 (void *)&cmd_del_port_tm_node_shaper_profile_port,
    1036                 :            :                 (void *)&cmd_del_port_tm_node_shaper_profile_tm,
    1037                 :            :                 (void *)&cmd_del_port_tm_node_shaper_profile_node,
    1038                 :            :                 (void *)&cmd_del_port_tm_node_shaper_profile_shaper,
    1039                 :            :                 (void *)&cmd_del_port_tm_node_shaper_profile_profile,
    1040                 :            :                 (void *)&cmd_del_port_tm_node_shaper_profile_port_id,
    1041                 :            :                 (void *)&cmd_del_port_tm_node_shaper_profile_shaper_id,
    1042                 :            :                 NULL,
    1043                 :            :         },
    1044                 :            : };
    1045                 :            : 
    1046                 :            : /* *** Add/Update Port TM shared Shaper *** */
    1047                 :            : struct cmd_add_port_tm_node_shared_shaper_result {
    1048                 :            :         cmdline_fixed_string_t cmd_type;
    1049                 :            :         cmdline_fixed_string_t port;
    1050                 :            :         cmdline_fixed_string_t tm;
    1051                 :            :         cmdline_fixed_string_t node;
    1052                 :            :         cmdline_fixed_string_t shared;
    1053                 :            :         cmdline_fixed_string_t shaper;
    1054                 :            :         uint16_t port_id;
    1055                 :            :         uint32_t shared_shaper_id;
    1056                 :            :         uint32_t shaper_profile_id;
    1057                 :            : };
    1058                 :            : 
    1059                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type =
    1060                 :            :         TOKEN_STRING_INITIALIZER(
    1061                 :            :                 struct cmd_add_port_tm_node_shared_shaper_result,
    1062                 :            :                         cmd_type, "add#set");
    1063                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port =
    1064                 :            :         TOKEN_STRING_INITIALIZER(
    1065                 :            :                 struct cmd_add_port_tm_node_shared_shaper_result, port, "port");
    1066                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm =
    1067                 :            :         TOKEN_STRING_INITIALIZER(
    1068                 :            :                 struct cmd_add_port_tm_node_shared_shaper_result, tm, "tm");
    1069                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node =
    1070                 :            :         TOKEN_STRING_INITIALIZER(
    1071                 :            :                 struct cmd_add_port_tm_node_shared_shaper_result, node, "node");
    1072                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared =
    1073                 :            :         TOKEN_STRING_INITIALIZER(
    1074                 :            :                 struct cmd_add_port_tm_node_shared_shaper_result,
    1075                 :            :                         shared, "shared");
    1076                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper =
    1077                 :            :         TOKEN_STRING_INITIALIZER(
    1078                 :            :                 struct cmd_add_port_tm_node_shared_shaper_result,
    1079                 :            :                         shaper, "shaper");
    1080                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id =
    1081                 :            :         TOKEN_NUM_INITIALIZER(
    1082                 :            :                 struct cmd_add_port_tm_node_shared_shaper_result,
    1083                 :            :                         port_id, RTE_UINT16);
    1084                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id =
    1085                 :            :         TOKEN_NUM_INITIALIZER(
    1086                 :            :                 struct cmd_add_port_tm_node_shared_shaper_result,
    1087                 :            :                         shared_shaper_id, RTE_UINT32);
    1088                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id =
    1089                 :            :         TOKEN_NUM_INITIALIZER(
    1090                 :            :                 struct cmd_add_port_tm_node_shared_shaper_result,
    1091                 :            :                         shaper_profile_id, RTE_UINT32);
    1092                 :            : 
    1093                 :          0 : static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result,
    1094                 :            :         __rte_unused struct cmdline *cl,
    1095                 :            :         __rte_unused void *data)
    1096                 :            : {
    1097                 :            :         struct cmd_add_port_tm_node_shared_shaper_result *res = parsed_result;
    1098                 :            :         struct rte_tm_error error;
    1099                 :          0 :         uint32_t shared_shaper_id = res->shared_shaper_id;
    1100                 :          0 :         uint32_t shaper_profile_id = res->shaper_profile_id;
    1101                 :          0 :         portid_t port_id = res->port_id;
    1102                 :            :         int ret;
    1103                 :            : 
    1104                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1105                 :          0 :                 return;
    1106                 :            : 
    1107                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    1108                 :            :         /* Command type: add */
    1109                 :          0 :         if ((strcmp(res->cmd_type, "add") == 0) &&
    1110                 :          0 :                 (port_is_started(port_id))) {
    1111                 :          0 :                 fprintf(stderr, " Port %u not stopped (error)\n", port_id);
    1112                 :          0 :                 return;
    1113                 :            :         }
    1114                 :            : 
    1115                 :            :         /* Command type: set (update) */
    1116                 :          0 :         if ((strcmp(res->cmd_type, "set") == 0) &&
    1117                 :          0 :                 (!port_is_started(port_id))) {
    1118                 :          0 :                 fprintf(stderr, " Port %u not started (error)\n", port_id);
    1119                 :          0 :                 return;
    1120                 :            :         }
    1121                 :            : 
    1122                 :          0 :         ret = rte_tm_shared_shaper_add_update(port_id, shared_shaper_id,
    1123                 :            :                 shaper_profile_id, &error);
    1124                 :          0 :         if (ret != 0) {
    1125                 :          0 :                 print_err_msg(&error);
    1126                 :          0 :                 return;
    1127                 :            :         }
    1128                 :            : }
    1129                 :            : 
    1130                 :            : cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper = {
    1131                 :            :         .f = cmd_add_port_tm_node_shared_shaper_parsed,
    1132                 :            :         .data = NULL,
    1133                 :            :         .help_str = "add/update port tm node shared shaper",
    1134                 :            :         .tokens = {
    1135                 :            :                 (void *)&cmd_add_port_tm_node_shared_shaper_cmd_type,
    1136                 :            :                 (void *)&cmd_add_port_tm_node_shared_shaper_port,
    1137                 :            :                 (void *)&cmd_add_port_tm_node_shared_shaper_tm,
    1138                 :            :                 (void *)&cmd_add_port_tm_node_shared_shaper_node,
    1139                 :            :                 (void *)&cmd_add_port_tm_node_shared_shaper_shared,
    1140                 :            :                 (void *)&cmd_add_port_tm_node_shared_shaper_shaper,
    1141                 :            :                 (void *)&cmd_add_port_tm_node_shared_shaper_port_id,
    1142                 :            :                 (void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id,
    1143                 :            :                 (void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id,
    1144                 :            :                 NULL,
    1145                 :            :         },
    1146                 :            : };
    1147                 :            : 
    1148                 :            : /* *** Delete Port TM shared Shaper *** */
    1149                 :            : struct cmd_del_port_tm_node_shared_shaper_result {
    1150                 :            :         cmdline_fixed_string_t del;
    1151                 :            :         cmdline_fixed_string_t port;
    1152                 :            :         cmdline_fixed_string_t tm;
    1153                 :            :         cmdline_fixed_string_t node;
    1154                 :            :         cmdline_fixed_string_t shared;
    1155                 :            :         cmdline_fixed_string_t shaper;
    1156                 :            :         uint16_t port_id;
    1157                 :            :         uint32_t shared_shaper_id;
    1158                 :            : };
    1159                 :            : 
    1160                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del =
    1161                 :            :         TOKEN_STRING_INITIALIZER(
    1162                 :            :                 struct cmd_del_port_tm_node_shared_shaper_result, del, "del");
    1163                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port =
    1164                 :            :         TOKEN_STRING_INITIALIZER(
    1165                 :            :                 struct cmd_del_port_tm_node_shared_shaper_result, port, "port");
    1166                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm =
    1167                 :            :         TOKEN_STRING_INITIALIZER(
    1168                 :            :                 struct cmd_del_port_tm_node_shared_shaper_result, tm, "tm");
    1169                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node =
    1170                 :            :         TOKEN_STRING_INITIALIZER(
    1171                 :            :                 struct cmd_del_port_tm_node_shared_shaper_result, node, "node");
    1172                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared =
    1173                 :            :         TOKEN_STRING_INITIALIZER(
    1174                 :            :                 struct cmd_del_port_tm_node_shared_shaper_result,
    1175                 :            :                         shared, "shared");
    1176                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper =
    1177                 :            :         TOKEN_STRING_INITIALIZER(
    1178                 :            :                 struct cmd_del_port_tm_node_shared_shaper_result,
    1179                 :            :                         shaper, "shaper");
    1180                 :            : static cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id =
    1181                 :            :         TOKEN_NUM_INITIALIZER(
    1182                 :            :                 struct cmd_del_port_tm_node_shared_shaper_result,
    1183                 :            :                         port_id, RTE_UINT16);
    1184                 :            : static cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id =
    1185                 :            :         TOKEN_NUM_INITIALIZER(
    1186                 :            :                 struct cmd_del_port_tm_node_shared_shaper_result,
    1187                 :            :                         shared_shaper_id, RTE_UINT32);
    1188                 :            : 
    1189                 :          0 : static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result,
    1190                 :            :         __rte_unused struct cmdline *cl,
    1191                 :            :         __rte_unused void *data)
    1192                 :            : {
    1193                 :            :         struct cmd_del_port_tm_node_shared_shaper_result *res = parsed_result;
    1194                 :            :         struct rte_tm_error error;
    1195                 :          0 :         uint32_t shared_shaper_id = res->shared_shaper_id;
    1196                 :          0 :         portid_t port_id = res->port_id;
    1197                 :            :         int ret;
    1198                 :            : 
    1199                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1200                 :          0 :                 return;
    1201                 :            : 
    1202                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    1203                 :          0 :         ret = rte_tm_shared_shaper_delete(port_id, shared_shaper_id, &error);
    1204                 :          0 :         if (ret != 0) {
    1205                 :          0 :                 print_err_msg(&error);
    1206                 :          0 :                 return;
    1207                 :            :         }
    1208                 :            : }
    1209                 :            : 
    1210                 :            : cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper = {
    1211                 :            :         .f = cmd_del_port_tm_node_shared_shaper_parsed,
    1212                 :            :         .data = NULL,
    1213                 :            :         .help_str = "delete port tm node shared shaper",
    1214                 :            :         .tokens = {
    1215                 :            :                 (void *)&cmd_del_port_tm_node_shared_shaper_del,
    1216                 :            :                 (void *)&cmd_del_port_tm_node_shared_shaper_port,
    1217                 :            :                 (void *)&cmd_del_port_tm_node_shared_shaper_tm,
    1218                 :            :                 (void *)&cmd_del_port_tm_node_shared_shaper_node,
    1219                 :            :                 (void *)&cmd_del_port_tm_node_shared_shaper_shared,
    1220                 :            :                 (void *)&cmd_del_port_tm_node_shared_shaper_shaper,
    1221                 :            :                 (void *)&cmd_del_port_tm_node_shared_shaper_port_id,
    1222                 :            :                 (void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id,
    1223                 :            :                 NULL,
    1224                 :            :         },
    1225                 :            : };
    1226                 :            : 
    1227                 :            : /* *** Add Port TM Node WRED Profile *** */
    1228                 :            : struct cmd_add_port_tm_node_wred_profile_result {
    1229                 :            :         cmdline_fixed_string_t add;
    1230                 :            :         cmdline_fixed_string_t port;
    1231                 :            :         cmdline_fixed_string_t tm;
    1232                 :            :         cmdline_fixed_string_t node;
    1233                 :            :         cmdline_fixed_string_t wred;
    1234                 :            :         cmdline_fixed_string_t profile;
    1235                 :            :         uint16_t port_id;
    1236                 :            :         uint32_t wred_profile_id;
    1237                 :            :         cmdline_fixed_string_t color_g;
    1238                 :            :         uint64_t min_th_g;
    1239                 :            :         uint64_t max_th_g;
    1240                 :            :         uint16_t maxp_inv_g;
    1241                 :            :         uint16_t wq_log2_g;
    1242                 :            :         cmdline_fixed_string_t color_y;
    1243                 :            :         uint64_t min_th_y;
    1244                 :            :         uint64_t max_th_y;
    1245                 :            :         uint16_t maxp_inv_y;
    1246                 :            :         uint16_t wq_log2_y;
    1247                 :            :         cmdline_fixed_string_t color_r;
    1248                 :            :         uint64_t min_th_r;
    1249                 :            :         uint64_t max_th_r;
    1250                 :            :         uint16_t maxp_inv_r;
    1251                 :            :         uint16_t wq_log2_r;
    1252                 :            : };
    1253                 :            : 
    1254                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add =
    1255                 :            :         TOKEN_STRING_INITIALIZER(
    1256                 :            :                 struct cmd_add_port_tm_node_wred_profile_result, add, "add");
    1257                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port =
    1258                 :            :         TOKEN_STRING_INITIALIZER(
    1259                 :            :                 struct cmd_add_port_tm_node_wred_profile_result, port, "port");
    1260                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm =
    1261                 :            :         TOKEN_STRING_INITIALIZER(
    1262                 :            :                 struct cmd_add_port_tm_node_wred_profile_result, tm, "tm");
    1263                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node =
    1264                 :            :         TOKEN_STRING_INITIALIZER(
    1265                 :            :                 struct cmd_add_port_tm_node_wred_profile_result, node, "node");
    1266                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred =
    1267                 :            :         TOKEN_STRING_INITIALIZER(
    1268                 :            :                 struct cmd_add_port_tm_node_wred_profile_result, wred, "wred");
    1269                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile =
    1270                 :            :         TOKEN_STRING_INITIALIZER(
    1271                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1272                 :            :                         profile, "profile");
    1273                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id =
    1274                 :            :         TOKEN_NUM_INITIALIZER(
    1275                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1276                 :            :                         port_id, RTE_UINT16);
    1277                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id =
    1278                 :            :         TOKEN_NUM_INITIALIZER(
    1279                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1280                 :            :                         wred_profile_id, RTE_UINT32);
    1281                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g =
    1282                 :            :         TOKEN_STRING_INITIALIZER(
    1283                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1284                 :            :                         color_g, "G#g");
    1285                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g =
    1286                 :            :         TOKEN_NUM_INITIALIZER(
    1287                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1288                 :            :                         min_th_g, RTE_UINT64);
    1289                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g =
    1290                 :            :         TOKEN_NUM_INITIALIZER(
    1291                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1292                 :            :                         max_th_g, RTE_UINT64);
    1293                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g =
    1294                 :            :         TOKEN_NUM_INITIALIZER(
    1295                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1296                 :            :                         maxp_inv_g, RTE_UINT16);
    1297                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g =
    1298                 :            :         TOKEN_NUM_INITIALIZER(
    1299                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1300                 :            :                         wq_log2_g, RTE_UINT16);
    1301                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y =
    1302                 :            :         TOKEN_STRING_INITIALIZER(
    1303                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1304                 :            :                         color_y, "Y#y");
    1305                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y =
    1306                 :            :         TOKEN_NUM_INITIALIZER(
    1307                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1308                 :            :                         min_th_y, RTE_UINT64);
    1309                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y =
    1310                 :            :         TOKEN_NUM_INITIALIZER(
    1311                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1312                 :            :                         max_th_y, RTE_UINT64);
    1313                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y =
    1314                 :            :         TOKEN_NUM_INITIALIZER(
    1315                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1316                 :            :                         maxp_inv_y, RTE_UINT16);
    1317                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y =
    1318                 :            :         TOKEN_NUM_INITIALIZER(
    1319                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1320                 :            :                         wq_log2_y, RTE_UINT16);
    1321                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r =
    1322                 :            :         TOKEN_STRING_INITIALIZER(
    1323                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1324                 :            :                         color_r, "R#r");
    1325                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r =
    1326                 :            :         TOKEN_NUM_INITIALIZER(
    1327                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1328                 :            :                         min_th_r, RTE_UINT64);
    1329                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r =
    1330                 :            :         TOKEN_NUM_INITIALIZER(
    1331                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1332                 :            :                         max_th_r, RTE_UINT64);
    1333                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r =
    1334                 :            :         TOKEN_NUM_INITIALIZER(
    1335                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1336                 :            :                         maxp_inv_r, RTE_UINT16);
    1337                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r =
    1338                 :            :         TOKEN_NUM_INITIALIZER(
    1339                 :            :                 struct cmd_add_port_tm_node_wred_profile_result,
    1340                 :            :                         wq_log2_r, RTE_UINT16);
    1341                 :            : 
    1342                 :            : 
    1343                 :          0 : static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
    1344                 :            :         __rte_unused struct cmdline *cl,
    1345                 :            :         __rte_unused void *data)
    1346                 :            : {
    1347                 :            :         struct cmd_add_port_tm_node_wred_profile_result *res = parsed_result;
    1348                 :            :         struct rte_tm_wred_params wp;
    1349                 :            :         enum rte_color color;
    1350                 :            :         struct rte_tm_error error;
    1351                 :          0 :         uint32_t wred_profile_id = res->wred_profile_id;
    1352                 :          0 :         portid_t port_id = res->port_id;
    1353                 :            :         int ret;
    1354                 :            : 
    1355                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1356                 :          0 :                 return;
    1357                 :            : 
    1358                 :            :         memset(&wp, 0, sizeof(struct rte_tm_wred_params));
    1359                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    1360                 :            : 
    1361                 :            :         /* WRED Params  (Green Color)*/
    1362                 :            :         color = RTE_COLOR_GREEN;
    1363                 :          0 :         wp.red_params[color].min_th = res->min_th_g;
    1364                 :          0 :         wp.red_params[color].max_th = res->max_th_g;
    1365                 :          0 :         wp.red_params[color].maxp_inv = res->maxp_inv_g;
    1366                 :          0 :         wp.red_params[color].wq_log2 = res->wq_log2_g;
    1367                 :            : 
    1368                 :            : 
    1369                 :            :         /* WRED Params  (Yellow Color)*/
    1370                 :            :         color = RTE_COLOR_YELLOW;
    1371                 :          0 :         wp.red_params[color].min_th = res->min_th_y;
    1372                 :          0 :         wp.red_params[color].max_th = res->max_th_y;
    1373                 :          0 :         wp.red_params[color].maxp_inv = res->maxp_inv_y;
    1374                 :          0 :         wp.red_params[color].wq_log2 = res->wq_log2_y;
    1375                 :            : 
    1376                 :            :         /* WRED Params  (Red Color)*/
    1377                 :            :         color = RTE_COLOR_RED;
    1378                 :          0 :         wp.red_params[color].min_th = res->min_th_r;
    1379                 :          0 :         wp.red_params[color].max_th = res->max_th_r;
    1380                 :          0 :         wp.red_params[color].maxp_inv = res->maxp_inv_r;
    1381                 :          0 :         wp.red_params[color].wq_log2 = res->wq_log2_r;
    1382                 :            : 
    1383                 :          0 :         ret = rte_tm_wred_profile_add(port_id, wred_profile_id, &wp, &error);
    1384                 :          0 :         if (ret != 0) {
    1385                 :          0 :                 print_err_msg(&error);
    1386                 :          0 :                 return;
    1387                 :            :         }
    1388                 :            : }
    1389                 :            : 
    1390                 :            : cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile = {
    1391                 :            :         .f = cmd_add_port_tm_node_wred_profile_parsed,
    1392                 :            :         .data = NULL,
    1393                 :            :         .help_str = "Add port tm node wred profile",
    1394                 :            :         .tokens = {
    1395                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_add,
    1396                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_port,
    1397                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_tm,
    1398                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_node,
    1399                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_wred,
    1400                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_profile,
    1401                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_port_id,
    1402                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id,
    1403                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_color_g,
    1404                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_min_th_g,
    1405                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_max_th_g,
    1406                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g,
    1407                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g,
    1408                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_color_y,
    1409                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_min_th_y,
    1410                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_max_th_y,
    1411                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y,
    1412                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y,
    1413                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_color_r,
    1414                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_min_th_r,
    1415                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_max_th_r,
    1416                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r,
    1417                 :            :                 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r,
    1418                 :            :                 NULL,
    1419                 :            :         },
    1420                 :            : };
    1421                 :            : 
    1422                 :            : /* *** Delete Port TM node WRED Profile *** */
    1423                 :            : struct cmd_del_port_tm_node_wred_profile_result {
    1424                 :            :         cmdline_fixed_string_t del;
    1425                 :            :         cmdline_fixed_string_t port;
    1426                 :            :         cmdline_fixed_string_t tm;
    1427                 :            :         cmdline_fixed_string_t node;
    1428                 :            :         cmdline_fixed_string_t wred;
    1429                 :            :         cmdline_fixed_string_t profile;
    1430                 :            :         uint16_t port_id;
    1431                 :            :         uint32_t wred_profile_id;
    1432                 :            : };
    1433                 :            : 
    1434                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del =
    1435                 :            :         TOKEN_STRING_INITIALIZER(
    1436                 :            :                 struct cmd_del_port_tm_node_wred_profile_result, del, "del");
    1437                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port =
    1438                 :            :         TOKEN_STRING_INITIALIZER(
    1439                 :            :                 struct cmd_del_port_tm_node_wred_profile_result, port, "port");
    1440                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm =
    1441                 :            :         TOKEN_STRING_INITIALIZER(
    1442                 :            :                 struct cmd_del_port_tm_node_wred_profile_result, tm, "tm");
    1443                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node =
    1444                 :            :         TOKEN_STRING_INITIALIZER(
    1445                 :            :                 struct cmd_del_port_tm_node_wred_profile_result, node, "node");
    1446                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred =
    1447                 :            :         TOKEN_STRING_INITIALIZER(
    1448                 :            :                 struct cmd_del_port_tm_node_wred_profile_result, wred, "wred");
    1449                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile =
    1450                 :            :         TOKEN_STRING_INITIALIZER(
    1451                 :            :                 struct cmd_del_port_tm_node_wred_profile_result,
    1452                 :            :                         profile, "profile");
    1453                 :            : static cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id =
    1454                 :            :         TOKEN_NUM_INITIALIZER(
    1455                 :            :                 struct cmd_del_port_tm_node_wred_profile_result,
    1456                 :            :                         port_id, RTE_UINT16);
    1457                 :            : static cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id =
    1458                 :            :         TOKEN_NUM_INITIALIZER(
    1459                 :            :                 struct cmd_del_port_tm_node_wred_profile_result,
    1460                 :            :                         wred_profile_id, RTE_UINT32);
    1461                 :            : 
    1462                 :          0 : static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result,
    1463                 :            :         __rte_unused struct cmdline *cl,
    1464                 :            :         __rte_unused void *data)
    1465                 :            : {
    1466                 :            :         struct cmd_del_port_tm_node_wred_profile_result *res = parsed_result;
    1467                 :            :         struct rte_tm_error error;
    1468                 :          0 :         uint32_t wred_profile_id = res->wred_profile_id;
    1469                 :          0 :         portid_t port_id = res->port_id;
    1470                 :            :         int ret;
    1471                 :            : 
    1472                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1473                 :          0 :                 return;
    1474                 :            : 
    1475                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    1476                 :          0 :         ret = rte_tm_wred_profile_delete(port_id, wred_profile_id, &error);
    1477                 :          0 :         if (ret != 0) {
    1478                 :          0 :                 print_err_msg(&error);
    1479                 :          0 :                 return;
    1480                 :            :         }
    1481                 :            : }
    1482                 :            : 
    1483                 :            : cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile = {
    1484                 :            :         .f = cmd_del_port_tm_node_wred_profile_parsed,
    1485                 :            :         .data = NULL,
    1486                 :            :         .help_str = "Delete port tm node wred profile",
    1487                 :            :         .tokens = {
    1488                 :            :                 (void *)&cmd_del_port_tm_node_wred_profile_del,
    1489                 :            :                 (void *)&cmd_del_port_tm_node_wred_profile_port,
    1490                 :            :                 (void *)&cmd_del_port_tm_node_wred_profile_tm,
    1491                 :            :                 (void *)&cmd_del_port_tm_node_wred_profile_node,
    1492                 :            :                 (void *)&cmd_del_port_tm_node_wred_profile_wred,
    1493                 :            :                 (void *)&cmd_del_port_tm_node_wred_profile_profile,
    1494                 :            :                 (void *)&cmd_del_port_tm_node_wred_profile_port_id,
    1495                 :            :                 (void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id,
    1496                 :            :                 NULL,
    1497                 :            :         },
    1498                 :            : };
    1499                 :            : 
    1500                 :            : /* *** Update Port TM Node Shaper profile *** */
    1501                 :            : struct cmd_set_port_tm_node_shaper_profile_result {
    1502                 :            :         cmdline_fixed_string_t set;
    1503                 :            :         cmdline_fixed_string_t port;
    1504                 :            :         cmdline_fixed_string_t tm;
    1505                 :            :         cmdline_fixed_string_t node;
    1506                 :            :         cmdline_fixed_string_t shaper;
    1507                 :            :         cmdline_fixed_string_t profile;
    1508                 :            :         uint16_t port_id;
    1509                 :            :         uint32_t node_id;
    1510                 :            :         uint32_t shaper_profile_id;
    1511                 :            : };
    1512                 :            : 
    1513                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set =
    1514                 :            :         TOKEN_STRING_INITIALIZER(
    1515                 :            :                 struct cmd_set_port_tm_node_shaper_profile_result, set, "set");
    1516                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port =
    1517                 :            :         TOKEN_STRING_INITIALIZER(
    1518                 :            :                 struct cmd_set_port_tm_node_shaper_profile_result,
    1519                 :            :                         port, "port");
    1520                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_tm =
    1521                 :            :         TOKEN_STRING_INITIALIZER(
    1522                 :            :                 struct cmd_set_port_tm_node_shaper_profile_result, tm, "tm");
    1523                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node =
    1524                 :            :         TOKEN_STRING_INITIALIZER(
    1525                 :            :                 struct cmd_set_port_tm_node_shaper_profile_result,
    1526                 :            :                         node, "node");
    1527                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper =
    1528                 :            :         TOKEN_STRING_INITIALIZER(
    1529                 :            :                 struct cmd_set_port_tm_node_shaper_profile_result,
    1530                 :            :                         shaper, "shaper");
    1531                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile =
    1532                 :            :         TOKEN_STRING_INITIALIZER(
    1533                 :            :                 struct cmd_set_port_tm_node_shaper_profile_result,
    1534                 :            :                         profile, "profile");
    1535                 :            : static cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id =
    1536                 :            :         TOKEN_NUM_INITIALIZER(
    1537                 :            :                 struct cmd_set_port_tm_node_shaper_profile_result,
    1538                 :            :                         port_id, RTE_UINT16);
    1539                 :            : static cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id =
    1540                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result,
    1541                 :            :                 node_id, RTE_UINT32);
    1542                 :            : static cmdline_parse_token_num_t
    1543                 :            :         cmd_set_port_tm_node_shaper_shaper_profile_profile_id =
    1544                 :            :                 TOKEN_NUM_INITIALIZER(
    1545                 :            :                         struct cmd_set_port_tm_node_shaper_profile_result,
    1546                 :            :                         shaper_profile_id, RTE_UINT32);
    1547                 :            : 
    1548                 :          0 : static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result,
    1549                 :            :         __rte_unused struct cmdline *cl,
    1550                 :            :         __rte_unused void *data)
    1551                 :            : {
    1552                 :            :         struct cmd_set_port_tm_node_shaper_profile_result *res = parsed_result;
    1553                 :            :         struct rte_tm_error error;
    1554                 :          0 :         uint32_t node_id = res->node_id;
    1555                 :          0 :         uint32_t shaper_profile_id = res->shaper_profile_id;
    1556                 :          0 :         portid_t port_id = res->port_id;
    1557                 :            :         int ret;
    1558                 :            : 
    1559                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1560                 :          0 :                 return;
    1561                 :            : 
    1562                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    1563                 :            :         /* Port status */
    1564                 :          0 :         if (!port_is_started(port_id)) {
    1565                 :          0 :                 fprintf(stderr, " Port %u not started (error)\n", port_id);
    1566                 :          0 :                 return;
    1567                 :            :         }
    1568                 :            : 
    1569                 :          0 :         ret = rte_tm_node_shaper_update(port_id, node_id,
    1570                 :            :                 shaper_profile_id, &error);
    1571                 :          0 :         if (ret != 0) {
    1572                 :          0 :                 print_err_msg(&error);
    1573                 :          0 :                 return;
    1574                 :            :         }
    1575                 :            : }
    1576                 :            : 
    1577                 :            : cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile = {
    1578                 :            :         .f = cmd_set_port_tm_node_shaper_profile_parsed,
    1579                 :            :         .data = NULL,
    1580                 :            :         .help_str = "Set port tm node shaper profile",
    1581                 :            :         .tokens = {
    1582                 :            :                 (void *)&cmd_set_port_tm_node_shaper_profile_set,
    1583                 :            :                 (void *)&cmd_set_port_tm_node_shaper_profile_port,
    1584                 :            :                 (void *)&cmd_set_port_tm_node_shaper_profile_tm,
    1585                 :            :                 (void *)&cmd_set_port_tm_node_shaper_profile_node,
    1586                 :            :                 (void *)&cmd_set_port_tm_node_shaper_profile_shaper,
    1587                 :            :                 (void *)&cmd_set_port_tm_node_shaper_profile_profile,
    1588                 :            :                 (void *)&cmd_set_port_tm_node_shaper_profile_port_id,
    1589                 :            :                 (void *)&cmd_set_port_tm_node_shaper_profile_node_id,
    1590                 :            :                 (void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id,
    1591                 :            :                 NULL,
    1592                 :            :         },
    1593                 :            : };
    1594                 :            : 
    1595                 :            : /* *** Add Port TM nonleaf node *** */
    1596                 :            : struct cmd_add_port_tm_nonleaf_node_result {
    1597                 :            :         cmdline_fixed_string_t add;
    1598                 :            :         cmdline_fixed_string_t port;
    1599                 :            :         cmdline_fixed_string_t tm;
    1600                 :            :         cmdline_fixed_string_t nonleaf;
    1601                 :            :         cmdline_fixed_string_t node;
    1602                 :            :         uint16_t port_id;
    1603                 :            :         uint32_t node_id;
    1604                 :            :         int32_t parent_node_id;
    1605                 :            :         uint32_t priority;
    1606                 :            :         uint32_t weight;
    1607                 :            :         uint32_t level_id;
    1608                 :            :         int32_t shaper_profile_id;
    1609                 :            :         uint32_t n_sp_priorities;
    1610                 :            :         uint64_t stats_mask;
    1611                 :            :         cmdline_multi_string_t multi_shared_shaper_id;
    1612                 :            : };
    1613                 :            : 
    1614                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add =
    1615                 :            :         TOKEN_STRING_INITIALIZER(
    1616                 :            :                 struct cmd_add_port_tm_nonleaf_node_result, add, "add");
    1617                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port =
    1618                 :            :         TOKEN_STRING_INITIALIZER(
    1619                 :            :                 struct cmd_add_port_tm_nonleaf_node_result, port, "port");
    1620                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm =
    1621                 :            :         TOKEN_STRING_INITIALIZER(
    1622                 :            :                 struct cmd_add_port_tm_nonleaf_node_result, tm, "tm");
    1623                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf =
    1624                 :            :         TOKEN_STRING_INITIALIZER(
    1625                 :            :                 struct cmd_add_port_tm_nonleaf_node_result, nonleaf, "nonleaf");
    1626                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node =
    1627                 :            :         TOKEN_STRING_INITIALIZER(
    1628                 :            :                 struct cmd_add_port_tm_nonleaf_node_result, node, "node");
    1629                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id =
    1630                 :            :         TOKEN_NUM_INITIALIZER(
    1631                 :            :                 struct cmd_add_port_tm_nonleaf_node_result,
    1632                 :            :                  port_id, RTE_UINT16);
    1633                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_id =
    1634                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
    1635                 :            :                  node_id, RTE_UINT32);
    1636                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_parent_node_id =
    1637                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
    1638                 :            :                  parent_node_id, RTE_INT32);
    1639                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority =
    1640                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
    1641                 :            :                  priority, RTE_UINT32);
    1642                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight =
    1643                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
    1644                 :            :                  weight, RTE_UINT32);
    1645                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =
    1646                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
    1647                 :            :                  level_id, RTE_UINT32);
    1648                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id =
    1649                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
    1650                 :            :                  shaper_profile_id, RTE_INT32);
    1651                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =
    1652                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
    1653                 :            :                  n_sp_priorities, RTE_UINT32);
    1654                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask =
    1655                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
    1656                 :            :                  stats_mask, RTE_UINT64);
    1657                 :            : static cmdline_parse_token_string_t
    1658                 :            :         cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id =
    1659                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
    1660                 :            :                  multi_shared_shaper_id, TOKEN_STRING_MULTI);
    1661                 :            : 
    1662                 :          0 : static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
    1663                 :            :         struct cmdline *cl,
    1664                 :            :         __rte_unused void *data)
    1665                 :            : {
    1666                 :            :         struct cmd_add_port_tm_nonleaf_node_result *res = parsed_result;
    1667                 :            :         struct rte_tm_error error;
    1668                 :            :         struct rte_tm_node_params np;
    1669                 :            :         uint32_t *shared_shaper_id;
    1670                 :          0 :         uint32_t parent_node_id, n_shared_shapers = 0;
    1671                 :          0 :         char *s_str = res->multi_shared_shaper_id;
    1672                 :          0 :         portid_t port_id = res->port_id;
    1673                 :            :         int ret;
    1674                 :            : 
    1675                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1676                 :          0 :                 return;
    1677                 :            : 
    1678                 :            :         memset(&np, 0, sizeof(struct rte_tm_node_params));
    1679                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    1680                 :            : 
    1681                 :            :         /* Node parameters */
    1682                 :          0 :         if (res->parent_node_id < 0)
    1683                 :            :                 parent_node_id = UINT32_MAX;
    1684                 :            :         else
    1685                 :          0 :                 parent_node_id = res->parent_node_id;
    1686                 :            : 
    1687                 :            :         if (parent_node_id != UINT32_MAX)
    1688                 :          0 :                 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                 :          0 :                 cmdline_printf(cl, "adding node on port %u, with id %u as root node\n",
    1692                 :            :                                 port_id, res->node_id);
    1693                 :          0 :         cmdline_printf(cl, "# priority: %u\n", res->priority);
    1694                 :          0 :         cmdline_printf(cl, "# weight: %u\n", res->weight);
    1695                 :          0 :         cmdline_printf(cl, "# level_id: %u\n", res->level_id);
    1696                 :          0 :         cmdline_printf(cl, "# shaper_profile_id: %d\n", res->shaper_profile_id);
    1697                 :          0 :         cmdline_printf(cl, "# num SP priorities: %u\n", res->n_sp_priorities);
    1698                 :          0 :         cmdline_printf(cl, "# stats_mask: %"PRIx64"\n", res->stats_mask);
    1699                 :          0 :         cmdline_printf(cl, "# shared shapers: '%s'\n", s_str);
    1700                 :            : 
    1701                 :          0 :         shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
    1702                 :            :                 sizeof(uint32_t));
    1703                 :          0 :         if (shared_shaper_id == NULL) {
    1704                 :          0 :                 fprintf(stderr,
    1705                 :            :                         " Memory not allocated for shared shapers (error)\n");
    1706                 :          0 :                 return;
    1707                 :            :         }
    1708                 :            : 
    1709                 :            :         /* Parse multi shared shaper id string */
    1710                 :          0 :         ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
    1711                 :          0 :         if (ret) {
    1712                 :          0 :                 fprintf(stderr, " Shared shapers params string parse error\n");
    1713                 :          0 :                 free(shared_shaper_id);
    1714                 :          0 :                 return;
    1715                 :            :         }
    1716                 :            : 
    1717                 :          0 :         if (res->shaper_profile_id < 0)
    1718                 :          0 :                 np.shaper_profile_id = UINT32_MAX;
    1719                 :            :         else
    1720                 :          0 :                 np.shaper_profile_id = res->shaper_profile_id;
    1721                 :            : 
    1722                 :          0 :         np.n_shared_shapers = n_shared_shapers;
    1723                 :          0 :         if (np.n_shared_shapers) {
    1724                 :          0 :                 np.shared_shaper_id = &shared_shaper_id[0];
    1725                 :            :         } else {
    1726                 :          0 :                 free(shared_shaper_id);
    1727                 :            :                 shared_shaper_id = NULL;
    1728                 :            :         }
    1729                 :            : 
    1730                 :          0 :         np.nonleaf.n_sp_priorities = res->n_sp_priorities;
    1731                 :          0 :         np.stats_mask = res->stats_mask;
    1732                 :          0 :         np.nonleaf.wfq_weight_mode = NULL;
    1733                 :            : 
    1734                 :          0 :         ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
    1735                 :            :                                 res->priority, res->weight, res->level_id,
    1736                 :            :                                 &np, &error);
    1737                 :          0 :         if (ret != 0) {
    1738                 :          0 :                 print_err_msg(&error);
    1739                 :          0 :                 free(shared_shaper_id);
    1740                 :          0 :                 return;
    1741                 :            :         }
    1742                 :            : }
    1743                 :            : 
    1744                 :            : cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node = {
    1745                 :            :         .f = cmd_add_port_tm_nonleaf_node_parsed,
    1746                 :            :         .data = NULL,
    1747                 :            :         .help_str = "Add port tm nonleaf node",
    1748                 :            :         .tokens = {
    1749                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_add,
    1750                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_port,
    1751                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_tm,
    1752                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_nonleaf,
    1753                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_node,
    1754                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_port_id,
    1755                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_node_id,
    1756                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_parent_node_id,
    1757                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_priority,
    1758                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_weight,
    1759                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_level_id,
    1760                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id,
    1761                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities,
    1762                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_stats_mask,
    1763                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id,
    1764                 :            :                 NULL,
    1765                 :            :         },
    1766                 :            : };
    1767                 :            : 
    1768                 :            : /* *** Add Port TM nonleaf node pkt mode *** */
    1769                 :            : struct cmd_add_port_tm_nonleaf_node_pmode_result {
    1770                 :            :         cmdline_fixed_string_t add;
    1771                 :            :         cmdline_fixed_string_t port;
    1772                 :            :         cmdline_fixed_string_t tm;
    1773                 :            :         cmdline_fixed_string_t nonleaf;
    1774                 :            :         cmdline_fixed_string_t node;
    1775                 :            :         uint16_t port_id;
    1776                 :            :         uint32_t node_id;
    1777                 :            :         int32_t parent_node_id;
    1778                 :            :         uint32_t priority;
    1779                 :            :         uint32_t weight;
    1780                 :            :         uint32_t level_id;
    1781                 :            :         int32_t shaper_profile_id;
    1782                 :            :         uint32_t n_sp_priorities;
    1783                 :            :         uint64_t stats_mask;
    1784                 :            :         cmdline_multi_string_t multi_shared_shaper_id;
    1785                 :            : };
    1786                 :            : 
    1787                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_add =
    1788                 :            :         TOKEN_STRING_INITIALIZER(
    1789                 :            :                 struct cmd_add_port_tm_nonleaf_node_pmode_result, add, "add");
    1790                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_port =
    1791                 :            :         TOKEN_STRING_INITIALIZER(
    1792                 :            :                 struct cmd_add_port_tm_nonleaf_node_pmode_result, port, "port");
    1793                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_tm =
    1794                 :            :         TOKEN_STRING_INITIALIZER(
    1795                 :            :                 struct cmd_add_port_tm_nonleaf_node_pmode_result, tm, "tm");
    1796                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_nonleaf =
    1797                 :            :         TOKEN_STRING_INITIALIZER(
    1798                 :            :                 struct cmd_add_port_tm_nonleaf_node_pmode_result, nonleaf, "nonleaf");
    1799                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_node =
    1800                 :            :         TOKEN_STRING_INITIALIZER(
    1801                 :            :                 struct cmd_add_port_tm_nonleaf_node_pmode_result, node, "node");
    1802                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_pktmode =
    1803                 :            :         TOKEN_STRING_INITIALIZER(
    1804                 :            :                 struct cmd_add_port_tm_nonleaf_node_pmode_result, node, "pktmode");
    1805                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_port_id =
    1806                 :            :         TOKEN_NUM_INITIALIZER(
    1807                 :            :                 struct cmd_add_port_tm_nonleaf_node_pmode_result,
    1808                 :            :                  port_id, RTE_UINT16);
    1809                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_node_id =
    1810                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
    1811                 :            :                  node_id, RTE_UINT32);
    1812                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_parent_node_id =
    1813                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
    1814                 :            :                  parent_node_id, RTE_INT32);
    1815                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_priority =
    1816                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
    1817                 :            :                  priority, RTE_UINT32);
    1818                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_weight =
    1819                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
    1820                 :            :                  weight, RTE_UINT32);
    1821                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_level_id =
    1822                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
    1823                 :            :                  level_id, RTE_UINT32);
    1824                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_shaper_profile_id =
    1825                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
    1826                 :            :                  shaper_profile_id, RTE_INT32);
    1827                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_n_sp_priorities =
    1828                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
    1829                 :            :                  n_sp_priorities, RTE_UINT32);
    1830                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_stats_mask =
    1831                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
    1832                 :            :                  stats_mask, RTE_UINT64);
    1833                 :            : static cmdline_parse_token_string_t
    1834                 :            :         cmd_add_port_tm_nonleaf_node_pmode_multi_shrd_shpr_id =
    1835                 :            :         TOKEN_STRING_INITIALIZER(
    1836                 :            :                         struct cmd_add_port_tm_nonleaf_node_pmode_result,
    1837                 :            :                         multi_shared_shaper_id, TOKEN_STRING_MULTI);
    1838                 :            : 
    1839                 :          0 : static void cmd_add_port_tm_nonleaf_node_pmode_parsed(void *parsed_result,
    1840                 :            :         __rte_unused struct cmdline *cl,
    1841                 :            :         __rte_unused void *data)
    1842                 :            : {
    1843                 :            :         struct cmd_add_port_tm_nonleaf_node_pmode_result *res = parsed_result;
    1844                 :          0 :         uint32_t parent_node_id, n_shared_shapers = 0;
    1845                 :          0 :         char *s_str = res->multi_shared_shaper_id;
    1846                 :          0 :         portid_t port_id = res->port_id;
    1847                 :            :         struct rte_tm_node_params np;
    1848                 :            :         int *wfq_weight_mode = NULL;
    1849                 :            :         uint32_t *shared_shaper_id;
    1850                 :            :         struct rte_tm_error error;
    1851                 :            :         int ret;
    1852                 :            : 
    1853                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1854                 :          0 :                 return;
    1855                 :            : 
    1856                 :            :         memset(&np, 0, sizeof(struct rte_tm_node_params));
    1857                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    1858                 :            : 
    1859                 :            :         /* Node parameters */
    1860                 :          0 :         if (res->parent_node_id < 0)
    1861                 :            :                 parent_node_id = UINT32_MAX;
    1862                 :            :         else
    1863                 :          0 :                 parent_node_id = res->parent_node_id;
    1864                 :            : 
    1865                 :          0 :         shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
    1866                 :            :                 sizeof(uint32_t));
    1867                 :          0 :         if (shared_shaper_id == NULL) {
    1868                 :          0 :                 fprintf(stderr,
    1869                 :            :                         " Memory not allocated for shared shapers (error)\n");
    1870                 :          0 :                 return;
    1871                 :            :         }
    1872                 :            : 
    1873                 :            :         /* Parse multi shared shaper id string */
    1874                 :          0 :         ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
    1875                 :          0 :         if (ret) {
    1876                 :          0 :                 fprintf(stderr, " Shared shapers params string parse error\n");
    1877                 :          0 :                 free(shared_shaper_id);
    1878                 :          0 :                 return;
    1879                 :            :         }
    1880                 :            : 
    1881                 :          0 :         if (res->shaper_profile_id < 0)
    1882                 :          0 :                 np.shaper_profile_id = UINT32_MAX;
    1883                 :            :         else
    1884                 :          0 :                 np.shaper_profile_id = res->shaper_profile_id;
    1885                 :            : 
    1886                 :          0 :         np.n_shared_shapers = n_shared_shapers;
    1887                 :          0 :         if (np.n_shared_shapers) {
    1888                 :          0 :                 np.shared_shaper_id = &shared_shaper_id[0];
    1889                 :            :         } else {
    1890                 :          0 :                 free(shared_shaper_id);
    1891                 :            :                 shared_shaper_id = NULL;
    1892                 :            :         }
    1893                 :            : 
    1894                 :          0 :         if (res->n_sp_priorities)
    1895                 :          0 :                 wfq_weight_mode = calloc(res->n_sp_priorities, sizeof(int));
    1896                 :          0 :         np.nonleaf.n_sp_priorities = res->n_sp_priorities;
    1897                 :          0 :         np.stats_mask = res->stats_mask;
    1898                 :          0 :         np.nonleaf.wfq_weight_mode = wfq_weight_mode;
    1899                 :            : 
    1900                 :          0 :         ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
    1901                 :            :                                 res->priority, res->weight, res->level_id,
    1902                 :            :                                 &np, &error);
    1903                 :          0 :         if (ret != 0) {
    1904                 :          0 :                 print_err_msg(&error);
    1905                 :          0 :                 free(shared_shaper_id);
    1906                 :          0 :                 free(wfq_weight_mode);
    1907                 :          0 :                 return;
    1908                 :            :         }
    1909                 :            : }
    1910                 :            : 
    1911                 :            : cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node_pmode = {
    1912                 :            :         .f = cmd_add_port_tm_nonleaf_node_pmode_parsed,
    1913                 :            :         .data = NULL,
    1914                 :            :         .help_str = "Add port tm nonleaf node pktmode",
    1915                 :            :         .tokens = {
    1916                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_add,
    1917                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_port,
    1918                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_tm,
    1919                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_nonleaf,
    1920                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_node,
    1921                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_pktmode,
    1922                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_port_id,
    1923                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_node_id,
    1924                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_parent_node_id,
    1925                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_priority,
    1926                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_weight,
    1927                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_level_id,
    1928                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_shaper_profile_id,
    1929                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_n_sp_priorities,
    1930                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_stats_mask,
    1931                 :            :                 (void *)&cmd_add_port_tm_nonleaf_node_pmode_multi_shrd_shpr_id,
    1932                 :            :                 NULL,
    1933                 :            :         },
    1934                 :            : };
    1935                 :            : /* *** Add Port TM leaf node *** */
    1936                 :            : struct cmd_add_port_tm_leaf_node_result {
    1937                 :            :         cmdline_fixed_string_t add;
    1938                 :            :         cmdline_fixed_string_t port;
    1939                 :            :         cmdline_fixed_string_t tm;
    1940                 :            :         cmdline_fixed_string_t leaf;
    1941                 :            :         cmdline_fixed_string_t node;
    1942                 :            :         uint16_t port_id;
    1943                 :            :         uint32_t node_id;
    1944                 :            :         int32_t parent_node_id;
    1945                 :            :         uint32_t priority;
    1946                 :            :         uint32_t weight;
    1947                 :            :         uint32_t level_id;
    1948                 :            :         int32_t shaper_profile_id;
    1949                 :            :         uint32_t cman_mode;
    1950                 :            :         uint32_t wred_profile_id;
    1951                 :            :         uint64_t stats_mask;
    1952                 :            :         cmdline_multi_string_t multi_shared_shaper_id;
    1953                 :            : };
    1954                 :            : 
    1955                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add =
    1956                 :            :         TOKEN_STRING_INITIALIZER(
    1957                 :            :                 struct cmd_add_port_tm_leaf_node_result, add, "add");
    1958                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port =
    1959                 :            :         TOKEN_STRING_INITIALIZER(
    1960                 :            :                 struct cmd_add_port_tm_leaf_node_result, port, "port");
    1961                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm =
    1962                 :            :         TOKEN_STRING_INITIALIZER(
    1963                 :            :                 struct cmd_add_port_tm_leaf_node_result, tm, "tm");
    1964                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf =
    1965                 :            :         TOKEN_STRING_INITIALIZER(
    1966                 :            :                 struct cmd_add_port_tm_leaf_node_result, leaf, "leaf");
    1967                 :            : static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node =
    1968                 :            :         TOKEN_STRING_INITIALIZER(
    1969                 :            :                 struct cmd_add_port_tm_leaf_node_result, node, "node");
    1970                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_id =
    1971                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    1972                 :            :                  port_id, RTE_UINT16);
    1973                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_node_id =
    1974                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    1975                 :            :                  node_id, RTE_UINT32);
    1976                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id =
    1977                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    1978                 :            :                  parent_node_id, RTE_INT32);
    1979                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority =
    1980                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    1981                 :            :                  priority, RTE_UINT32);
    1982                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight =
    1983                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    1984                 :            :                  weight, RTE_UINT32);
    1985                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =
    1986                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    1987                 :            :                  level_id, RTE_UINT32);
    1988                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =
    1989                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    1990                 :            :                  shaper_profile_id, RTE_INT32);
    1991                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =
    1992                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    1993                 :            :                  cman_mode, RTE_UINT32);
    1994                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id =
    1995                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    1996                 :            :                  wred_profile_id, RTE_UINT32);
    1997                 :            : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask =
    1998                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    1999                 :            :                  stats_mask, RTE_UINT64);
    2000                 :            : static cmdline_parse_token_string_t
    2001                 :            :         cmd_add_port_tm_leaf_node_multi_shared_shaper_id =
    2002                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
    2003                 :            :                  multi_shared_shaper_id, TOKEN_STRING_MULTI);
    2004                 :            : 
    2005                 :          0 : static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
    2006                 :            :         struct cmdline *cl,
    2007                 :            :         __rte_unused void *data)
    2008                 :            : {
    2009                 :            :         struct cmd_add_port_tm_leaf_node_result *res = parsed_result;
    2010                 :            :         struct rte_tm_error error;
    2011                 :            :         struct rte_tm_node_params np;
    2012                 :            :         uint32_t *shared_shaper_id;
    2013                 :          0 :         uint32_t parent_node_id, n_shared_shapers = 0;
    2014                 :          0 :         portid_t port_id = res->port_id;
    2015                 :          0 :         char *s_str = res->multi_shared_shaper_id;
    2016                 :            :         int ret;
    2017                 :            : 
    2018                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    2019                 :          0 :                 return;
    2020                 :            : 
    2021                 :            :         memset(&np, 0, sizeof(struct rte_tm_node_params));
    2022                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    2023                 :            : 
    2024                 :            :         /* Node parameters */
    2025                 :          0 :         if (res->parent_node_id < 0)
    2026                 :            :                 parent_node_id = UINT32_MAX;
    2027                 :            :         else
    2028                 :          0 :                 parent_node_id = res->parent_node_id;
    2029                 :            : 
    2030                 :            :         if (parent_node_id != UINT32_MAX)
    2031                 :          0 :                 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                 :          0 :                 cmdline_printf(cl, "adding leaf node on port %u, with id %u as root node\n",
    2035                 :            :                                 port_id, res->node_id);
    2036                 :          0 :         cmdline_printf(cl, "# priority: %u\n", res->priority);
    2037                 :          0 :         cmdline_printf(cl, "# weight: %u\n", res->weight);
    2038                 :          0 :         cmdline_printf(cl, "# level_id: %u\n", res->level_id);
    2039                 :          0 :         cmdline_printf(cl, "# shaper_profile_id: %d\n", res->shaper_profile_id);
    2040                 :          0 :         cmdline_printf(cl, "# cman_mode: %u\n", res->cman_mode);
    2041                 :          0 :         cmdline_printf(cl, "# wred_profile_id: %d\n", res->wred_profile_id);
    2042                 :          0 :         cmdline_printf(cl, "# stats_mask: %"PRIx64"\n", res->stats_mask);
    2043                 :          0 :         cmdline_printf(cl, "# shared shapers: '%s'\n", s_str);
    2044                 :            : 
    2045                 :          0 :         shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
    2046                 :            :                 sizeof(uint32_t));
    2047                 :          0 :         if (shared_shaper_id == NULL) {
    2048                 :          0 :                 fprintf(stderr,
    2049                 :            :                         " Memory not allocated for shared shapers (error)\n");
    2050                 :          0 :                 return;
    2051                 :            :         }
    2052                 :            : 
    2053                 :            :         /* Parse multi shared shaper id string */
    2054                 :          0 :         ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
    2055                 :          0 :         if (ret) {
    2056                 :          0 :                 fprintf(stderr, " Shared shapers params string parse error\n");
    2057                 :          0 :                 free(shared_shaper_id);
    2058                 :          0 :                 return;
    2059                 :            :         }
    2060                 :            : 
    2061                 :          0 :         if (res->shaper_profile_id < 0)
    2062                 :          0 :                 np.shaper_profile_id = UINT32_MAX;
    2063                 :            :         else
    2064                 :          0 :                 np.shaper_profile_id = res->shaper_profile_id;
    2065                 :            : 
    2066                 :          0 :         np.n_shared_shapers = n_shared_shapers;
    2067                 :            : 
    2068                 :          0 :         if (np.n_shared_shapers) {
    2069                 :          0 :                 np.shared_shaper_id = &shared_shaper_id[0];
    2070                 :            :         } else {
    2071                 :          0 :                 free(shared_shaper_id);
    2072                 :            :                 shared_shaper_id = NULL;
    2073                 :            :         }
    2074                 :            : 
    2075                 :          0 :         np.leaf.cman = res->cman_mode;
    2076                 :          0 :         np.leaf.wred.wred_profile_id = res->wred_profile_id;
    2077                 :          0 :         np.stats_mask = res->stats_mask;
    2078                 :            : 
    2079                 :          0 :         ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
    2080                 :            :                                 res->priority, res->weight, res->level_id,
    2081                 :            :                                 &np, &error);
    2082                 :          0 :         if (ret != 0) {
    2083                 :          0 :                 print_err_msg(&error);
    2084                 :          0 :                 free(shared_shaper_id);
    2085                 :          0 :                 return;
    2086                 :            :         }
    2087                 :            : }
    2088                 :            : 
    2089                 :            : cmdline_parse_inst_t cmd_add_port_tm_leaf_node = {
    2090                 :            :         .f = cmd_add_port_tm_leaf_node_parsed,
    2091                 :            :         .data = NULL,
    2092                 :            :         .help_str = "Add port tm leaf node",
    2093                 :            :         .tokens = {
    2094                 :            :                 (void *)&cmd_add_port_tm_leaf_node_add,
    2095                 :            :                 (void *)&cmd_add_port_tm_leaf_node_port,
    2096                 :            :                 (void *)&cmd_add_port_tm_leaf_node_tm,
    2097                 :            :                 (void *)&cmd_add_port_tm_leaf_node_nonleaf,
    2098                 :            :                 (void *)&cmd_add_port_tm_leaf_node_node,
    2099                 :            :                 (void *)&cmd_add_port_tm_leaf_node_port_id,
    2100                 :            :                 (void *)&cmd_add_port_tm_leaf_node_node_id,
    2101                 :            :                 (void *)&cmd_add_port_tm_leaf_node_parent_node_id,
    2102                 :            :                 (void *)&cmd_add_port_tm_leaf_node_priority,
    2103                 :            :                 (void *)&cmd_add_port_tm_leaf_node_weight,
    2104                 :            :                 (void *)&cmd_add_port_tm_leaf_node_level_id,
    2105                 :            :                 (void *)&cmd_add_port_tm_leaf_node_shaper_profile_id,
    2106                 :            :                 (void *)&cmd_add_port_tm_leaf_node_cman_mode,
    2107                 :            :                 (void *)&cmd_add_port_tm_leaf_node_wred_profile_id,
    2108                 :            :                 (void *)&cmd_add_port_tm_leaf_node_stats_mask,
    2109                 :            :                 (void *)&cmd_add_port_tm_leaf_node_multi_shared_shaper_id,
    2110                 :            :                 NULL,
    2111                 :            :         },
    2112                 :            : };
    2113                 :            : 
    2114                 :            : struct cmd_show_port_tm_node_result {
    2115                 :            :         cmdline_fixed_string_t show;
    2116                 :            :         cmdline_fixed_string_t port;
    2117                 :            :         cmdline_fixed_string_t tm;
    2118                 :            :         cmdline_fixed_string_t node;
    2119                 :            :         uint16_t port_id;
    2120                 :            :         uint32_t node_id;
    2121                 :            : };
    2122                 :            : 
    2123                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_show_tok =
    2124                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, show, "show");
    2125                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_port_tok =
    2126                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, port, "port");
    2127                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_tm_tok =
    2128                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, tm, "tm");
    2129                 :            : static cmdline_parse_token_string_t cmd_show_port_tm_node_node_tok =
    2130                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, node, "node");
    2131                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_node_port_id_tok =
    2132                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_result, port_id, RTE_UINT16);
    2133                 :            : static cmdline_parse_token_num_t cmd_show_port_tm_node_node_id_tok =
    2134                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_result, node_id, RTE_UINT32);
    2135                 :            : 
    2136                 :            : static void
    2137                 :          0 : cmd_show_port_tm_node_parsed(void *parsed_result, struct cmdline *cl, void *data __rte_unused)
    2138                 :            : {
    2139                 :            :         const struct cmd_show_port_tm_node_result *res = parsed_result;
    2140                 :          0 :         const portid_t port_id = res->port_id;
    2141                 :          0 :         const uint32_t node_id = res->node_id;
    2142                 :          0 :         struct rte_tm_node_params params = {0};
    2143                 :          0 :         struct rte_tm_error error = {0};
    2144                 :            :         uint32_t parent_id, priority, weight, level_id;
    2145                 :            :         int is_leaf;
    2146                 :            :         int ret;
    2147                 :            : 
    2148                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    2149                 :          0 :                 return;
    2150                 :            : 
    2151                 :          0 :         ret = rte_tm_node_query(port_id, node_id,
    2152                 :            :                         &parent_id, &priority, &weight, &level_id, &params, &error);
    2153                 :          0 :         if (ret != 0) {
    2154                 :          0 :                 print_err_msg(&error);
    2155                 :          0 :                 return;
    2156                 :            :         }
    2157                 :            : 
    2158                 :          0 :         ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
    2159                 :          0 :         if (ret != 0) {
    2160                 :          0 :                 print_err_msg(&error);
    2161                 :          0 :                 return;
    2162                 :            :         }
    2163                 :            : 
    2164                 :          0 :         cmdline_printf(cl, "Port %u TM Node %u\n", port_id, node_id);
    2165                 :          0 :         if (parent_id == RTE_TM_NODE_ID_NULL)
    2166                 :          0 :                 cmdline_printf(cl, "  Parent Node ID: <NULL>\n");
    2167                 :            :         else
    2168                 :          0 :                 cmdline_printf(cl, "  Parent Node ID: %d\n", parent_id);
    2169                 :          0 :         cmdline_printf(cl, "  Level ID: %u\n", level_id);
    2170                 :          0 :         cmdline_printf(cl, "  Priority: %u\n", priority);
    2171                 :          0 :         cmdline_printf(cl, "  Weight: %u\n", weight);
    2172                 :          0 :         if (params.shaper_profile_id == RTE_TM_SHAPER_PROFILE_ID_NONE)
    2173                 :          0 :                 cmdline_printf(cl, "  Shaper Profile ID: <none>\n");
    2174                 :            :         else
    2175                 :          0 :                 cmdline_printf(cl, "  Shaper Profile ID: %d\n", params.shaper_profile_id);
    2176                 :          0 :         cmdline_printf(cl, "  Shared Shaper IDs: ");
    2177                 :          0 :         if (params.n_shared_shapers == 0)
    2178                 :          0 :                 cmdline_printf(cl, "<none>\n");
    2179                 :            :         else {
    2180                 :          0 :                 for (uint32_t i = 0; i < params.n_shared_shapers; i++)
    2181                 :          0 :                         cmdline_printf(cl, "%u ", params.shared_shaper_id[i]);
    2182                 :          0 :                 cmdline_printf(cl, "\n");
    2183                 :            :         }
    2184                 :          0 :         cmdline_printf(cl, "  Stats Mask: %"PRIu64"\n", params.stats_mask);
    2185                 :          0 :         if (is_leaf) {
    2186                 :          0 :                 cmdline_printf(cl, "  Leaf Node Parameters\n");
    2187                 :          0 :                 switch (params.leaf.cman) {
    2188                 :          0 :                 case RTE_TM_CMAN_TAIL_DROP:
    2189                 :          0 :                         cmdline_printf(cl, "    CMAN Mode: Tail Drop\n");
    2190                 :          0 :                         break;
    2191                 :          0 :                 case RTE_TM_CMAN_HEAD_DROP:
    2192                 :          0 :                         cmdline_printf(cl, "    CMAN Mode: Head Drop\n");
    2193                 :          0 :                         break;
    2194                 :          0 :                 case RTE_TM_CMAN_WRED:
    2195                 :          0 :                         cmdline_printf(cl, "    CMAN Mode: WRED\n");
    2196                 :          0 :                         break;
    2197                 :            :                 }
    2198                 :          0 :                 if (params.leaf.wred.wred_profile_id == RTE_TM_WRED_PROFILE_ID_NONE)
    2199                 :          0 :                         cmdline_printf(cl, "    WRED Profile ID: <none>\n");
    2200                 :            :                 else
    2201                 :          0 :                         cmdline_printf(cl, "    WRED Profile ID: %u\n",
    2202                 :            :                                         params.leaf.wred.wred_profile_id);
    2203                 :          0 :                 cmdline_printf(cl, "    Shared WRED Context Ids: ");
    2204                 :          0 :                 if (params.leaf.wred.n_shared_wred_contexts == 0)
    2205                 :          0 :                         cmdline_printf(cl, "<none>\n");
    2206                 :            :                 else {
    2207                 :          0 :                         for (uint32_t i = 0; i < params.leaf.wred.n_shared_wred_contexts; i++)
    2208                 :          0 :                                 cmdline_printf(cl, "%u ",
    2209                 :          0 :                                                 params.leaf.wred.shared_wred_context_id[i]);
    2210                 :          0 :                         cmdline_printf(cl, "\n");
    2211                 :            :                 }
    2212                 :            :         } else {
    2213                 :          0 :                 cmdline_printf(cl, "  Nonleaf Node Parameters\n");
    2214                 :          0 :                 cmdline_printf(cl, "    Num Strict Priorities: %u\n",
    2215                 :            :                                 params.nonleaf.n_sp_priorities);
    2216                 :          0 :                 cmdline_printf(cl, "    WFQ Weights Mode: ");
    2217                 :          0 :                 if (params.nonleaf.wfq_weight_mode == NULL)
    2218                 :          0 :                         cmdline_printf(cl, "WFQ\n");
    2219                 :            :                 else {
    2220                 :          0 :                         for (uint32_t i = 0; i < params.nonleaf.n_sp_priorities; i++)
    2221                 :          0 :                                 cmdline_printf(cl, "%s(%d) ",
    2222                 :            :                                         params.nonleaf.wfq_weight_mode[i] ? "Bytes" : "Packet",
    2223                 :          0 :                                         params.nonleaf.wfq_weight_mode[i]);
    2224                 :          0 :                         cmdline_printf(cl, "\n");
    2225                 :            :                 }
    2226                 :            :         }
    2227                 :            : }
    2228                 :            : 
    2229                 :            : 
    2230                 :            : cmdline_parse_inst_t cmd_show_port_tm_node = {
    2231                 :            :         .f = cmd_show_port_tm_node_parsed,
    2232                 :            :         .data = NULL,
    2233                 :            :         .help_str = "",
    2234                 :            :         .tokens = {
    2235                 :            :                 (void *)&cmd_show_port_tm_node_show_tok,
    2236                 :            :                 (void *)&cmd_show_port_tm_node_port_tok,
    2237                 :            :                 (void *)&cmd_show_port_tm_node_tm_tok,
    2238                 :            :                 (void *)&cmd_show_port_tm_node_node_tok,
    2239                 :            :                 (void *)&cmd_show_port_tm_node_port_id_tok,
    2240                 :            :                 (void *)&cmd_show_port_tm_node_node_id_tok,
    2241                 :            :                 NULL,
    2242                 :            :         }
    2243                 :            : };
    2244                 :            : 
    2245                 :            : /* *** Delete Port TM Node *** */
    2246                 :            : struct cmd_del_port_tm_node_result {
    2247                 :            :         cmdline_fixed_string_t del;
    2248                 :            :         cmdline_fixed_string_t port;
    2249                 :            :         cmdline_fixed_string_t tm;
    2250                 :            :         cmdline_fixed_string_t node;
    2251                 :            :         uint16_t port_id;
    2252                 :            :         uint32_t node_id;
    2253                 :            : };
    2254                 :            : 
    2255                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_del =
    2256                 :            :         TOKEN_STRING_INITIALIZER(
    2257                 :            :                 struct cmd_del_port_tm_node_result, del, "del");
    2258                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_port =
    2259                 :            :         TOKEN_STRING_INITIALIZER(
    2260                 :            :                 struct cmd_del_port_tm_node_result, port, "port");
    2261                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_tm =
    2262                 :            :         TOKEN_STRING_INITIALIZER(
    2263                 :            :                 struct cmd_del_port_tm_node_result, tm, "tm");
    2264                 :            : static cmdline_parse_token_string_t cmd_del_port_tm_node_node =
    2265                 :            :         TOKEN_STRING_INITIALIZER(
    2266                 :            :                 struct cmd_del_port_tm_node_result, node, "node");
    2267                 :            : static cmdline_parse_token_num_t cmd_del_port_tm_node_port_id =
    2268                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
    2269                 :            :                  port_id, RTE_UINT16);
    2270                 :            : static cmdline_parse_token_num_t cmd_del_port_tm_node_node_id =
    2271                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
    2272                 :            :                 node_id, RTE_UINT32);
    2273                 :            : 
    2274                 :          0 : static void cmd_del_port_tm_node_parsed(void *parsed_result,
    2275                 :            :         __rte_unused struct cmdline *cl,
    2276                 :            :         __rte_unused void *data)
    2277                 :            : {
    2278                 :            :         struct cmd_del_port_tm_node_result *res = parsed_result;
    2279                 :            :         struct rte_tm_error error;
    2280                 :          0 :         uint32_t node_id = res->node_id;
    2281                 :          0 :         portid_t port_id = res->port_id;
    2282                 :            :         int ret;
    2283                 :            : 
    2284                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    2285                 :          0 :                 return;
    2286                 :            : 
    2287                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    2288                 :            :         /* Port status */
    2289                 :          0 :         if (port_is_started(port_id)) {
    2290                 :          0 :                 fprintf(stderr, " Port %u not stopped (error)\n", port_id);
    2291                 :          0 :                 return;
    2292                 :            :         }
    2293                 :            : 
    2294                 :          0 :         ret = rte_tm_node_delete(port_id, node_id, &error);
    2295                 :          0 :         if (ret != 0) {
    2296                 :          0 :                 print_err_msg(&error);
    2297                 :          0 :                 return;
    2298                 :            :         }
    2299                 :            : }
    2300                 :            : 
    2301                 :            : cmdline_parse_inst_t cmd_del_port_tm_node = {
    2302                 :            :         .f = cmd_del_port_tm_node_parsed,
    2303                 :            :         .data = NULL,
    2304                 :            :         .help_str = "Delete port tm node",
    2305                 :            :         .tokens = {
    2306                 :            :                 (void *)&cmd_del_port_tm_node_del,
    2307                 :            :                 (void *)&cmd_del_port_tm_node_port,
    2308                 :            :                 (void *)&cmd_del_port_tm_node_tm,
    2309                 :            :                 (void *)&cmd_del_port_tm_node_node,
    2310                 :            :                 (void *)&cmd_del_port_tm_node_port_id,
    2311                 :            :                 (void *)&cmd_del_port_tm_node_node_id,
    2312                 :            :                 NULL,
    2313                 :            :         },
    2314                 :            : };
    2315                 :            : 
    2316                 :            : /* *** Update Port TM Node Parent *** */
    2317                 :            : struct cmd_set_port_tm_node_parent_result {
    2318                 :            :         cmdline_fixed_string_t set;
    2319                 :            :         cmdline_fixed_string_t port;
    2320                 :            :         cmdline_fixed_string_t tm;
    2321                 :            :         cmdline_fixed_string_t node;
    2322                 :            :         cmdline_fixed_string_t parent;
    2323                 :            :         uint16_t port_id;
    2324                 :            :         uint32_t node_id;
    2325                 :            :         uint32_t parent_id;
    2326                 :            :         uint32_t priority;
    2327                 :            :         uint32_t weight;
    2328                 :            : };
    2329                 :            : 
    2330                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set =
    2331                 :            :         TOKEN_STRING_INITIALIZER(
    2332                 :            :                 struct cmd_set_port_tm_node_parent_result, set, "set");
    2333                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port =
    2334                 :            :         TOKEN_STRING_INITIALIZER(
    2335                 :            :                 struct cmd_set_port_tm_node_parent_result, port, "port");
    2336                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm =
    2337                 :            :         TOKEN_STRING_INITIALIZER(
    2338                 :            :                 struct cmd_set_port_tm_node_parent_result, tm, "tm");
    2339                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node =
    2340                 :            :         TOKEN_STRING_INITIALIZER(
    2341                 :            :                 struct cmd_set_port_tm_node_parent_result, node, "node");
    2342                 :            : static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent =
    2343                 :            :         TOKEN_STRING_INITIALIZER(
    2344                 :            :                 struct cmd_set_port_tm_node_parent_result, parent, "parent");
    2345                 :            : static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id =
    2346                 :            :         TOKEN_NUM_INITIALIZER(
    2347                 :            :                 struct cmd_set_port_tm_node_parent_result, port_id,
    2348                 :            :                 RTE_UINT16);
    2349                 :            : static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id =
    2350                 :            :         TOKEN_NUM_INITIALIZER(
    2351                 :            :                 struct cmd_set_port_tm_node_parent_result, node_id,
    2352                 :            :                 RTE_UINT32);
    2353                 :            : static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id =
    2354                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
    2355                 :            :                 parent_id, RTE_UINT32);
    2356                 :            : static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority =
    2357                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
    2358                 :            :                 priority, RTE_UINT32);
    2359                 :            : static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight =
    2360                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
    2361                 :            :                 weight, RTE_UINT32);
    2362                 :            : 
    2363                 :          0 : static void cmd_set_port_tm_node_parent_parsed(void *parsed_result,
    2364                 :            :         __rte_unused struct cmdline *cl,
    2365                 :            :         __rte_unused void *data)
    2366                 :            : {
    2367                 :            :         struct cmd_set_port_tm_node_parent_result *res = parsed_result;
    2368                 :            :         struct rte_tm_error error;
    2369                 :          0 :         uint32_t node_id = res->node_id;
    2370                 :          0 :         uint32_t parent_id = res->parent_id;
    2371                 :          0 :         uint32_t priority = res->priority;
    2372                 :          0 :         uint32_t weight = res->weight;
    2373                 :          0 :         portid_t port_id = res->port_id;
    2374                 :            :         int ret;
    2375                 :            : 
    2376                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    2377                 :          0 :                 return;
    2378                 :            : 
    2379                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    2380                 :            :         /* Port status */
    2381                 :          0 :         if (!port_is_started(port_id)) {
    2382                 :          0 :                 fprintf(stderr, " Port %u not started (error)\n", port_id);
    2383                 :          0 :                 return;
    2384                 :            :         }
    2385                 :            : 
    2386                 :          0 :         ret = rte_tm_node_parent_update(port_id, node_id,
    2387                 :            :                 parent_id, priority, weight, &error);
    2388                 :          0 :         if (ret != 0) {
    2389                 :          0 :                 print_err_msg(&error);
    2390                 :          0 :                 return;
    2391                 :            :         }
    2392                 :            : }
    2393                 :            : 
    2394                 :            : cmdline_parse_inst_t cmd_set_port_tm_node_parent = {
    2395                 :            :         .f = cmd_set_port_tm_node_parent_parsed,
    2396                 :            :         .data = NULL,
    2397                 :            :         .help_str = "Set port tm node parent",
    2398                 :            :         .tokens = {
    2399                 :            :                 (void *)&cmd_set_port_tm_node_parent_set,
    2400                 :            :                 (void *)&cmd_set_port_tm_node_parent_port,
    2401                 :            :                 (void *)&cmd_set_port_tm_node_parent_tm,
    2402                 :            :                 (void *)&cmd_set_port_tm_node_parent_node,
    2403                 :            :                 (void *)&cmd_set_port_tm_node_parent_parent,
    2404                 :            :                 (void *)&cmd_set_port_tm_node_parent_port_id,
    2405                 :            :                 (void *)&cmd_set_port_tm_node_parent_node_id,
    2406                 :            :                 (void *)&cmd_set_port_tm_node_parent_parent_id,
    2407                 :            :                 (void *)&cmd_set_port_tm_node_parent_priority,
    2408                 :            :                 (void *)&cmd_set_port_tm_node_parent_weight,
    2409                 :            :                 NULL,
    2410                 :            :         },
    2411                 :            : };
    2412                 :            : 
    2413                 :            : /* *** Suspend Port TM Node *** */
    2414                 :            : struct cmd_suspend_port_tm_node_result {
    2415                 :            :         cmdline_fixed_string_t suspend;
    2416                 :            :         cmdline_fixed_string_t port;
    2417                 :            :         cmdline_fixed_string_t tm;
    2418                 :            :         cmdline_fixed_string_t node;
    2419                 :            :         uint16_t port_id;
    2420                 :            :         uint32_t node_id;
    2421                 :            : };
    2422                 :            : 
    2423                 :            : static cmdline_parse_token_string_t cmd_suspend_port_tm_node_suspend =
    2424                 :            :         TOKEN_STRING_INITIALIZER(
    2425                 :            :                 struct cmd_suspend_port_tm_node_result, suspend, "suspend");
    2426                 :            : static cmdline_parse_token_string_t cmd_suspend_port_tm_node_port =
    2427                 :            :         TOKEN_STRING_INITIALIZER(
    2428                 :            :                 struct cmd_suspend_port_tm_node_result, port, "port");
    2429                 :            : static cmdline_parse_token_string_t cmd_suspend_port_tm_node_tm =
    2430                 :            :         TOKEN_STRING_INITIALIZER(
    2431                 :            :                 struct cmd_suspend_port_tm_node_result, tm, "tm");
    2432                 :            : static cmdline_parse_token_string_t cmd_suspend_port_tm_node_node =
    2433                 :            :         TOKEN_STRING_INITIALIZER(
    2434                 :            :                 struct cmd_suspend_port_tm_node_result, node, "node");
    2435                 :            : static cmdline_parse_token_num_t cmd_suspend_port_tm_node_port_id =
    2436                 :            :         TOKEN_NUM_INITIALIZER(
    2437                 :            :                 struct cmd_suspend_port_tm_node_result, port_id,
    2438                 :            :                 RTE_UINT16);
    2439                 :            : static cmdline_parse_token_num_t cmd_suspend_port_tm_node_node_id =
    2440                 :            :         TOKEN_NUM_INITIALIZER(
    2441                 :            :                 struct cmd_suspend_port_tm_node_result, node_id,
    2442                 :            :                 RTE_UINT32);
    2443                 :            : 
    2444                 :          0 : static void cmd_suspend_port_tm_node_parsed(void *parsed_result,
    2445                 :            :         __rte_unused struct cmdline *cl,
    2446                 :            :         __rte_unused void *data)
    2447                 :            : {
    2448                 :            :         struct cmd_suspend_port_tm_node_result *res = parsed_result;
    2449                 :            :         struct rte_tm_error error;
    2450                 :          0 :         uint32_t node_id = res->node_id;
    2451                 :          0 :         portid_t port_id = res->port_id;
    2452                 :            :         int ret;
    2453                 :            : 
    2454                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    2455                 :          0 :                 return;
    2456                 :            : 
    2457                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    2458                 :          0 :         ret = rte_tm_node_suspend(port_id, node_id, &error);
    2459                 :          0 :         if (ret != 0) {
    2460                 :          0 :                 print_err_msg(&error);
    2461                 :          0 :                 return;
    2462                 :            :         }
    2463                 :            : }
    2464                 :            : 
    2465                 :            : cmdline_parse_inst_t cmd_suspend_port_tm_node = {
    2466                 :            :         .f = cmd_suspend_port_tm_node_parsed,
    2467                 :            :         .data = NULL,
    2468                 :            :         .help_str = "Suspend port tm node",
    2469                 :            :         .tokens = {
    2470                 :            :                 (void *)&cmd_suspend_port_tm_node_suspend,
    2471                 :            :                 (void *)&cmd_suspend_port_tm_node_port,
    2472                 :            :                 (void *)&cmd_suspend_port_tm_node_tm,
    2473                 :            :                 (void *)&cmd_suspend_port_tm_node_node,
    2474                 :            :                 (void *)&cmd_suspend_port_tm_node_port_id,
    2475                 :            :                 (void *)&cmd_suspend_port_tm_node_node_id,
    2476                 :            :                 NULL,
    2477                 :            :         },
    2478                 :            : };
    2479                 :            : 
    2480                 :            : /* *** Resume Port TM Node *** */
    2481                 :            : struct cmd_resume_port_tm_node_result {
    2482                 :            :         cmdline_fixed_string_t resume;
    2483                 :            :         cmdline_fixed_string_t port;
    2484                 :            :         cmdline_fixed_string_t tm;
    2485                 :            :         cmdline_fixed_string_t node;
    2486                 :            :         uint16_t port_id;
    2487                 :            :         uint32_t node_id;
    2488                 :            : };
    2489                 :            : 
    2490                 :            : static cmdline_parse_token_string_t cmd_resume_port_tm_node_resume =
    2491                 :            :         TOKEN_STRING_INITIALIZER(
    2492                 :            :                 struct cmd_resume_port_tm_node_result, resume, "resume");
    2493                 :            : static cmdline_parse_token_string_t cmd_resume_port_tm_node_port =
    2494                 :            :         TOKEN_STRING_INITIALIZER(
    2495                 :            :                 struct cmd_resume_port_tm_node_result, port, "port");
    2496                 :            : static cmdline_parse_token_string_t cmd_resume_port_tm_node_tm =
    2497                 :            :         TOKEN_STRING_INITIALIZER(
    2498                 :            :                 struct cmd_resume_port_tm_node_result, tm, "tm");
    2499                 :            : static cmdline_parse_token_string_t cmd_resume_port_tm_node_node =
    2500                 :            :         TOKEN_STRING_INITIALIZER(
    2501                 :            :                 struct cmd_resume_port_tm_node_result, node, "node");
    2502                 :            : static cmdline_parse_token_num_t cmd_resume_port_tm_node_port_id =
    2503                 :            :         TOKEN_NUM_INITIALIZER(
    2504                 :            :                 struct cmd_resume_port_tm_node_result, port_id, RTE_UINT16);
    2505                 :            : static cmdline_parse_token_num_t cmd_resume_port_tm_node_node_id =
    2506                 :            :         TOKEN_NUM_INITIALIZER(
    2507                 :            :                 struct cmd_resume_port_tm_node_result, node_id, RTE_UINT32);
    2508                 :            : 
    2509                 :          0 : static void cmd_resume_port_tm_node_parsed(void *parsed_result,
    2510                 :            :         __rte_unused struct cmdline *cl,
    2511                 :            :         __rte_unused void *data)
    2512                 :            : {
    2513                 :            :         struct cmd_resume_port_tm_node_result *res = parsed_result;
    2514                 :            :         struct rte_tm_error error;
    2515                 :          0 :         uint32_t node_id = res->node_id;
    2516                 :          0 :         portid_t port_id = res->port_id;
    2517                 :            :         int ret;
    2518                 :            : 
    2519                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    2520                 :          0 :                 return;
    2521                 :            : 
    2522                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    2523                 :          0 :         ret = rte_tm_node_resume(port_id, node_id, &error);
    2524                 :          0 :         if (ret != 0) {
    2525                 :          0 :                 print_err_msg(&error);
    2526                 :          0 :                 return;
    2527                 :            :         }
    2528                 :            : }
    2529                 :            : 
    2530                 :            : cmdline_parse_inst_t cmd_resume_port_tm_node = {
    2531                 :            :         .f = cmd_resume_port_tm_node_parsed,
    2532                 :            :         .data = NULL,
    2533                 :            :         .help_str = "Resume port tm node",
    2534                 :            :         .tokens = {
    2535                 :            :                 (void *)&cmd_resume_port_tm_node_resume,
    2536                 :            :                 (void *)&cmd_resume_port_tm_node_port,
    2537                 :            :                 (void *)&cmd_resume_port_tm_node_tm,
    2538                 :            :                 (void *)&cmd_resume_port_tm_node_node,
    2539                 :            :                 (void *)&cmd_resume_port_tm_node_port_id,
    2540                 :            :                 (void *)&cmd_resume_port_tm_node_node_id,
    2541                 :            :                 NULL,
    2542                 :            :         },
    2543                 :            : };
    2544                 :            : 
    2545                 :            : /* *** Port TM Hierarchy Commit *** */
    2546                 :            : struct cmd_port_tm_hierarchy_commit_result {
    2547                 :            :         cmdline_fixed_string_t port;
    2548                 :            :         cmdline_fixed_string_t tm;
    2549                 :            :         cmdline_fixed_string_t hierarchy;
    2550                 :            :         cmdline_fixed_string_t commit;
    2551                 :            :         uint16_t port_id;
    2552                 :            :         cmdline_fixed_string_t clean_on_fail;
    2553                 :            : };
    2554                 :            : 
    2555                 :            : static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port =
    2556                 :            :         TOKEN_STRING_INITIALIZER(
    2557                 :            :                 struct cmd_port_tm_hierarchy_commit_result, port, "port");
    2558                 :            : static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm =
    2559                 :            :         TOKEN_STRING_INITIALIZER(
    2560                 :            :                 struct cmd_port_tm_hierarchy_commit_result, tm, "tm");
    2561                 :            : static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy =
    2562                 :            :         TOKEN_STRING_INITIALIZER(
    2563                 :            :                 struct cmd_port_tm_hierarchy_commit_result,
    2564                 :            :                         hierarchy, "hierarchy");
    2565                 :            : static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit =
    2566                 :            :         TOKEN_STRING_INITIALIZER(
    2567                 :            :                 struct cmd_port_tm_hierarchy_commit_result, commit, "commit");
    2568                 :            : static cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id =
    2569                 :            :         TOKEN_NUM_INITIALIZER(
    2570                 :            :                 struct cmd_port_tm_hierarchy_commit_result,
    2571                 :            :                         port_id, RTE_UINT16);
    2572                 :            : static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_clean_on_fail =
    2573                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result,
    2574                 :            :                  clean_on_fail, "yes#no");
    2575                 :            : 
    2576                 :          0 : static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result,
    2577                 :            :         __rte_unused struct cmdline *cl,
    2578                 :            :         __rte_unused void *data)
    2579                 :            : {
    2580                 :            :         struct cmd_port_tm_hierarchy_commit_result *res = parsed_result;
    2581                 :            :         struct rte_tm_error error;
    2582                 :            :         uint32_t clean_on_fail;
    2583                 :          0 :         portid_t port_id = res->port_id;
    2584                 :            :         int ret;
    2585                 :            : 
    2586                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    2587                 :          0 :                 return;
    2588                 :            : 
    2589                 :          0 :         if (strcmp(res->clean_on_fail, "yes") == 0)
    2590                 :            :                 clean_on_fail = 1;
    2591                 :            :         else
    2592                 :            :                 clean_on_fail = 0;
    2593                 :            : 
    2594                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    2595                 :          0 :         ret = rte_tm_hierarchy_commit(port_id, clean_on_fail, &error);
    2596                 :          0 :         if (ret != 0) {
    2597                 :          0 :                 print_err_msg(&error);
    2598                 :          0 :                 return;
    2599                 :            :         }
    2600                 :            : }
    2601                 :            : 
    2602                 :            : cmdline_parse_inst_t cmd_port_tm_hierarchy_commit = {
    2603                 :            :         .f = cmd_port_tm_hierarchy_commit_parsed,
    2604                 :            :         .data = NULL,
    2605                 :            :         .help_str = "Commit port tm hierarchy",
    2606                 :            :         .tokens = {
    2607                 :            :                 (void *)&cmd_port_tm_hierarchy_commit_port,
    2608                 :            :                 (void *)&cmd_port_tm_hierarchy_commit_tm,
    2609                 :            :                 (void *)&cmd_port_tm_hierarchy_commit_hierarchy,
    2610                 :            :                 (void *)&cmd_port_tm_hierarchy_commit_commit,
    2611                 :            :                 (void *)&cmd_port_tm_hierarchy_commit_port_id,
    2612                 :            :                 (void *)&cmd_port_tm_hierarchy_commit_clean_on_fail,
    2613                 :            :                 NULL,
    2614                 :            :         },
    2615                 :            : };
    2616                 :            : 
    2617                 :            : /* *** Port TM Mark IP ECN *** */
    2618                 :            : struct cmd_port_tm_mark_ip_ecn_result {
    2619                 :            :         cmdline_fixed_string_t set;
    2620                 :            :         cmdline_fixed_string_t port;
    2621                 :            :         cmdline_fixed_string_t tm;
    2622                 :            :         cmdline_fixed_string_t mark;
    2623                 :            :         cmdline_fixed_string_t ip_ecn;
    2624                 :            :         uint16_t port_id;
    2625                 :            :         uint16_t green;
    2626                 :            :         uint16_t yellow;
    2627                 :            :         uint16_t red;
    2628                 :            : };
    2629                 :            : 
    2630                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_set =
    2631                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
    2632                 :            :                                  set, "set");
    2633                 :            : 
    2634                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_port =
    2635                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
    2636                 :            :                                  port, "port");
    2637                 :            : 
    2638                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_tm =
    2639                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result, tm,
    2640                 :            :                                  "tm");
    2641                 :            : 
    2642                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_mark =
    2643                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
    2644                 :            :                                  mark, "mark");
    2645                 :            : 
    2646                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_ip_ecn =
    2647                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
    2648                 :            :                                  ip_ecn, "ip_ecn");
    2649                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_port_id =
    2650                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
    2651                 :            :                               port_id, RTE_UINT16);
    2652                 :            : 
    2653                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_green =
    2654                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
    2655                 :            :                               green, RTE_UINT16);
    2656                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_yellow =
    2657                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
    2658                 :            :                               yellow, RTE_UINT16);
    2659                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_red =
    2660                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
    2661                 :            :                                 red, RTE_UINT16);
    2662                 :            : 
    2663                 :          0 : static void cmd_port_tm_mark_ip_ecn_parsed(void *parsed_result,
    2664                 :            :         __rte_unused struct cmdline *cl,
    2665                 :            :         __rte_unused void *data)
    2666                 :            : {
    2667                 :            :         struct cmd_port_tm_mark_ip_ecn_result *res = parsed_result;
    2668                 :            :         struct rte_tm_error error;
    2669                 :          0 :         portid_t port_id = res->port_id;
    2670                 :          0 :         int green = res->green;
    2671                 :          0 :         int yellow = res->yellow;
    2672                 :          0 :         int red = res->red;
    2673                 :            :         int ret;
    2674                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    2675                 :          0 :                 return;
    2676                 :            : 
    2677                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    2678                 :          0 :         ret = rte_tm_mark_ip_ecn(port_id, green, yellow, red, &error);
    2679                 :          0 :         if (ret != 0) {
    2680                 :          0 :                 print_err_msg(&error);
    2681                 :          0 :                 return;
    2682                 :            :         }
    2683                 :            : }
    2684                 :            : 
    2685                 :            : cmdline_parse_inst_t cmd_port_tm_mark_ip_ecn = {
    2686                 :            :         .f = cmd_port_tm_mark_ip_ecn_parsed,
    2687                 :            :         .data = NULL,
    2688                 :            :         .help_str = "set port tm mark ip_ecn <port> <green> <yellow> <red>",
    2689                 :            :         .tokens = {
    2690                 :            :                 (void *)&cmd_port_tm_mark_ip_ecn_set,
    2691                 :            :                 (void *)&cmd_port_tm_mark_ip_ecn_port,
    2692                 :            :                 (void *)&cmd_port_tm_mark_ip_ecn_tm,
    2693                 :            :                 (void *)&cmd_port_tm_mark_ip_ecn_mark,
    2694                 :            :                 (void *)&cmd_port_tm_mark_ip_ecn_ip_ecn,
    2695                 :            :                 (void *)&cmd_port_tm_mark_ip_ecn_port_id,
    2696                 :            :                 (void *)&cmd_port_tm_mark_ip_ecn_green,
    2697                 :            :                 (void *)&cmd_port_tm_mark_ip_ecn_yellow,
    2698                 :            :                 (void *)&cmd_port_tm_mark_ip_ecn_red,
    2699                 :            :                 NULL,
    2700                 :            :         },
    2701                 :            : };
    2702                 :            : 
    2703                 :            : 
    2704                 :            : /* *** Port TM Mark IP DSCP *** */
    2705                 :            : struct cmd_port_tm_mark_ip_dscp_result {
    2706                 :            :         cmdline_fixed_string_t set;
    2707                 :            :         cmdline_fixed_string_t port;
    2708                 :            :         cmdline_fixed_string_t tm;
    2709                 :            :         cmdline_fixed_string_t mark;
    2710                 :            :         cmdline_fixed_string_t ip_dscp;
    2711                 :            :         uint16_t port_id;
    2712                 :            :         uint16_t green;
    2713                 :            :         uint16_t yellow;
    2714                 :            :         uint16_t red;
    2715                 :            : };
    2716                 :            : 
    2717                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_set =
    2718                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
    2719                 :            :                                  set, "set");
    2720                 :            : 
    2721                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_port =
    2722                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
    2723                 :            :                                  port, "port");
    2724                 :            : 
    2725                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_tm =
    2726                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result, tm,
    2727                 :            :                                  "tm");
    2728                 :            : 
    2729                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_mark =
    2730                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
    2731                 :            :                                  mark, "mark");
    2732                 :            : 
    2733                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_ip_dscp =
    2734                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
    2735                 :            :                                  ip_dscp, "ip_dscp");
    2736                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_port_id =
    2737                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
    2738                 :            :                               port_id, RTE_UINT16);
    2739                 :            : 
    2740                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_green =
    2741                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
    2742                 :            :                                 green, RTE_UINT16);
    2743                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_yellow =
    2744                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
    2745                 :            :                                 yellow, RTE_UINT16);
    2746                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_red =
    2747                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
    2748                 :            :                                 red, RTE_UINT16);
    2749                 :            : 
    2750                 :          0 : static void cmd_port_tm_mark_ip_dscp_parsed(void *parsed_result,
    2751                 :            :         __rte_unused struct cmdline *cl,
    2752                 :            :         __rte_unused void *data)
    2753                 :            : {
    2754                 :            :         struct cmd_port_tm_mark_ip_dscp_result *res = parsed_result;
    2755                 :            :         struct rte_tm_error error;
    2756                 :          0 :         portid_t port_id = res->port_id;
    2757                 :          0 :         int green = res->green;
    2758                 :          0 :         int yellow = res->yellow;
    2759                 :          0 :         int red = res->red;
    2760                 :            :         int ret;
    2761                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    2762                 :          0 :                 return;
    2763                 :            : 
    2764                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    2765                 :          0 :         ret = rte_tm_mark_ip_dscp(port_id, green, yellow, red, &error);
    2766                 :          0 :         if (ret != 0) {
    2767                 :          0 :                 print_err_msg(&error);
    2768                 :          0 :                 return;
    2769                 :            :         }
    2770                 :            : }
    2771                 :            : 
    2772                 :            : cmdline_parse_inst_t cmd_port_tm_mark_ip_dscp = {
    2773                 :            :         .f = cmd_port_tm_mark_ip_dscp_parsed,
    2774                 :            :         .data = NULL,
    2775                 :            :         .help_str = "set port tm mark ip_dscp <port> <green> <yellow> <red>",
    2776                 :            :         .tokens = {
    2777                 :            :                 (void *)&cmd_port_tm_mark_ip_dscp_set,
    2778                 :            :                 (void *)&cmd_port_tm_mark_ip_dscp_port,
    2779                 :            :                 (void *)&cmd_port_tm_mark_ip_dscp_tm,
    2780                 :            :                 (void *)&cmd_port_tm_mark_ip_dscp_mark,
    2781                 :            :                 (void *)&cmd_port_tm_mark_ip_dscp_ip_dscp,
    2782                 :            :                 (void *)&cmd_port_tm_mark_ip_dscp_port_id,
    2783                 :            :                 (void *)&cmd_port_tm_mark_ip_dscp_green,
    2784                 :            :                 (void *)&cmd_port_tm_mark_ip_dscp_yellow,
    2785                 :            :                 (void *)&cmd_port_tm_mark_ip_dscp_red,
    2786                 :            :                 NULL,
    2787                 :            :         },
    2788                 :            : };
    2789                 :            : 
    2790                 :            : 
    2791                 :            : /* *** Port TM Mark VLAN_DEI *** */
    2792                 :            : struct cmd_port_tm_mark_vlan_dei_result {
    2793                 :            :         cmdline_fixed_string_t set;
    2794                 :            :         cmdline_fixed_string_t port;
    2795                 :            :         cmdline_fixed_string_t tm;
    2796                 :            :         cmdline_fixed_string_t mark;
    2797                 :            :         cmdline_fixed_string_t vlan_dei;
    2798                 :            :         uint16_t port_id;
    2799                 :            :         uint16_t green;
    2800                 :            :         uint16_t yellow;
    2801                 :            :         uint16_t red;
    2802                 :            : };
    2803                 :            : 
    2804                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_set =
    2805                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
    2806                 :            :                                  set, "set");
    2807                 :            : 
    2808                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_port =
    2809                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
    2810                 :            :                                  port, "port");
    2811                 :            : 
    2812                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_tm =
    2813                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result, tm,
    2814                 :            :                                  "tm");
    2815                 :            : 
    2816                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_mark =
    2817                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
    2818                 :            :                                  mark, "mark");
    2819                 :            : 
    2820                 :            : static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_vlan_dei =
    2821                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
    2822                 :            :                                  vlan_dei, "vlan_dei");
    2823                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_port_id =
    2824                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
    2825                 :            :                               port_id, RTE_UINT16);
    2826                 :            : 
    2827                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_green =
    2828                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
    2829                 :            :                                 green, RTE_UINT16);
    2830                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_yellow =
    2831                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
    2832                 :            :                                 yellow, RTE_UINT16);
    2833                 :            : static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_red =
    2834                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
    2835                 :            :                                 red, RTE_UINT16);
    2836                 :            : 
    2837                 :          0 : static void cmd_port_tm_mark_vlan_dei_parsed(void *parsed_result,
    2838                 :            :         __rte_unused struct cmdline *cl,
    2839                 :            :         __rte_unused void *data)
    2840                 :            : {
    2841                 :            :         struct cmd_port_tm_mark_vlan_dei_result *res = parsed_result;
    2842                 :            :         struct rte_tm_error error;
    2843                 :          0 :         portid_t port_id = res->port_id;
    2844                 :          0 :         int green = res->green;
    2845                 :          0 :         int yellow = res->yellow;
    2846                 :          0 :         int red = res->red;
    2847                 :            :         int ret;
    2848                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    2849                 :          0 :                 return;
    2850                 :            : 
    2851                 :            :         memset(&error, 0, sizeof(struct rte_tm_error));
    2852                 :          0 :         ret = rte_tm_mark_vlan_dei(port_id, green, yellow, red, &error);
    2853                 :          0 :         if (ret != 0) {
    2854                 :          0 :                 print_err_msg(&error);
    2855                 :          0 :                 return;
    2856                 :            :         }
    2857                 :            : }
    2858                 :            : 
    2859                 :            : cmdline_parse_inst_t cmd_port_tm_mark_vlan_dei = {
    2860                 :            :         .f = cmd_port_tm_mark_vlan_dei_parsed,
    2861                 :            :         .data = NULL,
    2862                 :            :         .help_str = "set port tm mark vlan_dei <port> <green> <yellow> <red>",
    2863                 :            :         .tokens = {
    2864                 :            :                 (void *)&cmd_port_tm_mark_vlan_dei_set,
    2865                 :            :                 (void *)&cmd_port_tm_mark_vlan_dei_port,
    2866                 :            :                 (void *)&cmd_port_tm_mark_vlan_dei_tm,
    2867                 :            :                 (void *)&cmd_port_tm_mark_vlan_dei_mark,
    2868                 :            :                 (void *)&cmd_port_tm_mark_vlan_dei_vlan_dei,
    2869                 :            :                 (void *)&cmd_port_tm_mark_vlan_dei_port_id,
    2870                 :            :                 (void *)&cmd_port_tm_mark_vlan_dei_green,
    2871                 :            :                 (void *)&cmd_port_tm_mark_vlan_dei_yellow,
    2872                 :            :                 (void *)&cmd_port_tm_mark_vlan_dei_red,
    2873                 :            :                 NULL,
    2874                 :            :         },
    2875                 :            : };

Generated by: LCOV version 1.14