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_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_COLOR_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_COLOR_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_COLOR_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_COLOR_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_COLOR_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_COLOR_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
;
774 uint64_t cmit_tb_rate
;
775 uint64_t cmit_tb_size
;
776 uint64_t peak_tb_rate
;
777 uint64_t peak_tb_size
;
778 uint32_t pktlen_adjust
;
781 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add
=
782 TOKEN_STRING_INITIALIZER(
783 struct cmd_add_port_tm_node_shaper_profile_result
, add
, "add");
784 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port
=
785 TOKEN_STRING_INITIALIZER(
786 struct cmd_add_port_tm_node_shaper_profile_result
,
788 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm
=
789 TOKEN_STRING_INITIALIZER(
790 struct cmd_add_port_tm_node_shaper_profile_result
,
792 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node
=
793 TOKEN_STRING_INITIALIZER(
794 struct cmd_add_port_tm_node_shaper_profile_result
,
796 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper
=
797 TOKEN_STRING_INITIALIZER(
798 struct cmd_add_port_tm_node_shaper_profile_result
,
800 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile
=
801 TOKEN_STRING_INITIALIZER(
802 struct cmd_add_port_tm_node_shaper_profile_result
,
804 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id
=
805 TOKEN_NUM_INITIALIZER(
806 struct cmd_add_port_tm_node_shaper_profile_result
,
808 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id
=
809 TOKEN_NUM_INITIALIZER(
810 struct cmd_add_port_tm_node_shaper_profile_result
,
812 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_rate
=
813 TOKEN_NUM_INITIALIZER(
814 struct cmd_add_port_tm_node_shaper_profile_result
,
815 cmit_tb_rate
, UINT64
);
816 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_size
=
817 TOKEN_NUM_INITIALIZER(
818 struct cmd_add_port_tm_node_shaper_profile_result
,
819 cmit_tb_size
, UINT64
);
820 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_rate
=
821 TOKEN_NUM_INITIALIZER(
822 struct cmd_add_port_tm_node_shaper_profile_result
,
823 peak_tb_rate
, UINT64
);
824 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_size
=
825 TOKEN_NUM_INITIALIZER(
826 struct cmd_add_port_tm_node_shaper_profile_result
,
827 peak_tb_size
, UINT64
);
828 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust
=
829 TOKEN_NUM_INITIALIZER(
830 struct cmd_add_port_tm_node_shaper_profile_result
,
831 pktlen_adjust
, UINT32
);
833 static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result
,
834 __attribute__((unused
)) struct cmdline
*cl
,
835 __attribute__((unused
)) void *data
)
837 struct cmd_add_port_tm_node_shaper_profile_result
*res
= parsed_result
;
838 struct rte_tm_shaper_params sp
;
839 struct rte_tm_error error
;
840 uint32_t shaper_id
= res
->shaper_id
;
841 uint32_t pkt_len_adjust
= res
->pktlen_adjust
;
842 portid_t port_id
= res
->port_id
;
845 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
848 /* Private shaper profile params */
849 memset(&sp
, 0, sizeof(struct rte_tm_shaper_params
));
850 memset(&error
, 0, sizeof(struct rte_tm_error
));
851 sp
.committed
.rate
= res
->cmit_tb_rate
;
852 sp
.committed
.size
= res
->cmit_tb_size
;
853 sp
.peak
.rate
= res
->peak_tb_rate
;
854 sp
.peak
.size
= res
->peak_tb_size
;
855 sp
.pkt_length_adjust
= pkt_len_adjust
;
857 ret
= rte_tm_shaper_profile_add(port_id
, shaper_id
, &sp
, &error
);
859 print_err_msg(&error
);
864 cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile
= {
865 .f
= cmd_add_port_tm_node_shaper_profile_parsed
,
867 .help_str
= "Add port tm node private shaper profile",
869 (void *)&cmd_add_port_tm_node_shaper_profile_add
,
870 (void *)&cmd_add_port_tm_node_shaper_profile_port
,
871 (void *)&cmd_add_port_tm_node_shaper_profile_tm
,
872 (void *)&cmd_add_port_tm_node_shaper_profile_node
,
873 (void *)&cmd_add_port_tm_node_shaper_profile_shaper
,
874 (void *)&cmd_add_port_tm_node_shaper_profile_profile
,
875 (void *)&cmd_add_port_tm_node_shaper_profile_port_id
,
876 (void *)&cmd_add_port_tm_node_shaper_profile_shaper_id
,
877 (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_rate
,
878 (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_size
,
879 (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_rate
,
880 (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_size
,
881 (void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust
,
886 /* *** Delete Port TM Private Shaper Profile *** */
887 struct cmd_del_port_tm_node_shaper_profile_result
{
888 cmdline_fixed_string_t del
;
889 cmdline_fixed_string_t port
;
890 cmdline_fixed_string_t tm
;
891 cmdline_fixed_string_t node
;
892 cmdline_fixed_string_t shaper
;
893 cmdline_fixed_string_t profile
;
898 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del
=
899 TOKEN_STRING_INITIALIZER(
900 struct cmd_del_port_tm_node_shaper_profile_result
, del
, "del");
901 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port
=
902 TOKEN_STRING_INITIALIZER(
903 struct cmd_del_port_tm_node_shaper_profile_result
,
905 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm
=
906 TOKEN_STRING_INITIALIZER(
907 struct cmd_del_port_tm_node_shaper_profile_result
, tm
, "tm");
908 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node
=
909 TOKEN_STRING_INITIALIZER(
910 struct cmd_del_port_tm_node_shaper_profile_result
,
912 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper
=
913 TOKEN_STRING_INITIALIZER(
914 struct cmd_del_port_tm_node_shaper_profile_result
,
916 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile
=
917 TOKEN_STRING_INITIALIZER(
918 struct cmd_del_port_tm_node_shaper_profile_result
,
920 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id
=
921 TOKEN_NUM_INITIALIZER(
922 struct cmd_del_port_tm_node_shaper_profile_result
,
924 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id
=
925 TOKEN_NUM_INITIALIZER(
926 struct cmd_del_port_tm_node_shaper_profile_result
,
929 static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result
,
930 __attribute__((unused
)) struct cmdline
*cl
,
931 __attribute__((unused
)) void *data
)
933 struct cmd_del_port_tm_node_shaper_profile_result
*res
= parsed_result
;
934 struct rte_tm_error error
;
935 uint32_t shaper_id
= res
->shaper_id
;
936 portid_t port_id
= res
->port_id
;
939 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
942 memset(&error
, 0, sizeof(struct rte_tm_error
));
943 ret
= rte_tm_shaper_profile_delete(port_id
, shaper_id
, &error
);
945 print_err_msg(&error
);
950 cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile
= {
951 .f
= cmd_del_port_tm_node_shaper_profile_parsed
,
953 .help_str
= "Delete port tm node private shaper profile",
955 (void *)&cmd_del_port_tm_node_shaper_profile_del
,
956 (void *)&cmd_del_port_tm_node_shaper_profile_port
,
957 (void *)&cmd_del_port_tm_node_shaper_profile_tm
,
958 (void *)&cmd_del_port_tm_node_shaper_profile_node
,
959 (void *)&cmd_del_port_tm_node_shaper_profile_shaper
,
960 (void *)&cmd_del_port_tm_node_shaper_profile_profile
,
961 (void *)&cmd_del_port_tm_node_shaper_profile_port_id
,
962 (void *)&cmd_del_port_tm_node_shaper_profile_shaper_id
,
967 /* *** Add/Update Port TM shared Shaper *** */
968 struct cmd_add_port_tm_node_shared_shaper_result
{
969 cmdline_fixed_string_t cmd_type
;
970 cmdline_fixed_string_t port
;
971 cmdline_fixed_string_t tm
;
972 cmdline_fixed_string_t node
;
973 cmdline_fixed_string_t shared
;
974 cmdline_fixed_string_t shaper
;
976 uint32_t shared_shaper_id
;
977 uint32_t shaper_profile_id
;
980 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type
=
981 TOKEN_STRING_INITIALIZER(
982 struct cmd_add_port_tm_node_shared_shaper_result
,
983 cmd_type
, "add#set");
984 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port
=
985 TOKEN_STRING_INITIALIZER(
986 struct cmd_add_port_tm_node_shared_shaper_result
, port
, "port");
987 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm
=
988 TOKEN_STRING_INITIALIZER(
989 struct cmd_add_port_tm_node_shared_shaper_result
, tm
, "tm");
990 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node
=
991 TOKEN_STRING_INITIALIZER(
992 struct cmd_add_port_tm_node_shared_shaper_result
, node
, "node");
993 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared
=
994 TOKEN_STRING_INITIALIZER(
995 struct cmd_add_port_tm_node_shared_shaper_result
,
997 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper
=
998 TOKEN_STRING_INITIALIZER(
999 struct cmd_add_port_tm_node_shared_shaper_result
,
1001 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id
=
1002 TOKEN_NUM_INITIALIZER(
1003 struct cmd_add_port_tm_node_shared_shaper_result
,
1005 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id
=
1006 TOKEN_NUM_INITIALIZER(
1007 struct cmd_add_port_tm_node_shared_shaper_result
,
1008 shared_shaper_id
, UINT32
);
1009 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id
=
1010 TOKEN_NUM_INITIALIZER(
1011 struct cmd_add_port_tm_node_shared_shaper_result
,
1012 shaper_profile_id
, UINT32
);
1014 static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result
,
1015 __attribute__((unused
)) struct cmdline
*cl
,
1016 __attribute__((unused
)) void *data
)
1018 struct cmd_add_port_tm_node_shared_shaper_result
*res
= parsed_result
;
1019 struct rte_tm_error error
;
1020 uint32_t shared_shaper_id
= res
->shared_shaper_id
;
1021 uint32_t shaper_profile_id
= res
->shaper_profile_id
;
1022 portid_t port_id
= res
->port_id
;
1025 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1028 memset(&error
, 0, sizeof(struct rte_tm_error
));
1029 /* Command type: add */
1030 if ((strcmp(res
->cmd_type
, "add") == 0) &&
1031 (port_is_started(port_id
))) {
1032 printf(" Port %u not stopped (error)\n", port_id
);
1036 /* Command type: set (update) */
1037 if ((strcmp(res
->cmd_type
, "set") == 0) &&
1038 (!port_is_started(port_id
))) {
1039 printf(" Port %u not started (error)\n", port_id
);
1043 ret
= rte_tm_shared_shaper_add_update(port_id
, shared_shaper_id
,
1044 shaper_profile_id
, &error
);
1046 print_err_msg(&error
);
1051 cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper
= {
1052 .f
= cmd_add_port_tm_node_shared_shaper_parsed
,
1054 .help_str
= "add/update port tm node shared shaper",
1056 (void *)&cmd_add_port_tm_node_shared_shaper_cmd_type
,
1057 (void *)&cmd_add_port_tm_node_shared_shaper_port
,
1058 (void *)&cmd_add_port_tm_node_shared_shaper_tm
,
1059 (void *)&cmd_add_port_tm_node_shared_shaper_node
,
1060 (void *)&cmd_add_port_tm_node_shared_shaper_shared
,
1061 (void *)&cmd_add_port_tm_node_shared_shaper_shaper
,
1062 (void *)&cmd_add_port_tm_node_shared_shaper_port_id
,
1063 (void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id
,
1064 (void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id
,
1069 /* *** Delete Port TM shared Shaper *** */
1070 struct cmd_del_port_tm_node_shared_shaper_result
{
1071 cmdline_fixed_string_t del
;
1072 cmdline_fixed_string_t port
;
1073 cmdline_fixed_string_t tm
;
1074 cmdline_fixed_string_t node
;
1075 cmdline_fixed_string_t shared
;
1076 cmdline_fixed_string_t shaper
;
1078 uint32_t shared_shaper_id
;
1081 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del
=
1082 TOKEN_STRING_INITIALIZER(
1083 struct cmd_del_port_tm_node_shared_shaper_result
, del
, "del");
1084 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port
=
1085 TOKEN_STRING_INITIALIZER(
1086 struct cmd_del_port_tm_node_shared_shaper_result
, port
, "port");
1087 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm
=
1088 TOKEN_STRING_INITIALIZER(
1089 struct cmd_del_port_tm_node_shared_shaper_result
, tm
, "tm");
1090 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node
=
1091 TOKEN_STRING_INITIALIZER(
1092 struct cmd_del_port_tm_node_shared_shaper_result
, node
, "node");
1093 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared
=
1094 TOKEN_STRING_INITIALIZER(
1095 struct cmd_del_port_tm_node_shared_shaper_result
,
1097 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper
=
1098 TOKEN_STRING_INITIALIZER(
1099 struct cmd_del_port_tm_node_shared_shaper_result
,
1101 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id
=
1102 TOKEN_NUM_INITIALIZER(
1103 struct cmd_del_port_tm_node_shared_shaper_result
,
1105 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id
=
1106 TOKEN_NUM_INITIALIZER(
1107 struct cmd_del_port_tm_node_shared_shaper_result
,
1108 shared_shaper_id
, UINT32
);
1110 static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result
,
1111 __attribute__((unused
)) struct cmdline
*cl
,
1112 __attribute__((unused
)) void *data
)
1114 struct cmd_del_port_tm_node_shared_shaper_result
*res
= parsed_result
;
1115 struct rte_tm_error error
;
1116 uint32_t shared_shaper_id
= res
->shared_shaper_id
;
1117 portid_t port_id
= res
->port_id
;
1120 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1123 memset(&error
, 0, sizeof(struct rte_tm_error
));
1124 ret
= rte_tm_shared_shaper_delete(port_id
, shared_shaper_id
, &error
);
1126 print_err_msg(&error
);
1131 cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper
= {
1132 .f
= cmd_del_port_tm_node_shared_shaper_parsed
,
1134 .help_str
= "delete port tm node shared shaper",
1136 (void *)&cmd_del_port_tm_node_shared_shaper_del
,
1137 (void *)&cmd_del_port_tm_node_shared_shaper_port
,
1138 (void *)&cmd_del_port_tm_node_shared_shaper_tm
,
1139 (void *)&cmd_del_port_tm_node_shared_shaper_node
,
1140 (void *)&cmd_del_port_tm_node_shared_shaper_shared
,
1141 (void *)&cmd_del_port_tm_node_shared_shaper_shaper
,
1142 (void *)&cmd_del_port_tm_node_shared_shaper_port_id
,
1143 (void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id
,
1148 /* *** Add Port TM Node WRED Profile *** */
1149 struct cmd_add_port_tm_node_wred_profile_result
{
1150 cmdline_fixed_string_t add
;
1151 cmdline_fixed_string_t port
;
1152 cmdline_fixed_string_t tm
;
1153 cmdline_fixed_string_t node
;
1154 cmdline_fixed_string_t wred
;
1155 cmdline_fixed_string_t profile
;
1157 uint32_t wred_profile_id
;
1158 cmdline_fixed_string_t color_g
;
1161 uint16_t maxp_inv_g
;
1163 cmdline_fixed_string_t color_y
;
1166 uint16_t maxp_inv_y
;
1168 cmdline_fixed_string_t color_r
;
1171 uint16_t maxp_inv_r
;
1175 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add
=
1176 TOKEN_STRING_INITIALIZER(
1177 struct cmd_add_port_tm_node_wred_profile_result
, add
, "add");
1178 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port
=
1179 TOKEN_STRING_INITIALIZER(
1180 struct cmd_add_port_tm_node_wred_profile_result
, port
, "port");
1181 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm
=
1182 TOKEN_STRING_INITIALIZER(
1183 struct cmd_add_port_tm_node_wred_profile_result
, tm
, "tm");
1184 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node
=
1185 TOKEN_STRING_INITIALIZER(
1186 struct cmd_add_port_tm_node_wred_profile_result
, node
, "node");
1187 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred
=
1188 TOKEN_STRING_INITIALIZER(
1189 struct cmd_add_port_tm_node_wred_profile_result
, wred
, "wred");
1190 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile
=
1191 TOKEN_STRING_INITIALIZER(
1192 struct cmd_add_port_tm_node_wred_profile_result
,
1193 profile
, "profile");
1194 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id
=
1195 TOKEN_NUM_INITIALIZER(
1196 struct cmd_add_port_tm_node_wred_profile_result
,
1198 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id
=
1199 TOKEN_NUM_INITIALIZER(
1200 struct cmd_add_port_tm_node_wred_profile_result
,
1201 wred_profile_id
, UINT32
);
1202 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g
=
1203 TOKEN_STRING_INITIALIZER(
1204 struct cmd_add_port_tm_node_wred_profile_result
,
1206 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g
=
1207 TOKEN_NUM_INITIALIZER(
1208 struct cmd_add_port_tm_node_wred_profile_result
,
1210 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g
=
1211 TOKEN_NUM_INITIALIZER(
1212 struct cmd_add_port_tm_node_wred_profile_result
,
1214 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g
=
1215 TOKEN_NUM_INITIALIZER(
1216 struct cmd_add_port_tm_node_wred_profile_result
,
1217 maxp_inv_g
, UINT16
);
1218 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g
=
1219 TOKEN_NUM_INITIALIZER(
1220 struct cmd_add_port_tm_node_wred_profile_result
,
1222 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y
=
1223 TOKEN_STRING_INITIALIZER(
1224 struct cmd_add_port_tm_node_wred_profile_result
,
1226 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y
=
1227 TOKEN_NUM_INITIALIZER(
1228 struct cmd_add_port_tm_node_wred_profile_result
,
1230 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y
=
1231 TOKEN_NUM_INITIALIZER(
1232 struct cmd_add_port_tm_node_wred_profile_result
,
1234 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y
=
1235 TOKEN_NUM_INITIALIZER(
1236 struct cmd_add_port_tm_node_wred_profile_result
,
1237 maxp_inv_y
, UINT16
);
1238 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y
=
1239 TOKEN_NUM_INITIALIZER(
1240 struct cmd_add_port_tm_node_wred_profile_result
,
1242 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r
=
1243 TOKEN_STRING_INITIALIZER(
1244 struct cmd_add_port_tm_node_wred_profile_result
,
1246 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r
=
1247 TOKEN_NUM_INITIALIZER(
1248 struct cmd_add_port_tm_node_wred_profile_result
,
1250 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r
=
1251 TOKEN_NUM_INITIALIZER(
1252 struct cmd_add_port_tm_node_wred_profile_result
,
1254 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r
=
1255 TOKEN_NUM_INITIALIZER(
1256 struct cmd_add_port_tm_node_wred_profile_result
,
1257 maxp_inv_r
, UINT16
);
1258 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r
=
1259 TOKEN_NUM_INITIALIZER(
1260 struct cmd_add_port_tm_node_wred_profile_result
,
1264 static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result
,
1265 __attribute__((unused
)) struct cmdline
*cl
,
1266 __attribute__((unused
)) void *data
)
1268 struct cmd_add_port_tm_node_wred_profile_result
*res
= parsed_result
;
1269 struct rte_tm_wred_params wp
;
1270 enum rte_color color
;
1271 struct rte_tm_error error
;
1272 uint32_t wred_profile_id
= res
->wred_profile_id
;
1273 portid_t port_id
= res
->port_id
;
1276 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1279 memset(&wp
, 0, sizeof(struct rte_tm_wred_params
));
1280 memset(&error
, 0, sizeof(struct rte_tm_error
));
1282 /* WRED Params (Green Color)*/
1283 color
= RTE_COLOR_GREEN
;
1284 wp
.red_params
[color
].min_th
= res
->min_th_g
;
1285 wp
.red_params
[color
].max_th
= res
->max_th_g
;
1286 wp
.red_params
[color
].maxp_inv
= res
->maxp_inv_g
;
1287 wp
.red_params
[color
].wq_log2
= res
->wq_log2_g
;
1290 /* WRED Params (Yellow Color)*/
1291 color
= RTE_COLOR_YELLOW
;
1292 wp
.red_params
[color
].min_th
= res
->min_th_y
;
1293 wp
.red_params
[color
].max_th
= res
->max_th_y
;
1294 wp
.red_params
[color
].maxp_inv
= res
->maxp_inv_y
;
1295 wp
.red_params
[color
].wq_log2
= res
->wq_log2_y
;
1297 /* WRED Params (Red Color)*/
1298 color
= RTE_COLOR_RED
;
1299 wp
.red_params
[color
].min_th
= res
->min_th_r
;
1300 wp
.red_params
[color
].max_th
= res
->max_th_r
;
1301 wp
.red_params
[color
].maxp_inv
= res
->maxp_inv_r
;
1302 wp
.red_params
[color
].wq_log2
= res
->wq_log2_r
;
1304 ret
= rte_tm_wred_profile_add(port_id
, wred_profile_id
, &wp
, &error
);
1306 print_err_msg(&error
);
1311 cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile
= {
1312 .f
= cmd_add_port_tm_node_wred_profile_parsed
,
1314 .help_str
= "Add port tm node wred profile",
1316 (void *)&cmd_add_port_tm_node_wred_profile_add
,
1317 (void *)&cmd_add_port_tm_node_wred_profile_port
,
1318 (void *)&cmd_add_port_tm_node_wred_profile_tm
,
1319 (void *)&cmd_add_port_tm_node_wred_profile_node
,
1320 (void *)&cmd_add_port_tm_node_wred_profile_wred
,
1321 (void *)&cmd_add_port_tm_node_wred_profile_profile
,
1322 (void *)&cmd_add_port_tm_node_wred_profile_port_id
,
1323 (void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id
,
1324 (void *)&cmd_add_port_tm_node_wred_profile_color_g
,
1325 (void *)&cmd_add_port_tm_node_wred_profile_min_th_g
,
1326 (void *)&cmd_add_port_tm_node_wred_profile_max_th_g
,
1327 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g
,
1328 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g
,
1329 (void *)&cmd_add_port_tm_node_wred_profile_color_y
,
1330 (void *)&cmd_add_port_tm_node_wred_profile_min_th_y
,
1331 (void *)&cmd_add_port_tm_node_wred_profile_max_th_y
,
1332 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y
,
1333 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y
,
1334 (void *)&cmd_add_port_tm_node_wred_profile_color_r
,
1335 (void *)&cmd_add_port_tm_node_wred_profile_min_th_r
,
1336 (void *)&cmd_add_port_tm_node_wred_profile_max_th_r
,
1337 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r
,
1338 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r
,
1343 /* *** Delete Port TM node WRED Profile *** */
1344 struct cmd_del_port_tm_node_wred_profile_result
{
1345 cmdline_fixed_string_t del
;
1346 cmdline_fixed_string_t port
;
1347 cmdline_fixed_string_t tm
;
1348 cmdline_fixed_string_t node
;
1349 cmdline_fixed_string_t wred
;
1350 cmdline_fixed_string_t profile
;
1352 uint32_t wred_profile_id
;
1355 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del
=
1356 TOKEN_STRING_INITIALIZER(
1357 struct cmd_del_port_tm_node_wred_profile_result
, del
, "del");
1358 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port
=
1359 TOKEN_STRING_INITIALIZER(
1360 struct cmd_del_port_tm_node_wred_profile_result
, port
, "port");
1361 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm
=
1362 TOKEN_STRING_INITIALIZER(
1363 struct cmd_del_port_tm_node_wred_profile_result
, tm
, "tm");
1364 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node
=
1365 TOKEN_STRING_INITIALIZER(
1366 struct cmd_del_port_tm_node_wred_profile_result
, node
, "node");
1367 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred
=
1368 TOKEN_STRING_INITIALIZER(
1369 struct cmd_del_port_tm_node_wred_profile_result
, wred
, "wred");
1370 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile
=
1371 TOKEN_STRING_INITIALIZER(
1372 struct cmd_del_port_tm_node_wred_profile_result
,
1373 profile
, "profile");
1374 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id
=
1375 TOKEN_NUM_INITIALIZER(
1376 struct cmd_del_port_tm_node_wred_profile_result
,
1378 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id
=
1379 TOKEN_NUM_INITIALIZER(
1380 struct cmd_del_port_tm_node_wred_profile_result
,
1381 wred_profile_id
, UINT32
);
1383 static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result
,
1384 __attribute__((unused
)) struct cmdline
*cl
,
1385 __attribute__((unused
)) void *data
)
1387 struct cmd_del_port_tm_node_wred_profile_result
*res
= parsed_result
;
1388 struct rte_tm_error error
;
1389 uint32_t wred_profile_id
= res
->wred_profile_id
;
1390 portid_t port_id
= res
->port_id
;
1393 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1396 memset(&error
, 0, sizeof(struct rte_tm_error
));
1397 ret
= rte_tm_wred_profile_delete(port_id
, wred_profile_id
, &error
);
1399 print_err_msg(&error
);
1404 cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile
= {
1405 .f
= cmd_del_port_tm_node_wred_profile_parsed
,
1407 .help_str
= "Delete port tm node wred profile",
1409 (void *)&cmd_del_port_tm_node_wred_profile_del
,
1410 (void *)&cmd_del_port_tm_node_wred_profile_port
,
1411 (void *)&cmd_del_port_tm_node_wred_profile_tm
,
1412 (void *)&cmd_del_port_tm_node_wred_profile_node
,
1413 (void *)&cmd_del_port_tm_node_wred_profile_wred
,
1414 (void *)&cmd_del_port_tm_node_wred_profile_profile
,
1415 (void *)&cmd_del_port_tm_node_wred_profile_port_id
,
1416 (void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id
,
1421 /* *** Update Port TM Node Shaper profile *** */
1422 struct cmd_set_port_tm_node_shaper_profile_result
{
1423 cmdline_fixed_string_t set
;
1424 cmdline_fixed_string_t port
;
1425 cmdline_fixed_string_t tm
;
1426 cmdline_fixed_string_t node
;
1427 cmdline_fixed_string_t shaper
;
1428 cmdline_fixed_string_t profile
;
1431 uint32_t shaper_profile_id
;
1434 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set
=
1435 TOKEN_STRING_INITIALIZER(
1436 struct cmd_set_port_tm_node_shaper_profile_result
, set
, "set");
1437 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port
=
1438 TOKEN_STRING_INITIALIZER(
1439 struct cmd_set_port_tm_node_shaper_profile_result
,
1441 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_tm
=
1442 TOKEN_STRING_INITIALIZER(
1443 struct cmd_set_port_tm_node_shaper_profile_result
, tm
, "tm");
1444 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node
=
1445 TOKEN_STRING_INITIALIZER(
1446 struct cmd_set_port_tm_node_shaper_profile_result
,
1448 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper
=
1449 TOKEN_STRING_INITIALIZER(
1450 struct cmd_set_port_tm_node_shaper_profile_result
,
1452 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile
=
1453 TOKEN_STRING_INITIALIZER(
1454 struct cmd_set_port_tm_node_shaper_profile_result
,
1455 profile
, "profile");
1456 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id
=
1457 TOKEN_NUM_INITIALIZER(
1458 struct cmd_set_port_tm_node_shaper_profile_result
,
1460 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id
=
1461 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result
,
1463 cmdline_parse_token_num_t
1464 cmd_set_port_tm_node_shaper_shaper_profile_profile_id
=
1465 TOKEN_NUM_INITIALIZER(
1466 struct cmd_set_port_tm_node_shaper_profile_result
,
1467 shaper_profile_id
, UINT32
);
1469 static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result
,
1470 __attribute__((unused
)) struct cmdline
*cl
,
1471 __attribute__((unused
)) void *data
)
1473 struct cmd_set_port_tm_node_shaper_profile_result
*res
= parsed_result
;
1474 struct rte_tm_error error
;
1475 uint32_t node_id
= res
->node_id
;
1476 uint32_t shaper_profile_id
= res
->shaper_profile_id
;
1477 portid_t port_id
= res
->port_id
;
1480 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1483 memset(&error
, 0, sizeof(struct rte_tm_error
));
1485 if (!port_is_started(port_id
)) {
1486 printf(" Port %u not started (error)\n", port_id
);
1490 ret
= rte_tm_node_shaper_update(port_id
, node_id
,
1491 shaper_profile_id
, &error
);
1493 print_err_msg(&error
);
1498 cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile
= {
1499 .f
= cmd_set_port_tm_node_shaper_profile_parsed
,
1501 .help_str
= "Set port tm node shaper profile",
1503 (void *)&cmd_set_port_tm_node_shaper_profile_set
,
1504 (void *)&cmd_set_port_tm_node_shaper_profile_port
,
1505 (void *)&cmd_set_port_tm_node_shaper_profile_tm
,
1506 (void *)&cmd_set_port_tm_node_shaper_profile_node
,
1507 (void *)&cmd_set_port_tm_node_shaper_profile_shaper
,
1508 (void *)&cmd_set_port_tm_node_shaper_profile_profile
,
1509 (void *)&cmd_set_port_tm_node_shaper_profile_port_id
,
1510 (void *)&cmd_set_port_tm_node_shaper_profile_node_id
,
1511 (void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id
,
1516 /* *** Add Port TM nonleaf node *** */
1517 struct cmd_add_port_tm_nonleaf_node_result
{
1518 cmdline_fixed_string_t add
;
1519 cmdline_fixed_string_t port
;
1520 cmdline_fixed_string_t tm
;
1521 cmdline_fixed_string_t nonleaf
;
1522 cmdline_fixed_string_t node
;
1525 int32_t parent_node_id
;
1529 int32_t shaper_profile_id
;
1530 uint32_t n_sp_priorities
;
1531 uint64_t stats_mask
;
1532 cmdline_multi_string_t multi_shared_shaper_id
;
1535 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add
=
1536 TOKEN_STRING_INITIALIZER(
1537 struct cmd_add_port_tm_nonleaf_node_result
, add
, "add");
1538 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port
=
1539 TOKEN_STRING_INITIALIZER(
1540 struct cmd_add_port_tm_nonleaf_node_result
, port
, "port");
1541 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm
=
1542 TOKEN_STRING_INITIALIZER(
1543 struct cmd_add_port_tm_nonleaf_node_result
, tm
, "tm");
1544 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf
=
1545 TOKEN_STRING_INITIALIZER(
1546 struct cmd_add_port_tm_nonleaf_node_result
, nonleaf
, "nonleaf");
1547 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node
=
1548 TOKEN_STRING_INITIALIZER(
1549 struct cmd_add_port_tm_nonleaf_node_result
, node
, "node");
1550 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id
=
1551 TOKEN_NUM_INITIALIZER(
1552 struct cmd_add_port_tm_nonleaf_node_result
,
1554 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_id
=
1555 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1557 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_parent_node_id
=
1558 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1559 parent_node_id
, INT32
);
1560 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority
=
1561 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1563 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight
=
1564 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1566 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id
=
1567 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1569 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id
=
1570 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1571 shaper_profile_id
, INT32
);
1572 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities
=
1573 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1574 n_sp_priorities
, UINT32
);
1575 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask
=
1576 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1577 stats_mask
, UINT64
);
1578 cmdline_parse_token_string_t
1579 cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id
=
1580 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result
,
1581 multi_shared_shaper_id
, TOKEN_STRING_MULTI
);
1583 static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result
,
1584 __attribute__((unused
)) struct cmdline
*cl
,
1585 __attribute__((unused
)) void *data
)
1587 struct cmd_add_port_tm_nonleaf_node_result
*res
= parsed_result
;
1588 struct rte_tm_error error
;
1589 struct rte_tm_node_params np
;
1590 uint32_t *shared_shaper_id
;
1591 uint32_t parent_node_id
, n_shared_shapers
= 0;
1592 char *s_str
= res
->multi_shared_shaper_id
;
1593 portid_t port_id
= res
->port_id
;
1596 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1599 memset(&np
, 0, sizeof(struct rte_tm_node_params
));
1600 memset(&error
, 0, sizeof(struct rte_tm_error
));
1602 /* Node parameters */
1603 if (res
->parent_node_id
< 0)
1604 parent_node_id
= UINT32_MAX
;
1606 parent_node_id
= res
->parent_node_id
;
1608 shared_shaper_id
= (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS
*
1610 if (shared_shaper_id
== NULL
) {
1611 printf(" Memory not allocated for shared shapers (error)\n");
1615 /* Parse multi shared shaper id string */
1616 ret
= parse_multi_ss_id_str(s_str
, &n_shared_shapers
, shared_shaper_id
);
1618 printf(" Shared shapers params string parse error\n");
1619 free(shared_shaper_id
);
1623 if (res
->shaper_profile_id
< 0)
1624 np
.shaper_profile_id
= UINT32_MAX
;
1626 np
.shaper_profile_id
= res
->shaper_profile_id
;
1628 np
.n_shared_shapers
= n_shared_shapers
;
1629 if (np
.n_shared_shapers
) {
1630 np
.shared_shaper_id
= &shared_shaper_id
[0];
1632 free(shared_shaper_id
);
1633 shared_shaper_id
= NULL
;
1636 np
.nonleaf
.n_sp_priorities
= res
->n_sp_priorities
;
1637 np
.stats_mask
= res
->stats_mask
;
1638 np
.nonleaf
.wfq_weight_mode
= NULL
;
1640 ret
= rte_tm_node_add(port_id
, res
->node_id
, parent_node_id
,
1641 res
->priority
, res
->weight
, res
->level_id
,
1644 print_err_msg(&error
);
1645 free(shared_shaper_id
);
1650 cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node
= {
1651 .f
= cmd_add_port_tm_nonleaf_node_parsed
,
1653 .help_str
= "Add port tm nonleaf node",
1655 (void *)&cmd_add_port_tm_nonleaf_node_add
,
1656 (void *)&cmd_add_port_tm_nonleaf_node_port
,
1657 (void *)&cmd_add_port_tm_nonleaf_node_tm
,
1658 (void *)&cmd_add_port_tm_nonleaf_node_nonleaf
,
1659 (void *)&cmd_add_port_tm_nonleaf_node_node
,
1660 (void *)&cmd_add_port_tm_nonleaf_node_port_id
,
1661 (void *)&cmd_add_port_tm_nonleaf_node_node_id
,
1662 (void *)&cmd_add_port_tm_nonleaf_node_parent_node_id
,
1663 (void *)&cmd_add_port_tm_nonleaf_node_priority
,
1664 (void *)&cmd_add_port_tm_nonleaf_node_weight
,
1665 (void *)&cmd_add_port_tm_nonleaf_node_level_id
,
1666 (void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id
,
1667 (void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities
,
1668 (void *)&cmd_add_port_tm_nonleaf_node_stats_mask
,
1669 (void *)&cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id
,
1674 /* *** Add Port TM leaf node *** */
1675 struct cmd_add_port_tm_leaf_node_result
{
1676 cmdline_fixed_string_t add
;
1677 cmdline_fixed_string_t port
;
1678 cmdline_fixed_string_t tm
;
1679 cmdline_fixed_string_t leaf
;
1680 cmdline_fixed_string_t node
;
1683 int32_t parent_node_id
;
1687 int32_t shaper_profile_id
;
1689 uint32_t wred_profile_id
;
1690 uint64_t stats_mask
;
1691 cmdline_multi_string_t multi_shared_shaper_id
;
1694 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add
=
1695 TOKEN_STRING_INITIALIZER(
1696 struct cmd_add_port_tm_leaf_node_result
, add
, "add");
1697 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port
=
1698 TOKEN_STRING_INITIALIZER(
1699 struct cmd_add_port_tm_leaf_node_result
, port
, "port");
1700 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm
=
1701 TOKEN_STRING_INITIALIZER(
1702 struct cmd_add_port_tm_leaf_node_result
, tm
, "tm");
1703 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf
=
1704 TOKEN_STRING_INITIALIZER(
1705 struct cmd_add_port_tm_leaf_node_result
, leaf
, "leaf");
1706 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node
=
1707 TOKEN_STRING_INITIALIZER(
1708 struct cmd_add_port_tm_leaf_node_result
, node
, "node");
1709 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_id
=
1710 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1712 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_node_id
=
1713 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1715 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id
=
1716 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1717 parent_node_id
, INT32
);
1718 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority
=
1719 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1721 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight
=
1722 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1724 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id
=
1725 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1727 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id
=
1728 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1729 shaper_profile_id
, INT32
);
1730 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode
=
1731 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1733 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id
=
1734 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1735 wred_profile_id
, UINT32
);
1736 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask
=
1737 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1738 stats_mask
, UINT64
);
1739 cmdline_parse_token_string_t
1740 cmd_add_port_tm_leaf_node_multi_shared_shaper_id
=
1741 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_leaf_node_result
,
1742 multi_shared_shaper_id
, TOKEN_STRING_MULTI
);
1744 static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result
,
1745 __attribute__((unused
)) struct cmdline
*cl
,
1746 __attribute__((unused
)) void *data
)
1748 struct cmd_add_port_tm_leaf_node_result
*res
= parsed_result
;
1749 struct rte_tm_error error
;
1750 struct rte_tm_node_params np
;
1751 uint32_t *shared_shaper_id
;
1752 uint32_t parent_node_id
, n_shared_shapers
= 0;
1753 portid_t port_id
= res
->port_id
;
1754 char *s_str
= res
->multi_shared_shaper_id
;
1757 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1760 memset(&np
, 0, sizeof(struct rte_tm_node_params
));
1761 memset(&error
, 0, sizeof(struct rte_tm_error
));
1763 /* Node parameters */
1764 if (res
->parent_node_id
< 0)
1765 parent_node_id
= UINT32_MAX
;
1767 parent_node_id
= res
->parent_node_id
;
1769 shared_shaper_id
= (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS
*
1771 if (shared_shaper_id
== NULL
) {
1772 printf(" Memory not allocated for shared shapers (error)\n");
1776 /* Parse multi shared shaper id string */
1777 ret
= parse_multi_ss_id_str(s_str
, &n_shared_shapers
, shared_shaper_id
);
1779 printf(" Shared shapers params string parse error\n");
1780 free(shared_shaper_id
);
1784 if (res
->shaper_profile_id
< 0)
1785 np
.shaper_profile_id
= UINT32_MAX
;
1787 np
.shaper_profile_id
= res
->shaper_profile_id
;
1789 np
.n_shared_shapers
= n_shared_shapers
;
1791 if (np
.n_shared_shapers
) {
1792 np
.shared_shaper_id
= &shared_shaper_id
[0];
1794 free(shared_shaper_id
);
1795 shared_shaper_id
= NULL
;
1798 np
.leaf
.cman
= res
->cman_mode
;
1799 np
.leaf
.wred
.wred_profile_id
= res
->wred_profile_id
;
1800 np
.stats_mask
= res
->stats_mask
;
1802 ret
= rte_tm_node_add(port_id
, res
->node_id
, parent_node_id
,
1803 res
->priority
, res
->weight
, res
->level_id
,
1806 print_err_msg(&error
);
1807 free(shared_shaper_id
);
1812 cmdline_parse_inst_t cmd_add_port_tm_leaf_node
= {
1813 .f
= cmd_add_port_tm_leaf_node_parsed
,
1815 .help_str
= "Add port tm leaf node",
1817 (void *)&cmd_add_port_tm_leaf_node_add
,
1818 (void *)&cmd_add_port_tm_leaf_node_port
,
1819 (void *)&cmd_add_port_tm_leaf_node_tm
,
1820 (void *)&cmd_add_port_tm_leaf_node_nonleaf
,
1821 (void *)&cmd_add_port_tm_leaf_node_node
,
1822 (void *)&cmd_add_port_tm_leaf_node_port_id
,
1823 (void *)&cmd_add_port_tm_leaf_node_node_id
,
1824 (void *)&cmd_add_port_tm_leaf_node_parent_node_id
,
1825 (void *)&cmd_add_port_tm_leaf_node_priority
,
1826 (void *)&cmd_add_port_tm_leaf_node_weight
,
1827 (void *)&cmd_add_port_tm_leaf_node_level_id
,
1828 (void *)&cmd_add_port_tm_leaf_node_shaper_profile_id
,
1829 (void *)&cmd_add_port_tm_leaf_node_cman_mode
,
1830 (void *)&cmd_add_port_tm_leaf_node_wred_profile_id
,
1831 (void *)&cmd_add_port_tm_leaf_node_stats_mask
,
1832 (void *)&cmd_add_port_tm_leaf_node_multi_shared_shaper_id
,
1837 /* *** Delete Port TM Node *** */
1838 struct cmd_del_port_tm_node_result
{
1839 cmdline_fixed_string_t del
;
1840 cmdline_fixed_string_t port
;
1841 cmdline_fixed_string_t tm
;
1842 cmdline_fixed_string_t node
;
1847 cmdline_parse_token_string_t cmd_del_port_tm_node_del
=
1848 TOKEN_STRING_INITIALIZER(
1849 struct cmd_del_port_tm_node_result
, del
, "del");
1850 cmdline_parse_token_string_t cmd_del_port_tm_node_port
=
1851 TOKEN_STRING_INITIALIZER(
1852 struct cmd_del_port_tm_node_result
, port
, "port");
1853 cmdline_parse_token_string_t cmd_del_port_tm_node_tm
=
1854 TOKEN_STRING_INITIALIZER(
1855 struct cmd_del_port_tm_node_result
, tm
, "tm");
1856 cmdline_parse_token_string_t cmd_del_port_tm_node_node
=
1857 TOKEN_STRING_INITIALIZER(
1858 struct cmd_del_port_tm_node_result
, node
, "node");
1859 cmdline_parse_token_num_t cmd_del_port_tm_node_port_id
=
1860 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result
,
1862 cmdline_parse_token_num_t cmd_del_port_tm_node_node_id
=
1863 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result
,
1866 static void cmd_del_port_tm_node_parsed(void *parsed_result
,
1867 __attribute__((unused
)) struct cmdline
*cl
,
1868 __attribute__((unused
)) void *data
)
1870 struct cmd_del_port_tm_node_result
*res
= parsed_result
;
1871 struct rte_tm_error error
;
1872 uint32_t node_id
= res
->node_id
;
1873 portid_t port_id
= res
->port_id
;
1876 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1879 memset(&error
, 0, sizeof(struct rte_tm_error
));
1881 if (port_is_started(port_id
)) {
1882 printf(" Port %u not stopped (error)\n", port_id
);
1886 ret
= rte_tm_node_delete(port_id
, node_id
, &error
);
1888 print_err_msg(&error
);
1893 cmdline_parse_inst_t cmd_del_port_tm_node
= {
1894 .f
= cmd_del_port_tm_node_parsed
,
1896 .help_str
= "Delete port tm node",
1898 (void *)&cmd_del_port_tm_node_del
,
1899 (void *)&cmd_del_port_tm_node_port
,
1900 (void *)&cmd_del_port_tm_node_tm
,
1901 (void *)&cmd_del_port_tm_node_node
,
1902 (void *)&cmd_del_port_tm_node_port_id
,
1903 (void *)&cmd_del_port_tm_node_node_id
,
1908 /* *** Update Port TM Node Parent *** */
1909 struct cmd_set_port_tm_node_parent_result
{
1910 cmdline_fixed_string_t set
;
1911 cmdline_fixed_string_t port
;
1912 cmdline_fixed_string_t tm
;
1913 cmdline_fixed_string_t node
;
1914 cmdline_fixed_string_t parent
;
1922 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set
=
1923 TOKEN_STRING_INITIALIZER(
1924 struct cmd_set_port_tm_node_parent_result
, set
, "set");
1925 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port
=
1926 TOKEN_STRING_INITIALIZER(
1927 struct cmd_set_port_tm_node_parent_result
, port
, "port");
1928 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm
=
1929 TOKEN_STRING_INITIALIZER(
1930 struct cmd_set_port_tm_node_parent_result
, tm
, "tm");
1931 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node
=
1932 TOKEN_STRING_INITIALIZER(
1933 struct cmd_set_port_tm_node_parent_result
, node
, "node");
1934 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent
=
1935 TOKEN_STRING_INITIALIZER(
1936 struct cmd_set_port_tm_node_parent_result
, parent
, "parent");
1937 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id
=
1938 TOKEN_NUM_INITIALIZER(
1939 struct cmd_set_port_tm_node_parent_result
, port_id
, UINT16
);
1940 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id
=
1941 TOKEN_NUM_INITIALIZER(
1942 struct cmd_set_port_tm_node_parent_result
, node_id
, UINT32
);
1943 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id
=
1944 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result
,
1946 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority
=
1947 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result
,
1949 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight
=
1950 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result
,
1953 static void cmd_set_port_tm_node_parent_parsed(void *parsed_result
,
1954 __attribute__((unused
)) struct cmdline
*cl
,
1955 __attribute__((unused
)) void *data
)
1957 struct cmd_set_port_tm_node_parent_result
*res
= parsed_result
;
1958 struct rte_tm_error error
;
1959 uint32_t node_id
= res
->node_id
;
1960 uint32_t parent_id
= res
->parent_id
;
1961 uint32_t priority
= res
->priority
;
1962 uint32_t weight
= res
->weight
;
1963 portid_t port_id
= res
->port_id
;
1966 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
1969 memset(&error
, 0, sizeof(struct rte_tm_error
));
1971 if (!port_is_started(port_id
)) {
1972 printf(" Port %u not started (error)\n", port_id
);
1976 ret
= rte_tm_node_parent_update(port_id
, node_id
,
1977 parent_id
, priority
, weight
, &error
);
1979 print_err_msg(&error
);
1984 cmdline_parse_inst_t cmd_set_port_tm_node_parent
= {
1985 .f
= cmd_set_port_tm_node_parent_parsed
,
1987 .help_str
= "Set port tm node parent",
1989 (void *)&cmd_set_port_tm_node_parent_set
,
1990 (void *)&cmd_set_port_tm_node_parent_port
,
1991 (void *)&cmd_set_port_tm_node_parent_tm
,
1992 (void *)&cmd_set_port_tm_node_parent_node
,
1993 (void *)&cmd_set_port_tm_node_parent_parent
,
1994 (void *)&cmd_set_port_tm_node_parent_port_id
,
1995 (void *)&cmd_set_port_tm_node_parent_node_id
,
1996 (void *)&cmd_set_port_tm_node_parent_parent_id
,
1997 (void *)&cmd_set_port_tm_node_parent_priority
,
1998 (void *)&cmd_set_port_tm_node_parent_weight
,
2003 /* *** Suspend Port TM Node *** */
2004 struct cmd_suspend_port_tm_node_result
{
2005 cmdline_fixed_string_t suspend
;
2006 cmdline_fixed_string_t port
;
2007 cmdline_fixed_string_t tm
;
2008 cmdline_fixed_string_t node
;
2013 cmdline_parse_token_string_t cmd_suspend_port_tm_node_suspend
=
2014 TOKEN_STRING_INITIALIZER(
2015 struct cmd_suspend_port_tm_node_result
, suspend
, "suspend");
2016 cmdline_parse_token_string_t cmd_suspend_port_tm_node_port
=
2017 TOKEN_STRING_INITIALIZER(
2018 struct cmd_suspend_port_tm_node_result
, port
, "port");
2019 cmdline_parse_token_string_t cmd_suspend_port_tm_node_tm
=
2020 TOKEN_STRING_INITIALIZER(
2021 struct cmd_suspend_port_tm_node_result
, tm
, "tm");
2022 cmdline_parse_token_string_t cmd_suspend_port_tm_node_node
=
2023 TOKEN_STRING_INITIALIZER(
2024 struct cmd_suspend_port_tm_node_result
, node
, "node");
2025 cmdline_parse_token_num_t cmd_suspend_port_tm_node_port_id
=
2026 TOKEN_NUM_INITIALIZER(
2027 struct cmd_suspend_port_tm_node_result
, port_id
, UINT16
);
2028 cmdline_parse_token_num_t cmd_suspend_port_tm_node_node_id
=
2029 TOKEN_NUM_INITIALIZER(
2030 struct cmd_suspend_port_tm_node_result
, node_id
, UINT32
);
2032 static void cmd_suspend_port_tm_node_parsed(void *parsed_result
,
2033 __attribute__((unused
)) struct cmdline
*cl
,
2034 __attribute__((unused
)) void *data
)
2036 struct cmd_suspend_port_tm_node_result
*res
= parsed_result
;
2037 struct rte_tm_error error
;
2038 uint32_t node_id
= res
->node_id
;
2039 portid_t port_id
= res
->port_id
;
2042 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
2045 memset(&error
, 0, sizeof(struct rte_tm_error
));
2046 ret
= rte_tm_node_suspend(port_id
, node_id
, &error
);
2048 print_err_msg(&error
);
2053 cmdline_parse_inst_t cmd_suspend_port_tm_node
= {
2054 .f
= cmd_suspend_port_tm_node_parsed
,
2056 .help_str
= "Suspend port tm node",
2058 (void *)&cmd_suspend_port_tm_node_suspend
,
2059 (void *)&cmd_suspend_port_tm_node_port
,
2060 (void *)&cmd_suspend_port_tm_node_tm
,
2061 (void *)&cmd_suspend_port_tm_node_node
,
2062 (void *)&cmd_suspend_port_tm_node_port_id
,
2063 (void *)&cmd_suspend_port_tm_node_node_id
,
2068 /* *** Resume Port TM Node *** */
2069 struct cmd_resume_port_tm_node_result
{
2070 cmdline_fixed_string_t resume
;
2071 cmdline_fixed_string_t port
;
2072 cmdline_fixed_string_t tm
;
2073 cmdline_fixed_string_t node
;
2078 cmdline_parse_token_string_t cmd_resume_port_tm_node_resume
=
2079 TOKEN_STRING_INITIALIZER(
2080 struct cmd_resume_port_tm_node_result
, resume
, "resume");
2081 cmdline_parse_token_string_t cmd_resume_port_tm_node_port
=
2082 TOKEN_STRING_INITIALIZER(
2083 struct cmd_resume_port_tm_node_result
, port
, "port");
2084 cmdline_parse_token_string_t cmd_resume_port_tm_node_tm
=
2085 TOKEN_STRING_INITIALIZER(
2086 struct cmd_resume_port_tm_node_result
, tm
, "tm");
2087 cmdline_parse_token_string_t cmd_resume_port_tm_node_node
=
2088 TOKEN_STRING_INITIALIZER(
2089 struct cmd_resume_port_tm_node_result
, node
, "node");
2090 cmdline_parse_token_num_t cmd_resume_port_tm_node_port_id
=
2091 TOKEN_NUM_INITIALIZER(
2092 struct cmd_resume_port_tm_node_result
, port_id
, UINT16
);
2093 cmdline_parse_token_num_t cmd_resume_port_tm_node_node_id
=
2094 TOKEN_NUM_INITIALIZER(
2095 struct cmd_resume_port_tm_node_result
, node_id
, UINT32
);
2097 static void cmd_resume_port_tm_node_parsed(void *parsed_result
,
2098 __attribute__((unused
)) struct cmdline
*cl
,
2099 __attribute__((unused
)) void *data
)
2101 struct cmd_resume_port_tm_node_result
*res
= parsed_result
;
2102 struct rte_tm_error error
;
2103 uint32_t node_id
= res
->node_id
;
2104 portid_t port_id
= res
->port_id
;
2107 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
2110 memset(&error
, 0, sizeof(struct rte_tm_error
));
2111 ret
= rte_tm_node_resume(port_id
, node_id
, &error
);
2113 print_err_msg(&error
);
2118 cmdline_parse_inst_t cmd_resume_port_tm_node
= {
2119 .f
= cmd_resume_port_tm_node_parsed
,
2121 .help_str
= "Resume port tm node",
2123 (void *)&cmd_resume_port_tm_node_resume
,
2124 (void *)&cmd_resume_port_tm_node_port
,
2125 (void *)&cmd_resume_port_tm_node_tm
,
2126 (void *)&cmd_resume_port_tm_node_node
,
2127 (void *)&cmd_resume_port_tm_node_port_id
,
2128 (void *)&cmd_resume_port_tm_node_node_id
,
2133 /* *** Port TM Hierarchy Commit *** */
2134 struct cmd_port_tm_hierarchy_commit_result
{
2135 cmdline_fixed_string_t port
;
2136 cmdline_fixed_string_t tm
;
2137 cmdline_fixed_string_t hierarchy
;
2138 cmdline_fixed_string_t commit
;
2140 cmdline_fixed_string_t clean_on_fail
;
2143 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port
=
2144 TOKEN_STRING_INITIALIZER(
2145 struct cmd_port_tm_hierarchy_commit_result
, port
, "port");
2146 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm
=
2147 TOKEN_STRING_INITIALIZER(
2148 struct cmd_port_tm_hierarchy_commit_result
, tm
, "tm");
2149 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy
=
2150 TOKEN_STRING_INITIALIZER(
2151 struct cmd_port_tm_hierarchy_commit_result
,
2152 hierarchy
, "hierarchy");
2153 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit
=
2154 TOKEN_STRING_INITIALIZER(
2155 struct cmd_port_tm_hierarchy_commit_result
, commit
, "commit");
2156 cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id
=
2157 TOKEN_NUM_INITIALIZER(
2158 struct cmd_port_tm_hierarchy_commit_result
,
2160 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_clean_on_fail
=
2161 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result
,
2162 clean_on_fail
, "yes#no");
2164 static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result
,
2165 __attribute__((unused
)) struct cmdline
*cl
,
2166 __attribute__((unused
)) void *data
)
2168 struct cmd_port_tm_hierarchy_commit_result
*res
= parsed_result
;
2169 struct rte_tm_error error
;
2170 uint32_t clean_on_fail
;
2171 portid_t port_id
= res
->port_id
;
2174 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
2177 if (strcmp(res
->clean_on_fail
, "yes") == 0)
2182 memset(&error
, 0, sizeof(struct rte_tm_error
));
2183 ret
= rte_tm_hierarchy_commit(port_id
, clean_on_fail
, &error
);
2185 print_err_msg(&error
);
2190 cmdline_parse_inst_t cmd_port_tm_hierarchy_commit
= {
2191 .f
= cmd_port_tm_hierarchy_commit_parsed
,
2193 .help_str
= "Commit port tm hierarchy",
2195 (void *)&cmd_port_tm_hierarchy_commit_port
,
2196 (void *)&cmd_port_tm_hierarchy_commit_tm
,
2197 (void *)&cmd_port_tm_hierarchy_commit_hierarchy
,
2198 (void *)&cmd_port_tm_hierarchy_commit_commit
,
2199 (void *)&cmd_port_tm_hierarchy_commit_port_id
,
2200 (void *)&cmd_port_tm_hierarchy_commit_clean_on_fail
,
2205 /* *** Port TM Mark IP ECN *** */
2206 struct cmd_port_tm_mark_ip_ecn_result
{
2207 cmdline_fixed_string_t set
;
2208 cmdline_fixed_string_t port
;
2209 cmdline_fixed_string_t tm
;
2210 cmdline_fixed_string_t mark
;
2211 cmdline_fixed_string_t ip_ecn
;
2218 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_set
=
2219 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result
,
2222 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_port
=
2223 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result
,
2226 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_tm
=
2227 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result
, tm
,
2230 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_mark
=
2231 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result
,
2234 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_ip_ecn
=
2235 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result
,
2237 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_port_id
=
2238 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result
,
2241 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_green
=
2242 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result
,
2244 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_yellow
=
2245 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result
,
2247 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_red
=
2248 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result
,
2251 static void cmd_port_tm_mark_ip_ecn_parsed(void *parsed_result
,
2252 __attribute__((unused
)) struct cmdline
*cl
,
2253 __attribute__((unused
)) void *data
)
2255 struct cmd_port_tm_mark_ip_ecn_result
*res
= parsed_result
;
2256 struct rte_tm_error error
;
2257 portid_t port_id
= res
->port_id
;
2258 int green
= res
->green
;
2259 int yellow
= res
->yellow
;
2262 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
2265 memset(&error
, 0, sizeof(struct rte_tm_error
));
2266 ret
= rte_tm_mark_ip_ecn(port_id
, green
, yellow
, red
, &error
);
2268 print_err_msg(&error
);
2273 cmdline_parse_inst_t cmd_port_tm_mark_ip_ecn
= {
2274 .f
= cmd_port_tm_mark_ip_ecn_parsed
,
2276 .help_str
= "set port tm mark ip_ecn <port> <green> <yellow> <red>",
2278 (void *)&cmd_port_tm_mark_ip_ecn_set
,
2279 (void *)&cmd_port_tm_mark_ip_ecn_port
,
2280 (void *)&cmd_port_tm_mark_ip_ecn_tm
,
2281 (void *)&cmd_port_tm_mark_ip_ecn_mark
,
2282 (void *)&cmd_port_tm_mark_ip_ecn_ip_ecn
,
2283 (void *)&cmd_port_tm_mark_ip_ecn_port_id
,
2284 (void *)&cmd_port_tm_mark_ip_ecn_green
,
2285 (void *)&cmd_port_tm_mark_ip_ecn_yellow
,
2286 (void *)&cmd_port_tm_mark_ip_ecn_red
,
2292 /* *** Port TM Mark IP DSCP *** */
2293 struct cmd_port_tm_mark_ip_dscp_result
{
2294 cmdline_fixed_string_t set
;
2295 cmdline_fixed_string_t port
;
2296 cmdline_fixed_string_t tm
;
2297 cmdline_fixed_string_t mark
;
2298 cmdline_fixed_string_t ip_dscp
;
2305 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_set
=
2306 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result
,
2309 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_port
=
2310 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result
,
2313 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_tm
=
2314 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result
, tm
,
2317 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_mark
=
2318 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result
,
2321 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_ip_dscp
=
2322 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result
,
2323 ip_dscp
, "ip_dscp");
2324 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_port_id
=
2325 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result
,
2328 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_green
=
2329 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result
,
2331 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_yellow
=
2332 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result
,
2334 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_red
=
2335 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result
,
2338 static void cmd_port_tm_mark_ip_dscp_parsed(void *parsed_result
,
2339 __attribute__((unused
)) struct cmdline
*cl
,
2340 __attribute__((unused
)) void *data
)
2342 struct cmd_port_tm_mark_ip_dscp_result
*res
= parsed_result
;
2343 struct rte_tm_error error
;
2344 portid_t port_id
= res
->port_id
;
2345 int green
= res
->green
;
2346 int yellow
= res
->yellow
;
2349 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
2352 memset(&error
, 0, sizeof(struct rte_tm_error
));
2353 ret
= rte_tm_mark_ip_dscp(port_id
, green
, yellow
, red
, &error
);
2355 print_err_msg(&error
);
2360 cmdline_parse_inst_t cmd_port_tm_mark_ip_dscp
= {
2361 .f
= cmd_port_tm_mark_ip_dscp_parsed
,
2363 .help_str
= "set port tm mark ip_dscp <port> <green> <yellow> <red>",
2365 (void *)&cmd_port_tm_mark_ip_dscp_set
,
2366 (void *)&cmd_port_tm_mark_ip_dscp_port
,
2367 (void *)&cmd_port_tm_mark_ip_dscp_tm
,
2368 (void *)&cmd_port_tm_mark_ip_dscp_mark
,
2369 (void *)&cmd_port_tm_mark_ip_dscp_ip_dscp
,
2370 (void *)&cmd_port_tm_mark_ip_dscp_port_id
,
2371 (void *)&cmd_port_tm_mark_ip_dscp_green
,
2372 (void *)&cmd_port_tm_mark_ip_dscp_yellow
,
2373 (void *)&cmd_port_tm_mark_ip_dscp_red
,
2379 /* *** Port TM Mark VLAN_DEI *** */
2380 struct cmd_port_tm_mark_vlan_dei_result
{
2381 cmdline_fixed_string_t set
;
2382 cmdline_fixed_string_t port
;
2383 cmdline_fixed_string_t tm
;
2384 cmdline_fixed_string_t mark
;
2385 cmdline_fixed_string_t vlan_dei
;
2392 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_set
=
2393 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result
,
2396 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_port
=
2397 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result
,
2400 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_tm
=
2401 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result
, tm
,
2404 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_mark
=
2405 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result
,
2408 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_vlan_dei
=
2409 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result
,
2410 vlan_dei
, "vlan_dei");
2411 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_port_id
=
2412 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result
,
2415 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_green
=
2416 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result
,
2418 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_yellow
=
2419 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result
,
2421 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_red
=
2422 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result
,
2425 static void cmd_port_tm_mark_vlan_dei_parsed(void *parsed_result
,
2426 __attribute__((unused
)) struct cmdline
*cl
,
2427 __attribute__((unused
)) void *data
)
2429 struct cmd_port_tm_mark_vlan_dei_result
*res
= parsed_result
;
2430 struct rte_tm_error error
;
2431 portid_t port_id
= res
->port_id
;
2432 int green
= res
->green
;
2433 int yellow
= res
->yellow
;
2436 if (port_id_is_invalid(port_id
, ENABLED_WARN
))
2439 memset(&error
, 0, sizeof(struct rte_tm_error
));
2440 ret
= rte_tm_mark_vlan_dei(port_id
, green
, yellow
, red
, &error
);
2442 print_err_msg(&error
);
2447 cmdline_parse_inst_t cmd_port_tm_mark_vlan_dei
= {
2448 .f
= cmd_port_tm_mark_vlan_dei_parsed
,
2450 .help_str
= "set port tm mark vlan_dei <port> <green> <yellow> <red>",
2452 (void *)&cmd_port_tm_mark_vlan_dei_set
,
2453 (void *)&cmd_port_tm_mark_vlan_dei_port
,
2454 (void *)&cmd_port_tm_mark_vlan_dei_tm
,
2455 (void *)&cmd_port_tm_mark_vlan_dei_mark
,
2456 (void *)&cmd_port_tm_mark_vlan_dei_vlan_dei
,
2457 (void *)&cmd_port_tm_mark_vlan_dei_port_id
,
2458 (void *)&cmd_port_tm_mark_vlan_dei_green
,
2459 (void *)&cmd_port_tm_mark_vlan_dei_yellow
,
2460 (void *)&cmd_port_tm_mark_vlan_dei_red
,