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