4 * Copyright(c) 2017 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <cmdline_parse.h>
35 #include <cmdline_parse_num.h>
36 #include <cmdline_parse_string.h>
38 #include <rte_ethdev.h>
43 #include "cmdline_tm.h"
45 /** Display TM Error Message */
47 print_err_msg(struct rte_tm_error *error)
49 static const char *const errstrlist[] = {
50 [RTE_TM_ERROR_TYPE_NONE] = "no error",
51 [RTE_TM_ERROR_TYPE_UNSPECIFIED] = "cause unspecified",
52 [RTE_TM_ERROR_TYPE_CAPABILITIES]
53 = "capability parameter null",
54 [RTE_TM_ERROR_TYPE_LEVEL_ID] = "level id",
55 [RTE_TM_ERROR_TYPE_WRED_PROFILE]
56 = "wred profile null",
57 [RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN] = "wred profile(green)",
58 [RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW]
59 = "wred profile(yellow)",
60 [RTE_TM_ERROR_TYPE_WRED_PROFILE_RED] = "wred profile(red)",
61 [RTE_TM_ERROR_TYPE_WRED_PROFILE_ID] = "wred profile id",
62 [RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID]
63 = "shared wred context id",
64 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE] = "shaper profile null",
65 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE]
66 = "committed rate field (shaper profile)",
67 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE]
68 = "committed size field (shaper profile)",
69 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE]
70 = "peak rate field (shaper profile)",
71 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE]
72 = "peak size field (shaper profile)",
73 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN]
74 = "packet adjust length field (shaper profile)",
75 [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID] = "shaper profile id",
76 [RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID] = "shared shaper id",
77 [RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID] = "parent node id",
78 [RTE_TM_ERROR_TYPE_NODE_PRIORITY] = "node priority",
79 [RTE_TM_ERROR_TYPE_NODE_WEIGHT] = "node weight",
80 [RTE_TM_ERROR_TYPE_NODE_PARAMS] = "node parameter null",
81 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID]
82 = "shaper profile id field (node params)",
83 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID]
84 = "shared shaper id field (node params)",
85 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS]
86 = "num shared shapers field (node params)",
87 [RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE]
88 = "wfq weght mode field (node params)",
89 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES]
90 = "num strict priorities field (node params)",
91 [RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN]
92 = "congestion management mode field (node params)",
93 [RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID] =
94 "wred profile id field (node params)",
95 [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID]
96 = "shared wred context id field (node params)",
97 [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS]
98 = "num shared wred contexts field (node params)",
99 [RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS]
100 = "stats field (node params)",
101 [RTE_TM_ERROR_TYPE_NODE_ID] = "node id",
107 if ((unsigned int)error->type >= RTE_DIM(errstrlist) ||
108 !errstrlist[error->type])
109 errstr = "unknown type";
111 errstr = errstrlist[error->type];
114 snprintf(buf, sizeof(buf), "cause: %p, ", error->cause);
116 printf("%s: %s%s (error %d)\n", errstr, error->cause ? buf : "",
117 error->message ? error->message : "(no stated reason)",
121 /* *** Port TM Capability *** */
122 struct cmd_show_port_tm_cap_result {
123 cmdline_fixed_string_t show;
124 cmdline_fixed_string_t port;
125 cmdline_fixed_string_t tm;
126 cmdline_fixed_string_t cap;
130 cmdline_parse_token_string_t cmd_show_port_tm_cap_show =
131 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
133 cmdline_parse_token_string_t cmd_show_port_tm_cap_port =
134 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
136 cmdline_parse_token_string_t cmd_show_port_tm_cap_tm =
137 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
139 cmdline_parse_token_string_t cmd_show_port_tm_cap_cap =
140 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
142 cmdline_parse_token_num_t cmd_show_port_tm_cap_port_id =
143 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_cap_result,
146 static void cmd_show_port_tm_cap_parsed(void *parsed_result,
147 __attribute__((unused)) struct cmdline *cl,
148 __attribute__((unused)) void *data)
150 struct cmd_show_port_tm_cap_result *res = parsed_result;
151 struct rte_tm_capabilities cap;
152 struct rte_tm_error error;
153 portid_t port_id = res->port_id;
157 if (port_id_is_invalid(port_id, ENABLED_WARN))
160 memset(&cap, 0, sizeof(struct rte_tm_capabilities));
161 ret = rte_tm_capabilities_get(port_id, &cap, &error);
163 print_err_msg(&error);
167 printf("\n**** Port TM Capabilities ****\n\n");
168 printf("cap.n_nodes_max %" PRIu32 "\n", cap.n_nodes_max);
169 printf("cap.n_levels_max %" PRIu32 "\n", cap.n_levels_max);
170 printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
171 cap.non_leaf_nodes_identical);
172 printf("cap.leaf_nodes_identical %" PRId32 "\n",
173 cap.leaf_nodes_identical);
174 printf("cap.shaper_n_max %u\n", cap.shaper_n_max);
175 printf("cap.shaper_private_n_max %" PRIu32 "\n",
176 cap.shaper_private_n_max);
177 printf("cap.shaper_private_dual_rate_n_max %" PRId32 "\n",
178 cap.shaper_private_dual_rate_n_max);
179 printf("cap.shaper_private_rate_min %" PRIu64 "\n",
180 cap.shaper_private_rate_min);
181 printf("cap.shaper_private_rate_max %" PRIu64 "\n",
182 cap.shaper_private_rate_max);
183 printf("cap.shaper_shared_n_max %" PRIu32 "\n",
184 cap.shaper_shared_n_max);
185 printf("cap.shaper_shared_n_nodes_per_shaper_max %" PRIu32 "\n",
186 cap.shaper_shared_n_nodes_per_shaper_max);
187 printf("cap.shaper_shared_n_shapers_per_node_max %" PRIu32 "\n",
188 cap.shaper_shared_n_shapers_per_node_max);
189 printf("cap.shaper_shared_dual_rate_n_max %" PRIu32 "\n",
190 cap.shaper_shared_dual_rate_n_max);
191 printf("cap.shaper_shared_rate_min %" PRIu64 "\n",
192 cap.shaper_shared_rate_min);
193 printf("cap.shaper_shared_rate_max %" PRIu64 "\n",
194 cap.shaper_shared_rate_max);
195 printf("cap.shaper_pkt_length_adjust_min %" PRId32 "\n",
196 cap.shaper_pkt_length_adjust_min);
197 printf("cap.shaper_pkt_length_adjust_max %" PRId32 "\n",
198 cap.shaper_pkt_length_adjust_max);
199 printf("cap.sched_n_children_max %" PRIu32 "\n",
200 cap.sched_n_children_max);
201 printf("cap.sched_sp_n_priorities_max %" PRIu32 "\n",
202 cap.sched_sp_n_priorities_max);
203 printf("cap.sched_wfq_n_children_per_group_max %" PRIu32 "\n",
204 cap.sched_wfq_n_children_per_group_max);
205 printf("cap.sched_wfq_n_groups_max %" PRIu32 "\n",
206 cap.sched_wfq_n_groups_max);
207 printf("cap.sched_wfq_weight_max %" PRIu32 "\n",
208 cap.sched_wfq_weight_max);
209 printf("cap.cman_head_drop_supported %" PRId32 "\n",
210 cap.cman_head_drop_supported);
211 printf("cap.cman_wred_context_n_max %" PRIu32 "\n",
212 cap.cman_wred_context_n_max);
213 printf("cap.cman_wred_context_private_n_max %" PRIu32 "\n",
214 cap.cman_wred_context_private_n_max);
215 printf("cap.cman_wred_context_shared_n_max %" PRIu32 "\n",
216 cap.cman_wred_context_shared_n_max);
217 printf("cap.cman_wred_context_shared_n_nodes_per_context_max %" PRIu32
218 "\n", cap.cman_wred_context_shared_n_nodes_per_context_max);
219 printf("cap.cman_wred_context_shared_n_contexts_per_node_max %" PRIu32
220 "\n", cap.cman_wred_context_shared_n_contexts_per_node_max);
222 for (i = 0; i < RTE_TM_COLORS; i++) {
223 printf("cap.mark_vlan_dei_supported %" PRId32 "\n",
224 cap.mark_vlan_dei_supported[i]);
225 printf("cap.mark_ip_ecn_tcp_supported %" PRId32 "\n",
226 cap.mark_ip_ecn_tcp_supported[i]);
227 printf("cap.mark_ip_ecn_sctp_supported %" PRId32 "\n",
228 cap.mark_ip_ecn_sctp_supported[i]);
229 printf("cap.mark_ip_dscp_supported %" PRId32 "\n",
230 cap.mark_ip_dscp_supported[i]);
233 printf("cap.dynamic_update_mask %" PRIx64 "\n",
234 cap.dynamic_update_mask);
235 printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
238 cmdline_parse_inst_t cmd_show_port_tm_cap = {
239 .f = cmd_show_port_tm_cap_parsed,
241 .help_str = "Show Port TM Capabilities",
243 (void *)&cmd_show_port_tm_cap_show,
244 (void *)&cmd_show_port_tm_cap_port,
245 (void *)&cmd_show_port_tm_cap_tm,
246 (void *)&cmd_show_port_tm_cap_cap,
247 (void *)&cmd_show_port_tm_cap_port_id,
252 /* *** Port TM Hierarchical Level Capability *** */
253 struct cmd_show_port_tm_level_cap_result {
254 cmdline_fixed_string_t show;
255 cmdline_fixed_string_t port;
256 cmdline_fixed_string_t tm;
257 cmdline_fixed_string_t level;
258 cmdline_fixed_string_t cap;
263 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_show =
264 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
266 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_port =
267 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
269 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_tm =
270 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
272 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_level =
273 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
275 cmdline_parse_token_string_t cmd_show_port_tm_level_cap_cap =
276 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
278 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_port_id =
279 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
281 cmdline_parse_token_num_t cmd_show_port_tm_level_cap_level_id =
282 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
286 static void cmd_show_port_tm_level_cap_parsed(void *parsed_result,
287 __attribute__((unused)) struct cmdline *cl,
288 __attribute__((unused)) void *data)
290 struct cmd_show_port_tm_level_cap_result *res = parsed_result;
291 struct rte_tm_level_capabilities lcap;
292 struct rte_tm_error error;
293 portid_t port_id = res->port_id;
294 uint32_t level_id = res->level_id;
297 if (port_id_is_invalid(port_id, ENABLED_WARN))
300 memset(&lcap, 0, sizeof(struct rte_tm_level_capabilities));
301 ret = rte_tm_level_capabilities_get(port_id, level_id, &lcap, &error);
303 print_err_msg(&error);
306 printf("\n** Port TM Hierarchy level %" PRIu32 " Capability **\n\n",
309 printf("cap.n_nodes_max %" PRIu32 "\n", lcap.n_nodes_max);
310 printf("cap.n_nodes_nonleaf_max %" PRIu32 "\n",
311 lcap.n_nodes_nonleaf_max);
312 printf("cap.n_nodes_leaf_max %" PRIu32 "\n", lcap.n_nodes_leaf_max);
313 printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
314 lcap.non_leaf_nodes_identical);
315 printf("cap.leaf_nodes_identical %" PRId32 "\n",
316 lcap.leaf_nodes_identical);
318 printf("cap.nonleaf.shaper_private_supported %" PRId32 "\n",
319 lcap.nonleaf.shaper_private_supported);
320 printf("cap.nonleaf.shaper_private_dual_rate_supported %" PRId32
321 "\n", lcap.nonleaf.shaper_private_dual_rate_supported);
322 printf("cap.nonleaf.shaper_private_rate_min %" PRIu64 "\n",
323 lcap.nonleaf.shaper_private_rate_min);
324 printf("cap.nonleaf.shaper_private_rate_max %" PRIu64 "\n",
325 lcap.nonleaf.shaper_private_rate_max);
326 printf("cap.nonleaf.shaper_shared_n_max %" PRIu32 "\n",
327 lcap.nonleaf.shaper_shared_n_max);
328 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
329 lcap.nonleaf.sched_n_children_max);
330 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
331 lcap.nonleaf.sched_sp_n_priorities_max);
332 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
333 "\n", lcap.nonleaf.sched_wfq_n_children_per_group_max);
334 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
335 lcap.nonleaf.sched_wfq_n_groups_max);
336 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
337 lcap.nonleaf.sched_wfq_weight_max);
338 printf("cap.nonleaf.stats_mask %" PRIx64 "\n",
339 lcap.nonleaf.stats_mask);
341 printf("cap.leaf.shaper_private_supported %" PRId32 "\n",
342 lcap.leaf.shaper_private_supported);
343 printf("cap.leaf.shaper_private_dual_rate_supported %" PRId32
344 "\n", lcap.leaf.shaper_private_dual_rate_supported);
345 printf("cap.leaf.shaper_private_rate_min %" PRIu64 "\n",
346 lcap.leaf.shaper_private_rate_min);
347 printf("cap.leaf.shaper_private_rate_max %" PRIu64 "\n",
348 lcap.leaf.shaper_private_rate_max);
349 printf("cap.leaf.shaper_shared_n_max %" PRIu32 "\n",
350 lcap.leaf.shaper_shared_n_max);
351 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
352 lcap.leaf.cman_head_drop_supported);
353 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
354 "\n", lcap.leaf.cman_wred_context_private_supported);
355 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
356 lcap.leaf.cman_wred_context_shared_n_max);
357 printf("cap.leaf.stats_mask %" PRIx64 "\n",
358 lcap.leaf.stats_mask);
362 cmdline_parse_inst_t cmd_show_port_tm_level_cap = {
363 .f = cmd_show_port_tm_level_cap_parsed,
365 .help_str = "Show Port TM Hierarhical level Capabilities",
367 (void *)&cmd_show_port_tm_level_cap_show,
368 (void *)&cmd_show_port_tm_level_cap_port,
369 (void *)&cmd_show_port_tm_level_cap_tm,
370 (void *)&cmd_show_port_tm_level_cap_level,
371 (void *)&cmd_show_port_tm_level_cap_cap,
372 (void *)&cmd_show_port_tm_level_cap_port_id,
373 (void *)&cmd_show_port_tm_level_cap_level_id,
378 /* *** Port TM Hierarchy Node Capability *** */
379 struct cmd_show_port_tm_node_cap_result {
380 cmdline_fixed_string_t show;
381 cmdline_fixed_string_t port;
382 cmdline_fixed_string_t tm;
383 cmdline_fixed_string_t node;
384 cmdline_fixed_string_t cap;
389 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_show =
390 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
392 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_port =
393 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
395 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_tm =
396 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
398 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_node =
399 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
401 cmdline_parse_token_string_t cmd_show_port_tm_node_cap_cap =
402 TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
404 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_port_id =
405 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
407 cmdline_parse_token_num_t cmd_show_port_tm_node_cap_node_id =
408 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
411 static void cmd_show_port_tm_node_cap_parsed(void *parsed_result,
412 __attribute__((unused)) struct cmdline *cl,
413 __attribute__((unused)) void *data)
415 struct cmd_show_port_tm_node_cap_result *res = parsed_result;
416 struct rte_tm_node_capabilities ncap;
417 struct rte_tm_error error;
418 uint32_t node_id = res->node_id;
419 portid_t port_id = res->port_id;
420 int ret, is_leaf = 0;
422 if (port_id_is_invalid(port_id, ENABLED_WARN))
425 /* Node id must be valid */
426 ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
428 print_err_msg(&error);
432 memset(&ncap, 0, sizeof(struct rte_tm_node_capabilities));
433 ret = rte_tm_node_capabilities_get(port_id, node_id, &ncap, &error);
435 print_err_msg(&error);
438 printf("\n** Port TM Hierarchy node %" PRIu32 " Capability **\n\n",
440 printf("cap.shaper_private_supported %" PRId32 "\n",
441 ncap.shaper_private_supported);
442 printf("cap.shaper_private_dual_rate_supported %" PRId32 "\n",
443 ncap.shaper_private_dual_rate_supported);
444 printf("cap.shaper_private_rate_min %" PRIu64 "\n",
445 ncap.shaper_private_rate_min);
446 printf("cap.shaper_private_rate_max %" PRIu64 "\n",
447 ncap.shaper_private_rate_max);
448 printf("cap.shaper_shared_n_max %" PRIu32 "\n",
449 ncap.shaper_shared_n_max);
451 printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
452 ncap.nonleaf.sched_n_children_max);
453 printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
454 ncap.nonleaf.sched_sp_n_priorities_max);
455 printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
456 "\n", ncap.nonleaf.sched_wfq_n_children_per_group_max);
457 printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
458 ncap.nonleaf.sched_wfq_n_groups_max);
459 printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
460 ncap.nonleaf.sched_wfq_weight_max);
462 printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
463 ncap.leaf.cman_head_drop_supported);
464 printf("cap.leaf.cman_wred_context_private_supported %" PRId32
465 "\n", ncap.leaf.cman_wred_context_private_supported);
466 printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
467 ncap.leaf.cman_wred_context_shared_n_max);
469 printf("cap.stats_mask %" PRIx64 "\n", ncap.stats_mask);
472 cmdline_parse_inst_t cmd_show_port_tm_node_cap = {
473 .f = cmd_show_port_tm_node_cap_parsed,
475 .help_str = "Show Port TM Hierarchy node capabilities",
477 (void *)&cmd_show_port_tm_node_cap_show,
478 (void *)&cmd_show_port_tm_node_cap_port,
479 (void *)&cmd_show_port_tm_node_cap_tm,
480 (void *)&cmd_show_port_tm_node_cap_node,
481 (void *)&cmd_show_port_tm_node_cap_cap,
482 (void *)&cmd_show_port_tm_node_cap_port_id,
483 (void *)&cmd_show_port_tm_node_cap_node_id,
488 /* *** Show Port TM Node Statistics *** */
489 struct cmd_show_port_tm_node_stats_result {
490 cmdline_fixed_string_t show;
491 cmdline_fixed_string_t port;
492 cmdline_fixed_string_t tm;
493 cmdline_fixed_string_t node;
494 cmdline_fixed_string_t stats;
500 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_show =
501 TOKEN_STRING_INITIALIZER(
502 struct cmd_show_port_tm_node_stats_result, show, "show");
503 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_port =
504 TOKEN_STRING_INITIALIZER(
505 struct cmd_show_port_tm_node_stats_result, port, "port");
506 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_tm =
507 TOKEN_STRING_INITIALIZER(
508 struct cmd_show_port_tm_node_stats_result, tm, "tm");
509 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_node =
510 TOKEN_STRING_INITIALIZER(
511 struct cmd_show_port_tm_node_stats_result, node, "node");
512 cmdline_parse_token_string_t cmd_show_port_tm_node_stats_stats =
513 TOKEN_STRING_INITIALIZER(
514 struct cmd_show_port_tm_node_stats_result, stats, "stats");
515 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_port_id =
516 TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_stats_result,
518 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_node_id =
519 TOKEN_NUM_INITIALIZER(
520 struct cmd_show_port_tm_node_stats_result,
522 cmdline_parse_token_num_t cmd_show_port_tm_node_stats_clear =
523 TOKEN_NUM_INITIALIZER(
524 struct cmd_show_port_tm_node_stats_result, clear, UINT32);
526 static void cmd_show_port_tm_node_stats_parsed(void *parsed_result,
527 __attribute__((unused)) struct cmdline *cl,
528 __attribute__((unused)) void *data)
530 struct cmd_show_port_tm_node_stats_result *res = parsed_result;
531 struct rte_tm_node_stats stats;
532 struct rte_tm_error error;
533 uint64_t stats_mask = 0;
534 uint32_t node_id = res->node_id;
535 uint32_t clear = res->clear;
536 portid_t port_id = res->port_id;
539 if (port_id_is_invalid(port_id, ENABLED_WARN))
543 if (!port_is_started(port_id)) {
544 printf(" Port %u not started (error)\n", port_id);
548 memset(&stats, 0, sizeof(struct rte_tm_node_stats));
549 ret = rte_tm_node_stats_read(port_id, node_id, &stats,
550 &stats_mask, clear, &error);
552 print_err_msg(&error);
557 if (stats_mask & RTE_TM_STATS_N_PKTS)
558 printf("\tPkts scheduled from node: %" PRIu64 "\n",
560 if (stats_mask & RTE_TM_STATS_N_BYTES)
561 printf("\tBytes scheduled from node: %" PRIu64 "\n",
563 if (stats_mask & RTE_TM_STATS_N_PKTS_GREEN_DROPPED)
564 printf("\tPkts dropped (green): %" PRIu64 "\n",
565 stats.leaf.n_pkts_dropped[RTE_TM_GREEN]);
566 if (stats_mask & RTE_TM_STATS_N_PKTS_YELLOW_DROPPED)
567 printf("\tPkts dropped (yellow): %" PRIu64 "\n",
568 stats.leaf.n_pkts_dropped[RTE_TM_YELLOW]);
569 if (stats_mask & RTE_TM_STATS_N_PKTS_RED_DROPPED)
570 printf("\tPkts dropped (red): %" PRIu64 "\n",
571 stats.leaf.n_pkts_dropped[RTE_TM_RED]);
572 if (stats_mask & RTE_TM_STATS_N_BYTES_GREEN_DROPPED)
573 printf("\tBytes dropped (green): %" PRIu64 "\n",
574 stats.leaf.n_bytes_dropped[RTE_TM_GREEN]);
575 if (stats_mask & RTE_TM_STATS_N_BYTES_YELLOW_DROPPED)
576 printf("\tBytes dropped (yellow): %" PRIu64 "\n",
577 stats.leaf.n_bytes_dropped[RTE_TM_YELLOW]);
578 if (stats_mask & RTE_TM_STATS_N_BYTES_RED_DROPPED)
579 printf("\tBytes dropped (red): %" PRIu64 "\n",
580 stats.leaf.n_bytes_dropped[RTE_TM_RED]);
581 if (stats_mask & RTE_TM_STATS_N_PKTS_QUEUED)
582 printf("\tPkts queued: %" PRIu64 "\n",
583 stats.leaf.n_pkts_queued);
584 if (stats_mask & RTE_TM_STATS_N_BYTES_QUEUED)
585 printf("\tBytes queued: %" PRIu64 "\n",
586 stats.leaf.n_bytes_queued);
589 cmdline_parse_inst_t cmd_show_port_tm_node_stats = {
590 .f = cmd_show_port_tm_node_stats_parsed,
592 .help_str = "Show port tm node stats",
594 (void *)&cmd_show_port_tm_node_stats_show,
595 (void *)&cmd_show_port_tm_node_stats_port,
596 (void *)&cmd_show_port_tm_node_stats_tm,
597 (void *)&cmd_show_port_tm_node_stats_node,
598 (void *)&cmd_show_port_tm_node_stats_stats,
599 (void *)&cmd_show_port_tm_node_stats_port_id,
600 (void *)&cmd_show_port_tm_node_stats_node_id,
601 (void *)&cmd_show_port_tm_node_stats_clear,
606 /* *** Show Port TM Node Type *** */
607 struct cmd_show_port_tm_node_type_result {
608 cmdline_fixed_string_t show;
609 cmdline_fixed_string_t port;
610 cmdline_fixed_string_t tm;
611 cmdline_fixed_string_t node;
612 cmdline_fixed_string_t type;
617 cmdline_parse_token_string_t cmd_show_port_tm_node_type_show =
618 TOKEN_STRING_INITIALIZER(
619 struct cmd_show_port_tm_node_type_result, show, "show");
620 cmdline_parse_token_string_t cmd_show_port_tm_node_type_port =
621 TOKEN_STRING_INITIALIZER(
622 struct cmd_show_port_tm_node_type_result, port, "port");
623 cmdline_parse_token_string_t cmd_show_port_tm_node_type_tm =
624 TOKEN_STRING_INITIALIZER(
625 struct cmd_show_port_tm_node_type_result, tm, "tm");
626 cmdline_parse_token_string_t cmd_show_port_tm_node_type_node =
627 TOKEN_STRING_INITIALIZER(
628 struct cmd_show_port_tm_node_type_result, node, "node");
629 cmdline_parse_token_string_t cmd_show_port_tm_node_type_type =
630 TOKEN_STRING_INITIALIZER(
631 struct cmd_show_port_tm_node_type_result, type, "type");
632 cmdline_parse_token_num_t cmd_show_port_tm_node_type_port_id =
633 TOKEN_NUM_INITIALIZER(
634 struct cmd_show_port_tm_node_type_result,
636 cmdline_parse_token_num_t cmd_show_port_tm_node_type_node_id =
637 TOKEN_NUM_INITIALIZER(
638 struct cmd_show_port_tm_node_type_result,
641 static void cmd_show_port_tm_node_type_parsed(void *parsed_result,
642 __attribute__((unused)) struct cmdline *cl,
643 __attribute__((unused)) void *data)
645 struct cmd_show_port_tm_node_type_result *res = parsed_result;
646 struct rte_tm_error error;
647 uint32_t node_id = res->node_id;
648 portid_t port_id = res->port_id;
649 int ret, is_leaf = 0;
651 if (port_id_is_invalid(port_id, ENABLED_WARN))
654 ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
656 print_err_msg(&error);
661 printf("leaf node\n");
663 printf("nonleaf node\n");
667 cmdline_parse_inst_t cmd_show_port_tm_node_type = {
668 .f = cmd_show_port_tm_node_type_parsed,
670 .help_str = "Show port tm node type",
672 (void *)&cmd_show_port_tm_node_type_show,
673 (void *)&cmd_show_port_tm_node_type_port,
674 (void *)&cmd_show_port_tm_node_type_tm,
675 (void *)&cmd_show_port_tm_node_type_node,
676 (void *)&cmd_show_port_tm_node_type_type,
677 (void *)&cmd_show_port_tm_node_type_port_id,
678 (void *)&cmd_show_port_tm_node_type_node_id,
683 /* *** Add Port TM Private Shaper Profile *** */
684 struct cmd_add_port_tm_node_shaper_profile_result {
685 cmdline_fixed_string_t add;
686 cmdline_fixed_string_t port;
687 cmdline_fixed_string_t tm;
688 cmdline_fixed_string_t node;
689 cmdline_fixed_string_t shaper;
690 cmdline_fixed_string_t profile;
695 uint32_t pktlen_adjust;
698 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add =
699 TOKEN_STRING_INITIALIZER(
700 struct cmd_add_port_tm_node_shaper_profile_result, add, "add");
701 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port =
702 TOKEN_STRING_INITIALIZER(
703 struct cmd_add_port_tm_node_shaper_profile_result,
705 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm =
706 TOKEN_STRING_INITIALIZER(
707 struct cmd_add_port_tm_node_shaper_profile_result,
709 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node =
710 TOKEN_STRING_INITIALIZER(
711 struct cmd_add_port_tm_node_shaper_profile_result,
713 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper =
714 TOKEN_STRING_INITIALIZER(
715 struct cmd_add_port_tm_node_shaper_profile_result,
717 cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile =
718 TOKEN_STRING_INITIALIZER(
719 struct cmd_add_port_tm_node_shaper_profile_result,
721 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id =
722 TOKEN_NUM_INITIALIZER(
723 struct cmd_add_port_tm_node_shaper_profile_result,
725 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id =
726 TOKEN_NUM_INITIALIZER(
727 struct cmd_add_port_tm_node_shaper_profile_result,
729 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_tb_rate =
730 TOKEN_NUM_INITIALIZER(
731 struct cmd_add_port_tm_node_shaper_profile_result,
733 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_tb_size =
734 TOKEN_NUM_INITIALIZER(
735 struct cmd_add_port_tm_node_shaper_profile_result,
737 cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust =
738 TOKEN_NUM_INITIALIZER(
739 struct cmd_add_port_tm_node_shaper_profile_result,
740 pktlen_adjust, UINT32);
742 static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
743 __attribute__((unused)) struct cmdline *cl,
744 __attribute__((unused)) void *data)
746 struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result;
747 struct rte_tm_shaper_params sp;
748 struct rte_tm_error error;
749 uint32_t shaper_id = res->shaper_id;
750 uint32_t pkt_len_adjust = res->pktlen_adjust;
751 portid_t port_id = res->port_id;
754 if (port_id_is_invalid(port_id, ENABLED_WARN))
757 /* Private shaper profile params */
758 memset(&sp, 0, sizeof(struct rte_tm_shaper_params));
759 sp.peak.rate = res->tb_rate;
760 sp.peak.size = res->tb_size;
761 sp.pkt_length_adjust = pkt_len_adjust;
763 ret = rte_tm_shaper_profile_add(port_id, shaper_id, &sp, &error);
765 print_err_msg(&error);
770 cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile = {
771 .f = cmd_add_port_tm_node_shaper_profile_parsed,
773 .help_str = "Add port tm node private shaper profile",
775 (void *)&cmd_add_port_tm_node_shaper_profile_add,
776 (void *)&cmd_add_port_tm_node_shaper_profile_port,
777 (void *)&cmd_add_port_tm_node_shaper_profile_tm,
778 (void *)&cmd_add_port_tm_node_shaper_profile_node,
779 (void *)&cmd_add_port_tm_node_shaper_profile_shaper,
780 (void *)&cmd_add_port_tm_node_shaper_profile_profile,
781 (void *)&cmd_add_port_tm_node_shaper_profile_port_id,
782 (void *)&cmd_add_port_tm_node_shaper_profile_shaper_id,
783 (void *)&cmd_add_port_tm_node_shaper_profile_tb_rate,
784 (void *)&cmd_add_port_tm_node_shaper_profile_tb_size,
785 (void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust,
790 /* *** Delete Port TM Private Shaper Profile *** */
791 struct cmd_del_port_tm_node_shaper_profile_result {
792 cmdline_fixed_string_t del;
793 cmdline_fixed_string_t port;
794 cmdline_fixed_string_t tm;
795 cmdline_fixed_string_t node;
796 cmdline_fixed_string_t shaper;
797 cmdline_fixed_string_t profile;
802 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del =
803 TOKEN_STRING_INITIALIZER(
804 struct cmd_del_port_tm_node_shaper_profile_result, del, "del");
805 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port =
806 TOKEN_STRING_INITIALIZER(
807 struct cmd_del_port_tm_node_shaper_profile_result,
809 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm =
810 TOKEN_STRING_INITIALIZER(
811 struct cmd_del_port_tm_node_shaper_profile_result, tm, "tm");
812 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node =
813 TOKEN_STRING_INITIALIZER(
814 struct cmd_del_port_tm_node_shaper_profile_result,
816 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper =
817 TOKEN_STRING_INITIALIZER(
818 struct cmd_del_port_tm_node_shaper_profile_result,
820 cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile =
821 TOKEN_STRING_INITIALIZER(
822 struct cmd_del_port_tm_node_shaper_profile_result,
824 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id =
825 TOKEN_NUM_INITIALIZER(
826 struct cmd_del_port_tm_node_shaper_profile_result,
828 cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id =
829 TOKEN_NUM_INITIALIZER(
830 struct cmd_del_port_tm_node_shaper_profile_result,
833 static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result,
834 __attribute__((unused)) struct cmdline *cl,
835 __attribute__((unused)) void *data)
837 struct cmd_del_port_tm_node_shaper_profile_result *res = parsed_result;
838 struct rte_tm_error error;
839 uint32_t shaper_id = res->shaper_id;
840 portid_t port_id = res->port_id;
843 if (port_id_is_invalid(port_id, ENABLED_WARN))
846 ret = rte_tm_shaper_profile_delete(port_id, shaper_id, &error);
848 print_err_msg(&error);
853 cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile = {
854 .f = cmd_del_port_tm_node_shaper_profile_parsed,
856 .help_str = "Delete port tm node private shaper profile",
858 (void *)&cmd_del_port_tm_node_shaper_profile_del,
859 (void *)&cmd_del_port_tm_node_shaper_profile_port,
860 (void *)&cmd_del_port_tm_node_shaper_profile_tm,
861 (void *)&cmd_del_port_tm_node_shaper_profile_node,
862 (void *)&cmd_del_port_tm_node_shaper_profile_shaper,
863 (void *)&cmd_del_port_tm_node_shaper_profile_profile,
864 (void *)&cmd_del_port_tm_node_shaper_profile_port_id,
865 (void *)&cmd_del_port_tm_node_shaper_profile_shaper_id,
870 /* *** Add/Update Port TM shared Shaper *** */
871 struct cmd_add_port_tm_node_shared_shaper_result {
872 cmdline_fixed_string_t cmd_type;
873 cmdline_fixed_string_t port;
874 cmdline_fixed_string_t tm;
875 cmdline_fixed_string_t node;
876 cmdline_fixed_string_t shared;
877 cmdline_fixed_string_t shaper;
879 uint32_t shared_shaper_id;
880 uint32_t shaper_profile_id;
883 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type =
884 TOKEN_STRING_INITIALIZER(
885 struct cmd_add_port_tm_node_shared_shaper_result,
886 cmd_type, "add#set");
887 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port =
888 TOKEN_STRING_INITIALIZER(
889 struct cmd_add_port_tm_node_shared_shaper_result, port, "port");
890 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm =
891 TOKEN_STRING_INITIALIZER(
892 struct cmd_add_port_tm_node_shared_shaper_result, tm, "tm");
893 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node =
894 TOKEN_STRING_INITIALIZER(
895 struct cmd_add_port_tm_node_shared_shaper_result, node, "node");
896 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared =
897 TOKEN_STRING_INITIALIZER(
898 struct cmd_add_port_tm_node_shared_shaper_result,
900 cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper =
901 TOKEN_STRING_INITIALIZER(
902 struct cmd_add_port_tm_node_shared_shaper_result,
904 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id =
905 TOKEN_NUM_INITIALIZER(
906 struct cmd_add_port_tm_node_shared_shaper_result,
908 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id =
909 TOKEN_NUM_INITIALIZER(
910 struct cmd_add_port_tm_node_shared_shaper_result,
911 shared_shaper_id, UINT32);
912 cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id =
913 TOKEN_NUM_INITIALIZER(
914 struct cmd_add_port_tm_node_shared_shaper_result,
915 shaper_profile_id, UINT32);
917 static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result,
918 __attribute__((unused)) struct cmdline *cl,
919 __attribute__((unused)) void *data)
921 struct cmd_add_port_tm_node_shared_shaper_result *res = parsed_result;
922 struct rte_tm_error error;
923 uint32_t shared_shaper_id = res->shared_shaper_id;
924 uint32_t shaper_profile_id = res->shaper_profile_id;
925 portid_t port_id = res->port_id;
928 if (port_id_is_invalid(port_id, ENABLED_WARN))
931 /* Command type: add */
932 if ((strcmp(res->cmd_type, "add") == 0) &&
933 (port_is_started(port_id))) {
934 printf(" Port %u not stopped (error)\n", port_id);
938 /* Command type: set (update) */
939 if ((strcmp(res->cmd_type, "set") == 0) &&
940 (!port_is_started(port_id))) {
941 printf(" Port %u not started (error)\n", port_id);
945 ret = rte_tm_shared_shaper_add_update(port_id, shared_shaper_id,
946 shaper_profile_id, &error);
948 print_err_msg(&error);
953 cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper = {
954 .f = cmd_add_port_tm_node_shared_shaper_parsed,
956 .help_str = "add/update port tm node shared shaper",
958 (void *)&cmd_add_port_tm_node_shared_shaper_cmd_type,
959 (void *)&cmd_add_port_tm_node_shared_shaper_port,
960 (void *)&cmd_add_port_tm_node_shared_shaper_tm,
961 (void *)&cmd_add_port_tm_node_shared_shaper_node,
962 (void *)&cmd_add_port_tm_node_shared_shaper_shared,
963 (void *)&cmd_add_port_tm_node_shared_shaper_shaper,
964 (void *)&cmd_add_port_tm_node_shared_shaper_port_id,
965 (void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id,
966 (void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id,
971 /* *** Delete Port TM shared Shaper *** */
972 struct cmd_del_port_tm_node_shared_shaper_result {
973 cmdline_fixed_string_t del;
974 cmdline_fixed_string_t port;
975 cmdline_fixed_string_t tm;
976 cmdline_fixed_string_t node;
977 cmdline_fixed_string_t shared;
978 cmdline_fixed_string_t shaper;
980 uint32_t shared_shaper_id;
983 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del =
984 TOKEN_STRING_INITIALIZER(
985 struct cmd_del_port_tm_node_shared_shaper_result, del, "del");
986 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port =
987 TOKEN_STRING_INITIALIZER(
988 struct cmd_del_port_tm_node_shared_shaper_result, port, "port");
989 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm =
990 TOKEN_STRING_INITIALIZER(
991 struct cmd_del_port_tm_node_shared_shaper_result, tm, "tm");
992 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node =
993 TOKEN_STRING_INITIALIZER(
994 struct cmd_del_port_tm_node_shared_shaper_result, node, "node");
995 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared =
996 TOKEN_STRING_INITIALIZER(
997 struct cmd_del_port_tm_node_shared_shaper_result,
999 cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper =
1000 TOKEN_STRING_INITIALIZER(
1001 struct cmd_del_port_tm_node_shared_shaper_result,
1003 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id =
1004 TOKEN_NUM_INITIALIZER(
1005 struct cmd_del_port_tm_node_shared_shaper_result,
1007 cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id =
1008 TOKEN_NUM_INITIALIZER(
1009 struct cmd_del_port_tm_node_shared_shaper_result,
1010 shared_shaper_id, UINT32);
1012 static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result,
1013 __attribute__((unused)) struct cmdline *cl,
1014 __attribute__((unused)) void *data)
1016 struct cmd_del_port_tm_node_shared_shaper_result *res = parsed_result;
1017 struct rte_tm_error error;
1018 uint32_t shared_shaper_id = res->shared_shaper_id;
1019 portid_t port_id = res->port_id;
1022 if (port_id_is_invalid(port_id, ENABLED_WARN))
1025 ret = rte_tm_shared_shaper_delete(port_id, shared_shaper_id, &error);
1027 print_err_msg(&error);
1032 cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper = {
1033 .f = cmd_del_port_tm_node_shared_shaper_parsed,
1035 .help_str = "delete port tm node shared shaper",
1037 (void *)&cmd_del_port_tm_node_shared_shaper_del,
1038 (void *)&cmd_del_port_tm_node_shared_shaper_port,
1039 (void *)&cmd_del_port_tm_node_shared_shaper_tm,
1040 (void *)&cmd_del_port_tm_node_shared_shaper_node,
1041 (void *)&cmd_del_port_tm_node_shared_shaper_shared,
1042 (void *)&cmd_del_port_tm_node_shared_shaper_shaper,
1043 (void *)&cmd_del_port_tm_node_shared_shaper_port_id,
1044 (void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id,
1049 /* *** Add Port TM Node WRED Profile *** */
1050 struct cmd_add_port_tm_node_wred_profile_result {
1051 cmdline_fixed_string_t add;
1052 cmdline_fixed_string_t port;
1053 cmdline_fixed_string_t tm;
1054 cmdline_fixed_string_t node;
1055 cmdline_fixed_string_t wred;
1056 cmdline_fixed_string_t profile;
1058 uint32_t wred_profile_id;
1059 cmdline_fixed_string_t color_g;
1062 uint16_t maxp_inv_g;
1064 cmdline_fixed_string_t color_y;
1067 uint16_t maxp_inv_y;
1069 cmdline_fixed_string_t color_r;
1072 uint16_t maxp_inv_r;
1076 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add =
1077 TOKEN_STRING_INITIALIZER(
1078 struct cmd_add_port_tm_node_wred_profile_result, add, "add");
1079 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port =
1080 TOKEN_STRING_INITIALIZER(
1081 struct cmd_add_port_tm_node_wred_profile_result, port, "port");
1082 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm =
1083 TOKEN_STRING_INITIALIZER(
1084 struct cmd_add_port_tm_node_wred_profile_result, tm, "tm");
1085 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node =
1086 TOKEN_STRING_INITIALIZER(
1087 struct cmd_add_port_tm_node_wred_profile_result, node, "node");
1088 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred =
1089 TOKEN_STRING_INITIALIZER(
1090 struct cmd_add_port_tm_node_wred_profile_result, wred, "wred");
1091 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile =
1092 TOKEN_STRING_INITIALIZER(
1093 struct cmd_add_port_tm_node_wred_profile_result,
1094 profile, "profile");
1095 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id =
1096 TOKEN_NUM_INITIALIZER(
1097 struct cmd_add_port_tm_node_wred_profile_result,
1099 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id =
1100 TOKEN_NUM_INITIALIZER(
1101 struct cmd_add_port_tm_node_wred_profile_result,
1102 wred_profile_id, UINT32);
1103 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g =
1104 TOKEN_STRING_INITIALIZER(
1105 struct cmd_add_port_tm_node_wred_profile_result,
1107 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g =
1108 TOKEN_NUM_INITIALIZER(
1109 struct cmd_add_port_tm_node_wred_profile_result,
1111 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g =
1112 TOKEN_NUM_INITIALIZER(
1113 struct cmd_add_port_tm_node_wred_profile_result,
1115 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g =
1116 TOKEN_NUM_INITIALIZER(
1117 struct cmd_add_port_tm_node_wred_profile_result,
1118 maxp_inv_g, UINT16);
1119 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g =
1120 TOKEN_NUM_INITIALIZER(
1121 struct cmd_add_port_tm_node_wred_profile_result,
1123 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y =
1124 TOKEN_STRING_INITIALIZER(
1125 struct cmd_add_port_tm_node_wred_profile_result,
1127 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y =
1128 TOKEN_NUM_INITIALIZER(
1129 struct cmd_add_port_tm_node_wred_profile_result,
1131 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y =
1132 TOKEN_NUM_INITIALIZER(
1133 struct cmd_add_port_tm_node_wred_profile_result,
1135 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y =
1136 TOKEN_NUM_INITIALIZER(
1137 struct cmd_add_port_tm_node_wred_profile_result,
1138 maxp_inv_y, UINT16);
1139 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y =
1140 TOKEN_NUM_INITIALIZER(
1141 struct cmd_add_port_tm_node_wred_profile_result,
1143 cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r =
1144 TOKEN_STRING_INITIALIZER(
1145 struct cmd_add_port_tm_node_wred_profile_result,
1147 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r =
1148 TOKEN_NUM_INITIALIZER(
1149 struct cmd_add_port_tm_node_wred_profile_result,
1151 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r =
1152 TOKEN_NUM_INITIALIZER(
1153 struct cmd_add_port_tm_node_wred_profile_result,
1155 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r =
1156 TOKEN_NUM_INITIALIZER(
1157 struct cmd_add_port_tm_node_wred_profile_result,
1158 maxp_inv_r, UINT16);
1159 cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r =
1160 TOKEN_NUM_INITIALIZER(
1161 struct cmd_add_port_tm_node_wred_profile_result,
1165 static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
1166 __attribute__((unused)) struct cmdline *cl,
1167 __attribute__((unused)) void *data)
1169 struct cmd_add_port_tm_node_wred_profile_result *res = parsed_result;
1170 struct rte_tm_wred_params wp;
1171 enum rte_tm_color color;
1172 struct rte_tm_error error;
1173 uint32_t wred_profile_id = res->wred_profile_id;
1174 portid_t port_id = res->port_id;
1177 if (port_id_is_invalid(port_id, ENABLED_WARN))
1180 memset(&wp, 0, sizeof(struct rte_tm_wred_params));
1182 /* WRED Params (Green Color)*/
1183 color = RTE_TM_GREEN;
1184 wp.red_params[color].min_th = res->min_th_g;
1185 wp.red_params[color].max_th = res->max_th_g;
1186 wp.red_params[color].maxp_inv = res->maxp_inv_g;
1187 wp.red_params[color].wq_log2 = res->wq_log2_g;
1190 /* WRED Params (Yellow Color)*/
1191 color = RTE_TM_YELLOW;
1192 wp.red_params[color].min_th = res->min_th_y;
1193 wp.red_params[color].max_th = res->max_th_y;
1194 wp.red_params[color].maxp_inv = res->maxp_inv_y;
1195 wp.red_params[color].wq_log2 = res->wq_log2_y;
1197 /* WRED Params (Red Color)*/
1199 wp.red_params[color].min_th = res->min_th_r;
1200 wp.red_params[color].max_th = res->max_th_r;
1201 wp.red_params[color].maxp_inv = res->maxp_inv_r;
1202 wp.red_params[color].wq_log2 = res->wq_log2_r;
1204 ret = rte_tm_wred_profile_add(port_id, wred_profile_id, &wp, &error);
1206 print_err_msg(&error);
1211 cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile = {
1212 .f = cmd_add_port_tm_node_wred_profile_parsed,
1214 .help_str = "Add port tm node wred profile",
1216 (void *)&cmd_add_port_tm_node_wred_profile_add,
1217 (void *)&cmd_add_port_tm_node_wred_profile_port,
1218 (void *)&cmd_add_port_tm_node_wred_profile_tm,
1219 (void *)&cmd_add_port_tm_node_wred_profile_node,
1220 (void *)&cmd_add_port_tm_node_wred_profile_wred,
1221 (void *)&cmd_add_port_tm_node_wred_profile_profile,
1222 (void *)&cmd_add_port_tm_node_wred_profile_port_id,
1223 (void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id,
1224 (void *)&cmd_add_port_tm_node_wred_profile_color_g,
1225 (void *)&cmd_add_port_tm_node_wred_profile_min_th_g,
1226 (void *)&cmd_add_port_tm_node_wred_profile_max_th_g,
1227 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g,
1228 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g,
1229 (void *)&cmd_add_port_tm_node_wred_profile_color_y,
1230 (void *)&cmd_add_port_tm_node_wred_profile_min_th_y,
1231 (void *)&cmd_add_port_tm_node_wred_profile_max_th_y,
1232 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y,
1233 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y,
1234 (void *)&cmd_add_port_tm_node_wred_profile_color_r,
1235 (void *)&cmd_add_port_tm_node_wred_profile_min_th_r,
1236 (void *)&cmd_add_port_tm_node_wred_profile_max_th_r,
1237 (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r,
1238 (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r,
1243 /* *** Delete Port TM node WRED Profile *** */
1244 struct cmd_del_port_tm_node_wred_profile_result {
1245 cmdline_fixed_string_t del;
1246 cmdline_fixed_string_t port;
1247 cmdline_fixed_string_t tm;
1248 cmdline_fixed_string_t node;
1249 cmdline_fixed_string_t wred;
1250 cmdline_fixed_string_t profile;
1252 uint32_t wred_profile_id;
1255 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del =
1256 TOKEN_STRING_INITIALIZER(
1257 struct cmd_del_port_tm_node_wred_profile_result, del, "del");
1258 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port =
1259 TOKEN_STRING_INITIALIZER(
1260 struct cmd_del_port_tm_node_wred_profile_result, port, "port");
1261 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm =
1262 TOKEN_STRING_INITIALIZER(
1263 struct cmd_del_port_tm_node_wred_profile_result, tm, "tm");
1264 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node =
1265 TOKEN_STRING_INITIALIZER(
1266 struct cmd_del_port_tm_node_wred_profile_result, node, "node");
1267 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred =
1268 TOKEN_STRING_INITIALIZER(
1269 struct cmd_del_port_tm_node_wred_profile_result, wred, "wred");
1270 cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile =
1271 TOKEN_STRING_INITIALIZER(
1272 struct cmd_del_port_tm_node_wred_profile_result,
1273 profile, "profile");
1274 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id =
1275 TOKEN_NUM_INITIALIZER(
1276 struct cmd_del_port_tm_node_wred_profile_result,
1278 cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id =
1279 TOKEN_NUM_INITIALIZER(
1280 struct cmd_del_port_tm_node_wred_profile_result,
1281 wred_profile_id, UINT32);
1283 static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result,
1284 __attribute__((unused)) struct cmdline *cl,
1285 __attribute__((unused)) void *data)
1287 struct cmd_del_port_tm_node_wred_profile_result *res = parsed_result;
1288 struct rte_tm_error error;
1289 uint32_t wred_profile_id = res->wred_profile_id;
1290 portid_t port_id = res->port_id;
1293 if (port_id_is_invalid(port_id, ENABLED_WARN))
1296 ret = rte_tm_wred_profile_delete(port_id, wred_profile_id, &error);
1298 print_err_msg(&error);
1303 cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile = {
1304 .f = cmd_del_port_tm_node_wred_profile_parsed,
1306 .help_str = "Delete port tm node wred profile",
1308 (void *)&cmd_del_port_tm_node_wred_profile_del,
1309 (void *)&cmd_del_port_tm_node_wred_profile_port,
1310 (void *)&cmd_del_port_tm_node_wred_profile_tm,
1311 (void *)&cmd_del_port_tm_node_wred_profile_node,
1312 (void *)&cmd_del_port_tm_node_wred_profile_wred,
1313 (void *)&cmd_del_port_tm_node_wred_profile_profile,
1314 (void *)&cmd_del_port_tm_node_wred_profile_port_id,
1315 (void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id,
1320 /* *** Update Port TM Node Shaper profile *** */
1321 struct cmd_set_port_tm_node_shaper_profile_result {
1322 cmdline_fixed_string_t set;
1323 cmdline_fixed_string_t port;
1324 cmdline_fixed_string_t tm;
1325 cmdline_fixed_string_t node;
1326 cmdline_fixed_string_t shaper;
1327 cmdline_fixed_string_t profile;
1330 uint32_t shaper_profile_id;
1333 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set =
1334 TOKEN_STRING_INITIALIZER(
1335 struct cmd_set_port_tm_node_shaper_profile_result, set, "set");
1336 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port =
1337 TOKEN_STRING_INITIALIZER(
1338 struct cmd_set_port_tm_node_shaper_profile_result,
1340 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_tm =
1341 TOKEN_STRING_INITIALIZER(
1342 struct cmd_set_port_tm_node_shaper_profile_result, tm, "tm");
1343 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node =
1344 TOKEN_STRING_INITIALIZER(
1345 struct cmd_set_port_tm_node_shaper_profile_result,
1347 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper =
1348 TOKEN_STRING_INITIALIZER(
1349 struct cmd_set_port_tm_node_shaper_profile_result,
1351 cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile =
1352 TOKEN_STRING_INITIALIZER(
1353 struct cmd_set_port_tm_node_shaper_profile_result,
1354 profile, "profile");
1355 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id =
1356 TOKEN_NUM_INITIALIZER(
1357 struct cmd_set_port_tm_node_shaper_profile_result,
1359 cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id =
1360 TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result,
1362 cmdline_parse_token_num_t
1363 cmd_set_port_tm_node_shaper_shaper_profile_profile_id =
1364 TOKEN_NUM_INITIALIZER(
1365 struct cmd_set_port_tm_node_shaper_profile_result,
1366 shaper_profile_id, UINT32);
1368 static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result,
1369 __attribute__((unused)) struct cmdline *cl,
1370 __attribute__((unused)) void *data)
1372 struct cmd_set_port_tm_node_shaper_profile_result *res = parsed_result;
1373 struct rte_tm_error error;
1374 uint32_t node_id = res->node_id;
1375 uint32_t shaper_profile_id = res->shaper_profile_id;
1376 portid_t port_id = res->port_id;
1379 if (port_id_is_invalid(port_id, ENABLED_WARN))
1383 if (!port_is_started(port_id)) {
1384 printf(" Port %u not started (error)\n", port_id);
1388 ret = rte_tm_node_shaper_update(port_id, node_id,
1389 shaper_profile_id, &error);
1391 print_err_msg(&error);
1396 cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile = {
1397 .f = cmd_set_port_tm_node_shaper_profile_parsed,
1399 .help_str = "Set port tm node shaper profile",
1401 (void *)&cmd_set_port_tm_node_shaper_profile_set,
1402 (void *)&cmd_set_port_tm_node_shaper_profile_port,
1403 (void *)&cmd_set_port_tm_node_shaper_profile_tm,
1404 (void *)&cmd_set_port_tm_node_shaper_profile_node,
1405 (void *)&cmd_set_port_tm_node_shaper_profile_shaper,
1406 (void *)&cmd_set_port_tm_node_shaper_profile_profile,
1407 (void *)&cmd_set_port_tm_node_shaper_profile_port_id,
1408 (void *)&cmd_set_port_tm_node_shaper_profile_node_id,
1409 (void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id,