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 fprintf(stderr, "%s: %s%s (error %d)\n",
101 errstr, error->cause ? buf : "",
102 error->message ? error->message : "(no stated reason)",
107 read_uint64(uint64_t *value, const char *p)
112 p = skip_white_spaces(p);
116 val = strtoul(p, &next, 10);
138 p = skip_white_spaces(p);
147 read_uint32(uint32_t *value, const char *p)
150 int ret = read_uint64(&val, p);
155 if (val > UINT32_MAX)
163 parse_multi_ss_id_str(char *s_str, uint32_t *n_ssp, uint32_t shaper_id[])
165 uint32_t n_shared_shapers = 0, i = 0;
168 /* First token: num of shared shapers */
169 token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
173 if (read_uint32(&n_shared_shapers, token))
176 /* Check: num of shared shaper */
177 if (n_shared_shapers >= MAX_NUM_SHARED_SHAPERS) {
179 " Number of shared shapers exceed the max (error)\n");
183 /* Parse shared shaper ids */
185 token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
186 if ((token != NULL && n_shared_shapers == 0) ||
187 (token == NULL && i < n_shared_shapers))
193 if (read_uint32(&shaper_id[i], token))
197 *n_ssp = n_shared_shapers;
201 /* *** Port TM Capability *** */
202 struct cmd_show_port_tm_cap_result {
203 cmdline_fixed_string_t show;
204 cmdline_fixed_string_t port;
205 cmdline_fixed_string_t tm;
206 cmdline_fixed_string_t cap;
210 cmdline_parse_token_string_t cmd_show_port_tm_cap_show =
211 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
213 cmdline_parse_token_string_t cmd_show_port_tm_cap_port =
214 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
216 cmdline_parse_token_string_t cmd_show_port_tm_cap_tm =
217 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
219 cmdline_parse_token_string_t cmd_show_port_tm_cap_cap =
220 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
222 cmdline_parse_token_num_t cmd_show_port_tm_cap_port_id =
223 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_cap_result,
224 port_id, RTE_UINT16);
226 static void cmd_show_port_tm_cap_parsed(void *parsed_result,
227 __rte_unused struct cmdline *cl,
228 __rte_unused void *data)
230 struct cmd_show_port_tm_cap_result *res = parsed_result;
231 struct rte_tm_capabilities cap;
232 struct rte_tm_error error;
233 portid_t port_id = res->port_id;
237 if (port_id_is_invalid(port_id, ENABLED_WARN))
240 memset(&cap, 0, sizeof(struct rte_tm_capabilities));
241 memset(&error, 0, sizeof(struct rte_tm_error));
242 ret = rte_tm_capabilities_get(port_id, &cap, &error);
244 print_err_msg(&error);
248 printf("\n**** Port TM Capabilities ****\n\n");
249 printf("cap.n_nodes_max %" PRIu32 "\n", cap.n_nodes_max);
250 printf("cap.n_levels_max %" PRIu32 "\n", cap.n_levels_max);
251 printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
252 cap.non_leaf_nodes_identical);
253 printf("cap.leaf_nodes_identical %" PRId32 "\n",
254 cap.leaf_nodes_identical);
255 printf("cap.shaper_n_max %u\n", cap.shaper_n_max);
256 printf("cap.shaper_private_n_max %" PRIu32 "\n",
257 cap.shaper_private_n_max);
258 printf("cap.shaper_private_dual_rate_n_max %" PRId32 "\n",
259 cap.shaper_private_dual_rate_n_max);
260 printf("cap.shaper_private_rate_min %" PRIu64 "\n",
261 cap.shaper_private_rate_min);
262 printf("cap.shaper_private_rate_max %" PRIu64 "\n",
263 cap.shaper_private_rate_max);
264 printf("cap.shaper_private_packet_mode_supported %" PRId32 "\n",
265 cap.shaper_private_packet_mode_supported);
266 printf("cap.shaper_private_byte_mode_supported %" PRId32 "\n",
267 cap.shaper_private_byte_mode_supported);
268 printf("cap.shaper_shared_n_max %" PRIu32 "\n",
269 cap.shaper_shared_n_max);
270 printf("cap.shaper_shared_n_nodes_per_shaper_max %" PRIu32 "\n",
271 cap.shaper_shared_n_nodes_per_shaper_max);
272 printf("cap.shaper_shared_n_shapers_per_node_max %" PRIu32 "\n",
273 cap.shaper_shared_n_shapers_per_node_max);
274 printf("cap.shaper_shared_dual_rate_n_max %" PRIu32 "\n",
275 cap.shaper_shared_dual_rate_n_max);
276 printf("cap.shaper_shared_rate_min %" PRIu64 "\n",
277 cap.shaper_shared_rate_min);
278 printf("cap.shaper_shared_rate_max %" PRIu64 "\n",
279 cap.shaper_shared_rate_max);
280 printf("cap.shaper_shared_packet_mode_supported %" PRId32 "\n",
281 cap.shaper_shared_packet_mode_supported);
282 printf("cap.shaper_shared_byte_mode_supported %" PRId32 "\n",
283 cap.shaper_shared_byte_mode_supported);
284 printf("cap.shaper_pkt_length_adjust_min %" PRId32 "\n",
285 cap.shaper_pkt_length_adjust_min);
286 printf("cap.shaper_pkt_length_adjust_max %" PRId32 "\n",
287 cap.shaper_pkt_length_adjust_max);
288 printf("cap.sched_n_children_max %" PRIu32 "\n",
289 cap.sched_n_children_max);
290 printf("cap.sched_sp_n_priorities_max %" PRIu32 "\n",
291 cap.sched_sp_n_priorities_max);
292 printf("cap.sched_wfq_n_children_per_group_max %" PRIu32 "\n",
293 cap.sched_wfq_n_children_per_group_max);
294 printf("cap.sched_wfq_n_groups_max %" PRIu32 "\n",
295 cap.sched_wfq_n_groups_max);
296 printf("cap.sched_wfq_weight_max %" PRIu32 "\n",
297 cap.sched_wfq_weight_max);
298 printf("cap.sched_wfq_packet_mode_supported %" PRId32 "\n",
299 cap.sched_wfq_packet_mode_supported);
300 printf("cap.sched_wfq_byte_mode_supported %" PRId32 "\n",
301 cap.sched_wfq_byte_mode_supported);
302 printf("cap.cman_head_drop_supported %" PRId32 "\n",
303 cap.cman_head_drop_supported);
304 printf("cap.cman_wred_context_n_max %" PRIu32 "\n",
305 cap.cman_wred_context_n_max);
306 printf("cap.cman_wred_context_private_n_max %" PRIu32 "\n",
307 cap.cman_wred_context_private_n_max);
308 printf("cap.cman_wred_context_shared_n_max %" PRIu32 "\n",
309 cap.cman_wred_context_shared_n_max);
310 printf("cap.cman_wred_context_shared_n_nodes_per_context_max %" PRIu32
311 "\n", cap.cman_wred_context_shared_n_nodes_per_context_max);
312 printf("cap.cman_wred_context_shared_n_contexts_per_node_max %" PRIu32
313 "\n", cap.cman_wred_context_shared_n_contexts_per_node_max);
315 for (i = 0; i < RTE_COLORS; i++) {
316 printf("cap.mark_vlan_dei_supported %" PRId32 "\n",
317 cap.mark_vlan_dei_supported[i]);
318 printf("cap.mark_ip_ecn_tcp_supported %" PRId32 "\n",
319 cap.mark_ip_ecn_tcp_supported[i]);
320 printf("cap.mark_ip_ecn_sctp_supported %" PRId32 "\n",
321 cap.mark_ip_ecn_sctp_supported[i]);
322 printf("cap.mark_ip_dscp_supported %" PRId32 "\n",
323 cap.mark_ip_dscp_supported[i]);
326 printf("cap.dynamic_update_mask %" PRIx64 "\n",
327 cap.dynamic_update_mask);
328 printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
331 cmdline_parse_inst_t cmd_show_port_tm_cap = {
332 .f = cmd_show_port_tm_cap_parsed,
334 .help_str = "Show Port TM Capabilities",
336 (void *)&cmd_show_port_tm_cap_show,
337 (void *)&cmd_show_port_tm_cap_port,
338 (void *)&cmd_show_port_tm_cap_tm,
339 (void *)&cmd_show_port_tm_cap_cap,
340 (void *)&cmd_show_port_tm_cap_port_id,
345 /* *** Port TM Hierarchical Level Capability *** */
346 struct cmd_show_port_tm_level_cap_result {
347 cmdline_fixed_string_t show;
348 cmdline_fixed_string_t port;
349 cmdline_fixed_string_t tm;
350 cmdline_fixed_string_t level;
351 cmdline_fixed_string_t cap;
356 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_show =
357 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
359 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_port =
360 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
362 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_tm =
363 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
365 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_level =
366 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
368 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_cap =
369 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
371 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_port_id =
372 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
373 port_id, RTE_UINT16);
374 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_level_id =
375 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
376 level_id, RTE_UINT32);
379 static void cmd_show_port_tm_level_cap_parsed(void *parsed_result,
380 __rte_unused struct cmdline *cl,
381 __rte_unused void *data)
383 struct cmd_show_port_tm_level_cap_result *res = parsed_result;
384 struct rte_tm_level_capabilities lcap;
385 struct rte_tm_error error;
386 portid_t port_id = res->port_id;
387 uint32_t level_id = res->level_id;
390 if (port_id_is_invalid(port_id, ENABLED_WARN))
393 memset(&lcap, 0, sizeof(struct rte_tm_level_capabilities));
394 memset(&error, 0, sizeof(struct rte_tm_error));
395 ret = rte_tm_level_capabilities_get(port_id, level_id, &lcap, &error);
397 print_err_msg(&error);
400 printf("\n** Port TM Hierarchy level %" PRIu32 " Capability **\n\n",
403 printf("cap.n_nodes_max %" PRIu32 "\n", lcap.n_nodes_max);
404 printf("cap.n_nodes_nonleaf_max %" PRIu32 "\n",
405 lcap.n_nodes_nonleaf_max);
406 printf("cap.n_nodes_leaf_max %" PRIu32 "\n", lcap.n_nodes_leaf_max);
407 printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
408 lcap.non_leaf_nodes_identical);
409 printf("cap.leaf_nodes_identical %" PRId32 "\n",
410 lcap.leaf_nodes_identical);
412 printf("cap.nonleaf.shaper_private_supported %" PRId32 "\n",
413 lcap.nonleaf.shaper_private_supported);
414 printf("cap.nonleaf.shaper_private_dual_rate_supported %" PRId32
415 "\n", lcap.nonleaf.shaper_private_dual_rate_supported);
416 printf("cap.nonleaf.shaper_private_rate_min %" PRIu64 "\n",
417 lcap.nonleaf.shaper_private_rate_min);
418 printf("cap.nonleaf.shaper_private_rate_max %" PRIu64 "\n",
419 lcap.nonleaf.shaper_private_rate_max);
420 printf("cap.nonleaf.shaper_private_packet_mode_supported %"
422 lcap.nonleaf.shaper_private_packet_mode_supported);
423 printf("cap.nonleaf.shaper_private_byte_mode_supported %" PRId32
424 "\n", lcap.nonleaf.shaper_private_byte_mode_supported);
425 printf("cap.nonleaf.shaper_shared_n_max %" PRIu32 "\n",
426 lcap.nonleaf.shaper_shared_n_max);
427 printf("cap.nonleaf.shaper_shared_packet_mode_supported %"
429 lcap.nonleaf.shaper_shared_packet_mode_supported);
430 printf("cap.nonleaf.shaper_shared_byte_mode_supported %"
432 lcap.nonleaf.shaper_shared_byte_mode_supported);
433 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
434 lcap.nonleaf.sched_n_children_max);
435 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
436 lcap.nonleaf.sched_sp_n_priorities_max);
437 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
438 "\n", lcap.nonleaf.sched_wfq_n_children_per_group_max);
439 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
440 lcap.nonleaf.sched_wfq_n_groups_max);
441 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
442 lcap.nonleaf.sched_wfq_weight_max);
443 printf("cap.nonleaf.sched_wfq_packet_mode_supported %" PRId32 "\n",
444 lcap.nonleaf.sched_wfq_packet_mode_supported);
445 printf("cap.nonleaf.sched_wfq_byte_mode_supported %" PRId32
446 "\n", lcap.nonleaf.sched_wfq_byte_mode_supported);
447 printf("cap.nonleaf.stats_mask %" PRIx64 "\n",
448 lcap.nonleaf.stats_mask);
450 printf("cap.leaf.shaper_private_supported %" PRId32 "\n",
451 lcap.leaf.shaper_private_supported);
452 printf("cap.leaf.shaper_private_dual_rate_supported %" PRId32
453 "\n", lcap.leaf.shaper_private_dual_rate_supported);
454 printf("cap.leaf.shaper_private_rate_min %" PRIu64 "\n",
455 lcap.leaf.shaper_private_rate_min);
456 printf("cap.leaf.shaper_private_rate_max %" PRIu64 "\n",
457 lcap.leaf.shaper_private_rate_max);
458 printf("cap.leaf.shaper_private_packet_mode_supported %" PRId32
459 "\n", lcap.leaf.shaper_private_packet_mode_supported);
460 printf("cap.leaf.shaper_private_byte_mode_supported %" PRId32 "\n",
461 lcap.leaf.shaper_private_byte_mode_supported);
462 printf("cap.leaf.shaper_shared_n_max %" PRIu32 "\n",
463 lcap.leaf.shaper_shared_n_max);
464 printf("cap.leaf.shaper_shared_packet_mode_supported %" PRId32 "\n",
465 lcap.leaf.shaper_shared_packet_mode_supported);
466 printf("cap.leaf.shaper_shared_byte_mode_supported %" PRId32 "\n",
467 lcap.leaf.shaper_shared_byte_mode_supported);
468 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
469 lcap.leaf.cman_head_drop_supported);
470 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
471 "\n", lcap.leaf.cman_wred_context_private_supported);
472 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
473 lcap.leaf.cman_wred_context_shared_n_max);
474 printf("cap.leaf.stats_mask %" PRIx64 "\n",
475 lcap.leaf.stats_mask);
479 cmdline_parse_inst_t cmd_show_port_tm_level_cap = {
480 .f = cmd_show_port_tm_level_cap_parsed,
482 .help_str = "Show Port TM Hierarhical level Capabilities",
484 (void *)&cmd_show_port_tm_level_cap_show,
485 (void *)&cmd_show_port_tm_level_cap_port,
486 (void *)&cmd_show_port_tm_level_cap_tm,
487 (void *)&cmd_show_port_tm_level_cap_level,
488 (void *)&cmd_show_port_tm_level_cap_cap,
489 (void *)&cmd_show_port_tm_level_cap_port_id,
490 (void *)&cmd_show_port_tm_level_cap_level_id,
495 /* *** Port TM Hierarchy Node Capability *** */
496 struct cmd_show_port_tm_node_cap_result {
497 cmdline_fixed_string_t show;
498 cmdline_fixed_string_t port;
499 cmdline_fixed_string_t tm;
500 cmdline_fixed_string_t node;
501 cmdline_fixed_string_t cap;
506 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_show =
507 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
509 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_port =
510 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
512 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_tm =
513 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
515 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_node =
516 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
518 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_cap =
519 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
521 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_port_id =
522 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
523 port_id, RTE_UINT16);
524 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_node_id =
525 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
526 node_id, RTE_UINT32);
528 static void cmd_show_port_tm_node_cap_parsed(void *parsed_result,
529 __rte_unused struct cmdline *cl,
530 __rte_unused void *data)
532 struct cmd_show_port_tm_node_cap_result *res = parsed_result;
533 struct rte_tm_node_capabilities ncap;
534 struct rte_tm_error error;
535 uint32_t node_id = res->node_id;
536 portid_t port_id = res->port_id;
537 int ret, is_leaf = 0;
539 if (port_id_is_invalid(port_id, ENABLED_WARN))
542 memset(&error, 0, sizeof(struct rte_tm_error));
543 /* Node id must be valid */
544 ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
546 print_err_msg(&error);
550 memset(&ncap, 0, sizeof(struct rte_tm_node_capabilities));
551 ret = rte_tm_node_capabilities_get(port_id, node_id, &ncap, &error);
553 print_err_msg(&error);
556 printf("\n** Port TM Hierarchy node %" PRIu32 " Capability **\n\n",
558 printf("cap.shaper_private_supported %" PRId32 "\n",
559 ncap.shaper_private_supported);
560 printf("cap.shaper_private_dual_rate_supported %" PRId32 "\n",
561 ncap.shaper_private_dual_rate_supported);
562 printf("cap.shaper_private_rate_min %" PRIu64 "\n",
563 ncap.shaper_private_rate_min);
564 printf("cap.shaper_private_rate_max %" PRIu64 "\n",
565 ncap.shaper_private_rate_max);
566 printf("cap.shaper_private_packet_mode_supported %" PRId32 "\n",
567 ncap.shaper_private_packet_mode_supported);
568 printf("cap.shaper_private_byte_mode_supported %" PRId32 "\n",
569 ncap.shaper_private_byte_mode_supported);
570 printf("cap.shaper_shared_n_max %" PRIu32 "\n",
571 ncap.shaper_shared_n_max);
572 printf("cap.shaper_shared_packet_mode_supported %" PRId32 "\n",
573 ncap.shaper_shared_packet_mode_supported);
574 printf("cap.shaper_shared_byte_mode_supported %" PRId32 "\n",
575 ncap.shaper_shared_byte_mode_supported);
577 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
578 ncap.nonleaf.sched_n_children_max);
579 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
580 ncap.nonleaf.sched_sp_n_priorities_max);
581 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
582 "\n", ncap.nonleaf.sched_wfq_n_children_per_group_max);
583 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
584 ncap.nonleaf.sched_wfq_n_groups_max);
585 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
586 ncap.nonleaf.sched_wfq_weight_max);
587 printf("cap.nonleaf.sched_wfq_packet_mode_supported %" PRId32 "\n",
588 ncap.nonleaf.sched_wfq_packet_mode_supported);
589 printf("cap.nonleaf.sched_wfq_byte_mode_supported %" PRId32 "\n",
590 ncap.nonleaf.sched_wfq_byte_mode_supported);
592 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
593 ncap.leaf.cman_head_drop_supported);
594 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
595 "\n", ncap.leaf.cman_wred_context_private_supported);
596 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
597 ncap.leaf.cman_wred_context_shared_n_max);
599 printf("cap.stats_mask %" PRIx64 "\n", ncap.stats_mask);
602 cmdline_parse_inst_t cmd_show_port_tm_node_cap = {
603 .f = cmd_show_port_tm_node_cap_parsed,
605 .help_str = "Show Port TM Hierarchy node capabilities",
607 (void *)&cmd_show_port_tm_node_cap_show,
608 (void *)&cmd_show_port_tm_node_cap_port,
609 (void *)&cmd_show_port_tm_node_cap_tm,
610 (void *)&cmd_show_port_tm_node_cap_node,
611 (void *)&cmd_show_port_tm_node_cap_cap,
612 (void *)&cmd_show_port_tm_node_cap_port_id,
613 (void *)&cmd_show_port_tm_node_cap_node_id,
618 /* *** Show Port TM Node Statistics *** */
619 struct cmd_show_port_tm_node_stats_result {
620 cmdline_fixed_string_t show;
621 cmdline_fixed_string_t port;
622 cmdline_fixed_string_t tm;
623 cmdline_fixed_string_t node;
624 cmdline_fixed_string_t stats;
630 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_show =
631 TOKEN_STRING_INITIALIZER(
632 struct cmd_show_port_tm_node_stats_result, show, "show");
633 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_port =
634 TOKEN_STRING_INITIALIZER(
635 struct cmd_show_port_tm_node_stats_result, port, "port");
636 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_tm =
637 TOKEN_STRING_INITIALIZER(
638 struct cmd_show_port_tm_node_stats_result, tm, "tm");
639 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_node =
640 TOKEN_STRING_INITIALIZER(
641 struct cmd_show_port_tm_node_stats_result, node, "node");
642 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_stats =
643 TOKEN_STRING_INITIALIZER(
644 struct cmd_show_port_tm_node_stats_result, stats, "stats");
645 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_port_id =
646 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_stats_result,
647 port_id, RTE_UINT16);
648 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_node_id =
649 TOKEN_NUM_INITIALIZER(
650 struct cmd_show_port_tm_node_stats_result,
651 node_id, RTE_UINT32);
652 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_clear =
653 TOKEN_NUM_INITIALIZER(
654 struct cmd_show_port_tm_node_stats_result, clear, RTE_UINT32);
656 static void cmd_show_port_tm_node_stats_parsed(void *parsed_result,
657 __rte_unused struct cmdline *cl,
658 __rte_unused void *data)
660 struct cmd_show_port_tm_node_stats_result *res = parsed_result;
661 struct rte_tm_node_stats stats;
662 struct rte_tm_error error;
663 uint64_t stats_mask = 0;
664 uint32_t node_id = res->node_id;
665 uint32_t clear = res->clear;
666 portid_t port_id = res->port_id;
669 if (port_id_is_invalid(port_id, ENABLED_WARN))
672 memset(&error, 0, sizeof(struct rte_tm_error));
674 if (!port_is_started(port_id)) {
675 fprintf(stderr, " Port %u not started (error)\n", port_id);
679 memset(&stats, 0, sizeof(struct rte_tm_node_stats));
680 ret = rte_tm_node_stats_read(port_id, node_id, &stats,
681 &stats_mask, clear, &error);
683 print_err_msg(&error);
688 if (stats_mask & RTE_TM_STATS_N_PKTS)
689 printf("\tPkts scheduled from node: %" PRIu64 "\n",
691 if (stats_mask & RTE_TM_STATS_N_BYTES)
692 printf("\tBytes scheduled from node: %" PRIu64 "\n",
694 if (stats_mask & RTE_TM_STATS_N_PKTS_GREEN_DROPPED)
695 printf("\tPkts dropped (green): %" PRIu64 "\n",
696 stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN]);
697 if (stats_mask & RTE_TM_STATS_N_PKTS_YELLOW_DROPPED)
698 printf("\tPkts dropped (yellow): %" PRIu64 "\n",
699 stats.leaf.n_pkts_dropped[RTE_COLOR_YELLOW]);
700 if (stats_mask & RTE_TM_STATS_N_PKTS_RED_DROPPED)
701 printf("\tPkts dropped (red): %" PRIu64 "\n",
702 stats.leaf.n_pkts_dropped[RTE_COLOR_RED]);
703 if (stats_mask & RTE_TM_STATS_N_BYTES_GREEN_DROPPED)
704 printf("\tBytes dropped (green): %" PRIu64 "\n",
705 stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN]);
706 if (stats_mask & RTE_TM_STATS_N_BYTES_YELLOW_DROPPED)
707 printf("\tBytes dropped (yellow): %" PRIu64 "\n",
708 stats.leaf.n_bytes_dropped[RTE_COLOR_YELLOW]);
709 if (stats_mask & RTE_TM_STATS_N_BYTES_RED_DROPPED)
710 printf("\tBytes dropped (red): %" PRIu64 "\n",
711 stats.leaf.n_bytes_dropped[RTE_COLOR_RED]);
712 if (stats_mask & RTE_TM_STATS_N_PKTS_QUEUED)
713 printf("\tPkts queued: %" PRIu64 "\n",
714 stats.leaf.n_pkts_queued);
715 if (stats_mask & RTE_TM_STATS_N_BYTES_QUEUED)
716 printf("\tBytes queued: %" PRIu64 "\n",
717 stats.leaf.n_bytes_queued);
720 cmdline_parse_inst_t cmd_show_port_tm_node_stats = {
721 .f = cmd_show_port_tm_node_stats_parsed,
723 .help_str = "Show port tm node stats",
725 (void *)&cmd_show_port_tm_node_stats_show,
726 (void *)&cmd_show_port_tm_node_stats_port,
727 (void *)&cmd_show_port_tm_node_stats_tm,
728 (void *)&cmd_show_port_tm_node_stats_node,
729 (void *)&cmd_show_port_tm_node_stats_stats,
730 (void *)&cmd_show_port_tm_node_stats_port_id,
731 (void *)&cmd_show_port_tm_node_stats_node_id,
732 (void *)&cmd_show_port_tm_node_stats_clear,
737 /* *** Show Port TM Node Type *** */
738 struct cmd_show_port_tm_node_type_result {
739 cmdline_fixed_string_t show;
740 cmdline_fixed_string_t port;
741 cmdline_fixed_string_t tm;
742 cmdline_fixed_string_t node;
743 cmdline_fixed_string_t type;
748 cmdline_parse_token_string_t cmd_show_port_tm_node_type_show =
749 TOKEN_STRING_INITIALIZER(
750 struct cmd_show_port_tm_node_type_result, show, "show");
751 cmdline_parse_token_string_t cmd_show_port_tm_node_type_port =
752 TOKEN_STRING_INITIALIZER(
753 struct cmd_show_port_tm_node_type_result, port, "port");
754 cmdline_parse_token_string_t cmd_show_port_tm_node_type_tm =
755 TOKEN_STRING_INITIALIZER(
756 struct cmd_show_port_tm_node_type_result, tm, "tm");
757 cmdline_parse_token_string_t cmd_show_port_tm_node_type_node =
758 TOKEN_STRING_INITIALIZER(
759 struct cmd_show_port_tm_node_type_result, node, "node");
760 cmdline_parse_token_string_t cmd_show_port_tm_node_type_type =
761 TOKEN_STRING_INITIALIZER(
762 struct cmd_show_port_tm_node_type_result, type, "type");
763 cmdline_parse_token_num_t cmd_show_port_tm_node_type_port_id =
764 TOKEN_NUM_INITIALIZER(
765 struct cmd_show_port_tm_node_type_result,
766 port_id, RTE_UINT16);
767 cmdline_parse_token_num_t cmd_show_port_tm_node_type_node_id =
768 TOKEN_NUM_INITIALIZER(
769 struct cmd_show_port_tm_node_type_result,
770 node_id, RTE_UINT32);
772 static void cmd_show_port_tm_node_type_parsed(void *parsed_result,
773 __rte_unused struct cmdline *cl,
774 __rte_unused void *data)
776 struct cmd_show_port_tm_node_type_result *res = parsed_result;
777 struct rte_tm_error error;
778 uint32_t node_id = res->node_id;
779 portid_t port_id = res->port_id;
780 int ret, is_leaf = 0;
782 if (port_id_is_invalid(port_id, ENABLED_WARN))
785 memset(&error, 0, sizeof(struct rte_tm_error));
786 ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
788 print_err_msg(&error);
793 printf("leaf node\n");
795 printf("nonleaf node\n");
799 cmdline_parse_inst_t cmd_show_port_tm_node_type = {
800 .f = cmd_show_port_tm_node_type_parsed,
802 .help_str = "Show port tm node type",
804 (void *)&cmd_show_port_tm_node_type_show,
805 (void *)&cmd_show_port_tm_node_type_port,
806 (void *)&cmd_show_port_tm_node_type_tm,
807 (void *)&cmd_show_port_tm_node_type_node,
808 (void *)&cmd_show_port_tm_node_type_type,
809 (void *)&cmd_show_port_tm_node_type_port_id,
810 (void *)&cmd_show_port_tm_node_type_node_id,
815 /* *** Add Port TM Private Shaper Profile *** */
816 struct cmd_add_port_tm_node_shaper_profile_result {
817 cmdline_fixed_string_t add;
818 cmdline_fixed_string_t port;
819 cmdline_fixed_string_t tm;
820 cmdline_fixed_string_t node;
821 cmdline_fixed_string_t shaper;
822 cmdline_fixed_string_t profile;
825 uint64_t cmit_tb_rate;
826 uint64_t cmit_tb_size;
827 uint64_t peak_tb_rate;
828 uint64_t peak_tb_size;
829 uint32_t pktlen_adjust;
833 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add =
834 TOKEN_STRING_INITIALIZER(
835 struct cmd_add_port_tm_node_shaper_profile_result, add, "add");
836 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port =
837 TOKEN_STRING_INITIALIZER(
838 struct cmd_add_port_tm_node_shaper_profile_result,
840 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm =
841 TOKEN_STRING_INITIALIZER(
842 struct cmd_add_port_tm_node_shaper_profile_result,
844 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node =
845 TOKEN_STRING_INITIALIZER(
846 struct cmd_add_port_tm_node_shaper_profile_result,
848 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper =
849 TOKEN_STRING_INITIALIZER(
850 struct cmd_add_port_tm_node_shaper_profile_result,
852 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile =
853 TOKEN_STRING_INITIALIZER(
854 struct cmd_add_port_tm_node_shaper_profile_result,
856 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id =
857 TOKEN_NUM_INITIALIZER(
858 struct cmd_add_port_tm_node_shaper_profile_result,
859 port_id, RTE_UINT16);
860 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id =
861 TOKEN_NUM_INITIALIZER(
862 struct cmd_add_port_tm_node_shaper_profile_result,
863 shaper_id, RTE_UINT32);
864 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_rate =
865 TOKEN_NUM_INITIALIZER(
866 struct cmd_add_port_tm_node_shaper_profile_result,
867 cmit_tb_rate, RTE_UINT64);
868 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_size =
869 TOKEN_NUM_INITIALIZER(
870 struct cmd_add_port_tm_node_shaper_profile_result,
871 cmit_tb_size, RTE_UINT64);
872 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_rate =
873 TOKEN_NUM_INITIALIZER(
874 struct cmd_add_port_tm_node_shaper_profile_result,
875 peak_tb_rate, RTE_UINT64);
876 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_size =
877 TOKEN_NUM_INITIALIZER(
878 struct cmd_add_port_tm_node_shaper_profile_result,
879 peak_tb_size, RTE_UINT64);
880 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust =
881 TOKEN_NUM_INITIALIZER(
882 struct cmd_add_port_tm_node_shaper_profile_result,
883 pktlen_adjust, RTE_UINT32);
884 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_packet_mode =
885 TOKEN_NUM_INITIALIZER(
886 struct cmd_add_port_tm_node_shaper_profile_result,
887 pkt_mode, RTE_UINT32);
889 static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
890 __rte_unused struct cmdline *cl,
891 __rte_unused void *data)
893 struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result;
894 struct rte_tm_shaper_params sp;
895 struct rte_tm_error error;
896 uint32_t shaper_id = res->shaper_id;
897 uint32_t pkt_len_adjust = res->pktlen_adjust;
898 portid_t port_id = res->port_id;
901 if (port_id_is_invalid(port_id, ENABLED_WARN))
904 /* Private shaper profile params */
905 memset(&sp, 0, sizeof(struct rte_tm_shaper_params));
906 memset(&error, 0, sizeof(struct rte_tm_error));
907 sp.committed.rate = res->cmit_tb_rate;
908 sp.committed.size = res->cmit_tb_size;
909 sp.peak.rate = res->peak_tb_rate;
910 sp.peak.size = res->peak_tb_size;
911 sp.pkt_length_adjust = pkt_len_adjust;
912 sp.packet_mode = res->pkt_mode;
914 ret = rte_tm_shaper_profile_add(port_id, shaper_id, &sp, &error);
916 print_err_msg(&error);
921 cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile = {
922 .f = cmd_add_port_tm_node_shaper_profile_parsed,
924 .help_str = "Add port tm node private shaper profile",
926 (void *)&cmd_add_port_tm_node_shaper_profile_add,
927 (void *)&cmd_add_port_tm_node_shaper_profile_port,
928 (void *)&cmd_add_port_tm_node_shaper_profile_tm,
929 (void *)&cmd_add_port_tm_node_shaper_profile_node,
930 (void *)&cmd_add_port_tm_node_shaper_profile_shaper,
931 (void *)&cmd_add_port_tm_node_shaper_profile_profile,
932 (void *)&cmd_add_port_tm_node_shaper_profile_port_id,
933 (void *)&cmd_add_port_tm_node_shaper_profile_shaper_id,
934 (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_rate,
935 (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_size,
936 (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_rate,
937 (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_size,
938 (void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust,
939 (void *)&cmd_add_port_tm_node_shaper_profile_packet_mode,
944 /* *** Delete Port TM Private Shaper Profile *** */
945 struct cmd_del_port_tm_node_shaper_profile_result {
946 cmdline_fixed_string_t del;
947 cmdline_fixed_string_t port;
948 cmdline_fixed_string_t tm;
949 cmdline_fixed_string_t node;
950 cmdline_fixed_string_t shaper;
951 cmdline_fixed_string_t profile;
956 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del =
957 TOKEN_STRING_INITIALIZER(
958 struct cmd_del_port_tm_node_shaper_profile_result, del, "del");
959 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port =
960 TOKEN_STRING_INITIALIZER(
961 struct cmd_del_port_tm_node_shaper_profile_result,
963 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm =
964 TOKEN_STRING_INITIALIZER(
965 struct cmd_del_port_tm_node_shaper_profile_result, tm, "tm");
966 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node =
967 TOKEN_STRING_INITIALIZER(
968 struct cmd_del_port_tm_node_shaper_profile_result,
970 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper =
971 TOKEN_STRING_INITIALIZER(
972 struct cmd_del_port_tm_node_shaper_profile_result,
974 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile =
975 TOKEN_STRING_INITIALIZER(
976 struct cmd_del_port_tm_node_shaper_profile_result,
978 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id =
979 TOKEN_NUM_INITIALIZER(
980 struct cmd_del_port_tm_node_shaper_profile_result,
981 port_id, RTE_UINT16);
982 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id =
983 TOKEN_NUM_INITIALIZER(
984 struct cmd_del_port_tm_node_shaper_profile_result,
985 shaper_id, RTE_UINT32);
987 static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result,
988 __rte_unused struct cmdline *cl,
989 __rte_unused void *data)
991 struct cmd_del_port_tm_node_shaper_profile_result *res = parsed_result;
992 struct rte_tm_error error;
993 uint32_t shaper_id = res->shaper_id;
994 portid_t port_id = res->port_id;
997 if (port_id_is_invalid(port_id, ENABLED_WARN))
1000 memset(&error, 0, sizeof(struct rte_tm_error));
1001 ret = rte_tm_shaper_profile_delete(port_id, shaper_id, &error);
1003 print_err_msg(&error);
1008 cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile = {
1009 .f = cmd_del_port_tm_node_shaper_profile_parsed,
1011 .help_str = "Delete port tm node private shaper profile",
1013 (void *)&cmd_del_port_tm_node_shaper_profile_del,
1014 (void *)&cmd_del_port_tm_node_shaper_profile_port,
1015 (void *)&cmd_del_port_tm_node_shaper_profile_tm,
1016 (void *)&cmd_del_port_tm_node_shaper_profile_node,
1017 (void *)&cmd_del_port_tm_node_shaper_profile_shaper,
1018 (void *)&cmd_del_port_tm_node_shaper_profile_profile,
1019 (void *)&cmd_del_port_tm_node_shaper_profile_port_id,
1020 (void *)&cmd_del_port_tm_node_shaper_profile_shaper_id,
1025 /* *** Add/Update Port TM shared Shaper *** */
1026 struct cmd_add_port_tm_node_shared_shaper_result {
1027 cmdline_fixed_string_t cmd_type;
1028 cmdline_fixed_string_t port;
1029 cmdline_fixed_string_t tm;
1030 cmdline_fixed_string_t node;
1031 cmdline_fixed_string_t shared;
1032 cmdline_fixed_string_t shaper;
1034 uint32_t shared_shaper_id;
1035 uint32_t shaper_profile_id;
1038 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type =
1039 TOKEN_STRING_INITIALIZER(
1040 struct cmd_add_port_tm_node_shared_shaper_result,
1041 cmd_type, "add#set");
1042 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port =
1043 TOKEN_STRING_INITIALIZER(
1044 struct cmd_add_port_tm_node_shared_shaper_result, port, "port");
1045 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm =
1046 TOKEN_STRING_INITIALIZER(
1047 struct cmd_add_port_tm_node_shared_shaper_result, tm, "tm");
1048 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node =
1049 TOKEN_STRING_INITIALIZER(
1050 struct cmd_add_port_tm_node_shared_shaper_result, node, "node");
1051 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared =
1052 TOKEN_STRING_INITIALIZER(
1053 struct cmd_add_port_tm_node_shared_shaper_result,
1055 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper =
1056 TOKEN_STRING_INITIALIZER(
1057 struct cmd_add_port_tm_node_shared_shaper_result,
1059 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id =
1060 TOKEN_NUM_INITIALIZER(
1061 struct cmd_add_port_tm_node_shared_shaper_result,
1062 port_id, RTE_UINT16);
1063 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id =
1064 TOKEN_NUM_INITIALIZER(
1065 struct cmd_add_port_tm_node_shared_shaper_result,
1066 shared_shaper_id, RTE_UINT32);
1067 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id =
1068 TOKEN_NUM_INITIALIZER(
1069 struct cmd_add_port_tm_node_shared_shaper_result,
1070 shaper_profile_id, RTE_UINT32);
1072 static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result,
1073 __rte_unused struct cmdline *cl,
1074 __rte_unused void *data)
1076 struct cmd_add_port_tm_node_shared_shaper_result *res = parsed_result;
1077 struct rte_tm_error error;
1078 uint32_t shared_shaper_id = res->shared_shaper_id;
1079 uint32_t shaper_profile_id = res->shaper_profile_id;
1080 portid_t port_id = res->port_id;
1083 if (port_id_is_invalid(port_id, ENABLED_WARN))
1086 memset(&error, 0, sizeof(struct rte_tm_error));
1087 /* Command type: add */
1088 if ((strcmp(res->cmd_type, "add") == 0) &&
1089 (port_is_started(port_id))) {
1090 fprintf(stderr, " Port %u not stopped (error)\n", port_id);
1094 /* Command type: set (update) */
1095 if ((strcmp(res->cmd_type, "set") == 0) &&
1096 (!port_is_started(port_id))) {
1097 fprintf(stderr, " Port %u not started (error)\n", port_id);
1101 ret = rte_tm_shared_shaper_add_update(port_id, shared_shaper_id,
1102 shaper_profile_id, &error);
1104 print_err_msg(&error);
1109 cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper = {
1110 .f = cmd_add_port_tm_node_shared_shaper_parsed,
1112 .help_str = "add/update port tm node shared shaper",
1114 (void *)&cmd_add_port_tm_node_shared_shaper_cmd_type,
1115 (void *)&cmd_add_port_tm_node_shared_shaper_port,
1116 (void *)&cmd_add_port_tm_node_shared_shaper_tm,
1117 (void *)&cmd_add_port_tm_node_shared_shaper_node,
1118 (void *)&cmd_add_port_tm_node_shared_shaper_shared,
1119 (void *)&cmd_add_port_tm_node_shared_shaper_shaper,
1120 (void *)&cmd_add_port_tm_node_shared_shaper_port_id,
1121 (void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id,
1122 (void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id,
1127 /* *** Delete Port TM shared Shaper *** */
1128 struct cmd_del_port_tm_node_shared_shaper_result {
1129 cmdline_fixed_string_t del;
1130 cmdline_fixed_string_t port;
1131 cmdline_fixed_string_t tm;
1132 cmdline_fixed_string_t node;
1133 cmdline_fixed_string_t shared;
1134 cmdline_fixed_string_t shaper;
1136 uint32_t shared_shaper_id;
1139 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del =
1140 TOKEN_STRING_INITIALIZER(
1141 struct cmd_del_port_tm_node_shared_shaper_result, del, "del");
1142 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port =
1143 TOKEN_STRING_INITIALIZER(
1144 struct cmd_del_port_tm_node_shared_shaper_result, port, "port");
1145 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm =
1146 TOKEN_STRING_INITIALIZER(
1147 struct cmd_del_port_tm_node_shared_shaper_result, tm, "tm");
1148 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node =
1149 TOKEN_STRING_INITIALIZER(
1150 struct cmd_del_port_tm_node_shared_shaper_result, node, "node");
1151 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared =
1152 TOKEN_STRING_INITIALIZER(
1153 struct cmd_del_port_tm_node_shared_shaper_result,
1155 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper =
1156 TOKEN_STRING_INITIALIZER(
1157 struct cmd_del_port_tm_node_shared_shaper_result,
1159 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id =
1160 TOKEN_NUM_INITIALIZER(
1161 struct cmd_del_port_tm_node_shared_shaper_result,
1162 port_id, RTE_UINT16);
1163 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id =
1164 TOKEN_NUM_INITIALIZER(
1165 struct cmd_del_port_tm_node_shared_shaper_result,
1166 shared_shaper_id, RTE_UINT32);
1168 static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result,
1169 __rte_unused struct cmdline *cl,
1170 __rte_unused void *data)
1172 struct cmd_del_port_tm_node_shared_shaper_result *res = parsed_result;
1173 struct rte_tm_error error;
1174 uint32_t shared_shaper_id = res->shared_shaper_id;
1175 portid_t port_id = res->port_id;
1178 if (port_id_is_invalid(port_id, ENABLED_WARN))
1181 memset(&error, 0, sizeof(struct rte_tm_error));
1182 ret = rte_tm_shared_shaper_delete(port_id, shared_shaper_id, &error);
1184 print_err_msg(&error);
1189 cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper = {
1190 .f = cmd_del_port_tm_node_shared_shaper_parsed,
1192 .help_str = "delete port tm node shared shaper",
1194 (void *)&cmd_del_port_tm_node_shared_shaper_del,
1195 (void *)&cmd_del_port_tm_node_shared_shaper_port,
1196 (void *)&cmd_del_port_tm_node_shared_shaper_tm,
1197 (void *)&cmd_del_port_tm_node_shared_shaper_node,
1198 (void *)&cmd_del_port_tm_node_shared_shaper_shared,
1199 (void *)&cmd_del_port_tm_node_shared_shaper_shaper,
1200 (void *)&cmd_del_port_tm_node_shared_shaper_port_id,
1201 (void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id,
1206 /* *** Add Port TM Node WRED Profile *** */
1207 struct cmd_add_port_tm_node_wred_profile_result {
1208 cmdline_fixed_string_t add;
1209 cmdline_fixed_string_t port;
1210 cmdline_fixed_string_t tm;
1211 cmdline_fixed_string_t node;
1212 cmdline_fixed_string_t wred;
1213 cmdline_fixed_string_t profile;
1215 uint32_t wred_profile_id;
1216 cmdline_fixed_string_t color_g;
1219 uint16_t maxp_inv_g;
1221 cmdline_fixed_string_t color_y;
1224 uint16_t maxp_inv_y;
1226 cmdline_fixed_string_t color_r;
1229 uint16_t maxp_inv_r;
1233 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add =
1234 TOKEN_STRING_INITIALIZER(
1235 struct cmd_add_port_tm_node_wred_profile_result, add, "add");
1236 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port =
1237 TOKEN_STRING_INITIALIZER(
1238 struct cmd_add_port_tm_node_wred_profile_result, port, "port");
1239 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm =
1240 TOKEN_STRING_INITIALIZER(
1241 struct cmd_add_port_tm_node_wred_profile_result, tm, "tm");
1242 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node =
1243 TOKEN_STRING_INITIALIZER(
1244 struct cmd_add_port_tm_node_wred_profile_result, node, "node");
1245 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred =
1246 TOKEN_STRING_INITIALIZER(
1247 struct cmd_add_port_tm_node_wred_profile_result, wred, "wred");
1248 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile =
1249 TOKEN_STRING_INITIALIZER(
1250 struct cmd_add_port_tm_node_wred_profile_result,
1251 profile, "profile");
1252 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id =
1253 TOKEN_NUM_INITIALIZER(
1254 struct cmd_add_port_tm_node_wred_profile_result,
1255 port_id, RTE_UINT16);
1256 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id =
1257 TOKEN_NUM_INITIALIZER(
1258 struct cmd_add_port_tm_node_wred_profile_result,
1259 wred_profile_id, RTE_UINT32);
1260 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g =
1261 TOKEN_STRING_INITIALIZER(
1262 struct cmd_add_port_tm_node_wred_profile_result,
1264 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g =
1265 TOKEN_NUM_INITIALIZER(
1266 struct cmd_add_port_tm_node_wred_profile_result,
1267 min_th_g, RTE_UINT64);
1268 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g =
1269 TOKEN_NUM_INITIALIZER(
1270 struct cmd_add_port_tm_node_wred_profile_result,
1271 max_th_g, RTE_UINT64);
1272 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g =
1273 TOKEN_NUM_INITIALIZER(
1274 struct cmd_add_port_tm_node_wred_profile_result,
1275 maxp_inv_g, RTE_UINT16);
1276 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g =
1277 TOKEN_NUM_INITIALIZER(
1278 struct cmd_add_port_tm_node_wred_profile_result,
1279 wq_log2_g, RTE_UINT16);
1280 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y =
1281 TOKEN_STRING_INITIALIZER(
1282 struct cmd_add_port_tm_node_wred_profile_result,
1284 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y =
1285 TOKEN_NUM_INITIALIZER(
1286 struct cmd_add_port_tm_node_wred_profile_result,
1287 min_th_y, RTE_UINT64);
1288 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y =
1289 TOKEN_NUM_INITIALIZER(
1290 struct cmd_add_port_tm_node_wred_profile_result,
1291 max_th_y, RTE_UINT64);
1292 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y =
1293 TOKEN_NUM_INITIALIZER(
1294 struct cmd_add_port_tm_node_wred_profile_result,
1295 maxp_inv_y, RTE_UINT16);
1296 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y =
1297 TOKEN_NUM_INITIALIZER(
1298 struct cmd_add_port_tm_node_wred_profile_result,
1299 wq_log2_y, RTE_UINT16);
1300 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r =
1301 TOKEN_STRING_INITIALIZER(
1302 struct cmd_add_port_tm_node_wred_profile_result,
1304 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r =
1305 TOKEN_NUM_INITIALIZER(
1306 struct cmd_add_port_tm_node_wred_profile_result,
1307 min_th_r, RTE_UINT64);
1308 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r =
1309 TOKEN_NUM_INITIALIZER(
1310 struct cmd_add_port_tm_node_wred_profile_result,
1311 max_th_r, RTE_UINT64);
1312 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r =
1313 TOKEN_NUM_INITIALIZER(
1314 struct cmd_add_port_tm_node_wred_profile_result,
1315 maxp_inv_r, RTE_UINT16);
1316 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r =
1317 TOKEN_NUM_INITIALIZER(
1318 struct cmd_add_port_tm_node_wred_profile_result,
1319 wq_log2_r, RTE_UINT16);
1322 static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
1323 __rte_unused struct cmdline *cl,
1324 __rte_unused void *data)
1326 struct cmd_add_port_tm_node_wred_profile_result *res = parsed_result;
1327 struct rte_tm_wred_params wp;
1328 enum rte_color color;
1329 struct rte_tm_error error;
1330 uint32_t wred_profile_id = res->wred_profile_id;
1331 portid_t port_id = res->port_id;
1334 if (port_id_is_invalid(port_id, ENABLED_WARN))
1337 memset(&wp, 0, sizeof(struct rte_tm_wred_params));
1338 memset(&error, 0, sizeof(struct rte_tm_error));
1340 /* WRED Params (Green Color)*/
1341 color = RTE_COLOR_GREEN;
1342 wp.red_params[color].min_th = res->min_th_g;
1343 wp.red_params[color].max_th = res->max_th_g;
1344 wp.red_params[color].maxp_inv = res->maxp_inv_g;
1345 wp.red_params[color].wq_log2 = res->wq_log2_g;
1348 /* WRED Params (Yellow Color)*/
1349 color = RTE_COLOR_YELLOW;
1350 wp.red_params[color].min_th = res->min_th_y;
1351 wp.red_params[color].max_th = res->max_th_y;
1352 wp.red_params[color].maxp_inv = res->maxp_inv_y;
1353 wp.red_params[color].wq_log2 = res->wq_log2_y;
1355 /* WRED Params (Red Color)*/
1356 color = RTE_COLOR_RED;
1357 wp.red_params[color].min_th = res->min_th_r;
1358 wp.red_params[color].max_th = res->max_th_r;
1359 wp.red_params[color].maxp_inv = res->maxp_inv_r;
1360 wp.red_params[color].wq_log2 = res->wq_log2_r;
1362 ret = rte_tm_wred_profile_add(port_id, wred_profile_id, &wp, &error);
1364 print_err_msg(&error);
1369 cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile = {
1370 .f = cmd_add_port_tm_node_wred_profile_parsed,
1372 .help_str = "Add port tm node wred profile",
1374 (void *)&cmd_add_port_tm_node_wred_profile_add,
1375 (void *)&cmd_add_port_tm_node_wred_profile_port,
1376 (void *)&cmd_add_port_tm_node_wred_profile_tm,
1377 (void *)&cmd_add_port_tm_node_wred_profile_node,
1378 (void *)&cmd_add_port_tm_node_wred_profile_wred,
1379 (void *)&cmd_add_port_tm_node_wred_profile_profile,
1380 (void *)&cmd_add_port_tm_node_wred_profile_port_id,
1381 (void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id,
1382 (void *)&cmd_add_port_tm_node_wred_profile_color_g,
1383 (void *)&cmd_add_port_tm_node_wred_profile_min_th_g,
1384 (void *)&cmd_add_port_tm_node_wred_profile_max_th_g,
1385 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g,
1386 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g,
1387 (void *)&cmd_add_port_tm_node_wred_profile_color_y,
1388 (void *)&cmd_add_port_tm_node_wred_profile_min_th_y,
1389 (void *)&cmd_add_port_tm_node_wred_profile_max_th_y,
1390 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y,
1391 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y,
1392 (void *)&cmd_add_port_tm_node_wred_profile_color_r,
1393 (void *)&cmd_add_port_tm_node_wred_profile_min_th_r,
1394 (void *)&cmd_add_port_tm_node_wred_profile_max_th_r,
1395 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r,
1396 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r,
1401 /* *** Delete Port TM node WRED Profile *** */
1402 struct cmd_del_port_tm_node_wred_profile_result {
1403 cmdline_fixed_string_t del;
1404 cmdline_fixed_string_t port;
1405 cmdline_fixed_string_t tm;
1406 cmdline_fixed_string_t node;
1407 cmdline_fixed_string_t wred;
1408 cmdline_fixed_string_t profile;
1410 uint32_t wred_profile_id;
1413 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del =
1414 TOKEN_STRING_INITIALIZER(
1415 struct cmd_del_port_tm_node_wred_profile_result, del, "del");
1416 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port =
1417 TOKEN_STRING_INITIALIZER(
1418 struct cmd_del_port_tm_node_wred_profile_result, port, "port");
1419 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm =
1420 TOKEN_STRING_INITIALIZER(
1421 struct cmd_del_port_tm_node_wred_profile_result, tm, "tm");
1422 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node =
1423 TOKEN_STRING_INITIALIZER(
1424 struct cmd_del_port_tm_node_wred_profile_result, node, "node");
1425 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred =
1426 TOKEN_STRING_INITIALIZER(
1427 struct cmd_del_port_tm_node_wred_profile_result, wred, "wred");
1428 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile =
1429 TOKEN_STRING_INITIALIZER(
1430 struct cmd_del_port_tm_node_wred_profile_result,
1431 profile, "profile");
1432 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id =
1433 TOKEN_NUM_INITIALIZER(
1434 struct cmd_del_port_tm_node_wred_profile_result,
1435 port_id, RTE_UINT16);
1436 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id =
1437 TOKEN_NUM_INITIALIZER(
1438 struct cmd_del_port_tm_node_wred_profile_result,
1439 wred_profile_id, RTE_UINT32);
1441 static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result,
1442 __rte_unused struct cmdline *cl,
1443 __rte_unused void *data)
1445 struct cmd_del_port_tm_node_wred_profile_result *res = parsed_result;
1446 struct rte_tm_error error;
1447 uint32_t wred_profile_id = res->wred_profile_id;
1448 portid_t port_id = res->port_id;
1451 if (port_id_is_invalid(port_id, ENABLED_WARN))
1454 memset(&error, 0, sizeof(struct rte_tm_error));
1455 ret = rte_tm_wred_profile_delete(port_id, wred_profile_id, &error);
1457 print_err_msg(&error);
1462 cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile = {
1463 .f = cmd_del_port_tm_node_wred_profile_parsed,
1465 .help_str = "Delete port tm node wred profile",
1467 (void *)&cmd_del_port_tm_node_wred_profile_del,
1468 (void *)&cmd_del_port_tm_node_wred_profile_port,
1469 (void *)&cmd_del_port_tm_node_wred_profile_tm,
1470 (void *)&cmd_del_port_tm_node_wred_profile_node,
1471 (void *)&cmd_del_port_tm_node_wred_profile_wred,
1472 (void *)&cmd_del_port_tm_node_wred_profile_profile,
1473 (void *)&cmd_del_port_tm_node_wred_profile_port_id,
1474 (void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id,
1479 /* *** Update Port TM Node Shaper profile *** */
1480 struct cmd_set_port_tm_node_shaper_profile_result {
1481 cmdline_fixed_string_t set;
1482 cmdline_fixed_string_t port;
1483 cmdline_fixed_string_t tm;
1484 cmdline_fixed_string_t node;
1485 cmdline_fixed_string_t shaper;
1486 cmdline_fixed_string_t profile;
1489 uint32_t shaper_profile_id;
1492 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set =
1493 TOKEN_STRING_INITIALIZER(
1494 struct cmd_set_port_tm_node_shaper_profile_result, set, "set");
1495 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port =
1496 TOKEN_STRING_INITIALIZER(
1497 struct cmd_set_port_tm_node_shaper_profile_result,
1499 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_tm =
1500 TOKEN_STRING_INITIALIZER(
1501 struct cmd_set_port_tm_node_shaper_profile_result, tm, "tm");
1502 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node =
1503 TOKEN_STRING_INITIALIZER(
1504 struct cmd_set_port_tm_node_shaper_profile_result,
1506 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper =
1507 TOKEN_STRING_INITIALIZER(
1508 struct cmd_set_port_tm_node_shaper_profile_result,
1510 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile =
1511 TOKEN_STRING_INITIALIZER(
1512 struct cmd_set_port_tm_node_shaper_profile_result,
1513 profile, "profile");
1514 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id =
1515 TOKEN_NUM_INITIALIZER(
1516 struct cmd_set_port_tm_node_shaper_profile_result,
1517 port_id, RTE_UINT16);
1518 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id =
1519 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result,
1520 node_id, RTE_UINT32);
1521 cmdline_parse_token_num_t
1522 cmd_set_port_tm_node_shaper_shaper_profile_profile_id =
1523 TOKEN_NUM_INITIALIZER(
1524 struct cmd_set_port_tm_node_shaper_profile_result,
1525 shaper_profile_id, RTE_UINT32);
1527 static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result,
1528 __rte_unused struct cmdline *cl,
1529 __rte_unused void *data)
1531 struct cmd_set_port_tm_node_shaper_profile_result *res = parsed_result;
1532 struct rte_tm_error error;
1533 uint32_t node_id = res->node_id;
1534 uint32_t shaper_profile_id = res->shaper_profile_id;
1535 portid_t port_id = res->port_id;
1538 if (port_id_is_invalid(port_id, ENABLED_WARN))
1541 memset(&error, 0, sizeof(struct rte_tm_error));
1543 if (!port_is_started(port_id)) {
1544 fprintf(stderr, " Port %u not started (error)\n", port_id);
1548 ret = rte_tm_node_shaper_update(port_id, node_id,
1549 shaper_profile_id, &error);
1551 print_err_msg(&error);
1556 cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile = {
1557 .f = cmd_set_port_tm_node_shaper_profile_parsed,
1559 .help_str = "Set port tm node shaper profile",
1561 (void *)&cmd_set_port_tm_node_shaper_profile_set,
1562 (void *)&cmd_set_port_tm_node_shaper_profile_port,
1563 (void *)&cmd_set_port_tm_node_shaper_profile_tm,
1564 (void *)&cmd_set_port_tm_node_shaper_profile_node,
1565 (void *)&cmd_set_port_tm_node_shaper_profile_shaper,
1566 (void *)&cmd_set_port_tm_node_shaper_profile_profile,
1567 (void *)&cmd_set_port_tm_node_shaper_profile_port_id,
1568 (void *)&cmd_set_port_tm_node_shaper_profile_node_id,
1569 (void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id,
1574 /* *** Add Port TM nonleaf node *** */
1575 struct cmd_add_port_tm_nonleaf_node_result {
1576 cmdline_fixed_string_t add;
1577 cmdline_fixed_string_t port;
1578 cmdline_fixed_string_t tm;
1579 cmdline_fixed_string_t nonleaf;
1580 cmdline_fixed_string_t node;
1583 int32_t parent_node_id;
1587 int32_t shaper_profile_id;
1588 uint32_t n_sp_priorities;
1589 uint64_t stats_mask;
1590 cmdline_multi_string_t multi_shared_shaper_id;
1593 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add =
1594 TOKEN_STRING_INITIALIZER(
1595 struct cmd_add_port_tm_nonleaf_node_result, add, "add");
1596 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port =
1597 TOKEN_STRING_INITIALIZER(
1598 struct cmd_add_port_tm_nonleaf_node_result, port, "port");
1599 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm =
1600 TOKEN_STRING_INITIALIZER(
1601 struct cmd_add_port_tm_nonleaf_node_result, tm, "tm");
1602 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf =
1603 TOKEN_STRING_INITIALIZER(
1604 struct cmd_add_port_tm_nonleaf_node_result, nonleaf, "nonleaf");
1605 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node =
1606 TOKEN_STRING_INITIALIZER(
1607 struct cmd_add_port_tm_nonleaf_node_result, node, "node");
1608 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id =
1609 TOKEN_NUM_INITIALIZER(
1610 struct cmd_add_port_tm_nonleaf_node_result,
1611 port_id, RTE_UINT16);
1612 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_id =
1613 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1614 node_id, RTE_UINT32);
1615 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_parent_node_id =
1616 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1617 parent_node_id, RTE_INT32);
1618 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority =
1619 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1620 priority, RTE_UINT32);
1621 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight =
1622 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1623 weight, RTE_UINT32);
1624 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =
1625 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1626 level_id, RTE_UINT32);
1627 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id =
1628 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1629 shaper_profile_id, RTE_INT32);
1630 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =
1631 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1632 n_sp_priorities, RTE_UINT32);
1633 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask =
1634 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1635 stats_mask, RTE_UINT64);
1636 cmdline_parse_token_string_t
1637 cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id =
1638 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1639 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1641 static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
1642 __rte_unused struct cmdline *cl,
1643 __rte_unused void *data)
1645 struct cmd_add_port_tm_nonleaf_node_result *res = parsed_result;
1646 struct rte_tm_error error;
1647 struct rte_tm_node_params np;
1648 uint32_t *shared_shaper_id;
1649 uint32_t parent_node_id, n_shared_shapers = 0;
1650 char *s_str = res->multi_shared_shaper_id;
1651 portid_t port_id = res->port_id;
1654 if (port_id_is_invalid(port_id, ENABLED_WARN))
1657 memset(&np, 0, sizeof(struct rte_tm_node_params));
1658 memset(&error, 0, sizeof(struct rte_tm_error));
1660 /* Node parameters */
1661 if (res->parent_node_id < 0)
1662 parent_node_id = UINT32_MAX;
1664 parent_node_id = res->parent_node_id;
1666 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1668 if (shared_shaper_id == NULL) {
1670 " Memory not allocated for shared shapers (error)\n");
1674 /* Parse multi shared shaper id string */
1675 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1677 fprintf(stderr, " Shared shapers params string parse error\n");
1678 free(shared_shaper_id);
1682 if (res->shaper_profile_id < 0)
1683 np.shaper_profile_id = UINT32_MAX;
1685 np.shaper_profile_id = res->shaper_profile_id;
1687 np.n_shared_shapers = n_shared_shapers;
1688 if (np.n_shared_shapers) {
1689 np.shared_shaper_id = &shared_shaper_id[0];
1691 free(shared_shaper_id);
1692 shared_shaper_id = NULL;
1695 np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1696 np.stats_mask = res->stats_mask;
1697 np.nonleaf.wfq_weight_mode = NULL;
1699 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1700 res->priority, res->weight, res->level_id,
1703 print_err_msg(&error);
1704 free(shared_shaper_id);
1709 cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node = {
1710 .f = cmd_add_port_tm_nonleaf_node_parsed,
1712 .help_str = "Add port tm nonleaf node",
1714 (void *)&cmd_add_port_tm_nonleaf_node_add,
1715 (void *)&cmd_add_port_tm_nonleaf_node_port,
1716 (void *)&cmd_add_port_tm_nonleaf_node_tm,
1717 (void *)&cmd_add_port_tm_nonleaf_node_nonleaf,
1718 (void *)&cmd_add_port_tm_nonleaf_node_node,
1719 (void *)&cmd_add_port_tm_nonleaf_node_port_id,
1720 (void *)&cmd_add_port_tm_nonleaf_node_node_id,
1721 (void *)&cmd_add_port_tm_nonleaf_node_parent_node_id,
1722 (void *)&cmd_add_port_tm_nonleaf_node_priority,
1723 (void *)&cmd_add_port_tm_nonleaf_node_weight,
1724 (void *)&cmd_add_port_tm_nonleaf_node_level_id,
1725 (void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id,
1726 (void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities,
1727 (void *)&cmd_add_port_tm_nonleaf_node_stats_mask,
1728 (void *)&cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id,
1733 /* *** Add Port TM nonleaf node pkt mode *** */
1734 struct cmd_add_port_tm_nonleaf_node_pmode_result {
1735 cmdline_fixed_string_t add;
1736 cmdline_fixed_string_t port;
1737 cmdline_fixed_string_t tm;
1738 cmdline_fixed_string_t nonleaf;
1739 cmdline_fixed_string_t node;
1742 int32_t parent_node_id;
1746 int32_t shaper_profile_id;
1747 uint32_t n_sp_priorities;
1748 uint64_t stats_mask;
1749 cmdline_multi_string_t multi_shared_shaper_id;
1752 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_add =
1753 TOKEN_STRING_INITIALIZER(
1754 struct cmd_add_port_tm_nonleaf_node_pmode_result, add, "add");
1755 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_port =
1756 TOKEN_STRING_INITIALIZER(
1757 struct cmd_add_port_tm_nonleaf_node_pmode_result, port, "port");
1758 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_tm =
1759 TOKEN_STRING_INITIALIZER(
1760 struct cmd_add_port_tm_nonleaf_node_pmode_result, tm, "tm");
1761 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_nonleaf =
1762 TOKEN_STRING_INITIALIZER(
1763 struct cmd_add_port_tm_nonleaf_node_pmode_result, nonleaf, "nonleaf");
1764 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_node =
1765 TOKEN_STRING_INITIALIZER(
1766 struct cmd_add_port_tm_nonleaf_node_pmode_result, node, "node");
1767 cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_pktmode =
1768 TOKEN_STRING_INITIALIZER(
1769 struct cmd_add_port_tm_nonleaf_node_pmode_result, node, "pktmode");
1770 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_port_id =
1771 TOKEN_NUM_INITIALIZER(
1772 struct cmd_add_port_tm_nonleaf_node_pmode_result,
1773 port_id, RTE_UINT16);
1774 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_node_id =
1775 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1776 node_id, RTE_UINT32);
1777 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_parent_node_id =
1778 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1779 parent_node_id, RTE_INT32);
1780 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_priority =
1781 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1782 priority, RTE_UINT32);
1783 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_weight =
1784 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1785 weight, RTE_UINT32);
1786 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_level_id =
1787 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1788 level_id, RTE_UINT32);
1789 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_shaper_profile_id =
1790 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1791 shaper_profile_id, RTE_INT32);
1792 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_n_sp_priorities =
1793 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1794 n_sp_priorities, RTE_UINT32);
1795 cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_stats_mask =
1796 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1797 stats_mask, RTE_UINT64);
1798 cmdline_parse_token_string_t
1799 cmd_add_port_tm_nonleaf_node_pmode_multi_shrd_shpr_id =
1800 TOKEN_STRING_INITIALIZER(
1801 struct cmd_add_port_tm_nonleaf_node_pmode_result,
1802 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1804 static void cmd_add_port_tm_nonleaf_node_pmode_parsed(void *parsed_result,
1805 __rte_unused struct cmdline *cl,
1806 __rte_unused void *data)
1808 struct cmd_add_port_tm_nonleaf_node_pmode_result *res = parsed_result;
1809 uint32_t parent_node_id, n_shared_shapers = 0;
1810 char *s_str = res->multi_shared_shaper_id;
1811 portid_t port_id = res->port_id;
1812 struct rte_tm_node_params np;
1813 int *wfq_weight_mode = NULL;
1814 uint32_t *shared_shaper_id;
1815 struct rte_tm_error error;
1818 if (port_id_is_invalid(port_id, ENABLED_WARN))
1821 memset(&np, 0, sizeof(struct rte_tm_node_params));
1822 memset(&error, 0, sizeof(struct rte_tm_error));
1824 /* Node parameters */
1825 if (res->parent_node_id < 0)
1826 parent_node_id = UINT32_MAX;
1828 parent_node_id = res->parent_node_id;
1830 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1832 if (shared_shaper_id == NULL) {
1834 " Memory not allocated for shared shapers (error)\n");
1838 /* Parse multi shared shaper id string */
1839 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1841 fprintf(stderr, " Shared shapers params string parse error\n");
1842 free(shared_shaper_id);
1846 if (res->shaper_profile_id < 0)
1847 np.shaper_profile_id = UINT32_MAX;
1849 np.shaper_profile_id = res->shaper_profile_id;
1851 np.n_shared_shapers = n_shared_shapers;
1852 if (np.n_shared_shapers) {
1853 np.shared_shaper_id = &shared_shaper_id[0];
1855 free(shared_shaper_id);
1856 shared_shaper_id = NULL;
1859 if (res->n_sp_priorities)
1860 wfq_weight_mode = calloc(res->n_sp_priorities, sizeof(int));
1861 np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1862 np.stats_mask = res->stats_mask;
1863 np.nonleaf.wfq_weight_mode = wfq_weight_mode;
1865 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1866 res->priority, res->weight, res->level_id,
1869 print_err_msg(&error);
1870 free(shared_shaper_id);
1871 free(wfq_weight_mode);
1876 cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node_pmode = {
1877 .f = cmd_add_port_tm_nonleaf_node_pmode_parsed,
1879 .help_str = "Add port tm nonleaf node pktmode",
1881 (void *)&cmd_add_port_tm_nonleaf_node_pmode_add,
1882 (void *)&cmd_add_port_tm_nonleaf_node_pmode_port,
1883 (void *)&cmd_add_port_tm_nonleaf_node_pmode_tm,
1884 (void *)&cmd_add_port_tm_nonleaf_node_pmode_nonleaf,
1885 (void *)&cmd_add_port_tm_nonleaf_node_pmode_node,
1886 (void *)&cmd_add_port_tm_nonleaf_node_pmode_pktmode,
1887 (void *)&cmd_add_port_tm_nonleaf_node_pmode_port_id,
1888 (void *)&cmd_add_port_tm_nonleaf_node_pmode_node_id,
1889 (void *)&cmd_add_port_tm_nonleaf_node_pmode_parent_node_id,
1890 (void *)&cmd_add_port_tm_nonleaf_node_pmode_priority,
1891 (void *)&cmd_add_port_tm_nonleaf_node_pmode_weight,
1892 (void *)&cmd_add_port_tm_nonleaf_node_pmode_level_id,
1893 (void *)&cmd_add_port_tm_nonleaf_node_pmode_shaper_profile_id,
1894 (void *)&cmd_add_port_tm_nonleaf_node_pmode_n_sp_priorities,
1895 (void *)&cmd_add_port_tm_nonleaf_node_pmode_stats_mask,
1896 (void *)&cmd_add_port_tm_nonleaf_node_pmode_multi_shrd_shpr_id,
1900 /* *** Add Port TM leaf node *** */
1901 struct cmd_add_port_tm_leaf_node_result {
1902 cmdline_fixed_string_t add;
1903 cmdline_fixed_string_t port;
1904 cmdline_fixed_string_t tm;
1905 cmdline_fixed_string_t leaf;
1906 cmdline_fixed_string_t node;
1909 int32_t parent_node_id;
1913 int32_t shaper_profile_id;
1915 uint32_t wred_profile_id;
1916 uint64_t stats_mask;
1917 cmdline_multi_string_t multi_shared_shaper_id;
1920 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add =
1921 TOKEN_STRING_INITIALIZER(
1922 struct cmd_add_port_tm_leaf_node_result, add, "add");
1923 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port =
1924 TOKEN_STRING_INITIALIZER(
1925 struct cmd_add_port_tm_leaf_node_result, port, "port");
1926 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm =
1927 TOKEN_STRING_INITIALIZER(
1928 struct cmd_add_port_tm_leaf_node_result, tm, "tm");
1929 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf =
1930 TOKEN_STRING_INITIALIZER(
1931 struct cmd_add_port_tm_leaf_node_result, leaf, "leaf");
1932 cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node =
1933 TOKEN_STRING_INITIALIZER(
1934 struct cmd_add_port_tm_leaf_node_result, node, "node");
1935 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_id =
1936 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1937 port_id, RTE_UINT16);
1938 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_node_id =
1939 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1940 node_id, RTE_UINT32);
1941 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id =
1942 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1943 parent_node_id, RTE_INT32);
1944 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority =
1945 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1946 priority, RTE_UINT32);
1947 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight =
1948 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1949 weight, RTE_UINT32);
1950 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =
1951 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1952 level_id, RTE_UINT32);
1953 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =
1954 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1955 shaper_profile_id, RTE_INT32);
1956 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =
1957 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1958 cman_mode, RTE_UINT32);
1959 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id =
1960 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1961 wred_profile_id, RTE_UINT32);
1962 cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask =
1963 TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1964 stats_mask, RTE_UINT64);
1965 cmdline_parse_token_string_t
1966 cmd_add_port_tm_leaf_node_multi_shared_shaper_id =
1967 TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1968 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1970 static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
1971 __rte_unused struct cmdline *cl,
1972 __rte_unused void *data)
1974 struct cmd_add_port_tm_leaf_node_result *res = parsed_result;
1975 struct rte_tm_error error;
1976 struct rte_tm_node_params np;
1977 uint32_t *shared_shaper_id;
1978 uint32_t parent_node_id, n_shared_shapers = 0;
1979 portid_t port_id = res->port_id;
1980 char *s_str = res->multi_shared_shaper_id;
1983 if (port_id_is_invalid(port_id, ENABLED_WARN))
1986 memset(&np, 0, sizeof(struct rte_tm_node_params));
1987 memset(&error, 0, sizeof(struct rte_tm_error));
1989 /* Node parameters */
1990 if (res->parent_node_id < 0)
1991 parent_node_id = UINT32_MAX;
1993 parent_node_id = res->parent_node_id;
1995 shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1997 if (shared_shaper_id == NULL) {
1999 " Memory not allocated for shared shapers (error)\n");
2003 /* Parse multi shared shaper id string */
2004 ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
2006 fprintf(stderr, " Shared shapers params string parse error\n");
2007 free(shared_shaper_id);
2011 if (res->shaper_profile_id < 0)
2012 np.shaper_profile_id = UINT32_MAX;
2014 np.shaper_profile_id = res->shaper_profile_id;
2016 np.n_shared_shapers = n_shared_shapers;
2018 if (np.n_shared_shapers) {
2019 np.shared_shaper_id = &shared_shaper_id[0];
2021 free(shared_shaper_id);
2022 shared_shaper_id = NULL;
2025 np.leaf.cman = res->cman_mode;
2026 np.leaf.wred.wred_profile_id = res->wred_profile_id;
2027 np.stats_mask = res->stats_mask;
2029 ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
2030 res->priority, res->weight, res->level_id,
2033 print_err_msg(&error);
2034 free(shared_shaper_id);
2039 cmdline_parse_inst_t cmd_add_port_tm_leaf_node = {
2040 .f = cmd_add_port_tm_leaf_node_parsed,
2042 .help_str = "Add port tm leaf node",
2044 (void *)&cmd_add_port_tm_leaf_node_add,
2045 (void *)&cmd_add_port_tm_leaf_node_port,
2046 (void *)&cmd_add_port_tm_leaf_node_tm,
2047 (void *)&cmd_add_port_tm_leaf_node_nonleaf,
2048 (void *)&cmd_add_port_tm_leaf_node_node,
2049 (void *)&cmd_add_port_tm_leaf_node_port_id,
2050 (void *)&cmd_add_port_tm_leaf_node_node_id,
2051 (void *)&cmd_add_port_tm_leaf_node_parent_node_id,
2052 (void *)&cmd_add_port_tm_leaf_node_priority,
2053 (void *)&cmd_add_port_tm_leaf_node_weight,
2054 (void *)&cmd_add_port_tm_leaf_node_level_id,
2055 (void *)&cmd_add_port_tm_leaf_node_shaper_profile_id,
2056 (void *)&cmd_add_port_tm_leaf_node_cman_mode,
2057 (void *)&cmd_add_port_tm_leaf_node_wred_profile_id,
2058 (void *)&cmd_add_port_tm_leaf_node_stats_mask,
2059 (void *)&cmd_add_port_tm_leaf_node_multi_shared_shaper_id,
2064 /* *** Delete Port TM Node *** */
2065 struct cmd_del_port_tm_node_result {
2066 cmdline_fixed_string_t del;
2067 cmdline_fixed_string_t port;
2068 cmdline_fixed_string_t tm;
2069 cmdline_fixed_string_t node;
2074 cmdline_parse_token_string_t cmd_del_port_tm_node_del =
2075 TOKEN_STRING_INITIALIZER(
2076 struct cmd_del_port_tm_node_result, del, "del");
2077 cmdline_parse_token_string_t cmd_del_port_tm_node_port =
2078 TOKEN_STRING_INITIALIZER(
2079 struct cmd_del_port_tm_node_result, port, "port");
2080 cmdline_parse_token_string_t cmd_del_port_tm_node_tm =
2081 TOKEN_STRING_INITIALIZER(
2082 struct cmd_del_port_tm_node_result, tm, "tm");
2083 cmdline_parse_token_string_t cmd_del_port_tm_node_node =
2084 TOKEN_STRING_INITIALIZER(
2085 struct cmd_del_port_tm_node_result, node, "node");
2086 cmdline_parse_token_num_t cmd_del_port_tm_node_port_id =
2087 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
2088 port_id, RTE_UINT16);
2089 cmdline_parse_token_num_t cmd_del_port_tm_node_node_id =
2090 TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
2091 node_id, RTE_UINT32);
2093 static void cmd_del_port_tm_node_parsed(void *parsed_result,
2094 __rte_unused struct cmdline *cl,
2095 __rte_unused void *data)
2097 struct cmd_del_port_tm_node_result *res = parsed_result;
2098 struct rte_tm_error error;
2099 uint32_t node_id = res->node_id;
2100 portid_t port_id = res->port_id;
2103 if (port_id_is_invalid(port_id, ENABLED_WARN))
2106 memset(&error, 0, sizeof(struct rte_tm_error));
2108 if (port_is_started(port_id)) {
2109 fprintf(stderr, " Port %u not stopped (error)\n", port_id);
2113 ret = rte_tm_node_delete(port_id, node_id, &error);
2115 print_err_msg(&error);
2120 cmdline_parse_inst_t cmd_del_port_tm_node = {
2121 .f = cmd_del_port_tm_node_parsed,
2123 .help_str = "Delete port tm node",
2125 (void *)&cmd_del_port_tm_node_del,
2126 (void *)&cmd_del_port_tm_node_port,
2127 (void *)&cmd_del_port_tm_node_tm,
2128 (void *)&cmd_del_port_tm_node_node,
2129 (void *)&cmd_del_port_tm_node_port_id,
2130 (void *)&cmd_del_port_tm_node_node_id,
2135 /* *** Update Port TM Node Parent *** */
2136 struct cmd_set_port_tm_node_parent_result {
2137 cmdline_fixed_string_t set;
2138 cmdline_fixed_string_t port;
2139 cmdline_fixed_string_t tm;
2140 cmdline_fixed_string_t node;
2141 cmdline_fixed_string_t parent;
2149 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set =
2150 TOKEN_STRING_INITIALIZER(
2151 struct cmd_set_port_tm_node_parent_result, set, "set");
2152 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port =
2153 TOKEN_STRING_INITIALIZER(
2154 struct cmd_set_port_tm_node_parent_result, port, "port");
2155 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm =
2156 TOKEN_STRING_INITIALIZER(
2157 struct cmd_set_port_tm_node_parent_result, tm, "tm");
2158 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node =
2159 TOKEN_STRING_INITIALIZER(
2160 struct cmd_set_port_tm_node_parent_result, node, "node");
2161 cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent =
2162 TOKEN_STRING_INITIALIZER(
2163 struct cmd_set_port_tm_node_parent_result, parent, "parent");
2164 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id =
2165 TOKEN_NUM_INITIALIZER(
2166 struct cmd_set_port_tm_node_parent_result, port_id,
2168 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id =
2169 TOKEN_NUM_INITIALIZER(
2170 struct cmd_set_port_tm_node_parent_result, node_id,
2172 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id =
2173 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2174 parent_id, RTE_UINT32);
2175 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority =
2176 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2177 priority, RTE_UINT32);
2178 cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight =
2179 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2180 weight, RTE_UINT32);
2182 static void cmd_set_port_tm_node_parent_parsed(void *parsed_result,
2183 __rte_unused struct cmdline *cl,
2184 __rte_unused void *data)
2186 struct cmd_set_port_tm_node_parent_result *res = parsed_result;
2187 struct rte_tm_error error;
2188 uint32_t node_id = res->node_id;
2189 uint32_t parent_id = res->parent_id;
2190 uint32_t priority = res->priority;
2191 uint32_t weight = res->weight;
2192 portid_t port_id = res->port_id;
2195 if (port_id_is_invalid(port_id, ENABLED_WARN))
2198 memset(&error, 0, sizeof(struct rte_tm_error));
2200 if (!port_is_started(port_id)) {
2201 fprintf(stderr, " Port %u not started (error)\n", port_id);
2205 ret = rte_tm_node_parent_update(port_id, node_id,
2206 parent_id, priority, weight, &error);
2208 print_err_msg(&error);
2213 cmdline_parse_inst_t cmd_set_port_tm_node_parent = {
2214 .f = cmd_set_port_tm_node_parent_parsed,
2216 .help_str = "Set port tm node parent",
2218 (void *)&cmd_set_port_tm_node_parent_set,
2219 (void *)&cmd_set_port_tm_node_parent_port,
2220 (void *)&cmd_set_port_tm_node_parent_tm,
2221 (void *)&cmd_set_port_tm_node_parent_node,
2222 (void *)&cmd_set_port_tm_node_parent_parent,
2223 (void *)&cmd_set_port_tm_node_parent_port_id,
2224 (void *)&cmd_set_port_tm_node_parent_node_id,
2225 (void *)&cmd_set_port_tm_node_parent_parent_id,
2226 (void *)&cmd_set_port_tm_node_parent_priority,
2227 (void *)&cmd_set_port_tm_node_parent_weight,
2232 /* *** Suspend Port TM Node *** */
2233 struct cmd_suspend_port_tm_node_result {
2234 cmdline_fixed_string_t suspend;
2235 cmdline_fixed_string_t port;
2236 cmdline_fixed_string_t tm;
2237 cmdline_fixed_string_t node;
2242 cmdline_parse_token_string_t cmd_suspend_port_tm_node_suspend =
2243 TOKEN_STRING_INITIALIZER(
2244 struct cmd_suspend_port_tm_node_result, suspend, "suspend");
2245 cmdline_parse_token_string_t cmd_suspend_port_tm_node_port =
2246 TOKEN_STRING_INITIALIZER(
2247 struct cmd_suspend_port_tm_node_result, port, "port");
2248 cmdline_parse_token_string_t cmd_suspend_port_tm_node_tm =
2249 TOKEN_STRING_INITIALIZER(
2250 struct cmd_suspend_port_tm_node_result, tm, "tm");
2251 cmdline_parse_token_string_t cmd_suspend_port_tm_node_node =
2252 TOKEN_STRING_INITIALIZER(
2253 struct cmd_suspend_port_tm_node_result, node, "node");
2254 cmdline_parse_token_num_t cmd_suspend_port_tm_node_port_id =
2255 TOKEN_NUM_INITIALIZER(
2256 struct cmd_suspend_port_tm_node_result, port_id,
2258 cmdline_parse_token_num_t cmd_suspend_port_tm_node_node_id =
2259 TOKEN_NUM_INITIALIZER(
2260 struct cmd_suspend_port_tm_node_result, node_id,
2263 static void cmd_suspend_port_tm_node_parsed(void *parsed_result,
2264 __rte_unused struct cmdline *cl,
2265 __rte_unused void *data)
2267 struct cmd_suspend_port_tm_node_result *res = parsed_result;
2268 struct rte_tm_error error;
2269 uint32_t node_id = res->node_id;
2270 portid_t port_id = res->port_id;
2273 if (port_id_is_invalid(port_id, ENABLED_WARN))
2276 memset(&error, 0, sizeof(struct rte_tm_error));
2277 ret = rte_tm_node_suspend(port_id, node_id, &error);
2279 print_err_msg(&error);
2284 cmdline_parse_inst_t cmd_suspend_port_tm_node = {
2285 .f = cmd_suspend_port_tm_node_parsed,
2287 .help_str = "Suspend port tm node",
2289 (void *)&cmd_suspend_port_tm_node_suspend,
2290 (void *)&cmd_suspend_port_tm_node_port,
2291 (void *)&cmd_suspend_port_tm_node_tm,
2292 (void *)&cmd_suspend_port_tm_node_node,
2293 (void *)&cmd_suspend_port_tm_node_port_id,
2294 (void *)&cmd_suspend_port_tm_node_node_id,
2299 /* *** Resume Port TM Node *** */
2300 struct cmd_resume_port_tm_node_result {
2301 cmdline_fixed_string_t resume;
2302 cmdline_fixed_string_t port;
2303 cmdline_fixed_string_t tm;
2304 cmdline_fixed_string_t node;
2309 cmdline_parse_token_string_t cmd_resume_port_tm_node_resume =
2310 TOKEN_STRING_INITIALIZER(
2311 struct cmd_resume_port_tm_node_result, resume, "resume");
2312 cmdline_parse_token_string_t cmd_resume_port_tm_node_port =
2313 TOKEN_STRING_INITIALIZER(
2314 struct cmd_resume_port_tm_node_result, port, "port");
2315 cmdline_parse_token_string_t cmd_resume_port_tm_node_tm =
2316 TOKEN_STRING_INITIALIZER(
2317 struct cmd_resume_port_tm_node_result, tm, "tm");
2318 cmdline_parse_token_string_t cmd_resume_port_tm_node_node =
2319 TOKEN_STRING_INITIALIZER(
2320 struct cmd_resume_port_tm_node_result, node, "node");
2321 cmdline_parse_token_num_t cmd_resume_port_tm_node_port_id =
2322 TOKEN_NUM_INITIALIZER(
2323 struct cmd_resume_port_tm_node_result, port_id, RTE_UINT16);
2324 cmdline_parse_token_num_t cmd_resume_port_tm_node_node_id =
2325 TOKEN_NUM_INITIALIZER(
2326 struct cmd_resume_port_tm_node_result, node_id, RTE_UINT32);
2328 static void cmd_resume_port_tm_node_parsed(void *parsed_result,
2329 __rte_unused struct cmdline *cl,
2330 __rte_unused void *data)
2332 struct cmd_resume_port_tm_node_result *res = parsed_result;
2333 struct rte_tm_error error;
2334 uint32_t node_id = res->node_id;
2335 portid_t port_id = res->port_id;
2338 if (port_id_is_invalid(port_id, ENABLED_WARN))
2341 memset(&error, 0, sizeof(struct rte_tm_error));
2342 ret = rte_tm_node_resume(port_id, node_id, &error);
2344 print_err_msg(&error);
2349 cmdline_parse_inst_t cmd_resume_port_tm_node = {
2350 .f = cmd_resume_port_tm_node_parsed,
2352 .help_str = "Resume port tm node",
2354 (void *)&cmd_resume_port_tm_node_resume,
2355 (void *)&cmd_resume_port_tm_node_port,
2356 (void *)&cmd_resume_port_tm_node_tm,
2357 (void *)&cmd_resume_port_tm_node_node,
2358 (void *)&cmd_resume_port_tm_node_port_id,
2359 (void *)&cmd_resume_port_tm_node_node_id,
2364 /* *** Port TM Hierarchy Commit *** */
2365 struct cmd_port_tm_hierarchy_commit_result {
2366 cmdline_fixed_string_t port;
2367 cmdline_fixed_string_t tm;
2368 cmdline_fixed_string_t hierarchy;
2369 cmdline_fixed_string_t commit;
2371 cmdline_fixed_string_t clean_on_fail;
2374 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port =
2375 TOKEN_STRING_INITIALIZER(
2376 struct cmd_port_tm_hierarchy_commit_result, port, "port");
2377 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm =
2378 TOKEN_STRING_INITIALIZER(
2379 struct cmd_port_tm_hierarchy_commit_result, tm, "tm");
2380 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy =
2381 TOKEN_STRING_INITIALIZER(
2382 struct cmd_port_tm_hierarchy_commit_result,
2383 hierarchy, "hierarchy");
2384 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit =
2385 TOKEN_STRING_INITIALIZER(
2386 struct cmd_port_tm_hierarchy_commit_result, commit, "commit");
2387 cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id =
2388 TOKEN_NUM_INITIALIZER(
2389 struct cmd_port_tm_hierarchy_commit_result,
2390 port_id, RTE_UINT16);
2391 cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_clean_on_fail =
2392 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result,
2393 clean_on_fail, "yes#no");
2395 static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result,
2396 __rte_unused struct cmdline *cl,
2397 __rte_unused void *data)
2399 struct cmd_port_tm_hierarchy_commit_result *res = parsed_result;
2400 struct rte_tm_error error;
2401 uint32_t clean_on_fail;
2402 portid_t port_id = res->port_id;
2405 if (port_id_is_invalid(port_id, ENABLED_WARN))
2408 if (strcmp(res->clean_on_fail, "yes") == 0)
2413 memset(&error, 0, sizeof(struct rte_tm_error));
2414 ret = rte_tm_hierarchy_commit(port_id, clean_on_fail, &error);
2416 print_err_msg(&error);
2421 cmdline_parse_inst_t cmd_port_tm_hierarchy_commit = {
2422 .f = cmd_port_tm_hierarchy_commit_parsed,
2424 .help_str = "Commit port tm hierarchy",
2426 (void *)&cmd_port_tm_hierarchy_commit_port,
2427 (void *)&cmd_port_tm_hierarchy_commit_tm,
2428 (void *)&cmd_port_tm_hierarchy_commit_hierarchy,
2429 (void *)&cmd_port_tm_hierarchy_commit_commit,
2430 (void *)&cmd_port_tm_hierarchy_commit_port_id,
2431 (void *)&cmd_port_tm_hierarchy_commit_clean_on_fail,
2436 /* *** Port TM Mark IP ECN *** */
2437 struct cmd_port_tm_mark_ip_ecn_result {
2438 cmdline_fixed_string_t set;
2439 cmdline_fixed_string_t port;
2440 cmdline_fixed_string_t tm;
2441 cmdline_fixed_string_t mark;
2442 cmdline_fixed_string_t ip_ecn;
2449 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_set =
2450 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2453 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_port =
2454 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2457 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_tm =
2458 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result, tm,
2461 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_mark =
2462 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2465 cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_ip_ecn =
2466 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2468 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_port_id =
2469 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2470 port_id, RTE_UINT16);
2472 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_green =
2473 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2475 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_yellow =
2476 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2477 yellow, RTE_UINT16);
2478 cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_red =
2479 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2482 static void cmd_port_tm_mark_ip_ecn_parsed(void *parsed_result,
2483 __rte_unused struct cmdline *cl,
2484 __rte_unused void *data)
2486 struct cmd_port_tm_mark_ip_ecn_result *res = parsed_result;
2487 struct rte_tm_error error;
2488 portid_t port_id = res->port_id;
2489 int green = res->green;
2490 int yellow = res->yellow;
2493 if (port_id_is_invalid(port_id, ENABLED_WARN))
2496 memset(&error, 0, sizeof(struct rte_tm_error));
2497 ret = rte_tm_mark_ip_ecn(port_id, green, yellow, red, &error);
2499 print_err_msg(&error);
2504 cmdline_parse_inst_t cmd_port_tm_mark_ip_ecn = {
2505 .f = cmd_port_tm_mark_ip_ecn_parsed,
2507 .help_str = "set port tm mark ip_ecn <port> <green> <yellow> <red>",
2509 (void *)&cmd_port_tm_mark_ip_ecn_set,
2510 (void *)&cmd_port_tm_mark_ip_ecn_port,
2511 (void *)&cmd_port_tm_mark_ip_ecn_tm,
2512 (void *)&cmd_port_tm_mark_ip_ecn_mark,
2513 (void *)&cmd_port_tm_mark_ip_ecn_ip_ecn,
2514 (void *)&cmd_port_tm_mark_ip_ecn_port_id,
2515 (void *)&cmd_port_tm_mark_ip_ecn_green,
2516 (void *)&cmd_port_tm_mark_ip_ecn_yellow,
2517 (void *)&cmd_port_tm_mark_ip_ecn_red,
2523 /* *** Port TM Mark IP DSCP *** */
2524 struct cmd_port_tm_mark_ip_dscp_result {
2525 cmdline_fixed_string_t set;
2526 cmdline_fixed_string_t port;
2527 cmdline_fixed_string_t tm;
2528 cmdline_fixed_string_t mark;
2529 cmdline_fixed_string_t ip_dscp;
2536 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_set =
2537 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2540 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_port =
2541 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2544 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_tm =
2545 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result, tm,
2548 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_mark =
2549 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2552 cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_ip_dscp =
2553 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2554 ip_dscp, "ip_dscp");
2555 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_port_id =
2556 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2557 port_id, RTE_UINT16);
2559 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_green =
2560 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2562 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_yellow =
2563 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2564 yellow, RTE_UINT16);
2565 cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_red =
2566 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2569 static void cmd_port_tm_mark_ip_dscp_parsed(void *parsed_result,
2570 __rte_unused struct cmdline *cl,
2571 __rte_unused void *data)
2573 struct cmd_port_tm_mark_ip_dscp_result *res = parsed_result;
2574 struct rte_tm_error error;
2575 portid_t port_id = res->port_id;
2576 int green = res->green;
2577 int yellow = res->yellow;
2580 if (port_id_is_invalid(port_id, ENABLED_WARN))
2583 memset(&error, 0, sizeof(struct rte_tm_error));
2584 ret = rte_tm_mark_ip_dscp(port_id, green, yellow, red, &error);
2586 print_err_msg(&error);
2591 cmdline_parse_inst_t cmd_port_tm_mark_ip_dscp = {
2592 .f = cmd_port_tm_mark_ip_dscp_parsed,
2594 .help_str = "set port tm mark ip_dscp <port> <green> <yellow> <red>",
2596 (void *)&cmd_port_tm_mark_ip_dscp_set,
2597 (void *)&cmd_port_tm_mark_ip_dscp_port,
2598 (void *)&cmd_port_tm_mark_ip_dscp_tm,
2599 (void *)&cmd_port_tm_mark_ip_dscp_mark,
2600 (void *)&cmd_port_tm_mark_ip_dscp_ip_dscp,
2601 (void *)&cmd_port_tm_mark_ip_dscp_port_id,
2602 (void *)&cmd_port_tm_mark_ip_dscp_green,
2603 (void *)&cmd_port_tm_mark_ip_dscp_yellow,
2604 (void *)&cmd_port_tm_mark_ip_dscp_red,
2610 /* *** Port TM Mark VLAN_DEI *** */
2611 struct cmd_port_tm_mark_vlan_dei_result {
2612 cmdline_fixed_string_t set;
2613 cmdline_fixed_string_t port;
2614 cmdline_fixed_string_t tm;
2615 cmdline_fixed_string_t mark;
2616 cmdline_fixed_string_t vlan_dei;
2623 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_set =
2624 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2627 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_port =
2628 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2631 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_tm =
2632 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result, tm,
2635 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_mark =
2636 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2639 cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_vlan_dei =
2640 TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2641 vlan_dei, "vlan_dei");
2642 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_port_id =
2643 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2644 port_id, RTE_UINT16);
2646 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_green =
2647 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2649 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_yellow =
2650 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2651 yellow, RTE_UINT16);
2652 cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_red =
2653 TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2656 static void cmd_port_tm_mark_vlan_dei_parsed(void *parsed_result,
2657 __rte_unused struct cmdline *cl,
2658 __rte_unused void *data)
2660 struct cmd_port_tm_mark_vlan_dei_result *res = parsed_result;
2661 struct rte_tm_error error;
2662 portid_t port_id = res->port_id;
2663 int green = res->green;
2664 int yellow = res->yellow;
2667 if (port_id_is_invalid(port_id, ENABLED_WARN))
2670 memset(&error, 0, sizeof(struct rte_tm_error));
2671 ret = rte_tm_mark_vlan_dei(port_id, green, yellow, red, &error);
2673 print_err_msg(&error);
2678 cmdline_parse_inst_t cmd_port_tm_mark_vlan_dei = {
2679 .f = cmd_port_tm_mark_vlan_dei_parsed,
2681 .help_str = "set port tm mark vlan_dei <port> <green> <yellow> <red>",
2683 (void *)&cmd_port_tm_mark_vlan_dei_set,
2684 (void *)&cmd_port_tm_mark_vlan_dei_port,
2685 (void *)&cmd_port_tm_mark_vlan_dei_tm,
2686 (void *)&cmd_port_tm_mark_vlan_dei_mark,
2687 (void *)&cmd_port_tm_mark_vlan_dei_vlan_dei,
2688 (void *)&cmd_port_tm_mark_vlan_dei_port_id,
2689 (void *)&cmd_port_tm_mark_vlan_dei_green,
2690 (void *)&cmd_port_tm_mark_vlan_dei_yellow,
2691 (void *)&cmd_port_tm_mark_vlan_dei_red,