4 * Copyright(c) 2017 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <cmdline_parse.h>
35 #include <cmdline_parse_num.h>
36 #include <cmdline_parse_string.h>
38 #include <rte_ethdev.h>
43 #include "cmdline_tm.h"
45 #define PARSE_DELIMITER " \f\n\r\t\v"
46 #define MAX_NUM_SHARED_SHAPERS 256
48 #define skip_white_spaces(pos) \
50 __typeof__(pos) _p = (pos); \
51 for ( ; isspace(*_p); _p++) \
56 /** Display TM Error Message */
58 print_err_msg(struct rte_tm_error *error)
60 static const char *const errstrlist[] = {
61 [RTE_TM_ERROR_TYPE_NONE] = "no error",
62 [RTE_TM_ERROR_TYPE_UNSPECIFIED] = "cause unspecified",
63 [RTE_TM_ERROR_TYPE_CAPABILITIES]
64 = "capability parameter null",
65 [RTE_TM_ERROR_TYPE_LEVEL_ID] = "level id",
66 [RTE_TM_ERROR_TYPE_WRED_PROFILE]
67 = "wred profile null",
68 [RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN] = "wred profile(green)",
69 [RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW]
70 = "wred profile(yellow)",
71 [RTE_TM_ERROR_TYPE_WRED_PROFILE_RED] = "wred profile(red)",
72 [RTE_TM_ERROR_TYPE_WRED_PROFILE_ID] = "wred profile id",
73 [RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID]
74 = "shared wred context id",
75 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE] = "shaper profile null",
76 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE]
77 = "committed rate field (shaper profile)",
78 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE]
79 = "committed size field (shaper profile)",
80 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE]
81 = "peak rate field (shaper profile)",
82 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE]
83 = "peak size field (shaper profile)",
84 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN]
85 = "packet adjust length field (shaper profile)",
86 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID] = "shaper profile id",
87 [RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID] = "shared shaper id",
88 [RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID] = "parent node id",
89 [RTE_TM_ERROR_TYPE_NODE_PRIORITY] = "node priority",
90 [RTE_TM_ERROR_TYPE_NODE_WEIGHT] = "node weight",
91 [RTE_TM_ERROR_TYPE_NODE_PARAMS] = "node parameter null",
92 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID]
93 = "shaper profile id field (node params)",
94 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID]
95 = "shared shaper id field (node params)",
96 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS]
97 = "num shared shapers field (node params)",
98 [RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE]
99 = "wfq weght mode field (node params)",
100 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES]
101 = "num strict priorities field (node params)",
102 [RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN]
103 = "congestion management mode field (node params)",
104 [RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID] =
105 "wred profile id field (node params)",
106 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID]
107 = "shared wred context id field (node params)",
108 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS]
109 = "num shared wred contexts field (node params)",
110 [RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS]
111 = "stats field (node params)",
112 [RTE_TM_ERROR_TYPE_NODE_ID] = "node id",
118 if ((unsigned int)error->type >= RTE_DIM(errstrlist) ||
119 !errstrlist[error->type])
120 errstr = "unknown type";
122 errstr = errstrlist[error->type];
125 snprintf(buf, sizeof(buf), "cause: %p, ", error->cause);
127 printf("%s: %s%s (error %d)\n", errstr, error->cause ? buf : "",
128 error->message ? error->message : "(no stated reason)",
133 read_uint64(uint64_t *value, const char *p)
138 p = skip_white_spaces(p);
142 val = strtoul(p, &next, 10);
164 p = skip_white_spaces(p);
173 read_uint32(uint32_t *value, const char *p)
176 int ret = read_uint64(&val, p);
181 if (val > UINT32_MAX)
189 parse_multi_ss_id_str(char *s_str, uint32_t *n_ssp, uint32_t shaper_id[])
191 uint32_t n_shared_shapers = 0, i = 0;
194 /* First token: num of shared shapers */
195 token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
199 if (read_uint32(&n_shared_shapers, token))
202 /* Check: num of shared shaper */
203 if (n_shared_shapers >= MAX_NUM_SHARED_SHAPERS) {
204 printf(" Number of shared shapers exceed the max (error)\n");
208 /* Parse shared shaper ids */
210 token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
211 if ((token != NULL && n_shared_shapers == 0) ||
212 (token == NULL && i < n_shared_shapers))
218 if (read_uint32(&shaper_id[i], token))
222 *n_ssp = n_shared_shapers;
226 /* *** Port TM Capability *** */
227 struct cmd_show_port_tm_cap_result {
228 cmdline_fixed_string_t show;
229 cmdline_fixed_string_t port;
230 cmdline_fixed_string_t tm;
231 cmdline_fixed_string_t cap;
235 cmdline_parse_token_string_t cmd_show_port_tm_cap_show =
236 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
238 cmdline_parse_token_string_t cmd_show_port_tm_cap_port =
239 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
241 cmdline_parse_token_string_t cmd_show_port_tm_cap_tm =
242 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
244 cmdline_parse_token_string_t cmd_show_port_tm_cap_cap =
245 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
247 cmdline_parse_token_num_t cmd_show_port_tm_cap_port_id =
248 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_cap_result,
251 static void cmd_show_port_tm_cap_parsed(void *parsed_result,
252 __attribute__((unused)) struct cmdline *cl,
253 __attribute__((unused)) void *data)
255 struct cmd_show_port_tm_cap_result *res = parsed_result;
256 struct rte_tm_capabilities cap;
257 struct rte_tm_error error;
258 portid_t port_id = res->port_id;
262 if (port_id_is_invalid(port_id, ENABLED_WARN))
265 memset(&cap, 0, sizeof(struct rte_tm_capabilities));
266 ret = rte_tm_capabilities_get(port_id, &cap, &error);
268 print_err_msg(&error);
272 printf("\n**** Port TM Capabilities ****\n\n");
273 printf("cap.n_nodes_max %" PRIu32 "\n", cap.n_nodes_max);
274 printf("cap.n_levels_max %" PRIu32 "\n", cap.n_levels_max);
275 printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
276 cap.non_leaf_nodes_identical);
277 printf("cap.leaf_nodes_identical %" PRId32 "\n",
278 cap.leaf_nodes_identical);
279 printf("cap.shaper_n_max %u\n", cap.shaper_n_max);
280 printf("cap.shaper_private_n_max %" PRIu32 "\n",
281 cap.shaper_private_n_max);
282 printf("cap.shaper_private_dual_rate_n_max %" PRId32 "\n",
283 cap.shaper_private_dual_rate_n_max);
284 printf("cap.shaper_private_rate_min %" PRIu64 "\n",
285 cap.shaper_private_rate_min);
286 printf("cap.shaper_private_rate_max %" PRIu64 "\n",
287 cap.shaper_private_rate_max);
288 printf("cap.shaper_shared_n_max %" PRIu32 "\n",
289 cap.shaper_shared_n_max);
290 printf("cap.shaper_shared_n_nodes_per_shaper_max %" PRIu32 "\n",
291 cap.shaper_shared_n_nodes_per_shaper_max);
292 printf("cap.shaper_shared_n_shapers_per_node_max %" PRIu32 "\n",
293 cap.shaper_shared_n_shapers_per_node_max);
294 printf("cap.shaper_shared_dual_rate_n_max %" PRIu32 "\n",
295 cap.shaper_shared_dual_rate_n_max);
296 printf("cap.shaper_shared_rate_min %" PRIu64 "\n",
297 cap.shaper_shared_rate_min);
298 printf("cap.shaper_shared_rate_max %" PRIu64 "\n",
299 cap.shaper_shared_rate_max);
300 printf("cap.shaper_pkt_length_adjust_min %" PRId32 "\n",
301 cap.shaper_pkt_length_adjust_min);
302 printf("cap.shaper_pkt_length_adjust_max %" PRId32 "\n",
303 cap.shaper_pkt_length_adjust_max);
304 printf("cap.sched_n_children_max %" PRIu32 "\n",
305 cap.sched_n_children_max);
306 printf("cap.sched_sp_n_priorities_max %" PRIu32 "\n",
307 cap.sched_sp_n_priorities_max);
308 printf("cap.sched_wfq_n_children_per_group_max %" PRIu32 "\n",
309 cap.sched_wfq_n_children_per_group_max);
310 printf("cap.sched_wfq_n_groups_max %" PRIu32 "\n",
311 cap.sched_wfq_n_groups_max);
312 printf("cap.sched_wfq_weight_max %" PRIu32 "\n",
313 cap.sched_wfq_weight_max);
314 printf("cap.cman_head_drop_supported %" PRId32 "\n",
315 cap.cman_head_drop_supported);
316 printf("cap.cman_wred_context_n_max %" PRIu32 "\n",
317 cap.cman_wred_context_n_max);
318 printf("cap.cman_wred_context_private_n_max %" PRIu32 "\n",
319 cap.cman_wred_context_private_n_max);
320 printf("cap.cman_wred_context_shared_n_max %" PRIu32 "\n",
321 cap.cman_wred_context_shared_n_max);
322 printf("cap.cman_wred_context_shared_n_nodes_per_context_max %" PRIu32
323 "\n", cap.cman_wred_context_shared_n_nodes_per_context_max);
324 printf("cap.cman_wred_context_shared_n_contexts_per_node_max %" PRIu32
325 "\n", cap.cman_wred_context_shared_n_contexts_per_node_max);
327 for (i = 0; i < RTE_TM_COLORS; i++) {
328 printf("cap.mark_vlan_dei_supported %" PRId32 "\n",
329 cap.mark_vlan_dei_supported[i]);
330 printf("cap.mark_ip_ecn_tcp_supported %" PRId32 "\n",
331 cap.mark_ip_ecn_tcp_supported[i]);
332 printf("cap.mark_ip_ecn_sctp_supported %" PRId32 "\n",
333 cap.mark_ip_ecn_sctp_supported[i]);
334 printf("cap.mark_ip_dscp_supported %" PRId32 "\n",
335 cap.mark_ip_dscp_supported[i]);
338 printf("cap.dynamic_update_mask %" PRIx64 "\n",
339 cap.dynamic_update_mask);
340 printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
343 cmdline_parse_inst_t cmd_show_port_tm_cap = {
344 .f = cmd_show_port_tm_cap_parsed,
346 .help_str = "Show Port TM Capabilities",
348 (void *)&cmd_show_port_tm_cap_show,
349 (void *)&cmd_show_port_tm_cap_port,
350 (void *)&cmd_show_port_tm_cap_tm,
351 (void *)&cmd_show_port_tm_cap_cap,
352 (void *)&cmd_show_port_tm_cap_port_id,
357 /* *** Port TM Hierarchical Level Capability *** */
358 struct cmd_show_port_tm_level_cap_result {
359 cmdline_fixed_string_t show;
360 cmdline_fixed_string_t port;
361 cmdline_fixed_string_t tm;
362 cmdline_fixed_string_t level;
363 cmdline_fixed_string_t cap;
368 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_show =
369 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
371 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_port =
372 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
374 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_tm =
375 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
377 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_level =
378 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
380 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_cap =
381 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
383 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_port_id =
384 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
386 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_level_id =
387 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
391 static void cmd_show_port_tm_level_cap_parsed(void *parsed_result,
392 __attribute__((unused)) struct cmdline *cl,
393 __attribute__((unused)) void *data)
395 struct cmd_show_port_tm_level_cap_result *res = parsed_result;
396 struct rte_tm_level_capabilities lcap;
397 struct rte_tm_error error;
398 portid_t port_id = res->port_id;
399 uint32_t level_id = res->level_id;
402 if (port_id_is_invalid(port_id, ENABLED_WARN))
405 memset(&lcap, 0, sizeof(struct rte_tm_level_capabilities));
406 ret = rte_tm_level_capabilities_get(port_id, level_id, &lcap, &error);
408 print_err_msg(&error);
411 printf("\n** Port TM Hierarchy level %" PRIu32 " Capability **\n\n",
414 printf("cap.n_nodes_max %" PRIu32 "\n", lcap.n_nodes_max);
415 printf("cap.n_nodes_nonleaf_max %" PRIu32 "\n",
416 lcap.n_nodes_nonleaf_max);
417 printf("cap.n_nodes_leaf_max %" PRIu32 "\n", lcap.n_nodes_leaf_max);
418 printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
419 lcap.non_leaf_nodes_identical);
420 printf("cap.leaf_nodes_identical %" PRId32 "\n",
421 lcap.leaf_nodes_identical);
423 printf("cap.nonleaf.shaper_private_supported %" PRId32 "\n",
424 lcap.nonleaf.shaper_private_supported);
425 printf("cap.nonleaf.shaper_private_dual_rate_supported %" PRId32
426 "\n", lcap.nonleaf.shaper_private_dual_rate_supported);
427 printf("cap.nonleaf.shaper_private_rate_min %" PRIu64 "\n",
428 lcap.nonleaf.shaper_private_rate_min);
429 printf("cap.nonleaf.shaper_private_rate_max %" PRIu64 "\n",
430 lcap.nonleaf.shaper_private_rate_max);
431 printf("cap.nonleaf.shaper_shared_n_max %" PRIu32 "\n",
432 lcap.nonleaf.shaper_shared_n_max);
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.stats_mask %" PRIx64 "\n",
444 lcap.nonleaf.stats_mask);
446 printf("cap.leaf.shaper_private_supported %" PRId32 "\n",
447 lcap.leaf.shaper_private_supported);
448 printf("cap.leaf.shaper_private_dual_rate_supported %" PRId32
449 "\n", lcap.leaf.shaper_private_dual_rate_supported);
450 printf("cap.leaf.shaper_private_rate_min %" PRIu64 "\n",
451 lcap.leaf.shaper_private_rate_min);
452 printf("cap.leaf.shaper_private_rate_max %" PRIu64 "\n",
453 lcap.leaf.shaper_private_rate_max);
454 printf("cap.leaf.shaper_shared_n_max %" PRIu32 "\n",
455 lcap.leaf.shaper_shared_n_max);
456 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
457 lcap.leaf.cman_head_drop_supported);
458 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
459 "\n", lcap.leaf.cman_wred_context_private_supported);
460 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
461 lcap.leaf.cman_wred_context_shared_n_max);
462 printf("cap.leaf.stats_mask %" PRIx64 "\n",
463 lcap.leaf.stats_mask);
467 cmdline_parse_inst_t cmd_show_port_tm_level_cap = {
468 .f = cmd_show_port_tm_level_cap_parsed,
470 .help_str = "Show Port TM Hierarhical level Capabilities",
472 (void *)&cmd_show_port_tm_level_cap_show,
473 (void *)&cmd_show_port_tm_level_cap_port,
474 (void *)&cmd_show_port_tm_level_cap_tm,
475 (void *)&cmd_show_port_tm_level_cap_level,
476 (void *)&cmd_show_port_tm_level_cap_cap,
477 (void *)&cmd_show_port_tm_level_cap_port_id,
478 (void *)&cmd_show_port_tm_level_cap_level_id,
483 /* *** Port TM Hierarchy Node Capability *** */
484 struct cmd_show_port_tm_node_cap_result {
485 cmdline_fixed_string_t show;
486 cmdline_fixed_string_t port;
487 cmdline_fixed_string_t tm;
488 cmdline_fixed_string_t node;
489 cmdline_fixed_string_t cap;
494 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_show =
495 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
497 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_port =
498 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
500 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_tm =
501 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
503 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_node =
504 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
506 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_cap =
507 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
509 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_port_id =
510 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
512 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_node_id =
513 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
516 static void cmd_show_port_tm_node_cap_parsed(void *parsed_result,
517 __attribute__((unused)) struct cmdline *cl,
518 __attribute__((unused)) void *data)
520 struct cmd_show_port_tm_node_cap_result *res = parsed_result;
521 struct rte_tm_node_capabilities ncap;
522 struct rte_tm_error error;
523 uint32_t node_id = res->node_id;
524 portid_t port_id = res->port_id;
525 int ret, is_leaf = 0;
527 if (port_id_is_invalid(port_id, ENABLED_WARN))
530 /* Node id must be valid */
531 ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
533 print_err_msg(&error);
537 memset(&ncap, 0, sizeof(struct rte_tm_node_capabilities));
538 ret = rte_tm_node_capabilities_get(port_id, node_id, &ncap, &error);
540 print_err_msg(&error);
543 printf("\n** Port TM Hierarchy node %" PRIu32 " Capability **\n\n",
545 printf("cap.shaper_private_supported %" PRId32 "\n",
546 ncap.shaper_private_supported);
547 printf("cap.shaper_private_dual_rate_supported %" PRId32 "\n",
548 ncap.shaper_private_dual_rate_supported);
549 printf("cap.shaper_private_rate_min %" PRIu64 "\n",
550 ncap.shaper_private_rate_min);
551 printf("cap.shaper_private_rate_max %" PRIu64 "\n",
552 ncap.shaper_private_rate_max);
553 printf("cap.shaper_shared_n_max %" PRIu32 "\n",
554 ncap.shaper_shared_n_max);
556 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
557 ncap.nonleaf.sched_n_children_max);
558 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
559 ncap.nonleaf.sched_sp_n_priorities_max);
560 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
561 "\n", ncap.nonleaf.sched_wfq_n_children_per_group_max);
562 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
563 ncap.nonleaf.sched_wfq_n_groups_max);
564 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
565 ncap.nonleaf.sched_wfq_weight_max);
567 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
568 ncap.leaf.cman_head_drop_supported);
569 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
570 "\n", ncap.leaf.cman_wred_context_private_supported);
571 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
572 ncap.leaf.cman_wred_context_shared_n_max);
574 printf("cap.stats_mask %" PRIx64 "\n", ncap.stats_mask);
577 cmdline_parse_inst_t cmd_show_port_tm_node_cap = {
578 .f = cmd_show_port_tm_node_cap_parsed,
580 .help_str = "Show Port TM Hierarchy node capabilities",
582 (void *)&cmd_show_port_tm_node_cap_show,
583 (void *)&cmd_show_port_tm_node_cap_port,
584 (void *)&cmd_show_port_tm_node_cap_tm,
585 (void *)&cmd_show_port_tm_node_cap_node,
586 (void *)&cmd_show_port_tm_node_cap_cap,
587 (void *)&cmd_show_port_tm_node_cap_port_id,
588 (void *)&cmd_show_port_tm_node_cap_node_id,
593 /* *** Show Port TM Node Statistics *** */
594 struct cmd_show_port_tm_node_stats_result {
595 cmdline_fixed_string_t show;
596 cmdline_fixed_string_t port;
597 cmdline_fixed_string_t tm;
598 cmdline_fixed_string_t node;
599 cmdline_fixed_string_t stats;
605 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_show =
606 TOKEN_STRING_INITIALIZER(
607 struct cmd_show_port_tm_node_stats_result, show, "show");
608 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_port =
609 TOKEN_STRING_INITIALIZER(
610 struct cmd_show_port_tm_node_stats_result, port, "port");
611 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_tm =
612 TOKEN_STRING_INITIALIZER(
613 struct cmd_show_port_tm_node_stats_result, tm, "tm");
614 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_node =
615 TOKEN_STRING_INITIALIZER(
616 struct cmd_show_port_tm_node_stats_result, node, "node");
617 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_stats =
618 TOKEN_STRING_INITIALIZER(
619 struct cmd_show_port_tm_node_stats_result, stats, "stats");
620 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_port_id =
621 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_stats_result,
623 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_node_id =
624 TOKEN_NUM_INITIALIZER(
625 struct cmd_show_port_tm_node_stats_result,
627 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_clear =
628 TOKEN_NUM_INITIALIZER(
629 struct cmd_show_port_tm_node_stats_result, clear, UINT32);
631 static void cmd_show_port_tm_node_stats_parsed(void *parsed_result,
632 __attribute__((unused)) struct cmdline *cl,
633 __attribute__((unused)) void *data)
635 struct cmd_show_port_tm_node_stats_result *res = parsed_result;
636 struct rte_tm_node_stats stats;
637 struct rte_tm_error error;
638 uint64_t stats_mask = 0;
639 uint32_t node_id = res->node_id;
640 uint32_t clear = res->clear;
641 portid_t port_id = res->port_id;
644 if (port_id_is_invalid(port_id, ENABLED_WARN))
648 if (!port_is_started(port_id)) {
649 printf(" Port %u not started (error)\n", port_id);
653 memset(&stats, 0, sizeof(struct rte_tm_node_stats));
654 ret = rte_tm_node_stats_read(port_id, node_id, &stats,
655 &stats_mask, clear, &error);
657 print_err_msg(&error);
662 if (stats_mask & RTE_TM_STATS_N_PKTS)
663 printf("\tPkts scheduled from node: %" PRIu64 "\n",
665 if (stats_mask & RTE_TM_STATS_N_BYTES)
666 printf("\tBytes scheduled from node: %" PRIu64 "\n",
668 if (stats_mask & RTE_TM_STATS_N_PKTS_GREEN_DROPPED)
669 printf("\tPkts dropped (green): %" PRIu64 "\n",
670 stats.leaf.n_pkts_dropped[RTE_TM_GREEN]);
671 if (stats_mask & RTE_TM_STATS_N_PKTS_YELLOW_DROPPED)
672 printf("\tPkts dropped (yellow): %" PRIu64 "\n",
673 stats.leaf.n_pkts_dropped[RTE_TM_YELLOW]);
674 if (stats_mask & RTE_TM_STATS_N_PKTS_RED_DROPPED)
675 printf("\tPkts dropped (red): %" PRIu64 "\n",
676 stats.leaf.n_pkts_dropped[RTE_TM_RED]);
677 if (stats_mask & RTE_TM_STATS_N_BYTES_GREEN_DROPPED)
678 printf("\tBytes dropped (green): %" PRIu64 "\n",
679 stats.leaf.n_bytes_dropped[RTE_TM_GREEN]);
680 if (stats_mask & RTE_TM_STATS_N_BYTES_YELLOW_DROPPED)
681 printf("\tBytes dropped (yellow): %" PRIu64 "\n",
682 stats.leaf.n_bytes_dropped[RTE_TM_YELLOW]);
683 if (stats_mask & RTE_TM_STATS_N_BYTES_RED_DROPPED)
684 printf("\tBytes dropped (red): %" PRIu64 "\n",
685 stats.leaf.n_bytes_dropped[RTE_TM_RED]);
686 if (stats_mask & RTE_TM_STATS_N_PKTS_QUEUED)
687 printf("\tPkts queued: %" PRIu64 "\n",
688 stats.leaf.n_pkts_queued);
689 if (stats_mask & RTE_TM_STATS_N_BYTES_QUEUED)
690 printf("\tBytes queued: %" PRIu64 "\n",
691 stats.leaf.n_bytes_queued);
694 cmdline_parse_inst_t cmd_show_port_tm_node_stats = {
695 .f = cmd_show_port_tm_node_stats_parsed,
697 .help_str = "Show port tm node stats",
699 (void *)&cmd_show_port_tm_node_stats_show,
700 (void *)&cmd_show_port_tm_node_stats_port,
701 (void *)&cmd_show_port_tm_node_stats_tm,
702 (void *)&cmd_show_port_tm_node_stats_node,
703 (void *)&cmd_show_port_tm_node_stats_stats,
704 (void *)&cmd_show_port_tm_node_stats_port_id,
705 (void *)&cmd_show_port_tm_node_stats_node_id,
706 (void *)&cmd_show_port_tm_node_stats_clear,
711 /* *** Show Port TM Node Type *** */
712 struct cmd_show_port_tm_node_type_result {
713 cmdline_fixed_string_t show;
714 cmdline_fixed_string_t port;
715 cmdline_fixed_string_t tm;
716 cmdline_fixed_string_t node;
717 cmdline_fixed_string_t type;
722 cmdline_parse_token_string_t cmd_show_port_tm_node_type_show =
723 TOKEN_STRING_INITIALIZER(
724 struct cmd_show_port_tm_node_type_result, show, "show");
725 cmdline_parse_token_string_t cmd_show_port_tm_node_type_port =
726 TOKEN_STRING_INITIALIZER(
727 struct cmd_show_port_tm_node_type_result, port, "port");
728 cmdline_parse_token_string_t cmd_show_port_tm_node_type_tm =
729 TOKEN_STRING_INITIALIZER(
730 struct cmd_show_port_tm_node_type_result, tm, "tm");
731 cmdline_parse_token_string_t cmd_show_port_tm_node_type_node =
732 TOKEN_STRING_INITIALIZER(
733 struct cmd_show_port_tm_node_type_result, node, "node");
734 cmdline_parse_token_string_t cmd_show_port_tm_node_type_type =
735 TOKEN_STRING_INITIALIZER(
736 struct cmd_show_port_tm_node_type_result, type, "type");
737 cmdline_parse_token_num_t cmd_show_port_tm_node_type_port_id =
738 TOKEN_NUM_INITIALIZER(
739 struct cmd_show_port_tm_node_type_result,
741 cmdline_parse_token_num_t cmd_show_port_tm_node_type_node_id =
742 TOKEN_NUM_INITIALIZER(
743 struct cmd_show_port_tm_node_type_result,
746 static void cmd_show_port_tm_node_type_parsed(void *parsed_result,
747 __attribute__((unused)) struct cmdline *cl,
748 __attribute__((unused)) void *data)
750 struct cmd_show_port_tm_node_type_result *res = parsed_result;
751 struct rte_tm_error error;
752 uint32_t node_id = res->node_id;
753 portid_t port_id = res->port_id;
754 int ret, is_leaf = 0;
756 if (port_id_is_invalid(port_id, ENABLED_WARN))
759 ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
761 print_err_msg(&error);
766 printf("leaf node\n");
768 printf("nonleaf node\n");
772 cmdline_parse_inst_t cmd_show_port_tm_node_type = {
773 .f = cmd_show_port_tm_node_type_parsed,
775 .help_str = "Show port tm node type",
777 (void *)&cmd_show_port_tm_node_type_show,
778 (void *)&cmd_show_port_tm_node_type_port,
779 (void *)&cmd_show_port_tm_node_type_tm,
780 (void *)&cmd_show_port_tm_node_type_node,
781 (void *)&cmd_show_port_tm_node_type_type,
782 (void *)&cmd_show_port_tm_node_type_port_id,
783 (void *)&cmd_show_port_tm_node_type_node_id,
788 /* *** Add Port TM Private Shaper Profile *** */
789 struct cmd_add_port_tm_node_shaper_profile_result {
790 cmdline_fixed_string_t add;
791 cmdline_fixed_string_t port;
792 cmdline_fixed_string_t tm;
793 cmdline_fixed_string_t node;
794 cmdline_fixed_string_t shaper;
795 cmdline_fixed_string_t profile;
800 uint32_t pktlen_adjust;
803 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add =
804 TOKEN_STRING_INITIALIZER(
805 struct cmd_add_port_tm_node_shaper_profile_result, add, "add");
806 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port =
807 TOKEN_STRING_INITIALIZER(
808 struct cmd_add_port_tm_node_shaper_profile_result,
810 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm =
811 TOKEN_STRING_INITIALIZER(
812 struct cmd_add_port_tm_node_shaper_profile_result,
814 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node =
815 TOKEN_STRING_INITIALIZER(
816 struct cmd_add_port_tm_node_shaper_profile_result,
818 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper =
819 TOKEN_STRING_INITIALIZER(
820 struct cmd_add_port_tm_node_shaper_profile_result,
822 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile =
823 TOKEN_STRING_INITIALIZER(
824 struct cmd_add_port_tm_node_shaper_profile_result,
826 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id =
827 TOKEN_NUM_INITIALIZER(
828 struct cmd_add_port_tm_node_shaper_profile_result,
830 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id =
831 TOKEN_NUM_INITIALIZER(
832 struct cmd_add_port_tm_node_shaper_profile_result,
834 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_tb_rate =
835 TOKEN_NUM_INITIALIZER(
836 struct cmd_add_port_tm_node_shaper_profile_result,
838 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_tb_size =
839 TOKEN_NUM_INITIALIZER(
840 struct cmd_add_port_tm_node_shaper_profile_result,
842 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust =
843 TOKEN_NUM_INITIALIZER(
844 struct cmd_add_port_tm_node_shaper_profile_result,
845 pktlen_adjust, UINT32);
847 static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
848 __attribute__((unused)) struct cmdline *cl,
849 __attribute__((unused)) void *data)
851 struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result;
852 struct rte_tm_shaper_params sp;
853 struct rte_tm_error error;
854 uint32_t shaper_id = res->shaper_id;
855 uint32_t pkt_len_adjust = res->pktlen_adjust;
856 portid_t port_id = res->port_id;
859 if (port_id_is_invalid(port_id, ENABLED_WARN))
862 /* Private shaper profile params */
863 memset(&sp, 0, sizeof(struct rte_tm_shaper_params));
864 sp.peak.rate = res->tb_rate;
865 sp.peak.size = res->tb_size;
866 sp.pkt_length_adjust = pkt_len_adjust;
868 ret = rte_tm_shaper_profile_add(port_id, shaper_id, &sp, &error);
870 print_err_msg(&error);
875 cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile = {
876 .f = cmd_add_port_tm_node_shaper_profile_parsed,
878 .help_str = "Add port tm node private shaper profile",
880 (void *)&cmd_add_port_tm_node_shaper_profile_add,
881 (void *)&cmd_add_port_tm_node_shaper_profile_port,
882 (void *)&cmd_add_port_tm_node_shaper_profile_tm,
883 (void *)&cmd_add_port_tm_node_shaper_profile_node,
884 (void *)&cmd_add_port_tm_node_shaper_profile_shaper,
885 (void *)&cmd_add_port_tm_node_shaper_profile_profile,
886 (void *)&cmd_add_port_tm_node_shaper_profile_port_id,
887 (void *)&cmd_add_port_tm_node_shaper_profile_shaper_id,
888 (void *)&cmd_add_port_tm_node_shaper_profile_tb_rate,
889 (void *)&cmd_add_port_tm_node_shaper_profile_tb_size,
890 (void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust,
895 /* *** Delete Port TM Private Shaper Profile *** */
896 struct cmd_del_port_tm_node_shaper_profile_result {
897 cmdline_fixed_string_t del;
898 cmdline_fixed_string_t port;
899 cmdline_fixed_string_t tm;
900 cmdline_fixed_string_t node;
901 cmdline_fixed_string_t shaper;
902 cmdline_fixed_string_t profile;
907 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del =
908 TOKEN_STRING_INITIALIZER(
909 struct cmd_del_port_tm_node_shaper_profile_result, del, "del");
910 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port =
911 TOKEN_STRING_INITIALIZER(
912 struct cmd_del_port_tm_node_shaper_profile_result,
914 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm =
915 TOKEN_STRING_INITIALIZER(
916 struct cmd_del_port_tm_node_shaper_profile_result, tm, "tm");
917 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node =
918 TOKEN_STRING_INITIALIZER(
919 struct cmd_del_port_tm_node_shaper_profile_result,
921 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper =
922 TOKEN_STRING_INITIALIZER(
923 struct cmd_del_port_tm_node_shaper_profile_result,
925 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile =
926 TOKEN_STRING_INITIALIZER(
927 struct cmd_del_port_tm_node_shaper_profile_result,
929 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id =
930 TOKEN_NUM_INITIALIZER(
931 struct cmd_del_port_tm_node_shaper_profile_result,
933 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id =
934 TOKEN_NUM_INITIALIZER(
935 struct cmd_del_port_tm_node_shaper_profile_result,
938 static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result,
939 __attribute__((unused)) struct cmdline *cl,
940 __attribute__((unused)) void *data)
942 struct cmd_del_port_tm_node_shaper_profile_result *res = parsed_result;
943 struct rte_tm_error error;
944 uint32_t shaper_id = res->shaper_id;
945 portid_t port_id = res->port_id;
948 if (port_id_is_invalid(port_id, ENABLED_WARN))
951 ret = rte_tm_shaper_profile_delete(port_id, shaper_id, &error);
953 print_err_msg(&error);
958 cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile = {
959 .f = cmd_del_port_tm_node_shaper_profile_parsed,
961 .help_str = "Delete port tm node private shaper profile",
963 (void *)&cmd_del_port_tm_node_shaper_profile_del,
964 (void *)&cmd_del_port_tm_node_shaper_profile_port,
965 (void *)&cmd_del_port_tm_node_shaper_profile_tm,
966 (void *)&cmd_del_port_tm_node_shaper_profile_node,
967 (void *)&cmd_del_port_tm_node_shaper_profile_shaper,
968 (void *)&cmd_del_port_tm_node_shaper_profile_profile,
969 (void *)&cmd_del_port_tm_node_shaper_profile_port_id,
970 (void *)&cmd_del_port_tm_node_shaper_profile_shaper_id,
975 /* *** Add/Update Port TM shared Shaper *** */
976 struct cmd_add_port_tm_node_shared_shaper_result {
977 cmdline_fixed_string_t cmd_type;
978 cmdline_fixed_string_t port;
979 cmdline_fixed_string_t tm;
980 cmdline_fixed_string_t node;
981 cmdline_fixed_string_t shared;
982 cmdline_fixed_string_t shaper;
984 uint32_t shared_shaper_id;
985 uint32_t shaper_profile_id;
988 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type =
989 TOKEN_STRING_INITIALIZER(
990 struct cmd_add_port_tm_node_shared_shaper_result,
991 cmd_type, "add#set");
992 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port =
993 TOKEN_STRING_INITIALIZER(
994 struct cmd_add_port_tm_node_shared_shaper_result, port, "port");
995 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm =
996 TOKEN_STRING_INITIALIZER(
997 struct cmd_add_port_tm_node_shared_shaper_result, tm, "tm");
998 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node =
999 TOKEN_STRING_INITIALIZER(
1000 struct cmd_add_port_tm_node_shared_shaper_result, node, "node");
1001 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared =
1002 TOKEN_STRING_INITIALIZER(
1003 struct cmd_add_port_tm_node_shared_shaper_result,
1005 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper =
1006 TOKEN_STRING_INITIALIZER(
1007 struct cmd_add_port_tm_node_shared_shaper_result,
1009 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id =
1010 TOKEN_NUM_INITIALIZER(
1011 struct cmd_add_port_tm_node_shared_shaper_result,
1013 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id =
1014 TOKEN_NUM_INITIALIZER(
1015 struct cmd_add_port_tm_node_shared_shaper_result,
1016 shared_shaper_id, UINT32);
1017 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id =
1018 TOKEN_NUM_INITIALIZER(
1019 struct cmd_add_port_tm_node_shared_shaper_result,
1020 shaper_profile_id, UINT32);
1022 static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result,
1023 __attribute__((unused)) struct cmdline *cl,
1024 __attribute__((unused)) void *data)
1026 struct cmd_add_port_tm_node_shared_shaper_result *res = parsed_result;
1027 struct rte_tm_error error;
1028 uint32_t shared_shaper_id = res->shared_shaper_id;
1029 uint32_t shaper_profile_id = res->shaper_profile_id;
1030 portid_t port_id = res->port_id;
1033 if (port_id_is_invalid(port_id, ENABLED_WARN))
1036 /* Command type: add */
1037 if ((strcmp(res->cmd_type, "add") == 0) &&
1038 (port_is_started(port_id))) {
1039 printf(" Port %u not stopped (error)\n", port_id);
1043 /* Command type: set (update) */
1044 if ((strcmp(res->cmd_type, "set") == 0) &&
1045 (!port_is_started(port_id))) {
1046 printf(" Port %u not started (error)\n", port_id);
1050 ret = rte_tm_shared_shaper_add_update(port_id, shared_shaper_id,
1051 shaper_profile_id, &error);
1053 print_err_msg(&error);
1058 cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper = {
1059 .f = cmd_add_port_tm_node_shared_shaper_parsed,
1061 .help_str = "add/update port tm node shared shaper",
1063 (void *)&cmd_add_port_tm_node_shared_shaper_cmd_type,
1064 (void *)&cmd_add_port_tm_node_shared_shaper_port,
1065 (void *)&cmd_add_port_tm_node_shared_shaper_tm,
1066 (void *)&cmd_add_port_tm_node_shared_shaper_node,
1067 (void *)&cmd_add_port_tm_node_shared_shaper_shared,
1068 (void *)&cmd_add_port_tm_node_shared_shaper_shaper,
1069 (void *)&cmd_add_port_tm_node_shared_shaper_port_id,
1070 (void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id,
1071 (void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id,
1076 /* *** Delete Port TM shared Shaper *** */
1077 struct cmd_del_port_tm_node_shared_shaper_result {
1078 cmdline_fixed_string_t del;
1079 cmdline_fixed_string_t port;
1080 cmdline_fixed_string_t tm;
1081 cmdline_fixed_string_t node;
1082 cmdline_fixed_string_t shared;
1083 cmdline_fixed_string_t shaper;
1085 uint32_t shared_shaper_id;
1088 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del =
1089 TOKEN_STRING_INITIALIZER(
1090 struct cmd_del_port_tm_node_shared_shaper_result, del, "del");
1091 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port =
1092 TOKEN_STRING_INITIALIZER(
1093 struct cmd_del_port_tm_node_shared_shaper_result, port, "port");
1094 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm =
1095 TOKEN_STRING_INITIALIZER(
1096 struct cmd_del_port_tm_node_shared_shaper_result, tm, "tm");
1097 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node =
1098 TOKEN_STRING_INITIALIZER(
1099 struct cmd_del_port_tm_node_shared_shaper_result, node, "node");
1100 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared =
1101 TOKEN_STRING_INITIALIZER(
1102 struct cmd_del_port_tm_node_shared_shaper_result,
1104 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper =
1105 TOKEN_STRING_INITIALIZER(
1106 struct cmd_del_port_tm_node_shared_shaper_result,
1108 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id =
1109 TOKEN_NUM_INITIALIZER(
1110 struct cmd_del_port_tm_node_shared_shaper_result,
1112 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id =
1113 TOKEN_NUM_INITIALIZER(
1114 struct cmd_del_port_tm_node_shared_shaper_result,
1115 shared_shaper_id, UINT32);
1117 static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result,
1118 __attribute__((unused)) struct cmdline *cl,
1119 __attribute__((unused)) void *data)
1121 struct cmd_del_port_tm_node_shared_shaper_result *res = parsed_result;
1122 struct rte_tm_error error;
1123 uint32_t shared_shaper_id = res->shared_shaper_id;
1124 portid_t port_id = res->port_id;
1127 if (port_id_is_invalid(port_id, ENABLED_WARN))
1130 ret = rte_tm_shared_shaper_delete(port_id, shared_shaper_id, &error);
1132 print_err_msg(&error);
1137 cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper = {
1138 .f = cmd_del_port_tm_node_shared_shaper_parsed,
1140 .help_str = "delete port tm node shared shaper",
1142 (void *)&cmd_del_port_tm_node_shared_shaper_del,
1143 (void *)&cmd_del_port_tm_node_shared_shaper_port,
1144 (void *)&cmd_del_port_tm_node_shared_shaper_tm,
1145 (void *)&cmd_del_port_tm_node_shared_shaper_node,
1146 (void *)&cmd_del_port_tm_node_shared_shaper_shared,
1147 (void *)&cmd_del_port_tm_node_shared_shaper_shaper,
1148 (void *)&cmd_del_port_tm_node_shared_shaper_port_id,
1149 (void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id,
1154 /* *** Add Port TM Node WRED Profile *** */
1155 struct cmd_add_port_tm_node_wred_profile_result {
1156 cmdline_fixed_string_t add;
1157 cmdline_fixed_string_t port;
1158 cmdline_fixed_string_t tm;
1159 cmdline_fixed_string_t node;
1160 cmdline_fixed_string_t wred;
1161 cmdline_fixed_string_t profile;
1163 uint32_t wred_profile_id;
1164 cmdline_fixed_string_t color_g;
1167 uint16_t maxp_inv_g;
1169 cmdline_fixed_string_t color_y;
1172 uint16_t maxp_inv_y;
1174 cmdline_fixed_string_t color_r;
1177 uint16_t maxp_inv_r;
1181 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add =
1182 TOKEN_STRING_INITIALIZER(
1183 struct cmd_add_port_tm_node_wred_profile_result, add, "add");
1184 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port =
1185 TOKEN_STRING_INITIALIZER(
1186 struct cmd_add_port_tm_node_wred_profile_result, port, "port");
1187 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm =
1188 TOKEN_STRING_INITIALIZER(
1189 struct cmd_add_port_tm_node_wred_profile_result, tm, "tm");
1190 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node =
1191 TOKEN_STRING_INITIALIZER(
1192 struct cmd_add_port_tm_node_wred_profile_result, node, "node");
1193 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred =
1194 TOKEN_STRING_INITIALIZER(
1195 struct cmd_add_port_tm_node_wred_profile_result, wred, "wred");
1196 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile =
1197 TOKEN_STRING_INITIALIZER(
1198 struct cmd_add_port_tm_node_wred_profile_result,
1199 profile, "profile");
1200 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id =
1201 TOKEN_NUM_INITIALIZER(
1202 struct cmd_add_port_tm_node_wred_profile_result,
1204 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id =
1205 TOKEN_NUM_INITIALIZER(
1206 struct cmd_add_port_tm_node_wred_profile_result,
1207 wred_profile_id, UINT32);
1208 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g =
1209 TOKEN_STRING_INITIALIZER(
1210 struct cmd_add_port_tm_node_wred_profile_result,
1212 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g =
1213 TOKEN_NUM_INITIALIZER(
1214 struct cmd_add_port_tm_node_wred_profile_result,
1216 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g =
1217 TOKEN_NUM_INITIALIZER(
1218 struct cmd_add_port_tm_node_wred_profile_result,
1220 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g =
1221 TOKEN_NUM_INITIALIZER(
1222 struct cmd_add_port_tm_node_wred_profile_result,
1223 maxp_inv_g, UINT16);
1224 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g =
1225 TOKEN_NUM_INITIALIZER(
1226 struct cmd_add_port_tm_node_wred_profile_result,
1228 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y =
1229 TOKEN_STRING_INITIALIZER(
1230 struct cmd_add_port_tm_node_wred_profile_result,
1232 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y =
1233 TOKEN_NUM_INITIALIZER(
1234 struct cmd_add_port_tm_node_wred_profile_result,
1236 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y =
1237 TOKEN_NUM_INITIALIZER(
1238 struct cmd_add_port_tm_node_wred_profile_result,
1240 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y =
1241 TOKEN_NUM_INITIALIZER(
1242 struct cmd_add_port_tm_node_wred_profile_result,
1243 maxp_inv_y, UINT16);
1244 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y =
1245 TOKEN_NUM_INITIALIZER(
1246 struct cmd_add_port_tm_node_wred_profile_result,
1248 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r =
1249 TOKEN_STRING_INITIALIZER(
1250 struct cmd_add_port_tm_node_wred_profile_result,
1252 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r =
1253 TOKEN_NUM_INITIALIZER(
1254 struct cmd_add_port_tm_node_wred_profile_result,
1256 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r =
1257 TOKEN_NUM_INITIALIZER(
1258 struct cmd_add_port_tm_node_wred_profile_result,
1260 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r =
1261 TOKEN_NUM_INITIALIZER(
1262 struct cmd_add_port_tm_node_wred_profile_result,
1263 maxp_inv_r, UINT16);
1264 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r =
1265 TOKEN_NUM_INITIALIZER(
1266 struct cmd_add_port_tm_node_wred_profile_result,
1270 static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
1271 __attribute__((unused)) struct cmdline *cl,
1272 __attribute__((unused)) void *data)
1274 struct cmd_add_port_tm_node_wred_profile_result *res = parsed_result;
1275 struct rte_tm_wred_params wp;
1276 enum rte_tm_color color;
1277 struct rte_tm_error error;
1278 uint32_t wred_profile_id = res->wred_profile_id;
1279 portid_t port_id = res->port_id;
1282 if (port_id_is_invalid(port_id, ENABLED_WARN))
1285 memset(&wp, 0, sizeof(struct rte_tm_wred_params));
1287 /* WRED Params (Green Color)*/
1288 color = RTE_TM_GREEN;
1289 wp.red_params[color].min_th = res->min_th_g;
1290 wp.red_params[color].max_th = res->max_th_g;
1291 wp.red_params[color].maxp_inv = res->maxp_inv_g;
1292 wp.red_params[color].wq_log2 = res->wq_log2_g;
1295 /* WRED Params (Yellow Color)*/
1296 color = RTE_TM_YELLOW;
1297 wp.red_params[color].min_th = res->min_th_y;
1298 wp.red_params[color].max_th = res->max_th_y;
1299 wp.red_params[color].maxp_inv = res->maxp_inv_y;
1300 wp.red_params[color].wq_log2 = res->wq_log2_y;
1302 /* WRED Params (Red Color)*/
1304 wp.red_params[color].min_th = res->min_th_r;
1305 wp.red_params[color].max_th = res->max_th_r;
1306 wp.red_params[color].maxp_inv = res->maxp_inv_r;
1307 wp.red_params[color].wq_log2 = res->wq_log2_r;
1309 ret = rte_tm_wred_profile_add(port_id, wred_profile_id, &wp, &error);
1311 print_err_msg(&error);
1316 cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile = {
1317 .f = cmd_add_port_tm_node_wred_profile_parsed,
1319 .help_str = "Add port tm node wred profile",
1321 (void *)&cmd_add_port_tm_node_wred_profile_add,
1322 (void *)&cmd_add_port_tm_node_wred_profile_port,
1323 (void *)&cmd_add_port_tm_node_wred_profile_tm,
1324 (void *)&cmd_add_port_tm_node_wred_profile_node,
1325 (void *)&cmd_add_port_tm_node_wred_profile_wred,
1326 (void *)&cmd_add_port_tm_node_wred_profile_profile,
1327 (void *)&cmd_add_port_tm_node_wred_profile_port_id,
1328 (void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id,
1329 (void *)&cmd_add_port_tm_node_wred_profile_color_g,
1330 (void *)&cmd_add_port_tm_node_wred_profile_min_th_g,
1331 (void *)&cmd_add_port_tm_node_wred_profile_max_th_g,
1332 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g,
1333 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g,
1334 (void *)&cmd_add_port_tm_node_wred_profile_color_y,
1335 (void *)&cmd_add_port_tm_node_wred_profile_min_th_y,
1336 (void *)&cmd_add_port_tm_node_wred_profile_max_th_y,
1337 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y,
1338 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y,
1339 (void *)&cmd_add_port_tm_node_wred_profile_color_r,
1340 (void *)&cmd_add_port_tm_node_wred_profile_min_th_r,
1341 (void *)&cmd_add_port_tm_node_wred_profile_max_th_r,
1342 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r,
1343 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r,
1348 /* *** Delete Port TM node WRED Profile *** */
1349 struct cmd_del_port_tm_node_wred_profile_result {
1350 cmdline_fixed_string_t del;
1351 cmdline_fixed_string_t port;
1352 cmdline_fixed_string_t tm;
1353 cmdline_fixed_string_t node;
1354 cmdline_fixed_string_t wred;
1355 cmdline_fixed_string_t profile;
1357 uint32_t wred_profile_id;
1360 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del =
1361 TOKEN_STRING_INITIALIZER(
1362 struct cmd_del_port_tm_node_wred_profile_result, del, "del");
1363 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port =
1364 TOKEN_STRING_INITIALIZER(
1365 struct cmd_del_port_tm_node_wred_profile_result, port, "port");
1366 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm =
1367 TOKEN_STRING_INITIALIZER(
1368 struct cmd_del_port_tm_node_wred_profile_result, tm, "tm");
1369 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node =
1370 TOKEN_STRING_INITIALIZER(
1371 struct cmd_del_port_tm_node_wred_profile_result, node, "node");
1372 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred =
1373 TOKEN_STRING_INITIALIZER(
1374 struct cmd_del_port_tm_node_wred_profile_result, wred, "wred");
1375 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile =
1376 TOKEN_STRING_INITIALIZER(
1377 struct cmd_del_port_tm_node_wred_profile_result,
1378 profile, "profile");
1379 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id =
1380 TOKEN_NUM_INITIALIZER(
1381 struct cmd_del_port_tm_node_wred_profile_result,
1383 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id =
1384 TOKEN_NUM_INITIALIZER(
1385 struct cmd_del_port_tm_node_wred_profile_result,
1386 wred_profile_id, UINT32);
1388 static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result,
1389 __attribute__((unused)) struct cmdline *cl,
1390 __attribute__((unused)) void *data)
1392 struct cmd_del_port_tm_node_wred_profile_result *res = parsed_result;
1393 struct rte_tm_error error;
1394 uint32_t wred_profile_id = res->wred_profile_id;
1395 portid_t port_id = res->port_id;
1398 if (port_id_is_invalid(port_id, ENABLED_WARN))
1401 ret = rte_tm_wred_profile_delete(port_id, wred_profile_id, &error);
1403 print_err_msg(&error);
1408 cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile = {
1409 .f = cmd_del_port_tm_node_wred_profile_parsed,
1411 .help_str = "Delete port tm node wred profile",
1413 (void *)&cmd_del_port_tm_node_wred_profile_del,
1414 (void *)&cmd_del_port_tm_node_wred_profile_port,
1415 (void *)&cmd_del_port_tm_node_wred_profile_tm,
1416 (void *)&cmd_del_port_tm_node_wred_profile_node,
1417 (void *)&cmd_del_port_tm_node_wred_profile_wred,
1418 (void *)&cmd_del_port_tm_node_wred_profile_profile,
1419 (void *)&cmd_del_port_tm_node_wred_profile_port_id,
1420 (void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id,
1425 /* *** Update Port TM Node Shaper profile *** */
1426 struct cmd_set_port_tm_node_shaper_profile_result {
1427 cmdline_fixed_string_t set;
1428 cmdline_fixed_string_t port;
1429 cmdline_fixed_string_t tm;
1430 cmdline_fixed_string_t node;
1431 cmdline_fixed_string_t shaper;
1432 cmdline_fixed_string_t profile;
1435 uint32_t shaper_profile_id;
1438 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set =
1439 TOKEN_STRING_INITIALIZER(
1440 struct cmd_set_port_tm_node_shaper_profile_result, set, "set");
1441 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port =
1442 TOKEN_STRING_INITIALIZER(
1443 struct cmd_set_port_tm_node_shaper_profile_result,
1445 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_tm =
1446 TOKEN_STRING_INITIALIZER(
1447 struct cmd_set_port_tm_node_shaper_profile_result, tm, "tm");
1448 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node =
1449 TOKEN_STRING_INITIALIZER(
1450 struct cmd_set_port_tm_node_shaper_profile_result,
1452 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper =
1453 TOKEN_STRING_INITIALIZER(
1454 struct cmd_set_port_tm_node_shaper_profile_result,
1456 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile =
1457 TOKEN_STRING_INITIALIZER(
1458 struct cmd_set_port_tm_node_shaper_profile_result,
1459 profile, "profile");
1460 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id =
1461 TOKEN_NUM_INITIALIZER(
1462 struct cmd_set_port_tm_node_shaper_profile_result,
1464 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id =
1465 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result,
1467 cmdline_parse_token_num_t
1468 cmd_set_port_tm_node_shaper_shaper_profile_profile_id =
1469 TOKEN_NUM_INITIALIZER(
1470 struct cmd_set_port_tm_node_shaper_profile_result,
1471 shaper_profile_id, UINT32);
1473 static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result,
1474 __attribute__((unused)) struct cmdline *cl,
1475 __attribute__((unused)) void *data)
1477 struct cmd_set_port_tm_node_shaper_profile_result *res = parsed_result;
1478 struct rte_tm_error error;
1479 uint32_t node_id = res->node_id;
1480 uint32_t shaper_profile_id = res->shaper_profile_id;
1481 portid_t port_id = res->port_id;
1484 if (port_id_is_invalid(port_id, ENABLED_WARN))
1488 if (!port_is_started(port_id)) {
1489 printf(" Port %u not started (error)\n", port_id);
1493 ret = rte_tm_node_shaper_update(port_id, node_id,
1494 shaper_profile_id, &error);
1496 print_err_msg(&error);
1501 cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile = {
1502 .f = cmd_set_port_tm_node_shaper_profile_parsed,
1504 .help_str = "Set port tm node shaper profile",
1506 (void *)&cmd_set_port_tm_node_shaper_profile_set,
1507 (void *)&cmd_set_port_tm_node_shaper_profile_port,
1508 (void *)&cmd_set_port_tm_node_shaper_profile_tm,
1509 (void *)&cmd_set_port_tm_node_shaper_profile_node,
1510 (void *)&cmd_set_port_tm_node_shaper_profile_shaper,
1511 (void *)&cmd_set_port_tm_node_shaper_profile_profile,
1512 (void *)&cmd_set_port_tm_node_shaper_profile_port_id,
1513 (void *)&cmd_set_port_tm_node_shaper_profile_node_id,
1514 (void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id,
1519 /* *** Add Port TM nonleaf node *** */
1520 struct cmd_add_port_tm_nonleaf_node_result {
1521 cmdline_fixed_string_t add;
1522 cmdline_fixed_string_t port;
1523 cmdline_fixed_string_t tm;
1524 cmdline_fixed_string_t nonleaf;
1525 cmdline_fixed_string_t node;
1528 int32_t parent_node_id;
1532 uint32_t shaper_profile_id;
1533 uint32_t n_sp_priorities;
1534 uint64_t stats_mask;
1535 cmdline_multi_string_t multi_shared_shaper_id;
1538 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add =
1539 TOKEN_STRING_INITIALIZER(
1540 struct cmd_add_port_tm_nonleaf_node_result, add, "add");
1541 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port =
1542 TOKEN_STRING_INITIALIZER(
1543 struct cmd_add_port_tm_nonleaf_node_result, port, "port");
1544 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm =
1545 TOKEN_STRING_INITIALIZER(
1546 struct cmd_add_port_tm_nonleaf_node_result, tm, "tm");
1547 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf =
1548 TOKEN_STRING_INITIALIZER(
1549 struct cmd_add_port_tm_nonleaf_node_result, nonleaf, "nonleaf");
1550 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node =
1551 TOKEN_STRING_INITIALIZER(
1552 struct cmd_add_port_tm_nonleaf_node_result, node, "node");
1553 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id =
1554 TOKEN_NUM_INITIALIZER(
1555 struct cmd_add_port_tm_nonleaf_node_result,
1557 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_id =
1558 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1560 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_parent_node_id =
1561 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1562 parent_node_id, INT32);
1563 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority =
1564 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1566 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight =
1567 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1569 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =
1570 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1572 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id =
1573 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1574 shaper_profile_id, UINT32);
1575 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =
1576 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1577 n_sp_priorities, UINT32);
1578 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask =
1579 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1580 stats_mask, UINT64);
1581 cmdline_parse_token_string_t
1582 cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id =
1583 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1584 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1586 static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
1587 __attribute__((unused)) struct cmdline *cl,
1588 __attribute__((unused)) void *data)
1590 struct cmd_add_port_tm_nonleaf_node_result *res = parsed_result;
1591 struct rte_tm_error error;
1592 struct rte_tm_node_params np;
1593 uint32_t *shared_shaper_id;
1594 uint32_t parent_node_id, n_shared_shapers = 0;
1595 char *s_str = res->multi_shared_shaper_id;
1596 portid_t port_id = res->port_id;
1599 if (port_id_is_invalid(port_id, ENABLED_WARN))
1603 if (port_is_started(port_id)) {
1604 printf(" Port %u not stopped (error)\n", port_id);
1608 memset(&np, 0, sizeof(struct rte_tm_node_params));
1610 /* Node parameters */
1611 if (res->parent_node_id < 0)
1612 parent_node_id = UINT32_MAX;
1614 parent_node_id = res->parent_node_id;
1616 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1618 if (shared_shaper_id == NULL) {
1619 printf(" Memory not allocated for shared shapers (error)\n");
1623 /* Parse multi shared shaper id string */
1624 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1626 printf(" Shared shapers params string parse error\n");
1627 free(shared_shaper_id);
1631 np.shaper_profile_id = res->shaper_profile_id;
1632 np.n_shared_shapers = n_shared_shapers;
1633 if (np.n_shared_shapers)
1634 np.shared_shaper_id = &shared_shaper_id[0];
1636 np.shared_shaper_id = NULL;
1638 np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1639 np.stats_mask = res->stats_mask;
1640 np.nonleaf.wfq_weight_mode = NULL;
1642 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1643 res->priority, res->weight, res->level_id,
1646 print_err_msg(&error);
1647 free(shared_shaper_id);
1652 cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node = {
1653 .f = cmd_add_port_tm_nonleaf_node_parsed,
1655 .help_str = "Add port tm nonleaf node",
1657 (void *)&cmd_add_port_tm_nonleaf_node_add,
1658 (void *)&cmd_add_port_tm_nonleaf_node_port,
1659 (void *)&cmd_add_port_tm_nonleaf_node_tm,
1660 (void *)&cmd_add_port_tm_nonleaf_node_nonleaf,
1661 (void *)&cmd_add_port_tm_nonleaf_node_node,
1662 (void *)&cmd_add_port_tm_nonleaf_node_port_id,
1663 (void *)&cmd_add_port_tm_nonleaf_node_node_id,
1664 (void *)&cmd_add_port_tm_nonleaf_node_parent_node_id,
1665 (void *)&cmd_add_port_tm_nonleaf_node_priority,
1666 (void *)&cmd_add_port_tm_nonleaf_node_weight,
1667 (void *)&cmd_add_port_tm_nonleaf_node_level_id,
1668 (void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id,
1669 (void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities,
1670 (void *)&cmd_add_port_tm_nonleaf_node_stats_mask,
1671 (void *)&cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id,
1676 /* *** Add Port TM leaf node *** */
1677 struct cmd_add_port_tm_leaf_node_result {
1678 cmdline_fixed_string_t add;
1679 cmdline_fixed_string_t port;
1680 cmdline_fixed_string_t tm;
1681 cmdline_fixed_string_t leaf;
1682 cmdline_fixed_string_t node;
1685 int32_t parent_node_id;
1689 uint32_t shaper_profile_id;
1691 uint32_t wred_profile_id;
1692 uint64_t stats_mask;
1693 cmdline_multi_string_t multi_shared_shaper_id;
1696 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add =
1697 TOKEN_STRING_INITIALIZER(
1698 struct cmd_add_port_tm_leaf_node_result, add, "add");
1699 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port =
1700 TOKEN_STRING_INITIALIZER(
1701 struct cmd_add_port_tm_leaf_node_result, port, "port");
1702 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm =
1703 TOKEN_STRING_INITIALIZER(
1704 struct cmd_add_port_tm_leaf_node_result, tm, "tm");
1705 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf =
1706 TOKEN_STRING_INITIALIZER(
1707 struct cmd_add_port_tm_leaf_node_result, leaf, "leaf");
1708 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node =
1709 TOKEN_STRING_INITIALIZER(
1710 struct cmd_add_port_tm_leaf_node_result, node, "node");
1711 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_id =
1712 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1714 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_node_id =
1715 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1717 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id =
1718 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1719 parent_node_id, INT32);
1720 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority =
1721 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1723 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight =
1724 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1726 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =
1727 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1729 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =
1730 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1731 shaper_profile_id, UINT32);
1732 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =
1733 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1735 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id =
1736 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1737 wred_profile_id, UINT32);
1738 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask =
1739 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1740 stats_mask, UINT64);
1741 cmdline_parse_token_string_t
1742 cmd_add_port_tm_leaf_node_multi_shared_shaper_id =
1743 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1744 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1746 static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
1747 __attribute__((unused)) struct cmdline *cl,
1748 __attribute__((unused)) void *data)
1750 struct cmd_add_port_tm_leaf_node_result *res = parsed_result;
1751 struct rte_tm_error error;
1752 struct rte_tm_node_params np;
1753 uint32_t *shared_shaper_id;
1754 uint32_t parent_node_id, n_shared_shapers = 0;
1755 portid_t port_id = res->port_id;
1756 char *s_str = res->multi_shared_shaper_id;
1759 if (port_id_is_invalid(port_id, ENABLED_WARN))
1763 if (port_is_started(port_id)) {
1764 printf(" Port %u not stopped (error)\n", port_id);
1768 memset(&np, 0, sizeof(struct rte_tm_node_params));
1770 /* Node parameters */
1771 if (res->parent_node_id < 0)
1772 parent_node_id = UINT32_MAX;
1774 parent_node_id = res->parent_node_id;
1776 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1778 if (shared_shaper_id == NULL) {
1779 printf(" Memory not allocated for shared shapers (error)\n");
1783 /* Parse multi shared shaper id string */
1784 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1786 printf(" Shared shapers params string parse error\n");
1787 free(shared_shaper_id);
1791 np.shaper_profile_id = res->shaper_profile_id;
1792 np.n_shared_shapers = n_shared_shapers;
1794 if (np.n_shared_shapers)
1795 np.shared_shaper_id = &shared_shaper_id[0];
1797 np.shared_shaper_id = NULL;
1799 np.leaf.cman = res->cman_mode;
1800 np.leaf.wred.wred_profile_id = res->wred_profile_id;
1801 np.stats_mask = res->stats_mask;
1803 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1804 res->priority, res->weight, res->level_id,
1807 print_err_msg(&error);
1808 free(shared_shaper_id);
1813 cmdline_parse_inst_t cmd_add_port_tm_leaf_node = {
1814 .f = cmd_add_port_tm_leaf_node_parsed,
1816 .help_str = "Add port tm leaf node",
1818 (void *)&cmd_add_port_tm_leaf_node_add,
1819 (void *)&cmd_add_port_tm_leaf_node_port,
1820 (void *)&cmd_add_port_tm_leaf_node_tm,
1821 (void *)&cmd_add_port_tm_leaf_node_nonleaf,
1822 (void *)&cmd_add_port_tm_leaf_node_node,
1823 (void *)&cmd_add_port_tm_leaf_node_port_id,
1824 (void *)&cmd_add_port_tm_leaf_node_node_id,
1825 (void *)&cmd_add_port_tm_leaf_node_parent_node_id,
1826 (void *)&cmd_add_port_tm_leaf_node_priority,
1827 (void *)&cmd_add_port_tm_leaf_node_weight,
1828 (void *)&cmd_add_port_tm_leaf_node_level_id,
1829 (void *)&cmd_add_port_tm_leaf_node_shaper_profile_id,
1830 (void *)&cmd_add_port_tm_leaf_node_cman_mode,
1831 (void *)&cmd_add_port_tm_leaf_node_wred_profile_id,
1832 (void *)&cmd_add_port_tm_leaf_node_stats_mask,
1833 (void *)&cmd_add_port_tm_leaf_node_multi_shared_shaper_id,
1838 /* *** Delete Port TM Node *** */
1839 struct cmd_del_port_tm_node_result {
1840 cmdline_fixed_string_t del;
1841 cmdline_fixed_string_t port;
1842 cmdline_fixed_string_t tm;
1843 cmdline_fixed_string_t node;
1848 cmdline_parse_token_string_t cmd_del_port_tm_node_del =
1849 TOKEN_STRING_INITIALIZER(
1850 struct cmd_del_port_tm_node_result, del, "del");
1851 cmdline_parse_token_string_t cmd_del_port_tm_node_port =
1852 TOKEN_STRING_INITIALIZER(
1853 struct cmd_del_port_tm_node_result, port, "port");
1854 cmdline_parse_token_string_t cmd_del_port_tm_node_tm =
1855 TOKEN_STRING_INITIALIZER(
1856 struct cmd_del_port_tm_node_result, tm, "tm");
1857 cmdline_parse_token_string_t cmd_del_port_tm_node_node =
1858 TOKEN_STRING_INITIALIZER(
1859 struct cmd_del_port_tm_node_result, node, "node");
1860 cmdline_parse_token_num_t cmd_del_port_tm_node_port_id =
1861 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
1863 cmdline_parse_token_num_t cmd_del_port_tm_node_node_id =
1864 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
1867 static void cmd_del_port_tm_node_parsed(void *parsed_result,
1868 __attribute__((unused)) struct cmdline *cl,
1869 __attribute__((unused)) void *data)
1871 struct cmd_del_port_tm_node_result *res = parsed_result;
1872 struct rte_tm_error error;
1873 uint32_t node_id = res->node_id;
1874 portid_t port_id = res->port_id;
1877 if (port_id_is_invalid(port_id, ENABLED_WARN))
1881 if (port_is_started(port_id)) {
1882 printf(" Port %u not stopped (error)\n", port_id);
1886 ret = rte_tm_node_delete(port_id, node_id, &error);
1888 print_err_msg(&error);
1893 cmdline_parse_inst_t cmd_del_port_tm_node = {
1894 .f = cmd_del_port_tm_node_parsed,
1896 .help_str = "Delete port tm node",
1898 (void *)&cmd_del_port_tm_node_del,
1899 (void *)&cmd_del_port_tm_node_port,
1900 (void *)&cmd_del_port_tm_node_tm,
1901 (void *)&cmd_del_port_tm_node_node,
1902 (void *)&cmd_del_port_tm_node_port_id,
1903 (void *)&cmd_del_port_tm_node_node_id,
1908 /* *** Update Port TM Node Parent *** */
1909 struct cmd_set_port_tm_node_parent_result {
1910 cmdline_fixed_string_t set;
1911 cmdline_fixed_string_t port;
1912 cmdline_fixed_string_t tm;
1913 cmdline_fixed_string_t node;
1914 cmdline_fixed_string_t parent;
1922 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set =
1923 TOKEN_STRING_INITIALIZER(
1924 struct cmd_set_port_tm_node_parent_result, set, "set");
1925 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port =
1926 TOKEN_STRING_INITIALIZER(
1927 struct cmd_set_port_tm_node_parent_result, port, "port");
1928 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm =
1929 TOKEN_STRING_INITIALIZER(
1930 struct cmd_set_port_tm_node_parent_result, tm, "tm");
1931 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node =
1932 TOKEN_STRING_INITIALIZER(
1933 struct cmd_set_port_tm_node_parent_result, node, "node");
1934 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent =
1935 TOKEN_STRING_INITIALIZER(
1936 struct cmd_set_port_tm_node_parent_result, parent, "parent");
1937 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id =
1938 TOKEN_NUM_INITIALIZER(
1939 struct cmd_set_port_tm_node_parent_result, port_id, UINT16);
1940 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id =
1941 TOKEN_NUM_INITIALIZER(
1942 struct cmd_set_port_tm_node_parent_result, node_id, UINT32);
1943 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id =
1944 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
1946 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority =
1947 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
1949 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight =
1950 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
1953 static void cmd_set_port_tm_node_parent_parsed(void *parsed_result,
1954 __attribute__((unused)) struct cmdline *cl,
1955 __attribute__((unused)) void *data)
1957 struct cmd_set_port_tm_node_parent_result *res = parsed_result;
1958 struct rte_tm_error error;
1959 uint32_t node_id = res->node_id;
1960 uint32_t parent_id = res->parent_id;
1961 uint32_t priority = res->priority;
1962 uint32_t weight = res->weight;
1963 portid_t port_id = res->port_id;
1966 if (port_id_is_invalid(port_id, ENABLED_WARN))
1970 if (!port_is_started(port_id)) {
1971 printf(" Port %u not started (error)\n", port_id);
1975 ret = rte_tm_node_parent_update(port_id, node_id,
1976 parent_id, priority, weight, &error);
1978 print_err_msg(&error);
1983 cmdline_parse_inst_t cmd_set_port_tm_node_parent = {
1984 .f = cmd_set_port_tm_node_parent_parsed,
1986 .help_str = "Set port tm node parent",
1988 (void *)&cmd_set_port_tm_node_parent_set,
1989 (void *)&cmd_set_port_tm_node_parent_port,
1990 (void *)&cmd_set_port_tm_node_parent_tm,
1991 (void *)&cmd_set_port_tm_node_parent_node,
1992 (void *)&cmd_set_port_tm_node_parent_parent,
1993 (void *)&cmd_set_port_tm_node_parent_port_id,
1994 (void *)&cmd_set_port_tm_node_parent_node_id,
1995 (void *)&cmd_set_port_tm_node_parent_parent_id,
1996 (void *)&cmd_set_port_tm_node_parent_priority,
1997 (void *)&cmd_set_port_tm_node_parent_weight,
2002 /* *** Port TM Hierarchy Commit *** */
2003 struct cmd_port_tm_hierarchy_commit_result {
2004 cmdline_fixed_string_t port;
2005 cmdline_fixed_string_t tm;
2006 cmdline_fixed_string_t hierarchy;
2007 cmdline_fixed_string_t commit;
2009 cmdline_fixed_string_t clean_on_fail;
2012 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port =
2013 TOKEN_STRING_INITIALIZER(
2014 struct cmd_port_tm_hierarchy_commit_result, port, "port");
2015 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm =
2016 TOKEN_STRING_INITIALIZER(
2017 struct cmd_port_tm_hierarchy_commit_result, tm, "tm");
2018 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy =
2019 TOKEN_STRING_INITIALIZER(
2020 struct cmd_port_tm_hierarchy_commit_result,
2021 hierarchy, "hierarchy");
2022 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit =
2023 TOKEN_STRING_INITIALIZER(
2024 struct cmd_port_tm_hierarchy_commit_result, commit, "commit");
2025 cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id =
2026 TOKEN_NUM_INITIALIZER(
2027 struct cmd_port_tm_hierarchy_commit_result,
2029 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_clean_on_fail =
2030 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result,
2031 clean_on_fail, "yes#no");
2033 static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result,
2034 __attribute__((unused)) struct cmdline *cl,
2035 __attribute__((unused)) void *data)
2037 struct cmd_port_tm_hierarchy_commit_result *res = parsed_result;
2038 struct rte_tm_error error;
2039 uint32_t clean_on_fail;
2040 portid_t port_id = res->port_id;
2043 if (port_id_is_invalid(port_id, ENABLED_WARN))
2046 if (strcmp(res->clean_on_fail, "yes") == 0)
2051 ret = rte_tm_hierarchy_commit(port_id, clean_on_fail, &error);
2053 print_err_msg(&error);
2058 cmdline_parse_inst_t cmd_port_tm_hierarchy_commit = {
2059 .f = cmd_port_tm_hierarchy_commit_parsed,
2061 .help_str = "Set port tm node shaper profile",
2063 (void *)&cmd_port_tm_hierarchy_commit_port,
2064 (void *)&cmd_port_tm_hierarchy_commit_tm,
2065 (void *)&cmd_port_tm_hierarchy_commit_hierarchy,
2066 (void *)&cmd_port_tm_hierarchy_commit_commit,
2067 (void *)&cmd_port_tm_hierarchy_commit_port_id,
2068 (void *)&cmd_port_tm_hierarchy_commit_clean_on_fail,