1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #include <cmdline_parse.h>
6 #include <cmdline_parse_num.h>
7 #include <cmdline_parse_string.h>
9 #include <rte_ethdev.h>
14 #include "cmdline_tm.h"
16 #define PARSE_DELIMITER " \f\n\r\t\v"
17 #define MAX_NUM_SHARED_SHAPERS 256
19 #define skip_white_spaces(pos) \
21 __typeof__(pos) _p = (pos); \
22 for ( ; isspace(*_p); _p++) \
27 /** Display TM Error Message */
29 print_err_msg(struct rte_tm_error *error)
31 static const char *const errstrlist[] = {
32 [RTE_TM_ERROR_TYPE_NONE] = "no error",
33 [RTE_TM_ERROR_TYPE_UNSPECIFIED] = "cause unspecified",
34 [RTE_TM_ERROR_TYPE_CAPABILITIES]
35 = "capability parameter null",
36 [RTE_TM_ERROR_TYPE_LEVEL_ID] = "level id",
37 [RTE_TM_ERROR_TYPE_WRED_PROFILE]
38 = "wred profile null",
39 [RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN] = "wred profile(green)",
40 [RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW]
41 = "wred profile(yellow)",
42 [RTE_TM_ERROR_TYPE_WRED_PROFILE_RED] = "wred profile(red)",
43 [RTE_TM_ERROR_TYPE_WRED_PROFILE_ID] = "wred profile id",
44 [RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID]
45 = "shared wred context id",
46 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE] = "shaper profile null",
47 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE]
48 = "committed rate field (shaper profile)",
49 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE]
50 = "committed size field (shaper profile)",
51 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE]
52 = "peak rate field (shaper profile)",
53 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE]
54 = "peak size field (shaper profile)",
55 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN]
56 = "packet adjust length field (shaper profile)",
57 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID] = "shaper profile id",
58 [RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID] = "shared shaper id",
59 [RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID] = "parent node id",
60 [RTE_TM_ERROR_TYPE_NODE_PRIORITY] = "node priority",
61 [RTE_TM_ERROR_TYPE_NODE_WEIGHT] = "node weight",
62 [RTE_TM_ERROR_TYPE_NODE_PARAMS] = "node parameter null",
63 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID]
64 = "shaper profile id field (node params)",
65 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID]
66 = "shared shaper id field (node params)",
67 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS]
68 = "num shared shapers field (node params)",
69 [RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE]
70 = "wfq weght mode field (node params)",
71 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES]
72 = "num strict priorities field (node params)",
73 [RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN]
74 = "congestion management mode field (node params)",
75 [RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID] =
76 "wred profile id field (node params)",
77 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID]
78 = "shared wred context id field (node params)",
79 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS]
80 = "num shared wred contexts field (node params)",
81 [RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS]
82 = "stats field (node params)",
83 [RTE_TM_ERROR_TYPE_NODE_ID] = "node id",
89 if ((unsigned int)error->type >= RTE_DIM(errstrlist) ||
90 !errstrlist[error->type])
91 errstr = "unknown type";
93 errstr = errstrlist[error->type];
96 snprintf(buf, sizeof(buf), "cause: %p, ", error->cause);
98 printf("%s: %s%s (error %d)\n", errstr, error->cause ? buf : "",
99 error->message ? error->message : "(no stated reason)",
104 read_uint64(uint64_t *value, const char *p)
109 p = skip_white_spaces(p);
113 val = strtoul(p, &next, 10);
135 p = skip_white_spaces(p);
144 read_uint32(uint32_t *value, const char *p)
147 int ret = read_uint64(&val, p);
152 if (val > UINT32_MAX)
160 parse_multi_ss_id_str(char *s_str, uint32_t *n_ssp, uint32_t shaper_id[])
162 uint32_t n_shared_shapers = 0, i = 0;
165 /* First token: num of shared shapers */
166 token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
170 if (read_uint32(&n_shared_shapers, token))
173 /* Check: num of shared shaper */
174 if (n_shared_shapers >= MAX_NUM_SHARED_SHAPERS) {
175 printf(" Number of shared shapers exceed the max (error)\n");
179 /* Parse shared shaper ids */
181 token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
182 if ((token != NULL && n_shared_shapers == 0) ||
183 (token == NULL && i < n_shared_shapers))
189 if (read_uint32(&shaper_id[i], token))
193 *n_ssp = n_shared_shapers;
197 /* *** Port TM Capability *** */
198 struct cmd_show_port_tm_cap_result {
199 cmdline_fixed_string_t show;
200 cmdline_fixed_string_t port;
201 cmdline_fixed_string_t tm;
202 cmdline_fixed_string_t cap;
206 cmdline_parse_token_string_t cmd_show_port_tm_cap_show =
207 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
209 cmdline_parse_token_string_t cmd_show_port_tm_cap_port =
210 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
212 cmdline_parse_token_string_t cmd_show_port_tm_cap_tm =
213 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
215 cmdline_parse_token_string_t cmd_show_port_tm_cap_cap =
216 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
218 cmdline_parse_token_num_t cmd_show_port_tm_cap_port_id =
219 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_cap_result,
222 static void cmd_show_port_tm_cap_parsed(void *parsed_result,
223 __attribute__((unused)) struct cmdline *cl,
224 __attribute__((unused)) void *data)
226 struct cmd_show_port_tm_cap_result *res = parsed_result;
227 struct rte_tm_capabilities cap;
228 struct rte_tm_error error;
229 portid_t port_id = res->port_id;
233 if (port_id_is_invalid(port_id, ENABLED_WARN))
236 memset(&cap, 0, sizeof(struct rte_tm_capabilities));
237 ret = rte_tm_capabilities_get(port_id, &cap, &error);
239 print_err_msg(&error);
243 printf("\n**** Port TM Capabilities ****\n\n");
244 printf("cap.n_nodes_max %" PRIu32 "\n", cap.n_nodes_max);
245 printf("cap.n_levels_max %" PRIu32 "\n", cap.n_levels_max);
246 printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
247 cap.non_leaf_nodes_identical);
248 printf("cap.leaf_nodes_identical %" PRId32 "\n",
249 cap.leaf_nodes_identical);
250 printf("cap.shaper_n_max %u\n", cap.shaper_n_max);
251 printf("cap.shaper_private_n_max %" PRIu32 "\n",
252 cap.shaper_private_n_max);
253 printf("cap.shaper_private_dual_rate_n_max %" PRId32 "\n",
254 cap.shaper_private_dual_rate_n_max);
255 printf("cap.shaper_private_rate_min %" PRIu64 "\n",
256 cap.shaper_private_rate_min);
257 printf("cap.shaper_private_rate_max %" PRIu64 "\n",
258 cap.shaper_private_rate_max);
259 printf("cap.shaper_shared_n_max %" PRIu32 "\n",
260 cap.shaper_shared_n_max);
261 printf("cap.shaper_shared_n_nodes_per_shaper_max %" PRIu32 "\n",
262 cap.shaper_shared_n_nodes_per_shaper_max);
263 printf("cap.shaper_shared_n_shapers_per_node_max %" PRIu32 "\n",
264 cap.shaper_shared_n_shapers_per_node_max);
265 printf("cap.shaper_shared_dual_rate_n_max %" PRIu32 "\n",
266 cap.shaper_shared_dual_rate_n_max);
267 printf("cap.shaper_shared_rate_min %" PRIu64 "\n",
268 cap.shaper_shared_rate_min);
269 printf("cap.shaper_shared_rate_max %" PRIu64 "\n",
270 cap.shaper_shared_rate_max);
271 printf("cap.shaper_pkt_length_adjust_min %" PRId32 "\n",
272 cap.shaper_pkt_length_adjust_min);
273 printf("cap.shaper_pkt_length_adjust_max %" PRId32 "\n",
274 cap.shaper_pkt_length_adjust_max);
275 printf("cap.sched_n_children_max %" PRIu32 "\n",
276 cap.sched_n_children_max);
277 printf("cap.sched_sp_n_priorities_max %" PRIu32 "\n",
278 cap.sched_sp_n_priorities_max);
279 printf("cap.sched_wfq_n_children_per_group_max %" PRIu32 "\n",
280 cap.sched_wfq_n_children_per_group_max);
281 printf("cap.sched_wfq_n_groups_max %" PRIu32 "\n",
282 cap.sched_wfq_n_groups_max);
283 printf("cap.sched_wfq_weight_max %" PRIu32 "\n",
284 cap.sched_wfq_weight_max);
285 printf("cap.cman_head_drop_supported %" PRId32 "\n",
286 cap.cman_head_drop_supported);
287 printf("cap.cman_wred_context_n_max %" PRIu32 "\n",
288 cap.cman_wred_context_n_max);
289 printf("cap.cman_wred_context_private_n_max %" PRIu32 "\n",
290 cap.cman_wred_context_private_n_max);
291 printf("cap.cman_wred_context_shared_n_max %" PRIu32 "\n",
292 cap.cman_wred_context_shared_n_max);
293 printf("cap.cman_wred_context_shared_n_nodes_per_context_max %" PRIu32
294 "\n", cap.cman_wred_context_shared_n_nodes_per_context_max);
295 printf("cap.cman_wred_context_shared_n_contexts_per_node_max %" PRIu32
296 "\n", cap.cman_wred_context_shared_n_contexts_per_node_max);
298 for (i = 0; i < RTE_TM_COLORS; i++) {
299 printf("cap.mark_vlan_dei_supported %" PRId32 "\n",
300 cap.mark_vlan_dei_supported[i]);
301 printf("cap.mark_ip_ecn_tcp_supported %" PRId32 "\n",
302 cap.mark_ip_ecn_tcp_supported[i]);
303 printf("cap.mark_ip_ecn_sctp_supported %" PRId32 "\n",
304 cap.mark_ip_ecn_sctp_supported[i]);
305 printf("cap.mark_ip_dscp_supported %" PRId32 "\n",
306 cap.mark_ip_dscp_supported[i]);
309 printf("cap.dynamic_update_mask %" PRIx64 "\n",
310 cap.dynamic_update_mask);
311 printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
314 cmdline_parse_inst_t cmd_show_port_tm_cap = {
315 .f = cmd_show_port_tm_cap_parsed,
317 .help_str = "Show Port TM Capabilities",
319 (void *)&cmd_show_port_tm_cap_show,
320 (void *)&cmd_show_port_tm_cap_port,
321 (void *)&cmd_show_port_tm_cap_tm,
322 (void *)&cmd_show_port_tm_cap_cap,
323 (void *)&cmd_show_port_tm_cap_port_id,
328 /* *** Port TM Hierarchical Level Capability *** */
329 struct cmd_show_port_tm_level_cap_result {
330 cmdline_fixed_string_t show;
331 cmdline_fixed_string_t port;
332 cmdline_fixed_string_t tm;
333 cmdline_fixed_string_t level;
334 cmdline_fixed_string_t cap;
339 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_show =
340 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
342 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_port =
343 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
345 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_tm =
346 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
348 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_level =
349 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
351 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_cap =
352 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
354 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_port_id =
355 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
357 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_level_id =
358 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
362 static void cmd_show_port_tm_level_cap_parsed(void *parsed_result,
363 __attribute__((unused)) struct cmdline *cl,
364 __attribute__((unused)) void *data)
366 struct cmd_show_port_tm_level_cap_result *res = parsed_result;
367 struct rte_tm_level_capabilities lcap;
368 struct rte_tm_error error;
369 portid_t port_id = res->port_id;
370 uint32_t level_id = res->level_id;
373 if (port_id_is_invalid(port_id, ENABLED_WARN))
376 memset(&lcap, 0, sizeof(struct rte_tm_level_capabilities));
377 ret = rte_tm_level_capabilities_get(port_id, level_id, &lcap, &error);
379 print_err_msg(&error);
382 printf("\n** Port TM Hierarchy level %" PRIu32 " Capability **\n\n",
385 printf("cap.n_nodes_max %" PRIu32 "\n", lcap.n_nodes_max);
386 printf("cap.n_nodes_nonleaf_max %" PRIu32 "\n",
387 lcap.n_nodes_nonleaf_max);
388 printf("cap.n_nodes_leaf_max %" PRIu32 "\n", lcap.n_nodes_leaf_max);
389 printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
390 lcap.non_leaf_nodes_identical);
391 printf("cap.leaf_nodes_identical %" PRId32 "\n",
392 lcap.leaf_nodes_identical);
394 printf("cap.nonleaf.shaper_private_supported %" PRId32 "\n",
395 lcap.nonleaf.shaper_private_supported);
396 printf("cap.nonleaf.shaper_private_dual_rate_supported %" PRId32
397 "\n", lcap.nonleaf.shaper_private_dual_rate_supported);
398 printf("cap.nonleaf.shaper_private_rate_min %" PRIu64 "\n",
399 lcap.nonleaf.shaper_private_rate_min);
400 printf("cap.nonleaf.shaper_private_rate_max %" PRIu64 "\n",
401 lcap.nonleaf.shaper_private_rate_max);
402 printf("cap.nonleaf.shaper_shared_n_max %" PRIu32 "\n",
403 lcap.nonleaf.shaper_shared_n_max);
404 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
405 lcap.nonleaf.sched_n_children_max);
406 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
407 lcap.nonleaf.sched_sp_n_priorities_max);
408 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
409 "\n", lcap.nonleaf.sched_wfq_n_children_per_group_max);
410 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
411 lcap.nonleaf.sched_wfq_n_groups_max);
412 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
413 lcap.nonleaf.sched_wfq_weight_max);
414 printf("cap.nonleaf.stats_mask %" PRIx64 "\n",
415 lcap.nonleaf.stats_mask);
417 printf("cap.leaf.shaper_private_supported %" PRId32 "\n",
418 lcap.leaf.shaper_private_supported);
419 printf("cap.leaf.shaper_private_dual_rate_supported %" PRId32
420 "\n", lcap.leaf.shaper_private_dual_rate_supported);
421 printf("cap.leaf.shaper_private_rate_min %" PRIu64 "\n",
422 lcap.leaf.shaper_private_rate_min);
423 printf("cap.leaf.shaper_private_rate_max %" PRIu64 "\n",
424 lcap.leaf.shaper_private_rate_max);
425 printf("cap.leaf.shaper_shared_n_max %" PRIu32 "\n",
426 lcap.leaf.shaper_shared_n_max);
427 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
428 lcap.leaf.cman_head_drop_supported);
429 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
430 "\n", lcap.leaf.cman_wred_context_private_supported);
431 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
432 lcap.leaf.cman_wred_context_shared_n_max);
433 printf("cap.leaf.stats_mask %" PRIx64 "\n",
434 lcap.leaf.stats_mask);
438 cmdline_parse_inst_t cmd_show_port_tm_level_cap = {
439 .f = cmd_show_port_tm_level_cap_parsed,
441 .help_str = "Show Port TM Hierarhical level Capabilities",
443 (void *)&cmd_show_port_tm_level_cap_show,
444 (void *)&cmd_show_port_tm_level_cap_port,
445 (void *)&cmd_show_port_tm_level_cap_tm,
446 (void *)&cmd_show_port_tm_level_cap_level,
447 (void *)&cmd_show_port_tm_level_cap_cap,
448 (void *)&cmd_show_port_tm_level_cap_port_id,
449 (void *)&cmd_show_port_tm_level_cap_level_id,
454 /* *** Port TM Hierarchy Node Capability *** */
455 struct cmd_show_port_tm_node_cap_result {
456 cmdline_fixed_string_t show;
457 cmdline_fixed_string_t port;
458 cmdline_fixed_string_t tm;
459 cmdline_fixed_string_t node;
460 cmdline_fixed_string_t cap;
465 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_show =
466 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
468 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_port =
469 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
471 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_tm =
472 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
474 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_node =
475 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
477 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_cap =
478 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
480 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_port_id =
481 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
483 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_node_id =
484 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
487 static void cmd_show_port_tm_node_cap_parsed(void *parsed_result,
488 __attribute__((unused)) struct cmdline *cl,
489 __attribute__((unused)) void *data)
491 struct cmd_show_port_tm_node_cap_result *res = parsed_result;
492 struct rte_tm_node_capabilities ncap;
493 struct rte_tm_error error;
494 uint32_t node_id = res->node_id;
495 portid_t port_id = res->port_id;
496 int ret, is_leaf = 0;
498 if (port_id_is_invalid(port_id, ENABLED_WARN))
501 /* Node id must be valid */
502 ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
504 print_err_msg(&error);
508 memset(&ncap, 0, sizeof(struct rte_tm_node_capabilities));
509 ret = rte_tm_node_capabilities_get(port_id, node_id, &ncap, &error);
511 print_err_msg(&error);
514 printf("\n** Port TM Hierarchy node %" PRIu32 " Capability **\n\n",
516 printf("cap.shaper_private_supported %" PRId32 "\n",
517 ncap.shaper_private_supported);
518 printf("cap.shaper_private_dual_rate_supported %" PRId32 "\n",
519 ncap.shaper_private_dual_rate_supported);
520 printf("cap.shaper_private_rate_min %" PRIu64 "\n",
521 ncap.shaper_private_rate_min);
522 printf("cap.shaper_private_rate_max %" PRIu64 "\n",
523 ncap.shaper_private_rate_max);
524 printf("cap.shaper_shared_n_max %" PRIu32 "\n",
525 ncap.shaper_shared_n_max);
527 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
528 ncap.nonleaf.sched_n_children_max);
529 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
530 ncap.nonleaf.sched_sp_n_priorities_max);
531 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
532 "\n", ncap.nonleaf.sched_wfq_n_children_per_group_max);
533 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
534 ncap.nonleaf.sched_wfq_n_groups_max);
535 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
536 ncap.nonleaf.sched_wfq_weight_max);
538 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
539 ncap.leaf.cman_head_drop_supported);
540 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
541 "\n", ncap.leaf.cman_wred_context_private_supported);
542 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
543 ncap.leaf.cman_wred_context_shared_n_max);
545 printf("cap.stats_mask %" PRIx64 "\n", ncap.stats_mask);
548 cmdline_parse_inst_t cmd_show_port_tm_node_cap = {
549 .f = cmd_show_port_tm_node_cap_parsed,
551 .help_str = "Show Port TM Hierarchy node capabilities",
553 (void *)&cmd_show_port_tm_node_cap_show,
554 (void *)&cmd_show_port_tm_node_cap_port,
555 (void *)&cmd_show_port_tm_node_cap_tm,
556 (void *)&cmd_show_port_tm_node_cap_node,
557 (void *)&cmd_show_port_tm_node_cap_cap,
558 (void *)&cmd_show_port_tm_node_cap_port_id,
559 (void *)&cmd_show_port_tm_node_cap_node_id,
564 /* *** Show Port TM Node Statistics *** */
565 struct cmd_show_port_tm_node_stats_result {
566 cmdline_fixed_string_t show;
567 cmdline_fixed_string_t port;
568 cmdline_fixed_string_t tm;
569 cmdline_fixed_string_t node;
570 cmdline_fixed_string_t stats;
576 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_show =
577 TOKEN_STRING_INITIALIZER(
578 struct cmd_show_port_tm_node_stats_result, show, "show");
579 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_port =
580 TOKEN_STRING_INITIALIZER(
581 struct cmd_show_port_tm_node_stats_result, port, "port");
582 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_tm =
583 TOKEN_STRING_INITIALIZER(
584 struct cmd_show_port_tm_node_stats_result, tm, "tm");
585 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_node =
586 TOKEN_STRING_INITIALIZER(
587 struct cmd_show_port_tm_node_stats_result, node, "node");
588 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_stats =
589 TOKEN_STRING_INITIALIZER(
590 struct cmd_show_port_tm_node_stats_result, stats, "stats");
591 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_port_id =
592 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_stats_result,
594 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_node_id =
595 TOKEN_NUM_INITIALIZER(
596 struct cmd_show_port_tm_node_stats_result,
598 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_clear =
599 TOKEN_NUM_INITIALIZER(
600 struct cmd_show_port_tm_node_stats_result, clear, UINT32);
602 static void cmd_show_port_tm_node_stats_parsed(void *parsed_result,
603 __attribute__((unused)) struct cmdline *cl,
604 __attribute__((unused)) void *data)
606 struct cmd_show_port_tm_node_stats_result *res = parsed_result;
607 struct rte_tm_node_stats stats;
608 struct rte_tm_error error;
609 uint64_t stats_mask = 0;
610 uint32_t node_id = res->node_id;
611 uint32_t clear = res->clear;
612 portid_t port_id = res->port_id;
615 if (port_id_is_invalid(port_id, ENABLED_WARN))
619 if (!port_is_started(port_id)) {
620 printf(" Port %u not started (error)\n", port_id);
624 memset(&stats, 0, sizeof(struct rte_tm_node_stats));
625 ret = rte_tm_node_stats_read(port_id, node_id, &stats,
626 &stats_mask, clear, &error);
628 print_err_msg(&error);
633 if (stats_mask & RTE_TM_STATS_N_PKTS)
634 printf("\tPkts scheduled from node: %" PRIu64 "\n",
636 if (stats_mask & RTE_TM_STATS_N_BYTES)
637 printf("\tBytes scheduled from node: %" PRIu64 "\n",
639 if (stats_mask & RTE_TM_STATS_N_PKTS_GREEN_DROPPED)
640 printf("\tPkts dropped (green): %" PRIu64 "\n",
641 stats.leaf.n_pkts_dropped[RTE_TM_GREEN]);
642 if (stats_mask & RTE_TM_STATS_N_PKTS_YELLOW_DROPPED)
643 printf("\tPkts dropped (yellow): %" PRIu64 "\n",
644 stats.leaf.n_pkts_dropped[RTE_TM_YELLOW]);
645 if (stats_mask & RTE_TM_STATS_N_PKTS_RED_DROPPED)
646 printf("\tPkts dropped (red): %" PRIu64 "\n",
647 stats.leaf.n_pkts_dropped[RTE_TM_RED]);
648 if (stats_mask & RTE_TM_STATS_N_BYTES_GREEN_DROPPED)
649 printf("\tBytes dropped (green): %" PRIu64 "\n",
650 stats.leaf.n_bytes_dropped[RTE_TM_GREEN]);
651 if (stats_mask & RTE_TM_STATS_N_BYTES_YELLOW_DROPPED)
652 printf("\tBytes dropped (yellow): %" PRIu64 "\n",
653 stats.leaf.n_bytes_dropped[RTE_TM_YELLOW]);
654 if (stats_mask & RTE_TM_STATS_N_BYTES_RED_DROPPED)
655 printf("\tBytes dropped (red): %" PRIu64 "\n",
656 stats.leaf.n_bytes_dropped[RTE_TM_RED]);
657 if (stats_mask & RTE_TM_STATS_N_PKTS_QUEUED)
658 printf("\tPkts queued: %" PRIu64 "\n",
659 stats.leaf.n_pkts_queued);
660 if (stats_mask & RTE_TM_STATS_N_BYTES_QUEUED)
661 printf("\tBytes queued: %" PRIu64 "\n",
662 stats.leaf.n_bytes_queued);
665 cmdline_parse_inst_t cmd_show_port_tm_node_stats = {
666 .f = cmd_show_port_tm_node_stats_parsed,
668 .help_str = "Show port tm node stats",
670 (void *)&cmd_show_port_tm_node_stats_show,
671 (void *)&cmd_show_port_tm_node_stats_port,
672 (void *)&cmd_show_port_tm_node_stats_tm,
673 (void *)&cmd_show_port_tm_node_stats_node,
674 (void *)&cmd_show_port_tm_node_stats_stats,
675 (void *)&cmd_show_port_tm_node_stats_port_id,
676 (void *)&cmd_show_port_tm_node_stats_node_id,
677 (void *)&cmd_show_port_tm_node_stats_clear,
682 /* *** Show Port TM Node Type *** */
683 struct cmd_show_port_tm_node_type_result {
684 cmdline_fixed_string_t show;
685 cmdline_fixed_string_t port;
686 cmdline_fixed_string_t tm;
687 cmdline_fixed_string_t node;
688 cmdline_fixed_string_t type;
693 cmdline_parse_token_string_t cmd_show_port_tm_node_type_show =
694 TOKEN_STRING_INITIALIZER(
695 struct cmd_show_port_tm_node_type_result, show, "show");
696 cmdline_parse_token_string_t cmd_show_port_tm_node_type_port =
697 TOKEN_STRING_INITIALIZER(
698 struct cmd_show_port_tm_node_type_result, port, "port");
699 cmdline_parse_token_string_t cmd_show_port_tm_node_type_tm =
700 TOKEN_STRING_INITIALIZER(
701 struct cmd_show_port_tm_node_type_result, tm, "tm");
702 cmdline_parse_token_string_t cmd_show_port_tm_node_type_node =
703 TOKEN_STRING_INITIALIZER(
704 struct cmd_show_port_tm_node_type_result, node, "node");
705 cmdline_parse_token_string_t cmd_show_port_tm_node_type_type =
706 TOKEN_STRING_INITIALIZER(
707 struct cmd_show_port_tm_node_type_result, type, "type");
708 cmdline_parse_token_num_t cmd_show_port_tm_node_type_port_id =
709 TOKEN_NUM_INITIALIZER(
710 struct cmd_show_port_tm_node_type_result,
712 cmdline_parse_token_num_t cmd_show_port_tm_node_type_node_id =
713 TOKEN_NUM_INITIALIZER(
714 struct cmd_show_port_tm_node_type_result,
717 static void cmd_show_port_tm_node_type_parsed(void *parsed_result,
718 __attribute__((unused)) struct cmdline *cl,
719 __attribute__((unused)) void *data)
721 struct cmd_show_port_tm_node_type_result *res = parsed_result;
722 struct rte_tm_error error;
723 uint32_t node_id = res->node_id;
724 portid_t port_id = res->port_id;
725 int ret, is_leaf = 0;
727 if (port_id_is_invalid(port_id, ENABLED_WARN))
730 ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
732 print_err_msg(&error);
737 printf("leaf node\n");
739 printf("nonleaf node\n");
743 cmdline_parse_inst_t cmd_show_port_tm_node_type = {
744 .f = cmd_show_port_tm_node_type_parsed,
746 .help_str = "Show port tm node type",
748 (void *)&cmd_show_port_tm_node_type_show,
749 (void *)&cmd_show_port_tm_node_type_port,
750 (void *)&cmd_show_port_tm_node_type_tm,
751 (void *)&cmd_show_port_tm_node_type_node,
752 (void *)&cmd_show_port_tm_node_type_type,
753 (void *)&cmd_show_port_tm_node_type_port_id,
754 (void *)&cmd_show_port_tm_node_type_node_id,
759 /* *** Add Port TM Private Shaper Profile *** */
760 struct cmd_add_port_tm_node_shaper_profile_result {
761 cmdline_fixed_string_t add;
762 cmdline_fixed_string_t port;
763 cmdline_fixed_string_t tm;
764 cmdline_fixed_string_t node;
765 cmdline_fixed_string_t shaper;
766 cmdline_fixed_string_t profile;
771 uint32_t pktlen_adjust;
774 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add =
775 TOKEN_STRING_INITIALIZER(
776 struct cmd_add_port_tm_node_shaper_profile_result, add, "add");
777 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port =
778 TOKEN_STRING_INITIALIZER(
779 struct cmd_add_port_tm_node_shaper_profile_result,
781 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm =
782 TOKEN_STRING_INITIALIZER(
783 struct cmd_add_port_tm_node_shaper_profile_result,
785 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node =
786 TOKEN_STRING_INITIALIZER(
787 struct cmd_add_port_tm_node_shaper_profile_result,
789 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper =
790 TOKEN_STRING_INITIALIZER(
791 struct cmd_add_port_tm_node_shaper_profile_result,
793 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile =
794 TOKEN_STRING_INITIALIZER(
795 struct cmd_add_port_tm_node_shaper_profile_result,
797 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id =
798 TOKEN_NUM_INITIALIZER(
799 struct cmd_add_port_tm_node_shaper_profile_result,
801 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id =
802 TOKEN_NUM_INITIALIZER(
803 struct cmd_add_port_tm_node_shaper_profile_result,
805 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_tb_rate =
806 TOKEN_NUM_INITIALIZER(
807 struct cmd_add_port_tm_node_shaper_profile_result,
809 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_tb_size =
810 TOKEN_NUM_INITIALIZER(
811 struct cmd_add_port_tm_node_shaper_profile_result,
813 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust =
814 TOKEN_NUM_INITIALIZER(
815 struct cmd_add_port_tm_node_shaper_profile_result,
816 pktlen_adjust, UINT32);
818 static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
819 __attribute__((unused)) struct cmdline *cl,
820 __attribute__((unused)) void *data)
822 struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result;
823 struct rte_tm_shaper_params sp;
824 struct rte_tm_error error;
825 uint32_t shaper_id = res->shaper_id;
826 uint32_t pkt_len_adjust = res->pktlen_adjust;
827 portid_t port_id = res->port_id;
830 if (port_id_is_invalid(port_id, ENABLED_WARN))
833 /* Private shaper profile params */
834 memset(&sp, 0, sizeof(struct rte_tm_shaper_params));
835 sp.peak.rate = res->tb_rate;
836 sp.peak.size = res->tb_size;
837 sp.pkt_length_adjust = pkt_len_adjust;
839 ret = rte_tm_shaper_profile_add(port_id, shaper_id, &sp, &error);
841 print_err_msg(&error);
846 cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile = {
847 .f = cmd_add_port_tm_node_shaper_profile_parsed,
849 .help_str = "Add port tm node private shaper profile",
851 (void *)&cmd_add_port_tm_node_shaper_profile_add,
852 (void *)&cmd_add_port_tm_node_shaper_profile_port,
853 (void *)&cmd_add_port_tm_node_shaper_profile_tm,
854 (void *)&cmd_add_port_tm_node_shaper_profile_node,
855 (void *)&cmd_add_port_tm_node_shaper_profile_shaper,
856 (void *)&cmd_add_port_tm_node_shaper_profile_profile,
857 (void *)&cmd_add_port_tm_node_shaper_profile_port_id,
858 (void *)&cmd_add_port_tm_node_shaper_profile_shaper_id,
859 (void *)&cmd_add_port_tm_node_shaper_profile_tb_rate,
860 (void *)&cmd_add_port_tm_node_shaper_profile_tb_size,
861 (void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust,
866 /* *** Delete Port TM Private Shaper Profile *** */
867 struct cmd_del_port_tm_node_shaper_profile_result {
868 cmdline_fixed_string_t del;
869 cmdline_fixed_string_t port;
870 cmdline_fixed_string_t tm;
871 cmdline_fixed_string_t node;
872 cmdline_fixed_string_t shaper;
873 cmdline_fixed_string_t profile;
878 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del =
879 TOKEN_STRING_INITIALIZER(
880 struct cmd_del_port_tm_node_shaper_profile_result, del, "del");
881 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port =
882 TOKEN_STRING_INITIALIZER(
883 struct cmd_del_port_tm_node_shaper_profile_result,
885 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm =
886 TOKEN_STRING_INITIALIZER(
887 struct cmd_del_port_tm_node_shaper_profile_result, tm, "tm");
888 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node =
889 TOKEN_STRING_INITIALIZER(
890 struct cmd_del_port_tm_node_shaper_profile_result,
892 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper =
893 TOKEN_STRING_INITIALIZER(
894 struct cmd_del_port_tm_node_shaper_profile_result,
896 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile =
897 TOKEN_STRING_INITIALIZER(
898 struct cmd_del_port_tm_node_shaper_profile_result,
900 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id =
901 TOKEN_NUM_INITIALIZER(
902 struct cmd_del_port_tm_node_shaper_profile_result,
904 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id =
905 TOKEN_NUM_INITIALIZER(
906 struct cmd_del_port_tm_node_shaper_profile_result,
909 static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result,
910 __attribute__((unused)) struct cmdline *cl,
911 __attribute__((unused)) void *data)
913 struct cmd_del_port_tm_node_shaper_profile_result *res = parsed_result;
914 struct rte_tm_error error;
915 uint32_t shaper_id = res->shaper_id;
916 portid_t port_id = res->port_id;
919 if (port_id_is_invalid(port_id, ENABLED_WARN))
922 ret = rte_tm_shaper_profile_delete(port_id, shaper_id, &error);
924 print_err_msg(&error);
929 cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile = {
930 .f = cmd_del_port_tm_node_shaper_profile_parsed,
932 .help_str = "Delete port tm node private shaper profile",
934 (void *)&cmd_del_port_tm_node_shaper_profile_del,
935 (void *)&cmd_del_port_tm_node_shaper_profile_port,
936 (void *)&cmd_del_port_tm_node_shaper_profile_tm,
937 (void *)&cmd_del_port_tm_node_shaper_profile_node,
938 (void *)&cmd_del_port_tm_node_shaper_profile_shaper,
939 (void *)&cmd_del_port_tm_node_shaper_profile_profile,
940 (void *)&cmd_del_port_tm_node_shaper_profile_port_id,
941 (void *)&cmd_del_port_tm_node_shaper_profile_shaper_id,
946 /* *** Add/Update Port TM shared Shaper *** */
947 struct cmd_add_port_tm_node_shared_shaper_result {
948 cmdline_fixed_string_t cmd_type;
949 cmdline_fixed_string_t port;
950 cmdline_fixed_string_t tm;
951 cmdline_fixed_string_t node;
952 cmdline_fixed_string_t shared;
953 cmdline_fixed_string_t shaper;
955 uint32_t shared_shaper_id;
956 uint32_t shaper_profile_id;
959 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type =
960 TOKEN_STRING_INITIALIZER(
961 struct cmd_add_port_tm_node_shared_shaper_result,
962 cmd_type, "add#set");
963 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port =
964 TOKEN_STRING_INITIALIZER(
965 struct cmd_add_port_tm_node_shared_shaper_result, port, "port");
966 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm =
967 TOKEN_STRING_INITIALIZER(
968 struct cmd_add_port_tm_node_shared_shaper_result, tm, "tm");
969 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node =
970 TOKEN_STRING_INITIALIZER(
971 struct cmd_add_port_tm_node_shared_shaper_result, node, "node");
972 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared =
973 TOKEN_STRING_INITIALIZER(
974 struct cmd_add_port_tm_node_shared_shaper_result,
976 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper =
977 TOKEN_STRING_INITIALIZER(
978 struct cmd_add_port_tm_node_shared_shaper_result,
980 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id =
981 TOKEN_NUM_INITIALIZER(
982 struct cmd_add_port_tm_node_shared_shaper_result,
984 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id =
985 TOKEN_NUM_INITIALIZER(
986 struct cmd_add_port_tm_node_shared_shaper_result,
987 shared_shaper_id, UINT32);
988 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id =
989 TOKEN_NUM_INITIALIZER(
990 struct cmd_add_port_tm_node_shared_shaper_result,
991 shaper_profile_id, UINT32);
993 static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result,
994 __attribute__((unused)) struct cmdline *cl,
995 __attribute__((unused)) void *data)
997 struct cmd_add_port_tm_node_shared_shaper_result *res = parsed_result;
998 struct rte_tm_error error;
999 uint32_t shared_shaper_id = res->shared_shaper_id;
1000 uint32_t shaper_profile_id = res->shaper_profile_id;
1001 portid_t port_id = res->port_id;
1004 if (port_id_is_invalid(port_id, ENABLED_WARN))
1007 /* Command type: add */
1008 if ((strcmp(res->cmd_type, "add") == 0) &&
1009 (port_is_started(port_id))) {
1010 printf(" Port %u not stopped (error)\n", port_id);
1014 /* Command type: set (update) */
1015 if ((strcmp(res->cmd_type, "set") == 0) &&
1016 (!port_is_started(port_id))) {
1017 printf(" Port %u not started (error)\n", port_id);
1021 ret = rte_tm_shared_shaper_add_update(port_id, shared_shaper_id,
1022 shaper_profile_id, &error);
1024 print_err_msg(&error);
1029 cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper = {
1030 .f = cmd_add_port_tm_node_shared_shaper_parsed,
1032 .help_str = "add/update port tm node shared shaper",
1034 (void *)&cmd_add_port_tm_node_shared_shaper_cmd_type,
1035 (void *)&cmd_add_port_tm_node_shared_shaper_port,
1036 (void *)&cmd_add_port_tm_node_shared_shaper_tm,
1037 (void *)&cmd_add_port_tm_node_shared_shaper_node,
1038 (void *)&cmd_add_port_tm_node_shared_shaper_shared,
1039 (void *)&cmd_add_port_tm_node_shared_shaper_shaper,
1040 (void *)&cmd_add_port_tm_node_shared_shaper_port_id,
1041 (void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id,
1042 (void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id,
1047 /* *** Delete Port TM shared Shaper *** */
1048 struct cmd_del_port_tm_node_shared_shaper_result {
1049 cmdline_fixed_string_t del;
1050 cmdline_fixed_string_t port;
1051 cmdline_fixed_string_t tm;
1052 cmdline_fixed_string_t node;
1053 cmdline_fixed_string_t shared;
1054 cmdline_fixed_string_t shaper;
1056 uint32_t shared_shaper_id;
1059 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del =
1060 TOKEN_STRING_INITIALIZER(
1061 struct cmd_del_port_tm_node_shared_shaper_result, del, "del");
1062 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port =
1063 TOKEN_STRING_INITIALIZER(
1064 struct cmd_del_port_tm_node_shared_shaper_result, port, "port");
1065 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm =
1066 TOKEN_STRING_INITIALIZER(
1067 struct cmd_del_port_tm_node_shared_shaper_result, tm, "tm");
1068 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node =
1069 TOKEN_STRING_INITIALIZER(
1070 struct cmd_del_port_tm_node_shared_shaper_result, node, "node");
1071 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared =
1072 TOKEN_STRING_INITIALIZER(
1073 struct cmd_del_port_tm_node_shared_shaper_result,
1075 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper =
1076 TOKEN_STRING_INITIALIZER(
1077 struct cmd_del_port_tm_node_shared_shaper_result,
1079 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id =
1080 TOKEN_NUM_INITIALIZER(
1081 struct cmd_del_port_tm_node_shared_shaper_result,
1083 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id =
1084 TOKEN_NUM_INITIALIZER(
1085 struct cmd_del_port_tm_node_shared_shaper_result,
1086 shared_shaper_id, UINT32);
1088 static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result,
1089 __attribute__((unused)) struct cmdline *cl,
1090 __attribute__((unused)) void *data)
1092 struct cmd_del_port_tm_node_shared_shaper_result *res = parsed_result;
1093 struct rte_tm_error error;
1094 uint32_t shared_shaper_id = res->shared_shaper_id;
1095 portid_t port_id = res->port_id;
1098 if (port_id_is_invalid(port_id, ENABLED_WARN))
1101 ret = rte_tm_shared_shaper_delete(port_id, shared_shaper_id, &error);
1103 print_err_msg(&error);
1108 cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper = {
1109 .f = cmd_del_port_tm_node_shared_shaper_parsed,
1111 .help_str = "delete port tm node shared shaper",
1113 (void *)&cmd_del_port_tm_node_shared_shaper_del,
1114 (void *)&cmd_del_port_tm_node_shared_shaper_port,
1115 (void *)&cmd_del_port_tm_node_shared_shaper_tm,
1116 (void *)&cmd_del_port_tm_node_shared_shaper_node,
1117 (void *)&cmd_del_port_tm_node_shared_shaper_shared,
1118 (void *)&cmd_del_port_tm_node_shared_shaper_shaper,
1119 (void *)&cmd_del_port_tm_node_shared_shaper_port_id,
1120 (void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id,
1125 /* *** Add Port TM Node WRED Profile *** */
1126 struct cmd_add_port_tm_node_wred_profile_result {
1127 cmdline_fixed_string_t add;
1128 cmdline_fixed_string_t port;
1129 cmdline_fixed_string_t tm;
1130 cmdline_fixed_string_t node;
1131 cmdline_fixed_string_t wred;
1132 cmdline_fixed_string_t profile;
1134 uint32_t wred_profile_id;
1135 cmdline_fixed_string_t color_g;
1138 uint16_t maxp_inv_g;
1140 cmdline_fixed_string_t color_y;
1143 uint16_t maxp_inv_y;
1145 cmdline_fixed_string_t color_r;
1148 uint16_t maxp_inv_r;
1152 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add =
1153 TOKEN_STRING_INITIALIZER(
1154 struct cmd_add_port_tm_node_wred_profile_result, add, "add");
1155 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port =
1156 TOKEN_STRING_INITIALIZER(
1157 struct cmd_add_port_tm_node_wred_profile_result, port, "port");
1158 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm =
1159 TOKEN_STRING_INITIALIZER(
1160 struct cmd_add_port_tm_node_wred_profile_result, tm, "tm");
1161 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node =
1162 TOKEN_STRING_INITIALIZER(
1163 struct cmd_add_port_tm_node_wred_profile_result, node, "node");
1164 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred =
1165 TOKEN_STRING_INITIALIZER(
1166 struct cmd_add_port_tm_node_wred_profile_result, wred, "wred");
1167 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile =
1168 TOKEN_STRING_INITIALIZER(
1169 struct cmd_add_port_tm_node_wred_profile_result,
1170 profile, "profile");
1171 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id =
1172 TOKEN_NUM_INITIALIZER(
1173 struct cmd_add_port_tm_node_wred_profile_result,
1175 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id =
1176 TOKEN_NUM_INITIALIZER(
1177 struct cmd_add_port_tm_node_wred_profile_result,
1178 wred_profile_id, UINT32);
1179 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g =
1180 TOKEN_STRING_INITIALIZER(
1181 struct cmd_add_port_tm_node_wred_profile_result,
1183 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g =
1184 TOKEN_NUM_INITIALIZER(
1185 struct cmd_add_port_tm_node_wred_profile_result,
1187 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g =
1188 TOKEN_NUM_INITIALIZER(
1189 struct cmd_add_port_tm_node_wred_profile_result,
1191 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g =
1192 TOKEN_NUM_INITIALIZER(
1193 struct cmd_add_port_tm_node_wred_profile_result,
1194 maxp_inv_g, UINT16);
1195 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g =
1196 TOKEN_NUM_INITIALIZER(
1197 struct cmd_add_port_tm_node_wred_profile_result,
1199 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y =
1200 TOKEN_STRING_INITIALIZER(
1201 struct cmd_add_port_tm_node_wred_profile_result,
1203 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y =
1204 TOKEN_NUM_INITIALIZER(
1205 struct cmd_add_port_tm_node_wred_profile_result,
1207 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y =
1208 TOKEN_NUM_INITIALIZER(
1209 struct cmd_add_port_tm_node_wred_profile_result,
1211 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y =
1212 TOKEN_NUM_INITIALIZER(
1213 struct cmd_add_port_tm_node_wred_profile_result,
1214 maxp_inv_y, UINT16);
1215 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y =
1216 TOKEN_NUM_INITIALIZER(
1217 struct cmd_add_port_tm_node_wred_profile_result,
1219 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r =
1220 TOKEN_STRING_INITIALIZER(
1221 struct cmd_add_port_tm_node_wred_profile_result,
1223 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r =
1224 TOKEN_NUM_INITIALIZER(
1225 struct cmd_add_port_tm_node_wred_profile_result,
1227 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r =
1228 TOKEN_NUM_INITIALIZER(
1229 struct cmd_add_port_tm_node_wred_profile_result,
1231 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r =
1232 TOKEN_NUM_INITIALIZER(
1233 struct cmd_add_port_tm_node_wred_profile_result,
1234 maxp_inv_r, UINT16);
1235 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r =
1236 TOKEN_NUM_INITIALIZER(
1237 struct cmd_add_port_tm_node_wred_profile_result,
1241 static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
1242 __attribute__((unused)) struct cmdline *cl,
1243 __attribute__((unused)) void *data)
1245 struct cmd_add_port_tm_node_wred_profile_result *res = parsed_result;
1246 struct rte_tm_wred_params wp;
1247 enum rte_tm_color color;
1248 struct rte_tm_error error;
1249 uint32_t wred_profile_id = res->wred_profile_id;
1250 portid_t port_id = res->port_id;
1253 if (port_id_is_invalid(port_id, ENABLED_WARN))
1256 memset(&wp, 0, sizeof(struct rte_tm_wred_params));
1258 /* WRED Params (Green Color)*/
1259 color = RTE_TM_GREEN;
1260 wp.red_params[color].min_th = res->min_th_g;
1261 wp.red_params[color].max_th = res->max_th_g;
1262 wp.red_params[color].maxp_inv = res->maxp_inv_g;
1263 wp.red_params[color].wq_log2 = res->wq_log2_g;
1266 /* WRED Params (Yellow Color)*/
1267 color = RTE_TM_YELLOW;
1268 wp.red_params[color].min_th = res->min_th_y;
1269 wp.red_params[color].max_th = res->max_th_y;
1270 wp.red_params[color].maxp_inv = res->maxp_inv_y;
1271 wp.red_params[color].wq_log2 = res->wq_log2_y;
1273 /* WRED Params (Red Color)*/
1275 wp.red_params[color].min_th = res->min_th_r;
1276 wp.red_params[color].max_th = res->max_th_r;
1277 wp.red_params[color].maxp_inv = res->maxp_inv_r;
1278 wp.red_params[color].wq_log2 = res->wq_log2_r;
1280 ret = rte_tm_wred_profile_add(port_id, wred_profile_id, &wp, &error);
1282 print_err_msg(&error);
1287 cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile = {
1288 .f = cmd_add_port_tm_node_wred_profile_parsed,
1290 .help_str = "Add port tm node wred profile",
1292 (void *)&cmd_add_port_tm_node_wred_profile_add,
1293 (void *)&cmd_add_port_tm_node_wred_profile_port,
1294 (void *)&cmd_add_port_tm_node_wred_profile_tm,
1295 (void *)&cmd_add_port_tm_node_wred_profile_node,
1296 (void *)&cmd_add_port_tm_node_wred_profile_wred,
1297 (void *)&cmd_add_port_tm_node_wred_profile_profile,
1298 (void *)&cmd_add_port_tm_node_wred_profile_port_id,
1299 (void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id,
1300 (void *)&cmd_add_port_tm_node_wred_profile_color_g,
1301 (void *)&cmd_add_port_tm_node_wred_profile_min_th_g,
1302 (void *)&cmd_add_port_tm_node_wred_profile_max_th_g,
1303 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g,
1304 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g,
1305 (void *)&cmd_add_port_tm_node_wred_profile_color_y,
1306 (void *)&cmd_add_port_tm_node_wred_profile_min_th_y,
1307 (void *)&cmd_add_port_tm_node_wred_profile_max_th_y,
1308 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y,
1309 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y,
1310 (void *)&cmd_add_port_tm_node_wred_profile_color_r,
1311 (void *)&cmd_add_port_tm_node_wred_profile_min_th_r,
1312 (void *)&cmd_add_port_tm_node_wred_profile_max_th_r,
1313 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r,
1314 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r,
1319 /* *** Delete Port TM node WRED Profile *** */
1320 struct cmd_del_port_tm_node_wred_profile_result {
1321 cmdline_fixed_string_t del;
1322 cmdline_fixed_string_t port;
1323 cmdline_fixed_string_t tm;
1324 cmdline_fixed_string_t node;
1325 cmdline_fixed_string_t wred;
1326 cmdline_fixed_string_t profile;
1328 uint32_t wred_profile_id;
1331 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del =
1332 TOKEN_STRING_INITIALIZER(
1333 struct cmd_del_port_tm_node_wred_profile_result, del, "del");
1334 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port =
1335 TOKEN_STRING_INITIALIZER(
1336 struct cmd_del_port_tm_node_wred_profile_result, port, "port");
1337 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm =
1338 TOKEN_STRING_INITIALIZER(
1339 struct cmd_del_port_tm_node_wred_profile_result, tm, "tm");
1340 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node =
1341 TOKEN_STRING_INITIALIZER(
1342 struct cmd_del_port_tm_node_wred_profile_result, node, "node");
1343 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred =
1344 TOKEN_STRING_INITIALIZER(
1345 struct cmd_del_port_tm_node_wred_profile_result, wred, "wred");
1346 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile =
1347 TOKEN_STRING_INITIALIZER(
1348 struct cmd_del_port_tm_node_wred_profile_result,
1349 profile, "profile");
1350 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id =
1351 TOKEN_NUM_INITIALIZER(
1352 struct cmd_del_port_tm_node_wred_profile_result,
1354 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id =
1355 TOKEN_NUM_INITIALIZER(
1356 struct cmd_del_port_tm_node_wred_profile_result,
1357 wred_profile_id, UINT32);
1359 static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result,
1360 __attribute__((unused)) struct cmdline *cl,
1361 __attribute__((unused)) void *data)
1363 struct cmd_del_port_tm_node_wred_profile_result *res = parsed_result;
1364 struct rte_tm_error error;
1365 uint32_t wred_profile_id = res->wred_profile_id;
1366 portid_t port_id = res->port_id;
1369 if (port_id_is_invalid(port_id, ENABLED_WARN))
1372 ret = rte_tm_wred_profile_delete(port_id, wred_profile_id, &error);
1374 print_err_msg(&error);
1379 cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile = {
1380 .f = cmd_del_port_tm_node_wred_profile_parsed,
1382 .help_str = "Delete port tm node wred profile",
1384 (void *)&cmd_del_port_tm_node_wred_profile_del,
1385 (void *)&cmd_del_port_tm_node_wred_profile_port,
1386 (void *)&cmd_del_port_tm_node_wred_profile_tm,
1387 (void *)&cmd_del_port_tm_node_wred_profile_node,
1388 (void *)&cmd_del_port_tm_node_wred_profile_wred,
1389 (void *)&cmd_del_port_tm_node_wred_profile_profile,
1390 (void *)&cmd_del_port_tm_node_wred_profile_port_id,
1391 (void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id,
1396 /* *** Update Port TM Node Shaper profile *** */
1397 struct cmd_set_port_tm_node_shaper_profile_result {
1398 cmdline_fixed_string_t set;
1399 cmdline_fixed_string_t port;
1400 cmdline_fixed_string_t tm;
1401 cmdline_fixed_string_t node;
1402 cmdline_fixed_string_t shaper;
1403 cmdline_fixed_string_t profile;
1406 uint32_t shaper_profile_id;
1409 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set =
1410 TOKEN_STRING_INITIALIZER(
1411 struct cmd_set_port_tm_node_shaper_profile_result, set, "set");
1412 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port =
1413 TOKEN_STRING_INITIALIZER(
1414 struct cmd_set_port_tm_node_shaper_profile_result,
1416 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_tm =
1417 TOKEN_STRING_INITIALIZER(
1418 struct cmd_set_port_tm_node_shaper_profile_result, tm, "tm");
1419 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node =
1420 TOKEN_STRING_INITIALIZER(
1421 struct cmd_set_port_tm_node_shaper_profile_result,
1423 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper =
1424 TOKEN_STRING_INITIALIZER(
1425 struct cmd_set_port_tm_node_shaper_profile_result,
1427 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile =
1428 TOKEN_STRING_INITIALIZER(
1429 struct cmd_set_port_tm_node_shaper_profile_result,
1430 profile, "profile");
1431 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id =
1432 TOKEN_NUM_INITIALIZER(
1433 struct cmd_set_port_tm_node_shaper_profile_result,
1435 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id =
1436 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result,
1438 cmdline_parse_token_num_t
1439 cmd_set_port_tm_node_shaper_shaper_profile_profile_id =
1440 TOKEN_NUM_INITIALIZER(
1441 struct cmd_set_port_tm_node_shaper_profile_result,
1442 shaper_profile_id, UINT32);
1444 static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result,
1445 __attribute__((unused)) struct cmdline *cl,
1446 __attribute__((unused)) void *data)
1448 struct cmd_set_port_tm_node_shaper_profile_result *res = parsed_result;
1449 struct rte_tm_error error;
1450 uint32_t node_id = res->node_id;
1451 uint32_t shaper_profile_id = res->shaper_profile_id;
1452 portid_t port_id = res->port_id;
1455 if (port_id_is_invalid(port_id, ENABLED_WARN))
1459 if (!port_is_started(port_id)) {
1460 printf(" Port %u not started (error)\n", port_id);
1464 ret = rte_tm_node_shaper_update(port_id, node_id,
1465 shaper_profile_id, &error);
1467 print_err_msg(&error);
1472 cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile = {
1473 .f = cmd_set_port_tm_node_shaper_profile_parsed,
1475 .help_str = "Set port tm node shaper profile",
1477 (void *)&cmd_set_port_tm_node_shaper_profile_set,
1478 (void *)&cmd_set_port_tm_node_shaper_profile_port,
1479 (void *)&cmd_set_port_tm_node_shaper_profile_tm,
1480 (void *)&cmd_set_port_tm_node_shaper_profile_node,
1481 (void *)&cmd_set_port_tm_node_shaper_profile_shaper,
1482 (void *)&cmd_set_port_tm_node_shaper_profile_profile,
1483 (void *)&cmd_set_port_tm_node_shaper_profile_port_id,
1484 (void *)&cmd_set_port_tm_node_shaper_profile_node_id,
1485 (void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id,
1490 /* *** Add Port TM nonleaf node *** */
1491 struct cmd_add_port_tm_nonleaf_node_result {
1492 cmdline_fixed_string_t add;
1493 cmdline_fixed_string_t port;
1494 cmdline_fixed_string_t tm;
1495 cmdline_fixed_string_t nonleaf;
1496 cmdline_fixed_string_t node;
1499 int32_t parent_node_id;
1503 int32_t shaper_profile_id;
1504 uint32_t n_sp_priorities;
1505 uint64_t stats_mask;
1506 cmdline_multi_string_t multi_shared_shaper_id;
1509 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add =
1510 TOKEN_STRING_INITIALIZER(
1511 struct cmd_add_port_tm_nonleaf_node_result, add, "add");
1512 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port =
1513 TOKEN_STRING_INITIALIZER(
1514 struct cmd_add_port_tm_nonleaf_node_result, port, "port");
1515 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm =
1516 TOKEN_STRING_INITIALIZER(
1517 struct cmd_add_port_tm_nonleaf_node_result, tm, "tm");
1518 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf =
1519 TOKEN_STRING_INITIALIZER(
1520 struct cmd_add_port_tm_nonleaf_node_result, nonleaf, "nonleaf");
1521 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node =
1522 TOKEN_STRING_INITIALIZER(
1523 struct cmd_add_port_tm_nonleaf_node_result, node, "node");
1524 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id =
1525 TOKEN_NUM_INITIALIZER(
1526 struct cmd_add_port_tm_nonleaf_node_result,
1528 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_id =
1529 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1531 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_parent_node_id =
1532 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1533 parent_node_id, INT32);
1534 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority =
1535 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1537 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight =
1538 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1540 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =
1541 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1543 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id =
1544 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1545 shaper_profile_id, INT32);
1546 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =
1547 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1548 n_sp_priorities, UINT32);
1549 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask =
1550 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1551 stats_mask, UINT64);
1552 cmdline_parse_token_string_t
1553 cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id =
1554 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1555 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1557 static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
1558 __attribute__((unused)) struct cmdline *cl,
1559 __attribute__((unused)) void *data)
1561 struct cmd_add_port_tm_nonleaf_node_result *res = parsed_result;
1562 struct rte_tm_error error;
1563 struct rte_tm_node_params np;
1564 uint32_t *shared_shaper_id;
1565 uint32_t parent_node_id, n_shared_shapers = 0;
1566 char *s_str = res->multi_shared_shaper_id;
1567 portid_t port_id = res->port_id;
1570 if (port_id_is_invalid(port_id, ENABLED_WARN))
1573 memset(&np, 0, sizeof(struct rte_tm_node_params));
1575 /* Node parameters */
1576 if (res->parent_node_id < 0)
1577 parent_node_id = UINT32_MAX;
1579 parent_node_id = res->parent_node_id;
1581 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1583 if (shared_shaper_id == NULL) {
1584 printf(" Memory not allocated for shared shapers (error)\n");
1588 /* Parse multi shared shaper id string */
1589 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1591 printf(" Shared shapers params string parse error\n");
1592 free(shared_shaper_id);
1596 if (res->shaper_profile_id < 0)
1597 np.shaper_profile_id = UINT32_MAX;
1599 np.shaper_profile_id = res->shaper_profile_id;
1601 np.n_shared_shapers = n_shared_shapers;
1602 if (np.n_shared_shapers)
1603 np.shared_shaper_id = &shared_shaper_id[0];
1605 np.shared_shaper_id = NULL;
1607 np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1608 np.stats_mask = res->stats_mask;
1609 np.nonleaf.wfq_weight_mode = NULL;
1611 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1612 res->priority, res->weight, res->level_id,
1615 print_err_msg(&error);
1616 free(shared_shaper_id);
1621 cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node = {
1622 .f = cmd_add_port_tm_nonleaf_node_parsed,
1624 .help_str = "Add port tm nonleaf node",
1626 (void *)&cmd_add_port_tm_nonleaf_node_add,
1627 (void *)&cmd_add_port_tm_nonleaf_node_port,
1628 (void *)&cmd_add_port_tm_nonleaf_node_tm,
1629 (void *)&cmd_add_port_tm_nonleaf_node_nonleaf,
1630 (void *)&cmd_add_port_tm_nonleaf_node_node,
1631 (void *)&cmd_add_port_tm_nonleaf_node_port_id,
1632 (void *)&cmd_add_port_tm_nonleaf_node_node_id,
1633 (void *)&cmd_add_port_tm_nonleaf_node_parent_node_id,
1634 (void *)&cmd_add_port_tm_nonleaf_node_priority,
1635 (void *)&cmd_add_port_tm_nonleaf_node_weight,
1636 (void *)&cmd_add_port_tm_nonleaf_node_level_id,
1637 (void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id,
1638 (void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities,
1639 (void *)&cmd_add_port_tm_nonleaf_node_stats_mask,
1640 (void *)&cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id,
1645 /* *** Add Port TM leaf node *** */
1646 struct cmd_add_port_tm_leaf_node_result {
1647 cmdline_fixed_string_t add;
1648 cmdline_fixed_string_t port;
1649 cmdline_fixed_string_t tm;
1650 cmdline_fixed_string_t leaf;
1651 cmdline_fixed_string_t node;
1654 int32_t parent_node_id;
1658 int32_t shaper_profile_id;
1660 uint32_t wred_profile_id;
1661 uint64_t stats_mask;
1662 cmdline_multi_string_t multi_shared_shaper_id;
1665 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add =
1666 TOKEN_STRING_INITIALIZER(
1667 struct cmd_add_port_tm_leaf_node_result, add, "add");
1668 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port =
1669 TOKEN_STRING_INITIALIZER(
1670 struct cmd_add_port_tm_leaf_node_result, port, "port");
1671 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm =
1672 TOKEN_STRING_INITIALIZER(
1673 struct cmd_add_port_tm_leaf_node_result, tm, "tm");
1674 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf =
1675 TOKEN_STRING_INITIALIZER(
1676 struct cmd_add_port_tm_leaf_node_result, leaf, "leaf");
1677 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node =
1678 TOKEN_STRING_INITIALIZER(
1679 struct cmd_add_port_tm_leaf_node_result, node, "node");
1680 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_id =
1681 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1683 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_node_id =
1684 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1686 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id =
1687 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1688 parent_node_id, INT32);
1689 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority =
1690 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1692 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight =
1693 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1695 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =
1696 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1698 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =
1699 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1700 shaper_profile_id, INT32);
1701 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =
1702 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1704 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id =
1705 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1706 wred_profile_id, UINT32);
1707 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask =
1708 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1709 stats_mask, UINT64);
1710 cmdline_parse_token_string_t
1711 cmd_add_port_tm_leaf_node_multi_shared_shaper_id =
1712 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1713 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1715 static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
1716 __attribute__((unused)) struct cmdline *cl,
1717 __attribute__((unused)) void *data)
1719 struct cmd_add_port_tm_leaf_node_result *res = parsed_result;
1720 struct rte_tm_error error;
1721 struct rte_tm_node_params np;
1722 uint32_t *shared_shaper_id;
1723 uint32_t parent_node_id, n_shared_shapers = 0;
1724 portid_t port_id = res->port_id;
1725 char *s_str = res->multi_shared_shaper_id;
1728 if (port_id_is_invalid(port_id, ENABLED_WARN))
1731 memset(&np, 0, sizeof(struct rte_tm_node_params));
1733 /* Node parameters */
1734 if (res->parent_node_id < 0)
1735 parent_node_id = UINT32_MAX;
1737 parent_node_id = res->parent_node_id;
1739 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1741 if (shared_shaper_id == NULL) {
1742 printf(" Memory not allocated for shared shapers (error)\n");
1746 /* Parse multi shared shaper id string */
1747 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1749 printf(" Shared shapers params string parse error\n");
1750 free(shared_shaper_id);
1754 if (res->shaper_profile_id < 0)
1755 np.shaper_profile_id = UINT32_MAX;
1757 np.shaper_profile_id = res->shaper_profile_id;
1759 np.n_shared_shapers = n_shared_shapers;
1761 if (np.n_shared_shapers)
1762 np.shared_shaper_id = &shared_shaper_id[0];
1764 np.shared_shaper_id = NULL;
1766 np.leaf.cman = res->cman_mode;
1767 np.leaf.wred.wred_profile_id = res->wred_profile_id;
1768 np.stats_mask = res->stats_mask;
1770 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1771 res->priority, res->weight, res->level_id,
1774 print_err_msg(&error);
1775 free(shared_shaper_id);
1780 cmdline_parse_inst_t cmd_add_port_tm_leaf_node = {
1781 .f = cmd_add_port_tm_leaf_node_parsed,
1783 .help_str = "Add port tm leaf node",
1785 (void *)&cmd_add_port_tm_leaf_node_add,
1786 (void *)&cmd_add_port_tm_leaf_node_port,
1787 (void *)&cmd_add_port_tm_leaf_node_tm,
1788 (void *)&cmd_add_port_tm_leaf_node_nonleaf,
1789 (void *)&cmd_add_port_tm_leaf_node_node,
1790 (void *)&cmd_add_port_tm_leaf_node_port_id,
1791 (void *)&cmd_add_port_tm_leaf_node_node_id,
1792 (void *)&cmd_add_port_tm_leaf_node_parent_node_id,
1793 (void *)&cmd_add_port_tm_leaf_node_priority,
1794 (void *)&cmd_add_port_tm_leaf_node_weight,
1795 (void *)&cmd_add_port_tm_leaf_node_level_id,
1796 (void *)&cmd_add_port_tm_leaf_node_shaper_profile_id,
1797 (void *)&cmd_add_port_tm_leaf_node_cman_mode,
1798 (void *)&cmd_add_port_tm_leaf_node_wred_profile_id,
1799 (void *)&cmd_add_port_tm_leaf_node_stats_mask,
1800 (void *)&cmd_add_port_tm_leaf_node_multi_shared_shaper_id,
1805 /* *** Delete Port TM Node *** */
1806 struct cmd_del_port_tm_node_result {
1807 cmdline_fixed_string_t del;
1808 cmdline_fixed_string_t port;
1809 cmdline_fixed_string_t tm;
1810 cmdline_fixed_string_t node;
1815 cmdline_parse_token_string_t cmd_del_port_tm_node_del =
1816 TOKEN_STRING_INITIALIZER(
1817 struct cmd_del_port_tm_node_result, del, "del");
1818 cmdline_parse_token_string_t cmd_del_port_tm_node_port =
1819 TOKEN_STRING_INITIALIZER(
1820 struct cmd_del_port_tm_node_result, port, "port");
1821 cmdline_parse_token_string_t cmd_del_port_tm_node_tm =
1822 TOKEN_STRING_INITIALIZER(
1823 struct cmd_del_port_tm_node_result, tm, "tm");
1824 cmdline_parse_token_string_t cmd_del_port_tm_node_node =
1825 TOKEN_STRING_INITIALIZER(
1826 struct cmd_del_port_tm_node_result, node, "node");
1827 cmdline_parse_token_num_t cmd_del_port_tm_node_port_id =
1828 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
1830 cmdline_parse_token_num_t cmd_del_port_tm_node_node_id =
1831 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
1834 static void cmd_del_port_tm_node_parsed(void *parsed_result,
1835 __attribute__((unused)) struct cmdline *cl,
1836 __attribute__((unused)) void *data)
1838 struct cmd_del_port_tm_node_result *res = parsed_result;
1839 struct rte_tm_error error;
1840 uint32_t node_id = res->node_id;
1841 portid_t port_id = res->port_id;
1844 if (port_id_is_invalid(port_id, ENABLED_WARN))
1848 if (port_is_started(port_id)) {
1849 printf(" Port %u not stopped (error)\n", port_id);
1853 ret = rte_tm_node_delete(port_id, node_id, &error);
1855 print_err_msg(&error);
1860 cmdline_parse_inst_t cmd_del_port_tm_node = {
1861 .f = cmd_del_port_tm_node_parsed,
1863 .help_str = "Delete port tm node",
1865 (void *)&cmd_del_port_tm_node_del,
1866 (void *)&cmd_del_port_tm_node_port,
1867 (void *)&cmd_del_port_tm_node_tm,
1868 (void *)&cmd_del_port_tm_node_node,
1869 (void *)&cmd_del_port_tm_node_port_id,
1870 (void *)&cmd_del_port_tm_node_node_id,
1875 /* *** Update Port TM Node Parent *** */
1876 struct cmd_set_port_tm_node_parent_result {
1877 cmdline_fixed_string_t set;
1878 cmdline_fixed_string_t port;
1879 cmdline_fixed_string_t tm;
1880 cmdline_fixed_string_t node;
1881 cmdline_fixed_string_t parent;
1889 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set =
1890 TOKEN_STRING_INITIALIZER(
1891 struct cmd_set_port_tm_node_parent_result, set, "set");
1892 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port =
1893 TOKEN_STRING_INITIALIZER(
1894 struct cmd_set_port_tm_node_parent_result, port, "port");
1895 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm =
1896 TOKEN_STRING_INITIALIZER(
1897 struct cmd_set_port_tm_node_parent_result, tm, "tm");
1898 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node =
1899 TOKEN_STRING_INITIALIZER(
1900 struct cmd_set_port_tm_node_parent_result, node, "node");
1901 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent =
1902 TOKEN_STRING_INITIALIZER(
1903 struct cmd_set_port_tm_node_parent_result, parent, "parent");
1904 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id =
1905 TOKEN_NUM_INITIALIZER(
1906 struct cmd_set_port_tm_node_parent_result, port_id, UINT16);
1907 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id =
1908 TOKEN_NUM_INITIALIZER(
1909 struct cmd_set_port_tm_node_parent_result, node_id, UINT32);
1910 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id =
1911 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
1913 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority =
1914 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
1916 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight =
1917 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
1920 static void cmd_set_port_tm_node_parent_parsed(void *parsed_result,
1921 __attribute__((unused)) struct cmdline *cl,
1922 __attribute__((unused)) void *data)
1924 struct cmd_set_port_tm_node_parent_result *res = parsed_result;
1925 struct rte_tm_error error;
1926 uint32_t node_id = res->node_id;
1927 uint32_t parent_id = res->parent_id;
1928 uint32_t priority = res->priority;
1929 uint32_t weight = res->weight;
1930 portid_t port_id = res->port_id;
1933 if (port_id_is_invalid(port_id, ENABLED_WARN))
1937 if (!port_is_started(port_id)) {
1938 printf(" Port %u not started (error)\n", port_id);
1942 ret = rte_tm_node_parent_update(port_id, node_id,
1943 parent_id, priority, weight, &error);
1945 print_err_msg(&error);
1950 cmdline_parse_inst_t cmd_set_port_tm_node_parent = {
1951 .f = cmd_set_port_tm_node_parent_parsed,
1953 .help_str = "Set port tm node parent",
1955 (void *)&cmd_set_port_tm_node_parent_set,
1956 (void *)&cmd_set_port_tm_node_parent_port,
1957 (void *)&cmd_set_port_tm_node_parent_tm,
1958 (void *)&cmd_set_port_tm_node_parent_node,
1959 (void *)&cmd_set_port_tm_node_parent_parent,
1960 (void *)&cmd_set_port_tm_node_parent_port_id,
1961 (void *)&cmd_set_port_tm_node_parent_node_id,
1962 (void *)&cmd_set_port_tm_node_parent_parent_id,
1963 (void *)&cmd_set_port_tm_node_parent_priority,
1964 (void *)&cmd_set_port_tm_node_parent_weight,
1969 /* *** Port TM Hierarchy Commit *** */
1970 struct cmd_port_tm_hierarchy_commit_result {
1971 cmdline_fixed_string_t port;
1972 cmdline_fixed_string_t tm;
1973 cmdline_fixed_string_t hierarchy;
1974 cmdline_fixed_string_t commit;
1976 cmdline_fixed_string_t clean_on_fail;
1979 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port =
1980 TOKEN_STRING_INITIALIZER(
1981 struct cmd_port_tm_hierarchy_commit_result, port, "port");
1982 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm =
1983 TOKEN_STRING_INITIALIZER(
1984 struct cmd_port_tm_hierarchy_commit_result, tm, "tm");
1985 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy =
1986 TOKEN_STRING_INITIALIZER(
1987 struct cmd_port_tm_hierarchy_commit_result,
1988 hierarchy, "hierarchy");
1989 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit =
1990 TOKEN_STRING_INITIALIZER(
1991 struct cmd_port_tm_hierarchy_commit_result, commit, "commit");
1992 cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id =
1993 TOKEN_NUM_INITIALIZER(
1994 struct cmd_port_tm_hierarchy_commit_result,
1996 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_clean_on_fail =
1997 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result,
1998 clean_on_fail, "yes#no");
2000 static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result,
2001 __attribute__((unused)) struct cmdline *cl,
2002 __attribute__((unused)) void *data)
2004 struct cmd_port_tm_hierarchy_commit_result *res = parsed_result;
2005 struct rte_tm_error error;
2006 uint32_t clean_on_fail;
2007 portid_t port_id = res->port_id;
2010 if (port_id_is_invalid(port_id, ENABLED_WARN))
2013 if (strcmp(res->clean_on_fail, "yes") == 0)
2018 ret = rte_tm_hierarchy_commit(port_id, clean_on_fail, &error);
2020 print_err_msg(&error);
2025 cmdline_parse_inst_t cmd_port_tm_hierarchy_commit = {
2026 .f = cmd_port_tm_hierarchy_commit_parsed,
2028 .help_str = "Set port tm node shaper profile",
2030 (void *)&cmd_port_tm_hierarchy_commit_port,
2031 (void *)&cmd_port_tm_hierarchy_commit_tm,
2032 (void *)&cmd_port_tm_hierarchy_commit_hierarchy,
2033 (void *)&cmd_port_tm_hierarchy_commit_commit,
2034 (void *)&cmd_port_tm_hierarchy_commit_port_id,
2035 (void *)&cmd_port_tm_hierarchy_commit_clean_on_fail,