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 memset(&error
, 0, sizeof(struct rte_tm_error
));
238 ret
= rte_tm_capabilities_get(port_id
, &cap
, &error
);
240 print_err_msg(&error
);
244 printf("\n**** Port TM Capabilities ****\n\n");
245 printf("cap.n_nodes_max %" PRIu32
"\n", cap
.n_nodes_max
);
246 printf("cap.n_levels_max %" PRIu32
"\n", cap
.n_levels_max
);
247 printf("cap.non_leaf_nodes_identical %" PRId32
"\n",
248 cap
.non_leaf_nodes_identical
);
249 printf("cap.leaf_nodes_identical %" PRId32
"\n",
250 cap
.leaf_nodes_identical
);
251 printf("cap.shaper_n_max %u\n", cap
.shaper_n_max
);
252 printf("cap.shaper_private_n_max %" PRIu32
"\n",
253 cap
.shaper_private_n_max
);
254 printf("cap.shaper_private_dual_rate_n_max %" PRId32
"\n",
255 cap
.shaper_private_dual_rate_n_max
);
256 printf("cap.shaper_private_rate_min %" PRIu64
"\n",
257 cap
.shaper_private_rate_min
);
258 printf("cap.shaper_private_rate_max %" PRIu64
"\n",
259 cap
.shaper_private_rate_max
);
260 printf("cap.shaper_shared_n_max %" PRIu32
"\n",
261 cap
.shaper_shared_n_max
);
262 printf("cap.shaper_shared_n_nodes_per_shaper_max %" PRIu32
"\n",
263 cap
.shaper_shared_n_nodes_per_shaper_max
);
264 printf("cap.shaper_shared_n_shapers_per_node_max %" PRIu32
"\n",
265 cap
.shaper_shared_n_shapers_per_node_max
);
266 printf("cap.shaper_shared_dual_rate_n_max %" PRIu32
"\n",
267 cap
.shaper_shared_dual_rate_n_max
);
268 printf("cap.shaper_shared_rate_min %" PRIu64
"\n",
269 cap
.shaper_shared_rate_min
);
270 printf("cap.shaper_shared_rate_max %" PRIu64
"\n",
271 cap
.shaper_shared_rate_max
);
272 printf("cap.shaper_pkt_length_adjust_min %" PRId32
"\n",
273 cap
.shaper_pkt_length_adjust_min
);
274 printf("cap.shaper_pkt_length_adjust_max %" PRId32
"\n",
275 cap
.shaper_pkt_length_adjust_max
);
276 printf("cap.sched_n_children_max %" PRIu32
"\n",
277 cap
.sched_n_children_max
);
278 printf("cap.sched_sp_n_priorities_max %" PRIu32
"\n",
279 cap
.sched_sp_n_priorities_max
);
280 printf("cap.sched_wfq_n_children_per_group_max %" PRIu32
"\n",
281 cap
.sched_wfq_n_children_per_group_max
);
282 printf("cap.sched_wfq_n_groups_max %" PRIu32
"\n",
283 cap
.sched_wfq_n_groups_max
);
284 printf("cap.sched_wfq_weight_max %" PRIu32
"\n",
285 cap
.sched_wfq_weight_max
);
286 printf("cap.cman_head_drop_supported %" PRId32
"\n",
287 cap
.cman_head_drop_supported
);
288 printf("cap.cman_wred_context_n_max %" PRIu32
"\n",
289 cap
.cman_wred_context_n_max
);
290 printf("cap.cman_wred_context_private_n_max %" PRIu32
"\n",
291 cap
.cman_wred_context_private_n_max
);
292 printf("cap.cman_wred_context_shared_n_max %" PRIu32
"\n",
293 cap
.cman_wred_context_shared_n_max
);
294 printf("cap.cman_wred_context_shared_n_nodes_per_context_max %" PRIu32
295 "\n", cap
.cman_wred_context_shared_n_nodes_per_context_max
);
296 printf("cap.cman_wred_context_shared_n_contexts_per_node_max %" PRIu32
297 "\n", cap
.cman_wred_context_shared_n_contexts_per_node_max
);
299 for (i
= 0; i
< RTE_TM_COLORS
; i
++) {
300 printf("cap.mark_vlan_dei_supported %" PRId32
"\n",
301 cap
.mark_vlan_dei_supported
[i
]);
302 printf("cap.mark_ip_ecn_tcp_supported %" PRId32
"\n",
303 cap
.mark_ip_ecn_tcp_supported
[i
]);
304 printf("cap.mark_ip_ecn_sctp_supported %" PRId32
"\n",
305 cap
.mark_ip_ecn_sctp_supported
[i
]);
306 printf("cap.mark_ip_dscp_supported %" PRId32
"\n",
307 cap
.mark_ip_dscp_supported
[i
]);
310 printf("cap.dynamic_update_mask %" PRIx64
"\n",
311 cap
.dynamic_update_mask
);
312 printf("cap.stats_mask %" PRIx64
"\n", cap
.stats_mask
);
315 cmdline_parse_inst_t cmd_show_port_tm_cap
= {
316 .f
= cmd_show_port_tm_cap_parsed
,
318 .help_str
= "Show Port TM Capabilities",
320 (void *)&cmd_show_port_tm_cap_show
,
321 (void *)&cmd_show_port_tm_cap_port
,
322 (void *)&cmd_show_port_tm_cap_tm
,
323 (void *)&cmd_show_port_tm_cap_cap
,
324 (void *)&cmd_show_port_tm_cap_port_id
,
329 /* *** Port TM Hierarchical Level Capability *** */
330 struct cmd_show_port_tm_level_cap_result
{
331 cmdline_fixed_string_t show
;
332 cmdline_fixed_string_t port
;
333 cmdline_fixed_string_t tm
;
334 cmdline_fixed_string_t level
;
335 cmdline_fixed_string_t cap
;
340 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_show
=
341 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result
,
343 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_port
=
344 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result
,
346 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_tm
=
347 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result
,
349 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_level
=
350 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result
,
352 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_cap
=
353 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result
,
355 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_port_id
=
356 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result
,
358 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_level_id
=
359 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result
,
363 static void cmd_show_port_tm_level_cap_parsed(void *parsed_result
,
364 __attribute__((unused
)) struct cmdline
*cl
,
365 __attribute__((unused
)) void *data
)
367 struct cmd_show_port_tm_level_cap_result
*res
= parsed_result
;
368 struct rte_tm_level_capabilities lcap
;
369 struct rte_tm_error error
;
370 portid_t port_id
= res
->port_id
;
371 uint32_t level_id
= res
->level_id
;
374 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
377 memset(&lcap
, 0, sizeof(struct rte_tm_level_capabilities
));
378 memset(&error
, 0, sizeof(struct rte_tm_error
));
379 ret
= rte_tm_level_capabilities_get(port_id
, level_id
, &lcap
, &error
);
381 print_err_msg(&error
);
384 printf("\n** Port TM Hierarchy level %" PRIu32
" Capability **\n\n",
387 printf("cap.n_nodes_max %" PRIu32
"\n", lcap
.n_nodes_max
);
388 printf("cap.n_nodes_nonleaf_max %" PRIu32
"\n",
389 lcap
.n_nodes_nonleaf_max
);
390 printf("cap.n_nodes_leaf_max %" PRIu32
"\n", lcap
.n_nodes_leaf_max
);
391 printf("cap.non_leaf_nodes_identical %" PRId32
"\n",
392 lcap
.non_leaf_nodes_identical
);
393 printf("cap.leaf_nodes_identical %" PRId32
"\n",
394 lcap
.leaf_nodes_identical
);
396 printf("cap.nonleaf.shaper_private_supported %" PRId32
"\n",
397 lcap
.nonleaf
.shaper_private_supported
);
398 printf("cap.nonleaf.shaper_private_dual_rate_supported %" PRId32
399 "\n", lcap
.nonleaf
.shaper_private_dual_rate_supported
);
400 printf("cap.nonleaf.shaper_private_rate_min %" PRIu64
"\n",
401 lcap
.nonleaf
.shaper_private_rate_min
);
402 printf("cap.nonleaf.shaper_private_rate_max %" PRIu64
"\n",
403 lcap
.nonleaf
.shaper_private_rate_max
);
404 printf("cap.nonleaf.shaper_shared_n_max %" PRIu32
"\n",
405 lcap
.nonleaf
.shaper_shared_n_max
);
406 printf("cap.nonleaf.sched_n_children_max %" PRIu32
"\n",
407 lcap
.nonleaf
.sched_n_children_max
);
408 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32
"\n",
409 lcap
.nonleaf
.sched_sp_n_priorities_max
);
410 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
411 "\n", lcap
.nonleaf
.sched_wfq_n_children_per_group_max
);
412 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32
"\n",
413 lcap
.nonleaf
.sched_wfq_n_groups_max
);
414 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32
"\n",
415 lcap
.nonleaf
.sched_wfq_weight_max
);
416 printf("cap.nonleaf.stats_mask %" PRIx64
"\n",
417 lcap
.nonleaf
.stats_mask
);
419 printf("cap.leaf.shaper_private_supported %" PRId32
"\n",
420 lcap
.leaf
.shaper_private_supported
);
421 printf("cap.leaf.shaper_private_dual_rate_supported %" PRId32
422 "\n", lcap
.leaf
.shaper_private_dual_rate_supported
);
423 printf("cap.leaf.shaper_private_rate_min %" PRIu64
"\n",
424 lcap
.leaf
.shaper_private_rate_min
);
425 printf("cap.leaf.shaper_private_rate_max %" PRIu64
"\n",
426 lcap
.leaf
.shaper_private_rate_max
);
427 printf("cap.leaf.shaper_shared_n_max %" PRIu32
"\n",
428 lcap
.leaf
.shaper_shared_n_max
);
429 printf("cap.leaf.cman_head_drop_supported %" PRId32
"\n",
430 lcap
.leaf
.cman_head_drop_supported
);
431 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
432 "\n", lcap
.leaf
.cman_wred_context_private_supported
);
433 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32
"\n",
434 lcap
.leaf
.cman_wred_context_shared_n_max
);
435 printf("cap.leaf.stats_mask %" PRIx64
"\n",
436 lcap
.leaf
.stats_mask
);
440 cmdline_parse_inst_t cmd_show_port_tm_level_cap
= {
441 .f
= cmd_show_port_tm_level_cap_parsed
,
443 .help_str
= "Show Port TM Hierarhical level Capabilities",
445 (void *)&cmd_show_port_tm_level_cap_show
,
446 (void *)&cmd_show_port_tm_level_cap_port
,
447 (void *)&cmd_show_port_tm_level_cap_tm
,
448 (void *)&cmd_show_port_tm_level_cap_level
,
449 (void *)&cmd_show_port_tm_level_cap_cap
,
450 (void *)&cmd_show_port_tm_level_cap_port_id
,
451 (void *)&cmd_show_port_tm_level_cap_level_id
,
456 /* *** Port TM Hierarchy Node Capability *** */
457 struct cmd_show_port_tm_node_cap_result
{
458 cmdline_fixed_string_t show
;
459 cmdline_fixed_string_t port
;
460 cmdline_fixed_string_t tm
;
461 cmdline_fixed_string_t node
;
462 cmdline_fixed_string_t cap
;
467 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_show
=
468 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result
,
470 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_port
=
471 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result
,
473 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_tm
=
474 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result
,
476 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_node
=
477 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result
,
479 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_cap
=
480 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result
,
482 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_port_id
=
483 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result
,
485 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_node_id
=
486 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result
,
489 static void cmd_show_port_tm_node_cap_parsed(void *parsed_result
,
490 __attribute__((unused
)) struct cmdline
*cl
,
491 __attribute__((unused
)) void *data
)
493 struct cmd_show_port_tm_node_cap_result
*res
= parsed_result
;
494 struct rte_tm_node_capabilities ncap
;
495 struct rte_tm_error error
;
496 uint32_t node_id
= res
->node_id
;
497 portid_t port_id
= res
->port_id
;
498 int ret
, is_leaf
= 0;
500 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
503 memset(&error
, 0, sizeof(struct rte_tm_error
));
504 /* Node id must be valid */
505 ret
= rte_tm_node_type_get(port_id
, node_id
, &is_leaf
, &error
);
507 print_err_msg(&error
);
511 memset(&ncap
, 0, sizeof(struct rte_tm_node_capabilities
));
512 ret
= rte_tm_node_capabilities_get(port_id
, node_id
, &ncap
, &error
);
514 print_err_msg(&error
);
517 printf("\n** Port TM Hierarchy node %" PRIu32
" Capability **\n\n",
519 printf("cap.shaper_private_supported %" PRId32
"\n",
520 ncap
.shaper_private_supported
);
521 printf("cap.shaper_private_dual_rate_supported %" PRId32
"\n",
522 ncap
.shaper_private_dual_rate_supported
);
523 printf("cap.shaper_private_rate_min %" PRIu64
"\n",
524 ncap
.shaper_private_rate_min
);
525 printf("cap.shaper_private_rate_max %" PRIu64
"\n",
526 ncap
.shaper_private_rate_max
);
527 printf("cap.shaper_shared_n_max %" PRIu32
"\n",
528 ncap
.shaper_shared_n_max
);
530 printf("cap.nonleaf.sched_n_children_max %" PRIu32
"\n",
531 ncap
.nonleaf
.sched_n_children_max
);
532 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32
"\n",
533 ncap
.nonleaf
.sched_sp_n_priorities_max
);
534 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
535 "\n", ncap
.nonleaf
.sched_wfq_n_children_per_group_max
);
536 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32
"\n",
537 ncap
.nonleaf
.sched_wfq_n_groups_max
);
538 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32
"\n",
539 ncap
.nonleaf
.sched_wfq_weight_max
);
541 printf("cap.leaf.cman_head_drop_supported %" PRId32
"\n",
542 ncap
.leaf
.cman_head_drop_supported
);
543 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
544 "\n", ncap
.leaf
.cman_wred_context_private_supported
);
545 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32
"\n",
546 ncap
.leaf
.cman_wred_context_shared_n_max
);
548 printf("cap.stats_mask %" PRIx64
"\n", ncap
.stats_mask
);
551 cmdline_parse_inst_t cmd_show_port_tm_node_cap
= {
552 .f
= cmd_show_port_tm_node_cap_parsed
,
554 .help_str
= "Show Port TM Hierarchy node capabilities",
556 (void *)&cmd_show_port_tm_node_cap_show
,
557 (void *)&cmd_show_port_tm_node_cap_port
,
558 (void *)&cmd_show_port_tm_node_cap_tm
,
559 (void *)&cmd_show_port_tm_node_cap_node
,
560 (void *)&cmd_show_port_tm_node_cap_cap
,
561 (void *)&cmd_show_port_tm_node_cap_port_id
,
562 (void *)&cmd_show_port_tm_node_cap_node_id
,
567 /* *** Show Port TM Node Statistics *** */
568 struct cmd_show_port_tm_node_stats_result
{
569 cmdline_fixed_string_t show
;
570 cmdline_fixed_string_t port
;
571 cmdline_fixed_string_t tm
;
572 cmdline_fixed_string_t node
;
573 cmdline_fixed_string_t stats
;
579 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_show
=
580 TOKEN_STRING_INITIALIZER(
581 struct cmd_show_port_tm_node_stats_result
, show
, "show");
582 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_port
=
583 TOKEN_STRING_INITIALIZER(
584 struct cmd_show_port_tm_node_stats_result
, port
, "port");
585 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_tm
=
586 TOKEN_STRING_INITIALIZER(
587 struct cmd_show_port_tm_node_stats_result
, tm
, "tm");
588 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_node
=
589 TOKEN_STRING_INITIALIZER(
590 struct cmd_show_port_tm_node_stats_result
, node
, "node");
591 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_stats
=
592 TOKEN_STRING_INITIALIZER(
593 struct cmd_show_port_tm_node_stats_result
, stats
, "stats");
594 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_port_id
=
595 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_stats_result
,
597 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_node_id
=
598 TOKEN_NUM_INITIALIZER(
599 struct cmd_show_port_tm_node_stats_result
,
601 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_clear
=
602 TOKEN_NUM_INITIALIZER(
603 struct cmd_show_port_tm_node_stats_result
, clear
, UINT32
);
605 static void cmd_show_port_tm_node_stats_parsed(void *parsed_result
,
606 __attribute__((unused
)) struct cmdline
*cl
,
607 __attribute__((unused
)) void *data
)
609 struct cmd_show_port_tm_node_stats_result
*res
= parsed_result
;
610 struct rte_tm_node_stats stats
;
611 struct rte_tm_error error
;
612 uint64_t stats_mask
= 0;
613 uint32_t node_id
= res
->node_id
;
614 uint32_t clear
= res
->clear
;
615 portid_t port_id
= res
->port_id
;
618 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
621 memset(&error
, 0, sizeof(struct rte_tm_error
));
623 if (!port_is_started(port_id
)) {
624 printf(" Port %u not started (error)\n", port_id
);
628 memset(&stats
, 0, sizeof(struct rte_tm_node_stats
));
629 ret
= rte_tm_node_stats_read(port_id
, node_id
, &stats
,
630 &stats_mask
, clear
, &error
);
632 print_err_msg(&error
);
637 if (stats_mask
& RTE_TM_STATS_N_PKTS
)
638 printf("\tPkts scheduled from node: %" PRIu64
"\n",
640 if (stats_mask
& RTE_TM_STATS_N_BYTES
)
641 printf("\tBytes scheduled from node: %" PRIu64
"\n",
643 if (stats_mask
& RTE_TM_STATS_N_PKTS_GREEN_DROPPED
)
644 printf("\tPkts dropped (green): %" PRIu64
"\n",
645 stats
.leaf
.n_pkts_dropped
[RTE_TM_GREEN
]);
646 if (stats_mask
& RTE_TM_STATS_N_PKTS_YELLOW_DROPPED
)
647 printf("\tPkts dropped (yellow): %" PRIu64
"\n",
648 stats
.leaf
.n_pkts_dropped
[RTE_TM_YELLOW
]);
649 if (stats_mask
& RTE_TM_STATS_N_PKTS_RED_DROPPED
)
650 printf("\tPkts dropped (red): %" PRIu64
"\n",
651 stats
.leaf
.n_pkts_dropped
[RTE_TM_RED
]);
652 if (stats_mask
& RTE_TM_STATS_N_BYTES_GREEN_DROPPED
)
653 printf("\tBytes dropped (green): %" PRIu64
"\n",
654 stats
.leaf
.n_bytes_dropped
[RTE_TM_GREEN
]);
655 if (stats_mask
& RTE_TM_STATS_N_BYTES_YELLOW_DROPPED
)
656 printf("\tBytes dropped (yellow): %" PRIu64
"\n",
657 stats
.leaf
.n_bytes_dropped
[RTE_TM_YELLOW
]);
658 if (stats_mask
& RTE_TM_STATS_N_BYTES_RED_DROPPED
)
659 printf("\tBytes dropped (red): %" PRIu64
"\n",
660 stats
.leaf
.n_bytes_dropped
[RTE_TM_RED
]);
661 if (stats_mask
& RTE_TM_STATS_N_PKTS_QUEUED
)
662 printf("\tPkts queued: %" PRIu64
"\n",
663 stats
.leaf
.n_pkts_queued
);
664 if (stats_mask
& RTE_TM_STATS_N_BYTES_QUEUED
)
665 printf("\tBytes queued: %" PRIu64
"\n",
666 stats
.leaf
.n_bytes_queued
);
669 cmdline_parse_inst_t cmd_show_port_tm_node_stats
= {
670 .f
= cmd_show_port_tm_node_stats_parsed
,
672 .help_str
= "Show port tm node stats",
674 (void *)&cmd_show_port_tm_node_stats_show
,
675 (void *)&cmd_show_port_tm_node_stats_port
,
676 (void *)&cmd_show_port_tm_node_stats_tm
,
677 (void *)&cmd_show_port_tm_node_stats_node
,
678 (void *)&cmd_show_port_tm_node_stats_stats
,
679 (void *)&cmd_show_port_tm_node_stats_port_id
,
680 (void *)&cmd_show_port_tm_node_stats_node_id
,
681 (void *)&cmd_show_port_tm_node_stats_clear
,
686 /* *** Show Port TM Node Type *** */
687 struct cmd_show_port_tm_node_type_result
{
688 cmdline_fixed_string_t show
;
689 cmdline_fixed_string_t port
;
690 cmdline_fixed_string_t tm
;
691 cmdline_fixed_string_t node
;
692 cmdline_fixed_string_t type
;
697 cmdline_parse_token_string_t cmd_show_port_tm_node_type_show
=
698 TOKEN_STRING_INITIALIZER(
699 struct cmd_show_port_tm_node_type_result
, show
, "show");
700 cmdline_parse_token_string_t cmd_show_port_tm_node_type_port
=
701 TOKEN_STRING_INITIALIZER(
702 struct cmd_show_port_tm_node_type_result
, port
, "port");
703 cmdline_parse_token_string_t cmd_show_port_tm_node_type_tm
=
704 TOKEN_STRING_INITIALIZER(
705 struct cmd_show_port_tm_node_type_result
, tm
, "tm");
706 cmdline_parse_token_string_t cmd_show_port_tm_node_type_node
=
707 TOKEN_STRING_INITIALIZER(
708 struct cmd_show_port_tm_node_type_result
, node
, "node");
709 cmdline_parse_token_string_t cmd_show_port_tm_node_type_type
=
710 TOKEN_STRING_INITIALIZER(
711 struct cmd_show_port_tm_node_type_result
, type
, "type");
712 cmdline_parse_token_num_t cmd_show_port_tm_node_type_port_id
=
713 TOKEN_NUM_INITIALIZER(
714 struct cmd_show_port_tm_node_type_result
,
716 cmdline_parse_token_num_t cmd_show_port_tm_node_type_node_id
=
717 TOKEN_NUM_INITIALIZER(
718 struct cmd_show_port_tm_node_type_result
,
721 static void cmd_show_port_tm_node_type_parsed(void *parsed_result
,
722 __attribute__((unused
)) struct cmdline
*cl
,
723 __attribute__((unused
)) void *data
)
725 struct cmd_show_port_tm_node_type_result
*res
= parsed_result
;
726 struct rte_tm_error error
;
727 uint32_t node_id
= res
->node_id
;
728 portid_t port_id
= res
->port_id
;
729 int ret
, is_leaf
= 0;
731 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
734 memset(&error
, 0, sizeof(struct rte_tm_error
));
735 ret
= rte_tm_node_type_get(port_id
, node_id
, &is_leaf
, &error
);
737 print_err_msg(&error
);
742 printf("leaf node\n");
744 printf("nonleaf node\n");
748 cmdline_parse_inst_t cmd_show_port_tm_node_type
= {
749 .f
= cmd_show_port_tm_node_type_parsed
,
751 .help_str
= "Show port tm node type",
753 (void *)&cmd_show_port_tm_node_type_show
,
754 (void *)&cmd_show_port_tm_node_type_port
,
755 (void *)&cmd_show_port_tm_node_type_tm
,
756 (void *)&cmd_show_port_tm_node_type_node
,
757 (void *)&cmd_show_port_tm_node_type_type
,
758 (void *)&cmd_show_port_tm_node_type_port_id
,
759 (void *)&cmd_show_port_tm_node_type_node_id
,
764 /* *** Add Port TM Private Shaper Profile *** */
765 struct cmd_add_port_tm_node_shaper_profile_result
{
766 cmdline_fixed_string_t add
;
767 cmdline_fixed_string_t port
;
768 cmdline_fixed_string_t tm
;
769 cmdline_fixed_string_t node
;
770 cmdline_fixed_string_t shaper
;
771 cmdline_fixed_string_t profile
;
776 uint32_t pktlen_adjust
;
779 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add
=
780 TOKEN_STRING_INITIALIZER(
781 struct cmd_add_port_tm_node_shaper_profile_result
, add
, "add");
782 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port
=
783 TOKEN_STRING_INITIALIZER(
784 struct cmd_add_port_tm_node_shaper_profile_result
,
786 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm
=
787 TOKEN_STRING_INITIALIZER(
788 struct cmd_add_port_tm_node_shaper_profile_result
,
790 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node
=
791 TOKEN_STRING_INITIALIZER(
792 struct cmd_add_port_tm_node_shaper_profile_result
,
794 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper
=
795 TOKEN_STRING_INITIALIZER(
796 struct cmd_add_port_tm_node_shaper_profile_result
,
798 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile
=
799 TOKEN_STRING_INITIALIZER(
800 struct cmd_add_port_tm_node_shaper_profile_result
,
802 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id
=
803 TOKEN_NUM_INITIALIZER(
804 struct cmd_add_port_tm_node_shaper_profile_result
,
806 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id
=
807 TOKEN_NUM_INITIALIZER(
808 struct cmd_add_port_tm_node_shaper_profile_result
,
810 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_tb_rate
=
811 TOKEN_NUM_INITIALIZER(
812 struct cmd_add_port_tm_node_shaper_profile_result
,
814 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_tb_size
=
815 TOKEN_NUM_INITIALIZER(
816 struct cmd_add_port_tm_node_shaper_profile_result
,
818 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust
=
819 TOKEN_NUM_INITIALIZER(
820 struct cmd_add_port_tm_node_shaper_profile_result
,
821 pktlen_adjust
, UINT32
);
823 static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result
,
824 __attribute__((unused
)) struct cmdline
*cl
,
825 __attribute__((unused
)) void *data
)
827 struct cmd_add_port_tm_node_shaper_profile_result
*res
= parsed_result
;
828 struct rte_tm_shaper_params sp
;
829 struct rte_tm_error error
;
830 uint32_t shaper_id
= res
->shaper_id
;
831 uint32_t pkt_len_adjust
= res
->pktlen_adjust
;
832 portid_t port_id
= res
->port_id
;
835 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
838 /* Private shaper profile params */
839 memset(&sp
, 0, sizeof(struct rte_tm_shaper_params
));
840 memset(&error
, 0, sizeof(struct rte_tm_error
));
841 sp
.peak
.rate
= res
->tb_rate
;
842 sp
.peak
.size
= res
->tb_size
;
843 sp
.pkt_length_adjust
= pkt_len_adjust
;
845 ret
= rte_tm_shaper_profile_add(port_id
, shaper_id
, &sp
, &error
);
847 print_err_msg(&error
);
852 cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile
= {
853 .f
= cmd_add_port_tm_node_shaper_profile_parsed
,
855 .help_str
= "Add port tm node private shaper profile",
857 (void *)&cmd_add_port_tm_node_shaper_profile_add
,
858 (void *)&cmd_add_port_tm_node_shaper_profile_port
,
859 (void *)&cmd_add_port_tm_node_shaper_profile_tm
,
860 (void *)&cmd_add_port_tm_node_shaper_profile_node
,
861 (void *)&cmd_add_port_tm_node_shaper_profile_shaper
,
862 (void *)&cmd_add_port_tm_node_shaper_profile_profile
,
863 (void *)&cmd_add_port_tm_node_shaper_profile_port_id
,
864 (void *)&cmd_add_port_tm_node_shaper_profile_shaper_id
,
865 (void *)&cmd_add_port_tm_node_shaper_profile_tb_rate
,
866 (void *)&cmd_add_port_tm_node_shaper_profile_tb_size
,
867 (void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust
,
872 /* *** Delete Port TM Private Shaper Profile *** */
873 struct cmd_del_port_tm_node_shaper_profile_result
{
874 cmdline_fixed_string_t del
;
875 cmdline_fixed_string_t port
;
876 cmdline_fixed_string_t tm
;
877 cmdline_fixed_string_t node
;
878 cmdline_fixed_string_t shaper
;
879 cmdline_fixed_string_t profile
;
884 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del
=
885 TOKEN_STRING_INITIALIZER(
886 struct cmd_del_port_tm_node_shaper_profile_result
, del
, "del");
887 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port
=
888 TOKEN_STRING_INITIALIZER(
889 struct cmd_del_port_tm_node_shaper_profile_result
,
891 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm
=
892 TOKEN_STRING_INITIALIZER(
893 struct cmd_del_port_tm_node_shaper_profile_result
, tm
, "tm");
894 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node
=
895 TOKEN_STRING_INITIALIZER(
896 struct cmd_del_port_tm_node_shaper_profile_result
,
898 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper
=
899 TOKEN_STRING_INITIALIZER(
900 struct cmd_del_port_tm_node_shaper_profile_result
,
902 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile
=
903 TOKEN_STRING_INITIALIZER(
904 struct cmd_del_port_tm_node_shaper_profile_result
,
906 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id
=
907 TOKEN_NUM_INITIALIZER(
908 struct cmd_del_port_tm_node_shaper_profile_result
,
910 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id
=
911 TOKEN_NUM_INITIALIZER(
912 struct cmd_del_port_tm_node_shaper_profile_result
,
915 static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result
,
916 __attribute__((unused
)) struct cmdline
*cl
,
917 __attribute__((unused
)) void *data
)
919 struct cmd_del_port_tm_node_shaper_profile_result
*res
= parsed_result
;
920 struct rte_tm_error error
;
921 uint32_t shaper_id
= res
->shaper_id
;
922 portid_t port_id
= res
->port_id
;
925 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
928 memset(&error
, 0, sizeof(struct rte_tm_error
));
929 ret
= rte_tm_shaper_profile_delete(port_id
, shaper_id
, &error
);
931 print_err_msg(&error
);
936 cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile
= {
937 .f
= cmd_del_port_tm_node_shaper_profile_parsed
,
939 .help_str
= "Delete port tm node private shaper profile",
941 (void *)&cmd_del_port_tm_node_shaper_profile_del
,
942 (void *)&cmd_del_port_tm_node_shaper_profile_port
,
943 (void *)&cmd_del_port_tm_node_shaper_profile_tm
,
944 (void *)&cmd_del_port_tm_node_shaper_profile_node
,
945 (void *)&cmd_del_port_tm_node_shaper_profile_shaper
,
946 (void *)&cmd_del_port_tm_node_shaper_profile_profile
,
947 (void *)&cmd_del_port_tm_node_shaper_profile_port_id
,
948 (void *)&cmd_del_port_tm_node_shaper_profile_shaper_id
,
953 /* *** Add/Update Port TM shared Shaper *** */
954 struct cmd_add_port_tm_node_shared_shaper_result
{
955 cmdline_fixed_string_t cmd_type
;
956 cmdline_fixed_string_t port
;
957 cmdline_fixed_string_t tm
;
958 cmdline_fixed_string_t node
;
959 cmdline_fixed_string_t shared
;
960 cmdline_fixed_string_t shaper
;
962 uint32_t shared_shaper_id
;
963 uint32_t shaper_profile_id
;
966 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type
=
967 TOKEN_STRING_INITIALIZER(
968 struct cmd_add_port_tm_node_shared_shaper_result
,
969 cmd_type
, "add#set");
970 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port
=
971 TOKEN_STRING_INITIALIZER(
972 struct cmd_add_port_tm_node_shared_shaper_result
, port
, "port");
973 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm
=
974 TOKEN_STRING_INITIALIZER(
975 struct cmd_add_port_tm_node_shared_shaper_result
, tm
, "tm");
976 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node
=
977 TOKEN_STRING_INITIALIZER(
978 struct cmd_add_port_tm_node_shared_shaper_result
, node
, "node");
979 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared
=
980 TOKEN_STRING_INITIALIZER(
981 struct cmd_add_port_tm_node_shared_shaper_result
,
983 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper
=
984 TOKEN_STRING_INITIALIZER(
985 struct cmd_add_port_tm_node_shared_shaper_result
,
987 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id
=
988 TOKEN_NUM_INITIALIZER(
989 struct cmd_add_port_tm_node_shared_shaper_result
,
991 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id
=
992 TOKEN_NUM_INITIALIZER(
993 struct cmd_add_port_tm_node_shared_shaper_result
,
994 shared_shaper_id
, UINT32
);
995 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id
=
996 TOKEN_NUM_INITIALIZER(
997 struct cmd_add_port_tm_node_shared_shaper_result
,
998 shaper_profile_id
, UINT32
);
1000 static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result
,
1001 __attribute__((unused
)) struct cmdline
*cl
,
1002 __attribute__((unused
)) void *data
)
1004 struct cmd_add_port_tm_node_shared_shaper_result
*res
= parsed_result
;
1005 struct rte_tm_error error
;
1006 uint32_t shared_shaper_id
= res
->shared_shaper_id
;
1007 uint32_t shaper_profile_id
= res
->shaper_profile_id
;
1008 portid_t port_id
= res
->port_id
;
1011 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1014 memset(&error
, 0, sizeof(struct rte_tm_error
));
1015 /* Command type: add */
1016 if ((strcmp(res
->cmd_type
, "add") == 0) &&
1017 (port_is_started(port_id
))) {
1018 printf(" Port %u not stopped (error)\n", port_id
);
1022 /* Command type: set (update) */
1023 if ((strcmp(res
->cmd_type
, "set") == 0) &&
1024 (!port_is_started(port_id
))) {
1025 printf(" Port %u not started (error)\n", port_id
);
1029 ret
= rte_tm_shared_shaper_add_update(port_id
, shared_shaper_id
,
1030 shaper_profile_id
, &error
);
1032 print_err_msg(&error
);
1037 cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper
= {
1038 .f
= cmd_add_port_tm_node_shared_shaper_parsed
,
1040 .help_str
= "add/update port tm node shared shaper",
1042 (void *)&cmd_add_port_tm_node_shared_shaper_cmd_type
,
1043 (void *)&cmd_add_port_tm_node_shared_shaper_port
,
1044 (void *)&cmd_add_port_tm_node_shared_shaper_tm
,
1045 (void *)&cmd_add_port_tm_node_shared_shaper_node
,
1046 (void *)&cmd_add_port_tm_node_shared_shaper_shared
,
1047 (void *)&cmd_add_port_tm_node_shared_shaper_shaper
,
1048 (void *)&cmd_add_port_tm_node_shared_shaper_port_id
,
1049 (void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id
,
1050 (void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id
,
1055 /* *** Delete Port TM shared Shaper *** */
1056 struct cmd_del_port_tm_node_shared_shaper_result
{
1057 cmdline_fixed_string_t del
;
1058 cmdline_fixed_string_t port
;
1059 cmdline_fixed_string_t tm
;
1060 cmdline_fixed_string_t node
;
1061 cmdline_fixed_string_t shared
;
1062 cmdline_fixed_string_t shaper
;
1064 uint32_t shared_shaper_id
;
1067 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del
=
1068 TOKEN_STRING_INITIALIZER(
1069 struct cmd_del_port_tm_node_shared_shaper_result
, del
, "del");
1070 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port
=
1071 TOKEN_STRING_INITIALIZER(
1072 struct cmd_del_port_tm_node_shared_shaper_result
, port
, "port");
1073 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm
=
1074 TOKEN_STRING_INITIALIZER(
1075 struct cmd_del_port_tm_node_shared_shaper_result
, tm
, "tm");
1076 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node
=
1077 TOKEN_STRING_INITIALIZER(
1078 struct cmd_del_port_tm_node_shared_shaper_result
, node
, "node");
1079 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared
=
1080 TOKEN_STRING_INITIALIZER(
1081 struct cmd_del_port_tm_node_shared_shaper_result
,
1083 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper
=
1084 TOKEN_STRING_INITIALIZER(
1085 struct cmd_del_port_tm_node_shared_shaper_result
,
1087 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id
=
1088 TOKEN_NUM_INITIALIZER(
1089 struct cmd_del_port_tm_node_shared_shaper_result
,
1091 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id
=
1092 TOKEN_NUM_INITIALIZER(
1093 struct cmd_del_port_tm_node_shared_shaper_result
,
1094 shared_shaper_id
, UINT32
);
1096 static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result
,
1097 __attribute__((unused
)) struct cmdline
*cl
,
1098 __attribute__((unused
)) void *data
)
1100 struct cmd_del_port_tm_node_shared_shaper_result
*res
= parsed_result
;
1101 struct rte_tm_error error
;
1102 uint32_t shared_shaper_id
= res
->shared_shaper_id
;
1103 portid_t port_id
= res
->port_id
;
1106 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1109 memset(&error
, 0, sizeof(struct rte_tm_error
));
1110 ret
= rte_tm_shared_shaper_delete(port_id
, shared_shaper_id
, &error
);
1112 print_err_msg(&error
);
1117 cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper
= {
1118 .f
= cmd_del_port_tm_node_shared_shaper_parsed
,
1120 .help_str
= "delete port tm node shared shaper",
1122 (void *)&cmd_del_port_tm_node_shared_shaper_del
,
1123 (void *)&cmd_del_port_tm_node_shared_shaper_port
,
1124 (void *)&cmd_del_port_tm_node_shared_shaper_tm
,
1125 (void *)&cmd_del_port_tm_node_shared_shaper_node
,
1126 (void *)&cmd_del_port_tm_node_shared_shaper_shared
,
1127 (void *)&cmd_del_port_tm_node_shared_shaper_shaper
,
1128 (void *)&cmd_del_port_tm_node_shared_shaper_port_id
,
1129 (void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id
,
1134 /* *** Add Port TM Node WRED Profile *** */
1135 struct cmd_add_port_tm_node_wred_profile_result
{
1136 cmdline_fixed_string_t add
;
1137 cmdline_fixed_string_t port
;
1138 cmdline_fixed_string_t tm
;
1139 cmdline_fixed_string_t node
;
1140 cmdline_fixed_string_t wred
;
1141 cmdline_fixed_string_t profile
;
1143 uint32_t wred_profile_id
;
1144 cmdline_fixed_string_t color_g
;
1147 uint16_t maxp_inv_g
;
1149 cmdline_fixed_string_t color_y
;
1152 uint16_t maxp_inv_y
;
1154 cmdline_fixed_string_t color_r
;
1157 uint16_t maxp_inv_r
;
1161 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add
=
1162 TOKEN_STRING_INITIALIZER(
1163 struct cmd_add_port_tm_node_wred_profile_result
, add
, "add");
1164 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port
=
1165 TOKEN_STRING_INITIALIZER(
1166 struct cmd_add_port_tm_node_wred_profile_result
, port
, "port");
1167 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm
=
1168 TOKEN_STRING_INITIALIZER(
1169 struct cmd_add_port_tm_node_wred_profile_result
, tm
, "tm");
1170 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node
=
1171 TOKEN_STRING_INITIALIZER(
1172 struct cmd_add_port_tm_node_wred_profile_result
, node
, "node");
1173 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred
=
1174 TOKEN_STRING_INITIALIZER(
1175 struct cmd_add_port_tm_node_wred_profile_result
, wred
, "wred");
1176 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile
=
1177 TOKEN_STRING_INITIALIZER(
1178 struct cmd_add_port_tm_node_wred_profile_result
,
1179 profile
, "profile");
1180 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id
=
1181 TOKEN_NUM_INITIALIZER(
1182 struct cmd_add_port_tm_node_wred_profile_result
,
1184 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id
=
1185 TOKEN_NUM_INITIALIZER(
1186 struct cmd_add_port_tm_node_wred_profile_result
,
1187 wred_profile_id
, UINT32
);
1188 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g
=
1189 TOKEN_STRING_INITIALIZER(
1190 struct cmd_add_port_tm_node_wred_profile_result
,
1192 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g
=
1193 TOKEN_NUM_INITIALIZER(
1194 struct cmd_add_port_tm_node_wred_profile_result
,
1196 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g
=
1197 TOKEN_NUM_INITIALIZER(
1198 struct cmd_add_port_tm_node_wred_profile_result
,
1200 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g
=
1201 TOKEN_NUM_INITIALIZER(
1202 struct cmd_add_port_tm_node_wred_profile_result
,
1203 maxp_inv_g
, UINT16
);
1204 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g
=
1205 TOKEN_NUM_INITIALIZER(
1206 struct cmd_add_port_tm_node_wred_profile_result
,
1208 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y
=
1209 TOKEN_STRING_INITIALIZER(
1210 struct cmd_add_port_tm_node_wred_profile_result
,
1212 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y
=
1213 TOKEN_NUM_INITIALIZER(
1214 struct cmd_add_port_tm_node_wred_profile_result
,
1216 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y
=
1217 TOKEN_NUM_INITIALIZER(
1218 struct cmd_add_port_tm_node_wred_profile_result
,
1220 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y
=
1221 TOKEN_NUM_INITIALIZER(
1222 struct cmd_add_port_tm_node_wred_profile_result
,
1223 maxp_inv_y
, UINT16
);
1224 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y
=
1225 TOKEN_NUM_INITIALIZER(
1226 struct cmd_add_port_tm_node_wred_profile_result
,
1228 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r
=
1229 TOKEN_STRING_INITIALIZER(
1230 struct cmd_add_port_tm_node_wred_profile_result
,
1232 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r
=
1233 TOKEN_NUM_INITIALIZER(
1234 struct cmd_add_port_tm_node_wred_profile_result
,
1236 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r
=
1237 TOKEN_NUM_INITIALIZER(
1238 struct cmd_add_port_tm_node_wred_profile_result
,
1240 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r
=
1241 TOKEN_NUM_INITIALIZER(
1242 struct cmd_add_port_tm_node_wred_profile_result
,
1243 maxp_inv_r
, UINT16
);
1244 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r
=
1245 TOKEN_NUM_INITIALIZER(
1246 struct cmd_add_port_tm_node_wred_profile_result
,
1250 static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result
,
1251 __attribute__((unused
)) struct cmdline
*cl
,
1252 __attribute__((unused
)) void *data
)
1254 struct cmd_add_port_tm_node_wred_profile_result
*res
= parsed_result
;
1255 struct rte_tm_wred_params wp
;
1256 enum rte_tm_color color
;
1257 struct rte_tm_error error
;
1258 uint32_t wred_profile_id
= res
->wred_profile_id
;
1259 portid_t port_id
= res
->port_id
;
1262 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1265 memset(&wp
, 0, sizeof(struct rte_tm_wred_params
));
1266 memset(&error
, 0, sizeof(struct rte_tm_error
));
1268 /* WRED Params (Green Color)*/
1269 color
= RTE_TM_GREEN
;
1270 wp
.red_params
[color
].min_th
= res
->min_th_g
;
1271 wp
.red_params
[color
].max_th
= res
->max_th_g
;
1272 wp
.red_params
[color
].maxp_inv
= res
->maxp_inv_g
;
1273 wp
.red_params
[color
].wq_log2
= res
->wq_log2_g
;
1276 /* WRED Params (Yellow Color)*/
1277 color
= RTE_TM_YELLOW
;
1278 wp
.red_params
[color
].min_th
= res
->min_th_y
;
1279 wp
.red_params
[color
].max_th
= res
->max_th_y
;
1280 wp
.red_params
[color
].maxp_inv
= res
->maxp_inv_y
;
1281 wp
.red_params
[color
].wq_log2
= res
->wq_log2_y
;
1283 /* WRED Params (Red Color)*/
1285 wp
.red_params
[color
].min_th
= res
->min_th_r
;
1286 wp
.red_params
[color
].max_th
= res
->max_th_r
;
1287 wp
.red_params
[color
].maxp_inv
= res
->maxp_inv_r
;
1288 wp
.red_params
[color
].wq_log2
= res
->wq_log2_r
;
1290 ret
= rte_tm_wred_profile_add(port_id
, wred_profile_id
, &wp
, &error
);
1292 print_err_msg(&error
);
1297 cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile
= {
1298 .f
= cmd_add_port_tm_node_wred_profile_parsed
,
1300 .help_str
= "Add port tm node wred profile",
1302 (void *)&cmd_add_port_tm_node_wred_profile_add
,
1303 (void *)&cmd_add_port_tm_node_wred_profile_port
,
1304 (void *)&cmd_add_port_tm_node_wred_profile_tm
,
1305 (void *)&cmd_add_port_tm_node_wred_profile_node
,
1306 (void *)&cmd_add_port_tm_node_wred_profile_wred
,
1307 (void *)&cmd_add_port_tm_node_wred_profile_profile
,
1308 (void *)&cmd_add_port_tm_node_wred_profile_port_id
,
1309 (void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id
,
1310 (void *)&cmd_add_port_tm_node_wred_profile_color_g
,
1311 (void *)&cmd_add_port_tm_node_wred_profile_min_th_g
,
1312 (void *)&cmd_add_port_tm_node_wred_profile_max_th_g
,
1313 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g
,
1314 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g
,
1315 (void *)&cmd_add_port_tm_node_wred_profile_color_y
,
1316 (void *)&cmd_add_port_tm_node_wred_profile_min_th_y
,
1317 (void *)&cmd_add_port_tm_node_wred_profile_max_th_y
,
1318 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y
,
1319 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y
,
1320 (void *)&cmd_add_port_tm_node_wred_profile_color_r
,
1321 (void *)&cmd_add_port_tm_node_wred_profile_min_th_r
,
1322 (void *)&cmd_add_port_tm_node_wred_profile_max_th_r
,
1323 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r
,
1324 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r
,
1329 /* *** Delete Port TM node WRED Profile *** */
1330 struct cmd_del_port_tm_node_wred_profile_result
{
1331 cmdline_fixed_string_t del
;
1332 cmdline_fixed_string_t port
;
1333 cmdline_fixed_string_t tm
;
1334 cmdline_fixed_string_t node
;
1335 cmdline_fixed_string_t wred
;
1336 cmdline_fixed_string_t profile
;
1338 uint32_t wred_profile_id
;
1341 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del
=
1342 TOKEN_STRING_INITIALIZER(
1343 struct cmd_del_port_tm_node_wred_profile_result
, del
, "del");
1344 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port
=
1345 TOKEN_STRING_INITIALIZER(
1346 struct cmd_del_port_tm_node_wred_profile_result
, port
, "port");
1347 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm
=
1348 TOKEN_STRING_INITIALIZER(
1349 struct cmd_del_port_tm_node_wred_profile_result
, tm
, "tm");
1350 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node
=
1351 TOKEN_STRING_INITIALIZER(
1352 struct cmd_del_port_tm_node_wred_profile_result
, node
, "node");
1353 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred
=
1354 TOKEN_STRING_INITIALIZER(
1355 struct cmd_del_port_tm_node_wred_profile_result
, wred
, "wred");
1356 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile
=
1357 TOKEN_STRING_INITIALIZER(
1358 struct cmd_del_port_tm_node_wred_profile_result
,
1359 profile
, "profile");
1360 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id
=
1361 TOKEN_NUM_INITIALIZER(
1362 struct cmd_del_port_tm_node_wred_profile_result
,
1364 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id
=
1365 TOKEN_NUM_INITIALIZER(
1366 struct cmd_del_port_tm_node_wred_profile_result
,
1367 wred_profile_id
, UINT32
);
1369 static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result
,
1370 __attribute__((unused
)) struct cmdline
*cl
,
1371 __attribute__((unused
)) void *data
)
1373 struct cmd_del_port_tm_node_wred_profile_result
*res
= parsed_result
;
1374 struct rte_tm_error error
;
1375 uint32_t wred_profile_id
= res
->wred_profile_id
;
1376 portid_t port_id
= res
->port_id
;
1379 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1382 memset(&error
, 0, sizeof(struct rte_tm_error
));
1383 ret
= rte_tm_wred_profile_delete(port_id
, wred_profile_id
, &error
);
1385 print_err_msg(&error
);
1390 cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile
= {
1391 .f
= cmd_del_port_tm_node_wred_profile_parsed
,
1393 .help_str
= "Delete port tm node wred profile",
1395 (void *)&cmd_del_port_tm_node_wred_profile_del
,
1396 (void *)&cmd_del_port_tm_node_wred_profile_port
,
1397 (void *)&cmd_del_port_tm_node_wred_profile_tm
,
1398 (void *)&cmd_del_port_tm_node_wred_profile_node
,
1399 (void *)&cmd_del_port_tm_node_wred_profile_wred
,
1400 (void *)&cmd_del_port_tm_node_wred_profile_profile
,
1401 (void *)&cmd_del_port_tm_node_wred_profile_port_id
,
1402 (void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id
,
1407 /* *** Update Port TM Node Shaper profile *** */
1408 struct cmd_set_port_tm_node_shaper_profile_result
{
1409 cmdline_fixed_string_t set
;
1410 cmdline_fixed_string_t port
;
1411 cmdline_fixed_string_t tm
;
1412 cmdline_fixed_string_t node
;
1413 cmdline_fixed_string_t shaper
;
1414 cmdline_fixed_string_t profile
;
1417 uint32_t shaper_profile_id
;
1420 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set
=
1421 TOKEN_STRING_INITIALIZER(
1422 struct cmd_set_port_tm_node_shaper_profile_result
, set
, "set");
1423 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port
=
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_tm
=
1428 TOKEN_STRING_INITIALIZER(
1429 struct cmd_set_port_tm_node_shaper_profile_result
, tm
, "tm");
1430 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node
=
1431 TOKEN_STRING_INITIALIZER(
1432 struct cmd_set_port_tm_node_shaper_profile_result
,
1434 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper
=
1435 TOKEN_STRING_INITIALIZER(
1436 struct cmd_set_port_tm_node_shaper_profile_result
,
1438 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile
=
1439 TOKEN_STRING_INITIALIZER(
1440 struct cmd_set_port_tm_node_shaper_profile_result
,
1441 profile
, "profile");
1442 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id
=
1443 TOKEN_NUM_INITIALIZER(
1444 struct cmd_set_port_tm_node_shaper_profile_result
,
1446 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id
=
1447 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result
,
1449 cmdline_parse_token_num_t
1450 cmd_set_port_tm_node_shaper_shaper_profile_profile_id
=
1451 TOKEN_NUM_INITIALIZER(
1452 struct cmd_set_port_tm_node_shaper_profile_result
,
1453 shaper_profile_id
, UINT32
);
1455 static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result
,
1456 __attribute__((unused
)) struct cmdline
*cl
,
1457 __attribute__((unused
)) void *data
)
1459 struct cmd_set_port_tm_node_shaper_profile_result
*res
= parsed_result
;
1460 struct rte_tm_error error
;
1461 uint32_t node_id
= res
->node_id
;
1462 uint32_t shaper_profile_id
= res
->shaper_profile_id
;
1463 portid_t port_id
= res
->port_id
;
1466 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1469 memset(&error
, 0, sizeof(struct rte_tm_error
));
1471 if (!port_is_started(port_id
)) {
1472 printf(" Port %u not started (error)\n", port_id
);
1476 ret
= rte_tm_node_shaper_update(port_id
, node_id
,
1477 shaper_profile_id
, &error
);
1479 print_err_msg(&error
);
1484 cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile
= {
1485 .f
= cmd_set_port_tm_node_shaper_profile_parsed
,
1487 .help_str
= "Set port tm node shaper profile",
1489 (void *)&cmd_set_port_tm_node_shaper_profile_set
,
1490 (void *)&cmd_set_port_tm_node_shaper_profile_port
,
1491 (void *)&cmd_set_port_tm_node_shaper_profile_tm
,
1492 (void *)&cmd_set_port_tm_node_shaper_profile_node
,
1493 (void *)&cmd_set_port_tm_node_shaper_profile_shaper
,
1494 (void *)&cmd_set_port_tm_node_shaper_profile_profile
,
1495 (void *)&cmd_set_port_tm_node_shaper_profile_port_id
,
1496 (void *)&cmd_set_port_tm_node_shaper_profile_node_id
,
1497 (void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id
,
1502 /* *** Add Port TM nonleaf node *** */
1503 struct cmd_add_port_tm_nonleaf_node_result
{
1504 cmdline_fixed_string_t add
;
1505 cmdline_fixed_string_t port
;
1506 cmdline_fixed_string_t tm
;
1507 cmdline_fixed_string_t nonleaf
;
1508 cmdline_fixed_string_t node
;
1511 int32_t parent_node_id
;
1515 int32_t shaper_profile_id
;
1516 uint32_t n_sp_priorities
;
1517 uint64_t stats_mask
;
1518 cmdline_multi_string_t multi_shared_shaper_id
;
1521 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add
=
1522 TOKEN_STRING_INITIALIZER(
1523 struct cmd_add_port_tm_nonleaf_node_result
, add
, "add");
1524 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port
=
1525 TOKEN_STRING_INITIALIZER(
1526 struct cmd_add_port_tm_nonleaf_node_result
, port
, "port");
1527 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm
=
1528 TOKEN_STRING_INITIALIZER(
1529 struct cmd_add_port_tm_nonleaf_node_result
, tm
, "tm");
1530 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf
=
1531 TOKEN_STRING_INITIALIZER(
1532 struct cmd_add_port_tm_nonleaf_node_result
, nonleaf
, "nonleaf");
1533 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node
=
1534 TOKEN_STRING_INITIALIZER(
1535 struct cmd_add_port_tm_nonleaf_node_result
, node
, "node");
1536 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id
=
1537 TOKEN_NUM_INITIALIZER(
1538 struct cmd_add_port_tm_nonleaf_node_result
,
1540 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_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_parent_node_id
=
1544 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1545 parent_node_id
, INT32
);
1546 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority
=
1547 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1549 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight
=
1550 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1552 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id
=
1553 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1555 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id
=
1556 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1557 shaper_profile_id
, INT32
);
1558 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities
=
1559 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1560 n_sp_priorities
, UINT32
);
1561 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask
=
1562 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1563 stats_mask
, UINT64
);
1564 cmdline_parse_token_string_t
1565 cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id
=
1566 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1567 multi_shared_shaper_id
, TOKEN_STRING_MULTI
);
1569 static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result
,
1570 __attribute__((unused
)) struct cmdline
*cl
,
1571 __attribute__((unused
)) void *data
)
1573 struct cmd_add_port_tm_nonleaf_node_result
*res
= parsed_result
;
1574 struct rte_tm_error error
;
1575 struct rte_tm_node_params np
;
1576 uint32_t *shared_shaper_id
;
1577 uint32_t parent_node_id
, n_shared_shapers
= 0;
1578 char *s_str
= res
->multi_shared_shaper_id
;
1579 portid_t port_id
= res
->port_id
;
1582 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1585 memset(&np
, 0, sizeof(struct rte_tm_node_params
));
1586 memset(&error
, 0, sizeof(struct rte_tm_error
));
1588 /* Node parameters */
1589 if (res
->parent_node_id
< 0)
1590 parent_node_id
= UINT32_MAX
;
1592 parent_node_id
= res
->parent_node_id
;
1594 shared_shaper_id
= (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS
*
1596 if (shared_shaper_id
== NULL
) {
1597 printf(" Memory not allocated for shared shapers (error)\n");
1601 /* Parse multi shared shaper id string */
1602 ret
= parse_multi_ss_id_str(s_str
, &n_shared_shapers
, shared_shaper_id
);
1604 printf(" Shared shapers params string parse error\n");
1605 free(shared_shaper_id
);
1609 if (res
->shaper_profile_id
< 0)
1610 np
.shaper_profile_id
= UINT32_MAX
;
1612 np
.shaper_profile_id
= res
->shaper_profile_id
;
1614 np
.n_shared_shapers
= n_shared_shapers
;
1615 if (np
.n_shared_shapers
) {
1616 np
.shared_shaper_id
= &shared_shaper_id
[0];
1618 free(shared_shaper_id
);
1619 shared_shaper_id
= NULL
;
1622 np
.nonleaf
.n_sp_priorities
= res
->n_sp_priorities
;
1623 np
.stats_mask
= res
->stats_mask
;
1624 np
.nonleaf
.wfq_weight_mode
= NULL
;
1626 ret
= rte_tm_node_add(port_id
, res
->node_id
, parent_node_id
,
1627 res
->priority
, res
->weight
, res
->level_id
,
1630 print_err_msg(&error
);
1631 free(shared_shaper_id
);
1636 cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node
= {
1637 .f
= cmd_add_port_tm_nonleaf_node_parsed
,
1639 .help_str
= "Add port tm nonleaf node",
1641 (void *)&cmd_add_port_tm_nonleaf_node_add
,
1642 (void *)&cmd_add_port_tm_nonleaf_node_port
,
1643 (void *)&cmd_add_port_tm_nonleaf_node_tm
,
1644 (void *)&cmd_add_port_tm_nonleaf_node_nonleaf
,
1645 (void *)&cmd_add_port_tm_nonleaf_node_node
,
1646 (void *)&cmd_add_port_tm_nonleaf_node_port_id
,
1647 (void *)&cmd_add_port_tm_nonleaf_node_node_id
,
1648 (void *)&cmd_add_port_tm_nonleaf_node_parent_node_id
,
1649 (void *)&cmd_add_port_tm_nonleaf_node_priority
,
1650 (void *)&cmd_add_port_tm_nonleaf_node_weight
,
1651 (void *)&cmd_add_port_tm_nonleaf_node_level_id
,
1652 (void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id
,
1653 (void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities
,
1654 (void *)&cmd_add_port_tm_nonleaf_node_stats_mask
,
1655 (void *)&cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id
,
1660 /* *** Add Port TM leaf node *** */
1661 struct cmd_add_port_tm_leaf_node_result
{
1662 cmdline_fixed_string_t add
;
1663 cmdline_fixed_string_t port
;
1664 cmdline_fixed_string_t tm
;
1665 cmdline_fixed_string_t leaf
;
1666 cmdline_fixed_string_t node
;
1669 int32_t parent_node_id
;
1673 int32_t shaper_profile_id
;
1675 uint32_t wred_profile_id
;
1676 uint64_t stats_mask
;
1677 cmdline_multi_string_t multi_shared_shaper_id
;
1680 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add
=
1681 TOKEN_STRING_INITIALIZER(
1682 struct cmd_add_port_tm_leaf_node_result
, add
, "add");
1683 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port
=
1684 TOKEN_STRING_INITIALIZER(
1685 struct cmd_add_port_tm_leaf_node_result
, port
, "port");
1686 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm
=
1687 TOKEN_STRING_INITIALIZER(
1688 struct cmd_add_port_tm_leaf_node_result
, tm
, "tm");
1689 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf
=
1690 TOKEN_STRING_INITIALIZER(
1691 struct cmd_add_port_tm_leaf_node_result
, leaf
, "leaf");
1692 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node
=
1693 TOKEN_STRING_INITIALIZER(
1694 struct cmd_add_port_tm_leaf_node_result
, node
, "node");
1695 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_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_node_id
=
1699 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1701 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id
=
1702 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1703 parent_node_id
, INT32
);
1704 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority
=
1705 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1707 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight
=
1708 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1710 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id
=
1711 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1713 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id
=
1714 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1715 shaper_profile_id
, INT32
);
1716 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode
=
1717 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1719 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id
=
1720 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1721 wred_profile_id
, UINT32
);
1722 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask
=
1723 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1724 stats_mask
, UINT64
);
1725 cmdline_parse_token_string_t
1726 cmd_add_port_tm_leaf_node_multi_shared_shaper_id
=
1727 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1728 multi_shared_shaper_id
, TOKEN_STRING_MULTI
);
1730 static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result
,
1731 __attribute__((unused
)) struct cmdline
*cl
,
1732 __attribute__((unused
)) void *data
)
1734 struct cmd_add_port_tm_leaf_node_result
*res
= parsed_result
;
1735 struct rte_tm_error error
;
1736 struct rte_tm_node_params np
;
1737 uint32_t *shared_shaper_id
;
1738 uint32_t parent_node_id
, n_shared_shapers
= 0;
1739 portid_t port_id
= res
->port_id
;
1740 char *s_str
= res
->multi_shared_shaper_id
;
1743 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1746 memset(&np
, 0, sizeof(struct rte_tm_node_params
));
1747 memset(&error
, 0, sizeof(struct rte_tm_error
));
1749 /* Node parameters */
1750 if (res
->parent_node_id
< 0)
1751 parent_node_id
= UINT32_MAX
;
1753 parent_node_id
= res
->parent_node_id
;
1755 shared_shaper_id
= (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS
*
1757 if (shared_shaper_id
== NULL
) {
1758 printf(" Memory not allocated for shared shapers (error)\n");
1762 /* Parse multi shared shaper id string */
1763 ret
= parse_multi_ss_id_str(s_str
, &n_shared_shapers
, shared_shaper_id
);
1765 printf(" Shared shapers params string parse error\n");
1766 free(shared_shaper_id
);
1770 if (res
->shaper_profile_id
< 0)
1771 np
.shaper_profile_id
= UINT32_MAX
;
1773 np
.shaper_profile_id
= res
->shaper_profile_id
;
1775 np
.n_shared_shapers
= n_shared_shapers
;
1777 if (np
.n_shared_shapers
) {
1778 np
.shared_shaper_id
= &shared_shaper_id
[0];
1780 free(shared_shaper_id
);
1781 shared_shaper_id
= NULL
;
1784 np
.leaf
.cman
= res
->cman_mode
;
1785 np
.leaf
.wred
.wred_profile_id
= res
->wred_profile_id
;
1786 np
.stats_mask
= res
->stats_mask
;
1788 ret
= rte_tm_node_add(port_id
, res
->node_id
, parent_node_id
,
1789 res
->priority
, res
->weight
, res
->level_id
,
1792 print_err_msg(&error
);
1793 free(shared_shaper_id
);
1798 cmdline_parse_inst_t cmd_add_port_tm_leaf_node
= {
1799 .f
= cmd_add_port_tm_leaf_node_parsed
,
1801 .help_str
= "Add port tm leaf node",
1803 (void *)&cmd_add_port_tm_leaf_node_add
,
1804 (void *)&cmd_add_port_tm_leaf_node_port
,
1805 (void *)&cmd_add_port_tm_leaf_node_tm
,
1806 (void *)&cmd_add_port_tm_leaf_node_nonleaf
,
1807 (void *)&cmd_add_port_tm_leaf_node_node
,
1808 (void *)&cmd_add_port_tm_leaf_node_port_id
,
1809 (void *)&cmd_add_port_tm_leaf_node_node_id
,
1810 (void *)&cmd_add_port_tm_leaf_node_parent_node_id
,
1811 (void *)&cmd_add_port_tm_leaf_node_priority
,
1812 (void *)&cmd_add_port_tm_leaf_node_weight
,
1813 (void *)&cmd_add_port_tm_leaf_node_level_id
,
1814 (void *)&cmd_add_port_tm_leaf_node_shaper_profile_id
,
1815 (void *)&cmd_add_port_tm_leaf_node_cman_mode
,
1816 (void *)&cmd_add_port_tm_leaf_node_wred_profile_id
,
1817 (void *)&cmd_add_port_tm_leaf_node_stats_mask
,
1818 (void *)&cmd_add_port_tm_leaf_node_multi_shared_shaper_id
,
1823 /* *** Delete Port TM Node *** */
1824 struct cmd_del_port_tm_node_result
{
1825 cmdline_fixed_string_t del
;
1826 cmdline_fixed_string_t port
;
1827 cmdline_fixed_string_t tm
;
1828 cmdline_fixed_string_t node
;
1833 cmdline_parse_token_string_t cmd_del_port_tm_node_del
=
1834 TOKEN_STRING_INITIALIZER(
1835 struct cmd_del_port_tm_node_result
, del
, "del");
1836 cmdline_parse_token_string_t cmd_del_port_tm_node_port
=
1837 TOKEN_STRING_INITIALIZER(
1838 struct cmd_del_port_tm_node_result
, port
, "port");
1839 cmdline_parse_token_string_t cmd_del_port_tm_node_tm
=
1840 TOKEN_STRING_INITIALIZER(
1841 struct cmd_del_port_tm_node_result
, tm
, "tm");
1842 cmdline_parse_token_string_t cmd_del_port_tm_node_node
=
1843 TOKEN_STRING_INITIALIZER(
1844 struct cmd_del_port_tm_node_result
, node
, "node");
1845 cmdline_parse_token_num_t cmd_del_port_tm_node_port_id
=
1846 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result
,
1848 cmdline_parse_token_num_t cmd_del_port_tm_node_node_id
=
1849 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result
,
1852 static void cmd_del_port_tm_node_parsed(void *parsed_result
,
1853 __attribute__((unused
)) struct cmdline
*cl
,
1854 __attribute__((unused
)) void *data
)
1856 struct cmd_del_port_tm_node_result
*res
= parsed_result
;
1857 struct rte_tm_error error
;
1858 uint32_t node_id
= res
->node_id
;
1859 portid_t port_id
= res
->port_id
;
1862 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1865 memset(&error
, 0, sizeof(struct rte_tm_error
));
1867 if (port_is_started(port_id
)) {
1868 printf(" Port %u not stopped (error)\n", port_id
);
1872 ret
= rte_tm_node_delete(port_id
, node_id
, &error
);
1874 print_err_msg(&error
);
1879 cmdline_parse_inst_t cmd_del_port_tm_node
= {
1880 .f
= cmd_del_port_tm_node_parsed
,
1882 .help_str
= "Delete port tm node",
1884 (void *)&cmd_del_port_tm_node_del
,
1885 (void *)&cmd_del_port_tm_node_port
,
1886 (void *)&cmd_del_port_tm_node_tm
,
1887 (void *)&cmd_del_port_tm_node_node
,
1888 (void *)&cmd_del_port_tm_node_port_id
,
1889 (void *)&cmd_del_port_tm_node_node_id
,
1894 /* *** Update Port TM Node Parent *** */
1895 struct cmd_set_port_tm_node_parent_result
{
1896 cmdline_fixed_string_t set
;
1897 cmdline_fixed_string_t port
;
1898 cmdline_fixed_string_t tm
;
1899 cmdline_fixed_string_t node
;
1900 cmdline_fixed_string_t parent
;
1908 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set
=
1909 TOKEN_STRING_INITIALIZER(
1910 struct cmd_set_port_tm_node_parent_result
, set
, "set");
1911 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port
=
1912 TOKEN_STRING_INITIALIZER(
1913 struct cmd_set_port_tm_node_parent_result
, port
, "port");
1914 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm
=
1915 TOKEN_STRING_INITIALIZER(
1916 struct cmd_set_port_tm_node_parent_result
, tm
, "tm");
1917 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node
=
1918 TOKEN_STRING_INITIALIZER(
1919 struct cmd_set_port_tm_node_parent_result
, node
, "node");
1920 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent
=
1921 TOKEN_STRING_INITIALIZER(
1922 struct cmd_set_port_tm_node_parent_result
, parent
, "parent");
1923 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id
=
1924 TOKEN_NUM_INITIALIZER(
1925 struct cmd_set_port_tm_node_parent_result
, port_id
, UINT16
);
1926 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id
=
1927 TOKEN_NUM_INITIALIZER(
1928 struct cmd_set_port_tm_node_parent_result
, node_id
, UINT32
);
1929 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id
=
1930 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result
,
1932 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority
=
1933 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result
,
1935 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight
=
1936 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result
,
1939 static void cmd_set_port_tm_node_parent_parsed(void *parsed_result
,
1940 __attribute__((unused
)) struct cmdline
*cl
,
1941 __attribute__((unused
)) void *data
)
1943 struct cmd_set_port_tm_node_parent_result
*res
= parsed_result
;
1944 struct rte_tm_error error
;
1945 uint32_t node_id
= res
->node_id
;
1946 uint32_t parent_id
= res
->parent_id
;
1947 uint32_t priority
= res
->priority
;
1948 uint32_t weight
= res
->weight
;
1949 portid_t port_id
= res
->port_id
;
1952 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1955 memset(&error
, 0, sizeof(struct rte_tm_error
));
1957 if (!port_is_started(port_id
)) {
1958 printf(" Port %u not started (error)\n", port_id
);
1962 ret
= rte_tm_node_parent_update(port_id
, node_id
,
1963 parent_id
, priority
, weight
, &error
);
1965 print_err_msg(&error
);
1970 cmdline_parse_inst_t cmd_set_port_tm_node_parent
= {
1971 .f
= cmd_set_port_tm_node_parent_parsed
,
1973 .help_str
= "Set port tm node parent",
1975 (void *)&cmd_set_port_tm_node_parent_set
,
1976 (void *)&cmd_set_port_tm_node_parent_port
,
1977 (void *)&cmd_set_port_tm_node_parent_tm
,
1978 (void *)&cmd_set_port_tm_node_parent_node
,
1979 (void *)&cmd_set_port_tm_node_parent_parent
,
1980 (void *)&cmd_set_port_tm_node_parent_port_id
,
1981 (void *)&cmd_set_port_tm_node_parent_node_id
,
1982 (void *)&cmd_set_port_tm_node_parent_parent_id
,
1983 (void *)&cmd_set_port_tm_node_parent_priority
,
1984 (void *)&cmd_set_port_tm_node_parent_weight
,
1989 /* *** Suspend Port TM Node *** */
1990 struct cmd_suspend_port_tm_node_result
{
1991 cmdline_fixed_string_t suspend
;
1992 cmdline_fixed_string_t port
;
1993 cmdline_fixed_string_t tm
;
1994 cmdline_fixed_string_t node
;
1999 cmdline_parse_token_string_t cmd_suspend_port_tm_node_suspend
=
2000 TOKEN_STRING_INITIALIZER(
2001 struct cmd_suspend_port_tm_node_result
, suspend
, "suspend");
2002 cmdline_parse_token_string_t cmd_suspend_port_tm_node_port
=
2003 TOKEN_STRING_INITIALIZER(
2004 struct cmd_suspend_port_tm_node_result
, port
, "port");
2005 cmdline_parse_token_string_t cmd_suspend_port_tm_node_tm
=
2006 TOKEN_STRING_INITIALIZER(
2007 struct cmd_suspend_port_tm_node_result
, tm
, "tm");
2008 cmdline_parse_token_string_t cmd_suspend_port_tm_node_node
=
2009 TOKEN_STRING_INITIALIZER(
2010 struct cmd_suspend_port_tm_node_result
, node
, "node");
2011 cmdline_parse_token_num_t cmd_suspend_port_tm_node_port_id
=
2012 TOKEN_NUM_INITIALIZER(
2013 struct cmd_suspend_port_tm_node_result
, port_id
, UINT16
);
2014 cmdline_parse_token_num_t cmd_suspend_port_tm_node_node_id
=
2015 TOKEN_NUM_INITIALIZER(
2016 struct cmd_suspend_port_tm_node_result
, node_id
, UINT32
);
2018 static void cmd_suspend_port_tm_node_parsed(void *parsed_result
,
2019 __attribute__((unused
)) struct cmdline
*cl
,
2020 __attribute__((unused
)) void *data
)
2022 struct cmd_suspend_port_tm_node_result
*res
= parsed_result
;
2023 struct rte_tm_error error
;
2024 uint32_t node_id
= res
->node_id
;
2025 portid_t port_id
= res
->port_id
;
2028 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
2031 memset(&error
, 0, sizeof(struct rte_tm_error
));
2032 ret
= rte_tm_node_suspend(port_id
, node_id
, &error
);
2034 print_err_msg(&error
);
2039 cmdline_parse_inst_t cmd_suspend_port_tm_node
= {
2040 .f
= cmd_suspend_port_tm_node_parsed
,
2042 .help_str
= "Suspend port tm node",
2044 (void *)&cmd_suspend_port_tm_node_suspend
,
2045 (void *)&cmd_suspend_port_tm_node_port
,
2046 (void *)&cmd_suspend_port_tm_node_tm
,
2047 (void *)&cmd_suspend_port_tm_node_node
,
2048 (void *)&cmd_suspend_port_tm_node_port_id
,
2049 (void *)&cmd_suspend_port_tm_node_node_id
,
2054 /* *** Resume Port TM Node *** */
2055 struct cmd_resume_port_tm_node_result
{
2056 cmdline_fixed_string_t resume
;
2057 cmdline_fixed_string_t port
;
2058 cmdline_fixed_string_t tm
;
2059 cmdline_fixed_string_t node
;
2064 cmdline_parse_token_string_t cmd_resume_port_tm_node_resume
=
2065 TOKEN_STRING_INITIALIZER(
2066 struct cmd_resume_port_tm_node_result
, resume
, "resume");
2067 cmdline_parse_token_string_t cmd_resume_port_tm_node_port
=
2068 TOKEN_STRING_INITIALIZER(
2069 struct cmd_resume_port_tm_node_result
, port
, "port");
2070 cmdline_parse_token_string_t cmd_resume_port_tm_node_tm
=
2071 TOKEN_STRING_INITIALIZER(
2072 struct cmd_resume_port_tm_node_result
, tm
, "tm");
2073 cmdline_parse_token_string_t cmd_resume_port_tm_node_node
=
2074 TOKEN_STRING_INITIALIZER(
2075 struct cmd_resume_port_tm_node_result
, node
, "node");
2076 cmdline_parse_token_num_t cmd_resume_port_tm_node_port_id
=
2077 TOKEN_NUM_INITIALIZER(
2078 struct cmd_resume_port_tm_node_result
, port_id
, UINT16
);
2079 cmdline_parse_token_num_t cmd_resume_port_tm_node_node_id
=
2080 TOKEN_NUM_INITIALIZER(
2081 struct cmd_resume_port_tm_node_result
, node_id
, UINT32
);
2083 static void cmd_resume_port_tm_node_parsed(void *parsed_result
,
2084 __attribute__((unused
)) struct cmdline
*cl
,
2085 __attribute__((unused
)) void *data
)
2087 struct cmd_resume_port_tm_node_result
*res
= parsed_result
;
2088 struct rte_tm_error error
;
2089 uint32_t node_id
= res
->node_id
;
2090 portid_t port_id
= res
->port_id
;
2093 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
2096 memset(&error
, 0, sizeof(struct rte_tm_error
));
2097 ret
= rte_tm_node_resume(port_id
, node_id
, &error
);
2099 print_err_msg(&error
);
2104 cmdline_parse_inst_t cmd_resume_port_tm_node
= {
2105 .f
= cmd_resume_port_tm_node_parsed
,
2107 .help_str
= "Resume port tm node",
2109 (void *)&cmd_resume_port_tm_node_resume
,
2110 (void *)&cmd_resume_port_tm_node_port
,
2111 (void *)&cmd_resume_port_tm_node_tm
,
2112 (void *)&cmd_resume_port_tm_node_node
,
2113 (void *)&cmd_resume_port_tm_node_port_id
,
2114 (void *)&cmd_resume_port_tm_node_node_id
,
2119 /* *** Port TM Hierarchy Commit *** */
2120 struct cmd_port_tm_hierarchy_commit_result
{
2121 cmdline_fixed_string_t port
;
2122 cmdline_fixed_string_t tm
;
2123 cmdline_fixed_string_t hierarchy
;
2124 cmdline_fixed_string_t commit
;
2126 cmdline_fixed_string_t clean_on_fail
;
2129 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port
=
2130 TOKEN_STRING_INITIALIZER(
2131 struct cmd_port_tm_hierarchy_commit_result
, port
, "port");
2132 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm
=
2133 TOKEN_STRING_INITIALIZER(
2134 struct cmd_port_tm_hierarchy_commit_result
, tm
, "tm");
2135 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy
=
2136 TOKEN_STRING_INITIALIZER(
2137 struct cmd_port_tm_hierarchy_commit_result
,
2138 hierarchy
, "hierarchy");
2139 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit
=
2140 TOKEN_STRING_INITIALIZER(
2141 struct cmd_port_tm_hierarchy_commit_result
, commit
, "commit");
2142 cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id
=
2143 TOKEN_NUM_INITIALIZER(
2144 struct cmd_port_tm_hierarchy_commit_result
,
2146 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_clean_on_fail
=
2147 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result
,
2148 clean_on_fail
, "yes#no");
2150 static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result
,
2151 __attribute__((unused
)) struct cmdline
*cl
,
2152 __attribute__((unused
)) void *data
)
2154 struct cmd_port_tm_hierarchy_commit_result
*res
= parsed_result
;
2155 struct rte_tm_error error
;
2156 uint32_t clean_on_fail
;
2157 portid_t port_id
= res
->port_id
;
2160 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
2163 if (strcmp(res
->clean_on_fail
, "yes") == 0)
2168 memset(&error
, 0, sizeof(struct rte_tm_error
));
2169 ret
= rte_tm_hierarchy_commit(port_id
, clean_on_fail
, &error
);
2171 print_err_msg(&error
);
2176 cmdline_parse_inst_t cmd_port_tm_hierarchy_commit
= {
2177 .f
= cmd_port_tm_hierarchy_commit_parsed
,
2179 .help_str
= "Commit port tm hierarchy",
2181 (void *)&cmd_port_tm_hierarchy_commit_port
,
2182 (void *)&cmd_port_tm_hierarchy_commit_tm
,
2183 (void *)&cmd_port_tm_hierarchy_commit_hierarchy
,
2184 (void *)&cmd_port_tm_hierarchy_commit_commit
,
2185 (void *)&cmd_port_tm_hierarchy_commit_port_id
,
2186 (void *)&cmd_port_tm_hierarchy_commit_clean_on_fail
,