app/testpmd: add commands for shaper and wred profiles
[dpdk.git] / app / test-pmd / cmdline_tm.c
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
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
16  *       distribution.
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.
20  *
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.
32  */
33
34 #include <cmdline_parse.h>
35 #include <cmdline_parse_num.h>
36 #include <cmdline_parse_string.h>
37
38 #include <rte_ethdev.h>
39 #include <rte_flow.h>
40 #include <rte_tm.h>
41
42 #include "testpmd.h"
43 #include "cmdline_tm.h"
44
45 /** Display TM Error Message */
46 static void
47 print_err_msg(struct rte_tm_error *error)
48 {
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",
102         };
103
104         const char *errstr;
105         char buf[64];
106
107         if ((unsigned int)error->type >= RTE_DIM(errstrlist) ||
108                 !errstrlist[error->type])
109                 errstr = "unknown type";
110         else
111                 errstr = errstrlist[error->type];
112
113         if (error->cause)
114                 snprintf(buf, sizeof(buf), "cause: %p, ", error->cause);
115
116         printf("%s: %s%s (error %d)\n", errstr, error->cause ? buf : "",
117                 error->message ? error->message : "(no stated reason)",
118                 error->type);
119 }
120
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;
127         uint16_t port_id;
128 };
129
130 cmdline_parse_token_string_t cmd_show_port_tm_cap_show =
131         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
132                 show, "show");
133 cmdline_parse_token_string_t cmd_show_port_tm_cap_port =
134         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
135                 port, "port");
136 cmdline_parse_token_string_t cmd_show_port_tm_cap_tm =
137         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
138                 tm, "tm");
139 cmdline_parse_token_string_t cmd_show_port_tm_cap_cap =
140         TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
141                 cap, "cap");
142 cmdline_parse_token_num_t cmd_show_port_tm_cap_port_id =
143         TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_cap_result,
144                  port_id, UINT16);
145
146 static void cmd_show_port_tm_cap_parsed(void *parsed_result,
147         __attribute__((unused)) struct cmdline *cl,
148         __attribute__((unused)) void *data)
149 {
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;
154         uint32_t i;
155         int ret;
156
157         if (port_id_is_invalid(port_id, ENABLED_WARN))
158                 return;
159
160         memset(&cap, 0, sizeof(struct rte_tm_capabilities));
161         ret = rte_tm_capabilities_get(port_id, &cap, &error);
162         if (ret) {
163                 print_err_msg(&error);
164                 return;
165         }
166
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);
221
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]);
231         }
232
233         printf("cap.dynamic_update_mask %" PRIx64 "\n",
234                 cap.dynamic_update_mask);
235         printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
236 }
237
238 cmdline_parse_inst_t cmd_show_port_tm_cap = {
239         .f = cmd_show_port_tm_cap_parsed,
240         .data = NULL,
241         .help_str = "Show Port TM Capabilities",
242         .tokens = {
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,
248                 NULL,
249         },
250 };
251
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;
259         uint16_t port_id;
260         uint32_t level_id;
261 };
262
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,
265                 show, "show");
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,
268                 port, "port");
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,
271                 tm, "tm");
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,
274                 level, "level");
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,
277                 cap, "cap");
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,
280                  port_id, UINT16);
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,
283                  level_id, UINT32);
284
285
286 static void cmd_show_port_tm_level_cap_parsed(void *parsed_result,
287         __attribute__((unused)) struct cmdline *cl,
288         __attribute__((unused)) void *data)
289 {
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;
295         int ret;
296
297         if (port_id_is_invalid(port_id, ENABLED_WARN))
298                 return;
299
300         memset(&lcap, 0, sizeof(struct rte_tm_level_capabilities));
301         ret = rte_tm_level_capabilities_get(port_id, level_id, &lcap, &error);
302         if (ret) {
303                 print_err_msg(&error);
304                 return;
305         }
306         printf("\n**   Port TM Hierarchy level %" PRIu32 " Capability **\n\n",
307                 level_id);
308
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);
317         if (level_id <= 3) {
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);
340         } else {
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);
359         }
360 }
361
362 cmdline_parse_inst_t cmd_show_port_tm_level_cap = {
363         .f = cmd_show_port_tm_level_cap_parsed,
364         .data = NULL,
365         .help_str = "Show Port TM Hierarhical level Capabilities",
366         .tokens = {
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,
374                 NULL,
375         },
376 };
377
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;
385         uint16_t port_id;
386         uint32_t node_id;
387 };
388
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,
391                 show, "show");
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,
394                 port, "port");
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,
397                 tm, "tm");
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,
400                 node, "node");
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,
403                 cap, "cap");
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,
406                  port_id, UINT16);
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,
409                  node_id, UINT32);
410
411 static void cmd_show_port_tm_node_cap_parsed(void *parsed_result,
412         __attribute__((unused)) struct cmdline *cl,
413         __attribute__((unused)) void *data)
414 {
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;
421
422         if (port_id_is_invalid(port_id, ENABLED_WARN))
423                 return;
424
425         /* Node id must be valid */
426         ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
427         if (ret != 0) {
428                 print_err_msg(&error);
429                 return;
430         }
431
432         memset(&ncap, 0, sizeof(struct rte_tm_node_capabilities));
433         ret = rte_tm_node_capabilities_get(port_id, node_id, &ncap, &error);
434         if (ret != 0) {
435                 print_err_msg(&error);
436                 return;
437         }
438         printf("\n**   Port TM Hierarchy node %" PRIu32 " Capability **\n\n",
439                 node_id);
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);
450         if (!is_leaf) {
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);
461         } else {
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);
468         }
469         printf("cap.stats_mask %" PRIx64 "\n", ncap.stats_mask);
470 }
471
472 cmdline_parse_inst_t cmd_show_port_tm_node_cap = {
473         .f = cmd_show_port_tm_node_cap_parsed,
474         .data = NULL,
475         .help_str = "Show Port TM Hierarchy node capabilities",
476         .tokens = {
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,
484                 NULL,
485         },
486 };
487
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;
495         uint16_t port_id;
496         uint32_t node_id;
497         uint32_t clear;
498 };
499
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,
517                         port_id, UINT16);
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,
521                         node_id, UINT32);
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);
525
526 static void cmd_show_port_tm_node_stats_parsed(void *parsed_result,
527         __attribute__((unused)) struct cmdline *cl,
528         __attribute__((unused)) void *data)
529 {
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;
537         int ret;
538
539         if (port_id_is_invalid(port_id, ENABLED_WARN))
540                 return;
541
542         /* Port status */
543         if (!port_is_started(port_id)) {
544                 printf(" Port %u not started (error)\n", port_id);
545                 return;
546         }
547
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);
551         if (ret != 0) {
552                 print_err_msg(&error);
553                 return;
554         }
555
556         /* Display stats */
557         if (stats_mask & RTE_TM_STATS_N_PKTS)
558                 printf("\tPkts scheduled from node: %" PRIu64 "\n",
559                         stats.n_pkts);
560         if (stats_mask & RTE_TM_STATS_N_BYTES)
561                 printf("\tBytes scheduled from node: %" PRIu64 "\n",
562                         stats.n_bytes);
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);
587 }
588
589 cmdline_parse_inst_t cmd_show_port_tm_node_stats = {
590         .f = cmd_show_port_tm_node_stats_parsed,
591         .data = NULL,
592         .help_str = "Show port tm node stats",
593         .tokens = {
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,
602                 NULL,
603         },
604 };
605
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;
613         uint16_t port_id;
614         uint32_t node_id;
615 };
616
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,
635                         port_id, UINT16);
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,
639                         node_id, UINT32);
640
641 static void cmd_show_port_tm_node_type_parsed(void *parsed_result,
642         __attribute__((unused)) struct cmdline *cl,
643         __attribute__((unused)) void *data)
644 {
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;
650
651         if (port_id_is_invalid(port_id, ENABLED_WARN))
652                 return;
653
654         ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
655         if (ret != 0) {
656                 print_err_msg(&error);
657                 return;
658         }
659
660         if (is_leaf == 1)
661                 printf("leaf node\n");
662         else
663                 printf("nonleaf node\n");
664
665 }
666
667 cmdline_parse_inst_t cmd_show_port_tm_node_type = {
668         .f = cmd_show_port_tm_node_type_parsed,
669         .data = NULL,
670         .help_str = "Show port tm node type",
671         .tokens = {
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,
679                 NULL,
680         },
681 };
682
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;
691         uint16_t port_id;
692         uint32_t shaper_id;
693         uint64_t tb_rate;
694         uint64_t tb_size;
695         uint32_t pktlen_adjust;
696 };
697
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,
704                         port, "port");
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,
708                         tm, "tm");
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,
712                         node, "node");
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,
716                         shaper, "shaper");
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,
720                         profile, "profile");
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,
724                         port_id, UINT16);
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,
728                         shaper_id, UINT32);
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,
732                         tb_rate, UINT64);
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,
736                         tb_size, UINT64);
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);
741
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)
745 {
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;
752         int ret;
753
754         if (port_id_is_invalid(port_id, ENABLED_WARN))
755                 return;
756
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;
762
763         ret = rte_tm_shaper_profile_add(port_id, shaper_id, &sp, &error);
764         if (ret != 0) {
765                 print_err_msg(&error);
766                 return;
767         }
768 }
769
770 cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile = {
771         .f = cmd_add_port_tm_node_shaper_profile_parsed,
772         .data = NULL,
773         .help_str = "Add port tm node private shaper profile",
774         .tokens = {
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,
786                 NULL,
787         },
788 };
789
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;
798         uint16_t port_id;
799         uint32_t shaper_id;
800 };
801
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,
808                         port, "port");
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,
815                         node, "node");
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,
819                         shaper, "shaper");
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,
823                         profile, "profile");
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,
827                         port_id, UINT16);
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,
831                         shaper_id, UINT32);
832
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)
836 {
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;
841         int ret;
842
843         if (port_id_is_invalid(port_id, ENABLED_WARN))
844                 return;
845
846         ret = rte_tm_shaper_profile_delete(port_id, shaper_id, &error);
847         if (ret != 0) {
848                 print_err_msg(&error);
849                 return;
850         }
851 }
852
853 cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile = {
854         .f = cmd_del_port_tm_node_shaper_profile_parsed,
855         .data = NULL,
856         .help_str = "Delete port tm node private shaper profile",
857         .tokens = {
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,
866                 NULL,
867         },
868 };
869
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;
878         uint16_t port_id;
879         uint32_t shared_shaper_id;
880         uint32_t shaper_profile_id;
881 };
882
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,
899                         shared, "shared");
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,
903                         shaper, "shaper");
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,
907                         port_id, UINT16);
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);
916
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)
920 {
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;
926         int ret;
927
928         if (port_id_is_invalid(port_id, ENABLED_WARN))
929                 return;
930
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);
935                 return;
936         }
937
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);
942                 return;
943         }
944
945         ret = rte_tm_shared_shaper_add_update(port_id, shared_shaper_id,
946                 shaper_profile_id, &error);
947         if (ret != 0) {
948                 print_err_msg(&error);
949                 return;
950         }
951 }
952
953 cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper = {
954         .f = cmd_add_port_tm_node_shared_shaper_parsed,
955         .data = NULL,
956         .help_str = "add/update port tm node shared shaper",
957         .tokens = {
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,
967                 NULL,
968         },
969 };
970
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;
979         uint16_t port_id;
980         uint32_t shared_shaper_id;
981 };
982
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,
998                         shared, "shared");
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,
1002                         shaper, "shaper");
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,
1006                         port_id, UINT16);
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);
1011
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)
1015 {
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;
1020         int ret;
1021
1022         if (port_id_is_invalid(port_id, ENABLED_WARN))
1023                 return;
1024
1025         ret = rte_tm_shared_shaper_delete(port_id, shared_shaper_id, &error);
1026         if (ret != 0) {
1027                 print_err_msg(&error);
1028                 return;
1029         }
1030 }
1031
1032 cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper = {
1033         .f = cmd_del_port_tm_node_shared_shaper_parsed,
1034         .data = NULL,
1035         .help_str = "delete port tm node shared shaper",
1036         .tokens = {
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,
1045                 NULL,
1046         },
1047 };
1048
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;
1057         uint16_t port_id;
1058         uint32_t wred_profile_id;
1059         cmdline_fixed_string_t color_g;
1060         uint16_t min_th_g;
1061         uint16_t max_th_g;
1062         uint16_t maxp_inv_g;
1063         uint16_t wq_log2_g;
1064         cmdline_fixed_string_t color_y;
1065         uint16_t min_th_y;
1066         uint16_t max_th_y;
1067         uint16_t maxp_inv_y;
1068         uint16_t wq_log2_y;
1069         cmdline_fixed_string_t color_r;
1070         uint16_t min_th_r;
1071         uint16_t max_th_r;
1072         uint16_t maxp_inv_r;
1073         uint16_t wq_log2_r;
1074 };
1075
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,
1098                         port_id, UINT16);
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,
1106                         color_g, "G#g");
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,
1110                         min_th_g, UINT16);
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,
1114                         max_th_g, UINT16);
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,
1122                         wq_log2_g, UINT16);
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,
1126                         color_y, "Y#y");
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,
1130                         min_th_y, UINT16);
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,
1134                         max_th_y, UINT16);
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,
1142                         wq_log2_y, UINT16);
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,
1146                         color_r, "R#r");
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,
1150                         min_th_r, UINT16);
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,
1154                         max_th_r, UINT16);
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,
1162                         wq_log2_r, UINT16);
1163
1164
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)
1168 {
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;
1175         int ret;
1176
1177         if (port_id_is_invalid(port_id, ENABLED_WARN))
1178                 return;
1179
1180         memset(&wp, 0, sizeof(struct rte_tm_wred_params));
1181
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;
1188
1189
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;
1196
1197         /* WRED Params  (Red Color)*/
1198         color = RTE_TM_RED;
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;
1203
1204         ret = rte_tm_wred_profile_add(port_id, wred_profile_id, &wp, &error);
1205         if (ret != 0) {
1206                 print_err_msg(&error);
1207                 return;
1208         }
1209 }
1210
1211 cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile = {
1212         .f = cmd_add_port_tm_node_wred_profile_parsed,
1213         .data = NULL,
1214         .help_str = "Add port tm node wred profile",
1215         .tokens = {
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,
1239                 NULL,
1240         },
1241 };
1242
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;
1251         uint16_t port_id;
1252         uint32_t wred_profile_id;
1253 };
1254
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,
1277                         port_id, UINT16);
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);
1282
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)
1286 {
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;
1291         int ret;
1292
1293         if (port_id_is_invalid(port_id, ENABLED_WARN))
1294                 return;
1295
1296         ret = rte_tm_wred_profile_delete(port_id, wred_profile_id, &error);
1297         if (ret != 0) {
1298                 print_err_msg(&error);
1299                 return;
1300         }
1301 }
1302
1303 cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile = {
1304         .f = cmd_del_port_tm_node_wred_profile_parsed,
1305         .data = NULL,
1306         .help_str = "Delete port tm node wred profile",
1307         .tokens = {
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,
1316                 NULL,
1317         },
1318 };
1319
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;
1328         uint16_t port_id;
1329         uint32_t node_id;
1330         uint32_t shaper_profile_id;
1331 };
1332
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,
1339                         port, "port");
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,
1346                         node, "node");
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,
1350                         shaper, "shaper");
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,
1358                         port_id, UINT16);
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,
1361                 node_id, UINT32);
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);
1367
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)
1371 {
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;
1377         int ret;
1378
1379         if (port_id_is_invalid(port_id, ENABLED_WARN))
1380                 return;
1381
1382         /* Port status */
1383         if (!port_is_started(port_id)) {
1384                 printf(" Port %u not started (error)\n", port_id);
1385                 return;
1386         }
1387
1388         ret = rte_tm_node_shaper_update(port_id, node_id,
1389                 shaper_profile_id, &error);
1390         if (ret != 0) {
1391                 print_err_msg(&error);
1392                 return;
1393         }
1394 }
1395
1396 cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile = {
1397         .f = cmd_set_port_tm_node_shaper_profile_parsed,
1398         .data = NULL,
1399         .help_str = "Set port tm node shaper profile",
1400         .tokens = {
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,
1410                 NULL,
1411         },
1412 };