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_PACKET_MODE]
58 = "packet mode field (shaper profile)",
59 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID] = "shaper profile id",
60 [RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID] = "shared shaper id",
61 [RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID] = "parent node id",
62 [RTE_TM_ERROR_TYPE_NODE_PRIORITY] = "node priority",
63 [RTE_TM_ERROR_TYPE_NODE_WEIGHT] = "node weight",
64 [RTE_TM_ERROR_TYPE_NODE_PARAMS] = "node parameter null",
65 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID]
66 = "shaper profile id field (node params)",
67 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID]
68 = "shared shaper id field (node params)",
69 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS]
70 = "num shared shapers field (node params)",
71 [RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE]
72 = "wfq weght mode field (node params)",
73 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES]
74 = "num strict priorities field (node params)",
75 [RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN]
76 = "congestion management mode field (node params)",
77 [RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID] =
78 "wred profile id field (node params)",
79 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID]
80 = "shared wred context id field (node params)",
81 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS]
82 = "num shared wred contexts field (node params)",
83 [RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS]
84 = "stats field (node params)",
85 [RTE_TM_ERROR_TYPE_NODE_ID] = "node id",
91 if ((unsigned int)error->type >= RTE_DIM(errstrlist) ||
92 !errstrlist[error->type])
93 errstr = "unknown type";
95 errstr = errstrlist[error->type];
98 snprintf(buf, sizeof(buf), "cause: %p, ", error->cause);
100 printf("%s: %s%s (error %d)\n", errstr, error->cause ? buf : "",
101 error->message ? error->message : "(no stated reason)",
106 read_uint64(uint64_t *value, const char *p)
111 p = skip_white_spaces(p);
115 val = strtoul(p, &next, 10);
137 p = skip_white_spaces(p);
146 read_uint32(uint32_t *value, const char *p)
149 int ret = read_uint64(&val, p);
154 if (val > UINT32_MAX)
162 parse_multi_ss_id_str(char *s_str, uint32_t *n_ssp, uint32_t shaper_id[])
164 uint32_t n_shared_shapers = 0, i = 0;
167 /* First token: num of shared shapers */
168 token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
172 if (read_uint32(&n_shared_shapers, token))
175 /* Check: num of shared shaper */
176 if (n_shared_shapers >= MAX_NUM_SHARED_SHAPERS) {
177 printf(" Number of shared shapers exceed the max (error)\n");
181 /* Parse shared shaper ids */
183 token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
184 if ((token != NULL && n_shared_shapers == 0) ||
185 (token == NULL && i < n_shared_shapers))
191 if (read_uint32(&shaper_id[i], token))
195 *n_ssp = n_shared_shapers;
199 /* *** Port TM Capability *** */
200 struct cmd_show_port_tm_cap_result {
201 cmdline_fixed_string_t show;
202 cmdline_fixed_string_t port;
203 cmdline_fixed_string_t tm;
204 cmdline_fixed_string_t cap;
208 cmdline_parse_token_string_t cmd_show_port_tm_cap_show =
209 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
211 cmdline_parse_token_string_t cmd_show_port_tm_cap_port =
212 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
214 cmdline_parse_token_string_t cmd_show_port_tm_cap_tm =
215 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
217 cmdline_parse_token_string_t cmd_show_port_tm_cap_cap =
218 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
220 cmdline_parse_token_num_t cmd_show_port_tm_cap_port_id =
221 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_cap_result,
222 port_id, RTE_UINT16);
224 static void cmd_show_port_tm_cap_parsed(void *parsed_result,
225 __rte_unused struct cmdline *cl,
226 __rte_unused void *data)
228 struct cmd_show_port_tm_cap_result *res = parsed_result;
229 struct rte_tm_capabilities cap;
230 struct rte_tm_error error;
231 portid_t port_id = res->port_id;
235 if (port_id_is_invalid(port_id, ENABLED_WARN))
238 memset(&cap, 0, sizeof(struct rte_tm_capabilities));
239 memset(&error, 0, sizeof(struct rte_tm_error));
240 ret = rte_tm_capabilities_get(port_id, &cap, &error);
242 print_err_msg(&error);
246 printf("\n**** Port TM Capabilities ****\n\n");
247 printf("cap.n_nodes_max %" PRIu32 "\n", cap.n_nodes_max);
248 printf("cap.n_levels_max %" PRIu32 "\n", cap.n_levels_max);
249 printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
250 cap.non_leaf_nodes_identical);
251 printf("cap.leaf_nodes_identical %" PRId32 "\n",
252 cap.leaf_nodes_identical);
253 printf("cap.shaper_n_max %u\n", cap.shaper_n_max);
254 printf("cap.shaper_private_n_max %" PRIu32 "\n",
255 cap.shaper_private_n_max);
256 printf("cap.shaper_private_dual_rate_n_max %" PRId32 "\n",
257 cap.shaper_private_dual_rate_n_max);
258 printf("cap.shaper_private_rate_min %" PRIu64 "\n",
259 cap.shaper_private_rate_min);
260 printf("cap.shaper_private_rate_max %" PRIu64 "\n",
261 cap.shaper_private_rate_max);
262 printf("cap.shaper_private_packet_mode_supported %" PRId32 "\n",
263 cap.shaper_private_packet_mode_supported);
264 printf("cap.shaper_private_byte_mode_supported %" PRId32 "\n",
265 cap.shaper_private_byte_mode_supported);
266 printf("cap.shaper_shared_n_max %" PRIu32 "\n",
267 cap.shaper_shared_n_max);
268 printf("cap.shaper_shared_n_nodes_per_shaper_max %" PRIu32 "\n",
269 cap.shaper_shared_n_nodes_per_shaper_max);
270 printf("cap.shaper_shared_n_shapers_per_node_max %" PRIu32 "\n",
271 cap.shaper_shared_n_shapers_per_node_max);
272 printf("cap.shaper_shared_dual_rate_n_max %" PRIu32 "\n",
273 cap.shaper_shared_dual_rate_n_max);
274 printf("cap.shaper_shared_rate_min %" PRIu64 "\n",
275 cap.shaper_shared_rate_min);
276 printf("cap.shaper_shared_rate_max %" PRIu64 "\n",
277 cap.shaper_shared_rate_max);
278 printf("cap.shaper_shared_packet_mode_supported %" PRId32 "\n",
279 cap.shaper_shared_packet_mode_supported);
280 printf("cap.shaper_shared_byte_mode_supported %" PRId32 "\n",
281 cap.shaper_shared_byte_mode_supported);
282 printf("cap.shaper_pkt_length_adjust_min %" PRId32 "\n",
283 cap.shaper_pkt_length_adjust_min);
284 printf("cap.shaper_pkt_length_adjust_max %" PRId32 "\n",
285 cap.shaper_pkt_length_adjust_max);
286 printf("cap.sched_n_children_max %" PRIu32 "\n",
287 cap.sched_n_children_max);
288 printf("cap.sched_sp_n_priorities_max %" PRIu32 "\n",
289 cap.sched_sp_n_priorities_max);
290 printf("cap.sched_wfq_n_children_per_group_max %" PRIu32 "\n",
291 cap.sched_wfq_n_children_per_group_max);
292 printf("cap.sched_wfq_n_groups_max %" PRIu32 "\n",
293 cap.sched_wfq_n_groups_max);
294 printf("cap.sched_wfq_weight_max %" PRIu32 "\n",
295 cap.sched_wfq_weight_max);
296 printf("cap.sched_wfq_packet_mode_supported %" PRId32 "\n",
297 cap.sched_wfq_packet_mode_supported);
298 printf("cap.sched_wfq_byte_mode_supported %" PRId32 "\n",
299 cap.sched_wfq_byte_mode_supported);
300 printf("cap.cman_head_drop_supported %" PRId32 "\n",
301 cap.cman_head_drop_supported);
302 printf("cap.cman_wred_context_n_max %" PRIu32 "\n",
303 cap.cman_wred_context_n_max);
304 printf("cap.cman_wred_context_private_n_max %" PRIu32 "\n",
305 cap.cman_wred_context_private_n_max);
306 printf("cap.cman_wred_context_shared_n_max %" PRIu32 "\n",
307 cap.cman_wred_context_shared_n_max);
308 printf("cap.cman_wred_context_shared_n_nodes_per_context_max %" PRIu32
309 "\n", cap.cman_wred_context_shared_n_nodes_per_context_max);
310 printf("cap.cman_wred_context_shared_n_contexts_per_node_max %" PRIu32
311 "\n", cap.cman_wred_context_shared_n_contexts_per_node_max);
313 for (i = 0; i < RTE_COLORS; i++) {
314 printf("cap.mark_vlan_dei_supported %" PRId32 "\n",
315 cap.mark_vlan_dei_supported[i]);
316 printf("cap.mark_ip_ecn_tcp_supported %" PRId32 "\n",
317 cap.mark_ip_ecn_tcp_supported[i]);
318 printf("cap.mark_ip_ecn_sctp_supported %" PRId32 "\n",
319 cap.mark_ip_ecn_sctp_supported[i]);
320 printf("cap.mark_ip_dscp_supported %" PRId32 "\n",
321 cap.mark_ip_dscp_supported[i]);
324 printf("cap.dynamic_update_mask %" PRIx64 "\n",
325 cap.dynamic_update_mask);
326 printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
329 cmdline_parse_inst_t cmd_show_port_tm_cap = {
330 .f = cmd_show_port_tm_cap_parsed,
332 .help_str = "Show Port TM Capabilities",
334 (void *)&cmd_show_port_tm_cap_show,
335 (void *)&cmd_show_port_tm_cap_port,
336 (void *)&cmd_show_port_tm_cap_tm,
337 (void *)&cmd_show_port_tm_cap_cap,
338 (void *)&cmd_show_port_tm_cap_port_id,
343 /* *** Port TM Hierarchical Level Capability *** */
344 struct cmd_show_port_tm_level_cap_result {
345 cmdline_fixed_string_t show;
346 cmdline_fixed_string_t port;
347 cmdline_fixed_string_t tm;
348 cmdline_fixed_string_t level;
349 cmdline_fixed_string_t cap;
354 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_show =
355 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
357 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_port =
358 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
360 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_tm =
361 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
363 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_level =
364 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
366 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_cap =
367 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
369 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_port_id =
370 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
371 port_id, RTE_UINT16);
372 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_level_id =
373 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
374 level_id, RTE_UINT32);
377 static void cmd_show_port_tm_level_cap_parsed(void *parsed_result,
378 __rte_unused struct cmdline *cl,
379 __rte_unused void *data)
381 struct cmd_show_port_tm_level_cap_result *res = parsed_result;
382 struct rte_tm_level_capabilities lcap;
383 struct rte_tm_error error;
384 portid_t port_id = res->port_id;
385 uint32_t level_id = res->level_id;
388 if (port_id_is_invalid(port_id, ENABLED_WARN))
391 memset(&lcap, 0, sizeof(struct rte_tm_level_capabilities));
392 memset(&error, 0, sizeof(struct rte_tm_error));
393 ret = rte_tm_level_capabilities_get(port_id, level_id, &lcap, &error);
395 print_err_msg(&error);
398 printf("\n** Port TM Hierarchy level %" PRIu32 " Capability **\n\n",
401 printf("cap.n_nodes_max %" PRIu32 "\n", lcap.n_nodes_max);
402 printf("cap.n_nodes_nonleaf_max %" PRIu32 "\n",
403 lcap.n_nodes_nonleaf_max);
404 printf("cap.n_nodes_leaf_max %" PRIu32 "\n", lcap.n_nodes_leaf_max);
405 printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
406 lcap.non_leaf_nodes_identical);
407 printf("cap.leaf_nodes_identical %" PRId32 "\n",
408 lcap.leaf_nodes_identical);
410 printf("cap.nonleaf.shaper_private_supported %" PRId32 "\n",
411 lcap.nonleaf.shaper_private_supported);
412 printf("cap.nonleaf.shaper_private_dual_rate_supported %" PRId32
413 "\n", lcap.nonleaf.shaper_private_dual_rate_supported);
414 printf("cap.nonleaf.shaper_private_rate_min %" PRIu64 "\n",
415 lcap.nonleaf.shaper_private_rate_min);
416 printf("cap.nonleaf.shaper_private_rate_max %" PRIu64 "\n",
417 lcap.nonleaf.shaper_private_rate_max);
418 printf("cap.nonleaf.shaper_private_packet_mode_supported %"
420 lcap.nonleaf.shaper_private_packet_mode_supported);
421 printf("cap.nonleaf.shaper_private_byte_mode_supported %" PRId32
422 "\n", lcap.nonleaf.shaper_private_byte_mode_supported);
423 printf("cap.nonleaf.shaper_shared_n_max %" PRIu32 "\n",
424 lcap.nonleaf.shaper_shared_n_max);
425 printf("cap.nonleaf.shaper_shared_packet_mode_supported %"
427 lcap.nonleaf.shaper_shared_packet_mode_supported);
428 printf("cap.nonleaf.shaper_shared_byte_mode_supported %"
430 lcap.nonleaf.shaper_shared_byte_mode_supported);
431 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
432 lcap.nonleaf.sched_n_children_max);
433 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
434 lcap.nonleaf.sched_sp_n_priorities_max);
435 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
436 "\n", lcap.nonleaf.sched_wfq_n_children_per_group_max);
437 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
438 lcap.nonleaf.sched_wfq_n_groups_max);
439 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
440 lcap.nonleaf.sched_wfq_weight_max);
441 printf("cap.nonleaf.sched_wfq_packet_mode_supported %" PRId32 "\n",
442 lcap.nonleaf.sched_wfq_packet_mode_supported);
443 printf("cap.nonleaf.sched_wfq_byte_mode_supported %" PRId32
444 "\n", lcap.nonleaf.sched_wfq_byte_mode_supported);
445 printf("cap.nonleaf.stats_mask %" PRIx64 "\n",
446 lcap.nonleaf.stats_mask);
448 printf("cap.leaf.shaper_private_supported %" PRId32 "\n",
449 lcap.leaf.shaper_private_supported);
450 printf("cap.leaf.shaper_private_dual_rate_supported %" PRId32
451 "\n", lcap.leaf.shaper_private_dual_rate_supported);
452 printf("cap.leaf.shaper_private_rate_min %" PRIu64 "\n",
453 lcap.leaf.shaper_private_rate_min);
454 printf("cap.leaf.shaper_private_rate_max %" PRIu64 "\n",
455 lcap.leaf.shaper_private_rate_max);
456 printf("cap.leaf.shaper_private_packet_mode_supported %" PRId32
457 "\n", lcap.leaf.shaper_private_packet_mode_supported);
458 printf("cap.leaf.shaper_private_byte_mode_supported %" PRId32 "\n",
459 lcap.leaf.shaper_private_byte_mode_supported);
460 printf("cap.leaf.shaper_shared_n_max %" PRIu32 "\n",
461 lcap.leaf.shaper_shared_n_max);
462 printf("cap.leaf.shaper_shared_packet_mode_supported %" PRId32 "\n",
463 lcap.leaf.shaper_shared_packet_mode_supported);
464 printf("cap.leaf.shaper_shared_byte_mode_supported %" PRId32 "\n",
465 lcap.leaf.shaper_shared_byte_mode_supported);
466 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
467 lcap.leaf.cman_head_drop_supported);
468 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
469 "\n", lcap.leaf.cman_wred_context_private_supported);
470 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
471 lcap.leaf.cman_wred_context_shared_n_max);
472 printf("cap.leaf.stats_mask %" PRIx64 "\n",
473 lcap.leaf.stats_mask);
477 cmdline_parse_inst_t cmd_show_port_tm_level_cap = {
478 .f = cmd_show_port_tm_level_cap_parsed,
480 .help_str = "Show Port TM Hierarhical level Capabilities",
482 (void *)&cmd_show_port_tm_level_cap_show,
483 (void *)&cmd_show_port_tm_level_cap_port,
484 (void *)&cmd_show_port_tm_level_cap_tm,
485 (void *)&cmd_show_port_tm_level_cap_level,
486 (void *)&cmd_show_port_tm_level_cap_cap,
487 (void *)&cmd_show_port_tm_level_cap_port_id,
488 (void *)&cmd_show_port_tm_level_cap_level_id,
493 /* *** Port TM Hierarchy Node Capability *** */
494 struct cmd_show_port_tm_node_cap_result {
495 cmdline_fixed_string_t show;
496 cmdline_fixed_string_t port;
497 cmdline_fixed_string_t tm;
498 cmdline_fixed_string_t node;
499 cmdline_fixed_string_t cap;
504 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_show =
505 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
507 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_port =
508 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
510 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_tm =
511 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
513 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_node =
514 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
516 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_cap =
517 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
519 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_port_id =
520 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
521 port_id, RTE_UINT16);
522 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_node_id =
523 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
524 node_id, RTE_UINT32);
526 static void cmd_show_port_tm_node_cap_parsed(void *parsed_result,
527 __rte_unused struct cmdline *cl,
528 __rte_unused void *data)
530 struct cmd_show_port_tm_node_cap_result *res = parsed_result;
531 struct rte_tm_node_capabilities ncap;
532 struct rte_tm_error error;
533 uint32_t node_id = res->node_id;
534 portid_t port_id = res->port_id;
535 int ret, is_leaf = 0;
537 if (port_id_is_invalid(port_id, ENABLED_WARN))
540 memset(&error, 0, sizeof(struct rte_tm_error));
541 /* Node id must be valid */
542 ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
544 print_err_msg(&error);
548 memset(&ncap, 0, sizeof(struct rte_tm_node_capabilities));
549 ret = rte_tm_node_capabilities_get(port_id, node_id, &ncap, &error);
551 print_err_msg(&error);
554 printf("\n** Port TM Hierarchy node %" PRIu32 " Capability **\n\n",
556 printf("cap.shaper_private_supported %" PRId32 "\n",
557 ncap.shaper_private_supported);
558 printf("cap.shaper_private_dual_rate_supported %" PRId32 "\n",
559 ncap.shaper_private_dual_rate_supported);
560 printf("cap.shaper_private_rate_min %" PRIu64 "\n",
561 ncap.shaper_private_rate_min);
562 printf("cap.shaper_private_rate_max %" PRIu64 "\n",
563 ncap.shaper_private_rate_max);
564 printf("cap.shaper_private_packet_mode_supported %" PRId32 "\n",
565 ncap.shaper_private_packet_mode_supported);
566 printf("cap.shaper_private_byte_mode_supported %" PRId32 "\n",
567 ncap.shaper_private_byte_mode_supported);
568 printf("cap.shaper_shared_n_max %" PRIu32 "\n",
569 ncap.shaper_shared_n_max);
570 printf("cap.shaper_shared_packet_mode_supported %" PRId32 "\n",
571 ncap.shaper_shared_packet_mode_supported);
572 printf("cap.shaper_shared_byte_mode_supported %" PRId32 "\n",
573 ncap.shaper_shared_byte_mode_supported);
575 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
576 ncap.nonleaf.sched_n_children_max);
577 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
578 ncap.nonleaf.sched_sp_n_priorities_max);
579 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
580 "\n", ncap.nonleaf.sched_wfq_n_children_per_group_max);
581 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
582 ncap.nonleaf.sched_wfq_n_groups_max);
583 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
584 ncap.nonleaf.sched_wfq_weight_max);
585 printf("cap.nonleaf.sched_wfq_packet_mode_supported %" PRId32 "\n",
586 ncap.nonleaf.sched_wfq_packet_mode_supported);
587 printf("cap.nonleaf.sched_wfq_byte_mode_supported %" PRId32 "\n",
588 ncap.nonleaf.sched_wfq_byte_mode_supported);
590 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
591 ncap.leaf.cman_head_drop_supported);
592 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
593 "\n", ncap.leaf.cman_wred_context_private_supported);
594 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
595 ncap.leaf.cman_wred_context_shared_n_max);
597 printf("cap.stats_mask %" PRIx64 "\n", ncap.stats_mask);
600 cmdline_parse_inst_t cmd_show_port_tm_node_cap = {
601 .f = cmd_show_port_tm_node_cap_parsed,
603 .help_str = "Show Port TM Hierarchy node capabilities",
605 (void *)&cmd_show_port_tm_node_cap_show,
606 (void *)&cmd_show_port_tm_node_cap_port,
607 (void *)&cmd_show_port_tm_node_cap_tm,
608 (void *)&cmd_show_port_tm_node_cap_node,
609 (void *)&cmd_show_port_tm_node_cap_cap,
610 (void *)&cmd_show_port_tm_node_cap_port_id,
611 (void *)&cmd_show_port_tm_node_cap_node_id,
616 /* *** Show Port TM Node Statistics *** */
617 struct cmd_show_port_tm_node_stats_result {
618 cmdline_fixed_string_t show;
619 cmdline_fixed_string_t port;
620 cmdline_fixed_string_t tm;
621 cmdline_fixed_string_t node;
622 cmdline_fixed_string_t stats;
628 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_show =
629 TOKEN_STRING_INITIALIZER(
630 struct cmd_show_port_tm_node_stats_result, show, "show");
631 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_port =
632 TOKEN_STRING_INITIALIZER(
633 struct cmd_show_port_tm_node_stats_result, port, "port");
634 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_tm =
635 TOKEN_STRING_INITIALIZER(
636 struct cmd_show_port_tm_node_stats_result, tm, "tm");
637 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_node =
638 TOKEN_STRING_INITIALIZER(
639 struct cmd_show_port_tm_node_stats_result, node, "node");
640 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_stats =
641 TOKEN_STRING_INITIALIZER(
642 struct cmd_show_port_tm_node_stats_result, stats, "stats");
643 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_port_id =
644 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_stats_result,
645 port_id, RTE_UINT16);
646 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_node_id =
647 TOKEN_NUM_INITIALIZER(
648 struct cmd_show_port_tm_node_stats_result,
649 node_id, RTE_UINT32);
650 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_clear =
651 TOKEN_NUM_INITIALIZER(
652 struct cmd_show_port_tm_node_stats_result, clear, RTE_UINT32);
654 static void cmd_show_port_tm_node_stats_parsed(void *parsed_result,
655 __rte_unused struct cmdline *cl,
656 __rte_unused void *data)
658 struct cmd_show_port_tm_node_stats_result *res = parsed_result;
659 struct rte_tm_node_stats stats;
660 struct rte_tm_error error;
661 uint64_t stats_mask = 0;
662 uint32_t node_id = res->node_id;
663 uint32_t clear = res->clear;
664 portid_t port_id = res->port_id;
667 if (port_id_is_invalid(port_id, ENABLED_WARN))
670 memset(&error, 0, sizeof(struct rte_tm_error));
672 if (!port_is_started(port_id)) {
673 printf(" Port %u not started (error)\n", port_id);
677 memset(&stats, 0, sizeof(struct rte_tm_node_stats));
678 ret = rte_tm_node_stats_read(port_id, node_id, &stats,
679 &stats_mask, clear, &error);
681 print_err_msg(&error);
686 if (stats_mask & RTE_TM_STATS_N_PKTS)
687 printf("\tPkts scheduled from node: %" PRIu64 "\n",
689 if (stats_mask & RTE_TM_STATS_N_BYTES)
690 printf("\tBytes scheduled from node: %" PRIu64 "\n",
692 if (stats_mask & RTE_TM_STATS_N_PKTS_GREEN_DROPPED)
693 printf("\tPkts dropped (green): %" PRIu64 "\n",
694 stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN]);
695 if (stats_mask & RTE_TM_STATS_N_PKTS_YELLOW_DROPPED)
696 printf("\tPkts dropped (yellow): %" PRIu64 "\n",
697 stats.leaf.n_pkts_dropped[RTE_COLOR_YELLOW]);
698 if (stats_mask & RTE_TM_STATS_N_PKTS_RED_DROPPED)
699 printf("\tPkts dropped (red): %" PRIu64 "\n",
700 stats.leaf.n_pkts_dropped[RTE_COLOR_RED]);
701 if (stats_mask & RTE_TM_STATS_N_BYTES_GREEN_DROPPED)
702 printf("\tBytes dropped (green): %" PRIu64 "\n",
703 stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN]);
704 if (stats_mask & RTE_TM_STATS_N_BYTES_YELLOW_DROPPED)
705 printf("\tBytes dropped (yellow): %" PRIu64 "\n",
706 stats.leaf.n_bytes_dropped[RTE_COLOR_YELLOW]);
707 if (stats_mask & RTE_TM_STATS_N_BYTES_RED_DROPPED)
708 printf("\tBytes dropped (red): %" PRIu64 "\n",
709 stats.leaf.n_bytes_dropped[RTE_COLOR_RED]);
710 if (stats_mask & RTE_TM_STATS_N_PKTS_QUEUED)
711 printf("\tPkts queued: %" PRIu64 "\n",
712 stats.leaf.n_pkts_queued);
713 if (stats_mask & RTE_TM_STATS_N_BYTES_QUEUED)
714 printf("\tBytes queued: %" PRIu64 "\n",
715 stats.leaf.n_bytes_queued);
718 cmdline_parse_inst_t cmd_show_port_tm_node_stats = {
719 .f = cmd_show_port_tm_node_stats_parsed,
721 .help_str = "Show port tm node stats",
723 (void *)&cmd_show_port_tm_node_stats_show,
724 (void *)&cmd_show_port_tm_node_stats_port,
725 (void *)&cmd_show_port_tm_node_stats_tm,
726 (void *)&cmd_show_port_tm_node_stats_node,
727 (void *)&cmd_show_port_tm_node_stats_stats,
728 (void *)&cmd_show_port_tm_node_stats_port_id,
729 (void *)&cmd_show_port_tm_node_stats_node_id,
730 (void *)&cmd_show_port_tm_node_stats_clear,
735 /* *** Show Port TM Node Type *** */
736 struct cmd_show_port_tm_node_type_result {
737 cmdline_fixed_string_t show;
738 cmdline_fixed_string_t port;
739 cmdline_fixed_string_t tm;
740 cmdline_fixed_string_t node;
741 cmdline_fixed_string_t type;
746 cmdline_parse_token_string_t cmd_show_port_tm_node_type_show =
747 TOKEN_STRING_INITIALIZER(
748 struct cmd_show_port_tm_node_type_result, show, "show");
749 cmdline_parse_token_string_t cmd_show_port_tm_node_type_port =
750 TOKEN_STRING_INITIALIZER(
751 struct cmd_show_port_tm_node_type_result, port, "port");
752 cmdline_parse_token_string_t cmd_show_port_tm_node_type_tm =
753 TOKEN_STRING_INITIALIZER(
754 struct cmd_show_port_tm_node_type_result, tm, "tm");
755 cmdline_parse_token_string_t cmd_show_port_tm_node_type_node =
756 TOKEN_STRING_INITIALIZER(
757 struct cmd_show_port_tm_node_type_result, node, "node");
758 cmdline_parse_token_string_t cmd_show_port_tm_node_type_type =
759 TOKEN_STRING_INITIALIZER(
760 struct cmd_show_port_tm_node_type_result, type, "type");
761 cmdline_parse_token_num_t cmd_show_port_tm_node_type_port_id =
762 TOKEN_NUM_INITIALIZER(
763 struct cmd_show_port_tm_node_type_result,
764 port_id, RTE_UINT16);
765 cmdline_parse_token_num_t cmd_show_port_tm_node_type_node_id =
766 TOKEN_NUM_INITIALIZER(
767 struct cmd_show_port_tm_node_type_result,
768 node_id, RTE_UINT32);
770 static void cmd_show_port_tm_node_type_parsed(void *parsed_result,
771 __rte_unused struct cmdline *cl,
772 __rte_unused void *data)
774 struct cmd_show_port_tm_node_type_result *res = parsed_result;
775 struct rte_tm_error error;
776 uint32_t node_id = res->node_id;
777 portid_t port_id = res->port_id;
778 int ret, is_leaf = 0;
780 if (port_id_is_invalid(port_id, ENABLED_WARN))
783 memset(&error, 0, sizeof(struct rte_tm_error));
784 ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
786 print_err_msg(&error);
791 printf("leaf node\n");
793 printf("nonleaf node\n");
797 cmdline_parse_inst_t cmd_show_port_tm_node_type = {
798 .f = cmd_show_port_tm_node_type_parsed,
800 .help_str = "Show port tm node type",
802 (void *)&cmd_show_port_tm_node_type_show,
803 (void *)&cmd_show_port_tm_node_type_port,
804 (void *)&cmd_show_port_tm_node_type_tm,
805 (void *)&cmd_show_port_tm_node_type_node,
806 (void *)&cmd_show_port_tm_node_type_type,
807 (void *)&cmd_show_port_tm_node_type_port_id,
808 (void *)&cmd_show_port_tm_node_type_node_id,
813 /* *** Add Port TM Private Shaper Profile *** */
814 struct cmd_add_port_tm_node_shaper_profile_result {
815 cmdline_fixed_string_t add;
816 cmdline_fixed_string_t port;
817 cmdline_fixed_string_t tm;
818 cmdline_fixed_string_t node;
819 cmdline_fixed_string_t shaper;
820 cmdline_fixed_string_t profile;
823 uint64_t cmit_tb_rate;
824 uint64_t cmit_tb_size;
825 uint64_t peak_tb_rate;
826 uint64_t peak_tb_size;
827 uint32_t pktlen_adjust;
831 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add =
832 TOKEN_STRING_INITIALIZER(
833 struct cmd_add_port_tm_node_shaper_profile_result, add, "add");
834 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port =
835 TOKEN_STRING_INITIALIZER(
836 struct cmd_add_port_tm_node_shaper_profile_result,
838 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm =
839 TOKEN_STRING_INITIALIZER(
840 struct cmd_add_port_tm_node_shaper_profile_result,
842 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node =
843 TOKEN_STRING_INITIALIZER(
844 struct cmd_add_port_tm_node_shaper_profile_result,
846 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper =
847 TOKEN_STRING_INITIALIZER(
848 struct cmd_add_port_tm_node_shaper_profile_result,
850 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile =
851 TOKEN_STRING_INITIALIZER(
852 struct cmd_add_port_tm_node_shaper_profile_result,
854 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id =
855 TOKEN_NUM_INITIALIZER(
856 struct cmd_add_port_tm_node_shaper_profile_result,
857 port_id, RTE_UINT16);
858 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id =
859 TOKEN_NUM_INITIALIZER(
860 struct cmd_add_port_tm_node_shaper_profile_result,
861 shaper_id, RTE_UINT32);
862 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_rate =
863 TOKEN_NUM_INITIALIZER(
864 struct cmd_add_port_tm_node_shaper_profile_result,
865 cmit_tb_rate, RTE_UINT64);
866 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_size =
867 TOKEN_NUM_INITIALIZER(
868 struct cmd_add_port_tm_node_shaper_profile_result,
869 cmit_tb_size, RTE_UINT64);
870 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_rate =
871 TOKEN_NUM_INITIALIZER(
872 struct cmd_add_port_tm_node_shaper_profile_result,
873 peak_tb_rate, RTE_UINT64);
874 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_size =
875 TOKEN_NUM_INITIALIZER(
876 struct cmd_add_port_tm_node_shaper_profile_result,
877 peak_tb_size, RTE_UINT64);
878 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust =
879 TOKEN_NUM_INITIALIZER(
880 struct cmd_add_port_tm_node_shaper_profile_result,
881 pktlen_adjust, RTE_UINT32);
882 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_packet_mode =
883 TOKEN_NUM_INITIALIZER(
884 struct cmd_add_port_tm_node_shaper_profile_result,
885 pkt_mode, RTE_UINT32);
887 static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
888 __rte_unused struct cmdline *cl,
889 __rte_unused void *data)
891 struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result;
892 struct rte_tm_shaper_params sp;
893 struct rte_tm_error error;
894 uint32_t shaper_id = res->shaper_id;
895 uint32_t pkt_len_adjust = res->pktlen_adjust;
896 portid_t port_id = res->port_id;
899 if (port_id_is_invalid(port_id, ENABLED_WARN))
902 /* Private shaper profile params */
903 memset(&sp, 0, sizeof(struct rte_tm_shaper_params));
904 memset(&error, 0, sizeof(struct rte_tm_error));
905 sp.committed.rate = res->cmit_tb_rate;
906 sp.committed.size = res->cmit_tb_size;
907 sp.peak.rate = res->peak_tb_rate;
908 sp.peak.size = res->peak_tb_size;
909 sp.pkt_length_adjust = pkt_len_adjust;
910 sp.packet_mode = res->pkt_mode;
912 ret = rte_tm_shaper_profile_add(port_id, shaper_id, &sp, &error);
914 print_err_msg(&error);
919 cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile = {
920 .f = cmd_add_port_tm_node_shaper_profile_parsed,
922 .help_str = "Add port tm node private shaper profile",
924 (void *)&cmd_add_port_tm_node_shaper_profile_add,
925 (void *)&cmd_add_port_tm_node_shaper_profile_port,
926 (void *)&cmd_add_port_tm_node_shaper_profile_tm,
927 (void *)&cmd_add_port_tm_node_shaper_profile_node,
928 (void *)&cmd_add_port_tm_node_shaper_profile_shaper,
929 (void *)&cmd_add_port_tm_node_shaper_profile_profile,
930 (void *)&cmd_add_port_tm_node_shaper_profile_port_id,
931 (void *)&cmd_add_port_tm_node_shaper_profile_shaper_id,
932 (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_rate,
933 (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_size,
934 (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_rate,
935 (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_size,
936 (void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust,
937 (void *)&cmd_add_port_tm_node_shaper_profile_packet_mode,
942 /* *** Delete Port TM Private Shaper Profile *** */
943 struct cmd_del_port_tm_node_shaper_profile_result {
944 cmdline_fixed_string_t del;
945 cmdline_fixed_string_t port;
946 cmdline_fixed_string_t tm;
947 cmdline_fixed_string_t node;
948 cmdline_fixed_string_t shaper;
949 cmdline_fixed_string_t profile;
954 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del =
955 TOKEN_STRING_INITIALIZER(
956 struct cmd_del_port_tm_node_shaper_profile_result, del, "del");
957 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port =
958 TOKEN_STRING_INITIALIZER(
959 struct cmd_del_port_tm_node_shaper_profile_result,
961 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm =
962 TOKEN_STRING_INITIALIZER(
963 struct cmd_del_port_tm_node_shaper_profile_result, tm, "tm");
964 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node =
965 TOKEN_STRING_INITIALIZER(
966 struct cmd_del_port_tm_node_shaper_profile_result,
968 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper =
969 TOKEN_STRING_INITIALIZER(
970 struct cmd_del_port_tm_node_shaper_profile_result,
972 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile =
973 TOKEN_STRING_INITIALIZER(
974 struct cmd_del_port_tm_node_shaper_profile_result,
976 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id =
977 TOKEN_NUM_INITIALIZER(
978 struct cmd_del_port_tm_node_shaper_profile_result,
979 port_id, RTE_UINT16);
980 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id =
981 TOKEN_NUM_INITIALIZER(
982 struct cmd_del_port_tm_node_shaper_profile_result,
983 shaper_id, RTE_UINT32);
985 static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result,
986 __rte_unused struct cmdline *cl,
987 __rte_unused void *data)
989 struct cmd_del_port_tm_node_shaper_profile_result *res = parsed_result;
990 struct rte_tm_error error;
991 uint32_t shaper_id = res->shaper_id;
992 portid_t port_id = res->port_id;
995 if (port_id_is_invalid(port_id, ENABLED_WARN))
998 memset(&error, 0, sizeof(struct rte_tm_error));
999 ret = rte_tm_shaper_profile_delete(port_id, shaper_id, &error);
1001 print_err_msg(&error);
1006 cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile = {
1007 .f = cmd_del_port_tm_node_shaper_profile_parsed,
1009 .help_str = "Delete port tm node private shaper profile",
1011 (void *)&cmd_del_port_tm_node_shaper_profile_del,
1012 (void *)&cmd_del_port_tm_node_shaper_profile_port,
1013 (void *)&cmd_del_port_tm_node_shaper_profile_tm,
1014 (void *)&cmd_del_port_tm_node_shaper_profile_node,
1015 (void *)&cmd_del_port_tm_node_shaper_profile_shaper,
1016 (void *)&cmd_del_port_tm_node_shaper_profile_profile,
1017 (void *)&cmd_del_port_tm_node_shaper_profile_port_id,
1018 (void *)&cmd_del_port_tm_node_shaper_profile_shaper_id,
1023 /* *** Add/Update Port TM shared Shaper *** */
1024 struct cmd_add_port_tm_node_shared_shaper_result {
1025 cmdline_fixed_string_t cmd_type;
1026 cmdline_fixed_string_t port;
1027 cmdline_fixed_string_t tm;
1028 cmdline_fixed_string_t node;
1029 cmdline_fixed_string_t shared;
1030 cmdline_fixed_string_t shaper;
1032 uint32_t shared_shaper_id;
1033 uint32_t shaper_profile_id;
1036 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type =
1037 TOKEN_STRING_INITIALIZER(
1038 struct cmd_add_port_tm_node_shared_shaper_result,
1039 cmd_type, "add#set");
1040 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port =
1041 TOKEN_STRING_INITIALIZER(
1042 struct cmd_add_port_tm_node_shared_shaper_result, port, "port");
1043 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm =
1044 TOKEN_STRING_INITIALIZER(
1045 struct cmd_add_port_tm_node_shared_shaper_result, tm, "tm");
1046 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node =
1047 TOKEN_STRING_INITIALIZER(
1048 struct cmd_add_port_tm_node_shared_shaper_result, node, "node");
1049 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared =
1050 TOKEN_STRING_INITIALIZER(
1051 struct cmd_add_port_tm_node_shared_shaper_result,
1053 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper =
1054 TOKEN_STRING_INITIALIZER(
1055 struct cmd_add_port_tm_node_shared_shaper_result,
1057 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id =
1058 TOKEN_NUM_INITIALIZER(
1059 struct cmd_add_port_tm_node_shared_shaper_result,
1060 port_id, RTE_UINT16);
1061 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id =
1062 TOKEN_NUM_INITIALIZER(
1063 struct cmd_add_port_tm_node_shared_shaper_result,
1064 shared_shaper_id, RTE_UINT32);
1065 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id =
1066 TOKEN_NUM_INITIALIZER(
1067 struct cmd_add_port_tm_node_shared_shaper_result,
1068 shaper_profile_id, RTE_UINT32);
1070 static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result,
1071 __rte_unused struct cmdline *cl,
1072 __rte_unused void *data)
1074 struct cmd_add_port_tm_node_shared_shaper_result *res = parsed_result;
1075 struct rte_tm_error error;
1076 uint32_t shared_shaper_id = res->shared_shaper_id;
1077 uint32_t shaper_profile_id = res->shaper_profile_id;
1078 portid_t port_id = res->port_id;
1081 if (port_id_is_invalid(port_id, ENABLED_WARN))
1084 memset(&error, 0, sizeof(struct rte_tm_error));
1085 /* Command type: add */
1086 if ((strcmp(res->cmd_type, "add") == 0) &&
1087 (port_is_started(port_id))) {
1088 printf(" Port %u not stopped (error)\n", port_id);
1092 /* Command type: set (update) */
1093 if ((strcmp(res->cmd_type, "set") == 0) &&
1094 (!port_is_started(port_id))) {
1095 printf(" Port %u not started (error)\n", port_id);
1099 ret = rte_tm_shared_shaper_add_update(port_id, shared_shaper_id,
1100 shaper_profile_id, &error);
1102 print_err_msg(&error);
1107 cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper = {
1108 .f = cmd_add_port_tm_node_shared_shaper_parsed,
1110 .help_str = "add/update port tm node shared shaper",
1112 (void *)&cmd_add_port_tm_node_shared_shaper_cmd_type,
1113 (void *)&cmd_add_port_tm_node_shared_shaper_port,
1114 (void *)&cmd_add_port_tm_node_shared_shaper_tm,
1115 (void *)&cmd_add_port_tm_node_shared_shaper_node,
1116 (void *)&cmd_add_port_tm_node_shared_shaper_shared,
1117 (void *)&cmd_add_port_tm_node_shared_shaper_shaper,
1118 (void *)&cmd_add_port_tm_node_shared_shaper_port_id,
1119 (void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id,
1120 (void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id,
1125 /* *** Delete Port TM shared Shaper *** */
1126 struct cmd_del_port_tm_node_shared_shaper_result {
1127 cmdline_fixed_string_t del;
1128 cmdline_fixed_string_t port;
1129 cmdline_fixed_string_t tm;
1130 cmdline_fixed_string_t node;
1131 cmdline_fixed_string_t shared;
1132 cmdline_fixed_string_t shaper;
1134 uint32_t shared_shaper_id;
1137 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del =
1138 TOKEN_STRING_INITIALIZER(
1139 struct cmd_del_port_tm_node_shared_shaper_result, del, "del");
1140 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port =
1141 TOKEN_STRING_INITIALIZER(
1142 struct cmd_del_port_tm_node_shared_shaper_result, port, "port");
1143 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm =
1144 TOKEN_STRING_INITIALIZER(
1145 struct cmd_del_port_tm_node_shared_shaper_result, tm, "tm");
1146 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node =
1147 TOKEN_STRING_INITIALIZER(
1148 struct cmd_del_port_tm_node_shared_shaper_result, node, "node");
1149 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared =
1150 TOKEN_STRING_INITIALIZER(
1151 struct cmd_del_port_tm_node_shared_shaper_result,
1153 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper =
1154 TOKEN_STRING_INITIALIZER(
1155 struct cmd_del_port_tm_node_shared_shaper_result,
1157 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id =
1158 TOKEN_NUM_INITIALIZER(
1159 struct cmd_del_port_tm_node_shared_shaper_result,
1160 port_id, RTE_UINT16);
1161 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id =
1162 TOKEN_NUM_INITIALIZER(
1163 struct cmd_del_port_tm_node_shared_shaper_result,
1164 shared_shaper_id, RTE_UINT32);
1166 static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result,
1167 __rte_unused struct cmdline *cl,
1168 __rte_unused void *data)
1170 struct cmd_del_port_tm_node_shared_shaper_result *res = parsed_result;
1171 struct rte_tm_error error;
1172 uint32_t shared_shaper_id = res->shared_shaper_id;
1173 portid_t port_id = res->port_id;
1176 if (port_id_is_invalid(port_id, ENABLED_WARN))
1179 memset(&error, 0, sizeof(struct rte_tm_error));
1180 ret = rte_tm_shared_shaper_delete(port_id, shared_shaper_id, &error);
1182 print_err_msg(&error);
1187 cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper = {
1188 .f = cmd_del_port_tm_node_shared_shaper_parsed,
1190 .help_str = "delete port tm node shared shaper",
1192 (void *)&cmd_del_port_tm_node_shared_shaper_del,
1193 (void *)&cmd_del_port_tm_node_shared_shaper_port,
1194 (void *)&cmd_del_port_tm_node_shared_shaper_tm,
1195 (void *)&cmd_del_port_tm_node_shared_shaper_node,
1196 (void *)&cmd_del_port_tm_node_shared_shaper_shared,
1197 (void *)&cmd_del_port_tm_node_shared_shaper_shaper,
1198 (void *)&cmd_del_port_tm_node_shared_shaper_port_id,
1199 (void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id,
1204 /* *** Add Port TM Node WRED Profile *** */
1205 struct cmd_add_port_tm_node_wred_profile_result {
1206 cmdline_fixed_string_t add;
1207 cmdline_fixed_string_t port;
1208 cmdline_fixed_string_t tm;
1209 cmdline_fixed_string_t node;
1210 cmdline_fixed_string_t wred;
1211 cmdline_fixed_string_t profile;
1213 uint32_t wred_profile_id;
1214 cmdline_fixed_string_t color_g;
1217 uint16_t maxp_inv_g;
1219 cmdline_fixed_string_t color_y;
1222 uint16_t maxp_inv_y;
1224 cmdline_fixed_string_t color_r;
1227 uint16_t maxp_inv_r;
1231 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add =
1232 TOKEN_STRING_INITIALIZER(
1233 struct cmd_add_port_tm_node_wred_profile_result, add, "add");
1234 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port =
1235 TOKEN_STRING_INITIALIZER(
1236 struct cmd_add_port_tm_node_wred_profile_result, port, "port");
1237 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm =
1238 TOKEN_STRING_INITIALIZER(
1239 struct cmd_add_port_tm_node_wred_profile_result, tm, "tm");
1240 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node =
1241 TOKEN_STRING_INITIALIZER(
1242 struct cmd_add_port_tm_node_wred_profile_result, node, "node");
1243 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred =
1244 TOKEN_STRING_INITIALIZER(
1245 struct cmd_add_port_tm_node_wred_profile_result, wred, "wred");
1246 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile =
1247 TOKEN_STRING_INITIALIZER(
1248 struct cmd_add_port_tm_node_wred_profile_result,
1249 profile, "profile");
1250 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id =
1251 TOKEN_NUM_INITIALIZER(
1252 struct cmd_add_port_tm_node_wred_profile_result,
1253 port_id, RTE_UINT16);
1254 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id =
1255 TOKEN_NUM_INITIALIZER(
1256 struct cmd_add_port_tm_node_wred_profile_result,
1257 wred_profile_id, RTE_UINT32);
1258 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g =
1259 TOKEN_STRING_INITIALIZER(
1260 struct cmd_add_port_tm_node_wred_profile_result,
1262 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g =
1263 TOKEN_NUM_INITIALIZER(
1264 struct cmd_add_port_tm_node_wred_profile_result,
1265 min_th_g, RTE_UINT64);
1266 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g =
1267 TOKEN_NUM_INITIALIZER(
1268 struct cmd_add_port_tm_node_wred_profile_result,
1269 max_th_g, RTE_UINT64);
1270 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g =
1271 TOKEN_NUM_INITIALIZER(
1272 struct cmd_add_port_tm_node_wred_profile_result,
1273 maxp_inv_g, RTE_UINT16);
1274 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g =
1275 TOKEN_NUM_INITIALIZER(
1276 struct cmd_add_port_tm_node_wred_profile_result,
1277 wq_log2_g, RTE_UINT16);
1278 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y =
1279 TOKEN_STRING_INITIALIZER(
1280 struct cmd_add_port_tm_node_wred_profile_result,
1282 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y =
1283 TOKEN_NUM_INITIALIZER(
1284 struct cmd_add_port_tm_node_wred_profile_result,
1285 min_th_y, RTE_UINT64);
1286 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y =
1287 TOKEN_NUM_INITIALIZER(
1288 struct cmd_add_port_tm_node_wred_profile_result,
1289 max_th_y, RTE_UINT64);
1290 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y =
1291 TOKEN_NUM_INITIALIZER(
1292 struct cmd_add_port_tm_node_wred_profile_result,
1293 maxp_inv_y, RTE_UINT16);
1294 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y =
1295 TOKEN_NUM_INITIALIZER(
1296 struct cmd_add_port_tm_node_wred_profile_result,
1297 wq_log2_y, RTE_UINT16);
1298 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r =
1299 TOKEN_STRING_INITIALIZER(
1300 struct cmd_add_port_tm_node_wred_profile_result,
1302 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r =
1303 TOKEN_NUM_INITIALIZER(
1304 struct cmd_add_port_tm_node_wred_profile_result,
1305 min_th_r, RTE_UINT64);
1306 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r =
1307 TOKEN_NUM_INITIALIZER(
1308 struct cmd_add_port_tm_node_wred_profile_result,
1309 max_th_r, RTE_UINT64);
1310 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r =
1311 TOKEN_NUM_INITIALIZER(
1312 struct cmd_add_port_tm_node_wred_profile_result,
1313 maxp_inv_r, RTE_UINT16);
1314 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r =
1315 TOKEN_NUM_INITIALIZER(
1316 struct cmd_add_port_tm_node_wred_profile_result,
1317 wq_log2_r, RTE_UINT16);
1320 static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
1321 __rte_unused struct cmdline *cl,
1322 __rte_unused void *data)
1324 struct cmd_add_port_tm_node_wred_profile_result *res = parsed_result;
1325 struct rte_tm_wred_params wp;
1326 enum rte_color color;
1327 struct rte_tm_error error;
1328 uint32_t wred_profile_id = res->wred_profile_id;
1329 portid_t port_id = res->port_id;
1332 if (port_id_is_invalid(port_id, ENABLED_WARN))
1335 memset(&wp, 0, sizeof(struct rte_tm_wred_params));
1336 memset(&error, 0, sizeof(struct rte_tm_error));
1338 /* WRED Params (Green Color)*/
1339 color = RTE_COLOR_GREEN;
1340 wp.red_params[color].min_th = res->min_th_g;
1341 wp.red_params[color].max_th = res->max_th_g;
1342 wp.red_params[color].maxp_inv = res->maxp_inv_g;
1343 wp.red_params[color].wq_log2 = res->wq_log2_g;
1346 /* WRED Params (Yellow Color)*/
1347 color = RTE_COLOR_YELLOW;
1348 wp.red_params[color].min_th = res->min_th_y;
1349 wp.red_params[color].max_th = res->max_th_y;
1350 wp.red_params[color].maxp_inv = res->maxp_inv_y;
1351 wp.red_params[color].wq_log2 = res->wq_log2_y;
1353 /* WRED Params (Red Color)*/
1354 color = RTE_COLOR_RED;
1355 wp.red_params[color].min_th = res->min_th_r;
1356 wp.red_params[color].max_th = res->max_th_r;
1357 wp.red_params[color].maxp_inv = res->maxp_inv_r;
1358 wp.red_params[color].wq_log2 = res->wq_log2_r;
1360 ret = rte_tm_wred_profile_add(port_id, wred_profile_id, &wp, &error);
1362 print_err_msg(&error);
1367 cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile = {
1368 .f = cmd_add_port_tm_node_wred_profile_parsed,
1370 .help_str = "Add port tm node wred profile",
1372 (void *)&cmd_add_port_tm_node_wred_profile_add,
1373 (void *)&cmd_add_port_tm_node_wred_profile_port,
1374 (void *)&cmd_add_port_tm_node_wred_profile_tm,
1375 (void *)&cmd_add_port_tm_node_wred_profile_node,
1376 (void *)&cmd_add_port_tm_node_wred_profile_wred,
1377 (void *)&cmd_add_port_tm_node_wred_profile_profile,
1378 (void *)&cmd_add_port_tm_node_wred_profile_port_id,
1379 (void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id,
1380 (void *)&cmd_add_port_tm_node_wred_profile_color_g,
1381 (void *)&cmd_add_port_tm_node_wred_profile_min_th_g,
1382 (void *)&cmd_add_port_tm_node_wred_profile_max_th_g,
1383 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g,
1384 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g,
1385 (void *)&cmd_add_port_tm_node_wred_profile_color_y,
1386 (void *)&cmd_add_port_tm_node_wred_profile_min_th_y,
1387 (void *)&cmd_add_port_tm_node_wred_profile_max_th_y,
1388 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y,
1389 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y,
1390 (void *)&cmd_add_port_tm_node_wred_profile_color_r,
1391 (void *)&cmd_add_port_tm_node_wred_profile_min_th_r,
1392 (void *)&cmd_add_port_tm_node_wred_profile_max_th_r,
1393 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r,
1394 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r,
1399 /* *** Delete Port TM node WRED Profile *** */
1400 struct cmd_del_port_tm_node_wred_profile_result {
1401 cmdline_fixed_string_t del;
1402 cmdline_fixed_string_t port;
1403 cmdline_fixed_string_t tm;
1404 cmdline_fixed_string_t node;
1405 cmdline_fixed_string_t wred;
1406 cmdline_fixed_string_t profile;
1408 uint32_t wred_profile_id;
1411 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del =
1412 TOKEN_STRING_INITIALIZER(
1413 struct cmd_del_port_tm_node_wred_profile_result, del, "del");
1414 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port =
1415 TOKEN_STRING_INITIALIZER(
1416 struct cmd_del_port_tm_node_wred_profile_result, port, "port");
1417 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm =
1418 TOKEN_STRING_INITIALIZER(
1419 struct cmd_del_port_tm_node_wred_profile_result, tm, "tm");
1420 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node =
1421 TOKEN_STRING_INITIALIZER(
1422 struct cmd_del_port_tm_node_wred_profile_result, node, "node");
1423 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred =
1424 TOKEN_STRING_INITIALIZER(
1425 struct cmd_del_port_tm_node_wred_profile_result, wred, "wred");
1426 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile =
1427 TOKEN_STRING_INITIALIZER(
1428 struct cmd_del_port_tm_node_wred_profile_result,
1429 profile, "profile");
1430 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id =
1431 TOKEN_NUM_INITIALIZER(
1432 struct cmd_del_port_tm_node_wred_profile_result,
1433 port_id, RTE_UINT16);
1434 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id =
1435 TOKEN_NUM_INITIALIZER(
1436 struct cmd_del_port_tm_node_wred_profile_result,
1437 wred_profile_id, RTE_UINT32);
1439 static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result,
1440 __rte_unused struct cmdline *cl,
1441 __rte_unused void *data)
1443 struct cmd_del_port_tm_node_wred_profile_result *res = parsed_result;
1444 struct rte_tm_error error;
1445 uint32_t wred_profile_id = res->wred_profile_id;
1446 portid_t port_id = res->port_id;
1449 if (port_id_is_invalid(port_id, ENABLED_WARN))
1452 memset(&error, 0, sizeof(struct rte_tm_error));
1453 ret = rte_tm_wred_profile_delete(port_id, wred_profile_id, &error);
1455 print_err_msg(&error);
1460 cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile = {
1461 .f = cmd_del_port_tm_node_wred_profile_parsed,
1463 .help_str = "Delete port tm node wred profile",
1465 (void *)&cmd_del_port_tm_node_wred_profile_del,
1466 (void *)&cmd_del_port_tm_node_wred_profile_port,
1467 (void *)&cmd_del_port_tm_node_wred_profile_tm,
1468 (void *)&cmd_del_port_tm_node_wred_profile_node,
1469 (void *)&cmd_del_port_tm_node_wred_profile_wred,
1470 (void *)&cmd_del_port_tm_node_wred_profile_profile,
1471 (void *)&cmd_del_port_tm_node_wred_profile_port_id,
1472 (void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id,
1477 /* *** Update Port TM Node Shaper profile *** */
1478 struct cmd_set_port_tm_node_shaper_profile_result {
1479 cmdline_fixed_string_t set;
1480 cmdline_fixed_string_t port;
1481 cmdline_fixed_string_t tm;
1482 cmdline_fixed_string_t node;
1483 cmdline_fixed_string_t shaper;
1484 cmdline_fixed_string_t profile;
1487 uint32_t shaper_profile_id;
1490 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set =
1491 TOKEN_STRING_INITIALIZER(
1492 struct cmd_set_port_tm_node_shaper_profile_result, set, "set");
1493 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port =
1494 TOKEN_STRING_INITIALIZER(
1495 struct cmd_set_port_tm_node_shaper_profile_result,
1497 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_tm =
1498 TOKEN_STRING_INITIALIZER(
1499 struct cmd_set_port_tm_node_shaper_profile_result, tm, "tm");
1500 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node =
1501 TOKEN_STRING_INITIALIZER(
1502 struct cmd_set_port_tm_node_shaper_profile_result,
1504 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper =
1505 TOKEN_STRING_INITIALIZER(
1506 struct cmd_set_port_tm_node_shaper_profile_result,
1508 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile =
1509 TOKEN_STRING_INITIALIZER(
1510 struct cmd_set_port_tm_node_shaper_profile_result,
1511 profile, "profile");
1512 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id =
1513 TOKEN_NUM_INITIALIZER(
1514 struct cmd_set_port_tm_node_shaper_profile_result,
1515 port_id, RTE_UINT16);
1516 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id =
1517 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result,
1518 node_id, RTE_UINT32);
1519 cmdline_parse_token_num_t
1520 cmd_set_port_tm_node_shaper_shaper_profile_profile_id =
1521 TOKEN_NUM_INITIALIZER(
1522 struct cmd_set_port_tm_node_shaper_profile_result,
1523 shaper_profile_id, RTE_UINT32);
1525 static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result,
1526 __rte_unused struct cmdline *cl,
1527 __rte_unused void *data)
1529 struct cmd_set_port_tm_node_shaper_profile_result *res = parsed_result;
1530 struct rte_tm_error error;
1531 uint32_t node_id = res->node_id;
1532 uint32_t shaper_profile_id = res->shaper_profile_id;
1533 portid_t port_id = res->port_id;
1536 if (port_id_is_invalid(port_id, ENABLED_WARN))
1539 memset(&error, 0, sizeof(struct rte_tm_error));
1541 if (!port_is_started(port_id)) {
1542 printf(" Port %u not started (error)\n", port_id);
1546 ret = rte_tm_node_shaper_update(port_id, node_id,
1547 shaper_profile_id, &error);
1549 print_err_msg(&error);
1554 cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile = {
1555 .f = cmd_set_port_tm_node_shaper_profile_parsed,
1557 .help_str = "Set port tm node shaper profile",
1559 (void *)&cmd_set_port_tm_node_shaper_profile_set,
1560 (void *)&cmd_set_port_tm_node_shaper_profile_port,
1561 (void *)&cmd_set_port_tm_node_shaper_profile_tm,
1562 (void *)&cmd_set_port_tm_node_shaper_profile_node,
1563 (void *)&cmd_set_port_tm_node_shaper_profile_shaper,
1564 (void *)&cmd_set_port_tm_node_shaper_profile_profile,
1565 (void *)&cmd_set_port_tm_node_shaper_profile_port_id,
1566 (void *)&cmd_set_port_tm_node_shaper_profile_node_id,
1567 (void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id,
1572 /* *** Add Port TM nonleaf node *** */
1573 struct cmd_add_port_tm_nonleaf_node_result {
1574 cmdline_fixed_string_t add;
1575 cmdline_fixed_string_t port;
1576 cmdline_fixed_string_t tm;
1577 cmdline_fixed_string_t nonleaf;
1578 cmdline_fixed_string_t node;
1581 int32_t parent_node_id;
1585 int32_t shaper_profile_id;
1586 uint32_t n_sp_priorities;
1587 uint64_t stats_mask;
1588 cmdline_multi_string_t multi_shared_shaper_id;
1591 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add =
1592 TOKEN_STRING_INITIALIZER(
1593 struct cmd_add_port_tm_nonleaf_node_result, add, "add");
1594 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port =
1595 TOKEN_STRING_INITIALIZER(
1596 struct cmd_add_port_tm_nonleaf_node_result, port, "port");
1597 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm =
1598 TOKEN_STRING_INITIALIZER(
1599 struct cmd_add_port_tm_nonleaf_node_result, tm, "tm");
1600 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf =
1601 TOKEN_STRING_INITIALIZER(
1602 struct cmd_add_port_tm_nonleaf_node_result, nonleaf, "nonleaf");
1603 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node =
1604 TOKEN_STRING_INITIALIZER(
1605 struct cmd_add_port_tm_nonleaf_node_result, node, "node");
1606 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id =
1607 TOKEN_NUM_INITIALIZER(
1608 struct cmd_add_port_tm_nonleaf_node_result,
1609 port_id, RTE_UINT16);
1610 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_id =
1611 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1612 node_id, RTE_UINT32);
1613 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_parent_node_id =
1614 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1615 parent_node_id, RTE_INT32);
1616 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority =
1617 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1618 priority, RTE_UINT32);
1619 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight =
1620 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1621 weight, RTE_UINT32);
1622 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =
1623 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1624 level_id, RTE_UINT32);
1625 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id =
1626 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1627 shaper_profile_id, RTE_INT32);
1628 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =
1629 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1630 n_sp_priorities, RTE_UINT32);
1631 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask =
1632 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1633 stats_mask, RTE_UINT64);
1634 cmdline_parse_token_string_t
1635 cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id =
1636 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1637 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1639 static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
1640 __rte_unused struct cmdline *cl,
1641 __rte_unused void *data)
1643 struct cmd_add_port_tm_nonleaf_node_result *res = parsed_result;
1644 struct rte_tm_error error;
1645 struct rte_tm_node_params np;
1646 uint32_t *shared_shaper_id;
1647 uint32_t parent_node_id, n_shared_shapers = 0;
1648 char *s_str = res->multi_shared_shaper_id;
1649 portid_t port_id = res->port_id;
1652 if (port_id_is_invalid(port_id, ENABLED_WARN))
1655 memset(&np, 0, sizeof(struct rte_tm_node_params));
1656 memset(&error, 0, sizeof(struct rte_tm_error));
1658 /* Node parameters */
1659 if (res->parent_node_id < 0)
1660 parent_node_id = UINT32_MAX;
1662 parent_node_id = res->parent_node_id;
1664 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1666 if (shared_shaper_id == NULL) {
1667 printf(" Memory not allocated for shared shapers (error)\n");
1671 /* Parse multi shared shaper id string */
1672 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1674 printf(" Shared shapers params string parse error\n");
1675 free(shared_shaper_id);
1679 if (res->shaper_profile_id < 0)
1680 np.shaper_profile_id = UINT32_MAX;
1682 np.shaper_profile_id = res->shaper_profile_id;
1684 np.n_shared_shapers = n_shared_shapers;
1685 if (np.n_shared_shapers) {
1686 np.shared_shaper_id = &shared_shaper_id[0];
1688 free(shared_shaper_id);
1689 shared_shaper_id = NULL;
1692 np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1693 np.stats_mask = res->stats_mask;
1694 np.nonleaf.wfq_weight_mode = NULL;
1696 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1697 res->priority, res->weight, res->level_id,
1700 print_err_msg(&error);
1701 free(shared_shaper_id);
1706 cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node = {
1707 .f = cmd_add_port_tm_nonleaf_node_parsed,
1709 .help_str = "Add port tm nonleaf node",
1711 (void *)&cmd_add_port_tm_nonleaf_node_add,
1712 (void *)&cmd_add_port_tm_nonleaf_node_port,
1713 (void *)&cmd_add_port_tm_nonleaf_node_tm,
1714 (void *)&cmd_add_port_tm_nonleaf_node_nonleaf,
1715 (void *)&cmd_add_port_tm_nonleaf_node_node,
1716 (void *)&cmd_add_port_tm_nonleaf_node_port_id,
1717 (void *)&cmd_add_port_tm_nonleaf_node_node_id,
1718 (void *)&cmd_add_port_tm_nonleaf_node_parent_node_id,
1719 (void *)&cmd_add_port_tm_nonleaf_node_priority,
1720 (void *)&cmd_add_port_tm_nonleaf_node_weight,
1721 (void *)&cmd_add_port_tm_nonleaf_node_level_id,
1722 (void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id,
1723 (void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities,
1724 (void *)&cmd_add_port_tm_nonleaf_node_stats_mask,
1725 (void *)&cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id,
1730 /* *** Add Port TM nonleaf node pkt mode *** */
1731 struct cmd_add_port_tm_nonleaf_node_pmode_result {
1732 cmdline_fixed_string_t add;
1733 cmdline_fixed_string_t port;
1734 cmdline_fixed_string_t tm;
1735 cmdline_fixed_string_t nonleaf;
1736 cmdline_fixed_string_t node;
1739 int32_t parent_node_id;
1743 int32_t shaper_profile_id;
1744 uint32_t n_sp_priorities;
1745 uint64_t stats_mask;
1746 cmdline_multi_string_t multi_shared_shaper_id;
1749 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_add =
1750 TOKEN_STRING_INITIALIZER(
1751 struct cmd_add_port_tm_nonleaf_node_pmode_result, add, "add");
1752 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_port =
1753 TOKEN_STRING_INITIALIZER(
1754 struct cmd_add_port_tm_nonleaf_node_pmode_result, port, "port");
1755 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_tm =
1756 TOKEN_STRING_INITIALIZER(
1757 struct cmd_add_port_tm_nonleaf_node_pmode_result, tm, "tm");
1758 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_nonleaf =
1759 TOKEN_STRING_INITIALIZER(
1760 struct cmd_add_port_tm_nonleaf_node_pmode_result, nonleaf, "nonleaf");
1761 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_node =
1762 TOKEN_STRING_INITIALIZER(
1763 struct cmd_add_port_tm_nonleaf_node_pmode_result, node, "node");
1764 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_pktmode =
1765 TOKEN_STRING_INITIALIZER(
1766 struct cmd_add_port_tm_nonleaf_node_pmode_result, node, "pktmode");
1767 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_port_id =
1768 TOKEN_NUM_INITIALIZER(
1769 struct cmd_add_port_tm_nonleaf_node_pmode_result,
1770 port_id, RTE_UINT16);
1771 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_node_id =
1772 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1773 node_id, RTE_UINT32);
1774 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_parent_node_id =
1775 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1776 parent_node_id, RTE_INT32);
1777 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_priority =
1778 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1779 priority, RTE_UINT32);
1780 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_weight =
1781 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1782 weight, RTE_UINT32);
1783 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_level_id =
1784 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1785 level_id, RTE_UINT32);
1786 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_shaper_profile_id =
1787 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1788 shaper_profile_id, RTE_INT32);
1789 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_n_sp_priorities =
1790 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1791 n_sp_priorities, RTE_UINT32);
1792 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_stats_mask =
1793 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1794 stats_mask, RTE_UINT64);
1795 cmdline_parse_token_string_t
1796 cmd_add_port_tm_nonleaf_node_pmode_multi_shrd_shpr_id =
1797 TOKEN_STRING_INITIALIZER(
1798 struct cmd_add_port_tm_nonleaf_node_pmode_result,
1799 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1801 static void cmd_add_port_tm_nonleaf_node_pmode_parsed(void *parsed_result,
1802 __rte_unused struct cmdline *cl,
1803 __rte_unused void *data)
1805 struct cmd_add_port_tm_nonleaf_node_pmode_result *res = parsed_result;
1806 uint32_t parent_node_id, n_shared_shapers = 0;
1807 char *s_str = res->multi_shared_shaper_id;
1808 portid_t port_id = res->port_id;
1809 struct rte_tm_node_params np;
1810 int *wfq_weight_mode = NULL;
1811 uint32_t *shared_shaper_id;
1812 struct rte_tm_error error;
1815 if (port_id_is_invalid(port_id, ENABLED_WARN))
1818 memset(&np, 0, sizeof(struct rte_tm_node_params));
1819 memset(&error, 0, sizeof(struct rte_tm_error));
1821 /* Node parameters */
1822 if (res->parent_node_id < 0)
1823 parent_node_id = UINT32_MAX;
1825 parent_node_id = res->parent_node_id;
1827 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1829 if (shared_shaper_id == NULL) {
1830 printf(" Memory not allocated for shared shapers (error)\n");
1834 /* Parse multi shared shaper id string */
1835 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1837 printf(" Shared shapers params string parse error\n");
1838 free(shared_shaper_id);
1842 if (res->shaper_profile_id < 0)
1843 np.shaper_profile_id = UINT32_MAX;
1845 np.shaper_profile_id = res->shaper_profile_id;
1847 np.n_shared_shapers = n_shared_shapers;
1848 if (np.n_shared_shapers) {
1849 np.shared_shaper_id = &shared_shaper_id[0];
1851 free(shared_shaper_id);
1852 shared_shaper_id = NULL;
1855 if (res->n_sp_priorities)
1856 wfq_weight_mode = calloc(res->n_sp_priorities, sizeof(int));
1857 np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1858 np.stats_mask = res->stats_mask;
1859 np.nonleaf.wfq_weight_mode = wfq_weight_mode;
1861 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1862 res->priority, res->weight, res->level_id,
1865 print_err_msg(&error);
1866 free(shared_shaper_id);
1867 free(wfq_weight_mode);
1872 cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node_pmode = {
1873 .f = cmd_add_port_tm_nonleaf_node_pmode_parsed,
1875 .help_str = "Add port tm nonleaf node pktmode",
1877 (void *)&cmd_add_port_tm_nonleaf_node_pmode_add,
1878 (void *)&cmd_add_port_tm_nonleaf_node_pmode_port,
1879 (void *)&cmd_add_port_tm_nonleaf_node_pmode_tm,
1880 (void *)&cmd_add_port_tm_nonleaf_node_pmode_nonleaf,
1881 (void *)&cmd_add_port_tm_nonleaf_node_pmode_node,
1882 (void *)&cmd_add_port_tm_nonleaf_node_pmode_pktmode,
1883 (void *)&cmd_add_port_tm_nonleaf_node_pmode_port_id,
1884 (void *)&cmd_add_port_tm_nonleaf_node_pmode_node_id,
1885 (void *)&cmd_add_port_tm_nonleaf_node_pmode_parent_node_id,
1886 (void *)&cmd_add_port_tm_nonleaf_node_pmode_priority,
1887 (void *)&cmd_add_port_tm_nonleaf_node_pmode_weight,
1888 (void *)&cmd_add_port_tm_nonleaf_node_pmode_level_id,
1889 (void *)&cmd_add_port_tm_nonleaf_node_pmode_shaper_profile_id,
1890 (void *)&cmd_add_port_tm_nonleaf_node_pmode_n_sp_priorities,
1891 (void *)&cmd_add_port_tm_nonleaf_node_pmode_stats_mask,
1892 (void *)&cmd_add_port_tm_nonleaf_node_pmode_multi_shrd_shpr_id,
1896 /* *** Add Port TM leaf node *** */
1897 struct cmd_add_port_tm_leaf_node_result {
1898 cmdline_fixed_string_t add;
1899 cmdline_fixed_string_t port;
1900 cmdline_fixed_string_t tm;
1901 cmdline_fixed_string_t leaf;
1902 cmdline_fixed_string_t node;
1905 int32_t parent_node_id;
1909 int32_t shaper_profile_id;
1911 uint32_t wred_profile_id;
1912 uint64_t stats_mask;
1913 cmdline_multi_string_t multi_shared_shaper_id;
1916 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add =
1917 TOKEN_STRING_INITIALIZER(
1918 struct cmd_add_port_tm_leaf_node_result, add, "add");
1919 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port =
1920 TOKEN_STRING_INITIALIZER(
1921 struct cmd_add_port_tm_leaf_node_result, port, "port");
1922 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm =
1923 TOKEN_STRING_INITIALIZER(
1924 struct cmd_add_port_tm_leaf_node_result, tm, "tm");
1925 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf =
1926 TOKEN_STRING_INITIALIZER(
1927 struct cmd_add_port_tm_leaf_node_result, leaf, "leaf");
1928 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node =
1929 TOKEN_STRING_INITIALIZER(
1930 struct cmd_add_port_tm_leaf_node_result, node, "node");
1931 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_id =
1932 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1933 port_id, RTE_UINT16);
1934 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_node_id =
1935 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1936 node_id, RTE_UINT32);
1937 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id =
1938 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1939 parent_node_id, RTE_INT32);
1940 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority =
1941 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1942 priority, RTE_UINT32);
1943 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight =
1944 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1945 weight, RTE_UINT32);
1946 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =
1947 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1948 level_id, RTE_UINT32);
1949 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =
1950 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1951 shaper_profile_id, RTE_INT32);
1952 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =
1953 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1954 cman_mode, RTE_UINT32);
1955 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id =
1956 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1957 wred_profile_id, RTE_UINT32);
1958 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask =
1959 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1960 stats_mask, RTE_UINT64);
1961 cmdline_parse_token_string_t
1962 cmd_add_port_tm_leaf_node_multi_shared_shaper_id =
1963 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1964 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1966 static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
1967 __rte_unused struct cmdline *cl,
1968 __rte_unused void *data)
1970 struct cmd_add_port_tm_leaf_node_result *res = parsed_result;
1971 struct rte_tm_error error;
1972 struct rte_tm_node_params np;
1973 uint32_t *shared_shaper_id;
1974 uint32_t parent_node_id, n_shared_shapers = 0;
1975 portid_t port_id = res->port_id;
1976 char *s_str = res->multi_shared_shaper_id;
1979 if (port_id_is_invalid(port_id, ENABLED_WARN))
1982 memset(&np, 0, sizeof(struct rte_tm_node_params));
1983 memset(&error, 0, sizeof(struct rte_tm_error));
1985 /* Node parameters */
1986 if (res->parent_node_id < 0)
1987 parent_node_id = UINT32_MAX;
1989 parent_node_id = res->parent_node_id;
1991 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1993 if (shared_shaper_id == NULL) {
1994 printf(" Memory not allocated for shared shapers (error)\n");
1998 /* Parse multi shared shaper id string */
1999 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
2001 printf(" Shared shapers params string parse error\n");
2002 free(shared_shaper_id);
2006 if (res->shaper_profile_id < 0)
2007 np.shaper_profile_id = UINT32_MAX;
2009 np.shaper_profile_id = res->shaper_profile_id;
2011 np.n_shared_shapers = n_shared_shapers;
2013 if (np.n_shared_shapers) {
2014 np.shared_shaper_id = &shared_shaper_id[0];
2016 free(shared_shaper_id);
2017 shared_shaper_id = NULL;
2020 np.leaf.cman = res->cman_mode;
2021 np.leaf.wred.wred_profile_id = res->wred_profile_id;
2022 np.stats_mask = res->stats_mask;
2024 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
2025 res->priority, res->weight, res->level_id,
2028 print_err_msg(&error);
2029 free(shared_shaper_id);
2034 cmdline_parse_inst_t cmd_add_port_tm_leaf_node = {
2035 .f = cmd_add_port_tm_leaf_node_parsed,
2037 .help_str = "Add port tm leaf node",
2039 (void *)&cmd_add_port_tm_leaf_node_add,
2040 (void *)&cmd_add_port_tm_leaf_node_port,
2041 (void *)&cmd_add_port_tm_leaf_node_tm,
2042 (void *)&cmd_add_port_tm_leaf_node_nonleaf,
2043 (void *)&cmd_add_port_tm_leaf_node_node,
2044 (void *)&cmd_add_port_tm_leaf_node_port_id,
2045 (void *)&cmd_add_port_tm_leaf_node_node_id,
2046 (void *)&cmd_add_port_tm_leaf_node_parent_node_id,
2047 (void *)&cmd_add_port_tm_leaf_node_priority,
2048 (void *)&cmd_add_port_tm_leaf_node_weight,
2049 (void *)&cmd_add_port_tm_leaf_node_level_id,
2050 (void *)&cmd_add_port_tm_leaf_node_shaper_profile_id,
2051 (void *)&cmd_add_port_tm_leaf_node_cman_mode,
2052 (void *)&cmd_add_port_tm_leaf_node_wred_profile_id,
2053 (void *)&cmd_add_port_tm_leaf_node_stats_mask,
2054 (void *)&cmd_add_port_tm_leaf_node_multi_shared_shaper_id,
2059 /* *** Delete Port TM Node *** */
2060 struct cmd_del_port_tm_node_result {
2061 cmdline_fixed_string_t del;
2062 cmdline_fixed_string_t port;
2063 cmdline_fixed_string_t tm;
2064 cmdline_fixed_string_t node;
2069 cmdline_parse_token_string_t cmd_del_port_tm_node_del =
2070 TOKEN_STRING_INITIALIZER(
2071 struct cmd_del_port_tm_node_result, del, "del");
2072 cmdline_parse_token_string_t cmd_del_port_tm_node_port =
2073 TOKEN_STRING_INITIALIZER(
2074 struct cmd_del_port_tm_node_result, port, "port");
2075 cmdline_parse_token_string_t cmd_del_port_tm_node_tm =
2076 TOKEN_STRING_INITIALIZER(
2077 struct cmd_del_port_tm_node_result, tm, "tm");
2078 cmdline_parse_token_string_t cmd_del_port_tm_node_node =
2079 TOKEN_STRING_INITIALIZER(
2080 struct cmd_del_port_tm_node_result, node, "node");
2081 cmdline_parse_token_num_t cmd_del_port_tm_node_port_id =
2082 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
2083 port_id, RTE_UINT16);
2084 cmdline_parse_token_num_t cmd_del_port_tm_node_node_id =
2085 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
2086 node_id, RTE_UINT32);
2088 static void cmd_del_port_tm_node_parsed(void *parsed_result,
2089 __rte_unused struct cmdline *cl,
2090 __rte_unused void *data)
2092 struct cmd_del_port_tm_node_result *res = parsed_result;
2093 struct rte_tm_error error;
2094 uint32_t node_id = res->node_id;
2095 portid_t port_id = res->port_id;
2098 if (port_id_is_invalid(port_id, ENABLED_WARN))
2101 memset(&error, 0, sizeof(struct rte_tm_error));
2103 if (port_is_started(port_id)) {
2104 printf(" Port %u not stopped (error)\n", port_id);
2108 ret = rte_tm_node_delete(port_id, node_id, &error);
2110 print_err_msg(&error);
2115 cmdline_parse_inst_t cmd_del_port_tm_node = {
2116 .f = cmd_del_port_tm_node_parsed,
2118 .help_str = "Delete port tm node",
2120 (void *)&cmd_del_port_tm_node_del,
2121 (void *)&cmd_del_port_tm_node_port,
2122 (void *)&cmd_del_port_tm_node_tm,
2123 (void *)&cmd_del_port_tm_node_node,
2124 (void *)&cmd_del_port_tm_node_port_id,
2125 (void *)&cmd_del_port_tm_node_node_id,
2130 /* *** Update Port TM Node Parent *** */
2131 struct cmd_set_port_tm_node_parent_result {
2132 cmdline_fixed_string_t set;
2133 cmdline_fixed_string_t port;
2134 cmdline_fixed_string_t tm;
2135 cmdline_fixed_string_t node;
2136 cmdline_fixed_string_t parent;
2144 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set =
2145 TOKEN_STRING_INITIALIZER(
2146 struct cmd_set_port_tm_node_parent_result, set, "set");
2147 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port =
2148 TOKEN_STRING_INITIALIZER(
2149 struct cmd_set_port_tm_node_parent_result, port, "port");
2150 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm =
2151 TOKEN_STRING_INITIALIZER(
2152 struct cmd_set_port_tm_node_parent_result, tm, "tm");
2153 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node =
2154 TOKEN_STRING_INITIALIZER(
2155 struct cmd_set_port_tm_node_parent_result, node, "node");
2156 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent =
2157 TOKEN_STRING_INITIALIZER(
2158 struct cmd_set_port_tm_node_parent_result, parent, "parent");
2159 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id =
2160 TOKEN_NUM_INITIALIZER(
2161 struct cmd_set_port_tm_node_parent_result, port_id,
2163 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id =
2164 TOKEN_NUM_INITIALIZER(
2165 struct cmd_set_port_tm_node_parent_result, node_id,
2167 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id =
2168 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2169 parent_id, RTE_UINT32);
2170 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority =
2171 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2172 priority, RTE_UINT32);
2173 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight =
2174 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2175 weight, RTE_UINT32);
2177 static void cmd_set_port_tm_node_parent_parsed(void *parsed_result,
2178 __rte_unused struct cmdline *cl,
2179 __rte_unused void *data)
2181 struct cmd_set_port_tm_node_parent_result *res = parsed_result;
2182 struct rte_tm_error error;
2183 uint32_t node_id = res->node_id;
2184 uint32_t parent_id = res->parent_id;
2185 uint32_t priority = res->priority;
2186 uint32_t weight = res->weight;
2187 portid_t port_id = res->port_id;
2190 if (port_id_is_invalid(port_id, ENABLED_WARN))
2193 memset(&error, 0, sizeof(struct rte_tm_error));
2195 if (!port_is_started(port_id)) {
2196 printf(" Port %u not started (error)\n", port_id);
2200 ret = rte_tm_node_parent_update(port_id, node_id,
2201 parent_id, priority, weight, &error);
2203 print_err_msg(&error);
2208 cmdline_parse_inst_t cmd_set_port_tm_node_parent = {
2209 .f = cmd_set_port_tm_node_parent_parsed,
2211 .help_str = "Set port tm node parent",
2213 (void *)&cmd_set_port_tm_node_parent_set,
2214 (void *)&cmd_set_port_tm_node_parent_port,
2215 (void *)&cmd_set_port_tm_node_parent_tm,
2216 (void *)&cmd_set_port_tm_node_parent_node,
2217 (void *)&cmd_set_port_tm_node_parent_parent,
2218 (void *)&cmd_set_port_tm_node_parent_port_id,
2219 (void *)&cmd_set_port_tm_node_parent_node_id,
2220 (void *)&cmd_set_port_tm_node_parent_parent_id,
2221 (void *)&cmd_set_port_tm_node_parent_priority,
2222 (void *)&cmd_set_port_tm_node_parent_weight,
2227 /* *** Suspend Port TM Node *** */
2228 struct cmd_suspend_port_tm_node_result {
2229 cmdline_fixed_string_t suspend;
2230 cmdline_fixed_string_t port;
2231 cmdline_fixed_string_t tm;
2232 cmdline_fixed_string_t node;
2237 cmdline_parse_token_string_t cmd_suspend_port_tm_node_suspend =
2238 TOKEN_STRING_INITIALIZER(
2239 struct cmd_suspend_port_tm_node_result, suspend, "suspend");
2240 cmdline_parse_token_string_t cmd_suspend_port_tm_node_port =
2241 TOKEN_STRING_INITIALIZER(
2242 struct cmd_suspend_port_tm_node_result, port, "port");
2243 cmdline_parse_token_string_t cmd_suspend_port_tm_node_tm =
2244 TOKEN_STRING_INITIALIZER(
2245 struct cmd_suspend_port_tm_node_result, tm, "tm");
2246 cmdline_parse_token_string_t cmd_suspend_port_tm_node_node =
2247 TOKEN_STRING_INITIALIZER(
2248 struct cmd_suspend_port_tm_node_result, node, "node");
2249 cmdline_parse_token_num_t cmd_suspend_port_tm_node_port_id =
2250 TOKEN_NUM_INITIALIZER(
2251 struct cmd_suspend_port_tm_node_result, port_id,
2253 cmdline_parse_token_num_t cmd_suspend_port_tm_node_node_id =
2254 TOKEN_NUM_INITIALIZER(
2255 struct cmd_suspend_port_tm_node_result, node_id,
2258 static void cmd_suspend_port_tm_node_parsed(void *parsed_result,
2259 __rte_unused struct cmdline *cl,
2260 __rte_unused void *data)
2262 struct cmd_suspend_port_tm_node_result *res = parsed_result;
2263 struct rte_tm_error error;
2264 uint32_t node_id = res->node_id;
2265 portid_t port_id = res->port_id;
2268 if (port_id_is_invalid(port_id, ENABLED_WARN))
2271 memset(&error, 0, sizeof(struct rte_tm_error));
2272 ret = rte_tm_node_suspend(port_id, node_id, &error);
2274 print_err_msg(&error);
2279 cmdline_parse_inst_t cmd_suspend_port_tm_node = {
2280 .f = cmd_suspend_port_tm_node_parsed,
2282 .help_str = "Suspend port tm node",
2284 (void *)&cmd_suspend_port_tm_node_suspend,
2285 (void *)&cmd_suspend_port_tm_node_port,
2286 (void *)&cmd_suspend_port_tm_node_tm,
2287 (void *)&cmd_suspend_port_tm_node_node,
2288 (void *)&cmd_suspend_port_tm_node_port_id,
2289 (void *)&cmd_suspend_port_tm_node_node_id,
2294 /* *** Resume Port TM Node *** */
2295 struct cmd_resume_port_tm_node_result {
2296 cmdline_fixed_string_t resume;
2297 cmdline_fixed_string_t port;
2298 cmdline_fixed_string_t tm;
2299 cmdline_fixed_string_t node;
2304 cmdline_parse_token_string_t cmd_resume_port_tm_node_resume =
2305 TOKEN_STRING_INITIALIZER(
2306 struct cmd_resume_port_tm_node_result, resume, "resume");
2307 cmdline_parse_token_string_t cmd_resume_port_tm_node_port =
2308 TOKEN_STRING_INITIALIZER(
2309 struct cmd_resume_port_tm_node_result, port, "port");
2310 cmdline_parse_token_string_t cmd_resume_port_tm_node_tm =
2311 TOKEN_STRING_INITIALIZER(
2312 struct cmd_resume_port_tm_node_result, tm, "tm");
2313 cmdline_parse_token_string_t cmd_resume_port_tm_node_node =
2314 TOKEN_STRING_INITIALIZER(
2315 struct cmd_resume_port_tm_node_result, node, "node");
2316 cmdline_parse_token_num_t cmd_resume_port_tm_node_port_id =
2317 TOKEN_NUM_INITIALIZER(
2318 struct cmd_resume_port_tm_node_result, port_id, RTE_UINT16);
2319 cmdline_parse_token_num_t cmd_resume_port_tm_node_node_id =
2320 TOKEN_NUM_INITIALIZER(
2321 struct cmd_resume_port_tm_node_result, node_id, RTE_UINT32);
2323 static void cmd_resume_port_tm_node_parsed(void *parsed_result,
2324 __rte_unused struct cmdline *cl,
2325 __rte_unused void *data)
2327 struct cmd_resume_port_tm_node_result *res = parsed_result;
2328 struct rte_tm_error error;
2329 uint32_t node_id = res->node_id;
2330 portid_t port_id = res->port_id;
2333 if (port_id_is_invalid(port_id, ENABLED_WARN))
2336 memset(&error, 0, sizeof(struct rte_tm_error));
2337 ret = rte_tm_node_resume(port_id, node_id, &error);
2339 print_err_msg(&error);
2344 cmdline_parse_inst_t cmd_resume_port_tm_node = {
2345 .f = cmd_resume_port_tm_node_parsed,
2347 .help_str = "Resume port tm node",
2349 (void *)&cmd_resume_port_tm_node_resume,
2350 (void *)&cmd_resume_port_tm_node_port,
2351 (void *)&cmd_resume_port_tm_node_tm,
2352 (void *)&cmd_resume_port_tm_node_node,
2353 (void *)&cmd_resume_port_tm_node_port_id,
2354 (void *)&cmd_resume_port_tm_node_node_id,
2359 /* *** Port TM Hierarchy Commit *** */
2360 struct cmd_port_tm_hierarchy_commit_result {
2361 cmdline_fixed_string_t port;
2362 cmdline_fixed_string_t tm;
2363 cmdline_fixed_string_t hierarchy;
2364 cmdline_fixed_string_t commit;
2366 cmdline_fixed_string_t clean_on_fail;
2369 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port =
2370 TOKEN_STRING_INITIALIZER(
2371 struct cmd_port_tm_hierarchy_commit_result, port, "port");
2372 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm =
2373 TOKEN_STRING_INITIALIZER(
2374 struct cmd_port_tm_hierarchy_commit_result, tm, "tm");
2375 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy =
2376 TOKEN_STRING_INITIALIZER(
2377 struct cmd_port_tm_hierarchy_commit_result,
2378 hierarchy, "hierarchy");
2379 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit =
2380 TOKEN_STRING_INITIALIZER(
2381 struct cmd_port_tm_hierarchy_commit_result, commit, "commit");
2382 cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id =
2383 TOKEN_NUM_INITIALIZER(
2384 struct cmd_port_tm_hierarchy_commit_result,
2385 port_id, RTE_UINT16);
2386 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_clean_on_fail =
2387 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result,
2388 clean_on_fail, "yes#no");
2390 static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result,
2391 __rte_unused struct cmdline *cl,
2392 __rte_unused void *data)
2394 struct cmd_port_tm_hierarchy_commit_result *res = parsed_result;
2395 struct rte_tm_error error;
2396 uint32_t clean_on_fail;
2397 portid_t port_id = res->port_id;
2400 if (port_id_is_invalid(port_id, ENABLED_WARN))
2403 if (strcmp(res->clean_on_fail, "yes") == 0)
2408 memset(&error, 0, sizeof(struct rte_tm_error));
2409 ret = rte_tm_hierarchy_commit(port_id, clean_on_fail, &error);
2411 print_err_msg(&error);
2416 cmdline_parse_inst_t cmd_port_tm_hierarchy_commit = {
2417 .f = cmd_port_tm_hierarchy_commit_parsed,
2419 .help_str = "Commit port tm hierarchy",
2421 (void *)&cmd_port_tm_hierarchy_commit_port,
2422 (void *)&cmd_port_tm_hierarchy_commit_tm,
2423 (void *)&cmd_port_tm_hierarchy_commit_hierarchy,
2424 (void *)&cmd_port_tm_hierarchy_commit_commit,
2425 (void *)&cmd_port_tm_hierarchy_commit_port_id,
2426 (void *)&cmd_port_tm_hierarchy_commit_clean_on_fail,
2431 /* *** Port TM Mark IP ECN *** */
2432 struct cmd_port_tm_mark_ip_ecn_result {
2433 cmdline_fixed_string_t set;
2434 cmdline_fixed_string_t port;
2435 cmdline_fixed_string_t tm;
2436 cmdline_fixed_string_t mark;
2437 cmdline_fixed_string_t ip_ecn;
2444 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_set =
2445 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2448 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_port =
2449 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2452 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_tm =
2453 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result, tm,
2456 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_mark =
2457 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2460 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_ip_ecn =
2461 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2463 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_port_id =
2464 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2465 port_id, RTE_UINT16);
2467 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_green =
2468 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2470 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_yellow =
2471 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2472 yellow, RTE_UINT16);
2473 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_red =
2474 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2477 static void cmd_port_tm_mark_ip_ecn_parsed(void *parsed_result,
2478 __rte_unused struct cmdline *cl,
2479 __rte_unused void *data)
2481 struct cmd_port_tm_mark_ip_ecn_result *res = parsed_result;
2482 struct rte_tm_error error;
2483 portid_t port_id = res->port_id;
2484 int green = res->green;
2485 int yellow = res->yellow;
2488 if (port_id_is_invalid(port_id, ENABLED_WARN))
2491 memset(&error, 0, sizeof(struct rte_tm_error));
2492 ret = rte_tm_mark_ip_ecn(port_id, green, yellow, red, &error);
2494 print_err_msg(&error);
2499 cmdline_parse_inst_t cmd_port_tm_mark_ip_ecn = {
2500 .f = cmd_port_tm_mark_ip_ecn_parsed,
2502 .help_str = "set port tm mark ip_ecn <port> <green> <yellow> <red>",
2504 (void *)&cmd_port_tm_mark_ip_ecn_set,
2505 (void *)&cmd_port_tm_mark_ip_ecn_port,
2506 (void *)&cmd_port_tm_mark_ip_ecn_tm,
2507 (void *)&cmd_port_tm_mark_ip_ecn_mark,
2508 (void *)&cmd_port_tm_mark_ip_ecn_ip_ecn,
2509 (void *)&cmd_port_tm_mark_ip_ecn_port_id,
2510 (void *)&cmd_port_tm_mark_ip_ecn_green,
2511 (void *)&cmd_port_tm_mark_ip_ecn_yellow,
2512 (void *)&cmd_port_tm_mark_ip_ecn_red,
2518 /* *** Port TM Mark IP DSCP *** */
2519 struct cmd_port_tm_mark_ip_dscp_result {
2520 cmdline_fixed_string_t set;
2521 cmdline_fixed_string_t port;
2522 cmdline_fixed_string_t tm;
2523 cmdline_fixed_string_t mark;
2524 cmdline_fixed_string_t ip_dscp;
2531 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_set =
2532 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2535 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_port =
2536 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2539 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_tm =
2540 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result, tm,
2543 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_mark =
2544 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2547 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_ip_dscp =
2548 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2549 ip_dscp, "ip_dscp");
2550 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_port_id =
2551 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2552 port_id, RTE_UINT16);
2554 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_green =
2555 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2557 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_yellow =
2558 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2559 yellow, RTE_UINT16);
2560 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_red =
2561 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2564 static void cmd_port_tm_mark_ip_dscp_parsed(void *parsed_result,
2565 __rte_unused struct cmdline *cl,
2566 __rte_unused void *data)
2568 struct cmd_port_tm_mark_ip_dscp_result *res = parsed_result;
2569 struct rte_tm_error error;
2570 portid_t port_id = res->port_id;
2571 int green = res->green;
2572 int yellow = res->yellow;
2575 if (port_id_is_invalid(port_id, ENABLED_WARN))
2578 memset(&error, 0, sizeof(struct rte_tm_error));
2579 ret = rte_tm_mark_ip_dscp(port_id, green, yellow, red, &error);
2581 print_err_msg(&error);
2586 cmdline_parse_inst_t cmd_port_tm_mark_ip_dscp = {
2587 .f = cmd_port_tm_mark_ip_dscp_parsed,
2589 .help_str = "set port tm mark ip_dscp <port> <green> <yellow> <red>",
2591 (void *)&cmd_port_tm_mark_ip_dscp_set,
2592 (void *)&cmd_port_tm_mark_ip_dscp_port,
2593 (void *)&cmd_port_tm_mark_ip_dscp_tm,
2594 (void *)&cmd_port_tm_mark_ip_dscp_mark,
2595 (void *)&cmd_port_tm_mark_ip_dscp_ip_dscp,
2596 (void *)&cmd_port_tm_mark_ip_dscp_port_id,
2597 (void *)&cmd_port_tm_mark_ip_dscp_green,
2598 (void *)&cmd_port_tm_mark_ip_dscp_yellow,
2599 (void *)&cmd_port_tm_mark_ip_dscp_red,
2605 /* *** Port TM Mark VLAN_DEI *** */
2606 struct cmd_port_tm_mark_vlan_dei_result {
2607 cmdline_fixed_string_t set;
2608 cmdline_fixed_string_t port;
2609 cmdline_fixed_string_t tm;
2610 cmdline_fixed_string_t mark;
2611 cmdline_fixed_string_t vlan_dei;
2618 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_set =
2619 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2622 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_port =
2623 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2626 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_tm =
2627 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result, tm,
2630 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_mark =
2631 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2634 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_vlan_dei =
2635 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2636 vlan_dei, "vlan_dei");
2637 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_port_id =
2638 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2639 port_id, RTE_UINT16);
2641 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_green =
2642 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2644 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_yellow =
2645 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2646 yellow, RTE_UINT16);
2647 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_red =
2648 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2651 static void cmd_port_tm_mark_vlan_dei_parsed(void *parsed_result,
2652 __rte_unused struct cmdline *cl,
2653 __rte_unused void *data)
2655 struct cmd_port_tm_mark_vlan_dei_result *res = parsed_result;
2656 struct rte_tm_error error;
2657 portid_t port_id = res->port_id;
2658 int green = res->green;
2659 int yellow = res->yellow;
2662 if (port_id_is_invalid(port_id, ENABLED_WARN))
2665 memset(&error, 0, sizeof(struct rte_tm_error));
2666 ret = rte_tm_mark_vlan_dei(port_id, green, yellow, red, &error);
2668 print_err_msg(&error);
2673 cmdline_parse_inst_t cmd_port_tm_mark_vlan_dei = {
2674 .f = cmd_port_tm_mark_vlan_dei_parsed,
2676 .help_str = "set port tm mark vlan_dei <port> <green> <yellow> <red>",
2678 (void *)&cmd_port_tm_mark_vlan_dei_set,
2679 (void *)&cmd_port_tm_mark_vlan_dei_port,
2680 (void *)&cmd_port_tm_mark_vlan_dei_tm,
2681 (void *)&cmd_port_tm_mark_vlan_dei_mark,
2682 (void *)&cmd_port_tm_mark_vlan_dei_vlan_dei,
2683 (void *)&cmd_port_tm_mark_vlan_dei_port_id,
2684 (void *)&cmd_port_tm_mark_vlan_dei_green,
2685 (void *)&cmd_port_tm_mark_vlan_dei_yellow,
2686 (void *)&cmd_port_tm_mark_vlan_dei_red,