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;
798 uint64_t cmit_tb_rate;
799 uint64_t cmit_tb_size;
800 uint64_t peak_tb_rate;
801 uint64_t peak_tb_size;
802 uint32_t pktlen_adjust;
805 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add =
806 TOKEN_STRING_INITIALIZER(
807 struct cmd_add_port_tm_node_shaper_profile_result, add, "add");
808 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port =
809 TOKEN_STRING_INITIALIZER(
810 struct cmd_add_port_tm_node_shaper_profile_result,
812 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm =
813 TOKEN_STRING_INITIALIZER(
814 struct cmd_add_port_tm_node_shaper_profile_result,
816 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node =
817 TOKEN_STRING_INITIALIZER(
818 struct cmd_add_port_tm_node_shaper_profile_result,
820 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper =
821 TOKEN_STRING_INITIALIZER(
822 struct cmd_add_port_tm_node_shaper_profile_result,
824 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile =
825 TOKEN_STRING_INITIALIZER(
826 struct cmd_add_port_tm_node_shaper_profile_result,
828 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id =
829 TOKEN_NUM_INITIALIZER(
830 struct cmd_add_port_tm_node_shaper_profile_result,
832 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id =
833 TOKEN_NUM_INITIALIZER(
834 struct cmd_add_port_tm_node_shaper_profile_result,
836 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_rate =
837 TOKEN_NUM_INITIALIZER(
838 struct cmd_add_port_tm_node_shaper_profile_result,
839 cmit_tb_rate, UINT64);
840 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_size =
841 TOKEN_NUM_INITIALIZER(
842 struct cmd_add_port_tm_node_shaper_profile_result,
843 cmit_tb_size, UINT64);
844 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_rate =
845 TOKEN_NUM_INITIALIZER(
846 struct cmd_add_port_tm_node_shaper_profile_result,
847 peak_tb_rate, UINT64);
848 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_size =
849 TOKEN_NUM_INITIALIZER(
850 struct cmd_add_port_tm_node_shaper_profile_result,
851 peak_tb_size, UINT64);
852 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust =
853 TOKEN_NUM_INITIALIZER(
854 struct cmd_add_port_tm_node_shaper_profile_result,
855 pktlen_adjust, UINT32);
857 static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
858 __attribute__((unused)) struct cmdline *cl,
859 __attribute__((unused)) void *data)
861 struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result;
862 struct rte_tm_shaper_params sp;
863 struct rte_tm_error error;
864 uint32_t shaper_id = res->shaper_id;
865 uint32_t pkt_len_adjust = res->pktlen_adjust;
866 portid_t port_id = res->port_id;
869 if (port_id_is_invalid(port_id, ENABLED_WARN))
872 /* Private shaper profile params */
873 memset(&sp, 0, sizeof(struct rte_tm_shaper_params));
874 sp.committed.rate = res->cmit_tb_rate;
875 sp.committed.size = res->cmit_tb_size;
876 sp.peak.rate = res->peak_tb_rate;
877 sp.peak.size = res->peak_tb_size;
878 sp.pkt_length_adjust = pkt_len_adjust;
880 ret = rte_tm_shaper_profile_add(port_id, shaper_id, &sp, &error);
882 print_err_msg(&error);
887 cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile = {
888 .f = cmd_add_port_tm_node_shaper_profile_parsed,
890 .help_str = "Add port tm node private shaper profile",
892 (void *)&cmd_add_port_tm_node_shaper_profile_add,
893 (void *)&cmd_add_port_tm_node_shaper_profile_port,
894 (void *)&cmd_add_port_tm_node_shaper_profile_tm,
895 (void *)&cmd_add_port_tm_node_shaper_profile_node,
896 (void *)&cmd_add_port_tm_node_shaper_profile_shaper,
897 (void *)&cmd_add_port_tm_node_shaper_profile_profile,
898 (void *)&cmd_add_port_tm_node_shaper_profile_port_id,
899 (void *)&cmd_add_port_tm_node_shaper_profile_shaper_id,
900 (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_rate,
901 (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_size,
902 (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_rate,
903 (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_size,
904 (void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust,
909 /* *** Delete Port TM Private Shaper Profile *** */
910 struct cmd_del_port_tm_node_shaper_profile_result {
911 cmdline_fixed_string_t del;
912 cmdline_fixed_string_t port;
913 cmdline_fixed_string_t tm;
914 cmdline_fixed_string_t node;
915 cmdline_fixed_string_t shaper;
916 cmdline_fixed_string_t profile;
921 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del =
922 TOKEN_STRING_INITIALIZER(
923 struct cmd_del_port_tm_node_shaper_profile_result, del, "del");
924 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port =
925 TOKEN_STRING_INITIALIZER(
926 struct cmd_del_port_tm_node_shaper_profile_result,
928 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm =
929 TOKEN_STRING_INITIALIZER(
930 struct cmd_del_port_tm_node_shaper_profile_result, tm, "tm");
931 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node =
932 TOKEN_STRING_INITIALIZER(
933 struct cmd_del_port_tm_node_shaper_profile_result,
935 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper =
936 TOKEN_STRING_INITIALIZER(
937 struct cmd_del_port_tm_node_shaper_profile_result,
939 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile =
940 TOKEN_STRING_INITIALIZER(
941 struct cmd_del_port_tm_node_shaper_profile_result,
943 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id =
944 TOKEN_NUM_INITIALIZER(
945 struct cmd_del_port_tm_node_shaper_profile_result,
947 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id =
948 TOKEN_NUM_INITIALIZER(
949 struct cmd_del_port_tm_node_shaper_profile_result,
952 static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result,
953 __attribute__((unused)) struct cmdline *cl,
954 __attribute__((unused)) void *data)
956 struct cmd_del_port_tm_node_shaper_profile_result *res = parsed_result;
957 struct rte_tm_error error;
958 uint32_t shaper_id = res->shaper_id;
959 portid_t port_id = res->port_id;
962 if (port_id_is_invalid(port_id, ENABLED_WARN))
965 ret = rte_tm_shaper_profile_delete(port_id, shaper_id, &error);
967 print_err_msg(&error);
972 cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile = {
973 .f = cmd_del_port_tm_node_shaper_profile_parsed,
975 .help_str = "Delete port tm node private shaper profile",
977 (void *)&cmd_del_port_tm_node_shaper_profile_del,
978 (void *)&cmd_del_port_tm_node_shaper_profile_port,
979 (void *)&cmd_del_port_tm_node_shaper_profile_tm,
980 (void *)&cmd_del_port_tm_node_shaper_profile_node,
981 (void *)&cmd_del_port_tm_node_shaper_profile_shaper,
982 (void *)&cmd_del_port_tm_node_shaper_profile_profile,
983 (void *)&cmd_del_port_tm_node_shaper_profile_port_id,
984 (void *)&cmd_del_port_tm_node_shaper_profile_shaper_id,
989 /* *** Add/Update Port TM shared Shaper *** */
990 struct cmd_add_port_tm_node_shared_shaper_result {
991 cmdline_fixed_string_t cmd_type;
992 cmdline_fixed_string_t port;
993 cmdline_fixed_string_t tm;
994 cmdline_fixed_string_t node;
995 cmdline_fixed_string_t shared;
996 cmdline_fixed_string_t shaper;
998 uint32_t shared_shaper_id;
999 uint32_t shaper_profile_id;
1002 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type =
1003 TOKEN_STRING_INITIALIZER(
1004 struct cmd_add_port_tm_node_shared_shaper_result,
1005 cmd_type, "add#set");
1006 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port =
1007 TOKEN_STRING_INITIALIZER(
1008 struct cmd_add_port_tm_node_shared_shaper_result, port, "port");
1009 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm =
1010 TOKEN_STRING_INITIALIZER(
1011 struct cmd_add_port_tm_node_shared_shaper_result, tm, "tm");
1012 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node =
1013 TOKEN_STRING_INITIALIZER(
1014 struct cmd_add_port_tm_node_shared_shaper_result, node, "node");
1015 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared =
1016 TOKEN_STRING_INITIALIZER(
1017 struct cmd_add_port_tm_node_shared_shaper_result,
1019 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper =
1020 TOKEN_STRING_INITIALIZER(
1021 struct cmd_add_port_tm_node_shared_shaper_result,
1023 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id =
1024 TOKEN_NUM_INITIALIZER(
1025 struct cmd_add_port_tm_node_shared_shaper_result,
1027 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id =
1028 TOKEN_NUM_INITIALIZER(
1029 struct cmd_add_port_tm_node_shared_shaper_result,
1030 shared_shaper_id, UINT32);
1031 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id =
1032 TOKEN_NUM_INITIALIZER(
1033 struct cmd_add_port_tm_node_shared_shaper_result,
1034 shaper_profile_id, UINT32);
1036 static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result,
1037 __attribute__((unused)) struct cmdline *cl,
1038 __attribute__((unused)) void *data)
1040 struct cmd_add_port_tm_node_shared_shaper_result *res = parsed_result;
1041 struct rte_tm_error error;
1042 uint32_t shared_shaper_id = res->shared_shaper_id;
1043 uint32_t shaper_profile_id = res->shaper_profile_id;
1044 portid_t port_id = res->port_id;
1047 if (port_id_is_invalid(port_id, ENABLED_WARN))
1050 /* Command type: add */
1051 if ((strcmp(res->cmd_type, "add") == 0) &&
1052 (port_is_started(port_id))) {
1053 printf(" Port %u not stopped (error)\n", port_id);
1057 /* Command type: set (update) */
1058 if ((strcmp(res->cmd_type, "set") == 0) &&
1059 (!port_is_started(port_id))) {
1060 printf(" Port %u not started (error)\n", port_id);
1064 ret = rte_tm_shared_shaper_add_update(port_id, shared_shaper_id,
1065 shaper_profile_id, &error);
1067 print_err_msg(&error);
1072 cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper = {
1073 .f = cmd_add_port_tm_node_shared_shaper_parsed,
1075 .help_str = "add/update port tm node shared shaper",
1077 (void *)&cmd_add_port_tm_node_shared_shaper_cmd_type,
1078 (void *)&cmd_add_port_tm_node_shared_shaper_port,
1079 (void *)&cmd_add_port_tm_node_shared_shaper_tm,
1080 (void *)&cmd_add_port_tm_node_shared_shaper_node,
1081 (void *)&cmd_add_port_tm_node_shared_shaper_shared,
1082 (void *)&cmd_add_port_tm_node_shared_shaper_shaper,
1083 (void *)&cmd_add_port_tm_node_shared_shaper_port_id,
1084 (void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id,
1085 (void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id,
1090 /* *** Delete Port TM shared Shaper *** */
1091 struct cmd_del_port_tm_node_shared_shaper_result {
1092 cmdline_fixed_string_t del;
1093 cmdline_fixed_string_t port;
1094 cmdline_fixed_string_t tm;
1095 cmdline_fixed_string_t node;
1096 cmdline_fixed_string_t shared;
1097 cmdline_fixed_string_t shaper;
1099 uint32_t shared_shaper_id;
1102 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del =
1103 TOKEN_STRING_INITIALIZER(
1104 struct cmd_del_port_tm_node_shared_shaper_result, del, "del");
1105 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port =
1106 TOKEN_STRING_INITIALIZER(
1107 struct cmd_del_port_tm_node_shared_shaper_result, port, "port");
1108 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm =
1109 TOKEN_STRING_INITIALIZER(
1110 struct cmd_del_port_tm_node_shared_shaper_result, tm, "tm");
1111 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node =
1112 TOKEN_STRING_INITIALIZER(
1113 struct cmd_del_port_tm_node_shared_shaper_result, node, "node");
1114 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared =
1115 TOKEN_STRING_INITIALIZER(
1116 struct cmd_del_port_tm_node_shared_shaper_result,
1118 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper =
1119 TOKEN_STRING_INITIALIZER(
1120 struct cmd_del_port_tm_node_shared_shaper_result,
1122 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id =
1123 TOKEN_NUM_INITIALIZER(
1124 struct cmd_del_port_tm_node_shared_shaper_result,
1126 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id =
1127 TOKEN_NUM_INITIALIZER(
1128 struct cmd_del_port_tm_node_shared_shaper_result,
1129 shared_shaper_id, UINT32);
1131 static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result,
1132 __attribute__((unused)) struct cmdline *cl,
1133 __attribute__((unused)) void *data)
1135 struct cmd_del_port_tm_node_shared_shaper_result *res = parsed_result;
1136 struct rte_tm_error error;
1137 uint32_t shared_shaper_id = res->shared_shaper_id;
1138 portid_t port_id = res->port_id;
1141 if (port_id_is_invalid(port_id, ENABLED_WARN))
1144 ret = rte_tm_shared_shaper_delete(port_id, shared_shaper_id, &error);
1146 print_err_msg(&error);
1151 cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper = {
1152 .f = cmd_del_port_tm_node_shared_shaper_parsed,
1154 .help_str = "delete port tm node shared shaper",
1156 (void *)&cmd_del_port_tm_node_shared_shaper_del,
1157 (void *)&cmd_del_port_tm_node_shared_shaper_port,
1158 (void *)&cmd_del_port_tm_node_shared_shaper_tm,
1159 (void *)&cmd_del_port_tm_node_shared_shaper_node,
1160 (void *)&cmd_del_port_tm_node_shared_shaper_shared,
1161 (void *)&cmd_del_port_tm_node_shared_shaper_shaper,
1162 (void *)&cmd_del_port_tm_node_shared_shaper_port_id,
1163 (void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id,
1168 /* *** Add Port TM Node WRED Profile *** */
1169 struct cmd_add_port_tm_node_wred_profile_result {
1170 cmdline_fixed_string_t add;
1171 cmdline_fixed_string_t port;
1172 cmdline_fixed_string_t tm;
1173 cmdline_fixed_string_t node;
1174 cmdline_fixed_string_t wred;
1175 cmdline_fixed_string_t profile;
1177 uint32_t wred_profile_id;
1178 cmdline_fixed_string_t color_g;
1181 uint16_t maxp_inv_g;
1183 cmdline_fixed_string_t color_y;
1186 uint16_t maxp_inv_y;
1188 cmdline_fixed_string_t color_r;
1191 uint16_t maxp_inv_r;
1195 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add =
1196 TOKEN_STRING_INITIALIZER(
1197 struct cmd_add_port_tm_node_wred_profile_result, add, "add");
1198 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port =
1199 TOKEN_STRING_INITIALIZER(
1200 struct cmd_add_port_tm_node_wred_profile_result, port, "port");
1201 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm =
1202 TOKEN_STRING_INITIALIZER(
1203 struct cmd_add_port_tm_node_wred_profile_result, tm, "tm");
1204 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node =
1205 TOKEN_STRING_INITIALIZER(
1206 struct cmd_add_port_tm_node_wred_profile_result, node, "node");
1207 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred =
1208 TOKEN_STRING_INITIALIZER(
1209 struct cmd_add_port_tm_node_wred_profile_result, wred, "wred");
1210 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile =
1211 TOKEN_STRING_INITIALIZER(
1212 struct cmd_add_port_tm_node_wred_profile_result,
1213 profile, "profile");
1214 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id =
1215 TOKEN_NUM_INITIALIZER(
1216 struct cmd_add_port_tm_node_wred_profile_result,
1218 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id =
1219 TOKEN_NUM_INITIALIZER(
1220 struct cmd_add_port_tm_node_wred_profile_result,
1221 wred_profile_id, UINT32);
1222 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g =
1223 TOKEN_STRING_INITIALIZER(
1224 struct cmd_add_port_tm_node_wred_profile_result,
1226 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g =
1227 TOKEN_NUM_INITIALIZER(
1228 struct cmd_add_port_tm_node_wred_profile_result,
1230 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g =
1231 TOKEN_NUM_INITIALIZER(
1232 struct cmd_add_port_tm_node_wred_profile_result,
1234 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g =
1235 TOKEN_NUM_INITIALIZER(
1236 struct cmd_add_port_tm_node_wred_profile_result,
1237 maxp_inv_g, UINT16);
1238 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g =
1239 TOKEN_NUM_INITIALIZER(
1240 struct cmd_add_port_tm_node_wred_profile_result,
1242 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y =
1243 TOKEN_STRING_INITIALIZER(
1244 struct cmd_add_port_tm_node_wred_profile_result,
1246 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y =
1247 TOKEN_NUM_INITIALIZER(
1248 struct cmd_add_port_tm_node_wred_profile_result,
1250 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y =
1251 TOKEN_NUM_INITIALIZER(
1252 struct cmd_add_port_tm_node_wred_profile_result,
1254 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y =
1255 TOKEN_NUM_INITIALIZER(
1256 struct cmd_add_port_tm_node_wred_profile_result,
1257 maxp_inv_y, UINT16);
1258 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y =
1259 TOKEN_NUM_INITIALIZER(
1260 struct cmd_add_port_tm_node_wred_profile_result,
1262 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r =
1263 TOKEN_STRING_INITIALIZER(
1264 struct cmd_add_port_tm_node_wred_profile_result,
1266 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r =
1267 TOKEN_NUM_INITIALIZER(
1268 struct cmd_add_port_tm_node_wred_profile_result,
1270 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r =
1271 TOKEN_NUM_INITIALIZER(
1272 struct cmd_add_port_tm_node_wred_profile_result,
1274 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r =
1275 TOKEN_NUM_INITIALIZER(
1276 struct cmd_add_port_tm_node_wred_profile_result,
1277 maxp_inv_r, UINT16);
1278 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r =
1279 TOKEN_NUM_INITIALIZER(
1280 struct cmd_add_port_tm_node_wred_profile_result,
1284 static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
1285 __attribute__((unused)) struct cmdline *cl,
1286 __attribute__((unused)) void *data)
1288 struct cmd_add_port_tm_node_wred_profile_result *res = parsed_result;
1289 struct rte_tm_wred_params wp;
1290 enum rte_tm_color color;
1291 struct rte_tm_error error;
1292 uint32_t wred_profile_id = res->wred_profile_id;
1293 portid_t port_id = res->port_id;
1296 if (port_id_is_invalid(port_id, ENABLED_WARN))
1299 memset(&wp, 0, sizeof(struct rte_tm_wred_params));
1301 /* WRED Params (Green Color)*/
1302 color = RTE_TM_GREEN;
1303 wp.red_params[color].min_th = res->min_th_g;
1304 wp.red_params[color].max_th = res->max_th_g;
1305 wp.red_params[color].maxp_inv = res->maxp_inv_g;
1306 wp.red_params[color].wq_log2 = res->wq_log2_g;
1309 /* WRED Params (Yellow Color)*/
1310 color = RTE_TM_YELLOW;
1311 wp.red_params[color].min_th = res->min_th_y;
1312 wp.red_params[color].max_th = res->max_th_y;
1313 wp.red_params[color].maxp_inv = res->maxp_inv_y;
1314 wp.red_params[color].wq_log2 = res->wq_log2_y;
1316 /* WRED Params (Red Color)*/
1318 wp.red_params[color].min_th = res->min_th_r;
1319 wp.red_params[color].max_th = res->max_th_r;
1320 wp.red_params[color].maxp_inv = res->maxp_inv_r;
1321 wp.red_params[color].wq_log2 = res->wq_log2_r;
1323 ret = rte_tm_wred_profile_add(port_id, wred_profile_id, &wp, &error);
1325 print_err_msg(&error);
1330 cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile = {
1331 .f = cmd_add_port_tm_node_wred_profile_parsed,
1333 .help_str = "Add port tm node wred profile",
1335 (void *)&cmd_add_port_tm_node_wred_profile_add,
1336 (void *)&cmd_add_port_tm_node_wred_profile_port,
1337 (void *)&cmd_add_port_tm_node_wred_profile_tm,
1338 (void *)&cmd_add_port_tm_node_wred_profile_node,
1339 (void *)&cmd_add_port_tm_node_wred_profile_wred,
1340 (void *)&cmd_add_port_tm_node_wred_profile_profile,
1341 (void *)&cmd_add_port_tm_node_wred_profile_port_id,
1342 (void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id,
1343 (void *)&cmd_add_port_tm_node_wred_profile_color_g,
1344 (void *)&cmd_add_port_tm_node_wred_profile_min_th_g,
1345 (void *)&cmd_add_port_tm_node_wred_profile_max_th_g,
1346 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g,
1347 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g,
1348 (void *)&cmd_add_port_tm_node_wred_profile_color_y,
1349 (void *)&cmd_add_port_tm_node_wred_profile_min_th_y,
1350 (void *)&cmd_add_port_tm_node_wred_profile_max_th_y,
1351 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y,
1352 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y,
1353 (void *)&cmd_add_port_tm_node_wred_profile_color_r,
1354 (void *)&cmd_add_port_tm_node_wred_profile_min_th_r,
1355 (void *)&cmd_add_port_tm_node_wred_profile_max_th_r,
1356 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r,
1357 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r,
1362 /* *** Delete Port TM node WRED Profile *** */
1363 struct cmd_del_port_tm_node_wred_profile_result {
1364 cmdline_fixed_string_t del;
1365 cmdline_fixed_string_t port;
1366 cmdline_fixed_string_t tm;
1367 cmdline_fixed_string_t node;
1368 cmdline_fixed_string_t wred;
1369 cmdline_fixed_string_t profile;
1371 uint32_t wred_profile_id;
1374 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del =
1375 TOKEN_STRING_INITIALIZER(
1376 struct cmd_del_port_tm_node_wred_profile_result, del, "del");
1377 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port =
1378 TOKEN_STRING_INITIALIZER(
1379 struct cmd_del_port_tm_node_wred_profile_result, port, "port");
1380 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm =
1381 TOKEN_STRING_INITIALIZER(
1382 struct cmd_del_port_tm_node_wred_profile_result, tm, "tm");
1383 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node =
1384 TOKEN_STRING_INITIALIZER(
1385 struct cmd_del_port_tm_node_wred_profile_result, node, "node");
1386 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred =
1387 TOKEN_STRING_INITIALIZER(
1388 struct cmd_del_port_tm_node_wred_profile_result, wred, "wred");
1389 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile =
1390 TOKEN_STRING_INITIALIZER(
1391 struct cmd_del_port_tm_node_wred_profile_result,
1392 profile, "profile");
1393 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id =
1394 TOKEN_NUM_INITIALIZER(
1395 struct cmd_del_port_tm_node_wred_profile_result,
1397 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id =
1398 TOKEN_NUM_INITIALIZER(
1399 struct cmd_del_port_tm_node_wred_profile_result,
1400 wred_profile_id, UINT32);
1402 static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result,
1403 __attribute__((unused)) struct cmdline *cl,
1404 __attribute__((unused)) void *data)
1406 struct cmd_del_port_tm_node_wred_profile_result *res = parsed_result;
1407 struct rte_tm_error error;
1408 uint32_t wred_profile_id = res->wred_profile_id;
1409 portid_t port_id = res->port_id;
1412 if (port_id_is_invalid(port_id, ENABLED_WARN))
1415 ret = rte_tm_wred_profile_delete(port_id, wred_profile_id, &error);
1417 print_err_msg(&error);
1422 cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile = {
1423 .f = cmd_del_port_tm_node_wred_profile_parsed,
1425 .help_str = "Delete port tm node wred profile",
1427 (void *)&cmd_del_port_tm_node_wred_profile_del,
1428 (void *)&cmd_del_port_tm_node_wred_profile_port,
1429 (void *)&cmd_del_port_tm_node_wred_profile_tm,
1430 (void *)&cmd_del_port_tm_node_wred_profile_node,
1431 (void *)&cmd_del_port_tm_node_wred_profile_wred,
1432 (void *)&cmd_del_port_tm_node_wred_profile_profile,
1433 (void *)&cmd_del_port_tm_node_wred_profile_port_id,
1434 (void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id,
1439 /* *** Update Port TM Node Shaper profile *** */
1440 struct cmd_set_port_tm_node_shaper_profile_result {
1441 cmdline_fixed_string_t set;
1442 cmdline_fixed_string_t port;
1443 cmdline_fixed_string_t tm;
1444 cmdline_fixed_string_t node;
1445 cmdline_fixed_string_t shaper;
1446 cmdline_fixed_string_t profile;
1449 uint32_t shaper_profile_id;
1452 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set =
1453 TOKEN_STRING_INITIALIZER(
1454 struct cmd_set_port_tm_node_shaper_profile_result, set, "set");
1455 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port =
1456 TOKEN_STRING_INITIALIZER(
1457 struct cmd_set_port_tm_node_shaper_profile_result,
1459 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_tm =
1460 TOKEN_STRING_INITIALIZER(
1461 struct cmd_set_port_tm_node_shaper_profile_result, tm, "tm");
1462 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node =
1463 TOKEN_STRING_INITIALIZER(
1464 struct cmd_set_port_tm_node_shaper_profile_result,
1466 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper =
1467 TOKEN_STRING_INITIALIZER(
1468 struct cmd_set_port_tm_node_shaper_profile_result,
1470 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile =
1471 TOKEN_STRING_INITIALIZER(
1472 struct cmd_set_port_tm_node_shaper_profile_result,
1473 profile, "profile");
1474 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id =
1475 TOKEN_NUM_INITIALIZER(
1476 struct cmd_set_port_tm_node_shaper_profile_result,
1478 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id =
1479 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result,
1481 cmdline_parse_token_num_t
1482 cmd_set_port_tm_node_shaper_shaper_profile_profile_id =
1483 TOKEN_NUM_INITIALIZER(
1484 struct cmd_set_port_tm_node_shaper_profile_result,
1485 shaper_profile_id, UINT32);
1487 static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result,
1488 __attribute__((unused)) struct cmdline *cl,
1489 __attribute__((unused)) void *data)
1491 struct cmd_set_port_tm_node_shaper_profile_result *res = parsed_result;
1492 struct rte_tm_error error;
1493 uint32_t node_id = res->node_id;
1494 uint32_t shaper_profile_id = res->shaper_profile_id;
1495 portid_t port_id = res->port_id;
1498 if (port_id_is_invalid(port_id, ENABLED_WARN))
1502 if (!port_is_started(port_id)) {
1503 printf(" Port %u not started (error)\n", port_id);
1507 ret = rte_tm_node_shaper_update(port_id, node_id,
1508 shaper_profile_id, &error);
1510 print_err_msg(&error);
1515 cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile = {
1516 .f = cmd_set_port_tm_node_shaper_profile_parsed,
1518 .help_str = "Set port tm node shaper profile",
1520 (void *)&cmd_set_port_tm_node_shaper_profile_set,
1521 (void *)&cmd_set_port_tm_node_shaper_profile_port,
1522 (void *)&cmd_set_port_tm_node_shaper_profile_tm,
1523 (void *)&cmd_set_port_tm_node_shaper_profile_node,
1524 (void *)&cmd_set_port_tm_node_shaper_profile_shaper,
1525 (void *)&cmd_set_port_tm_node_shaper_profile_profile,
1526 (void *)&cmd_set_port_tm_node_shaper_profile_port_id,
1527 (void *)&cmd_set_port_tm_node_shaper_profile_node_id,
1528 (void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id,
1533 /* *** Add Port TM nonleaf node *** */
1534 struct cmd_add_port_tm_nonleaf_node_result {
1535 cmdline_fixed_string_t add;
1536 cmdline_fixed_string_t port;
1537 cmdline_fixed_string_t tm;
1538 cmdline_fixed_string_t nonleaf;
1539 cmdline_fixed_string_t node;
1542 int32_t parent_node_id;
1546 uint32_t shaper_profile_id;
1547 uint32_t n_sp_priorities;
1548 uint64_t stats_mask;
1549 cmdline_multi_string_t multi_shared_shaper_id;
1552 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add =
1553 TOKEN_STRING_INITIALIZER(
1554 struct cmd_add_port_tm_nonleaf_node_result, add, "add");
1555 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port =
1556 TOKEN_STRING_INITIALIZER(
1557 struct cmd_add_port_tm_nonleaf_node_result, port, "port");
1558 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm =
1559 TOKEN_STRING_INITIALIZER(
1560 struct cmd_add_port_tm_nonleaf_node_result, tm, "tm");
1561 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf =
1562 TOKEN_STRING_INITIALIZER(
1563 struct cmd_add_port_tm_nonleaf_node_result, nonleaf, "nonleaf");
1564 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node =
1565 TOKEN_STRING_INITIALIZER(
1566 struct cmd_add_port_tm_nonleaf_node_result, node, "node");
1567 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id =
1568 TOKEN_NUM_INITIALIZER(
1569 struct cmd_add_port_tm_nonleaf_node_result,
1571 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_id =
1572 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1574 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_parent_node_id =
1575 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1576 parent_node_id, INT32);
1577 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority =
1578 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1580 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight =
1581 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1583 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =
1584 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1586 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id =
1587 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1588 shaper_profile_id, UINT32);
1589 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =
1590 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1591 n_sp_priorities, UINT32);
1592 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask =
1593 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1594 stats_mask, UINT64);
1595 cmdline_parse_token_string_t
1596 cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id =
1597 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1598 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1600 static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
1601 __attribute__((unused)) struct cmdline *cl,
1602 __attribute__((unused)) void *data)
1604 struct cmd_add_port_tm_nonleaf_node_result *res = parsed_result;
1605 struct rte_tm_error error;
1606 struct rte_tm_node_params np;
1607 uint32_t *shared_shaper_id;
1608 uint32_t parent_node_id, n_shared_shapers = 0;
1609 char *s_str = res->multi_shared_shaper_id;
1610 portid_t port_id = res->port_id;
1613 if (port_id_is_invalid(port_id, ENABLED_WARN))
1616 memset(&np, 0, sizeof(struct rte_tm_node_params));
1618 /* Node parameters */
1619 if (res->parent_node_id < 0)
1620 parent_node_id = UINT32_MAX;
1622 parent_node_id = res->parent_node_id;
1624 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1626 if (shared_shaper_id == NULL) {
1627 printf(" Memory not allocated for shared shapers (error)\n");
1631 /* Parse multi shared shaper id string */
1632 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1634 printf(" Shared shapers params string parse error\n");
1635 free(shared_shaper_id);
1639 np.shaper_profile_id = res->shaper_profile_id;
1640 np.n_shared_shapers = n_shared_shapers;
1641 if (np.n_shared_shapers) {
1642 np.shared_shaper_id = &shared_shaper_id[0];
1644 free(shared_shaper_id);
1645 shared_shaper_id = NULL;
1648 np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1649 np.stats_mask = res->stats_mask;
1650 np.nonleaf.wfq_weight_mode = NULL;
1652 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1653 res->priority, res->weight, res->level_id,
1656 print_err_msg(&error);
1657 free(shared_shaper_id);
1662 cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node = {
1663 .f = cmd_add_port_tm_nonleaf_node_parsed,
1665 .help_str = "Add port tm nonleaf node",
1667 (void *)&cmd_add_port_tm_nonleaf_node_add,
1668 (void *)&cmd_add_port_tm_nonleaf_node_port,
1669 (void *)&cmd_add_port_tm_nonleaf_node_tm,
1670 (void *)&cmd_add_port_tm_nonleaf_node_nonleaf,
1671 (void *)&cmd_add_port_tm_nonleaf_node_node,
1672 (void *)&cmd_add_port_tm_nonleaf_node_port_id,
1673 (void *)&cmd_add_port_tm_nonleaf_node_node_id,
1674 (void *)&cmd_add_port_tm_nonleaf_node_parent_node_id,
1675 (void *)&cmd_add_port_tm_nonleaf_node_priority,
1676 (void *)&cmd_add_port_tm_nonleaf_node_weight,
1677 (void *)&cmd_add_port_tm_nonleaf_node_level_id,
1678 (void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id,
1679 (void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities,
1680 (void *)&cmd_add_port_tm_nonleaf_node_stats_mask,
1681 (void *)&cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id,
1686 /* *** Add Port TM leaf node *** */
1687 struct cmd_add_port_tm_leaf_node_result {
1688 cmdline_fixed_string_t add;
1689 cmdline_fixed_string_t port;
1690 cmdline_fixed_string_t tm;
1691 cmdline_fixed_string_t leaf;
1692 cmdline_fixed_string_t node;
1695 int32_t parent_node_id;
1699 uint32_t shaper_profile_id;
1701 uint32_t wred_profile_id;
1702 uint64_t stats_mask;
1703 cmdline_multi_string_t multi_shared_shaper_id;
1706 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add =
1707 TOKEN_STRING_INITIALIZER(
1708 struct cmd_add_port_tm_leaf_node_result, add, "add");
1709 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port =
1710 TOKEN_STRING_INITIALIZER(
1711 struct cmd_add_port_tm_leaf_node_result, port, "port");
1712 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm =
1713 TOKEN_STRING_INITIALIZER(
1714 struct cmd_add_port_tm_leaf_node_result, tm, "tm");
1715 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf =
1716 TOKEN_STRING_INITIALIZER(
1717 struct cmd_add_port_tm_leaf_node_result, leaf, "leaf");
1718 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node =
1719 TOKEN_STRING_INITIALIZER(
1720 struct cmd_add_port_tm_leaf_node_result, node, "node");
1721 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_id =
1722 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1724 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_node_id =
1725 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1727 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id =
1728 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1729 parent_node_id, INT32);
1730 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority =
1731 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1733 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight =
1734 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1736 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =
1737 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1739 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =
1740 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1741 shaper_profile_id, UINT32);
1742 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =
1743 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1745 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id =
1746 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1747 wred_profile_id, UINT32);
1748 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask =
1749 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1750 stats_mask, UINT64);
1751 cmdline_parse_token_string_t
1752 cmd_add_port_tm_leaf_node_multi_shared_shaper_id =
1753 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1754 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1756 static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
1757 __attribute__((unused)) struct cmdline *cl,
1758 __attribute__((unused)) void *data)
1760 struct cmd_add_port_tm_leaf_node_result *res = parsed_result;
1761 struct rte_tm_error error;
1762 struct rte_tm_node_params np;
1763 uint32_t *shared_shaper_id;
1764 uint32_t parent_node_id, n_shared_shapers = 0;
1765 portid_t port_id = res->port_id;
1766 char *s_str = res->multi_shared_shaper_id;
1769 if (port_id_is_invalid(port_id, ENABLED_WARN))
1772 memset(&np, 0, sizeof(struct rte_tm_node_params));
1774 /* Node parameters */
1775 if (res->parent_node_id < 0)
1776 parent_node_id = UINT32_MAX;
1778 parent_node_id = res->parent_node_id;
1780 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1782 if (shared_shaper_id == NULL) {
1783 printf(" Memory not allocated for shared shapers (error)\n");
1787 /* Parse multi shared shaper id string */
1788 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1790 printf(" Shared shapers params string parse error\n");
1791 free(shared_shaper_id);
1795 np.shaper_profile_id = res->shaper_profile_id;
1796 np.n_shared_shapers = n_shared_shapers;
1798 if (np.n_shared_shapers) {
1799 np.shared_shaper_id = &shared_shaper_id[0];
1801 free(shared_shaper_id);
1802 shared_shaper_id = NULL;
1805 np.leaf.cman = res->cman_mode;
1806 np.leaf.wred.wred_profile_id = res->wred_profile_id;
1807 np.stats_mask = res->stats_mask;
1809 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1810 res->priority, res->weight, res->level_id,
1813 print_err_msg(&error);
1814 free(shared_shaper_id);
1819 cmdline_parse_inst_t cmd_add_port_tm_leaf_node = {
1820 .f = cmd_add_port_tm_leaf_node_parsed,
1822 .help_str = "Add port tm leaf node",
1824 (void *)&cmd_add_port_tm_leaf_node_add,
1825 (void *)&cmd_add_port_tm_leaf_node_port,
1826 (void *)&cmd_add_port_tm_leaf_node_tm,
1827 (void *)&cmd_add_port_tm_leaf_node_nonleaf,
1828 (void *)&cmd_add_port_tm_leaf_node_node,
1829 (void *)&cmd_add_port_tm_leaf_node_port_id,
1830 (void *)&cmd_add_port_tm_leaf_node_node_id,
1831 (void *)&cmd_add_port_tm_leaf_node_parent_node_id,
1832 (void *)&cmd_add_port_tm_leaf_node_priority,
1833 (void *)&cmd_add_port_tm_leaf_node_weight,
1834 (void *)&cmd_add_port_tm_leaf_node_level_id,
1835 (void *)&cmd_add_port_tm_leaf_node_shaper_profile_id,
1836 (void *)&cmd_add_port_tm_leaf_node_cman_mode,
1837 (void *)&cmd_add_port_tm_leaf_node_wred_profile_id,
1838 (void *)&cmd_add_port_tm_leaf_node_stats_mask,
1839 (void *)&cmd_add_port_tm_leaf_node_multi_shared_shaper_id,
1844 /* *** Delete Port TM Node *** */
1845 struct cmd_del_port_tm_node_result {
1846 cmdline_fixed_string_t del;
1847 cmdline_fixed_string_t port;
1848 cmdline_fixed_string_t tm;
1849 cmdline_fixed_string_t node;
1854 cmdline_parse_token_string_t cmd_del_port_tm_node_del =
1855 TOKEN_STRING_INITIALIZER(
1856 struct cmd_del_port_tm_node_result, del, "del");
1857 cmdline_parse_token_string_t cmd_del_port_tm_node_port =
1858 TOKEN_STRING_INITIALIZER(
1859 struct cmd_del_port_tm_node_result, port, "port");
1860 cmdline_parse_token_string_t cmd_del_port_tm_node_tm =
1861 TOKEN_STRING_INITIALIZER(
1862 struct cmd_del_port_tm_node_result, tm, "tm");
1863 cmdline_parse_token_string_t cmd_del_port_tm_node_node =
1864 TOKEN_STRING_INITIALIZER(
1865 struct cmd_del_port_tm_node_result, node, "node");
1866 cmdline_parse_token_num_t cmd_del_port_tm_node_port_id =
1867 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
1869 cmdline_parse_token_num_t cmd_del_port_tm_node_node_id =
1870 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
1873 static void cmd_del_port_tm_node_parsed(void *parsed_result,
1874 __attribute__((unused)) struct cmdline *cl,
1875 __attribute__((unused)) void *data)
1877 struct cmd_del_port_tm_node_result *res = parsed_result;
1878 struct rte_tm_error error;
1879 uint32_t node_id = res->node_id;
1880 portid_t port_id = res->port_id;
1883 if (port_id_is_invalid(port_id, ENABLED_WARN))
1887 if (port_is_started(port_id)) {
1888 printf(" Port %u not stopped (error)\n", port_id);
1892 ret = rte_tm_node_delete(port_id, node_id, &error);
1894 print_err_msg(&error);
1899 cmdline_parse_inst_t cmd_del_port_tm_node = {
1900 .f = cmd_del_port_tm_node_parsed,
1902 .help_str = "Delete port tm node",
1904 (void *)&cmd_del_port_tm_node_del,
1905 (void *)&cmd_del_port_tm_node_port,
1906 (void *)&cmd_del_port_tm_node_tm,
1907 (void *)&cmd_del_port_tm_node_node,
1908 (void *)&cmd_del_port_tm_node_port_id,
1909 (void *)&cmd_del_port_tm_node_node_id,
1914 /* *** Update Port TM Node Parent *** */
1915 struct cmd_set_port_tm_node_parent_result {
1916 cmdline_fixed_string_t set;
1917 cmdline_fixed_string_t port;
1918 cmdline_fixed_string_t tm;
1919 cmdline_fixed_string_t node;
1920 cmdline_fixed_string_t parent;
1928 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set =
1929 TOKEN_STRING_INITIALIZER(
1930 struct cmd_set_port_tm_node_parent_result, set, "set");
1931 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port =
1932 TOKEN_STRING_INITIALIZER(
1933 struct cmd_set_port_tm_node_parent_result, port, "port");
1934 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm =
1935 TOKEN_STRING_INITIALIZER(
1936 struct cmd_set_port_tm_node_parent_result, tm, "tm");
1937 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node =
1938 TOKEN_STRING_INITIALIZER(
1939 struct cmd_set_port_tm_node_parent_result, node, "node");
1940 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent =
1941 TOKEN_STRING_INITIALIZER(
1942 struct cmd_set_port_tm_node_parent_result, parent, "parent");
1943 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id =
1944 TOKEN_NUM_INITIALIZER(
1945 struct cmd_set_port_tm_node_parent_result, port_id, UINT16);
1946 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id =
1947 TOKEN_NUM_INITIALIZER(
1948 struct cmd_set_port_tm_node_parent_result, node_id, UINT32);
1949 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id =
1950 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
1952 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority =
1953 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
1955 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight =
1956 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
1959 static void cmd_set_port_tm_node_parent_parsed(void *parsed_result,
1960 __attribute__((unused)) struct cmdline *cl,
1961 __attribute__((unused)) void *data)
1963 struct cmd_set_port_tm_node_parent_result *res = parsed_result;
1964 struct rte_tm_error error;
1965 uint32_t node_id = res->node_id;
1966 uint32_t parent_id = res->parent_id;
1967 uint32_t priority = res->priority;
1968 uint32_t weight = res->weight;
1969 portid_t port_id = res->port_id;
1972 if (port_id_is_invalid(port_id, ENABLED_WARN))
1976 if (!port_is_started(port_id)) {
1977 printf(" Port %u not started (error)\n", port_id);
1981 ret = rte_tm_node_parent_update(port_id, node_id,
1982 parent_id, priority, weight, &error);
1984 print_err_msg(&error);
1989 cmdline_parse_inst_t cmd_set_port_tm_node_parent = {
1990 .f = cmd_set_port_tm_node_parent_parsed,
1992 .help_str = "Set port tm node parent",
1994 (void *)&cmd_set_port_tm_node_parent_set,
1995 (void *)&cmd_set_port_tm_node_parent_port,
1996 (void *)&cmd_set_port_tm_node_parent_tm,
1997 (void *)&cmd_set_port_tm_node_parent_node,
1998 (void *)&cmd_set_port_tm_node_parent_parent,
1999 (void *)&cmd_set_port_tm_node_parent_port_id,
2000 (void *)&cmd_set_port_tm_node_parent_node_id,
2001 (void *)&cmd_set_port_tm_node_parent_parent_id,
2002 (void *)&cmd_set_port_tm_node_parent_priority,
2003 (void *)&cmd_set_port_tm_node_parent_weight,
2008 /* *** Port TM Hierarchy Commit *** */
2009 struct cmd_port_tm_hierarchy_commit_result {
2010 cmdline_fixed_string_t port;
2011 cmdline_fixed_string_t tm;
2012 cmdline_fixed_string_t hierarchy;
2013 cmdline_fixed_string_t commit;
2015 cmdline_fixed_string_t clean_on_fail;
2018 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port =
2019 TOKEN_STRING_INITIALIZER(
2020 struct cmd_port_tm_hierarchy_commit_result, port, "port");
2021 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm =
2022 TOKEN_STRING_INITIALIZER(
2023 struct cmd_port_tm_hierarchy_commit_result, tm, "tm");
2024 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy =
2025 TOKEN_STRING_INITIALIZER(
2026 struct cmd_port_tm_hierarchy_commit_result,
2027 hierarchy, "hierarchy");
2028 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit =
2029 TOKEN_STRING_INITIALIZER(
2030 struct cmd_port_tm_hierarchy_commit_result, commit, "commit");
2031 cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id =
2032 TOKEN_NUM_INITIALIZER(
2033 struct cmd_port_tm_hierarchy_commit_result,
2035 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_clean_on_fail =
2036 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result,
2037 clean_on_fail, "yes#no");
2039 static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result,
2040 __attribute__((unused)) struct cmdline *cl,
2041 __attribute__((unused)) void *data)
2043 struct cmd_port_tm_hierarchy_commit_result *res = parsed_result;
2044 struct rte_tm_error error;
2045 uint32_t clean_on_fail;
2046 portid_t port_id = res->port_id;
2049 if (port_id_is_invalid(port_id, ENABLED_WARN))
2052 if (strcmp(res->clean_on_fail, "yes") == 0)
2057 ret = rte_tm_hierarchy_commit(port_id, clean_on_fail, &error);
2059 print_err_msg(&error);
2064 cmdline_parse_inst_t cmd_port_tm_hierarchy_commit = {
2065 .f = cmd_port_tm_hierarchy_commit_parsed,
2067 .help_str = "Set port tm node shaper profile",
2069 (void *)&cmd_port_tm_hierarchy_commit_port,
2070 (void *)&cmd_port_tm_hierarchy_commit_tm,
2071 (void *)&cmd_port_tm_hierarchy_commit_hierarchy,
2072 (void *)&cmd_port_tm_hierarchy_commit_commit,
2073 (void *)&cmd_port_tm_hierarchy_commit_port_id,
2074 (void *)&cmd_port_tm_hierarchy_commit_clean_on_fail,