LCOV - code coverage report
Current view: top level - app/test-pmd - cmdline_mtr.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 441 0.0 %
Date: 2025-10-01 17:51:42 Functions: 0 29 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 <stdlib.h>
       6                 :            : 
       7                 :            : #include <cmdline_parse.h>
       8                 :            : #include <cmdline_parse_num.h>
       9                 :            : #include <cmdline_parse_string.h>
      10                 :            : 
      11                 :            : #include <rte_ethdev.h>
      12                 :            : #include <rte_flow.h>
      13                 :            : #include <rte_mtr.h>
      14                 :            : 
      15                 :            : #include "testpmd.h"
      16                 :            : #include "cmdline_mtr.h"
      17                 :            : 
      18                 :            : #define PARSE_DELIMITER                         " \f\n\r\t\v"
      19                 :            : #define MAX_VLAN_TABLE_ENTRIES          16
      20                 :            : #define MAX_DSCP_TABLE_ENTRIES          64
      21                 :            : 
      22                 :            : /** Display Meter Error Message */
      23                 :            : static void
      24                 :          0 : print_err_msg(struct rte_mtr_error *error)
      25                 :            : {
      26                 :            :         static const char *const errstrlist[] = {
      27                 :            :                 [RTE_MTR_ERROR_TYPE_NONE] = "no error",
      28                 :            :                 [RTE_MTR_ERROR_TYPE_UNSPECIFIED] = "cause unspecified",
      29                 :            :                 [RTE_MTR_ERROR_TYPE_METER_PROFILE_ID] = "meter profile id",
      30                 :            :                 [RTE_MTR_ERROR_TYPE_METER_PROFILE] = "meter profile null",
      31                 :            :                 [RTE_MTR_ERROR_TYPE_MTR_ID] = "meter id",
      32                 :            :                 [RTE_MTR_ERROR_TYPE_MTR_PARAMS] = "meter params null",
      33                 :            :                 [RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN]
      34                 :            :                         = "policer action(green)",
      35                 :            :                 [RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW]
      36                 :            :                         = "policer action(yellow)",
      37                 :            :                 [RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED]
      38                 :            :                         = "policer action(red)",
      39                 :            :                 [RTE_MTR_ERROR_TYPE_STATS_MASK] = "stats mask",
      40                 :            :                 [RTE_MTR_ERROR_TYPE_STATS] = "stats",
      41                 :            :                 [RTE_MTR_ERROR_TYPE_SHARED]
      42                 :            :                         = "shared meter",
      43                 :            :                 [RTE_MTR_ERROR_TYPE_METER_POLICY_ID] = "meter policy id",
      44                 :            :                 [RTE_MTR_ERROR_TYPE_METER_POLICY] = "meter policy null",
      45                 :            :         };
      46                 :            : 
      47                 :            :         const char *errstr;
      48                 :            :         char buf[64];
      49                 :            : 
      50                 :          0 :         if ((unsigned int)error->type >= RTE_DIM(errstrlist) ||
      51                 :          0 :                 !errstrlist[error->type])
      52                 :            :                 errstr = "unknown type";
      53                 :            :         else
      54                 :            :                 errstr = errstrlist[error->type];
      55                 :            : 
      56                 :          0 :         if (error->cause)
      57                 :            :                 snprintf(buf, sizeof(buf), "cause: %p, ", error->cause);
      58                 :            : 
      59                 :          0 :         fprintf(stderr, "%s: %s%s (error %d)\n",
      60                 :          0 :                 errstr, error->cause ? buf : "",
      61                 :          0 :                 error->message ? error->message : "(no stated reason)",
      62                 :          0 :                 error->type);
      63                 :          0 : }
      64                 :            : 
      65                 :            : void
      66                 :          0 : print_mtr_err_msg(struct rte_mtr_error *error)
      67                 :            : {
      68                 :          0 :         print_err_msg(error);
      69                 :          0 : }
      70                 :            : 
      71                 :            : static int
      72                 :          0 : parse_uint(uint64_t *value, const char *str)
      73                 :            : {
      74                 :          0 :         char *next = NULL;
      75                 :            :         uint64_t n;
      76                 :            : 
      77                 :          0 :         errno = 0;
      78                 :            :         /* Parse number string */
      79                 :          0 :         n = strtol(str, &next, 10);
      80                 :          0 :         if (errno != 0 || str == next || *next != '\0')
      81                 :            :                 return -1;
      82                 :            : 
      83                 :          0 :         *value = n;
      84                 :            : 
      85                 :          0 :         return 0;
      86                 :            : }
      87                 :            : 
      88                 :            : static int
      89                 :          0 : validate_input_color_table_entries(char *str)
      90                 :            : {
      91                 :            :         char *saveptr;
      92                 :          0 :         char *token = strtok_r(str, PARSE_DELIMITER, &saveptr);
      93                 :          0 :         for (int i = 0; token != NULL; i++) {
      94                 :          0 :                 if (i > ((MAX_DSCP_TABLE_ENTRIES + MAX_VLAN_TABLE_ENTRIES) - 1))
      95                 :            :                         return -1;
      96                 :          0 :                 token = strtok_r(NULL, PARSE_DELIMITER, &saveptr);
      97                 :            :         }
      98                 :            :         return 0;
      99                 :            : }
     100                 :            : 
     101                 :            : static int
     102                 :          0 : parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
     103                 :            :         enum rte_color **vlan_table)
     104                 :            : {
     105                 :            :         enum rte_color *vlan, *dscp;
     106                 :            :         char *token, *saveptr;
     107                 :          0 :         char *temp_str = strdup(str);
     108                 :            :         int i = 0;
     109                 :            : 
     110                 :          0 :         if (validate_input_color_table_entries(temp_str)) {
     111                 :          0 :                 free(temp_str);
     112                 :          0 :                 return -1;
     113                 :            :         }
     114                 :          0 :         free(temp_str);
     115                 :            : 
     116                 :          0 :         token = strtok_r(str, PARSE_DELIMITER, &saveptr);
     117                 :          0 :         if (token == NULL)
     118                 :            :                 return 0;
     119                 :            : 
     120                 :            :         /* Allocate memory for dscp table */
     121                 :          0 :         dscp = (enum rte_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
     122                 :            :                 sizeof(enum rte_color));
     123                 :          0 :         if (dscp == NULL)
     124                 :            :                 return -1;
     125                 :            : 
     126                 :            :         while (1) {
     127                 :          0 :                 if (strcasecmp(token, "G") == 0)
     128                 :          0 :                         dscp[i++] = RTE_COLOR_GREEN;
     129                 :          0 :                 else if (strcasecmp(token, "Y") == 0)
     130                 :          0 :                         dscp[i++] = RTE_COLOR_YELLOW;
     131                 :          0 :                 else if (strcasecmp(token, "R") == 0)
     132                 :          0 :                         dscp[i++] = RTE_COLOR_RED;
     133                 :            :                 else {
     134                 :          0 :                         free(dscp);
     135                 :          0 :                         return -1;
     136                 :            :                 }
     137                 :          0 :                 if (i == MAX_DSCP_TABLE_ENTRIES)
     138                 :            :                         break;
     139                 :            : 
     140                 :          0 :                 token = strtok_r(NULL, PARSE_DELIMITER, &saveptr);
     141                 :          0 :                 if (token == NULL) {
     142                 :          0 :                         free(dscp);
     143                 :          0 :                         return -1;
     144                 :            :                 }
     145                 :            :         }
     146                 :            : 
     147                 :          0 :         *dscp_table = dscp;
     148                 :            : 
     149                 :          0 :         token = strtok_r(NULL, PARSE_DELIMITER, &saveptr);
     150                 :          0 :         if (token == NULL)
     151                 :            :                 return 0;
     152                 :            : 
     153                 :            :         /* Allocate memory for vlan table */
     154                 :          0 :         vlan = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
     155                 :            :                 sizeof(enum rte_color));
     156                 :          0 :         if (vlan == NULL) {
     157                 :          0 :                 free(*dscp_table);
     158                 :          0 :                 return -1;
     159                 :            :         }
     160                 :            : 
     161                 :            :         i = 0;
     162                 :            :         while (1) {
     163                 :          0 :                 if (strcasecmp(token, "G") == 0)
     164                 :          0 :                         vlan[i++] = RTE_COLOR_GREEN;
     165                 :          0 :                 else if (strcasecmp(token, "Y") == 0)
     166                 :          0 :                         vlan[i++] = RTE_COLOR_YELLOW;
     167                 :          0 :                 else if (strcasecmp(token, "R") == 0)
     168                 :          0 :                         vlan[i++] = RTE_COLOR_RED;
     169                 :            :                 else {
     170                 :          0 :                         free(vlan);
     171                 :          0 :                         free(*dscp_table);
     172                 :          0 :                         return -1;
     173                 :            :                 }
     174                 :          0 :                 if (i == MAX_VLAN_TABLE_ENTRIES)
     175                 :            :                         break;
     176                 :            : 
     177                 :          0 :                 token = strtok_r(NULL, PARSE_DELIMITER, &saveptr);
     178                 :          0 :                 if (token == NULL) {
     179                 :          0 :                         free(vlan);
     180                 :          0 :                         free(*dscp_table);
     181                 :          0 :                         return -1;
     182                 :            :                 }
     183                 :            :         }
     184                 :            : 
     185                 :          0 :         *vlan_table = vlan;
     186                 :          0 :         return 0;
     187                 :            : }
     188                 :            : 
     189                 :            : static int
     190                 :          0 : parse_vlan_table_entries(char *str, enum rte_color **vlan_table)
     191                 :            : {
     192                 :            :         char *token;
     193                 :            :         int i = 0;
     194                 :            : 
     195                 :          0 :         token = strtok_r(str, PARSE_DELIMITER, &str);
     196                 :          0 :         if (token == NULL)
     197                 :            :                 return 0;
     198                 :            : 
     199                 :            :         /* Allocate memory for vlan table */
     200                 :          0 :         *vlan_table = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
     201                 :            :                 sizeof(enum rte_color));
     202                 :          0 :         if (*vlan_table == NULL)
     203                 :            :                 return -1;
     204                 :            : 
     205                 :            :         while (1) {
     206                 :          0 :                 if (strcasecmp(token, "G") == 0)
     207                 :          0 :                         (*vlan_table)[i++] = RTE_COLOR_GREEN;
     208                 :          0 :                 else if (strcasecmp(token, "Y") == 0)
     209                 :          0 :                         (*vlan_table)[i++] = RTE_COLOR_YELLOW;
     210                 :          0 :                 else if (strcasecmp(token, "R") == 0)
     211                 :          0 :                         (*vlan_table)[i++] = RTE_COLOR_RED;
     212                 :            :                 else {
     213                 :          0 :                         free(*vlan_table);
     214                 :          0 :                         return -1;
     215                 :            :                 }
     216                 :          0 :                 if (i == MAX_VLAN_TABLE_ENTRIES)
     217                 :            :                         break;
     218                 :            : 
     219                 :          0 :                 token = strtok_r(str, PARSE_DELIMITER, &str);
     220                 :          0 :                 if (token == NULL) {
     221                 :          0 :                         free(*vlan_table);
     222                 :          0 :                         return -1;
     223                 :            :                 }
     224                 :            :         }
     225                 :            :         return 0;
     226                 :            : }
     227                 :            : 
     228                 :            : static int
     229                 :          0 : parse_dscp_table_entries(char *str, enum rte_color **dscp_table)
     230                 :            : {
     231                 :            :         char *token;
     232                 :            :         int i = 0;
     233                 :            : 
     234                 :          0 :         token = strtok_r(str, PARSE_DELIMITER, &str);
     235                 :          0 :         if (token == NULL)
     236                 :            :                 return 0;
     237                 :            : 
     238                 :            :         /* Allocate memory for dscp table */
     239                 :          0 :         *dscp_table = (enum rte_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
     240                 :            :                 sizeof(enum rte_color));
     241                 :          0 :         if (*dscp_table == NULL)
     242                 :            :                 return -1;
     243                 :            : 
     244                 :            :         while (1) {
     245                 :          0 :                 if (strcmp(token, "G") == 0 ||
     246                 :          0 :                         strcmp(token, "g") == 0)
     247                 :          0 :                         (*dscp_table)[i++] = RTE_COLOR_GREEN;
     248                 :          0 :                 else if (strcmp(token, "Y") == 0 ||
     249                 :          0 :                         strcmp(token, "y") == 0)
     250                 :          0 :                         (*dscp_table)[i++] = RTE_COLOR_YELLOW;
     251                 :          0 :                 else if (strcmp(token, "R") == 0 ||
     252                 :          0 :                         strcmp(token, "r") == 0)
     253                 :          0 :                         (*dscp_table)[i++] = RTE_COLOR_RED;
     254                 :            :                 else {
     255                 :          0 :                         free(*dscp_table);
     256                 :          0 :                         return -1;
     257                 :            :                 }
     258                 :          0 :                 if (i == MAX_DSCP_TABLE_ENTRIES)
     259                 :            :                         break;
     260                 :            : 
     261                 :          0 :                 token = strtok_r(str, PARSE_DELIMITER, &str);
     262                 :          0 :                 if (token == NULL) {
     263                 :          0 :                         free(*dscp_table);
     264                 :          0 :                         return -1;
     265                 :            :                 }
     266                 :            :         }
     267                 :            :         return 0;
     268                 :            : }
     269                 :            : 
     270                 :            : static int
     271                 :          0 : parse_default_input_color_str(char *str, uint64_t *def_inp_color)
     272                 :            : {
     273                 :            :         char *token;
     274                 :            : 
     275                 :          0 :         token = strtok_r(str, PARSE_DELIMITER, &str);
     276                 :          0 :         if (token == NULL)
     277                 :            :                 return 0;
     278                 :            : 
     279                 :          0 :         if (strcasecmp(token, "G") == 0)
     280                 :          0 :                 *def_inp_color = RTE_COLOR_GREEN;
     281                 :          0 :         else if (strcasecmp(token, "Y") == 0)
     282                 :          0 :                 *def_inp_color = RTE_COLOR_YELLOW;
     283                 :          0 :         else if (strcasecmp(token, "R") == 0)
     284                 :          0 :                 *def_inp_color = RTE_COLOR_RED;
     285                 :            :         else
     286                 :            :                 return -1;
     287                 :            : 
     288                 :            :         return 0;
     289                 :            : }
     290                 :            : 
     291                 :            : static int
     292                 :          0 : parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
     293                 :            :         enum rte_color **vlan_table, enum rte_color **dscp_table)
     294                 :            : {
     295                 :            :         char *token;
     296                 :          0 :         uint64_t previous_mtr_color = 0;
     297                 :            :         int ret;
     298                 :            : 
     299                 :            :         /* First token: use previous meter color */
     300                 :          0 :         token = strtok_r(c_str, PARSE_DELIMITER, &c_str);
     301                 :          0 :         if (token ==  NULL)
     302                 :            :                 return -1;
     303                 :            : 
     304                 :          0 :         ret = parse_uint(&previous_mtr_color, token);
     305                 :          0 :         if (ret != 0)
     306                 :            :                 return -1;
     307                 :            : 
     308                 :            :         /* Check if previous meter color to be used */
     309                 :          0 :         if (previous_mtr_color) {
     310                 :          0 :                 *use_prev_meter_color = previous_mtr_color;
     311                 :          0 :                 return 0;
     312                 :            :         }
     313                 :            : 
     314                 :          0 :         ret = parse_input_color_table_entries(c_str, dscp_table, vlan_table);
     315                 :          0 :         if (ret != 0)
     316                 :          0 :                 return -1;
     317                 :            : 
     318                 :            :         return 0;
     319                 :            : }
     320                 :            : 
     321                 :            : static int
     322                 :          0 : parse_multi_token_string(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
     323                 :            :         enum rte_mtr_color_in_protocol *proto, enum rte_color **dscp_table)
     324                 :            : {
     325                 :            :         char *token;
     326                 :            :         uint64_t val;
     327                 :            :         int ret;
     328                 :            : 
     329                 :            :         /* First token: port id */
     330                 :          0 :         token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
     331                 :          0 :         if (token ==  NULL)
     332                 :            :                 return -1;
     333                 :            : 
     334                 :          0 :         ret = parse_uint(&val, token);
     335                 :          0 :         if (ret != 0 || val > UINT16_MAX)
     336                 :            :                 return -1;
     337                 :            : 
     338                 :          0 :         *port_id = val;
     339                 :            : 
     340                 :            :         /* Second token: meter id */
     341                 :          0 :         token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
     342                 :          0 :         if (token == NULL)
     343                 :            :                 return 0;
     344                 :            : 
     345                 :          0 :         ret = parse_uint(&val, token);
     346                 :          0 :         if (ret != 0 || val > UINT32_MAX)
     347                 :            :                 return -1;
     348                 :            : 
     349                 :          0 :         *mtr_id = val;
     350                 :            : 
     351                 :            :         /* Third token: protocol  */
     352                 :          0 :         token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
     353                 :          0 :         if (token == NULL)
     354                 :            :                 return 0;
     355                 :            : 
     356                 :          0 :         if (strcmp(token, "outer_ip") == 0)
     357                 :          0 :                 *proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
     358                 :          0 :         else if (strcmp(token, "inner_ip") == 0)
     359                 :          0 :                 *proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
     360                 :            : 
     361                 :          0 :         ret = parse_dscp_table_entries(t_str, dscp_table);
     362                 :          0 :         if (ret != 0)
     363                 :          0 :                 return -1;
     364                 :            : 
     365                 :            :         return 0;
     366                 :            : }
     367                 :            : 
     368                 :            : static int
     369                 :          0 : parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id,
     370                 :            :         enum rte_mtr_color_in_protocol *proto, enum rte_color **vlan_table)
     371                 :            : {
     372                 :            :         uint64_t val;
     373                 :            :         char *token;
     374                 :            :         int ret;
     375                 :            : 
     376                 :            :         /* First token: port id */
     377                 :          0 :         token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
     378                 :          0 :         if (token ==  NULL)
     379                 :            :                 return -1;
     380                 :            : 
     381                 :          0 :         ret = parse_uint(&val, token);
     382                 :          0 :         if (ret != 0 || val > UINT16_MAX)
     383                 :            :                 return -1;
     384                 :            : 
     385                 :          0 :         *port_id = val;
     386                 :            : 
     387                 :            :         /* Second token: meter id */
     388                 :          0 :         token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
     389                 :          0 :         if (token == NULL)
     390                 :            :                 return 0;
     391                 :            : 
     392                 :          0 :         ret = parse_uint(&val, token);
     393                 :          0 :         if (ret != 0 || val > UINT32_MAX)
     394                 :            :                 return -1;
     395                 :            : 
     396                 :          0 :         *mtr_id = val;
     397                 :            : 
     398                 :            :         /* Third token: protocol  */
     399                 :          0 :         token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
     400                 :          0 :         if (token == NULL)
     401                 :            :                 return 0;
     402                 :            : 
     403                 :          0 :         if (strcmp(token, "outer_vlan") == 0)
     404                 :          0 :                 *proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
     405                 :          0 :         else if (strcmp(token, "inner_vlan") == 0)
     406                 :          0 :                 *proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
     407                 :            : 
     408                 :          0 :         ret = parse_vlan_table_entries(t_str, vlan_table);
     409                 :          0 :         if (ret != 0)
     410                 :          0 :                 return -1;
     411                 :            : 
     412                 :            :         return 0;
     413                 :            : }
     414                 :            : 
     415                 :            : /* *** Show Port Meter Capabilities *** */
     416                 :            : struct cmd_show_port_meter_cap_result {
     417                 :            :         cmdline_fixed_string_t show;
     418                 :            :         cmdline_fixed_string_t port;
     419                 :            :         cmdline_fixed_string_t meter;
     420                 :            :         cmdline_fixed_string_t cap;
     421                 :            :         uint16_t port_id;
     422                 :            : };
     423                 :            : 
     424                 :            : static cmdline_parse_token_string_t cmd_show_port_meter_cap_show =
     425                 :            :         TOKEN_STRING_INITIALIZER(
     426                 :            :                 struct cmd_show_port_meter_cap_result, show, "show");
     427                 :            : static cmdline_parse_token_string_t cmd_show_port_meter_cap_port =
     428                 :            :         TOKEN_STRING_INITIALIZER(
     429                 :            :                 struct cmd_show_port_meter_cap_result, port, "port");
     430                 :            : static cmdline_parse_token_string_t cmd_show_port_meter_cap_meter =
     431                 :            :         TOKEN_STRING_INITIALIZER(
     432                 :            :                 struct cmd_show_port_meter_cap_result, meter, "meter");
     433                 :            : static cmdline_parse_token_string_t cmd_show_port_meter_cap_cap =
     434                 :            :         TOKEN_STRING_INITIALIZER(
     435                 :            :                 struct cmd_show_port_meter_cap_result, cap, "cap");
     436                 :            : static cmdline_parse_token_num_t cmd_show_port_meter_cap_port_id =
     437                 :            :         TOKEN_NUM_INITIALIZER(
     438                 :            :                 struct cmd_show_port_meter_cap_result, port_id, RTE_UINT16);
     439                 :            : 
     440                 :          0 : static void cmd_show_port_meter_cap_parsed(void *parsed_result,
     441                 :            :         __rte_unused struct cmdline *cl,
     442                 :            :         __rte_unused void *data)
     443                 :            : {
     444                 :            :         struct cmd_show_port_meter_cap_result *res = parsed_result;
     445                 :            :         struct rte_mtr_capabilities cap;
     446                 :            :         struct rte_mtr_error error;
     447                 :          0 :         uint16_t port_id = res->port_id;
     448                 :            :         int ret;
     449                 :            : 
     450                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     451                 :          0 :                 return;
     452                 :            : 
     453                 :            :         memset(&cap, 0, sizeof(struct rte_mtr_capabilities));
     454                 :          0 :         ret = rte_mtr_capabilities_get(port_id, &cap, &error);
     455                 :          0 :         if (ret) {
     456                 :          0 :                 print_err_msg(&error);
     457                 :          0 :                 return;
     458                 :            :         }
     459                 :            : 
     460                 :            :         printf("\n****   Port Meter Object Capabilities ****\n\n");
     461                 :          0 :         printf("cap.n_max %" PRIu32 "\n", cap.n_max);
     462                 :          0 :         printf("cap.n_shared_max %" PRIu32 "\n", cap.n_shared_max);
     463                 :          0 :         printf("cap.identical %" PRId32 "\n", cap.identical);
     464                 :          0 :         printf("cap.shared_identical %" PRId32 "\n",
     465                 :            :                 cap.shared_identical);
     466                 :          0 :         printf("cap.shared_n_flows_per_mtr_max %" PRIu32 "\n",
     467                 :            :                 cap.shared_n_flows_per_mtr_max);
     468                 :          0 :         printf("cap.chaining_n_mtrs_per_flow_max %" PRIu32 "\n",
     469                 :            :                 cap.chaining_n_mtrs_per_flow_max);
     470                 :          0 :         printf("cap.chaining_use_prev_mtr_color_supported %" PRId32 "\n",
     471                 :            :                 cap.chaining_use_prev_mtr_color_supported);
     472                 :          0 :         printf("cap.chaining_use_prev_mtr_color_enforced %" PRId32 "\n",
     473                 :            :                 cap.chaining_use_prev_mtr_color_enforced);
     474                 :          0 :         printf("cap.meter_srtcm_rfc2697_n_max %" PRIu32 "\n",
     475                 :            :                 cap.meter_srtcm_rfc2697_n_max);
     476                 :          0 :         printf("cap.meter_trtcm_rfc2698_n_max %" PRIu32 "\n",
     477                 :            :                 cap.meter_trtcm_rfc2698_n_max);
     478                 :          0 :         printf("cap.meter_trtcm_rfc4115_n_max %" PRIu32 "\n",
     479                 :            :                 cap.meter_trtcm_rfc4115_n_max);
     480                 :          0 :         printf("cap.meter_rate_max %" PRIu64 "\n", cap.meter_rate_max);
     481                 :          0 :         printf("cap.color_aware_srtcm_rfc2697_supported %" PRId32 "\n",
     482                 :            :                 cap.color_aware_srtcm_rfc2697_supported);
     483                 :          0 :         printf("cap.color_aware_trtcm_rfc2698_supported %" PRId32 "\n",
     484                 :            :                 cap.color_aware_trtcm_rfc2698_supported);
     485                 :          0 :         printf("cap.color_aware_trtcm_rfc4115_supported %" PRId32 "\n",
     486                 :            :                 cap.color_aware_trtcm_rfc4115_supported);
     487                 :          0 :         printf("cap.srtcm_rfc2697_byte_mode_supported %" PRId32 "\n",
     488                 :            :                 cap.srtcm_rfc2697_byte_mode_supported);
     489                 :          0 :         printf("cap.srtcm_rfc2697_packet_mode_supported %" PRId32 "\n",
     490                 :            :                 cap.srtcm_rfc2697_packet_mode_supported);
     491                 :          0 :         printf("cap.trtcm_rfc2698_byte_mode_supported %" PRId32 "\n",
     492                 :            :                 cap.trtcm_rfc2698_byte_mode_supported);
     493                 :          0 :         printf("cap.trtcm_rfc2698_packet_mode_supported %" PRId32 "\n",
     494                 :            :                 cap.trtcm_rfc2698_packet_mode_supported);
     495                 :          0 :         printf("cap.trtcm_rfc4115_byte_mode_supported %" PRId32 "\n",
     496                 :            :                 cap.trtcm_rfc4115_byte_mode_supported);
     497                 :          0 :         printf("cap.trtcm_rfc4115_packet_mode_supported %" PRId32 "\n",
     498                 :            :                 cap.trtcm_rfc4115_packet_mode_supported);
     499                 :          0 :         printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
     500                 :          0 :         printf("cap.input_color_proto_mask 0x%" PRIx64 "\n",
     501                 :            :                 cap.input_color_proto_mask);
     502                 :          0 :         printf("cap.separate_input_color_table_per_port %" PRId32 "\n",
     503                 :            :                 cap.separate_input_color_table_per_port);
     504                 :            : }
     505                 :            : 
     506                 :            : cmdline_parse_inst_t cmd_show_port_meter_cap = {
     507                 :            :         .f = cmd_show_port_meter_cap_parsed,
     508                 :            :         .data = NULL,
     509                 :            :         .help_str = "show port meter cap <port_id>",
     510                 :            :         .tokens = {
     511                 :            :                 (void *)&cmd_show_port_meter_cap_show,
     512                 :            :                 (void *)&cmd_show_port_meter_cap_port,
     513                 :            :                 (void *)&cmd_show_port_meter_cap_meter,
     514                 :            :                 (void *)&cmd_show_port_meter_cap_cap,
     515                 :            :                 (void *)&cmd_show_port_meter_cap_port_id,
     516                 :            :                 NULL,
     517                 :            :         },
     518                 :            : };
     519                 :            : 
     520                 :            : /* *** Add Port Meter Profile srtcm_rfc2697 *** */
     521                 :            : struct cmd_add_port_meter_profile_srtcm_result {
     522                 :            :         cmdline_fixed_string_t add;
     523                 :            :         cmdline_fixed_string_t port;
     524                 :            :         cmdline_fixed_string_t meter;
     525                 :            :         cmdline_fixed_string_t profile;
     526                 :            :         cmdline_fixed_string_t srtcm_rfc2697;
     527                 :            :         uint16_t port_id;
     528                 :            :         uint32_t profile_id;
     529                 :            :         uint64_t cir;
     530                 :            :         uint64_t cbs;
     531                 :            :         uint64_t ebs;
     532                 :            :         int packet_mode;
     533                 :            : };
     534                 :            : 
     535                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_add =
     536                 :            :         TOKEN_STRING_INITIALIZER(
     537                 :            :                 struct cmd_add_port_meter_profile_srtcm_result, add, "add");
     538                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_port =
     539                 :            :         TOKEN_STRING_INITIALIZER(
     540                 :            :                 struct cmd_add_port_meter_profile_srtcm_result,
     541                 :            :                         port, "port");
     542                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_meter =
     543                 :            :         TOKEN_STRING_INITIALIZER(
     544                 :            :                 struct cmd_add_port_meter_profile_srtcm_result,
     545                 :            :                         meter, "meter");
     546                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_profile =
     547                 :            :         TOKEN_STRING_INITIALIZER(
     548                 :            :                 struct cmd_add_port_meter_profile_srtcm_result,
     549                 :            :                         profile, "profile");
     550                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_srtcm_srtcm_rfc2697 =
     551                 :            :         TOKEN_STRING_INITIALIZER(
     552                 :            :                 struct cmd_add_port_meter_profile_srtcm_result,
     553                 :            :                         srtcm_rfc2697, "srtcm_rfc2697");
     554                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_port_id =
     555                 :            :         TOKEN_NUM_INITIALIZER(
     556                 :            :                 struct cmd_add_port_meter_profile_srtcm_result,
     557                 :            :                         port_id, RTE_UINT16);
     558                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_profile_id =
     559                 :            :         TOKEN_NUM_INITIALIZER(
     560                 :            :                 struct cmd_add_port_meter_profile_srtcm_result,
     561                 :            :                         profile_id, RTE_UINT32);
     562                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_cir =
     563                 :            :         TOKEN_NUM_INITIALIZER(
     564                 :            :                 struct cmd_add_port_meter_profile_srtcm_result,
     565                 :            :                         cir, RTE_UINT64);
     566                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_cbs =
     567                 :            :         TOKEN_NUM_INITIALIZER(
     568                 :            :                 struct cmd_add_port_meter_profile_srtcm_result,
     569                 :            :                         cbs, RTE_UINT64);
     570                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_ebs =
     571                 :            :         TOKEN_NUM_INITIALIZER(
     572                 :            :                 struct cmd_add_port_meter_profile_srtcm_result,
     573                 :            :                         ebs, RTE_UINT64);
     574                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_srtcm_packet_mode =
     575                 :            :         TOKEN_NUM_INITIALIZER(
     576                 :            :                 struct cmd_add_port_meter_profile_srtcm_result,
     577                 :            :                         packet_mode, RTE_UINT32);
     578                 :            : 
     579                 :          0 : static void cmd_add_port_meter_profile_srtcm_parsed(void *parsed_result,
     580                 :            :         __rte_unused struct cmdline *cl,
     581                 :            :         __rte_unused void *data)
     582                 :            : {
     583                 :            :         struct cmd_add_port_meter_profile_srtcm_result *res = parsed_result;
     584                 :            :         struct rte_mtr_meter_profile mp;
     585                 :            :         struct rte_mtr_error error;
     586                 :          0 :         uint32_t profile_id = res->profile_id;
     587                 :          0 :         uint16_t port_id = res->port_id;
     588                 :            :         int ret;
     589                 :            : 
     590                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     591                 :          0 :                 return;
     592                 :            : 
     593                 :            :         /* Private shaper profile params */
     594                 :            :         memset(&mp, 0, sizeof(struct rte_mtr_meter_profile));
     595                 :          0 :         mp.alg = RTE_MTR_SRTCM_RFC2697;
     596                 :          0 :         mp.srtcm_rfc2697.cir = res->cir;
     597                 :          0 :         mp.srtcm_rfc2697.cbs = res->cbs;
     598                 :          0 :         mp.srtcm_rfc2697.ebs = res->ebs;
     599                 :          0 :         mp.packet_mode = res->packet_mode;
     600                 :            : 
     601                 :          0 :         ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
     602                 :          0 :         if (ret != 0) {
     603                 :          0 :                 print_err_msg(&error);
     604                 :          0 :                 return;
     605                 :            :         }
     606                 :            : }
     607                 :            : 
     608                 :            : cmdline_parse_inst_t cmd_add_port_meter_profile_srtcm = {
     609                 :            :         .f = cmd_add_port_meter_profile_srtcm_parsed,
     610                 :            :         .data = NULL,
     611                 :            :         .help_str = "add port meter profile srtcm_rfc2697 <port_id> <profile_id> <cir> <cbs> <ebs> <packet_mode>",
     612                 :            :         .tokens = {
     613                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_add,
     614                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_port,
     615                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_meter,
     616                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_profile,
     617                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_srtcm_rfc2697,
     618                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_port_id,
     619                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_profile_id,
     620                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_cir,
     621                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_cbs,
     622                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_ebs,
     623                 :            :                 (void *)&cmd_add_port_meter_profile_srtcm_packet_mode,
     624                 :            :                 NULL,
     625                 :            :         },
     626                 :            : };
     627                 :            : 
     628                 :            : /* *** Add Port Meter Profile trtcm_rfc2698 *** */
     629                 :            : struct cmd_add_port_meter_profile_trtcm_result {
     630                 :            :         cmdline_fixed_string_t add;
     631                 :            :         cmdline_fixed_string_t port;
     632                 :            :         cmdline_fixed_string_t meter;
     633                 :            :         cmdline_fixed_string_t profile;
     634                 :            :         cmdline_fixed_string_t trtcm_rfc2698;
     635                 :            :         uint16_t port_id;
     636                 :            :         uint32_t profile_id;
     637                 :            :         uint64_t cir;
     638                 :            :         uint64_t pir;
     639                 :            :         uint64_t cbs;
     640                 :            :         uint64_t pbs;
     641                 :            :         int packet_mode;
     642                 :            : };
     643                 :            : 
     644                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_add =
     645                 :            :         TOKEN_STRING_INITIALIZER(
     646                 :            :                 struct cmd_add_port_meter_profile_trtcm_result, add, "add");
     647                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_port =
     648                 :            :         TOKEN_STRING_INITIALIZER(
     649                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     650                 :            :                         port, "port");
     651                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_meter =
     652                 :            :         TOKEN_STRING_INITIALIZER(
     653                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     654                 :            :                         meter, "meter");
     655                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_profile =
     656                 :            :         TOKEN_STRING_INITIALIZER(
     657                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     658                 :            :                         profile, "profile");
     659                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_trtcm_rfc2698 =
     660                 :            :         TOKEN_STRING_INITIALIZER(
     661                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     662                 :            :                         trtcm_rfc2698, "trtcm_rfc2698");
     663                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_port_id =
     664                 :            :         TOKEN_NUM_INITIALIZER(
     665                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     666                 :            :                         port_id, RTE_UINT16);
     667                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_profile_id =
     668                 :            :         TOKEN_NUM_INITIALIZER(
     669                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     670                 :            :                         profile_id, RTE_UINT32);
     671                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_cir =
     672                 :            :         TOKEN_NUM_INITIALIZER(
     673                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     674                 :            :                         cir, RTE_UINT64);
     675                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_pir =
     676                 :            :         TOKEN_NUM_INITIALIZER(
     677                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     678                 :            :                         pir, RTE_UINT64);
     679                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_cbs =
     680                 :            :         TOKEN_NUM_INITIALIZER(
     681                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     682                 :            :                         cbs, RTE_UINT64);
     683                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_pbs =
     684                 :            :         TOKEN_NUM_INITIALIZER(
     685                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     686                 :            :                         pbs, RTE_UINT64);
     687                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_packet_mode =
     688                 :            :         TOKEN_NUM_INITIALIZER(
     689                 :            :                 struct cmd_add_port_meter_profile_trtcm_result,
     690                 :            :                         packet_mode, RTE_UINT32);
     691                 :            : 
     692                 :          0 : static void cmd_add_port_meter_profile_trtcm_parsed(void *parsed_result,
     693                 :            :         __rte_unused struct cmdline *cl,
     694                 :            :         __rte_unused void *data)
     695                 :            : {
     696                 :            :         struct cmd_add_port_meter_profile_trtcm_result *res = parsed_result;
     697                 :            :         struct rte_mtr_meter_profile mp;
     698                 :            :         struct rte_mtr_error error;
     699                 :          0 :         uint32_t profile_id = res->profile_id;
     700                 :          0 :         uint16_t port_id = res->port_id;
     701                 :            :         int ret;
     702                 :            : 
     703                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     704                 :          0 :                 return;
     705                 :            : 
     706                 :            :         /* Private shaper profile params */
     707                 :            :         memset(&mp, 0, sizeof(struct rte_mtr_meter_profile));
     708                 :          0 :         mp.alg = RTE_MTR_TRTCM_RFC2698;
     709                 :          0 :         mp.trtcm_rfc2698.cir = res->cir;
     710                 :          0 :         mp.trtcm_rfc2698.pir = res->pir;
     711                 :          0 :         mp.trtcm_rfc2698.cbs = res->cbs;
     712                 :          0 :         mp.trtcm_rfc2698.pbs = res->pbs;
     713                 :          0 :         mp.packet_mode = res->packet_mode;
     714                 :            : 
     715                 :          0 :         ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
     716                 :          0 :         if (ret != 0) {
     717                 :          0 :                 print_err_msg(&error);
     718                 :          0 :                 return;
     719                 :            :         }
     720                 :            : }
     721                 :            : 
     722                 :            : cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm = {
     723                 :            :         .f = cmd_add_port_meter_profile_trtcm_parsed,
     724                 :            :         .data = NULL,
     725                 :            :         .help_str = "add port meter profile trtcm_rfc2698 <port_id> <profile_id> <cir> <pir> <cbs> <pbs> <packet_mode>",
     726                 :            :         .tokens = {
     727                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_add,
     728                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_port,
     729                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_meter,
     730                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_profile,
     731                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_trtcm_rfc2698,
     732                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_port_id,
     733                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_profile_id,
     734                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_cir,
     735                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_pir,
     736                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_cbs,
     737                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_pbs,
     738                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_packet_mode,
     739                 :            :                 NULL,
     740                 :            :         },
     741                 :            : };
     742                 :            : 
     743                 :            : /* *** Add Port Meter Profile trtcm_rfc4115 *** */
     744                 :            : struct cmd_add_port_meter_profile_trtcm_rfc4115_result {
     745                 :            :         cmdline_fixed_string_t add;
     746                 :            :         cmdline_fixed_string_t port;
     747                 :            :         cmdline_fixed_string_t meter;
     748                 :            :         cmdline_fixed_string_t profile;
     749                 :            :         cmdline_fixed_string_t trtcm_rfc4115;
     750                 :            :         uint16_t port_id;
     751                 :            :         uint32_t profile_id;
     752                 :            :         uint64_t cir;
     753                 :            :         uint64_t eir;
     754                 :            :         uint64_t cbs;
     755                 :            :         uint64_t ebs;
     756                 :            :         int packet_mode;
     757                 :            : };
     758                 :            : 
     759                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_rfc4115_add =
     760                 :            :         TOKEN_STRING_INITIALIZER(
     761                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result, add,
     762                 :            :                 "add");
     763                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_rfc4115_port =
     764                 :            :         TOKEN_STRING_INITIALIZER(
     765                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     766                 :            :                         port, "port");
     767                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_rfc4115_meter =
     768                 :            :         TOKEN_STRING_INITIALIZER(
     769                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     770                 :            :                         meter, "meter");
     771                 :            : static cmdline_parse_token_string_t cmd_add_port_meter_profile_trtcm_rfc4115_profile =
     772                 :            :         TOKEN_STRING_INITIALIZER(
     773                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     774                 :            :                         profile, "profile");
     775                 :            : static cmdline_parse_token_string_t
     776                 :            :         cmd_add_port_meter_profile_trtcm_rfc4115_trtcm_rfc4115 =
     777                 :            :         TOKEN_STRING_INITIALIZER(
     778                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     779                 :            :                         trtcm_rfc4115, "trtcm_rfc4115");
     780                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_port_id =
     781                 :            :         TOKEN_NUM_INITIALIZER(
     782                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     783                 :            :                         port_id, RTE_UINT16);
     784                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_profile_id =
     785                 :            :         TOKEN_NUM_INITIALIZER(
     786                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     787                 :            :                         profile_id, RTE_UINT32);
     788                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_cir =
     789                 :            :         TOKEN_NUM_INITIALIZER(
     790                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     791                 :            :                         cir, RTE_UINT64);
     792                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_eir =
     793                 :            :         TOKEN_NUM_INITIALIZER(
     794                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     795                 :            :                         eir, RTE_UINT64);
     796                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_cbs =
     797                 :            :         TOKEN_NUM_INITIALIZER(
     798                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     799                 :            :                         cbs, RTE_UINT64);
     800                 :            : static cmdline_parse_token_num_t cmd_add_port_meter_profile_trtcm_rfc4115_ebs =
     801                 :            :         TOKEN_NUM_INITIALIZER(
     802                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     803                 :            :                         ebs, RTE_UINT64);
     804                 :            : static cmdline_parse_token_num_t
     805                 :            :         cmd_add_port_meter_profile_trtcm_rfc4115_packet_mode =
     806                 :            :         TOKEN_NUM_INITIALIZER(
     807                 :            :                 struct cmd_add_port_meter_profile_trtcm_rfc4115_result,
     808                 :            :                         packet_mode, RTE_UINT32);
     809                 :            : 
     810                 :          0 : static void cmd_add_port_meter_profile_trtcm_rfc4115_parsed(
     811                 :            :         void *parsed_result,
     812                 :            :         __rte_unused struct cmdline *cl,
     813                 :            :         __rte_unused void *data)
     814                 :            : {
     815                 :            :         struct cmd_add_port_meter_profile_trtcm_rfc4115_result *res =
     816                 :            :                 parsed_result;
     817                 :            :         struct rte_mtr_meter_profile mp;
     818                 :            :         struct rte_mtr_error error;
     819                 :          0 :         uint32_t profile_id = res->profile_id;
     820                 :          0 :         uint16_t port_id = res->port_id;
     821                 :            :         int ret;
     822                 :            : 
     823                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     824                 :          0 :                 return;
     825                 :            : 
     826                 :            :         /* Private shaper profile params */
     827                 :            :         memset(&mp, 0, sizeof(struct rte_mtr_meter_profile));
     828                 :          0 :         mp.alg = RTE_MTR_TRTCM_RFC4115;
     829                 :          0 :         mp.trtcm_rfc4115.cir = res->cir;
     830                 :          0 :         mp.trtcm_rfc4115.eir = res->eir;
     831                 :          0 :         mp.trtcm_rfc4115.cbs = res->cbs;
     832                 :          0 :         mp.trtcm_rfc4115.ebs = res->ebs;
     833                 :          0 :         mp.packet_mode = res->packet_mode;
     834                 :            : 
     835                 :          0 :         ret = rte_mtr_meter_profile_add(port_id, profile_id, &mp, &error);
     836                 :          0 :         if (ret != 0) {
     837                 :          0 :                 print_err_msg(&error);
     838                 :          0 :                 return;
     839                 :            :         }
     840                 :            : }
     841                 :            : 
     842                 :            : cmdline_parse_inst_t cmd_add_port_meter_profile_trtcm_rfc4115 = {
     843                 :            :         .f = cmd_add_port_meter_profile_trtcm_rfc4115_parsed,
     844                 :            :         .data = NULL,
     845                 :            :         .help_str = "add port meter profile trtcm_rfc4115 <port_id> <profile_id> <cir> <eir> <cbs> <ebs> <packet_mode>",
     846                 :            :         .tokens = {
     847                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_add,
     848                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_port,
     849                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_meter,
     850                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_profile,
     851                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_trtcm_rfc4115,
     852                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_port_id,
     853                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_profile_id,
     854                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_cir,
     855                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_eir,
     856                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_cbs,
     857                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_ebs,
     858                 :            :                 (void *)&cmd_add_port_meter_profile_trtcm_rfc4115_packet_mode,
     859                 :            :                 NULL,
     860                 :            :         },
     861                 :            : };
     862                 :            : 
     863                 :            : /* *** Delete Port Meter Profile *** */
     864                 :            : struct cmd_del_port_meter_profile_result {
     865                 :            :         cmdline_fixed_string_t del;
     866                 :            :         cmdline_fixed_string_t port;
     867                 :            :         cmdline_fixed_string_t meter;
     868                 :            :         cmdline_fixed_string_t profile;
     869                 :            :         uint16_t port_id;
     870                 :            :         uint32_t profile_id;
     871                 :            : };
     872                 :            : 
     873                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_profile_del =
     874                 :            :         TOKEN_STRING_INITIALIZER(
     875                 :            :                 struct cmd_del_port_meter_profile_result, del, "del");
     876                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_profile_port =
     877                 :            :         TOKEN_STRING_INITIALIZER(
     878                 :            :                 struct cmd_del_port_meter_profile_result,
     879                 :            :                         port, "port");
     880                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_profile_meter =
     881                 :            :         TOKEN_STRING_INITIALIZER(
     882                 :            :                 struct cmd_del_port_meter_profile_result,
     883                 :            :                         meter, "meter");
     884                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_profile_profile =
     885                 :            :         TOKEN_STRING_INITIALIZER(
     886                 :            :                 struct cmd_del_port_meter_profile_result,
     887                 :            :                         profile, "profile");
     888                 :            : static cmdline_parse_token_num_t cmd_del_port_meter_profile_port_id =
     889                 :            :         TOKEN_NUM_INITIALIZER(
     890                 :            :                 struct cmd_del_port_meter_profile_result,
     891                 :            :                         port_id, RTE_UINT16);
     892                 :            : static cmdline_parse_token_num_t cmd_del_port_meter_profile_profile_id =
     893                 :            :         TOKEN_NUM_INITIALIZER(
     894                 :            :                 struct cmd_del_port_meter_profile_result,
     895                 :            :                         profile_id, RTE_UINT32);
     896                 :            : 
     897                 :          0 : static void cmd_del_port_meter_profile_parsed(void *parsed_result,
     898                 :            :         __rte_unused struct cmdline *cl,
     899                 :            :         __rte_unused void *data)
     900                 :            : {
     901                 :            :         struct cmd_del_port_meter_profile_result *res = parsed_result;
     902                 :            :         struct rte_mtr_error error;
     903                 :          0 :         uint32_t profile_id = res->profile_id;
     904                 :          0 :         uint16_t port_id = res->port_id;
     905                 :            :         int ret;
     906                 :            : 
     907                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
     908                 :          0 :                 return;
     909                 :            : 
     910                 :            :         /* Delete meter profile */
     911                 :          0 :         ret = rte_mtr_meter_profile_delete(port_id, profile_id, &error);
     912                 :          0 :         if (ret != 0) {
     913                 :          0 :                 print_err_msg(&error);
     914                 :          0 :                 return;
     915                 :            :         }
     916                 :            : }
     917                 :            : 
     918                 :            : cmdline_parse_inst_t cmd_del_port_meter_profile = {
     919                 :            :         .f = cmd_del_port_meter_profile_parsed,
     920                 :            :         .data = NULL,
     921                 :            :         .help_str = "del port meter profile <port_id> <profile_id>",
     922                 :            :         .tokens = {
     923                 :            :                 (void *)&cmd_del_port_meter_profile_del,
     924                 :            :                 (void *)&cmd_del_port_meter_profile_port,
     925                 :            :                 (void *)&cmd_del_port_meter_profile_meter,
     926                 :            :                 (void *)&cmd_del_port_meter_profile_profile,
     927                 :            :                 (void *)&cmd_del_port_meter_profile_port_id,
     928                 :            :                 (void *)&cmd_del_port_meter_profile_profile_id,
     929                 :            :                 NULL,
     930                 :            :         },
     931                 :            : };
     932                 :            : 
     933                 :            : /* *** Create Port Meter Object *** */
     934                 :            : struct cmd_create_port_meter_result {
     935                 :            :         cmdline_fixed_string_t create;
     936                 :            :         cmdline_fixed_string_t port;
     937                 :            :         cmdline_fixed_string_t meter;
     938                 :            :         uint16_t port_id;
     939                 :            :         uint32_t mtr_id;
     940                 :            :         uint32_t profile_id;
     941                 :            :         uint32_t policy_id;
     942                 :            :         cmdline_fixed_string_t meter_enable;
     943                 :            :         cmdline_fixed_string_t g_action;
     944                 :            :         cmdline_fixed_string_t y_action;
     945                 :            :         cmdline_fixed_string_t r_action;
     946                 :            :         uint64_t statistics_mask;
     947                 :            :         uint32_t shared;
     948                 :            :         cmdline_fixed_string_t default_input_color;
     949                 :            :         cmdline_multi_string_t meter_input_color;
     950                 :            : };
     951                 :            : 
     952                 :            : static cmdline_parse_token_string_t cmd_create_port_meter_create =
     953                 :            :         TOKEN_STRING_INITIALIZER(
     954                 :            :                 struct cmd_create_port_meter_result, create, "create");
     955                 :            : static cmdline_parse_token_string_t cmd_create_port_meter_port =
     956                 :            :         TOKEN_STRING_INITIALIZER(
     957                 :            :                 struct cmd_create_port_meter_result, port, "port");
     958                 :            : static cmdline_parse_token_string_t cmd_create_port_meter_meter =
     959                 :            :         TOKEN_STRING_INITIALIZER(
     960                 :            :                 struct cmd_create_port_meter_result, meter, "meter");
     961                 :            : static cmdline_parse_token_num_t cmd_create_port_meter_port_id =
     962                 :            :         TOKEN_NUM_INITIALIZER(
     963                 :            :                 struct cmd_create_port_meter_result, port_id, RTE_UINT16);
     964                 :            : static cmdline_parse_token_num_t cmd_create_port_meter_mtr_id =
     965                 :            :         TOKEN_NUM_INITIALIZER(
     966                 :            :                 struct cmd_create_port_meter_result, mtr_id, RTE_UINT32);
     967                 :            : static cmdline_parse_token_num_t cmd_create_port_meter_profile_id =
     968                 :            :         TOKEN_NUM_INITIALIZER(
     969                 :            :                 struct cmd_create_port_meter_result, profile_id, RTE_UINT32);
     970                 :            : static cmdline_parse_token_num_t cmd_create_port_meter_policy_id =
     971                 :            :         TOKEN_NUM_INITIALIZER(
     972                 :            :                 struct cmd_create_port_meter_result, policy_id, RTE_UINT32);
     973                 :            : static cmdline_parse_token_string_t cmd_create_port_meter_meter_enable =
     974                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
     975                 :            :                 meter_enable, "yes#no");
     976                 :            : static cmdline_parse_token_num_t cmd_create_port_meter_statistics_mask =
     977                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_create_port_meter_result,
     978                 :            :                 statistics_mask, RTE_UINT64);
     979                 :            : static cmdline_parse_token_num_t cmd_create_port_meter_shared =
     980                 :            :         TOKEN_NUM_INITIALIZER(struct cmd_create_port_meter_result,
     981                 :            :                 shared, RTE_UINT32);
     982                 :            : static cmdline_parse_token_string_t cmd_create_port_meter_default_input_color =
     983                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
     984                 :            :                 default_input_color, "R#Y#G#r#y#g");
     985                 :            : static cmdline_parse_token_string_t cmd_create_port_meter_input_color =
     986                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_create_port_meter_result,
     987                 :            :                 meter_input_color, TOKEN_STRING_MULTI);
     988                 :            : 
     989                 :          0 : static void cmd_create_port_meter_parsed(void *parsed_result,
     990                 :            :         __rte_unused struct cmdline *cl,
     991                 :            :         __rte_unused void *data)
     992                 :            : {
     993                 :            :         struct cmd_create_port_meter_result *res = parsed_result;
     994                 :            :         struct rte_mtr_error error;
     995                 :            :         struct rte_mtr_params params;
     996                 :          0 :         uint32_t mtr_id = res->mtr_id;
     997                 :          0 :         uint32_t shared = res->shared;
     998                 :          0 :         uint32_t use_prev_meter_color = 0;
     999                 :          0 :         uint16_t port_id = res->port_id;
    1000                 :          0 :         uint64_t def_inp_color = 0;
    1001                 :          0 :         enum rte_color *dscp_table = NULL;
    1002                 :          0 :         enum rte_color *vlan_table = NULL;
    1003                 :          0 :         char *def_color_str = res->default_input_color;
    1004                 :          0 :         char *c_str = res->meter_input_color;
    1005                 :            :         int ret;
    1006                 :            : 
    1007                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1008                 :          0 :                 return;
    1009                 :            : 
    1010                 :            :         /* Meter params */
    1011                 :            :         memset(&params, 0, sizeof(struct rte_mtr_params));
    1012                 :          0 :         params.meter_profile_id = res->profile_id;
    1013                 :          0 :         params.meter_policy_id = res->policy_id;
    1014                 :            : 
    1015                 :            :         /* Parse meter default input color string params */
    1016                 :          0 :         ret = parse_default_input_color_str(def_color_str, &def_inp_color);
    1017                 :          0 :         if (ret) {
    1018                 :          0 :                 fprintf(stderr,
    1019                 :            :                         " Meter default input color is invalid\n");
    1020                 :          0 :                 return;
    1021                 :            :         }
    1022                 :            : 
    1023                 :            :         /* Parse meter input color string params */
    1024                 :          0 :         ret = parse_meter_color_str(c_str, &use_prev_meter_color, &vlan_table,
    1025                 :            :                 &dscp_table);
    1026                 :          0 :         if (ret) {
    1027                 :          0 :                 fprintf(stderr,
    1028                 :            :                         " Meter input color params string parse error\n");
    1029                 :          0 :                 return;
    1030                 :            :         }
    1031                 :            : 
    1032                 :          0 :         params.use_prev_mtr_color = use_prev_meter_color;
    1033                 :          0 :         params.vlan_table = vlan_table;
    1034                 :          0 :         params.dscp_table = dscp_table;
    1035                 :          0 :         params.default_input_color = def_inp_color;
    1036                 :            : 
    1037                 :          0 :         if (strcmp(res->meter_enable, "yes") == 0)
    1038                 :          0 :                 params.meter_enable = 1;
    1039                 :            :         else
    1040                 :          0 :                 params.meter_enable = 0;
    1041                 :            : 
    1042                 :          0 :         params.stats_mask = res->statistics_mask;
    1043                 :            : 
    1044                 :          0 :         ret = rte_mtr_create(port_id, mtr_id, &params, shared, &error);
    1045                 :          0 :         if (ret != 0) {
    1046                 :          0 :                 free(vlan_table);
    1047                 :          0 :                 free(dscp_table);
    1048                 :          0 :                 print_err_msg(&error);
    1049                 :          0 :                 return;
    1050                 :            :         }
    1051                 :            : }
    1052                 :            : 
    1053                 :            : cmdline_parse_inst_t cmd_create_port_meter = {
    1054                 :            :         .f = cmd_create_port_meter_parsed,
    1055                 :            :         .data = NULL,
    1056                 :            :         .help_str = "create port meter <port_id> <mtr_id> <profile_id> <policy_id> "
    1057                 :            :                 "<meter_enable>(yes|no) <stats_mask> <shared> "
    1058                 :            :                 "<default_input_color>(g|y|r) <use_pre_meter_color> "
    1059                 :            :                 "[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>] "
    1060                 :            :                 "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
    1061                 :            :         .tokens = {
    1062                 :            :                 (void *)&cmd_create_port_meter_create,
    1063                 :            :                 (void *)&cmd_create_port_meter_port,
    1064                 :            :                 (void *)&cmd_create_port_meter_meter,
    1065                 :            :                 (void *)&cmd_create_port_meter_port_id,
    1066                 :            :                 (void *)&cmd_create_port_meter_mtr_id,
    1067                 :            :                 (void *)&cmd_create_port_meter_profile_id,
    1068                 :            :                 (void *)&cmd_create_port_meter_policy_id,
    1069                 :            :                 (void *)&cmd_create_port_meter_meter_enable,
    1070                 :            :                 (void *)&cmd_create_port_meter_statistics_mask,
    1071                 :            :                 (void *)&cmd_create_port_meter_shared,
    1072                 :            :                 (void *)&cmd_create_port_meter_default_input_color,
    1073                 :            :                 (void *)&cmd_create_port_meter_input_color,
    1074                 :            :                 NULL,
    1075                 :            :         },
    1076                 :            : };
    1077                 :            : 
    1078                 :            : /* *** Enable Meter of MTR Object  *** */
    1079                 :            : struct cmd_enable_port_meter_result {
    1080                 :            :         cmdline_fixed_string_t enable;
    1081                 :            :         cmdline_fixed_string_t port;
    1082                 :            :         cmdline_fixed_string_t meter;
    1083                 :            :         uint16_t port_id;
    1084                 :            :         uint32_t mtr_id;
    1085                 :            : };
    1086                 :            : 
    1087                 :            : static cmdline_parse_token_string_t cmd_enable_port_meter_enable =
    1088                 :            :         TOKEN_STRING_INITIALIZER(
    1089                 :            :                 struct cmd_enable_port_meter_result, enable, "enable");
    1090                 :            : static cmdline_parse_token_string_t cmd_enable_port_meter_port =
    1091                 :            :         TOKEN_STRING_INITIALIZER(
    1092                 :            :                 struct cmd_enable_port_meter_result, port, "port");
    1093                 :            : static cmdline_parse_token_string_t cmd_enable_port_meter_meter =
    1094                 :            :         TOKEN_STRING_INITIALIZER(
    1095                 :            :                 struct cmd_enable_port_meter_result, meter, "meter");
    1096                 :            : static cmdline_parse_token_num_t cmd_enable_port_meter_port_id =
    1097                 :            :         TOKEN_NUM_INITIALIZER(
    1098                 :            :                 struct cmd_enable_port_meter_result, port_id, RTE_UINT16);
    1099                 :            : static cmdline_parse_token_num_t cmd_enable_port_meter_mtr_id =
    1100                 :            :         TOKEN_NUM_INITIALIZER(
    1101                 :            :                 struct cmd_enable_port_meter_result, mtr_id, RTE_UINT32);
    1102                 :            : 
    1103                 :          0 : static void cmd_enable_port_meter_parsed(void *parsed_result,
    1104                 :            :         __rte_unused struct cmdline *cl,
    1105                 :            :         __rte_unused void *data)
    1106                 :            : {
    1107                 :            :         struct cmd_enable_port_meter_result *res = parsed_result;
    1108                 :            :         struct rte_mtr_error error;
    1109                 :          0 :         uint32_t mtr_id = res->mtr_id;
    1110                 :          0 :         uint16_t port_id = res->port_id;
    1111                 :            : 
    1112                 :            :         int ret;
    1113                 :            : 
    1114                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1115                 :          0 :                 return;
    1116                 :            : 
    1117                 :            :         /* Enable Meter */
    1118                 :          0 :         ret = rte_mtr_meter_enable(port_id, mtr_id, &error);
    1119                 :          0 :         if (ret != 0) {
    1120                 :          0 :                 print_err_msg(&error);
    1121                 :          0 :                 return;
    1122                 :            :         }
    1123                 :            : }
    1124                 :            : 
    1125                 :            : cmdline_parse_inst_t cmd_enable_port_meter = {
    1126                 :            :         .f = cmd_enable_port_meter_parsed,
    1127                 :            :         .data = NULL,
    1128                 :            :         .help_str = "enable port meter <port_id> <mtr_id>",
    1129                 :            :         .tokens = {
    1130                 :            :                 (void *)&cmd_enable_port_meter_enable,
    1131                 :            :                 (void *)&cmd_enable_port_meter_port,
    1132                 :            :                 (void *)&cmd_enable_port_meter_meter,
    1133                 :            :                 (void *)&cmd_enable_port_meter_port_id,
    1134                 :            :                 (void *)&cmd_enable_port_meter_mtr_id,
    1135                 :            :                 NULL,
    1136                 :            :         },
    1137                 :            : };
    1138                 :            : 
    1139                 :            : /* *** Disable Meter of MTR Object  *** */
    1140                 :            : struct cmd_disable_port_meter_result {
    1141                 :            :         cmdline_fixed_string_t disable;
    1142                 :            :         cmdline_fixed_string_t port;
    1143                 :            :         cmdline_fixed_string_t meter;
    1144                 :            :         uint16_t port_id;
    1145                 :            :         uint32_t mtr_id;
    1146                 :            : };
    1147                 :            : 
    1148                 :            : static cmdline_parse_token_string_t cmd_disable_port_meter_disable =
    1149                 :            :         TOKEN_STRING_INITIALIZER(
    1150                 :            :                 struct cmd_disable_port_meter_result, disable, "disable");
    1151                 :            : static cmdline_parse_token_string_t cmd_disable_port_meter_port =
    1152                 :            :         TOKEN_STRING_INITIALIZER(
    1153                 :            :                 struct cmd_disable_port_meter_result, port, "port");
    1154                 :            : static cmdline_parse_token_string_t cmd_disable_port_meter_meter =
    1155                 :            :         TOKEN_STRING_INITIALIZER(
    1156                 :            :                 struct cmd_disable_port_meter_result, meter, "meter");
    1157                 :            : static cmdline_parse_token_num_t cmd_disable_port_meter_port_id =
    1158                 :            :         TOKEN_NUM_INITIALIZER(
    1159                 :            :                 struct cmd_disable_port_meter_result, port_id, RTE_UINT16);
    1160                 :            : static cmdline_parse_token_num_t cmd_disable_port_meter_mtr_id =
    1161                 :            :         TOKEN_NUM_INITIALIZER(
    1162                 :            :                 struct cmd_disable_port_meter_result, mtr_id, RTE_UINT32);
    1163                 :            : 
    1164                 :          0 : static void cmd_disable_port_meter_parsed(void *parsed_result,
    1165                 :            :         __rte_unused struct cmdline *cl,
    1166                 :            :         __rte_unused void *data)
    1167                 :            : {
    1168                 :            :         struct cmd_disable_port_meter_result *res = parsed_result;
    1169                 :            :         struct rte_mtr_error error;
    1170                 :          0 :         uint32_t mtr_id = res->mtr_id;
    1171                 :          0 :         uint16_t port_id = res->port_id;
    1172                 :            : 
    1173                 :            :         int ret;
    1174                 :            : 
    1175                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1176                 :          0 :                 return;
    1177                 :            : 
    1178                 :            :         /* Disable Meter */
    1179                 :          0 :         ret = rte_mtr_meter_disable(port_id, mtr_id, &error);
    1180                 :          0 :         if (ret != 0) {
    1181                 :          0 :                 print_err_msg(&error);
    1182                 :          0 :                 return;
    1183                 :            :         }
    1184                 :            : }
    1185                 :            : 
    1186                 :            : cmdline_parse_inst_t cmd_disable_port_meter = {
    1187                 :            :         .f = cmd_disable_port_meter_parsed,
    1188                 :            :         .data = NULL,
    1189                 :            :         .help_str = "disable port meter <port_id> <mtr_id>",
    1190                 :            :         .tokens = {
    1191                 :            :                 (void *)&cmd_disable_port_meter_disable,
    1192                 :            :                 (void *)&cmd_disable_port_meter_port,
    1193                 :            :                 (void *)&cmd_disable_port_meter_meter,
    1194                 :            :                 (void *)&cmd_disable_port_meter_port_id,
    1195                 :            :                 (void *)&cmd_disable_port_meter_mtr_id,
    1196                 :            :                 NULL,
    1197                 :            :         },
    1198                 :            : };
    1199                 :            : 
    1200                 :            : /* *** Delete Port Meter Policy Object *** */
    1201                 :            : struct cmd_del_port_meter_policy_result {
    1202                 :            :         cmdline_fixed_string_t del;
    1203                 :            :         cmdline_fixed_string_t port;
    1204                 :            :         cmdline_fixed_string_t meter;
    1205                 :            :         cmdline_fixed_string_t policy;
    1206                 :            :         uint16_t port_id;
    1207                 :            :         uint32_t policy_id;
    1208                 :            : };
    1209                 :            : 
    1210                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_policy_del =
    1211                 :            :         TOKEN_STRING_INITIALIZER(
    1212                 :            :                 struct cmd_del_port_meter_policy_result, del, "del");
    1213                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_policy_port =
    1214                 :            :         TOKEN_STRING_INITIALIZER(
    1215                 :            :                 struct cmd_del_port_meter_policy_result, port, "port");
    1216                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_policy_meter =
    1217                 :            :         TOKEN_STRING_INITIALIZER(
    1218                 :            :                 struct cmd_del_port_meter_policy_result, meter, "meter");
    1219                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_policy_policy =
    1220                 :            :         TOKEN_STRING_INITIALIZER(
    1221                 :            :                 struct cmd_del_port_meter_policy_result, policy, "policy");
    1222                 :            : static cmdline_parse_token_num_t cmd_del_port_meter_policy_port_id =
    1223                 :            :         TOKEN_NUM_INITIALIZER(
    1224                 :            :                 struct cmd_del_port_meter_policy_result, port_id, RTE_UINT16);
    1225                 :            : static cmdline_parse_token_num_t cmd_del_port_meter_policy_policy_id =
    1226                 :            :         TOKEN_NUM_INITIALIZER(
    1227                 :            :                 struct cmd_del_port_meter_policy_result, policy_id, RTE_UINT32);
    1228                 :            : 
    1229                 :          0 : static void cmd_del_port_meter_policy_parsed(void *parsed_result,
    1230                 :            :         __rte_unused struct cmdline *cl,
    1231                 :            :         __rte_unused void *data)
    1232                 :            : {
    1233                 :            :         struct cmd_del_port_meter_policy_result *res = parsed_result;
    1234                 :            :         struct rte_mtr_error error;
    1235                 :          0 :         uint32_t policy_id = res->policy_id;
    1236                 :          0 :         uint16_t port_id = res->port_id;
    1237                 :            :         int ret;
    1238                 :            : 
    1239                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1240                 :          0 :                 return;
    1241                 :            : 
    1242                 :            :         /* Delete Meter Policy*/
    1243                 :          0 :         ret = rte_mtr_meter_policy_delete(port_id, policy_id, &error);
    1244                 :          0 :         if (ret != 0) {
    1245                 :          0 :                 print_err_msg(&error);
    1246                 :          0 :                 return;
    1247                 :            :         }
    1248                 :            : }
    1249                 :            : 
    1250                 :            : cmdline_parse_inst_t cmd_del_port_meter_policy = {
    1251                 :            :         .f = cmd_del_port_meter_policy_parsed,
    1252                 :            :         .data = NULL,
    1253                 :            :         .help_str = "Delete port meter policy",
    1254                 :            :         .tokens = {
    1255                 :            :                 (void *)&cmd_del_port_meter_policy_del,
    1256                 :            :                 (void *)&cmd_del_port_meter_policy_port,
    1257                 :            :                 (void *)&cmd_del_port_meter_policy_meter,
    1258                 :            :                 (void *)&cmd_del_port_meter_policy_policy,
    1259                 :            :                 (void *)&cmd_del_port_meter_policy_port_id,
    1260                 :            :                 (void *)&cmd_del_port_meter_policy_policy_id,
    1261                 :            :                 NULL,
    1262                 :            :         },
    1263                 :            : };
    1264                 :            : 
    1265                 :            : /* *** Delete Port Meter Object *** */
    1266                 :            : struct cmd_del_port_meter_result {
    1267                 :            :         cmdline_fixed_string_t del;
    1268                 :            :         cmdline_fixed_string_t port;
    1269                 :            :         cmdline_fixed_string_t meter;
    1270                 :            :         uint16_t port_id;
    1271                 :            :         uint32_t mtr_id;
    1272                 :            : };
    1273                 :            : 
    1274                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_del =
    1275                 :            :         TOKEN_STRING_INITIALIZER(
    1276                 :            :                 struct cmd_del_port_meter_result, del, "del");
    1277                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_port =
    1278                 :            :         TOKEN_STRING_INITIALIZER(
    1279                 :            :                 struct cmd_del_port_meter_result, port, "port");
    1280                 :            : static cmdline_parse_token_string_t cmd_del_port_meter_meter =
    1281                 :            :         TOKEN_STRING_INITIALIZER(
    1282                 :            :                 struct cmd_del_port_meter_result, meter, "meter");
    1283                 :            : static cmdline_parse_token_num_t cmd_del_port_meter_port_id =
    1284                 :            :         TOKEN_NUM_INITIALIZER(
    1285                 :            :                 struct cmd_del_port_meter_result, port_id, RTE_UINT16);
    1286                 :            : static cmdline_parse_token_num_t cmd_del_port_meter_mtr_id =
    1287                 :            :         TOKEN_NUM_INITIALIZER(
    1288                 :            :                 struct cmd_del_port_meter_result, mtr_id, RTE_UINT32);
    1289                 :            : 
    1290                 :          0 : static void cmd_del_port_meter_parsed(void *parsed_result,
    1291                 :            :         __rte_unused struct cmdline *cl,
    1292                 :            :         __rte_unused void *data)
    1293                 :            : {
    1294                 :            :         struct cmd_del_port_meter_result *res = parsed_result;
    1295                 :            :         struct rte_mtr_error error;
    1296                 :          0 :         uint32_t mtr_id = res->mtr_id;
    1297                 :          0 :         uint16_t port_id = res->port_id;
    1298                 :            : 
    1299                 :            :         int ret;
    1300                 :            : 
    1301                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1302                 :          0 :                 return;
    1303                 :            : 
    1304                 :            :         /* Destroy Meter */
    1305                 :          0 :         ret = rte_mtr_destroy(port_id, mtr_id, &error);
    1306                 :          0 :         if (ret != 0) {
    1307                 :          0 :                 print_err_msg(&error);
    1308                 :          0 :                 return;
    1309                 :            :         }
    1310                 :            : }
    1311                 :            : 
    1312                 :            : cmdline_parse_inst_t cmd_del_port_meter = {
    1313                 :            :         .f = cmd_del_port_meter_parsed,
    1314                 :            :         .data = NULL,
    1315                 :            :         .help_str = "del port meter <port_id> <mtr_id>",
    1316                 :            :         .tokens = {
    1317                 :            :                 (void *)&cmd_del_port_meter_del,
    1318                 :            :                 (void *)&cmd_del_port_meter_port,
    1319                 :            :                 (void *)&cmd_del_port_meter_meter,
    1320                 :            :                 (void *)&cmd_del_port_meter_port_id,
    1321                 :            :                 (void *)&cmd_del_port_meter_mtr_id,
    1322                 :            :                 NULL,
    1323                 :            :         },
    1324                 :            : };
    1325                 :            : 
    1326                 :            : /* *** Set Port Meter Profile *** */
    1327                 :            : struct cmd_set_port_meter_profile_result {
    1328                 :            :         cmdline_fixed_string_t set;
    1329                 :            :         cmdline_fixed_string_t port;
    1330                 :            :         cmdline_fixed_string_t meter;
    1331                 :            :         cmdline_fixed_string_t profile;
    1332                 :            :         uint16_t port_id;
    1333                 :            :         uint32_t mtr_id;
    1334                 :            :         uint32_t profile_id;
    1335                 :            : };
    1336                 :            : 
    1337                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_profile_set =
    1338                 :            :         TOKEN_STRING_INITIALIZER(
    1339                 :            :                 struct cmd_set_port_meter_profile_result, set, "set");
    1340                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_profile_port =
    1341                 :            :         TOKEN_STRING_INITIALIZER(
    1342                 :            :                 struct cmd_set_port_meter_profile_result, port, "port");
    1343                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_profile_meter =
    1344                 :            :         TOKEN_STRING_INITIALIZER(
    1345                 :            :                 struct cmd_set_port_meter_profile_result, meter, "meter");
    1346                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_profile_profile =
    1347                 :            :         TOKEN_STRING_INITIALIZER(
    1348                 :            :                 struct cmd_set_port_meter_profile_result, profile, "profile");
    1349                 :            : static cmdline_parse_token_num_t cmd_set_port_meter_profile_port_id =
    1350                 :            :         TOKEN_NUM_INITIALIZER(
    1351                 :            :                 struct cmd_set_port_meter_profile_result, port_id,
    1352                 :            :                 RTE_UINT16);
    1353                 :            : static cmdline_parse_token_num_t cmd_set_port_meter_profile_mtr_id =
    1354                 :            :         TOKEN_NUM_INITIALIZER(
    1355                 :            :                 struct cmd_set_port_meter_profile_result, mtr_id,
    1356                 :            :                 RTE_UINT32);
    1357                 :            : static cmdline_parse_token_num_t cmd_set_port_meter_profile_profile_id =
    1358                 :            :         TOKEN_NUM_INITIALIZER(
    1359                 :            :                 struct cmd_set_port_meter_profile_result, profile_id,
    1360                 :            :                 RTE_UINT32);
    1361                 :            : 
    1362                 :          0 : static void cmd_set_port_meter_profile_parsed(void *parsed_result,
    1363                 :            :         __rte_unused struct cmdline *cl,
    1364                 :            :         __rte_unused void *data)
    1365                 :            : {
    1366                 :            :         struct cmd_set_port_meter_profile_result *res = parsed_result;
    1367                 :            :         struct rte_mtr_error error;
    1368                 :          0 :         uint32_t mtr_id = res->mtr_id;
    1369                 :          0 :         uint32_t profile_id = res->profile_id;
    1370                 :          0 :         uint16_t port_id = res->port_id;
    1371                 :            : 
    1372                 :            :         int ret;
    1373                 :            : 
    1374                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1375                 :          0 :                 return;
    1376                 :            : 
    1377                 :            :         /* Set meter profile */
    1378                 :          0 :         ret = rte_mtr_meter_profile_update(port_id, mtr_id,
    1379                 :            :                 profile_id, &error);
    1380                 :          0 :         if (ret != 0) {
    1381                 :          0 :                 print_err_msg(&error);
    1382                 :          0 :                 return;
    1383                 :            :         }
    1384                 :            : }
    1385                 :            : 
    1386                 :            : cmdline_parse_inst_t cmd_set_port_meter_profile = {
    1387                 :            :         .f = cmd_set_port_meter_profile_parsed,
    1388                 :            :         .data = NULL,
    1389                 :            :         .help_str = "set port meter profile <port_id> <mtr_id> <profile_id>",
    1390                 :            :         .tokens = {
    1391                 :            :                 (void *)&cmd_set_port_meter_profile_set,
    1392                 :            :                 (void *)&cmd_set_port_meter_profile_port,
    1393                 :            :                 (void *)&cmd_set_port_meter_profile_meter,
    1394                 :            :                 (void *)&cmd_set_port_meter_profile_profile,
    1395                 :            :                 (void *)&cmd_set_port_meter_profile_port_id,
    1396                 :            :                 (void *)&cmd_set_port_meter_profile_mtr_id,
    1397                 :            :                 (void *)&cmd_set_port_meter_profile_profile_id,
    1398                 :            :                 NULL,
    1399                 :            :         },
    1400                 :            : };
    1401                 :            : 
    1402                 :            : /* *** Set Port Meter DSCP Table *** */
    1403                 :            : struct cmd_set_port_meter_dscp_table_result {
    1404                 :            :         cmdline_fixed_string_t set;
    1405                 :            :         cmdline_fixed_string_t port;
    1406                 :            :         cmdline_fixed_string_t meter;
    1407                 :            :         cmdline_fixed_string_t dscp_table;
    1408                 :            :         cmdline_multi_string_t token_string;
    1409                 :            : };
    1410                 :            : 
    1411                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_dscp_table_set =
    1412                 :            :         TOKEN_STRING_INITIALIZER(
    1413                 :            :                 struct cmd_set_port_meter_dscp_table_result, set, "set");
    1414                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_dscp_table_port =
    1415                 :            :         TOKEN_STRING_INITIALIZER(
    1416                 :            :                 struct cmd_set_port_meter_dscp_table_result, port, "port");
    1417                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_dscp_table_meter =
    1418                 :            :         TOKEN_STRING_INITIALIZER(
    1419                 :            :                 struct cmd_set_port_meter_dscp_table_result, meter, "meter");
    1420                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_dscp_table_dscp_table =
    1421                 :            :         TOKEN_STRING_INITIALIZER(
    1422                 :            :                 struct cmd_set_port_meter_dscp_table_result,
    1423                 :            :                 dscp_table, "dscp table");
    1424                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_dscp_table_token_string =
    1425                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_dscp_table_result,
    1426                 :            :                 token_string, TOKEN_STRING_MULTI);
    1427                 :            : 
    1428                 :          0 : static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
    1429                 :            :         __rte_unused struct cmdline *cl,
    1430                 :            :         __rte_unused void *data)
    1431                 :            : {
    1432                 :            :         struct cmd_set_port_meter_dscp_table_result *res = parsed_result;
    1433                 :          0 :         enum rte_mtr_color_in_protocol proto = 0;
    1434                 :            :         struct rte_mtr_error error;
    1435                 :          0 :         enum rte_color *dscp_table = NULL;
    1436                 :          0 :         char *t_str = res->token_string;
    1437                 :          0 :         uint32_t mtr_id = 0;
    1438                 :            :         uint16_t port_id;
    1439                 :            :         int ret;
    1440                 :            : 
    1441                 :            :         /* Parse string */
    1442                 :          0 :         ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &proto,
    1443                 :            :                                        &dscp_table);
    1444                 :          0 :         if (ret) {
    1445                 :          0 :                 fprintf(stderr, " Multi token string parse error\n");
    1446                 :          0 :                 return;
    1447                 :            :         }
    1448                 :            : 
    1449                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1450                 :          0 :                 goto free_table;
    1451                 :            : 
    1452                 :            :         /* Update Meter DSCP Table*/
    1453                 :          0 :         ret = rte_mtr_meter_dscp_table_update(port_id, mtr_id, proto,
    1454                 :            :                 dscp_table, &error);
    1455                 :          0 :         if (ret != 0)
    1456                 :          0 :                 print_err_msg(&error);
    1457                 :            : 
    1458                 :          0 : free_table:
    1459                 :          0 :         free(dscp_table);
    1460                 :            : }
    1461                 :            : 
    1462                 :            : cmdline_parse_inst_t cmd_set_port_meter_dscp_table = {
    1463                 :            :         .f = cmd_set_port_meter_dscp_table_parsed,
    1464                 :            :         .data = NULL,
    1465                 :            :         .help_str = "set port meter dscp table <port_id> <mtr_id> <proto> "
    1466                 :            :                 "[<dscp_tbl_entry0> <dscp_tbl_entry1> ... <dscp_tbl_entry63>]",
    1467                 :            :         .tokens = {
    1468                 :            :                 (void *)&cmd_set_port_meter_dscp_table_set,
    1469                 :            :                 (void *)&cmd_set_port_meter_dscp_table_port,
    1470                 :            :                 (void *)&cmd_set_port_meter_dscp_table_meter,
    1471                 :            :                 (void *)&cmd_set_port_meter_dscp_table_dscp_table,
    1472                 :            :                 (void *)&cmd_set_port_meter_dscp_table_token_string,
    1473                 :            :                 NULL,
    1474                 :            :         },
    1475                 :            : };
    1476                 :            : 
    1477                 :            : /* *** Set Port Meter VLAN Table *** */
    1478                 :            : struct cmd_set_port_meter_vlan_table_result {
    1479                 :            :         cmdline_fixed_string_t set;
    1480                 :            :         cmdline_fixed_string_t port;
    1481                 :            :         cmdline_fixed_string_t meter;
    1482                 :            :         cmdline_fixed_string_t vlan_table;
    1483                 :            :         cmdline_multi_string_t token_string;
    1484                 :            : };
    1485                 :            : 
    1486                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_set =
    1487                 :            :         TOKEN_STRING_INITIALIZER(
    1488                 :            :                 struct cmd_set_port_meter_vlan_table_result, set, "set");
    1489                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_port =
    1490                 :            :         TOKEN_STRING_INITIALIZER(
    1491                 :            :                 struct cmd_set_port_meter_vlan_table_result, port, "port");
    1492                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_meter =
    1493                 :            :         TOKEN_STRING_INITIALIZER(
    1494                 :            :                 struct cmd_set_port_meter_vlan_table_result, meter, "meter");
    1495                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_vlan_table =
    1496                 :            :         TOKEN_STRING_INITIALIZER(
    1497                 :            :                 struct cmd_set_port_meter_vlan_table_result,
    1498                 :            :                 vlan_table, "vlan table");
    1499                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_vlan_table_token_string =
    1500                 :            :         TOKEN_STRING_INITIALIZER(struct cmd_set_port_meter_vlan_table_result,
    1501                 :            :                 token_string, TOKEN_STRING_MULTI);
    1502                 :            : 
    1503                 :          0 : static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result,
    1504                 :            :         __rte_unused struct cmdline *cl,
    1505                 :            :         __rte_unused void *data)
    1506                 :            : {
    1507                 :            :         struct cmd_set_port_meter_vlan_table_result *res = parsed_result;
    1508                 :          0 :         enum rte_mtr_color_in_protocol proto = 0;
    1509                 :            :         struct rte_mtr_error error;
    1510                 :          0 :         enum rte_color *vlan_table = NULL;
    1511                 :          0 :         char *t_str = res->token_string;
    1512                 :          0 :         uint32_t mtr_id = 0;
    1513                 :            :         uint16_t port_id;
    1514                 :            :         int ret;
    1515                 :            : 
    1516                 :            :         /* Parse string */
    1517                 :          0 :         ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &proto,
    1518                 :            :                                          &vlan_table);
    1519                 :          0 :         if (ret) {
    1520                 :          0 :                 fprintf(stderr, " Multi token string parse error\n");
    1521                 :          0 :                 return;
    1522                 :            :         }
    1523                 :            : 
    1524                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1525                 :          0 :                 goto free_table;
    1526                 :            : 
    1527                 :            :         /* Update Meter VLAN Table*/
    1528                 :          0 :         ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id, proto,
    1529                 :            :                 vlan_table, &error);
    1530                 :          0 :         if (ret != 0)
    1531                 :          0 :                 print_err_msg(&error);
    1532                 :            : 
    1533                 :          0 : free_table:
    1534                 :          0 :         free(vlan_table);
    1535                 :            : }
    1536                 :            : 
    1537                 :            : cmdline_parse_inst_t cmd_set_port_meter_vlan_table = {
    1538                 :            :         .f = cmd_set_port_meter_vlan_table_parsed,
    1539                 :            :         .data = NULL,
    1540                 :            :         .help_str = "set port meter vlan table <port_id> <mtr_id> <proto> "
    1541                 :            :                 "[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>]",
    1542                 :            :         .tokens = {
    1543                 :            :                 (void *)&cmd_set_port_meter_vlan_table_set,
    1544                 :            :                 (void *)&cmd_set_port_meter_vlan_table_port,
    1545                 :            :                 (void *)&cmd_set_port_meter_vlan_table_meter,
    1546                 :            :                 (void *)&cmd_set_port_meter_vlan_table_vlan_table,
    1547                 :            :                 (void *)&cmd_set_port_meter_vlan_table_token_string,
    1548                 :            :                 NULL,
    1549                 :            :         },
    1550                 :            : };
    1551                 :            : 
    1552                 :            : /* *** Set Port Meter input protocol *** */
    1553                 :            : struct cmd_set_port_meter_in_proto_result {
    1554                 :            :         cmdline_fixed_string_t set;
    1555                 :            :         cmdline_fixed_string_t port;
    1556                 :            :         cmdline_fixed_string_t meter;
    1557                 :            :         cmdline_fixed_string_t protocol;
    1558                 :            :         cmdline_fixed_string_t proto;
    1559                 :            :         uint32_t prio;
    1560                 :            :         uint32_t mtr_id;
    1561                 :            :         uint16_t port_id;
    1562                 :            : };
    1563                 :            : 
    1564                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_set =
    1565                 :            :         TOKEN_STRING_INITIALIZER(
    1566                 :            :                 struct cmd_set_port_meter_in_proto_result, set, "set");
    1567                 :            : 
    1568                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_port =
    1569                 :            :         TOKEN_STRING_INITIALIZER(
    1570                 :            :                 struct cmd_set_port_meter_in_proto_result, port, "port");
    1571                 :            : 
    1572                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_meter =
    1573                 :            :         TOKEN_STRING_INITIALIZER(
    1574                 :            :                 struct cmd_set_port_meter_in_proto_result, meter, "meter");
    1575                 :            : 
    1576                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_protocol =
    1577                 :            :         TOKEN_STRING_INITIALIZER(
    1578                 :            :                 struct cmd_set_port_meter_in_proto_result, protocol, "proto");
    1579                 :            : 
    1580                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_in_proto_proto =
    1581                 :            :         TOKEN_STRING_INITIALIZER(
    1582                 :            :                 struct cmd_set_port_meter_in_proto_result, proto,
    1583                 :            :                 "outer_vlan#inner_vlan#outer_ip#inner_ip");
    1584                 :            : 
    1585                 :            : static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_prio =
    1586                 :            :         TOKEN_NUM_INITIALIZER(
    1587                 :            :                 struct cmd_set_port_meter_in_proto_result, prio, RTE_UINT32);
    1588                 :            : 
    1589                 :            : static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_port_id =
    1590                 :            :         TOKEN_NUM_INITIALIZER(
    1591                 :            :                 struct cmd_set_port_meter_in_proto_result, port_id, RTE_UINT16);
    1592                 :            : 
    1593                 :            : static cmdline_parse_token_num_t cmd_set_port_meter_in_proto_mtr_id =
    1594                 :            :         TOKEN_NUM_INITIALIZER(
    1595                 :            :                 struct cmd_set_port_meter_in_proto_result, mtr_id, RTE_UINT32);
    1596                 :            : 
    1597                 :          0 : static void cmd_set_port_meter_in_proto_parsed(void *parsed_result,
    1598                 :            :         __rte_unused struct cmdline *cl,
    1599                 :            :         __rte_unused void *data)
    1600                 :            : {
    1601                 :            :         struct cmd_set_port_meter_in_proto_result *res = parsed_result;
    1602                 :            :         enum rte_mtr_color_in_protocol proto;
    1603                 :            :         struct rte_mtr_error error;
    1604                 :            :         int ret;
    1605                 :            : 
    1606                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    1607                 :          0 :                 return;
    1608                 :            : 
    1609                 :          0 :         if (strcmp(res->proto, "outer_vlan") == 0)
    1610                 :            :                 proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
    1611                 :          0 :         else if (strcmp(res->proto, "inner_vlan") == 0)
    1612                 :            :                 proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
    1613                 :          0 :         else if (strcmp(res->proto, "outer_ip") == 0)
    1614                 :            :                 proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
    1615                 :          0 :         else if (strcmp(res->proto, "inner_ip") == 0)
    1616                 :            :                 proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
    1617                 :            :         else {
    1618                 :            :                 printf("Invalid protocol\n");
    1619                 :          0 :                 return;
    1620                 :            :         }
    1621                 :            : 
    1622                 :            :         /* Update Meter input proto and priority */
    1623                 :          0 :         ret = rte_mtr_color_in_protocol_set(res->port_id, res->mtr_id,
    1624                 :            :                 proto, res->prio, &error);
    1625                 :          0 :         if (ret != 0)
    1626                 :          0 :                 print_err_msg(&error);
    1627                 :            : }
    1628                 :            : 
    1629                 :            : cmdline_parse_inst_t cmd_set_port_meter_in_proto = {
    1630                 :            :         .f = cmd_set_port_meter_in_proto_parsed,
    1631                 :            :         .data = NULL,
    1632                 :            :         .help_str = "set port meter proto <port_id> <mtr_id> <proto> "
    1633                 :            :                 "<prio>",
    1634                 :            :         .tokens = {
    1635                 :            :                 (void *)&cmd_set_port_meter_in_proto_set,
    1636                 :            :                 (void *)&cmd_set_port_meter_in_proto_port,
    1637                 :            :                 (void *)&cmd_set_port_meter_in_proto_meter,
    1638                 :            :                 (void *)&cmd_set_port_meter_in_proto_protocol,
    1639                 :            :                 (void *)&cmd_set_port_meter_in_proto_port_id,
    1640                 :            :                 (void *)&cmd_set_port_meter_in_proto_mtr_id,
    1641                 :            :                 (void *)&cmd_set_port_meter_in_proto_proto,
    1642                 :            :                 (void *)&cmd_set_port_meter_in_proto_prio,
    1643                 :            :                 NULL,
    1644                 :            :         },
    1645                 :            : };
    1646                 :            : 
    1647                 :            : /* *** Get Port Meter input protocol *** */
    1648                 :            : struct cmd_get_port_meter_in_proto_result {
    1649                 :            :         cmdline_fixed_string_t get;
    1650                 :            :         cmdline_fixed_string_t port;
    1651                 :            :         cmdline_fixed_string_t meter;
    1652                 :            :         cmdline_fixed_string_t protocol;
    1653                 :            :         uint32_t mtr_id;
    1654                 :            :         uint16_t port_id;
    1655                 :            : };
    1656                 :            : 
    1657                 :            : static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_get =
    1658                 :            :         TOKEN_STRING_INITIALIZER(
    1659                 :            :                 struct cmd_get_port_meter_in_proto_result, get, "get");
    1660                 :            : 
    1661                 :            : static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_port =
    1662                 :            :         TOKEN_STRING_INITIALIZER(
    1663                 :            :                 struct cmd_get_port_meter_in_proto_result, port, "port");
    1664                 :            : 
    1665                 :            : static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_meter =
    1666                 :            :         TOKEN_STRING_INITIALIZER(
    1667                 :            :                 struct cmd_get_port_meter_in_proto_result, meter, "meter");
    1668                 :            : 
    1669                 :            : static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_protocol =
    1670                 :            :         TOKEN_STRING_INITIALIZER(
    1671                 :            :                 struct cmd_get_port_meter_in_proto_result, protocol, "proto");
    1672                 :            : 
    1673                 :            : static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_port_id =
    1674                 :            :         TOKEN_NUM_INITIALIZER(
    1675                 :            :                 struct cmd_get_port_meter_in_proto_result, port_id, RTE_UINT16);
    1676                 :            : 
    1677                 :            : static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_mtr_id =
    1678                 :            :         TOKEN_NUM_INITIALIZER(
    1679                 :            :                 struct cmd_get_port_meter_in_proto_result, mtr_id, RTE_UINT32);
    1680                 :            : 
    1681                 :          0 : static void cmd_get_port_meter_in_proto_parsed(void *parsed_result,
    1682                 :            :         __rte_unused struct cmdline *cl,
    1683                 :            :         __rte_unused void *data)
    1684                 :            : {
    1685                 :            :         struct cmd_set_port_meter_in_proto_result *res = parsed_result;
    1686                 :            :         struct rte_mtr_error error;
    1687                 :          0 :         uint64_t proto_mask = 0;
    1688                 :            :         int ret;
    1689                 :            : 
    1690                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    1691                 :          0 :                 return;
    1692                 :            : 
    1693                 :            :         /* Update Meter input proto and priority */
    1694                 :          0 :         ret = rte_mtr_color_in_protocol_get(res->port_id, res->mtr_id,
    1695                 :            :                 &proto_mask, &error);
    1696                 :          0 :         if (ret != 0)
    1697                 :          0 :                 print_err_msg(&error);
    1698                 :            : 
    1699                 :            :         printf("Enabled protocols:\n");
    1700                 :          0 :         if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN)
    1701                 :            :                 printf("\touter_vlan\n");
    1702                 :          0 :         if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_VLAN)
    1703                 :            :                 printf("\tinner_vlan\n");
    1704                 :          0 :         if (proto_mask & RTE_MTR_COLOR_IN_PROTO_OUTER_IP)
    1705                 :            :                 printf("\touter_ip\n");
    1706                 :          0 :         if (proto_mask & RTE_MTR_COLOR_IN_PROTO_INNER_IP)
    1707                 :            :                 printf("\tinner_ip\n");
    1708                 :            : }
    1709                 :            : 
    1710                 :            : cmdline_parse_inst_t cmd_get_port_meter_in_proto = {
    1711                 :            :         .f = cmd_get_port_meter_in_proto_parsed,
    1712                 :            :         .data = NULL,
    1713                 :            :         .help_str = "get port meter proto <port_id> <mtr_id>",
    1714                 :            :         .tokens = {
    1715                 :            :                 (void *)&cmd_get_port_meter_in_proto_get,
    1716                 :            :                 (void *)&cmd_get_port_meter_in_proto_port,
    1717                 :            :                 (void *)&cmd_get_port_meter_in_proto_meter,
    1718                 :            :                 (void *)&cmd_get_port_meter_in_proto_protocol,
    1719                 :            :                 (void *)&cmd_get_port_meter_in_proto_port_id,
    1720                 :            :                 (void *)&cmd_get_port_meter_in_proto_mtr_id,
    1721                 :            :                 NULL,
    1722                 :            :         },
    1723                 :            : };
    1724                 :            : 
    1725                 :            : /* *** Get Port Meter input protocol priority *** */
    1726                 :            : struct cmd_get_port_meter_in_proto_prio_result {
    1727                 :            :         cmdline_fixed_string_t get;
    1728                 :            :         cmdline_fixed_string_t port;
    1729                 :            :         cmdline_fixed_string_t meter;
    1730                 :            :         cmdline_fixed_string_t protocol;
    1731                 :            :         cmdline_fixed_string_t proto;
    1732                 :            :         uint32_t mtr_id;
    1733                 :            :         uint16_t port_id;
    1734                 :            : };
    1735                 :            : 
    1736                 :            : static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_get =
    1737                 :            :         TOKEN_STRING_INITIALIZER(
    1738                 :            :                 struct cmd_get_port_meter_in_proto_prio_result, get, "get");
    1739                 :            : 
    1740                 :            : static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_port =
    1741                 :            :         TOKEN_STRING_INITIALIZER(
    1742                 :            :                 struct cmd_get_port_meter_in_proto_prio_result, port, "port");
    1743                 :            : 
    1744                 :            : static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_meter =
    1745                 :            :         TOKEN_STRING_INITIALIZER(
    1746                 :            :                 struct cmd_get_port_meter_in_proto_prio_result, meter, "meter");
    1747                 :            : 
    1748                 :            : static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_protocol =
    1749                 :            :         TOKEN_STRING_INITIALIZER(
    1750                 :            :                 struct cmd_get_port_meter_in_proto_prio_result, protocol,
    1751                 :            :                 "proto_prio");
    1752                 :            : 
    1753                 :            : static cmdline_parse_token_string_t cmd_get_port_meter_in_proto_prio_proto =
    1754                 :            :         TOKEN_STRING_INITIALIZER(
    1755                 :            :                 struct cmd_get_port_meter_in_proto_prio_result, proto,
    1756                 :            :                 "outer_vlan#inner_vlan#outer_ip#inner_ip");
    1757                 :            : 
    1758                 :            : static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_port_id =
    1759                 :            :         TOKEN_NUM_INITIALIZER(
    1760                 :            :                 struct cmd_get_port_meter_in_proto_prio_result, port_id,
    1761                 :            :                 RTE_UINT16);
    1762                 :            : 
    1763                 :            : static cmdline_parse_token_num_t cmd_get_port_meter_in_proto_prio_mtr_id =
    1764                 :            :         TOKEN_NUM_INITIALIZER(
    1765                 :            :                 struct cmd_get_port_meter_in_proto_prio_result, mtr_id,
    1766                 :            :                 RTE_UINT32);
    1767                 :            : 
    1768                 :          0 : static void cmd_get_port_meter_in_proto_prio_parsed(void *parsed_result,
    1769                 :            :         __rte_unused struct cmdline *cl,
    1770                 :            :         __rte_unused void *data)
    1771                 :            : {
    1772                 :            :         struct cmd_get_port_meter_in_proto_prio_result *res = parsed_result;
    1773                 :            :         enum rte_mtr_color_in_protocol proto;
    1774                 :            :         struct rte_mtr_error error;
    1775                 :          0 :         uint32_t prio = 0;
    1776                 :            :         int ret;
    1777                 :            : 
    1778                 :          0 :         if (port_id_is_invalid(res->port_id, ENABLED_WARN))
    1779                 :          0 :                 return;
    1780                 :            : 
    1781                 :          0 :         if (strcmp(res->proto, "outer_vlan") == 0)
    1782                 :            :                 proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN;
    1783                 :          0 :         else if (strcmp(res->proto, "inner_vlan") == 0)
    1784                 :            :                 proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN;
    1785                 :          0 :         else if (strcmp(res->proto, "outer_ip") == 0)
    1786                 :            :                 proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP;
    1787                 :          0 :         else if (strcmp(res->proto, "inner_ip") == 0)
    1788                 :            :                 proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP;
    1789                 :            :         else {
    1790                 :            :                 printf("Invalid protocol\n");
    1791                 :          0 :                 return;
    1792                 :            :         }
    1793                 :            : 
    1794                 :            :         /* Get Meter input proto and priority */
    1795                 :          0 :         ret = rte_mtr_color_in_protocol_priority_get(res->port_id, res->mtr_id,
    1796                 :            :                 proto, &prio, &error);
    1797                 :          0 :         if (ret != 0)
    1798                 :          0 :                 print_err_msg(&error);
    1799                 :            : }
    1800                 :            : 
    1801                 :            : cmdline_parse_inst_t cmd_get_port_meter_in_proto_prio = {
    1802                 :            :         .f = cmd_get_port_meter_in_proto_prio_parsed,
    1803                 :            :         .data = NULL,
    1804                 :            :         .help_str = "get port meter proto_prio <port_id> <mtr_id> <proto>",
    1805                 :            :         .tokens = {
    1806                 :            :                 (void *)&cmd_get_port_meter_in_proto_prio_get,
    1807                 :            :                 (void *)&cmd_get_port_meter_in_proto_prio_port,
    1808                 :            :                 (void *)&cmd_get_port_meter_in_proto_prio_meter,
    1809                 :            :                 (void *)&cmd_get_port_meter_in_proto_prio_protocol,
    1810                 :            :                 (void *)&cmd_get_port_meter_in_proto_prio_port_id,
    1811                 :            :                 (void *)&cmd_get_port_meter_in_proto_prio_mtr_id,
    1812                 :            :                 (void *)&cmd_get_port_meter_in_proto_prio_proto,
    1813                 :            :                 NULL,
    1814                 :            :         },
    1815                 :            : };
    1816                 :            : 
    1817                 :            : /* *** Set Port Meter Stats Mask *** */
    1818                 :            : struct cmd_set_port_meter_stats_mask_result {
    1819                 :            :         cmdline_fixed_string_t set;
    1820                 :            :         cmdline_fixed_string_t port;
    1821                 :            :         cmdline_fixed_string_t meter;
    1822                 :            :         cmdline_fixed_string_t stats;
    1823                 :            :         cmdline_fixed_string_t mask;
    1824                 :            :         uint16_t port_id;
    1825                 :            :         uint32_t mtr_id;
    1826                 :            :         uint64_t stats_mask;
    1827                 :            : };
    1828                 :            : 
    1829                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_stats_mask_set =
    1830                 :            :         TOKEN_STRING_INITIALIZER(
    1831                 :            :                 struct cmd_set_port_meter_stats_mask_result, set, "set");
    1832                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_stats_mask_port =
    1833                 :            :         TOKEN_STRING_INITIALIZER(
    1834                 :            :                 struct cmd_set_port_meter_stats_mask_result, port, "port");
    1835                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_stats_mask_meter =
    1836                 :            :         TOKEN_STRING_INITIALIZER(
    1837                 :            :                 struct cmd_set_port_meter_stats_mask_result, meter, "meter");
    1838                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_stats_mask_stats =
    1839                 :            :         TOKEN_STRING_INITIALIZER(
    1840                 :            :                 struct cmd_set_port_meter_stats_mask_result, stats, "stats");
    1841                 :            : static cmdline_parse_token_string_t cmd_set_port_meter_stats_mask_mask =
    1842                 :            :         TOKEN_STRING_INITIALIZER(
    1843                 :            :                 struct cmd_set_port_meter_stats_mask_result, mask, "mask");
    1844                 :            : static cmdline_parse_token_num_t cmd_set_port_meter_stats_mask_port_id =
    1845                 :            :         TOKEN_NUM_INITIALIZER(
    1846                 :            :                 struct cmd_set_port_meter_stats_mask_result, port_id,
    1847                 :            :                 RTE_UINT16);
    1848                 :            : static cmdline_parse_token_num_t cmd_set_port_meter_stats_mask_mtr_id =
    1849                 :            :         TOKEN_NUM_INITIALIZER(
    1850                 :            :                 struct cmd_set_port_meter_stats_mask_result, mtr_id,
    1851                 :            :                 RTE_UINT32);
    1852                 :            : static cmdline_parse_token_num_t cmd_set_port_meter_stats_mask_stats_mask =
    1853                 :            :         TOKEN_NUM_INITIALIZER(
    1854                 :            :                 struct cmd_set_port_meter_stats_mask_result, stats_mask,
    1855                 :            :                 RTE_UINT64);
    1856                 :            : 
    1857                 :          0 : static void cmd_set_port_meter_stats_mask_parsed(void *parsed_result,
    1858                 :            :         __rte_unused struct cmdline *cl,
    1859                 :            :         __rte_unused void *data)
    1860                 :            : {
    1861                 :            :         struct cmd_set_port_meter_stats_mask_result *res = parsed_result;
    1862                 :            :         struct rte_mtr_error error;
    1863                 :          0 :         uint64_t stats_mask = res->stats_mask;
    1864                 :          0 :         uint32_t mtr_id = res->mtr_id;
    1865                 :          0 :         uint16_t port_id = res->port_id;
    1866                 :            :         int ret;
    1867                 :            : 
    1868                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1869                 :          0 :                 return;
    1870                 :            : 
    1871                 :          0 :         ret = rte_mtr_stats_update(port_id, mtr_id, stats_mask, &error);
    1872                 :          0 :         if (ret != 0) {
    1873                 :          0 :                 print_err_msg(&error);
    1874                 :          0 :                 return;
    1875                 :            :         }
    1876                 :            : }
    1877                 :            : 
    1878                 :            : cmdline_parse_inst_t cmd_set_port_meter_stats_mask = {
    1879                 :            :         .f = cmd_set_port_meter_stats_mask_parsed,
    1880                 :            :         .data = NULL,
    1881                 :            :         .help_str = "set port meter stats mask <port_id> <mtr_id> <stats_mask>",
    1882                 :            :         .tokens = {
    1883                 :            :                 (void *)&cmd_set_port_meter_stats_mask_set,
    1884                 :            :                 (void *)&cmd_set_port_meter_stats_mask_port,
    1885                 :            :                 (void *)&cmd_set_port_meter_stats_mask_meter,
    1886                 :            :                 (void *)&cmd_set_port_meter_stats_mask_stats,
    1887                 :            :                 (void *)&cmd_set_port_meter_stats_mask_mask,
    1888                 :            :                 (void *)&cmd_set_port_meter_stats_mask_port_id,
    1889                 :            :                 (void *)&cmd_set_port_meter_stats_mask_mtr_id,
    1890                 :            :                 (void *)&cmd_set_port_meter_stats_mask_stats_mask,
    1891                 :            :                 NULL,
    1892                 :            :         },
    1893                 :            : };
    1894                 :            : 
    1895                 :            : /* *** Show Port Meter Stats *** */
    1896                 :            : struct cmd_show_port_meter_stats_result {
    1897                 :            :         cmdline_fixed_string_t show;
    1898                 :            :         cmdline_fixed_string_t port;
    1899                 :            :         cmdline_fixed_string_t meter;
    1900                 :            :         cmdline_fixed_string_t stats;
    1901                 :            :         uint16_t port_id;
    1902                 :            :         uint32_t mtr_id;
    1903                 :            :         cmdline_fixed_string_t clear;
    1904                 :            : };
    1905                 :            : 
    1906                 :            : static cmdline_parse_token_string_t cmd_show_port_meter_stats_show =
    1907                 :            :         TOKEN_STRING_INITIALIZER(
    1908                 :            :                 struct cmd_show_port_meter_stats_result, show, "show");
    1909                 :            : static cmdline_parse_token_string_t cmd_show_port_meter_stats_port =
    1910                 :            :         TOKEN_STRING_INITIALIZER(
    1911                 :            :                 struct cmd_show_port_meter_stats_result, port, "port");
    1912                 :            : static cmdline_parse_token_string_t cmd_show_port_meter_stats_meter =
    1913                 :            :         TOKEN_STRING_INITIALIZER(
    1914                 :            :                 struct cmd_show_port_meter_stats_result, meter, "meter");
    1915                 :            : static cmdline_parse_token_string_t cmd_show_port_meter_stats_stats =
    1916                 :            :         TOKEN_STRING_INITIALIZER(
    1917                 :            :                 struct cmd_show_port_meter_stats_result, stats, "stats");
    1918                 :            : static cmdline_parse_token_num_t cmd_show_port_meter_stats_port_id =
    1919                 :            :         TOKEN_NUM_INITIALIZER(
    1920                 :            :                 struct cmd_show_port_meter_stats_result, port_id, RTE_UINT16);
    1921                 :            : static cmdline_parse_token_num_t cmd_show_port_meter_stats_mtr_id =
    1922                 :            :         TOKEN_NUM_INITIALIZER(
    1923                 :            :                 struct cmd_show_port_meter_stats_result, mtr_id, RTE_UINT32);
    1924                 :            : static cmdline_parse_token_string_t cmd_show_port_meter_stats_clear =
    1925                 :            :         TOKEN_STRING_INITIALIZER(
    1926                 :            :                 struct cmd_show_port_meter_stats_result, clear, "yes#no");
    1927                 :            : 
    1928                 :          0 : static void cmd_show_port_meter_stats_parsed(void *parsed_result,
    1929                 :            :         __rte_unused struct cmdline *cl,
    1930                 :            :         __rte_unused void *data)
    1931                 :            : {
    1932                 :            :         struct cmd_show_port_meter_stats_result *res = parsed_result;
    1933                 :            :         struct rte_mtr_stats stats;
    1934                 :          0 :         uint64_t stats_mask = 0;
    1935                 :            :         struct rte_mtr_error error;
    1936                 :          0 :         uint32_t mtr_id = res->mtr_id;
    1937                 :            :         uint32_t clear = 0;
    1938                 :          0 :         uint16_t port_id = res->port_id;
    1939                 :            :         int ret;
    1940                 :            : 
    1941                 :          0 :         if (port_id_is_invalid(port_id, ENABLED_WARN))
    1942                 :          0 :                 return;
    1943                 :            : 
    1944                 :          0 :         if (strcmp(res->clear, "yes") == 0)
    1945                 :            :                 clear = 1;
    1946                 :            : 
    1947                 :            :         memset(&stats, 0, sizeof(struct rte_mtr_stats));
    1948                 :          0 :         ret = rte_mtr_stats_read(port_id, mtr_id, &stats,
    1949                 :            :                 &stats_mask, clear, &error);
    1950                 :          0 :         if (ret != 0) {
    1951                 :          0 :                 print_err_msg(&error);
    1952                 :          0 :                 return;
    1953                 :            :         }
    1954                 :            : 
    1955                 :            :         /* Display stats */
    1956                 :          0 :         if (stats_mask & RTE_MTR_STATS_N_PKTS_GREEN)
    1957                 :          0 :                 printf("\tPkts G: %" PRIu64 "\n",
    1958                 :            :                         stats.n_pkts[RTE_COLOR_GREEN]);
    1959                 :          0 :         if (stats_mask & RTE_MTR_STATS_N_BYTES_GREEN)
    1960                 :          0 :                 printf("\tBytes G: %" PRIu64 "\n",
    1961                 :            :                         stats.n_bytes[RTE_COLOR_GREEN]);
    1962                 :          0 :         if (stats_mask & RTE_MTR_STATS_N_PKTS_YELLOW)
    1963                 :          0 :                 printf("\tPkts Y: %" PRIu64 "\n",
    1964                 :            :                         stats.n_pkts[RTE_COLOR_YELLOW]);
    1965                 :          0 :         if (stats_mask & RTE_MTR_STATS_N_BYTES_YELLOW)
    1966                 :          0 :                 printf("\tBytes Y: %" PRIu64 "\n",
    1967                 :            :                         stats.n_bytes[RTE_COLOR_YELLOW]);
    1968                 :          0 :         if (stats_mask & RTE_MTR_STATS_N_PKTS_RED)
    1969                 :          0 :                 printf("\tPkts R: %" PRIu64 "\n",
    1970                 :            :                         stats.n_pkts[RTE_COLOR_RED]);
    1971                 :          0 :         if (stats_mask & RTE_MTR_STATS_N_BYTES_RED)
    1972                 :          0 :                 printf("\tBytes R: %" PRIu64 "\n",
    1973                 :            :                         stats.n_bytes[RTE_COLOR_RED]);
    1974                 :          0 :         if (stats_mask & RTE_MTR_STATS_N_PKTS_DROPPED)
    1975                 :          0 :                 printf("\tPkts DROPPED: %" PRIu64 "\n",
    1976                 :            :                         stats.n_pkts_dropped);
    1977                 :          0 :         if (stats_mask & RTE_MTR_STATS_N_BYTES_DROPPED)
    1978                 :          0 :                 printf("\tBytes DROPPED: %" PRIu64 "\n",
    1979                 :            :                         stats.n_bytes_dropped);
    1980                 :            : }
    1981                 :            : 
    1982                 :            : cmdline_parse_inst_t cmd_show_port_meter_stats = {
    1983                 :            :         .f = cmd_show_port_meter_stats_parsed,
    1984                 :            :         .data = NULL,
    1985                 :            :         .help_str = "show port meter stats <port_id> <mtr_id> <clear>(yes|no)",
    1986                 :            :         .tokens = {
    1987                 :            :                 (void *)&cmd_show_port_meter_stats_show,
    1988                 :            :                 (void *)&cmd_show_port_meter_stats_port,
    1989                 :            :                 (void *)&cmd_show_port_meter_stats_meter,
    1990                 :            :                 (void *)&cmd_show_port_meter_stats_stats,
    1991                 :            :                 (void *)&cmd_show_port_meter_stats_port_id,
    1992                 :            :                 (void *)&cmd_show_port_meter_stats_mtr_id,
    1993                 :            :                 (void *)&cmd_show_port_meter_stats_clear,
    1994                 :            :                 NULL,
    1995                 :            :         },
    1996                 :            : };

Generated by: LCOV version 1.14