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