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

Generated by: LCOV version 1.14