xref: /dpdk/app/test-pmd/cmdline_tm.c (revision 25a2a0dc3de31ca0a6fbc9371cf3dd85dfd74b07)
1174a1631SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2174a1631SBruce Richardson  * Copyright(c) 2017 Intel Corporation
3c6af0842SJasvinder Singh  */
4c6af0842SJasvinder Singh 
572b452c5SDmitry Kozlyuk #include <ctype.h>
61bcb7ba9SDavid Marchand #include <stdlib.h>
772b452c5SDmitry Kozlyuk 
8c6af0842SJasvinder Singh #include <cmdline_parse.h>
9c6af0842SJasvinder Singh #include <cmdline_parse_num.h>
10c6af0842SJasvinder Singh #include <cmdline_parse_string.h>
11c6af0842SJasvinder Singh 
12c6af0842SJasvinder Singh #include <rte_ethdev.h>
13c6af0842SJasvinder Singh #include <rte_flow.h>
142df20a1dSDavid Marchand #include <rte_string_fns.h>
15c6af0842SJasvinder Singh #include <rte_tm.h>
16c6af0842SJasvinder Singh 
17c6af0842SJasvinder Singh #include "testpmd.h"
18c6af0842SJasvinder Singh #include "cmdline_tm.h"
19c6af0842SJasvinder Singh 
20996cb153SJasvinder Singh #define PARSE_DELIMITER				" \f\n\r\t\v"
21996cb153SJasvinder Singh #define MAX_NUM_SHARED_SHAPERS		256
22996cb153SJasvinder Singh 
23c6af0842SJasvinder Singh /** Display TM Error Message */
24c6af0842SJasvinder Singh static void
25c6af0842SJasvinder Singh print_err_msg(struct rte_tm_error *error)
26c6af0842SJasvinder Singh {
27c6af0842SJasvinder Singh 	static const char *const errstrlist[] = {
28c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NONE] = "no error",
29c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_UNSPECIFIED] = "cause unspecified",
30c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_CAPABILITIES]
31c6af0842SJasvinder Singh 			= "capability parameter null",
32c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_LEVEL_ID] = "level id",
33c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_WRED_PROFILE]
34c6af0842SJasvinder Singh 			= "wred profile null",
35c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN] = "wred profile(green)",
36c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW]
37c6af0842SJasvinder Singh 			= "wred profile(yellow)",
38c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_WRED_PROFILE_RED] = "wred profile(red)",
39c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_WRED_PROFILE_ID] = "wred profile id",
40c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID]
41c6af0842SJasvinder Singh 			= "shared wred context id",
42c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_SHAPER_PROFILE] = "shaper profile null",
43c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE]
44c6af0842SJasvinder Singh 			= "committed rate field (shaper profile)",
45c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE]
46c6af0842SJasvinder Singh 			= "committed size field (shaper profile)",
47c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE]
48c6af0842SJasvinder Singh 			= "peak rate field (shaper profile)",
49c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE]
50c6af0842SJasvinder Singh 			= "peak size field (shaper profile)",
51c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN]
52c6af0842SJasvinder Singh 			= "packet adjust length field (shaper profile)",
53bb52561eSNithin Dabilpuram 		[RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PACKET_MODE]
54bb52561eSNithin Dabilpuram 			= "packet mode field (shaper profile)",
55c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID] = "shaper profile id",
56c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID] = "shared shaper id",
57c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID] = "parent node id",
58c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PRIORITY] = "node priority",
59c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_WEIGHT] = "node weight",
60c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS] = "node parameter null",
61c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID]
62c6af0842SJasvinder Singh 			= "shaper profile id field (node params)",
63c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID]
64c6af0842SJasvinder Singh 			= "shared shaper id field (node params)",
65c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS]
66c6af0842SJasvinder Singh 			= "num shared shapers field (node params)",
67c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE]
687be78d02SJosh Soref 			= "wfq weight mode field (node params)",
69c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES]
70c6af0842SJasvinder Singh 			= "num strict priorities field (node params)",
71c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN]
72c6af0842SJasvinder Singh 			= "congestion management mode field (node params)",
73c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID] =
74c6af0842SJasvinder Singh 			"wred profile id field (node params)",
75c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID]
76c6af0842SJasvinder Singh 			= "shared wred context id field (node params)",
77c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS]
78c6af0842SJasvinder Singh 			= "num shared wred contexts field (node params)",
79c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS]
80c6af0842SJasvinder Singh 			= "stats field (node params)",
81c6af0842SJasvinder Singh 		[RTE_TM_ERROR_TYPE_NODE_ID] = "node id",
82c6af0842SJasvinder Singh 	};
83c6af0842SJasvinder Singh 
84c6af0842SJasvinder Singh 	const char *errstr;
85c6af0842SJasvinder Singh 	char buf[64];
86c6af0842SJasvinder Singh 
87c6af0842SJasvinder Singh 	if ((unsigned int)error->type >= RTE_DIM(errstrlist) ||
88c6af0842SJasvinder Singh 		!errstrlist[error->type])
89c6af0842SJasvinder Singh 		errstr = "unknown type";
90c6af0842SJasvinder Singh 	else
91c6af0842SJasvinder Singh 		errstr = errstrlist[error->type];
92c6af0842SJasvinder Singh 
93c6af0842SJasvinder Singh 	if (error->cause)
94c6af0842SJasvinder Singh 		snprintf(buf, sizeof(buf), "cause: %p, ", error->cause);
95c6af0842SJasvinder Singh 
9661a3b0e5SAndrew Rybchenko 	fprintf(stderr, "%s: %s%s (error %d)\n",
9761a3b0e5SAndrew Rybchenko 		errstr, error->cause ? buf : "",
98c6af0842SJasvinder Singh 		error->message ? error->message : "(no stated reason)",
99c6af0842SJasvinder Singh 		error->type);
100c6af0842SJasvinder Singh }
101c6af0842SJasvinder Singh 
102996cb153SJasvinder Singh static int
103996cb153SJasvinder Singh read_uint64(uint64_t *value, const char *p)
104996cb153SJasvinder Singh {
105996cb153SJasvinder Singh 	char *next;
106996cb153SJasvinder Singh 	uint64_t val;
107996cb153SJasvinder Singh 
1082df20a1dSDavid Marchand 	p = rte_str_skip_leading_spaces(p);
109996cb153SJasvinder Singh 	if (!isdigit(*p))
110996cb153SJasvinder Singh 		return -EINVAL;
111996cb153SJasvinder Singh 
112996cb153SJasvinder Singh 	val = strtoul(p, &next, 10);
113996cb153SJasvinder Singh 	if (p == next)
114996cb153SJasvinder Singh 		return -EINVAL;
115996cb153SJasvinder Singh 
116996cb153SJasvinder Singh 	p = next;
117996cb153SJasvinder Singh 	switch (*p) {
118996cb153SJasvinder Singh 	case 'T':
119996cb153SJasvinder Singh 		val *= 1024ULL;
120996cb153SJasvinder Singh 		/* fall through */
121996cb153SJasvinder Singh 	case 'G':
122996cb153SJasvinder Singh 		val *= 1024ULL;
123996cb153SJasvinder Singh 		/* fall through */
124996cb153SJasvinder Singh 	case 'M':
125996cb153SJasvinder Singh 		val *= 1024ULL;
126996cb153SJasvinder Singh 		/* fall through */
127996cb153SJasvinder Singh 	case 'k':
128996cb153SJasvinder Singh 	case 'K':
129996cb153SJasvinder Singh 		val *= 1024ULL;
130996cb153SJasvinder Singh 		p++;
131996cb153SJasvinder Singh 		break;
132996cb153SJasvinder Singh 	}
133996cb153SJasvinder Singh 
1342df20a1dSDavid Marchand 	p = rte_str_skip_leading_spaces(p);
135996cb153SJasvinder Singh 	if (*p != '\0')
136996cb153SJasvinder Singh 		return -EINVAL;
137996cb153SJasvinder Singh 
138996cb153SJasvinder Singh 	*value = val;
139996cb153SJasvinder Singh 	return 0;
140996cb153SJasvinder Singh }
141996cb153SJasvinder Singh 
142996cb153SJasvinder Singh static int
143996cb153SJasvinder Singh read_uint32(uint32_t *value, const char *p)
144996cb153SJasvinder Singh {
145996cb153SJasvinder Singh 	uint64_t val = 0;
146996cb153SJasvinder Singh 	int ret = read_uint64(&val, p);
147996cb153SJasvinder Singh 
148996cb153SJasvinder Singh 	if (ret < 0)
149996cb153SJasvinder Singh 		return ret;
150996cb153SJasvinder Singh 
151996cb153SJasvinder Singh 	if (val > UINT32_MAX)
152996cb153SJasvinder Singh 		return -ERANGE;
153996cb153SJasvinder Singh 
154996cb153SJasvinder Singh 	*value = val;
155996cb153SJasvinder Singh 	return 0;
156996cb153SJasvinder Singh }
157996cb153SJasvinder Singh 
158996cb153SJasvinder Singh static int
159996cb153SJasvinder Singh parse_multi_ss_id_str(char *s_str, uint32_t *n_ssp, uint32_t shaper_id[])
160996cb153SJasvinder Singh {
161996cb153SJasvinder Singh 	uint32_t n_shared_shapers = 0, i = 0;
162996cb153SJasvinder Singh 	char *token;
163996cb153SJasvinder Singh 
164996cb153SJasvinder Singh 	/* First token: num of shared shapers */
165996cb153SJasvinder Singh 	token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
166996cb153SJasvinder Singh 	if (token ==  NULL)
167996cb153SJasvinder Singh 		return -1;
168996cb153SJasvinder Singh 
169996cb153SJasvinder Singh 	if (read_uint32(&n_shared_shapers, token))
170996cb153SJasvinder Singh 		return -1;
171996cb153SJasvinder Singh 
172996cb153SJasvinder Singh 	/* Check: num of shared shaper */
173996cb153SJasvinder Singh 	if (n_shared_shapers >= MAX_NUM_SHARED_SHAPERS) {
17461a3b0e5SAndrew Rybchenko 		fprintf(stderr,
17561a3b0e5SAndrew Rybchenko 			" Number of shared shapers exceed the max (error)\n");
176996cb153SJasvinder Singh 		return -1;
177996cb153SJasvinder Singh 	}
178996cb153SJasvinder Singh 
179996cb153SJasvinder Singh 	/* Parse shared shaper ids */
180996cb153SJasvinder Singh 	while (1) {
181996cb153SJasvinder Singh 		token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
182996cb153SJasvinder Singh 		if ((token !=  NULL && n_shared_shapers == 0) ||
183996cb153SJasvinder Singh 			(token == NULL && i < n_shared_shapers))
184996cb153SJasvinder Singh 			return -1;
185996cb153SJasvinder Singh 
186996cb153SJasvinder Singh 		if (token == NULL)
187996cb153SJasvinder Singh 			break;
188996cb153SJasvinder Singh 
189996cb153SJasvinder Singh 		if (read_uint32(&shaper_id[i], token))
190996cb153SJasvinder Singh 			return -1;
191996cb153SJasvinder Singh 		i++;
192996cb153SJasvinder Singh 	}
193996cb153SJasvinder Singh 	*n_ssp = n_shared_shapers;
194996cb153SJasvinder Singh 
195996cb153SJasvinder Singh 	return 0;
196996cb153SJasvinder Singh }
197c6af0842SJasvinder Singh /* *** Port TM Capability *** */
198c6af0842SJasvinder Singh struct cmd_show_port_tm_cap_result {
199c6af0842SJasvinder Singh 	cmdline_fixed_string_t show;
200c6af0842SJasvinder Singh 	cmdline_fixed_string_t port;
201c6af0842SJasvinder Singh 	cmdline_fixed_string_t tm;
202c6af0842SJasvinder Singh 	cmdline_fixed_string_t cap;
203c6af0842SJasvinder Singh 	uint16_t port_id;
204c6af0842SJasvinder Singh };
205c6af0842SJasvinder Singh 
206ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_cap_show =
207c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
208c6af0842SJasvinder Singh 		show, "show");
209ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_cap_port =
210c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
211c6af0842SJasvinder Singh 		port, "port");
212ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_cap_tm =
213c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
214c6af0842SJasvinder Singh 		tm, "tm");
215ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_cap_cap =
216c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
217c6af0842SJasvinder Singh 		cap, "cap");
218ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_show_port_tm_cap_port_id =
219c6af0842SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_cap_result,
220c2341bb6SDmitry Kozlyuk 		 port_id, RTE_UINT16);
221c6af0842SJasvinder Singh 
222c6af0842SJasvinder Singh static void cmd_show_port_tm_cap_parsed(void *parsed_result,
223f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
224f2fc83b4SThomas Monjalon 	__rte_unused void *data)
225c6af0842SJasvinder Singh {
226c6af0842SJasvinder Singh 	struct cmd_show_port_tm_cap_result *res = parsed_result;
227c6af0842SJasvinder Singh 	struct rte_tm_capabilities cap;
228c6af0842SJasvinder Singh 	struct rte_tm_error error;
229c6af0842SJasvinder Singh 	portid_t port_id = res->port_id;
230c6af0842SJasvinder Singh 	uint32_t i;
231c6af0842SJasvinder Singh 	int ret;
232c6af0842SJasvinder Singh 
233c6af0842SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
234c6af0842SJasvinder Singh 		return;
235c6af0842SJasvinder Singh 
236c6af0842SJasvinder Singh 	memset(&cap, 0, sizeof(struct rte_tm_capabilities));
237a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
238c6af0842SJasvinder Singh 	ret = rte_tm_capabilities_get(port_id, &cap, &error);
239c6af0842SJasvinder Singh 	if (ret) {
240c6af0842SJasvinder Singh 		print_err_msg(&error);
241c6af0842SJasvinder Singh 		return;
242c6af0842SJasvinder Singh 	}
243c6af0842SJasvinder Singh 
244c6af0842SJasvinder Singh 	printf("\n****   Port TM Capabilities ****\n\n");
245c6af0842SJasvinder Singh 	printf("cap.n_nodes_max %" PRIu32 "\n", cap.n_nodes_max);
246c6af0842SJasvinder Singh 	printf("cap.n_levels_max %" PRIu32 "\n", cap.n_levels_max);
247c6af0842SJasvinder Singh 	printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
248c6af0842SJasvinder Singh 		cap.non_leaf_nodes_identical);
249c6af0842SJasvinder Singh 	printf("cap.leaf_nodes_identical %" PRId32 "\n",
250c6af0842SJasvinder Singh 		cap.leaf_nodes_identical);
251c6af0842SJasvinder Singh 	printf("cap.shaper_n_max %u\n", cap.shaper_n_max);
252c6af0842SJasvinder Singh 	printf("cap.shaper_private_n_max %" PRIu32 "\n",
253c6af0842SJasvinder Singh 		cap.shaper_private_n_max);
254c6af0842SJasvinder Singh 	printf("cap.shaper_private_dual_rate_n_max %" PRId32 "\n",
255c6af0842SJasvinder Singh 		cap.shaper_private_dual_rate_n_max);
256c6af0842SJasvinder Singh 	printf("cap.shaper_private_rate_min %" PRIu64 "\n",
257c6af0842SJasvinder Singh 		cap.shaper_private_rate_min);
258c6af0842SJasvinder Singh 	printf("cap.shaper_private_rate_max %" PRIu64 "\n",
259c6af0842SJasvinder Singh 		cap.shaper_private_rate_max);
260bb52561eSNithin Dabilpuram 	printf("cap.shaper_private_packet_mode_supported %" PRId32 "\n",
261bb52561eSNithin Dabilpuram 		cap.shaper_private_packet_mode_supported);
262bb52561eSNithin Dabilpuram 	printf("cap.shaper_private_byte_mode_supported %" PRId32 "\n",
263bb52561eSNithin Dabilpuram 		cap.shaper_private_byte_mode_supported);
264c6af0842SJasvinder Singh 	printf("cap.shaper_shared_n_max %" PRIu32 "\n",
265c6af0842SJasvinder Singh 		cap.shaper_shared_n_max);
266c6af0842SJasvinder Singh 	printf("cap.shaper_shared_n_nodes_per_shaper_max %" PRIu32 "\n",
267c6af0842SJasvinder Singh 		cap.shaper_shared_n_nodes_per_shaper_max);
268c6af0842SJasvinder Singh 	printf("cap.shaper_shared_n_shapers_per_node_max %" PRIu32 "\n",
269c6af0842SJasvinder Singh 		cap.shaper_shared_n_shapers_per_node_max);
270c6af0842SJasvinder Singh 	printf("cap.shaper_shared_dual_rate_n_max %" PRIu32 "\n",
271c6af0842SJasvinder Singh 		cap.shaper_shared_dual_rate_n_max);
272c6af0842SJasvinder Singh 	printf("cap.shaper_shared_rate_min %" PRIu64 "\n",
273c6af0842SJasvinder Singh 		cap.shaper_shared_rate_min);
274c6af0842SJasvinder Singh 	printf("cap.shaper_shared_rate_max %" PRIu64 "\n",
275c6af0842SJasvinder Singh 		cap.shaper_shared_rate_max);
276bb52561eSNithin Dabilpuram 	printf("cap.shaper_shared_packet_mode_supported %" PRId32 "\n",
277bb52561eSNithin Dabilpuram 		cap.shaper_shared_packet_mode_supported);
278bb52561eSNithin Dabilpuram 	printf("cap.shaper_shared_byte_mode_supported %" PRId32 "\n",
279bb52561eSNithin Dabilpuram 		cap.shaper_shared_byte_mode_supported);
280c6af0842SJasvinder Singh 	printf("cap.shaper_pkt_length_adjust_min %" PRId32 "\n",
281c6af0842SJasvinder Singh 		cap.shaper_pkt_length_adjust_min);
282c6af0842SJasvinder Singh 	printf("cap.shaper_pkt_length_adjust_max %" PRId32 "\n",
283c6af0842SJasvinder Singh 		cap.shaper_pkt_length_adjust_max);
284c6af0842SJasvinder Singh 	printf("cap.sched_n_children_max %" PRIu32 "\n",
285c6af0842SJasvinder Singh 		cap.sched_n_children_max);
286c6af0842SJasvinder Singh 	printf("cap.sched_sp_n_priorities_max %" PRIu32 "\n",
287c6af0842SJasvinder Singh 		cap.sched_sp_n_priorities_max);
288c6af0842SJasvinder Singh 	printf("cap.sched_wfq_n_children_per_group_max %" PRIu32 "\n",
289c6af0842SJasvinder Singh 		cap.sched_wfq_n_children_per_group_max);
290c6af0842SJasvinder Singh 	printf("cap.sched_wfq_n_groups_max %" PRIu32 "\n",
291c6af0842SJasvinder Singh 		cap.sched_wfq_n_groups_max);
292c6af0842SJasvinder Singh 	printf("cap.sched_wfq_weight_max %" PRIu32 "\n",
293c6af0842SJasvinder Singh 		cap.sched_wfq_weight_max);
294bb52561eSNithin Dabilpuram 	printf("cap.sched_wfq_packet_mode_supported %" PRId32 "\n",
295bb52561eSNithin Dabilpuram 		cap.sched_wfq_packet_mode_supported);
296bb52561eSNithin Dabilpuram 	printf("cap.sched_wfq_byte_mode_supported %" PRId32 "\n",
297bb52561eSNithin Dabilpuram 		cap.sched_wfq_byte_mode_supported);
298c6af0842SJasvinder Singh 	printf("cap.cman_head_drop_supported %" PRId32 "\n",
299c6af0842SJasvinder Singh 		cap.cman_head_drop_supported);
300c6af0842SJasvinder Singh 	printf("cap.cman_wred_context_n_max %" PRIu32 "\n",
301c6af0842SJasvinder Singh 		cap.cman_wred_context_n_max);
302c6af0842SJasvinder Singh 	printf("cap.cman_wred_context_private_n_max %" PRIu32 "\n",
303c6af0842SJasvinder Singh 		cap.cman_wred_context_private_n_max);
304c6af0842SJasvinder Singh 	printf("cap.cman_wred_context_shared_n_max %" PRIu32 "\n",
305c6af0842SJasvinder Singh 		cap.cman_wred_context_shared_n_max);
306c6af0842SJasvinder Singh 	printf("cap.cman_wred_context_shared_n_nodes_per_context_max %" PRIu32
307c6af0842SJasvinder Singh 		"\n", cap.cman_wred_context_shared_n_nodes_per_context_max);
308c6af0842SJasvinder Singh 	printf("cap.cman_wred_context_shared_n_contexts_per_node_max %" PRIu32
309c6af0842SJasvinder Singh 		"\n", cap.cman_wred_context_shared_n_contexts_per_node_max);
310c6af0842SJasvinder Singh 
311c1656328SJasvinder Singh 	for (i = 0; i < RTE_COLORS; i++) {
312c6af0842SJasvinder Singh 		printf("cap.mark_vlan_dei_supported %" PRId32 "\n",
313c6af0842SJasvinder Singh 			cap.mark_vlan_dei_supported[i]);
314c6af0842SJasvinder Singh 		printf("cap.mark_ip_ecn_tcp_supported %" PRId32 "\n",
315c6af0842SJasvinder Singh 			cap.mark_ip_ecn_tcp_supported[i]);
316c6af0842SJasvinder Singh 		printf("cap.mark_ip_ecn_sctp_supported %" PRId32 "\n",
317c6af0842SJasvinder Singh 			cap.mark_ip_ecn_sctp_supported[i]);
318c6af0842SJasvinder Singh 		printf("cap.mark_ip_dscp_supported %" PRId32 "\n",
319c6af0842SJasvinder Singh 			cap.mark_ip_dscp_supported[i]);
320c6af0842SJasvinder Singh 	}
321c6af0842SJasvinder Singh 
322c6af0842SJasvinder Singh 	printf("cap.dynamic_update_mask %" PRIx64 "\n",
323c6af0842SJasvinder Singh 		cap.dynamic_update_mask);
324c6af0842SJasvinder Singh 	printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
325c6af0842SJasvinder Singh }
326c6af0842SJasvinder Singh 
327c6af0842SJasvinder Singh cmdline_parse_inst_t cmd_show_port_tm_cap = {
328c6af0842SJasvinder Singh 	.f = cmd_show_port_tm_cap_parsed,
329c6af0842SJasvinder Singh 	.data = NULL,
330c6af0842SJasvinder Singh 	.help_str = "Show Port TM Capabilities",
331c6af0842SJasvinder Singh 	.tokens = {
332c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_cap_show,
333c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_cap_port,
334c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_cap_tm,
335c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_cap_cap,
336c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_cap_port_id,
337c6af0842SJasvinder Singh 		NULL,
338c6af0842SJasvinder Singh 	},
339c6af0842SJasvinder Singh };
340c6af0842SJasvinder Singh 
341c6af0842SJasvinder Singh /* *** Port TM Hierarchical Level Capability *** */
342c6af0842SJasvinder Singh struct cmd_show_port_tm_level_cap_result {
343c6af0842SJasvinder Singh 	cmdline_fixed_string_t show;
344c6af0842SJasvinder Singh 	cmdline_fixed_string_t port;
345c6af0842SJasvinder Singh 	cmdline_fixed_string_t tm;
346c6af0842SJasvinder Singh 	cmdline_fixed_string_t level;
347c6af0842SJasvinder Singh 	cmdline_fixed_string_t cap;
348c6af0842SJasvinder Singh 	uint16_t port_id;
349c6af0842SJasvinder Singh 	uint32_t level_id;
350c6af0842SJasvinder Singh };
351c6af0842SJasvinder Singh 
352ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_show =
353c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
354c6af0842SJasvinder Singh 		show, "show");
355ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_port =
356c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
357c6af0842SJasvinder Singh 		port, "port");
358ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_tm =
359c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
360c6af0842SJasvinder Singh 		tm, "tm");
361ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_level =
362c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
363c6af0842SJasvinder Singh 		level, "level");
364ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_cap =
365c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
366c6af0842SJasvinder Singh 		cap, "cap");
367ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_show_port_tm_level_cap_port_id =
368c6af0842SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
369c2341bb6SDmitry Kozlyuk 		 port_id, RTE_UINT16);
370ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_show_port_tm_level_cap_level_id =
371c6af0842SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
372c2341bb6SDmitry Kozlyuk 		 level_id, RTE_UINT32);
373c6af0842SJasvinder Singh 
374c6af0842SJasvinder Singh 
375c6af0842SJasvinder Singh static void cmd_show_port_tm_level_cap_parsed(void *parsed_result,
376f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
377f2fc83b4SThomas Monjalon 	__rte_unused void *data)
378c6af0842SJasvinder Singh {
379c6af0842SJasvinder Singh 	struct cmd_show_port_tm_level_cap_result *res = parsed_result;
380c6af0842SJasvinder Singh 	struct rte_tm_level_capabilities lcap;
381c6af0842SJasvinder Singh 	struct rte_tm_error error;
382c6af0842SJasvinder Singh 	portid_t port_id = res->port_id;
383c6af0842SJasvinder Singh 	uint32_t level_id = res->level_id;
384c6af0842SJasvinder Singh 	int ret;
385c6af0842SJasvinder Singh 
386c6af0842SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
387c6af0842SJasvinder Singh 		return;
388c6af0842SJasvinder Singh 
389c6af0842SJasvinder Singh 	memset(&lcap, 0, sizeof(struct rte_tm_level_capabilities));
390a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
391c6af0842SJasvinder Singh 	ret = rte_tm_level_capabilities_get(port_id, level_id, &lcap, &error);
392c6af0842SJasvinder Singh 	if (ret) {
393c6af0842SJasvinder Singh 		print_err_msg(&error);
394c6af0842SJasvinder Singh 		return;
395c6af0842SJasvinder Singh 	}
396c6af0842SJasvinder Singh 	printf("\n**   Port TM Hierarchy level %" PRIu32 " Capability **\n\n",
397c6af0842SJasvinder Singh 		level_id);
398c6af0842SJasvinder Singh 
399c6af0842SJasvinder Singh 	printf("cap.n_nodes_max %" PRIu32 "\n", lcap.n_nodes_max);
400c6af0842SJasvinder Singh 	printf("cap.n_nodes_nonleaf_max %" PRIu32 "\n",
401c6af0842SJasvinder Singh 		lcap.n_nodes_nonleaf_max);
402c6af0842SJasvinder Singh 	printf("cap.n_nodes_leaf_max %" PRIu32 "\n", lcap.n_nodes_leaf_max);
403c6af0842SJasvinder Singh 	printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
404c6af0842SJasvinder Singh 		lcap.non_leaf_nodes_identical);
405c6af0842SJasvinder Singh 	printf("cap.leaf_nodes_identical %" PRId32 "\n",
406c6af0842SJasvinder Singh 		lcap.leaf_nodes_identical);
407c6af0842SJasvinder Singh 	if (level_id <= 3) {
408c6af0842SJasvinder Singh 		printf("cap.nonleaf.shaper_private_supported %" PRId32 "\n",
409c6af0842SJasvinder Singh 			lcap.nonleaf.shaper_private_supported);
410c6af0842SJasvinder Singh 		printf("cap.nonleaf.shaper_private_dual_rate_supported %" PRId32
411c6af0842SJasvinder Singh 			"\n", lcap.nonleaf.shaper_private_dual_rate_supported);
412c6af0842SJasvinder Singh 		printf("cap.nonleaf.shaper_private_rate_min %" PRIu64 "\n",
413c6af0842SJasvinder Singh 			lcap.nonleaf.shaper_private_rate_min);
414c6af0842SJasvinder Singh 		printf("cap.nonleaf.shaper_private_rate_max %" PRIu64 "\n",
415c6af0842SJasvinder Singh 			lcap.nonleaf.shaper_private_rate_max);
416bb52561eSNithin Dabilpuram 		printf("cap.nonleaf.shaper_private_packet_mode_supported %"
417bb52561eSNithin Dabilpuram 		       PRId32 "\n",
418bb52561eSNithin Dabilpuram 			lcap.nonleaf.shaper_private_packet_mode_supported);
419bb52561eSNithin Dabilpuram 		printf("cap.nonleaf.shaper_private_byte_mode_supported %" PRId32
420bb52561eSNithin Dabilpuram 		       "\n", lcap.nonleaf.shaper_private_byte_mode_supported);
421c6af0842SJasvinder Singh 		printf("cap.nonleaf.shaper_shared_n_max %" PRIu32 "\n",
422c6af0842SJasvinder Singh 			lcap.nonleaf.shaper_shared_n_max);
423bb52561eSNithin Dabilpuram 		printf("cap.nonleaf.shaper_shared_packet_mode_supported %"
424bb52561eSNithin Dabilpuram 		       PRId32 "\n",
425bb52561eSNithin Dabilpuram 		       lcap.nonleaf.shaper_shared_packet_mode_supported);
426bb52561eSNithin Dabilpuram 		printf("cap.nonleaf.shaper_shared_byte_mode_supported %"
427bb52561eSNithin Dabilpuram 		       PRId32 "\n",
428bb52561eSNithin Dabilpuram 		       lcap.nonleaf.shaper_shared_byte_mode_supported);
429c6af0842SJasvinder Singh 		printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
430c6af0842SJasvinder Singh 			lcap.nonleaf.sched_n_children_max);
431c6af0842SJasvinder Singh 		printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
432c6af0842SJasvinder Singh 			lcap.nonleaf.sched_sp_n_priorities_max);
433c6af0842SJasvinder Singh 		printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
434c6af0842SJasvinder Singh 			"\n", lcap.nonleaf.sched_wfq_n_children_per_group_max);
435c6af0842SJasvinder Singh 		printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
436c6af0842SJasvinder Singh 			lcap.nonleaf.sched_wfq_n_groups_max);
437c6af0842SJasvinder Singh 		printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
438c6af0842SJasvinder Singh 			lcap.nonleaf.sched_wfq_weight_max);
439bb52561eSNithin Dabilpuram 		printf("cap.nonleaf.sched_wfq_packet_mode_supported %" PRId32 "\n",
440bb52561eSNithin Dabilpuram 			lcap.nonleaf.sched_wfq_packet_mode_supported);
441bb52561eSNithin Dabilpuram 		printf("cap.nonleaf.sched_wfq_byte_mode_supported %" PRId32
442bb52561eSNithin Dabilpuram 		       "\n", lcap.nonleaf.sched_wfq_byte_mode_supported);
443c6af0842SJasvinder Singh 		printf("cap.nonleaf.stats_mask %" PRIx64 "\n",
444c6af0842SJasvinder Singh 			lcap.nonleaf.stats_mask);
445c6af0842SJasvinder Singh 	} else {
446c6af0842SJasvinder Singh 		printf("cap.leaf.shaper_private_supported %" PRId32 "\n",
447c6af0842SJasvinder Singh 			lcap.leaf.shaper_private_supported);
448c6af0842SJasvinder Singh 		printf("cap.leaf.shaper_private_dual_rate_supported %" PRId32
449c6af0842SJasvinder Singh 			"\n", lcap.leaf.shaper_private_dual_rate_supported);
450c6af0842SJasvinder Singh 		printf("cap.leaf.shaper_private_rate_min %" PRIu64 "\n",
451c6af0842SJasvinder Singh 			lcap.leaf.shaper_private_rate_min);
452c6af0842SJasvinder Singh 		printf("cap.leaf.shaper_private_rate_max %" PRIu64 "\n",
453c6af0842SJasvinder Singh 			lcap.leaf.shaper_private_rate_max);
454bb52561eSNithin Dabilpuram 		printf("cap.leaf.shaper_private_packet_mode_supported %" PRId32
455bb52561eSNithin Dabilpuram 		       "\n", lcap.leaf.shaper_private_packet_mode_supported);
456bb52561eSNithin Dabilpuram 		printf("cap.leaf.shaper_private_byte_mode_supported %" PRId32 "\n",
457bb52561eSNithin Dabilpuram 			lcap.leaf.shaper_private_byte_mode_supported);
458c6af0842SJasvinder Singh 		printf("cap.leaf.shaper_shared_n_max %" PRIu32 "\n",
459c6af0842SJasvinder Singh 			lcap.leaf.shaper_shared_n_max);
460bb52561eSNithin Dabilpuram 		printf("cap.leaf.shaper_shared_packet_mode_supported %" PRId32 "\n",
461bb52561eSNithin Dabilpuram 		       lcap.leaf.shaper_shared_packet_mode_supported);
462bb52561eSNithin Dabilpuram 		printf("cap.leaf.shaper_shared_byte_mode_supported %" PRId32 "\n",
463bb52561eSNithin Dabilpuram 		       lcap.leaf.shaper_shared_byte_mode_supported);
464c6af0842SJasvinder Singh 		printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
465c6af0842SJasvinder Singh 			lcap.leaf.cman_head_drop_supported);
466c6af0842SJasvinder Singh 		printf("cap.leaf.cman_wred_context_private_supported %"	PRId32
467c6af0842SJasvinder Singh 			"\n", lcap.leaf.cman_wred_context_private_supported);
468c6af0842SJasvinder Singh 		printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
469c6af0842SJasvinder Singh 			lcap.leaf.cman_wred_context_shared_n_max);
470c6af0842SJasvinder Singh 		printf("cap.leaf.stats_mask %" PRIx64 "\n",
471c6af0842SJasvinder Singh 			lcap.leaf.stats_mask);
472c6af0842SJasvinder Singh 	}
473c6af0842SJasvinder Singh }
474c6af0842SJasvinder Singh 
475c6af0842SJasvinder Singh cmdline_parse_inst_t cmd_show_port_tm_level_cap = {
476c6af0842SJasvinder Singh 	.f = cmd_show_port_tm_level_cap_parsed,
477c6af0842SJasvinder Singh 	.data = NULL,
4787be78d02SJosh Soref 	.help_str = "Show port TM hierarchical level capabilities",
479c6af0842SJasvinder Singh 	.tokens = {
480c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_level_cap_show,
481c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_level_cap_port,
482c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_level_cap_tm,
483c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_level_cap_level,
484c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_level_cap_cap,
485c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_level_cap_port_id,
486c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_level_cap_level_id,
487c6af0842SJasvinder Singh 		NULL,
488c6af0842SJasvinder Singh 	},
489c6af0842SJasvinder Singh };
490c6af0842SJasvinder Singh 
491c6af0842SJasvinder Singh /* *** Port TM Hierarchy Node Capability *** */
492c6af0842SJasvinder Singh struct cmd_show_port_tm_node_cap_result {
493c6af0842SJasvinder Singh 	cmdline_fixed_string_t show;
494c6af0842SJasvinder Singh 	cmdline_fixed_string_t port;
495c6af0842SJasvinder Singh 	cmdline_fixed_string_t tm;
496c6af0842SJasvinder Singh 	cmdline_fixed_string_t node;
497c6af0842SJasvinder Singh 	cmdline_fixed_string_t cap;
498c6af0842SJasvinder Singh 	uint16_t port_id;
499c6af0842SJasvinder Singh 	uint32_t node_id;
500c6af0842SJasvinder Singh };
501c6af0842SJasvinder Singh 
502ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_show =
503c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
504c6af0842SJasvinder Singh 		show, "show");
505ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_port =
506c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
507c6af0842SJasvinder Singh 		port, "port");
508ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_tm =
509c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
510c6af0842SJasvinder Singh 		tm, "tm");
511ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_node =
512c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
513c6af0842SJasvinder Singh 		node, "node");
514ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_cap =
515c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
516c6af0842SJasvinder Singh 		cap, "cap");
517ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_show_port_tm_node_cap_port_id =
518c6af0842SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
519c2341bb6SDmitry Kozlyuk 		 port_id, RTE_UINT16);
520ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_show_port_tm_node_cap_node_id =
521c6af0842SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
522c2341bb6SDmitry Kozlyuk 		 node_id, RTE_UINT32);
523c6af0842SJasvinder Singh 
524c6af0842SJasvinder Singh static void cmd_show_port_tm_node_cap_parsed(void *parsed_result,
525f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
526f2fc83b4SThomas Monjalon 	__rte_unused void *data)
527c6af0842SJasvinder Singh {
528c6af0842SJasvinder Singh 	struct cmd_show_port_tm_node_cap_result *res = parsed_result;
529c6af0842SJasvinder Singh 	struct rte_tm_node_capabilities ncap;
530c6af0842SJasvinder Singh 	struct rte_tm_error error;
531c6af0842SJasvinder Singh 	uint32_t node_id = res->node_id;
532c6af0842SJasvinder Singh 	portid_t port_id = res->port_id;
533c6af0842SJasvinder Singh 	int ret, is_leaf = 0;
534c6af0842SJasvinder Singh 
535c6af0842SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
536c6af0842SJasvinder Singh 		return;
537c6af0842SJasvinder Singh 
538a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
539c6af0842SJasvinder Singh 	/* Node id must be valid */
540c6af0842SJasvinder Singh 	ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
541c6af0842SJasvinder Singh 	if (ret != 0) {
542c6af0842SJasvinder Singh 		print_err_msg(&error);
543c6af0842SJasvinder Singh 		return;
544c6af0842SJasvinder Singh 	}
545c6af0842SJasvinder Singh 
546c6af0842SJasvinder Singh 	memset(&ncap, 0, sizeof(struct rte_tm_node_capabilities));
547c6af0842SJasvinder Singh 	ret = rte_tm_node_capabilities_get(port_id, node_id, &ncap, &error);
548c6af0842SJasvinder Singh 	if (ret != 0) {
549c6af0842SJasvinder Singh 		print_err_msg(&error);
550c6af0842SJasvinder Singh 		return;
551c6af0842SJasvinder Singh 	}
552c6af0842SJasvinder Singh 	printf("\n**   Port TM Hierarchy node %" PRIu32 " Capability **\n\n",
553c6af0842SJasvinder Singh 		node_id);
554c6af0842SJasvinder Singh 	printf("cap.shaper_private_supported %" PRId32 "\n",
555c6af0842SJasvinder Singh 		ncap.shaper_private_supported);
556c6af0842SJasvinder Singh 	printf("cap.shaper_private_dual_rate_supported %" PRId32 "\n",
557c6af0842SJasvinder Singh 		ncap.shaper_private_dual_rate_supported);
558c6af0842SJasvinder Singh 	printf("cap.shaper_private_rate_min %" PRIu64 "\n",
559c6af0842SJasvinder Singh 		ncap.shaper_private_rate_min);
560c6af0842SJasvinder Singh 	printf("cap.shaper_private_rate_max %" PRIu64 "\n",
561c6af0842SJasvinder Singh 		ncap.shaper_private_rate_max);
562bb52561eSNithin Dabilpuram 	printf("cap.shaper_private_packet_mode_supported %" PRId32 "\n",
563bb52561eSNithin Dabilpuram 		ncap.shaper_private_packet_mode_supported);
564bb52561eSNithin Dabilpuram 	printf("cap.shaper_private_byte_mode_supported %" PRId32 "\n",
565bb52561eSNithin Dabilpuram 		ncap.shaper_private_byte_mode_supported);
566c6af0842SJasvinder Singh 	printf("cap.shaper_shared_n_max %" PRIu32 "\n",
567c6af0842SJasvinder Singh 		ncap.shaper_shared_n_max);
568bb52561eSNithin Dabilpuram 	printf("cap.shaper_shared_packet_mode_supported %" PRId32 "\n",
569bb52561eSNithin Dabilpuram 		ncap.shaper_shared_packet_mode_supported);
570bb52561eSNithin Dabilpuram 	printf("cap.shaper_shared_byte_mode_supported %" PRId32 "\n",
571bb52561eSNithin Dabilpuram 		ncap.shaper_shared_byte_mode_supported);
572c6af0842SJasvinder Singh 	if (!is_leaf) {
573c6af0842SJasvinder Singh 		printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
574c6af0842SJasvinder Singh 			ncap.nonleaf.sched_n_children_max);
575c6af0842SJasvinder Singh 		printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
576c6af0842SJasvinder Singh 			ncap.nonleaf.sched_sp_n_priorities_max);
577c6af0842SJasvinder Singh 		printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
578c6af0842SJasvinder Singh 			"\n", ncap.nonleaf.sched_wfq_n_children_per_group_max);
579c6af0842SJasvinder Singh 		printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
580c6af0842SJasvinder Singh 			ncap.nonleaf.sched_wfq_n_groups_max);
581c6af0842SJasvinder Singh 		printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
582c6af0842SJasvinder Singh 			ncap.nonleaf.sched_wfq_weight_max);
583bb52561eSNithin Dabilpuram 		printf("cap.nonleaf.sched_wfq_packet_mode_supported %" PRId32 "\n",
584bb52561eSNithin Dabilpuram 			ncap.nonleaf.sched_wfq_packet_mode_supported);
585bb52561eSNithin Dabilpuram 		printf("cap.nonleaf.sched_wfq_byte_mode_supported %" PRId32 "\n",
586bb52561eSNithin Dabilpuram 			ncap.nonleaf.sched_wfq_byte_mode_supported);
587c6af0842SJasvinder Singh 	} else {
588c6af0842SJasvinder Singh 		printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
589c6af0842SJasvinder Singh 			ncap.leaf.cman_head_drop_supported);
590c6af0842SJasvinder Singh 		printf("cap.leaf.cman_wred_context_private_supported %" PRId32
591c6af0842SJasvinder Singh 			"\n", ncap.leaf.cman_wred_context_private_supported);
592c6af0842SJasvinder Singh 		printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
593c6af0842SJasvinder Singh 			ncap.leaf.cman_wred_context_shared_n_max);
594c6af0842SJasvinder Singh 	}
595c6af0842SJasvinder Singh 	printf("cap.stats_mask %" PRIx64 "\n", ncap.stats_mask);
596c6af0842SJasvinder Singh }
597c6af0842SJasvinder Singh 
598c6af0842SJasvinder Singh cmdline_parse_inst_t cmd_show_port_tm_node_cap = {
599c6af0842SJasvinder Singh 	.f = cmd_show_port_tm_node_cap_parsed,
600c6af0842SJasvinder Singh 	.data = NULL,
601c6af0842SJasvinder Singh 	.help_str = "Show Port TM Hierarchy node capabilities",
602c6af0842SJasvinder Singh 	.tokens = {
603c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_cap_show,
604c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_cap_port,
605c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_cap_tm,
606c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_cap_node,
607c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_cap_cap,
608c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_cap_port_id,
609c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_cap_node_id,
610c6af0842SJasvinder Singh 		NULL,
611c6af0842SJasvinder Singh 	},
612c6af0842SJasvinder Singh };
613c6af0842SJasvinder Singh 
614c6af0842SJasvinder Singh /* *** Show Port TM Node Statistics *** */
615c6af0842SJasvinder Singh struct cmd_show_port_tm_node_stats_result {
616c6af0842SJasvinder Singh 	cmdline_fixed_string_t show;
617c6af0842SJasvinder Singh 	cmdline_fixed_string_t port;
618c6af0842SJasvinder Singh 	cmdline_fixed_string_t tm;
619c6af0842SJasvinder Singh 	cmdline_fixed_string_t node;
620c6af0842SJasvinder Singh 	cmdline_fixed_string_t stats;
621c6af0842SJasvinder Singh 	uint16_t port_id;
622c6af0842SJasvinder Singh 	uint32_t node_id;
623c6af0842SJasvinder Singh 	uint32_t clear;
624c6af0842SJasvinder Singh };
625c6af0842SJasvinder Singh 
626ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_show =
627c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
628c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_stats_result, show, "show");
629ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_port =
630c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
631c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_stats_result, port, "port");
632ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_tm =
633c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
634c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_stats_result, tm, "tm");
635ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_node =
636c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
637c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_stats_result, node, "node");
638ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_stats =
639c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
640c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_stats_result, stats, "stats");
641ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_show_port_tm_node_stats_port_id =
642c6af0842SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_stats_result,
643c2341bb6SDmitry Kozlyuk 			port_id, RTE_UINT16);
644ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_show_port_tm_node_stats_node_id =
645c6af0842SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
646c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_stats_result,
647c2341bb6SDmitry Kozlyuk 			node_id, RTE_UINT32);
648ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_show_port_tm_node_stats_clear =
649c6af0842SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
650c2341bb6SDmitry Kozlyuk 		struct cmd_show_port_tm_node_stats_result, clear, RTE_UINT32);
651c6af0842SJasvinder Singh 
652c6af0842SJasvinder Singh static void cmd_show_port_tm_node_stats_parsed(void *parsed_result,
653f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
654f2fc83b4SThomas Monjalon 	__rte_unused void *data)
655c6af0842SJasvinder Singh {
656c6af0842SJasvinder Singh 	struct cmd_show_port_tm_node_stats_result *res = parsed_result;
657c6af0842SJasvinder Singh 	struct rte_tm_node_stats stats;
658c6af0842SJasvinder Singh 	struct rte_tm_error error;
659c6af0842SJasvinder Singh 	uint64_t stats_mask = 0;
660c6af0842SJasvinder Singh 	uint32_t node_id = res->node_id;
661c6af0842SJasvinder Singh 	uint32_t clear = res->clear;
662c6af0842SJasvinder Singh 	portid_t port_id = res->port_id;
663c6af0842SJasvinder Singh 	int ret;
664c6af0842SJasvinder Singh 
665c6af0842SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
666c6af0842SJasvinder Singh 		return;
667c6af0842SJasvinder Singh 
668a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
669c6af0842SJasvinder Singh 	/* Port status */
670c6af0842SJasvinder Singh 	if (!port_is_started(port_id)) {
67161a3b0e5SAndrew Rybchenko 		fprintf(stderr, " Port %u not started (error)\n", port_id);
672c6af0842SJasvinder Singh 		return;
673c6af0842SJasvinder Singh 	}
674c6af0842SJasvinder Singh 
675c6af0842SJasvinder Singh 	memset(&stats, 0, sizeof(struct rte_tm_node_stats));
676c6af0842SJasvinder Singh 	ret = rte_tm_node_stats_read(port_id, node_id, &stats,
677c6af0842SJasvinder Singh 			&stats_mask, clear, &error);
678c6af0842SJasvinder Singh 	if (ret != 0) {
679c6af0842SJasvinder Singh 		print_err_msg(&error);
680c6af0842SJasvinder Singh 		return;
681c6af0842SJasvinder Singh 	}
682c6af0842SJasvinder Singh 
683c6af0842SJasvinder Singh 	/* Display stats */
684c6af0842SJasvinder Singh 	if (stats_mask & RTE_TM_STATS_N_PKTS)
685c6af0842SJasvinder Singh 		printf("\tPkts scheduled from node: %" PRIu64 "\n",
686c6af0842SJasvinder Singh 			stats.n_pkts);
687c6af0842SJasvinder Singh 	if (stats_mask & RTE_TM_STATS_N_BYTES)
688c6af0842SJasvinder Singh 		printf("\tBytes scheduled from node: %" PRIu64 "\n",
689c6af0842SJasvinder Singh 			stats.n_bytes);
690c6af0842SJasvinder Singh 	if (stats_mask & RTE_TM_STATS_N_PKTS_GREEN_DROPPED)
691c6af0842SJasvinder Singh 		printf("\tPkts dropped (green): %" PRIu64 "\n",
692c1656328SJasvinder Singh 			stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN]);
693c6af0842SJasvinder Singh 	if (stats_mask & RTE_TM_STATS_N_PKTS_YELLOW_DROPPED)
694c6af0842SJasvinder Singh 		printf("\tPkts dropped (yellow): %" PRIu64 "\n",
695c1656328SJasvinder Singh 			stats.leaf.n_pkts_dropped[RTE_COLOR_YELLOW]);
696c6af0842SJasvinder Singh 	if (stats_mask & RTE_TM_STATS_N_PKTS_RED_DROPPED)
697c6af0842SJasvinder Singh 		printf("\tPkts dropped (red): %" PRIu64 "\n",
698c1656328SJasvinder Singh 			stats.leaf.n_pkts_dropped[RTE_COLOR_RED]);
699c6af0842SJasvinder Singh 	if (stats_mask & RTE_TM_STATS_N_BYTES_GREEN_DROPPED)
700c6af0842SJasvinder Singh 		printf("\tBytes dropped (green): %" PRIu64 "\n",
701c1656328SJasvinder Singh 			stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN]);
702c6af0842SJasvinder Singh 	if (stats_mask & RTE_TM_STATS_N_BYTES_YELLOW_DROPPED)
703c6af0842SJasvinder Singh 		printf("\tBytes dropped (yellow): %" PRIu64 "\n",
704c1656328SJasvinder Singh 			stats.leaf.n_bytes_dropped[RTE_COLOR_YELLOW]);
705c6af0842SJasvinder Singh 	if (stats_mask & RTE_TM_STATS_N_BYTES_RED_DROPPED)
706c6af0842SJasvinder Singh 		printf("\tBytes dropped (red): %" PRIu64 "\n",
707c1656328SJasvinder Singh 			stats.leaf.n_bytes_dropped[RTE_COLOR_RED]);
708c6af0842SJasvinder Singh 	if (stats_mask & RTE_TM_STATS_N_PKTS_QUEUED)
709c6af0842SJasvinder Singh 		printf("\tPkts queued: %" PRIu64 "\n",
710c6af0842SJasvinder Singh 			stats.leaf.n_pkts_queued);
711c6af0842SJasvinder Singh 	if (stats_mask & RTE_TM_STATS_N_BYTES_QUEUED)
712c6af0842SJasvinder Singh 		printf("\tBytes queued: %" PRIu64 "\n",
713c6af0842SJasvinder Singh 			stats.leaf.n_bytes_queued);
714c6af0842SJasvinder Singh }
715c6af0842SJasvinder Singh 
716c6af0842SJasvinder Singh cmdline_parse_inst_t cmd_show_port_tm_node_stats = {
717c6af0842SJasvinder Singh 	.f = cmd_show_port_tm_node_stats_parsed,
718c6af0842SJasvinder Singh 	.data = NULL,
719c6af0842SJasvinder Singh 	.help_str = "Show port tm node stats",
720c6af0842SJasvinder Singh 	.tokens = {
721c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_stats_show,
722c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_stats_port,
723c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_stats_tm,
724c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_stats_node,
725c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_stats_stats,
726c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_stats_port_id,
727c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_stats_node_id,
728c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_stats_clear,
729c6af0842SJasvinder Singh 		NULL,
730c6af0842SJasvinder Singh 	},
731c6af0842SJasvinder Singh };
732c6af0842SJasvinder Singh 
733c6af0842SJasvinder Singh /* *** Show Port TM Node Type *** */
734c6af0842SJasvinder Singh struct cmd_show_port_tm_node_type_result {
735c6af0842SJasvinder Singh 	cmdline_fixed_string_t show;
736c6af0842SJasvinder Singh 	cmdline_fixed_string_t port;
737c6af0842SJasvinder Singh 	cmdline_fixed_string_t tm;
738c6af0842SJasvinder Singh 	cmdline_fixed_string_t node;
739c6af0842SJasvinder Singh 	cmdline_fixed_string_t type;
740c6af0842SJasvinder Singh 	uint16_t port_id;
741c6af0842SJasvinder Singh 	uint32_t node_id;
742c6af0842SJasvinder Singh };
743c6af0842SJasvinder Singh 
744ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_type_show =
745c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
746c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_type_result, show, "show");
747ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_type_port =
748c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
749c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_type_result, port, "port");
750ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_type_tm =
751c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
752c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_type_result, tm, "tm");
753ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_type_node =
754c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
755c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_type_result, node, "node");
756ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_show_port_tm_node_type_type =
757c6af0842SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
758c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_type_result, type, "type");
759ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_show_port_tm_node_type_port_id =
760c6af0842SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
761c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_type_result,
762c2341bb6SDmitry Kozlyuk 			port_id, RTE_UINT16);
763ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_show_port_tm_node_type_node_id =
764c6af0842SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
765c6af0842SJasvinder Singh 		struct cmd_show_port_tm_node_type_result,
766c2341bb6SDmitry Kozlyuk 			node_id, RTE_UINT32);
767c6af0842SJasvinder Singh 
768c6af0842SJasvinder Singh static void cmd_show_port_tm_node_type_parsed(void *parsed_result,
769f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
770f2fc83b4SThomas Monjalon 	__rte_unused void *data)
771c6af0842SJasvinder Singh {
772c6af0842SJasvinder Singh 	struct cmd_show_port_tm_node_type_result *res = parsed_result;
773c6af0842SJasvinder Singh 	struct rte_tm_error error;
774c6af0842SJasvinder Singh 	uint32_t node_id = res->node_id;
775c6af0842SJasvinder Singh 	portid_t port_id = res->port_id;
776c6af0842SJasvinder Singh 	int ret, is_leaf = 0;
777c6af0842SJasvinder Singh 
778c6af0842SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
779c6af0842SJasvinder Singh 		return;
780c6af0842SJasvinder Singh 
781a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
782c6af0842SJasvinder Singh 	ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
783c6af0842SJasvinder Singh 	if (ret != 0) {
784c6af0842SJasvinder Singh 		print_err_msg(&error);
785c6af0842SJasvinder Singh 		return;
786c6af0842SJasvinder Singh 	}
787c6af0842SJasvinder Singh 
788c6af0842SJasvinder Singh 	if (is_leaf == 1)
789c6af0842SJasvinder Singh 		printf("leaf node\n");
790c6af0842SJasvinder Singh 	else
791c6af0842SJasvinder Singh 		printf("nonleaf node\n");
792c6af0842SJasvinder Singh 
793c6af0842SJasvinder Singh }
794c6af0842SJasvinder Singh 
795c6af0842SJasvinder Singh cmdline_parse_inst_t cmd_show_port_tm_node_type = {
796c6af0842SJasvinder Singh 	.f = cmd_show_port_tm_node_type_parsed,
797c6af0842SJasvinder Singh 	.data = NULL,
798c6af0842SJasvinder Singh 	.help_str = "Show port tm node type",
799c6af0842SJasvinder Singh 	.tokens = {
800c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_type_show,
801c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_type_port,
802c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_type_tm,
803c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_type_node,
804c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_type_type,
805c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_type_port_id,
806c6af0842SJasvinder Singh 		(void *)&cmd_show_port_tm_node_type_node_id,
807c6af0842SJasvinder Singh 		NULL,
808c6af0842SJasvinder Singh 	},
809c6af0842SJasvinder Singh };
810bddc2f40SJasvinder Singh 
811bddc2f40SJasvinder Singh /* *** Add Port TM Private Shaper Profile *** */
812bddc2f40SJasvinder Singh struct cmd_add_port_tm_node_shaper_profile_result {
813bddc2f40SJasvinder Singh 	cmdline_fixed_string_t add;
814bddc2f40SJasvinder Singh 	cmdline_fixed_string_t port;
815bddc2f40SJasvinder Singh 	cmdline_fixed_string_t tm;
816bddc2f40SJasvinder Singh 	cmdline_fixed_string_t node;
817bddc2f40SJasvinder Singh 	cmdline_fixed_string_t shaper;
818bddc2f40SJasvinder Singh 	cmdline_fixed_string_t profile;
819bddc2f40SJasvinder Singh 	uint16_t port_id;
820bddc2f40SJasvinder Singh 	uint32_t shaper_id;
821c2c15f76SRosen Xu 	uint64_t cmit_tb_rate;
822c2c15f76SRosen Xu 	uint64_t cmit_tb_size;
823c2c15f76SRosen Xu 	uint64_t peak_tb_rate;
824c2c15f76SRosen Xu 	uint64_t peak_tb_size;
825bddc2f40SJasvinder Singh 	uint32_t pktlen_adjust;
826bb52561eSNithin Dabilpuram 	int pkt_mode;
827bddc2f40SJasvinder Singh };
828bddc2f40SJasvinder Singh 
829ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add =
830bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
831bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result, add, "add");
832ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port =
833bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
834bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result,
835bddc2f40SJasvinder Singh 			port, "port");
836ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm =
837bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
838bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result,
839bddc2f40SJasvinder Singh 			tm, "tm");
840ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node =
841bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
842bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result,
843bddc2f40SJasvinder Singh 			node, "node");
844ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper =
845bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
846bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result,
847bddc2f40SJasvinder Singh 			shaper, "shaper");
848ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile =
849bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
850bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result,
851bddc2f40SJasvinder Singh 			profile, "profile");
852ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id =
853bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
854bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result,
855c2341bb6SDmitry Kozlyuk 			port_id, RTE_UINT16);
856ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id =
857bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
858bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result,
859c2341bb6SDmitry Kozlyuk 			shaper_id, RTE_UINT32);
860ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_rate =
861bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
862bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result,
863c2341bb6SDmitry Kozlyuk 			cmit_tb_rate, RTE_UINT64);
864ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_size =
865bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
866bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result,
867c2341bb6SDmitry Kozlyuk 			cmit_tb_size, RTE_UINT64);
868ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_rate =
869c2c15f76SRosen Xu 	TOKEN_NUM_INITIALIZER(
870c2c15f76SRosen Xu 		struct cmd_add_port_tm_node_shaper_profile_result,
871c2341bb6SDmitry Kozlyuk 			peak_tb_rate, RTE_UINT64);
872ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_size =
873c2c15f76SRosen Xu 	TOKEN_NUM_INITIALIZER(
874c2c15f76SRosen Xu 		struct cmd_add_port_tm_node_shaper_profile_result,
875c2341bb6SDmitry Kozlyuk 			peak_tb_size, RTE_UINT64);
876ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust =
877bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
878bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shaper_profile_result,
879c2341bb6SDmitry Kozlyuk 			pktlen_adjust, RTE_UINT32);
880ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_packet_mode =
881bb52561eSNithin Dabilpuram 	TOKEN_NUM_INITIALIZER(
882bb52561eSNithin Dabilpuram 		struct cmd_add_port_tm_node_shaper_profile_result,
883c2341bb6SDmitry Kozlyuk 			pkt_mode, RTE_UINT32);
884bddc2f40SJasvinder Singh 
88552e5e7c2SBruce Richardson static int
88652e5e7c2SBruce Richardson get_printable_rate(uint64_t rate, char *buffer, size_t size)
88752e5e7c2SBruce Richardson {
88852e5e7c2SBruce Richardson 	if (rate >= 1000 * 1000 * 1000)
88952e5e7c2SBruce Richardson 		return snprintf(buffer, size, "%.1fG", rate / (1000 * 1000 * 1000.0));
89052e5e7c2SBruce Richardson 	else if (rate >= 1000 * 1000)
89152e5e7c2SBruce Richardson 		return snprintf(buffer, size, "%.1fM", rate / (1000 * 1000.0));
89252e5e7c2SBruce Richardson 	else if (rate >= 1000)
89352e5e7c2SBruce Richardson 		return snprintf(buffer, size, "%.1fK", rate / 1000.0);
89452e5e7c2SBruce Richardson 	else
89552e5e7c2SBruce Richardson 		return snprintf(buffer, size, "%"PRIu64, rate);
89652e5e7c2SBruce Richardson }
89752e5e7c2SBruce Richardson 
898bddc2f40SJasvinder Singh static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
89952e5e7c2SBruce Richardson 	struct cmdline *cl,
900f2fc83b4SThomas Monjalon 	__rte_unused void *data)
901bddc2f40SJasvinder Singh {
902bddc2f40SJasvinder Singh 	struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result;
903bddc2f40SJasvinder Singh 	struct rte_tm_shaper_params sp;
904bddc2f40SJasvinder Singh 	struct rte_tm_error error;
905bddc2f40SJasvinder Singh 	uint32_t shaper_id = res->shaper_id;
906bddc2f40SJasvinder Singh 	uint32_t pkt_len_adjust = res->pktlen_adjust;
907bddc2f40SJasvinder Singh 	portid_t port_id = res->port_id;
90852e5e7c2SBruce Richardson 	char rate_str[20];
909bddc2f40SJasvinder Singh 	int ret;
910bddc2f40SJasvinder Singh 
91152e5e7c2SBruce Richardson 	cmdline_printf(cl, "adding node shaper on port %u, with id %u\n", res->port_id, shaper_id);
91252e5e7c2SBruce Richardson 	get_printable_rate(res->cmit_tb_rate, rate_str, sizeof(rate_str));
91352e5e7c2SBruce Richardson 	cmdline_printf(cl, "# committed rate: %s, t.b. size: %"PRIu64"\n",
91452e5e7c2SBruce Richardson 			rate_str, res->cmit_tb_size);
91552e5e7c2SBruce Richardson 
91652e5e7c2SBruce Richardson 	get_printable_rate(res->peak_tb_rate, rate_str, sizeof(rate_str));
91752e5e7c2SBruce Richardson 	cmdline_printf(cl, "# peak rate: %s, t.b. size: %"PRIu64"\n",
91852e5e7c2SBruce Richardson 			rate_str, res->peak_tb_size);
91952e5e7c2SBruce Richardson 	cmdline_printf(cl, "# pkt length adjust: %u\n", res->pktlen_adjust);
92052e5e7c2SBruce Richardson 	cmdline_printf(cl, "# packet mode: %s\n", res->pkt_mode ? "true" : "false (bytes mode)");
92152e5e7c2SBruce Richardson 
922bddc2f40SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
923bddc2f40SJasvinder Singh 		return;
924bddc2f40SJasvinder Singh 
925bddc2f40SJasvinder Singh 	/* Private shaper profile params */
926bddc2f40SJasvinder Singh 	memset(&sp, 0, sizeof(struct rte_tm_shaper_params));
927a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
928c2c15f76SRosen Xu 	sp.committed.rate = res->cmit_tb_rate;
929c2c15f76SRosen Xu 	sp.committed.size = res->cmit_tb_size;
930c2c15f76SRosen Xu 	sp.peak.rate = res->peak_tb_rate;
931c2c15f76SRosen Xu 	sp.peak.size = res->peak_tb_size;
932bddc2f40SJasvinder Singh 	sp.pkt_length_adjust = pkt_len_adjust;
933bb52561eSNithin Dabilpuram 	sp.packet_mode = res->pkt_mode;
934bddc2f40SJasvinder Singh 
935bddc2f40SJasvinder Singh 	ret = rte_tm_shaper_profile_add(port_id, shaper_id, &sp, &error);
936bddc2f40SJasvinder Singh 	if (ret != 0) {
937bddc2f40SJasvinder Singh 		print_err_msg(&error);
938bddc2f40SJasvinder Singh 		return;
939bddc2f40SJasvinder Singh 	}
940bddc2f40SJasvinder Singh }
941bddc2f40SJasvinder Singh 
942bddc2f40SJasvinder Singh cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile = {
943bddc2f40SJasvinder Singh 	.f = cmd_add_port_tm_node_shaper_profile_parsed,
944bddc2f40SJasvinder Singh 	.data = NULL,
945bddc2f40SJasvinder Singh 	.help_str = "Add port tm node private shaper profile",
946bddc2f40SJasvinder Singh 	.tokens = {
947bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shaper_profile_add,
948bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shaper_profile_port,
949bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shaper_profile_tm,
950bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shaper_profile_node,
951bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shaper_profile_shaper,
952bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shaper_profile_profile,
953bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shaper_profile_port_id,
954bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shaper_profile_shaper_id,
955c2c15f76SRosen Xu 		(void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_rate,
956c2c15f76SRosen Xu 		(void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_size,
957c2c15f76SRosen Xu 		(void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_rate,
958c2c15f76SRosen Xu 		(void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_size,
959bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust,
960bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_node_shaper_profile_packet_mode,
961bddc2f40SJasvinder Singh 		NULL,
962bddc2f40SJasvinder Singh 	},
963bddc2f40SJasvinder Singh };
964bddc2f40SJasvinder Singh 
965bddc2f40SJasvinder Singh /* *** Delete Port TM Private Shaper Profile *** */
966bddc2f40SJasvinder Singh struct cmd_del_port_tm_node_shaper_profile_result {
967bddc2f40SJasvinder Singh 	cmdline_fixed_string_t del;
968bddc2f40SJasvinder Singh 	cmdline_fixed_string_t port;
969bddc2f40SJasvinder Singh 	cmdline_fixed_string_t tm;
970bddc2f40SJasvinder Singh 	cmdline_fixed_string_t node;
971bddc2f40SJasvinder Singh 	cmdline_fixed_string_t shaper;
972bddc2f40SJasvinder Singh 	cmdline_fixed_string_t profile;
973bddc2f40SJasvinder Singh 	uint16_t port_id;
974bddc2f40SJasvinder Singh 	uint32_t shaper_id;
975bddc2f40SJasvinder Singh };
976bddc2f40SJasvinder Singh 
977ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del =
978bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
979bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shaper_profile_result, del, "del");
980ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port =
981bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
982bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shaper_profile_result,
983bddc2f40SJasvinder Singh 			port, "port");
984ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm =
985bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
986bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shaper_profile_result, tm, "tm");
987ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node =
988bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
989bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shaper_profile_result,
990bddc2f40SJasvinder Singh 			node, "node");
991ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper =
992bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
993bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shaper_profile_result,
994bddc2f40SJasvinder Singh 			shaper, "shaper");
995ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile =
996bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
997bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shaper_profile_result,
998bddc2f40SJasvinder Singh 			profile, "profile");
999ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id =
1000bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1001bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shaper_profile_result,
1002c2341bb6SDmitry Kozlyuk 			port_id, RTE_UINT16);
1003ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id =
1004bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1005bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shaper_profile_result,
1006c2341bb6SDmitry Kozlyuk 			shaper_id, RTE_UINT32);
1007bddc2f40SJasvinder Singh 
1008bddc2f40SJasvinder Singh static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result,
1009f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
1010f2fc83b4SThomas Monjalon 	__rte_unused void *data)
1011bddc2f40SJasvinder Singh {
1012bddc2f40SJasvinder Singh 	struct cmd_del_port_tm_node_shaper_profile_result *res = parsed_result;
1013bddc2f40SJasvinder Singh 	struct rte_tm_error error;
1014bddc2f40SJasvinder Singh 	uint32_t shaper_id = res->shaper_id;
1015bddc2f40SJasvinder Singh 	portid_t port_id = res->port_id;
1016bddc2f40SJasvinder Singh 	int ret;
1017bddc2f40SJasvinder Singh 
1018bddc2f40SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
1019bddc2f40SJasvinder Singh 		return;
1020bddc2f40SJasvinder Singh 
1021a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
1022bddc2f40SJasvinder Singh 	ret = rte_tm_shaper_profile_delete(port_id, shaper_id, &error);
1023bddc2f40SJasvinder Singh 	if (ret != 0) {
1024bddc2f40SJasvinder Singh 		print_err_msg(&error);
1025bddc2f40SJasvinder Singh 		return;
1026bddc2f40SJasvinder Singh 	}
1027bddc2f40SJasvinder Singh }
1028bddc2f40SJasvinder Singh 
1029bddc2f40SJasvinder Singh cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile = {
1030bddc2f40SJasvinder Singh 	.f = cmd_del_port_tm_node_shaper_profile_parsed,
1031bddc2f40SJasvinder Singh 	.data = NULL,
1032bddc2f40SJasvinder Singh 	.help_str = "Delete port tm node private shaper profile",
1033bddc2f40SJasvinder Singh 	.tokens = {
1034bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shaper_profile_del,
1035bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shaper_profile_port,
1036bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shaper_profile_tm,
1037bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shaper_profile_node,
1038bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shaper_profile_shaper,
1039bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shaper_profile_profile,
1040bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shaper_profile_port_id,
1041bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shaper_profile_shaper_id,
1042bddc2f40SJasvinder Singh 		NULL,
1043bddc2f40SJasvinder Singh 	},
1044bddc2f40SJasvinder Singh };
1045bddc2f40SJasvinder Singh 
1046bddc2f40SJasvinder Singh /* *** Add/Update Port TM shared Shaper *** */
1047bddc2f40SJasvinder Singh struct cmd_add_port_tm_node_shared_shaper_result {
1048bddc2f40SJasvinder Singh 	cmdline_fixed_string_t cmd_type;
1049bddc2f40SJasvinder Singh 	cmdline_fixed_string_t port;
1050bddc2f40SJasvinder Singh 	cmdline_fixed_string_t tm;
1051bddc2f40SJasvinder Singh 	cmdline_fixed_string_t node;
1052bddc2f40SJasvinder Singh 	cmdline_fixed_string_t shared;
1053bddc2f40SJasvinder Singh 	cmdline_fixed_string_t shaper;
1054bddc2f40SJasvinder Singh 	uint16_t port_id;
1055bddc2f40SJasvinder Singh 	uint32_t shared_shaper_id;
1056bddc2f40SJasvinder Singh 	uint32_t shaper_profile_id;
1057bddc2f40SJasvinder Singh };
1058bddc2f40SJasvinder Singh 
1059ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type =
1060bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1061bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shared_shaper_result,
1062bddc2f40SJasvinder Singh 			cmd_type, "add#set");
1063ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port =
1064bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1065bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shared_shaper_result, port, "port");
1066ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm =
1067bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1068bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shared_shaper_result, tm, "tm");
1069ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node =
1070bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1071bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shared_shaper_result, node, "node");
1072ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared =
1073bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1074bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shared_shaper_result,
1075bddc2f40SJasvinder Singh 			shared, "shared");
1076ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper =
1077bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1078bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shared_shaper_result,
1079bddc2f40SJasvinder Singh 			shaper, "shaper");
1080ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id =
1081bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1082bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shared_shaper_result,
1083c2341bb6SDmitry Kozlyuk 			port_id, RTE_UINT16);
1084ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id =
1085bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1086bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shared_shaper_result,
1087c2341bb6SDmitry Kozlyuk 			shared_shaper_id, RTE_UINT32);
1088ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id =
1089bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1090bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_shared_shaper_result,
1091c2341bb6SDmitry Kozlyuk 			shaper_profile_id, RTE_UINT32);
1092bddc2f40SJasvinder Singh 
1093bddc2f40SJasvinder Singh static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result,
1094f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
1095f2fc83b4SThomas Monjalon 	__rte_unused void *data)
1096bddc2f40SJasvinder Singh {
1097bddc2f40SJasvinder Singh 	struct cmd_add_port_tm_node_shared_shaper_result *res = parsed_result;
1098bddc2f40SJasvinder Singh 	struct rte_tm_error error;
1099bddc2f40SJasvinder Singh 	uint32_t shared_shaper_id = res->shared_shaper_id;
1100bddc2f40SJasvinder Singh 	uint32_t shaper_profile_id = res->shaper_profile_id;
1101bddc2f40SJasvinder Singh 	portid_t port_id = res->port_id;
1102bddc2f40SJasvinder Singh 	int ret;
1103bddc2f40SJasvinder Singh 
1104bddc2f40SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
1105bddc2f40SJasvinder Singh 		return;
1106bddc2f40SJasvinder Singh 
1107a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
1108bddc2f40SJasvinder Singh 	/* Command type: add */
1109bddc2f40SJasvinder Singh 	if ((strcmp(res->cmd_type, "add") == 0) &&
1110bddc2f40SJasvinder Singh 		(port_is_started(port_id))) {
111161a3b0e5SAndrew Rybchenko 		fprintf(stderr, " Port %u not stopped (error)\n", port_id);
1112bddc2f40SJasvinder Singh 		return;
1113bddc2f40SJasvinder Singh 	}
1114bddc2f40SJasvinder Singh 
1115bddc2f40SJasvinder Singh 	/* Command type: set (update) */
1116bddc2f40SJasvinder Singh 	if ((strcmp(res->cmd_type, "set") == 0) &&
1117bddc2f40SJasvinder Singh 		(!port_is_started(port_id))) {
111861a3b0e5SAndrew Rybchenko 		fprintf(stderr, " Port %u not started (error)\n", port_id);
1119bddc2f40SJasvinder Singh 		return;
1120bddc2f40SJasvinder Singh 	}
1121bddc2f40SJasvinder Singh 
1122bddc2f40SJasvinder Singh 	ret = rte_tm_shared_shaper_add_update(port_id, shared_shaper_id,
1123bddc2f40SJasvinder Singh 		shaper_profile_id, &error);
1124bddc2f40SJasvinder Singh 	if (ret != 0) {
1125bddc2f40SJasvinder Singh 		print_err_msg(&error);
1126bddc2f40SJasvinder Singh 		return;
1127bddc2f40SJasvinder Singh 	}
1128bddc2f40SJasvinder Singh }
1129bddc2f40SJasvinder Singh 
1130bddc2f40SJasvinder Singh cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper = {
1131bddc2f40SJasvinder Singh 	.f = cmd_add_port_tm_node_shared_shaper_parsed,
1132bddc2f40SJasvinder Singh 	.data = NULL,
1133bddc2f40SJasvinder Singh 	.help_str = "add/update port tm node shared shaper",
1134bddc2f40SJasvinder Singh 	.tokens = {
1135bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shared_shaper_cmd_type,
1136bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shared_shaper_port,
1137bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shared_shaper_tm,
1138bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shared_shaper_node,
1139bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shared_shaper_shared,
1140bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shared_shaper_shaper,
1141bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shared_shaper_port_id,
1142bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id,
1143bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id,
1144bddc2f40SJasvinder Singh 		NULL,
1145bddc2f40SJasvinder Singh 	},
1146bddc2f40SJasvinder Singh };
1147bddc2f40SJasvinder Singh 
1148bddc2f40SJasvinder Singh /* *** Delete Port TM shared Shaper *** */
1149bddc2f40SJasvinder Singh struct cmd_del_port_tm_node_shared_shaper_result {
1150bddc2f40SJasvinder Singh 	cmdline_fixed_string_t del;
1151bddc2f40SJasvinder Singh 	cmdline_fixed_string_t port;
1152bddc2f40SJasvinder Singh 	cmdline_fixed_string_t tm;
1153bddc2f40SJasvinder Singh 	cmdline_fixed_string_t node;
1154bddc2f40SJasvinder Singh 	cmdline_fixed_string_t shared;
1155bddc2f40SJasvinder Singh 	cmdline_fixed_string_t shaper;
1156bddc2f40SJasvinder Singh 	uint16_t port_id;
1157bddc2f40SJasvinder Singh 	uint32_t shared_shaper_id;
1158bddc2f40SJasvinder Singh };
1159bddc2f40SJasvinder Singh 
1160ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del =
1161bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1162bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shared_shaper_result, del, "del");
1163ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port =
1164bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1165bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shared_shaper_result, port, "port");
1166ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm =
1167bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1168bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shared_shaper_result, tm, "tm");
1169ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node =
1170bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1171bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shared_shaper_result, node, "node");
1172ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared =
1173bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1174bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shared_shaper_result,
1175bddc2f40SJasvinder Singh 			shared, "shared");
1176ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper =
1177bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1178bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shared_shaper_result,
1179bddc2f40SJasvinder Singh 			shaper, "shaper");
1180ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id =
1181bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1182bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shared_shaper_result,
1183c2341bb6SDmitry Kozlyuk 			port_id, RTE_UINT16);
1184ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id =
1185bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1186bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_shared_shaper_result,
1187c2341bb6SDmitry Kozlyuk 			shared_shaper_id, RTE_UINT32);
1188bddc2f40SJasvinder Singh 
1189bddc2f40SJasvinder Singh static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result,
1190f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
1191f2fc83b4SThomas Monjalon 	__rte_unused void *data)
1192bddc2f40SJasvinder Singh {
1193bddc2f40SJasvinder Singh 	struct cmd_del_port_tm_node_shared_shaper_result *res = parsed_result;
1194bddc2f40SJasvinder Singh 	struct rte_tm_error error;
1195bddc2f40SJasvinder Singh 	uint32_t shared_shaper_id = res->shared_shaper_id;
1196bddc2f40SJasvinder Singh 	portid_t port_id = res->port_id;
1197bddc2f40SJasvinder Singh 	int ret;
1198bddc2f40SJasvinder Singh 
1199bddc2f40SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
1200bddc2f40SJasvinder Singh 		return;
1201bddc2f40SJasvinder Singh 
1202a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
1203bddc2f40SJasvinder Singh 	ret = rte_tm_shared_shaper_delete(port_id, shared_shaper_id, &error);
1204bddc2f40SJasvinder Singh 	if (ret != 0) {
1205bddc2f40SJasvinder Singh 		print_err_msg(&error);
1206bddc2f40SJasvinder Singh 		return;
1207bddc2f40SJasvinder Singh 	}
1208bddc2f40SJasvinder Singh }
1209bddc2f40SJasvinder Singh 
1210bddc2f40SJasvinder Singh cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper = {
1211bddc2f40SJasvinder Singh 	.f = cmd_del_port_tm_node_shared_shaper_parsed,
1212bddc2f40SJasvinder Singh 	.data = NULL,
1213bddc2f40SJasvinder Singh 	.help_str = "delete port tm node shared shaper",
1214bddc2f40SJasvinder Singh 	.tokens = {
1215bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shared_shaper_del,
1216bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shared_shaper_port,
1217bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shared_shaper_tm,
1218bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shared_shaper_node,
1219bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shared_shaper_shared,
1220bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shared_shaper_shaper,
1221bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shared_shaper_port_id,
1222bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id,
1223bddc2f40SJasvinder Singh 		NULL,
1224bddc2f40SJasvinder Singh 	},
1225bddc2f40SJasvinder Singh };
1226bddc2f40SJasvinder Singh 
1227bddc2f40SJasvinder Singh /* *** Add Port TM Node WRED Profile *** */
1228bddc2f40SJasvinder Singh struct cmd_add_port_tm_node_wred_profile_result {
1229bddc2f40SJasvinder Singh 	cmdline_fixed_string_t add;
1230bddc2f40SJasvinder Singh 	cmdline_fixed_string_t port;
1231bddc2f40SJasvinder Singh 	cmdline_fixed_string_t tm;
1232bddc2f40SJasvinder Singh 	cmdline_fixed_string_t node;
1233bddc2f40SJasvinder Singh 	cmdline_fixed_string_t wred;
1234bddc2f40SJasvinder Singh 	cmdline_fixed_string_t profile;
1235bddc2f40SJasvinder Singh 	uint16_t port_id;
1236bddc2f40SJasvinder Singh 	uint32_t wred_profile_id;
1237bddc2f40SJasvinder Singh 	cmdline_fixed_string_t color_g;
1238cb43e0b3SRosen Xu 	uint64_t min_th_g;
1239cb43e0b3SRosen Xu 	uint64_t max_th_g;
1240bddc2f40SJasvinder Singh 	uint16_t maxp_inv_g;
1241bddc2f40SJasvinder Singh 	uint16_t wq_log2_g;
1242bddc2f40SJasvinder Singh 	cmdline_fixed_string_t color_y;
1243cb43e0b3SRosen Xu 	uint64_t min_th_y;
1244cb43e0b3SRosen Xu 	uint64_t max_th_y;
1245bddc2f40SJasvinder Singh 	uint16_t maxp_inv_y;
1246bddc2f40SJasvinder Singh 	uint16_t wq_log2_y;
1247bddc2f40SJasvinder Singh 	cmdline_fixed_string_t color_r;
1248cb43e0b3SRosen Xu 	uint64_t min_th_r;
1249cb43e0b3SRosen Xu 	uint64_t max_th_r;
1250bddc2f40SJasvinder Singh 	uint16_t maxp_inv_r;
1251bddc2f40SJasvinder Singh 	uint16_t wq_log2_r;
1252bddc2f40SJasvinder Singh };
1253bddc2f40SJasvinder Singh 
1254ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add =
1255bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1256bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result, add, "add");
1257ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port =
1258bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1259bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result, port, "port");
1260ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm =
1261bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1262bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result, tm, "tm");
1263ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node =
1264bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1265bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result, node, "node");
1266ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred =
1267bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1268bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result, wred, "wred");
1269ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile =
1270bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1271bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1272bddc2f40SJasvinder Singh 			profile, "profile");
1273ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id =
1274bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1275bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1276c2341bb6SDmitry Kozlyuk 			port_id, RTE_UINT16);
1277ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id =
1278bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1279bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1280c2341bb6SDmitry Kozlyuk 			wred_profile_id, RTE_UINT32);
1281ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g =
1282bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1283bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1284bddc2f40SJasvinder Singh 			color_g, "G#g");
1285ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g =
1286bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1287bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1288c2341bb6SDmitry Kozlyuk 			min_th_g, RTE_UINT64);
1289ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g =
1290bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1291bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1292c2341bb6SDmitry Kozlyuk 			max_th_g, RTE_UINT64);
1293ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g =
1294bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1295bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1296c2341bb6SDmitry Kozlyuk 			maxp_inv_g, RTE_UINT16);
1297ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g =
1298bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1299bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1300c2341bb6SDmitry Kozlyuk 			wq_log2_g, RTE_UINT16);
1301ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y =
1302bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1303bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1304bddc2f40SJasvinder Singh 			color_y, "Y#y");
1305ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y =
1306bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1307bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1308c2341bb6SDmitry Kozlyuk 			min_th_y, RTE_UINT64);
1309ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y =
1310bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1311bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1312c2341bb6SDmitry Kozlyuk 			max_th_y, RTE_UINT64);
1313ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y =
1314bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1315bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1316c2341bb6SDmitry Kozlyuk 			maxp_inv_y, RTE_UINT16);
1317ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y =
1318bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1319bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1320c2341bb6SDmitry Kozlyuk 			wq_log2_y, RTE_UINT16);
1321ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r =
1322bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1323bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1324bddc2f40SJasvinder Singh 			color_r, "R#r");
1325ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r =
1326bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1327bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1328c2341bb6SDmitry Kozlyuk 			min_th_r, RTE_UINT64);
1329ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r =
1330bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1331bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1332c2341bb6SDmitry Kozlyuk 			max_th_r, RTE_UINT64);
1333ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r =
1334bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1335bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1336c2341bb6SDmitry Kozlyuk 			maxp_inv_r, RTE_UINT16);
1337ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r =
1338bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1339bddc2f40SJasvinder Singh 		struct cmd_add_port_tm_node_wred_profile_result,
1340c2341bb6SDmitry Kozlyuk 			wq_log2_r, RTE_UINT16);
1341bddc2f40SJasvinder Singh 
1342bddc2f40SJasvinder Singh 
1343bddc2f40SJasvinder Singh static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
1344f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
1345f2fc83b4SThomas Monjalon 	__rte_unused void *data)
1346bddc2f40SJasvinder Singh {
1347bddc2f40SJasvinder Singh 	struct cmd_add_port_tm_node_wred_profile_result *res = parsed_result;
1348bddc2f40SJasvinder Singh 	struct rte_tm_wred_params wp;
1349c1656328SJasvinder Singh 	enum rte_color color;
1350bddc2f40SJasvinder Singh 	struct rte_tm_error error;
1351bddc2f40SJasvinder Singh 	uint32_t wred_profile_id = res->wred_profile_id;
1352bddc2f40SJasvinder Singh 	portid_t port_id = res->port_id;
1353bddc2f40SJasvinder Singh 	int ret;
1354bddc2f40SJasvinder Singh 
1355bddc2f40SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
1356bddc2f40SJasvinder Singh 		return;
1357bddc2f40SJasvinder Singh 
1358bddc2f40SJasvinder Singh 	memset(&wp, 0, sizeof(struct rte_tm_wred_params));
1359a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
1360bddc2f40SJasvinder Singh 
1361bddc2f40SJasvinder Singh 	/* WRED Params  (Green Color)*/
1362c1656328SJasvinder Singh 	color = RTE_COLOR_GREEN;
1363bddc2f40SJasvinder Singh 	wp.red_params[color].min_th = res->min_th_g;
1364bddc2f40SJasvinder Singh 	wp.red_params[color].max_th = res->max_th_g;
1365bddc2f40SJasvinder Singh 	wp.red_params[color].maxp_inv = res->maxp_inv_g;
1366bddc2f40SJasvinder Singh 	wp.red_params[color].wq_log2 = res->wq_log2_g;
1367bddc2f40SJasvinder Singh 
1368bddc2f40SJasvinder Singh 
1369bddc2f40SJasvinder Singh 	/* WRED Params  (Yellow Color)*/
1370c1656328SJasvinder Singh 	color = RTE_COLOR_YELLOW;
1371bddc2f40SJasvinder Singh 	wp.red_params[color].min_th = res->min_th_y;
1372bddc2f40SJasvinder Singh 	wp.red_params[color].max_th = res->max_th_y;
1373bddc2f40SJasvinder Singh 	wp.red_params[color].maxp_inv = res->maxp_inv_y;
1374bddc2f40SJasvinder Singh 	wp.red_params[color].wq_log2 = res->wq_log2_y;
1375bddc2f40SJasvinder Singh 
1376bddc2f40SJasvinder Singh 	/* WRED Params  (Red Color)*/
1377c1656328SJasvinder Singh 	color = RTE_COLOR_RED;
1378bddc2f40SJasvinder Singh 	wp.red_params[color].min_th = res->min_th_r;
1379bddc2f40SJasvinder Singh 	wp.red_params[color].max_th = res->max_th_r;
1380bddc2f40SJasvinder Singh 	wp.red_params[color].maxp_inv = res->maxp_inv_r;
1381bddc2f40SJasvinder Singh 	wp.red_params[color].wq_log2 = res->wq_log2_r;
1382bddc2f40SJasvinder Singh 
1383bddc2f40SJasvinder Singh 	ret = rte_tm_wred_profile_add(port_id, wred_profile_id, &wp, &error);
1384bddc2f40SJasvinder Singh 	if (ret != 0) {
1385bddc2f40SJasvinder Singh 		print_err_msg(&error);
1386bddc2f40SJasvinder Singh 		return;
1387bddc2f40SJasvinder Singh 	}
1388bddc2f40SJasvinder Singh }
1389bddc2f40SJasvinder Singh 
1390bddc2f40SJasvinder Singh cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile = {
1391bddc2f40SJasvinder Singh 	.f = cmd_add_port_tm_node_wred_profile_parsed,
1392bddc2f40SJasvinder Singh 	.data = NULL,
1393bddc2f40SJasvinder Singh 	.help_str = "Add port tm node wred profile",
1394bddc2f40SJasvinder Singh 	.tokens = {
1395bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_add,
1396bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_port,
1397bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_tm,
1398bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_node,
1399bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_wred,
1400bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_profile,
1401bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_port_id,
1402bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id,
1403bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_color_g,
1404bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_min_th_g,
1405bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_max_th_g,
1406bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g,
1407bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g,
1408bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_color_y,
1409bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_min_th_y,
1410bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_max_th_y,
1411bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y,
1412bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y,
1413bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_color_r,
1414bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_min_th_r,
1415bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_max_th_r,
1416bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r,
1417bddc2f40SJasvinder Singh 		(void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r,
1418bddc2f40SJasvinder Singh 		NULL,
1419bddc2f40SJasvinder Singh 	},
1420bddc2f40SJasvinder Singh };
1421bddc2f40SJasvinder Singh 
1422bddc2f40SJasvinder Singh /* *** Delete Port TM node WRED Profile *** */
1423bddc2f40SJasvinder Singh struct cmd_del_port_tm_node_wred_profile_result {
1424bddc2f40SJasvinder Singh 	cmdline_fixed_string_t del;
1425bddc2f40SJasvinder Singh 	cmdline_fixed_string_t port;
1426bddc2f40SJasvinder Singh 	cmdline_fixed_string_t tm;
1427bddc2f40SJasvinder Singh 	cmdline_fixed_string_t node;
1428bddc2f40SJasvinder Singh 	cmdline_fixed_string_t wred;
1429bddc2f40SJasvinder Singh 	cmdline_fixed_string_t profile;
1430bddc2f40SJasvinder Singh 	uint16_t port_id;
1431bddc2f40SJasvinder Singh 	uint32_t wred_profile_id;
1432bddc2f40SJasvinder Singh };
1433bddc2f40SJasvinder Singh 
1434ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del =
1435bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1436bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_wred_profile_result, del, "del");
1437ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port =
1438bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1439bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_wred_profile_result, port, "port");
1440ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm =
1441bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1442bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_wred_profile_result, tm, "tm");
1443ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node =
1444bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1445bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_wred_profile_result, node, "node");
1446ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred =
1447bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1448bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_wred_profile_result, wred, "wred");
1449ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile =
1450bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1451bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_wred_profile_result,
1452bddc2f40SJasvinder Singh 			profile, "profile");
1453ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id =
1454bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1455bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_wred_profile_result,
1456c2341bb6SDmitry Kozlyuk 			port_id, RTE_UINT16);
1457ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id =
1458bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1459bddc2f40SJasvinder Singh 		struct cmd_del_port_tm_node_wred_profile_result,
1460c2341bb6SDmitry Kozlyuk 			wred_profile_id, RTE_UINT32);
1461bddc2f40SJasvinder Singh 
1462bddc2f40SJasvinder Singh static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result,
1463f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
1464f2fc83b4SThomas Monjalon 	__rte_unused void *data)
1465bddc2f40SJasvinder Singh {
1466bddc2f40SJasvinder Singh 	struct cmd_del_port_tm_node_wred_profile_result *res = parsed_result;
1467bddc2f40SJasvinder Singh 	struct rte_tm_error error;
1468bddc2f40SJasvinder Singh 	uint32_t wred_profile_id = res->wred_profile_id;
1469bddc2f40SJasvinder Singh 	portid_t port_id = res->port_id;
1470bddc2f40SJasvinder Singh 	int ret;
1471bddc2f40SJasvinder Singh 
1472bddc2f40SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
1473bddc2f40SJasvinder Singh 		return;
1474bddc2f40SJasvinder Singh 
1475a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
1476bddc2f40SJasvinder Singh 	ret = rte_tm_wred_profile_delete(port_id, wred_profile_id, &error);
1477bddc2f40SJasvinder Singh 	if (ret != 0) {
1478bddc2f40SJasvinder Singh 		print_err_msg(&error);
1479bddc2f40SJasvinder Singh 		return;
1480bddc2f40SJasvinder Singh 	}
1481bddc2f40SJasvinder Singh }
1482bddc2f40SJasvinder Singh 
1483bddc2f40SJasvinder Singh cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile = {
1484bddc2f40SJasvinder Singh 	.f = cmd_del_port_tm_node_wred_profile_parsed,
1485bddc2f40SJasvinder Singh 	.data = NULL,
1486bddc2f40SJasvinder Singh 	.help_str = "Delete port tm node wred profile",
1487bddc2f40SJasvinder Singh 	.tokens = {
1488bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_wred_profile_del,
1489bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_wred_profile_port,
1490bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_wred_profile_tm,
1491bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_wred_profile_node,
1492bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_wred_profile_wred,
1493bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_wred_profile_profile,
1494bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_wred_profile_port_id,
1495bddc2f40SJasvinder Singh 		(void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id,
1496bddc2f40SJasvinder Singh 		NULL,
1497bddc2f40SJasvinder Singh 	},
1498bddc2f40SJasvinder Singh };
1499bddc2f40SJasvinder Singh 
1500bddc2f40SJasvinder Singh /* *** Update Port TM Node Shaper profile *** */
1501bddc2f40SJasvinder Singh struct cmd_set_port_tm_node_shaper_profile_result {
1502bddc2f40SJasvinder Singh 	cmdline_fixed_string_t set;
1503bddc2f40SJasvinder Singh 	cmdline_fixed_string_t port;
1504bddc2f40SJasvinder Singh 	cmdline_fixed_string_t tm;
1505bddc2f40SJasvinder Singh 	cmdline_fixed_string_t node;
1506bddc2f40SJasvinder Singh 	cmdline_fixed_string_t shaper;
1507bddc2f40SJasvinder Singh 	cmdline_fixed_string_t profile;
1508bddc2f40SJasvinder Singh 	uint16_t port_id;
1509bddc2f40SJasvinder Singh 	uint32_t node_id;
1510bddc2f40SJasvinder Singh 	uint32_t shaper_profile_id;
1511bddc2f40SJasvinder Singh };
1512bddc2f40SJasvinder Singh 
1513ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set =
1514bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1515bddc2f40SJasvinder Singh 		struct cmd_set_port_tm_node_shaper_profile_result, set, "set");
1516ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port =
1517bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1518bddc2f40SJasvinder Singh 		struct cmd_set_port_tm_node_shaper_profile_result,
1519bddc2f40SJasvinder Singh 			port, "port");
1520ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_tm =
1521bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1522bddc2f40SJasvinder Singh 		struct cmd_set_port_tm_node_shaper_profile_result, tm, "tm");
1523ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node =
1524bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1525bddc2f40SJasvinder Singh 		struct cmd_set_port_tm_node_shaper_profile_result,
1526bddc2f40SJasvinder Singh 			node, "node");
1527ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper =
1528bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1529bddc2f40SJasvinder Singh 		struct cmd_set_port_tm_node_shaper_profile_result,
1530bddc2f40SJasvinder Singh 			shaper, "shaper");
1531ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile =
1532bddc2f40SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1533bddc2f40SJasvinder Singh 		struct cmd_set_port_tm_node_shaper_profile_result,
1534bddc2f40SJasvinder Singh 			profile, "profile");
1535ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id =
1536bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1537bddc2f40SJasvinder Singh 		struct cmd_set_port_tm_node_shaper_profile_result,
1538c2341bb6SDmitry Kozlyuk 			port_id, RTE_UINT16);
1539ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id =
1540bddc2f40SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result,
1541c2341bb6SDmitry Kozlyuk 		node_id, RTE_UINT32);
1542ea0774ffSDavid Marchand static cmdline_parse_token_num_t
1543bddc2f40SJasvinder Singh 	cmd_set_port_tm_node_shaper_shaper_profile_profile_id =
1544bddc2f40SJasvinder Singh 		TOKEN_NUM_INITIALIZER(
1545bddc2f40SJasvinder Singh 			struct cmd_set_port_tm_node_shaper_profile_result,
1546c2341bb6SDmitry Kozlyuk 			shaper_profile_id, RTE_UINT32);
1547bddc2f40SJasvinder Singh 
1548bddc2f40SJasvinder Singh static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result,
1549f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
1550f2fc83b4SThomas Monjalon 	__rte_unused void *data)
1551bddc2f40SJasvinder Singh {
1552bddc2f40SJasvinder Singh 	struct cmd_set_port_tm_node_shaper_profile_result *res = parsed_result;
1553bddc2f40SJasvinder Singh 	struct rte_tm_error error;
1554bddc2f40SJasvinder Singh 	uint32_t node_id = res->node_id;
1555bddc2f40SJasvinder Singh 	uint32_t shaper_profile_id = res->shaper_profile_id;
1556bddc2f40SJasvinder Singh 	portid_t port_id = res->port_id;
1557bddc2f40SJasvinder Singh 	int ret;
1558bddc2f40SJasvinder Singh 
1559bddc2f40SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
1560bddc2f40SJasvinder Singh 		return;
1561bddc2f40SJasvinder Singh 
1562a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
1563bddc2f40SJasvinder Singh 	/* Port status */
1564bddc2f40SJasvinder Singh 	if (!port_is_started(port_id)) {
156561a3b0e5SAndrew Rybchenko 		fprintf(stderr, " Port %u not started (error)\n", port_id);
1566bddc2f40SJasvinder Singh 		return;
1567bddc2f40SJasvinder Singh 	}
1568bddc2f40SJasvinder Singh 
1569bddc2f40SJasvinder Singh 	ret = rte_tm_node_shaper_update(port_id, node_id,
1570bddc2f40SJasvinder Singh 		shaper_profile_id, &error);
1571bddc2f40SJasvinder Singh 	if (ret != 0) {
1572bddc2f40SJasvinder Singh 		print_err_msg(&error);
1573bddc2f40SJasvinder Singh 		return;
1574bddc2f40SJasvinder Singh 	}
1575bddc2f40SJasvinder Singh }
1576bddc2f40SJasvinder Singh 
1577bddc2f40SJasvinder Singh cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile = {
1578bddc2f40SJasvinder Singh 	.f = cmd_set_port_tm_node_shaper_profile_parsed,
1579bddc2f40SJasvinder Singh 	.data = NULL,
1580bddc2f40SJasvinder Singh 	.help_str = "Set port tm node shaper profile",
1581bddc2f40SJasvinder Singh 	.tokens = {
1582bddc2f40SJasvinder Singh 		(void *)&cmd_set_port_tm_node_shaper_profile_set,
1583bddc2f40SJasvinder Singh 		(void *)&cmd_set_port_tm_node_shaper_profile_port,
1584bddc2f40SJasvinder Singh 		(void *)&cmd_set_port_tm_node_shaper_profile_tm,
1585bddc2f40SJasvinder Singh 		(void *)&cmd_set_port_tm_node_shaper_profile_node,
1586bddc2f40SJasvinder Singh 		(void *)&cmd_set_port_tm_node_shaper_profile_shaper,
1587bddc2f40SJasvinder Singh 		(void *)&cmd_set_port_tm_node_shaper_profile_profile,
1588bddc2f40SJasvinder Singh 		(void *)&cmd_set_port_tm_node_shaper_profile_port_id,
1589bddc2f40SJasvinder Singh 		(void *)&cmd_set_port_tm_node_shaper_profile_node_id,
1590bddc2f40SJasvinder Singh 		(void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id,
1591bddc2f40SJasvinder Singh 		NULL,
1592bddc2f40SJasvinder Singh 	},
1593bddc2f40SJasvinder Singh };
1594996cb153SJasvinder Singh 
1595996cb153SJasvinder Singh /* *** Add Port TM nonleaf node *** */
1596996cb153SJasvinder Singh struct cmd_add_port_tm_nonleaf_node_result {
1597996cb153SJasvinder Singh 	cmdline_fixed_string_t add;
1598996cb153SJasvinder Singh 	cmdline_fixed_string_t port;
1599996cb153SJasvinder Singh 	cmdline_fixed_string_t tm;
1600996cb153SJasvinder Singh 	cmdline_fixed_string_t nonleaf;
1601996cb153SJasvinder Singh 	cmdline_fixed_string_t node;
1602996cb153SJasvinder Singh 	uint16_t port_id;
1603996cb153SJasvinder Singh 	uint32_t node_id;
1604996cb153SJasvinder Singh 	int32_t parent_node_id;
1605996cb153SJasvinder Singh 	uint32_t priority;
1606996cb153SJasvinder Singh 	uint32_t weight;
1607996cb153SJasvinder Singh 	uint32_t level_id;
160854fbcfc6STomasz Duszynski 	int32_t shaper_profile_id;
1609996cb153SJasvinder Singh 	uint32_t n_sp_priorities;
1610996cb153SJasvinder Singh 	uint64_t stats_mask;
1611996cb153SJasvinder Singh 	cmdline_multi_string_t multi_shared_shaper_id;
1612996cb153SJasvinder Singh };
1613996cb153SJasvinder Singh 
1614ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add =
1615996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1616996cb153SJasvinder Singh 		struct cmd_add_port_tm_nonleaf_node_result, add, "add");
1617ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port =
1618996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1619996cb153SJasvinder Singh 		struct cmd_add_port_tm_nonleaf_node_result, port, "port");
1620ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm =
1621996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1622996cb153SJasvinder Singh 		struct cmd_add_port_tm_nonleaf_node_result, tm, "tm");
1623ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf =
1624996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1625996cb153SJasvinder Singh 		struct cmd_add_port_tm_nonleaf_node_result, nonleaf, "nonleaf");
1626ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node =
1627996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1628996cb153SJasvinder Singh 		struct cmd_add_port_tm_nonleaf_node_result, node, "node");
1629ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id =
1630996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
1631996cb153SJasvinder Singh 		struct cmd_add_port_tm_nonleaf_node_result,
1632c2341bb6SDmitry Kozlyuk 		 port_id, RTE_UINT16);
1633ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_id =
1634996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1635c2341bb6SDmitry Kozlyuk 		 node_id, RTE_UINT32);
1636ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_parent_node_id =
1637996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1638c2341bb6SDmitry Kozlyuk 		 parent_node_id, RTE_INT32);
1639ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority =
1640996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1641c2341bb6SDmitry Kozlyuk 		 priority, RTE_UINT32);
1642ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight =
1643996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1644c2341bb6SDmitry Kozlyuk 		 weight, RTE_UINT32);
1645ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =
1646996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1647c2341bb6SDmitry Kozlyuk 		 level_id, RTE_UINT32);
1648ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id =
1649996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1650c2341bb6SDmitry Kozlyuk 		 shaper_profile_id, RTE_INT32);
1651ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =
1652996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1653c2341bb6SDmitry Kozlyuk 		 n_sp_priorities, RTE_UINT32);
1654ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask =
1655996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1656c2341bb6SDmitry Kozlyuk 		 stats_mask, RTE_UINT64);
1657ea0774ffSDavid Marchand static cmdline_parse_token_string_t
1658996cb153SJasvinder Singh 	cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id =
1659996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1660996cb153SJasvinder Singh 		 multi_shared_shaper_id, TOKEN_STRING_MULTI);
1661996cb153SJasvinder Singh 
1662996cb153SJasvinder Singh static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
166352e5e7c2SBruce Richardson 	struct cmdline *cl,
1664f2fc83b4SThomas Monjalon 	__rte_unused void *data)
1665996cb153SJasvinder Singh {
1666996cb153SJasvinder Singh 	struct cmd_add_port_tm_nonleaf_node_result *res = parsed_result;
1667996cb153SJasvinder Singh 	struct rte_tm_error error;
1668996cb153SJasvinder Singh 	struct rte_tm_node_params np;
1669996cb153SJasvinder Singh 	uint32_t *shared_shaper_id;
1670996cb153SJasvinder Singh 	uint32_t parent_node_id, n_shared_shapers = 0;
1671996cb153SJasvinder Singh 	char *s_str = res->multi_shared_shaper_id;
1672996cb153SJasvinder Singh 	portid_t port_id = res->port_id;
1673996cb153SJasvinder Singh 	int ret;
1674996cb153SJasvinder Singh 
1675996cb153SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
1676996cb153SJasvinder Singh 		return;
1677996cb153SJasvinder Singh 
1678996cb153SJasvinder Singh 	memset(&np, 0, sizeof(struct rte_tm_node_params));
1679a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
1680996cb153SJasvinder Singh 
1681996cb153SJasvinder Singh 	/* Node parameters */
1682996cb153SJasvinder Singh 	if (res->parent_node_id < 0)
1683996cb153SJasvinder Singh 		parent_node_id = UINT32_MAX;
1684996cb153SJasvinder Singh 	else
1685996cb153SJasvinder Singh 		parent_node_id = res->parent_node_id;
1686996cb153SJasvinder Singh 
168752e5e7c2SBruce Richardson 	if (parent_node_id != UINT32_MAX)
168852e5e7c2SBruce Richardson 		cmdline_printf(cl, "adding node on port %u, with id %u and parent node %u\n",
168952e5e7c2SBruce Richardson 				port_id, res->node_id, parent_node_id);
169052e5e7c2SBruce Richardson 	else
169152e5e7c2SBruce Richardson 		cmdline_printf(cl, "adding node on port %u, with id %u as root node\n",
169252e5e7c2SBruce Richardson 				port_id, res->node_id);
169352e5e7c2SBruce Richardson 	cmdline_printf(cl, "# priority: %u\n", res->priority);
169452e5e7c2SBruce Richardson 	cmdline_printf(cl, "# weight: %u\n", res->weight);
169552e5e7c2SBruce Richardson 	cmdline_printf(cl, "# level_id: %u\n", res->level_id);
169652e5e7c2SBruce Richardson 	cmdline_printf(cl, "# shaper_profile_id: %d\n", res->shaper_profile_id);
169752e5e7c2SBruce Richardson 	cmdline_printf(cl, "# num SP priorities: %u\n", res->n_sp_priorities);
169852e5e7c2SBruce Richardson 	cmdline_printf(cl, "# stats_mask: %"PRIx64"\n", res->stats_mask);
169952e5e7c2SBruce Richardson 	cmdline_printf(cl, "# shared shapers: '%s'\n", s_str);
170052e5e7c2SBruce Richardson 
1701996cb153SJasvinder Singh 	shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1702996cb153SJasvinder Singh 		sizeof(uint32_t));
17034f5dd001SJasvinder Singh 	if (shared_shaper_id == NULL) {
170461a3b0e5SAndrew Rybchenko 		fprintf(stderr,
170561a3b0e5SAndrew Rybchenko 			" Memory not allocated for shared shapers (error)\n");
17064f5dd001SJasvinder Singh 		return;
17074f5dd001SJasvinder Singh 	}
17084f5dd001SJasvinder Singh 
1709996cb153SJasvinder Singh 	/* Parse multi shared shaper id string */
1710996cb153SJasvinder Singh 	ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1711996cb153SJasvinder Singh 	if (ret) {
171261a3b0e5SAndrew Rybchenko 		fprintf(stderr, " Shared shapers params string parse error\n");
1713996cb153SJasvinder Singh 		free(shared_shaper_id);
1714996cb153SJasvinder Singh 		return;
1715996cb153SJasvinder Singh 	}
1716996cb153SJasvinder Singh 
171754fbcfc6STomasz Duszynski 	if (res->shaper_profile_id < 0)
171854fbcfc6STomasz Duszynski 		np.shaper_profile_id = UINT32_MAX;
171954fbcfc6STomasz Duszynski 	else
1720996cb153SJasvinder Singh 		np.shaper_profile_id = res->shaper_profile_id;
172154fbcfc6STomasz Duszynski 
1722996cb153SJasvinder Singh 	np.n_shared_shapers = n_shared_shapers;
1723b23ee8f2SNithin Dabilpuram 	if (np.n_shared_shapers) {
1724996cb153SJasvinder Singh 		np.shared_shaper_id = &shared_shaper_id[0];
1725b23ee8f2SNithin Dabilpuram 	} else {
1726b23ee8f2SNithin Dabilpuram 		free(shared_shaper_id);
1727b23ee8f2SNithin Dabilpuram 		shared_shaper_id = NULL;
1728b23ee8f2SNithin Dabilpuram 	}
1729996cb153SJasvinder Singh 
1730996cb153SJasvinder Singh 	np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1731996cb153SJasvinder Singh 	np.stats_mask = res->stats_mask;
1732996cb153SJasvinder Singh 	np.nonleaf.wfq_weight_mode = NULL;
1733996cb153SJasvinder Singh 
1734996cb153SJasvinder Singh 	ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1735996cb153SJasvinder Singh 				res->priority, res->weight, res->level_id,
1736996cb153SJasvinder Singh 				&np, &error);
1737996cb153SJasvinder Singh 	if (ret != 0) {
1738996cb153SJasvinder Singh 		print_err_msg(&error);
1739996cb153SJasvinder Singh 		free(shared_shaper_id);
1740996cb153SJasvinder Singh 		return;
1741996cb153SJasvinder Singh 	}
1742996cb153SJasvinder Singh }
1743996cb153SJasvinder Singh 
1744996cb153SJasvinder Singh cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node = {
1745996cb153SJasvinder Singh 	.f = cmd_add_port_tm_nonleaf_node_parsed,
1746996cb153SJasvinder Singh 	.data = NULL,
1747996cb153SJasvinder Singh 	.help_str = "Add port tm nonleaf node",
1748996cb153SJasvinder Singh 	.tokens = {
1749996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_add,
1750996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_port,
1751996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_tm,
1752996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_nonleaf,
1753996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_node,
1754996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_port_id,
1755996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_node_id,
1756996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_parent_node_id,
1757996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_priority,
1758996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_weight,
1759996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_level_id,
1760996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id,
1761996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities,
1762996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_stats_mask,
1763996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id,
1764996cb153SJasvinder Singh 		NULL,
1765996cb153SJasvinder Singh 	},
1766996cb153SJasvinder Singh };
1767996cb153SJasvinder Singh 
1768bb52561eSNithin Dabilpuram /* *** Add Port TM nonleaf node pkt mode *** */
1769bb52561eSNithin Dabilpuram struct cmd_add_port_tm_nonleaf_node_pmode_result {
1770bb52561eSNithin Dabilpuram 	cmdline_fixed_string_t add;
1771bb52561eSNithin Dabilpuram 	cmdline_fixed_string_t port;
1772bb52561eSNithin Dabilpuram 	cmdline_fixed_string_t tm;
1773bb52561eSNithin Dabilpuram 	cmdline_fixed_string_t nonleaf;
1774bb52561eSNithin Dabilpuram 	cmdline_fixed_string_t node;
1775bb52561eSNithin Dabilpuram 	uint16_t port_id;
1776bb52561eSNithin Dabilpuram 	uint32_t node_id;
1777bb52561eSNithin Dabilpuram 	int32_t parent_node_id;
1778bb52561eSNithin Dabilpuram 	uint32_t priority;
1779bb52561eSNithin Dabilpuram 	uint32_t weight;
1780bb52561eSNithin Dabilpuram 	uint32_t level_id;
1781bb52561eSNithin Dabilpuram 	int32_t shaper_profile_id;
1782bb52561eSNithin Dabilpuram 	uint32_t n_sp_priorities;
1783bb52561eSNithin Dabilpuram 	uint64_t stats_mask;
1784bb52561eSNithin Dabilpuram 	cmdline_multi_string_t multi_shared_shaper_id;
1785bb52561eSNithin Dabilpuram };
1786bb52561eSNithin Dabilpuram 
1787ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_add =
1788bb52561eSNithin Dabilpuram 	TOKEN_STRING_INITIALIZER(
1789bb52561eSNithin Dabilpuram 		struct cmd_add_port_tm_nonleaf_node_pmode_result, add, "add");
1790ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_port =
1791bb52561eSNithin Dabilpuram 	TOKEN_STRING_INITIALIZER(
1792bb52561eSNithin Dabilpuram 		struct cmd_add_port_tm_nonleaf_node_pmode_result, port, "port");
1793ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_tm =
1794bb52561eSNithin Dabilpuram 	TOKEN_STRING_INITIALIZER(
1795bb52561eSNithin Dabilpuram 		struct cmd_add_port_tm_nonleaf_node_pmode_result, tm, "tm");
1796ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_nonleaf =
1797bb52561eSNithin Dabilpuram 	TOKEN_STRING_INITIALIZER(
1798bb52561eSNithin Dabilpuram 		struct cmd_add_port_tm_nonleaf_node_pmode_result, nonleaf, "nonleaf");
1799ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_node =
1800bb52561eSNithin Dabilpuram 	TOKEN_STRING_INITIALIZER(
1801bb52561eSNithin Dabilpuram 		struct cmd_add_port_tm_nonleaf_node_pmode_result, node, "node");
1802ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_pktmode =
1803bb52561eSNithin Dabilpuram 	TOKEN_STRING_INITIALIZER(
1804bb52561eSNithin Dabilpuram 		struct cmd_add_port_tm_nonleaf_node_pmode_result, node, "pktmode");
1805ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_port_id =
1806bb52561eSNithin Dabilpuram 	TOKEN_NUM_INITIALIZER(
1807bb52561eSNithin Dabilpuram 		struct cmd_add_port_tm_nonleaf_node_pmode_result,
1808c2341bb6SDmitry Kozlyuk 		 port_id, RTE_UINT16);
1809ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_node_id =
1810bb52561eSNithin Dabilpuram 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1811c2341bb6SDmitry Kozlyuk 		 node_id, RTE_UINT32);
1812ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_parent_node_id =
1813bb52561eSNithin Dabilpuram 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1814c2341bb6SDmitry Kozlyuk 		 parent_node_id, RTE_INT32);
1815ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_priority =
1816bb52561eSNithin Dabilpuram 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1817c2341bb6SDmitry Kozlyuk 		 priority, RTE_UINT32);
1818ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_weight =
1819bb52561eSNithin Dabilpuram 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1820c2341bb6SDmitry Kozlyuk 		 weight, RTE_UINT32);
1821ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_level_id =
1822bb52561eSNithin Dabilpuram 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1823c2341bb6SDmitry Kozlyuk 		 level_id, RTE_UINT32);
1824ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_shaper_profile_id =
1825bb52561eSNithin Dabilpuram 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1826c2341bb6SDmitry Kozlyuk 		 shaper_profile_id, RTE_INT32);
1827ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_n_sp_priorities =
1828bb52561eSNithin Dabilpuram 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1829c2341bb6SDmitry Kozlyuk 		 n_sp_priorities, RTE_UINT32);
1830ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_stats_mask =
1831bb52561eSNithin Dabilpuram 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1832c2341bb6SDmitry Kozlyuk 		 stats_mask, RTE_UINT64);
1833ea0774ffSDavid Marchand static cmdline_parse_token_string_t
1834bb52561eSNithin Dabilpuram 	cmd_add_port_tm_nonleaf_node_pmode_multi_shrd_shpr_id =
1835bb52561eSNithin Dabilpuram 	TOKEN_STRING_INITIALIZER(
1836bb52561eSNithin Dabilpuram 			struct cmd_add_port_tm_nonleaf_node_pmode_result,
1837bb52561eSNithin Dabilpuram 			multi_shared_shaper_id, TOKEN_STRING_MULTI);
1838bb52561eSNithin Dabilpuram 
1839bb52561eSNithin Dabilpuram static void cmd_add_port_tm_nonleaf_node_pmode_parsed(void *parsed_result,
1840bb52561eSNithin Dabilpuram 	__rte_unused struct cmdline *cl,
1841bb52561eSNithin Dabilpuram 	__rte_unused void *data)
1842bb52561eSNithin Dabilpuram {
1843bb52561eSNithin Dabilpuram 	struct cmd_add_port_tm_nonleaf_node_pmode_result *res = parsed_result;
1844bb52561eSNithin Dabilpuram 	uint32_t parent_node_id, n_shared_shapers = 0;
1845bb52561eSNithin Dabilpuram 	char *s_str = res->multi_shared_shaper_id;
1846bb52561eSNithin Dabilpuram 	portid_t port_id = res->port_id;
1847bb52561eSNithin Dabilpuram 	struct rte_tm_node_params np;
1848bb52561eSNithin Dabilpuram 	int *wfq_weight_mode = NULL;
1849bb52561eSNithin Dabilpuram 	uint32_t *shared_shaper_id;
1850bb52561eSNithin Dabilpuram 	struct rte_tm_error error;
1851bb52561eSNithin Dabilpuram 	int ret;
1852bb52561eSNithin Dabilpuram 
1853bb52561eSNithin Dabilpuram 	if (port_id_is_invalid(port_id, ENABLED_WARN))
1854bb52561eSNithin Dabilpuram 		return;
1855bb52561eSNithin Dabilpuram 
1856bb52561eSNithin Dabilpuram 	memset(&np, 0, sizeof(struct rte_tm_node_params));
1857bb52561eSNithin Dabilpuram 	memset(&error, 0, sizeof(struct rte_tm_error));
1858bb52561eSNithin Dabilpuram 
1859bb52561eSNithin Dabilpuram 	/* Node parameters */
1860bb52561eSNithin Dabilpuram 	if (res->parent_node_id < 0)
1861bb52561eSNithin Dabilpuram 		parent_node_id = UINT32_MAX;
1862bb52561eSNithin Dabilpuram 	else
1863bb52561eSNithin Dabilpuram 		parent_node_id = res->parent_node_id;
1864bb52561eSNithin Dabilpuram 
1865bb52561eSNithin Dabilpuram 	shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1866bb52561eSNithin Dabilpuram 		sizeof(uint32_t));
1867bb52561eSNithin Dabilpuram 	if (shared_shaper_id == NULL) {
186861a3b0e5SAndrew Rybchenko 		fprintf(stderr,
186961a3b0e5SAndrew Rybchenko 			" Memory not allocated for shared shapers (error)\n");
1870bb52561eSNithin Dabilpuram 		return;
1871bb52561eSNithin Dabilpuram 	}
1872bb52561eSNithin Dabilpuram 
1873bb52561eSNithin Dabilpuram 	/* Parse multi shared shaper id string */
1874bb52561eSNithin Dabilpuram 	ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1875bb52561eSNithin Dabilpuram 	if (ret) {
187661a3b0e5SAndrew Rybchenko 		fprintf(stderr, " Shared shapers params string parse error\n");
1877bb52561eSNithin Dabilpuram 		free(shared_shaper_id);
1878bb52561eSNithin Dabilpuram 		return;
1879bb52561eSNithin Dabilpuram 	}
1880bb52561eSNithin Dabilpuram 
1881bb52561eSNithin Dabilpuram 	if (res->shaper_profile_id < 0)
1882bb52561eSNithin Dabilpuram 		np.shaper_profile_id = UINT32_MAX;
1883bb52561eSNithin Dabilpuram 	else
1884bb52561eSNithin Dabilpuram 		np.shaper_profile_id = res->shaper_profile_id;
1885bb52561eSNithin Dabilpuram 
1886bb52561eSNithin Dabilpuram 	np.n_shared_shapers = n_shared_shapers;
1887bb52561eSNithin Dabilpuram 	if (np.n_shared_shapers) {
1888bb52561eSNithin Dabilpuram 		np.shared_shaper_id = &shared_shaper_id[0];
1889bb52561eSNithin Dabilpuram 	} else {
1890bb52561eSNithin Dabilpuram 		free(shared_shaper_id);
1891bb52561eSNithin Dabilpuram 		shared_shaper_id = NULL;
1892bb52561eSNithin Dabilpuram 	}
1893bb52561eSNithin Dabilpuram 
1894bb52561eSNithin Dabilpuram 	if (res->n_sp_priorities)
1895bb52561eSNithin Dabilpuram 		wfq_weight_mode = calloc(res->n_sp_priorities, sizeof(int));
1896bb52561eSNithin Dabilpuram 	np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1897bb52561eSNithin Dabilpuram 	np.stats_mask = res->stats_mask;
1898bb52561eSNithin Dabilpuram 	np.nonleaf.wfq_weight_mode = wfq_weight_mode;
1899bb52561eSNithin Dabilpuram 
1900bb52561eSNithin Dabilpuram 	ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1901bb52561eSNithin Dabilpuram 				res->priority, res->weight, res->level_id,
1902bb52561eSNithin Dabilpuram 				&np, &error);
1903bb52561eSNithin Dabilpuram 	if (ret != 0) {
1904bb52561eSNithin Dabilpuram 		print_err_msg(&error);
1905bb52561eSNithin Dabilpuram 		free(shared_shaper_id);
1906bb52561eSNithin Dabilpuram 		free(wfq_weight_mode);
1907bb52561eSNithin Dabilpuram 		return;
1908bb52561eSNithin Dabilpuram 	}
1909bb52561eSNithin Dabilpuram }
1910bb52561eSNithin Dabilpuram 
1911bb52561eSNithin Dabilpuram cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node_pmode = {
1912bb52561eSNithin Dabilpuram 	.f = cmd_add_port_tm_nonleaf_node_pmode_parsed,
1913bb52561eSNithin Dabilpuram 	.data = NULL,
1914bb52561eSNithin Dabilpuram 	.help_str = "Add port tm nonleaf node pktmode",
1915bb52561eSNithin Dabilpuram 	.tokens = {
1916bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_add,
1917bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_port,
1918bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_tm,
1919bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_nonleaf,
1920bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_node,
1921bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_pktmode,
1922bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_port_id,
1923bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_node_id,
1924bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_parent_node_id,
1925bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_priority,
1926bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_weight,
1927bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_level_id,
1928bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_shaper_profile_id,
1929bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_n_sp_priorities,
1930bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_stats_mask,
1931bb52561eSNithin Dabilpuram 		(void *)&cmd_add_port_tm_nonleaf_node_pmode_multi_shrd_shpr_id,
1932bb52561eSNithin Dabilpuram 		NULL,
1933bb52561eSNithin Dabilpuram 	},
1934bb52561eSNithin Dabilpuram };
1935996cb153SJasvinder Singh /* *** Add Port TM leaf node *** */
1936996cb153SJasvinder Singh struct cmd_add_port_tm_leaf_node_result {
1937996cb153SJasvinder Singh 	cmdline_fixed_string_t add;
1938996cb153SJasvinder Singh 	cmdline_fixed_string_t port;
1939996cb153SJasvinder Singh 	cmdline_fixed_string_t tm;
1940996cb153SJasvinder Singh 	cmdline_fixed_string_t leaf;
1941996cb153SJasvinder Singh 	cmdline_fixed_string_t node;
1942996cb153SJasvinder Singh 	uint16_t port_id;
1943996cb153SJasvinder Singh 	uint32_t node_id;
1944996cb153SJasvinder Singh 	int32_t parent_node_id;
1945996cb153SJasvinder Singh 	uint32_t priority;
1946996cb153SJasvinder Singh 	uint32_t weight;
1947996cb153SJasvinder Singh 	uint32_t level_id;
194854fbcfc6STomasz Duszynski 	int32_t shaper_profile_id;
1949996cb153SJasvinder Singh 	uint32_t cman_mode;
1950996cb153SJasvinder Singh 	uint32_t wred_profile_id;
1951996cb153SJasvinder Singh 	uint64_t stats_mask;
1952996cb153SJasvinder Singh 	cmdline_multi_string_t multi_shared_shaper_id;
1953996cb153SJasvinder Singh };
1954996cb153SJasvinder Singh 
1955ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add =
1956996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1957996cb153SJasvinder Singh 		struct cmd_add_port_tm_leaf_node_result, add, "add");
1958ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port =
1959996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1960996cb153SJasvinder Singh 		struct cmd_add_port_tm_leaf_node_result, port, "port");
1961ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm =
1962996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1963996cb153SJasvinder Singh 		struct cmd_add_port_tm_leaf_node_result, tm, "tm");
1964ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf =
1965996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1966996cb153SJasvinder Singh 		struct cmd_add_port_tm_leaf_node_result, leaf, "leaf");
1967ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node =
1968996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
1969996cb153SJasvinder Singh 		struct cmd_add_port_tm_leaf_node_result, node, "node");
1970ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_id =
1971996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1972c2341bb6SDmitry Kozlyuk 		 port_id, RTE_UINT16);
1973ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_node_id =
1974996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1975c2341bb6SDmitry Kozlyuk 		 node_id, RTE_UINT32);
1976ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id =
1977996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1978c2341bb6SDmitry Kozlyuk 		 parent_node_id, RTE_INT32);
1979ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority =
1980996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1981c2341bb6SDmitry Kozlyuk 		 priority, RTE_UINT32);
1982ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight =
1983996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1984c2341bb6SDmitry Kozlyuk 		 weight, RTE_UINT32);
1985ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =
1986996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1987c2341bb6SDmitry Kozlyuk 		 level_id, RTE_UINT32);
1988ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =
1989996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1990c2341bb6SDmitry Kozlyuk 		 shaper_profile_id, RTE_INT32);
1991ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =
1992996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1993c2341bb6SDmitry Kozlyuk 		 cman_mode, RTE_UINT32);
1994ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id =
1995996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1996c2341bb6SDmitry Kozlyuk 		 wred_profile_id, RTE_UINT32);
1997ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask =
1998996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1999c2341bb6SDmitry Kozlyuk 		 stats_mask, RTE_UINT64);
2000ea0774ffSDavid Marchand static cmdline_parse_token_string_t
2001996cb153SJasvinder Singh 	cmd_add_port_tm_leaf_node_multi_shared_shaper_id =
2002996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
2003996cb153SJasvinder Singh 		 multi_shared_shaper_id, TOKEN_STRING_MULTI);
2004996cb153SJasvinder Singh 
2005996cb153SJasvinder Singh static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
200652e5e7c2SBruce Richardson 	struct cmdline *cl,
2007f2fc83b4SThomas Monjalon 	__rte_unused void *data)
2008996cb153SJasvinder Singh {
2009996cb153SJasvinder Singh 	struct cmd_add_port_tm_leaf_node_result *res = parsed_result;
2010996cb153SJasvinder Singh 	struct rte_tm_error error;
2011996cb153SJasvinder Singh 	struct rte_tm_node_params np;
2012996cb153SJasvinder Singh 	uint32_t *shared_shaper_id;
2013996cb153SJasvinder Singh 	uint32_t parent_node_id, n_shared_shapers = 0;
2014996cb153SJasvinder Singh 	portid_t port_id = res->port_id;
2015996cb153SJasvinder Singh 	char *s_str = res->multi_shared_shaper_id;
2016996cb153SJasvinder Singh 	int ret;
2017996cb153SJasvinder Singh 
2018996cb153SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
2019996cb153SJasvinder Singh 		return;
2020996cb153SJasvinder Singh 
2021996cb153SJasvinder Singh 	memset(&np, 0, sizeof(struct rte_tm_node_params));
2022a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
2023996cb153SJasvinder Singh 
2024996cb153SJasvinder Singh 	/* Node parameters */
2025996cb153SJasvinder Singh 	if (res->parent_node_id < 0)
2026996cb153SJasvinder Singh 		parent_node_id = UINT32_MAX;
2027996cb153SJasvinder Singh 	else
2028996cb153SJasvinder Singh 		parent_node_id = res->parent_node_id;
2029996cb153SJasvinder Singh 
203052e5e7c2SBruce Richardson 	if (parent_node_id != UINT32_MAX)
203152e5e7c2SBruce Richardson 		cmdline_printf(cl, "adding leaf node on port %u, with id %u and parent node %u\n",
203252e5e7c2SBruce Richardson 				port_id, res->node_id, parent_node_id);
203352e5e7c2SBruce Richardson 	else
203452e5e7c2SBruce Richardson 		cmdline_printf(cl, "adding leaf node on port %u, with id %u as root node\n",
203552e5e7c2SBruce Richardson 				port_id, res->node_id);
203652e5e7c2SBruce Richardson 	cmdline_printf(cl, "# priority: %u\n", res->priority);
203752e5e7c2SBruce Richardson 	cmdline_printf(cl, "# weight: %u\n", res->weight);
203852e5e7c2SBruce Richardson 	cmdline_printf(cl, "# level_id: %u\n", res->level_id);
203952e5e7c2SBruce Richardson 	cmdline_printf(cl, "# shaper_profile_id: %d\n", res->shaper_profile_id);
204052e5e7c2SBruce Richardson 	cmdline_printf(cl, "# cman_mode: %u\n", res->cman_mode);
204152e5e7c2SBruce Richardson 	cmdline_printf(cl, "# wred_profile_id: %d\n", res->wred_profile_id);
204252e5e7c2SBruce Richardson 	cmdline_printf(cl, "# stats_mask: %"PRIx64"\n", res->stats_mask);
204352e5e7c2SBruce Richardson 	cmdline_printf(cl, "# shared shapers: '%s'\n", s_str);
204452e5e7c2SBruce Richardson 
2045996cb153SJasvinder Singh 	shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
2046996cb153SJasvinder Singh 		sizeof(uint32_t));
20474f5dd001SJasvinder Singh 	if (shared_shaper_id == NULL) {
204861a3b0e5SAndrew Rybchenko 		fprintf(stderr,
204961a3b0e5SAndrew Rybchenko 			" Memory not allocated for shared shapers (error)\n");
20504f5dd001SJasvinder Singh 		return;
20514f5dd001SJasvinder Singh 	}
20524f5dd001SJasvinder Singh 
2053996cb153SJasvinder Singh 	/* Parse multi shared shaper id string */
2054996cb153SJasvinder Singh 	ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
2055996cb153SJasvinder Singh 	if (ret) {
205661a3b0e5SAndrew Rybchenko 		fprintf(stderr, " Shared shapers params string parse error\n");
2057996cb153SJasvinder Singh 		free(shared_shaper_id);
2058996cb153SJasvinder Singh 		return;
2059996cb153SJasvinder Singh 	}
2060996cb153SJasvinder Singh 
206154fbcfc6STomasz Duszynski 	if (res->shaper_profile_id < 0)
206254fbcfc6STomasz Duszynski 		np.shaper_profile_id = UINT32_MAX;
206354fbcfc6STomasz Duszynski 	else
2064996cb153SJasvinder Singh 		np.shaper_profile_id = res->shaper_profile_id;
206554fbcfc6STomasz Duszynski 
2066996cb153SJasvinder Singh 	np.n_shared_shapers = n_shared_shapers;
2067996cb153SJasvinder Singh 
2068b23ee8f2SNithin Dabilpuram 	if (np.n_shared_shapers) {
2069996cb153SJasvinder Singh 		np.shared_shaper_id = &shared_shaper_id[0];
2070b23ee8f2SNithin Dabilpuram 	} else {
2071b23ee8f2SNithin Dabilpuram 		free(shared_shaper_id);
2072b23ee8f2SNithin Dabilpuram 		shared_shaper_id = NULL;
2073b23ee8f2SNithin Dabilpuram 	}
2074996cb153SJasvinder Singh 
2075996cb153SJasvinder Singh 	np.leaf.cman = res->cman_mode;
2076996cb153SJasvinder Singh 	np.leaf.wred.wred_profile_id = res->wred_profile_id;
2077996cb153SJasvinder Singh 	np.stats_mask = res->stats_mask;
2078996cb153SJasvinder Singh 
2079996cb153SJasvinder Singh 	ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
2080996cb153SJasvinder Singh 				res->priority, res->weight, res->level_id,
2081996cb153SJasvinder Singh 				&np, &error);
2082996cb153SJasvinder Singh 	if (ret != 0) {
2083996cb153SJasvinder Singh 		print_err_msg(&error);
2084996cb153SJasvinder Singh 		free(shared_shaper_id);
2085996cb153SJasvinder Singh 		return;
2086996cb153SJasvinder Singh 	}
2087996cb153SJasvinder Singh }
2088996cb153SJasvinder Singh 
2089996cb153SJasvinder Singh cmdline_parse_inst_t cmd_add_port_tm_leaf_node = {
2090996cb153SJasvinder Singh 	.f = cmd_add_port_tm_leaf_node_parsed,
2091996cb153SJasvinder Singh 	.data = NULL,
2092996cb153SJasvinder Singh 	.help_str = "Add port tm leaf node",
2093996cb153SJasvinder Singh 	.tokens = {
2094996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_add,
2095996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_port,
2096996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_tm,
2097996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_nonleaf,
2098996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_node,
2099996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_port_id,
2100996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_node_id,
2101996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_parent_node_id,
2102996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_priority,
2103996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_weight,
2104996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_level_id,
2105996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_shaper_profile_id,
2106996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_cman_mode,
2107996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_wred_profile_id,
2108996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_stats_mask,
2109996cb153SJasvinder Singh 		(void *)&cmd_add_port_tm_leaf_node_multi_shared_shaper_id,
2110996cb153SJasvinder Singh 		NULL,
2111996cb153SJasvinder Singh 	},
2112996cb153SJasvinder Singh };
2113996cb153SJasvinder Singh 
2114*25a2a0dcSBruce Richardson struct cmd_show_port_tm_node_result {
2115*25a2a0dcSBruce Richardson 	cmdline_fixed_string_t show;
2116*25a2a0dcSBruce Richardson 	cmdline_fixed_string_t port;
2117*25a2a0dcSBruce Richardson 	cmdline_fixed_string_t tm;
2118*25a2a0dcSBruce Richardson 	cmdline_fixed_string_t node;
2119*25a2a0dcSBruce Richardson 	uint16_t port_id;
2120*25a2a0dcSBruce Richardson 	uint32_t node_id;
2121*25a2a0dcSBruce Richardson };
2122*25a2a0dcSBruce Richardson 
2123*25a2a0dcSBruce Richardson static cmdline_parse_token_string_t cmd_show_port_tm_node_show_tok =
2124*25a2a0dcSBruce Richardson 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, show, "show");
2125*25a2a0dcSBruce Richardson static cmdline_parse_token_string_t cmd_show_port_tm_node_port_tok =
2126*25a2a0dcSBruce Richardson 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, port, "port");
2127*25a2a0dcSBruce Richardson static cmdline_parse_token_string_t cmd_show_port_tm_node_tm_tok =
2128*25a2a0dcSBruce Richardson 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, tm, "tm");
2129*25a2a0dcSBruce Richardson static cmdline_parse_token_string_t cmd_show_port_tm_node_node_tok =
2130*25a2a0dcSBruce Richardson 	TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, node, "node");
2131*25a2a0dcSBruce Richardson static cmdline_parse_token_num_t cmd_show_port_tm_node_port_id_tok =
2132*25a2a0dcSBruce Richardson 	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_result, port_id, RTE_UINT16);
2133*25a2a0dcSBruce Richardson static cmdline_parse_token_num_t cmd_show_port_tm_node_node_id_tok =
2134*25a2a0dcSBruce Richardson 	TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_result, node_id, RTE_UINT32);
2135*25a2a0dcSBruce Richardson 
2136*25a2a0dcSBruce Richardson static void
2137*25a2a0dcSBruce Richardson cmd_show_port_tm_node_parsed(void *parsed_result, struct cmdline *cl, void *data __rte_unused)
2138*25a2a0dcSBruce Richardson {
2139*25a2a0dcSBruce Richardson 	const struct cmd_show_port_tm_node_result *res = parsed_result;
2140*25a2a0dcSBruce Richardson 	const portid_t port_id = res->port_id;
2141*25a2a0dcSBruce Richardson 	const uint32_t node_id = res->node_id;
2142*25a2a0dcSBruce Richardson 	struct rte_tm_node_params params = {0};
2143*25a2a0dcSBruce Richardson 	struct rte_tm_error error = {0};
2144*25a2a0dcSBruce Richardson 	uint32_t parent_id, priority, weight, level_id;
2145*25a2a0dcSBruce Richardson 	int is_leaf;
2146*25a2a0dcSBruce Richardson 	int ret;
2147*25a2a0dcSBruce Richardson 
2148*25a2a0dcSBruce Richardson 	if (port_id_is_invalid(port_id, ENABLED_WARN))
2149*25a2a0dcSBruce Richardson 		return;
2150*25a2a0dcSBruce Richardson 
2151*25a2a0dcSBruce Richardson 	ret = rte_tm_node_query(port_id, node_id,
2152*25a2a0dcSBruce Richardson 			&parent_id, &priority, &weight, &level_id, &params, &error);
2153*25a2a0dcSBruce Richardson 	if (ret != 0) {
2154*25a2a0dcSBruce Richardson 		print_err_msg(&error);
2155*25a2a0dcSBruce Richardson 		return;
2156*25a2a0dcSBruce Richardson 	}
2157*25a2a0dcSBruce Richardson 
2158*25a2a0dcSBruce Richardson 	ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
2159*25a2a0dcSBruce Richardson 	if (ret != 0) {
2160*25a2a0dcSBruce Richardson 		print_err_msg(&error);
2161*25a2a0dcSBruce Richardson 		return;
2162*25a2a0dcSBruce Richardson 	}
2163*25a2a0dcSBruce Richardson 
2164*25a2a0dcSBruce Richardson 	cmdline_printf(cl, "Port %u TM Node %u\n", port_id, node_id);
2165*25a2a0dcSBruce Richardson 	if (parent_id == RTE_TM_NODE_ID_NULL)
2166*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "  Parent Node ID: <NULL>\n");
2167*25a2a0dcSBruce Richardson 	else
2168*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "  Parent Node ID: %d\n", parent_id);
2169*25a2a0dcSBruce Richardson 	cmdline_printf(cl, "  Level ID: %u\n", level_id);
2170*25a2a0dcSBruce Richardson 	cmdline_printf(cl, "  Priority: %u\n", priority);
2171*25a2a0dcSBruce Richardson 	cmdline_printf(cl, "  Weight: %u\n", weight);
2172*25a2a0dcSBruce Richardson 	if (params.shaper_profile_id == RTE_TM_SHAPER_PROFILE_ID_NONE)
2173*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "  Shaper Profile ID: <none>\n");
2174*25a2a0dcSBruce Richardson 	else
2175*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "  Shaper Profile ID: %d\n", params.shaper_profile_id);
2176*25a2a0dcSBruce Richardson 	cmdline_printf(cl, "  Shared Shaper IDs: ");
2177*25a2a0dcSBruce Richardson 	if (params.n_shared_shapers == 0)
2178*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "<none>\n");
2179*25a2a0dcSBruce Richardson 	else {
2180*25a2a0dcSBruce Richardson 		for (uint32_t i = 0; i < params.n_shared_shapers; i++)
2181*25a2a0dcSBruce Richardson 			cmdline_printf(cl, "%u ", params.shared_shaper_id[i]);
2182*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "\n");
2183*25a2a0dcSBruce Richardson 	}
2184*25a2a0dcSBruce Richardson 	cmdline_printf(cl, "  Stats Mask: %"PRIu64"\n", params.stats_mask);
2185*25a2a0dcSBruce Richardson 	if (is_leaf) {
2186*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "  Leaf Node Parameters\n");
2187*25a2a0dcSBruce Richardson 		switch (params.leaf.cman) {
2188*25a2a0dcSBruce Richardson 		case RTE_TM_CMAN_TAIL_DROP:
2189*25a2a0dcSBruce Richardson 			cmdline_printf(cl, "    CMAN Mode: Tail Drop\n");
2190*25a2a0dcSBruce Richardson 			break;
2191*25a2a0dcSBruce Richardson 		case RTE_TM_CMAN_HEAD_DROP:
2192*25a2a0dcSBruce Richardson 			cmdline_printf(cl, "    CMAN Mode: Head Drop\n");
2193*25a2a0dcSBruce Richardson 			break;
2194*25a2a0dcSBruce Richardson 		case RTE_TM_CMAN_WRED:
2195*25a2a0dcSBruce Richardson 			cmdline_printf(cl, "    CMAN Mode: WRED\n");
2196*25a2a0dcSBruce Richardson 			break;
2197*25a2a0dcSBruce Richardson 		}
2198*25a2a0dcSBruce Richardson 		if (params.leaf.wred.wred_profile_id == RTE_TM_WRED_PROFILE_ID_NONE)
2199*25a2a0dcSBruce Richardson 			cmdline_printf(cl, "    WRED Profile ID: <none>\n");
2200*25a2a0dcSBruce Richardson 		else
2201*25a2a0dcSBruce Richardson 			cmdline_printf(cl, "    WRED Profile ID: %u\n",
2202*25a2a0dcSBruce Richardson 					params.leaf.wred.wred_profile_id);
2203*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "    Shared WRED Context Ids: ");
2204*25a2a0dcSBruce Richardson 		if (params.leaf.wred.n_shared_wred_contexts == 0)
2205*25a2a0dcSBruce Richardson 			cmdline_printf(cl, "<none>\n");
2206*25a2a0dcSBruce Richardson 		else {
2207*25a2a0dcSBruce Richardson 			for (uint32_t i = 0; i < params.leaf.wred.n_shared_wred_contexts; i++)
2208*25a2a0dcSBruce Richardson 				cmdline_printf(cl, "%u ",
2209*25a2a0dcSBruce Richardson 						params.leaf.wred.shared_wred_context_id[i]);
2210*25a2a0dcSBruce Richardson 			cmdline_printf(cl, "\n");
2211*25a2a0dcSBruce Richardson 		}
2212*25a2a0dcSBruce Richardson 	} else {
2213*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "  Nonleaf Node Parameters\n");
2214*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "    Num Strict Priorities: %u\n",
2215*25a2a0dcSBruce Richardson 				params.nonleaf.n_sp_priorities);
2216*25a2a0dcSBruce Richardson 		cmdline_printf(cl, "    WFQ Weights Mode: ");
2217*25a2a0dcSBruce Richardson 		if (params.nonleaf.wfq_weight_mode == NULL)
2218*25a2a0dcSBruce Richardson 			cmdline_printf(cl, "WFQ\n");
2219*25a2a0dcSBruce Richardson 		else {
2220*25a2a0dcSBruce Richardson 			for (uint32_t i = 0; i < params.nonleaf.n_sp_priorities; i++)
2221*25a2a0dcSBruce Richardson 				cmdline_printf(cl, "%s(%d) ",
2222*25a2a0dcSBruce Richardson 					params.nonleaf.wfq_weight_mode[i] ? "Bytes" : "Packet",
2223*25a2a0dcSBruce Richardson 					params.nonleaf.wfq_weight_mode[i]);
2224*25a2a0dcSBruce Richardson 			cmdline_printf(cl, "\n");
2225*25a2a0dcSBruce Richardson 		}
2226*25a2a0dcSBruce Richardson 	}
2227*25a2a0dcSBruce Richardson }
2228*25a2a0dcSBruce Richardson 
2229*25a2a0dcSBruce Richardson 
2230*25a2a0dcSBruce Richardson cmdline_parse_inst_t cmd_show_port_tm_node = {
2231*25a2a0dcSBruce Richardson 	.f = cmd_show_port_tm_node_parsed,
2232*25a2a0dcSBruce Richardson 	.data = NULL,
2233*25a2a0dcSBruce Richardson 	.help_str = "",
2234*25a2a0dcSBruce Richardson 	.tokens = {
2235*25a2a0dcSBruce Richardson 		(void *)&cmd_show_port_tm_node_show_tok,
2236*25a2a0dcSBruce Richardson 		(void *)&cmd_show_port_tm_node_port_tok,
2237*25a2a0dcSBruce Richardson 		(void *)&cmd_show_port_tm_node_tm_tok,
2238*25a2a0dcSBruce Richardson 		(void *)&cmd_show_port_tm_node_node_tok,
2239*25a2a0dcSBruce Richardson 		(void *)&cmd_show_port_tm_node_port_id_tok,
2240*25a2a0dcSBruce Richardson 		(void *)&cmd_show_port_tm_node_node_id_tok,
2241*25a2a0dcSBruce Richardson 		NULL,
2242*25a2a0dcSBruce Richardson 	}
2243*25a2a0dcSBruce Richardson };
2244*25a2a0dcSBruce Richardson 
2245996cb153SJasvinder Singh /* *** Delete Port TM Node *** */
2246996cb153SJasvinder Singh struct cmd_del_port_tm_node_result {
2247996cb153SJasvinder Singh 	cmdline_fixed_string_t del;
2248996cb153SJasvinder Singh 	cmdline_fixed_string_t port;
2249996cb153SJasvinder Singh 	cmdline_fixed_string_t tm;
2250996cb153SJasvinder Singh 	cmdline_fixed_string_t node;
2251996cb153SJasvinder Singh 	uint16_t port_id;
2252996cb153SJasvinder Singh 	uint32_t node_id;
2253996cb153SJasvinder Singh };
2254996cb153SJasvinder Singh 
2255ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_del =
2256996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2257996cb153SJasvinder Singh 		struct cmd_del_port_tm_node_result, del, "del");
2258ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_port =
2259996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2260996cb153SJasvinder Singh 		struct cmd_del_port_tm_node_result, port, "port");
2261ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_tm =
2262996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2263996cb153SJasvinder Singh 		struct cmd_del_port_tm_node_result, tm, "tm");
2264ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_del_port_tm_node_node =
2265996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2266996cb153SJasvinder Singh 		struct cmd_del_port_tm_node_result, node, "node");
2267ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_del_port_tm_node_port_id =
2268996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
2269c2341bb6SDmitry Kozlyuk 		 port_id, RTE_UINT16);
2270ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_del_port_tm_node_node_id =
2271996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
2272c2341bb6SDmitry Kozlyuk 		node_id, RTE_UINT32);
2273996cb153SJasvinder Singh 
2274996cb153SJasvinder Singh static void cmd_del_port_tm_node_parsed(void *parsed_result,
2275f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
2276f2fc83b4SThomas Monjalon 	__rte_unused void *data)
2277996cb153SJasvinder Singh {
2278996cb153SJasvinder Singh 	struct cmd_del_port_tm_node_result *res = parsed_result;
2279996cb153SJasvinder Singh 	struct rte_tm_error error;
2280996cb153SJasvinder Singh 	uint32_t node_id = res->node_id;
2281996cb153SJasvinder Singh 	portid_t port_id = res->port_id;
2282996cb153SJasvinder Singh 	int ret;
2283996cb153SJasvinder Singh 
2284996cb153SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
2285996cb153SJasvinder Singh 		return;
2286996cb153SJasvinder Singh 
2287a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
2288996cb153SJasvinder Singh 	/* Port status */
2289996cb153SJasvinder Singh 	if (port_is_started(port_id)) {
229061a3b0e5SAndrew Rybchenko 		fprintf(stderr, " Port %u not stopped (error)\n", port_id);
2291996cb153SJasvinder Singh 		return;
2292996cb153SJasvinder Singh 	}
2293996cb153SJasvinder Singh 
2294996cb153SJasvinder Singh 	ret = rte_tm_node_delete(port_id, node_id, &error);
2295996cb153SJasvinder Singh 	if (ret != 0) {
2296996cb153SJasvinder Singh 		print_err_msg(&error);
2297996cb153SJasvinder Singh 		return;
2298996cb153SJasvinder Singh 	}
2299996cb153SJasvinder Singh }
2300996cb153SJasvinder Singh 
2301996cb153SJasvinder Singh cmdline_parse_inst_t cmd_del_port_tm_node = {
2302996cb153SJasvinder Singh 	.f = cmd_del_port_tm_node_parsed,
2303996cb153SJasvinder Singh 	.data = NULL,
2304996cb153SJasvinder Singh 	.help_str = "Delete port tm node",
2305996cb153SJasvinder Singh 	.tokens = {
2306996cb153SJasvinder Singh 		(void *)&cmd_del_port_tm_node_del,
2307996cb153SJasvinder Singh 		(void *)&cmd_del_port_tm_node_port,
2308996cb153SJasvinder Singh 		(void *)&cmd_del_port_tm_node_tm,
2309996cb153SJasvinder Singh 		(void *)&cmd_del_port_tm_node_node,
2310996cb153SJasvinder Singh 		(void *)&cmd_del_port_tm_node_port_id,
2311996cb153SJasvinder Singh 		(void *)&cmd_del_port_tm_node_node_id,
2312996cb153SJasvinder Singh 		NULL,
2313996cb153SJasvinder Singh 	},
2314996cb153SJasvinder Singh };
2315996cb153SJasvinder Singh 
2316996cb153SJasvinder Singh /* *** Update Port TM Node Parent *** */
2317996cb153SJasvinder Singh struct cmd_set_port_tm_node_parent_result {
2318996cb153SJasvinder Singh 	cmdline_fixed_string_t set;
2319996cb153SJasvinder Singh 	cmdline_fixed_string_t port;
2320996cb153SJasvinder Singh 	cmdline_fixed_string_t tm;
2321996cb153SJasvinder Singh 	cmdline_fixed_string_t node;
2322996cb153SJasvinder Singh 	cmdline_fixed_string_t parent;
2323996cb153SJasvinder Singh 	uint16_t port_id;
2324996cb153SJasvinder Singh 	uint32_t node_id;
2325996cb153SJasvinder Singh 	uint32_t parent_id;
2326996cb153SJasvinder Singh 	uint32_t priority;
2327996cb153SJasvinder Singh 	uint32_t weight;
2328996cb153SJasvinder Singh };
2329996cb153SJasvinder Singh 
2330ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set =
2331996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2332996cb153SJasvinder Singh 		struct cmd_set_port_tm_node_parent_result, set, "set");
2333ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port =
2334996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2335996cb153SJasvinder Singh 		struct cmd_set_port_tm_node_parent_result, port, "port");
2336ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm =
2337996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2338996cb153SJasvinder Singh 		struct cmd_set_port_tm_node_parent_result, tm, "tm");
2339ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node =
2340996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2341996cb153SJasvinder Singh 		struct cmd_set_port_tm_node_parent_result, node, "node");
2342ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent =
2343996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2344996cb153SJasvinder Singh 		struct cmd_set_port_tm_node_parent_result, parent, "parent");
2345ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id =
2346996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
2347c2341bb6SDmitry Kozlyuk 		struct cmd_set_port_tm_node_parent_result, port_id,
2348c2341bb6SDmitry Kozlyuk 		RTE_UINT16);
2349ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id =
2350996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
2351c2341bb6SDmitry Kozlyuk 		struct cmd_set_port_tm_node_parent_result, node_id,
2352c2341bb6SDmitry Kozlyuk 		RTE_UINT32);
2353ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id =
2354996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2355c2341bb6SDmitry Kozlyuk 		parent_id, RTE_UINT32);
2356ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority =
2357996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2358c2341bb6SDmitry Kozlyuk 		priority, RTE_UINT32);
2359ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight =
2360996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2361c2341bb6SDmitry Kozlyuk 		weight, RTE_UINT32);
2362996cb153SJasvinder Singh 
2363996cb153SJasvinder Singh static void cmd_set_port_tm_node_parent_parsed(void *parsed_result,
2364f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
2365f2fc83b4SThomas Monjalon 	__rte_unused void *data)
2366996cb153SJasvinder Singh {
2367996cb153SJasvinder Singh 	struct cmd_set_port_tm_node_parent_result *res = parsed_result;
2368996cb153SJasvinder Singh 	struct rte_tm_error error;
2369996cb153SJasvinder Singh 	uint32_t node_id = res->node_id;
2370996cb153SJasvinder Singh 	uint32_t parent_id = res->parent_id;
2371996cb153SJasvinder Singh 	uint32_t priority = res->priority;
2372996cb153SJasvinder Singh 	uint32_t weight = res->weight;
2373996cb153SJasvinder Singh 	portid_t port_id = res->port_id;
2374996cb153SJasvinder Singh 	int ret;
2375996cb153SJasvinder Singh 
2376996cb153SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
2377996cb153SJasvinder Singh 		return;
2378996cb153SJasvinder Singh 
2379a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
2380996cb153SJasvinder Singh 	/* Port status */
2381996cb153SJasvinder Singh 	if (!port_is_started(port_id)) {
238261a3b0e5SAndrew Rybchenko 		fprintf(stderr, " Port %u not started (error)\n", port_id);
2383996cb153SJasvinder Singh 		return;
2384996cb153SJasvinder Singh 	}
2385996cb153SJasvinder Singh 
2386996cb153SJasvinder Singh 	ret = rte_tm_node_parent_update(port_id, node_id,
2387996cb153SJasvinder Singh 		parent_id, priority, weight, &error);
2388996cb153SJasvinder Singh 	if (ret != 0) {
2389996cb153SJasvinder Singh 		print_err_msg(&error);
2390996cb153SJasvinder Singh 		return;
2391996cb153SJasvinder Singh 	}
2392996cb153SJasvinder Singh }
2393996cb153SJasvinder Singh 
2394996cb153SJasvinder Singh cmdline_parse_inst_t cmd_set_port_tm_node_parent = {
2395996cb153SJasvinder Singh 	.f = cmd_set_port_tm_node_parent_parsed,
2396996cb153SJasvinder Singh 	.data = NULL,
2397996cb153SJasvinder Singh 	.help_str = "Set port tm node parent",
2398996cb153SJasvinder Singh 	.tokens = {
2399996cb153SJasvinder Singh 		(void *)&cmd_set_port_tm_node_parent_set,
2400996cb153SJasvinder Singh 		(void *)&cmd_set_port_tm_node_parent_port,
2401996cb153SJasvinder Singh 		(void *)&cmd_set_port_tm_node_parent_tm,
2402996cb153SJasvinder Singh 		(void *)&cmd_set_port_tm_node_parent_node,
2403996cb153SJasvinder Singh 		(void *)&cmd_set_port_tm_node_parent_parent,
2404996cb153SJasvinder Singh 		(void *)&cmd_set_port_tm_node_parent_port_id,
2405996cb153SJasvinder Singh 		(void *)&cmd_set_port_tm_node_parent_node_id,
2406996cb153SJasvinder Singh 		(void *)&cmd_set_port_tm_node_parent_parent_id,
2407996cb153SJasvinder Singh 		(void *)&cmd_set_port_tm_node_parent_priority,
2408996cb153SJasvinder Singh 		(void *)&cmd_set_port_tm_node_parent_weight,
2409996cb153SJasvinder Singh 		NULL,
2410996cb153SJasvinder Singh 	},
2411996cb153SJasvinder Singh };
2412996cb153SJasvinder Singh 
2413079dcbb8STomasz Duszynski /* *** Suspend Port TM Node *** */
2414079dcbb8STomasz Duszynski struct cmd_suspend_port_tm_node_result {
2415079dcbb8STomasz Duszynski 	cmdline_fixed_string_t suspend;
2416079dcbb8STomasz Duszynski 	cmdline_fixed_string_t port;
2417079dcbb8STomasz Duszynski 	cmdline_fixed_string_t tm;
2418079dcbb8STomasz Duszynski 	cmdline_fixed_string_t node;
2419079dcbb8STomasz Duszynski 	uint16_t port_id;
2420079dcbb8STomasz Duszynski 	uint32_t node_id;
2421079dcbb8STomasz Duszynski };
2422079dcbb8STomasz Duszynski 
2423ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_suspend_port_tm_node_suspend =
2424079dcbb8STomasz Duszynski 	TOKEN_STRING_INITIALIZER(
2425079dcbb8STomasz Duszynski 		struct cmd_suspend_port_tm_node_result, suspend, "suspend");
2426ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_suspend_port_tm_node_port =
2427079dcbb8STomasz Duszynski 	TOKEN_STRING_INITIALIZER(
2428079dcbb8STomasz Duszynski 		struct cmd_suspend_port_tm_node_result, port, "port");
2429ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_suspend_port_tm_node_tm =
2430079dcbb8STomasz Duszynski 	TOKEN_STRING_INITIALIZER(
2431079dcbb8STomasz Duszynski 		struct cmd_suspend_port_tm_node_result, tm, "tm");
2432ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_suspend_port_tm_node_node =
2433079dcbb8STomasz Duszynski 	TOKEN_STRING_INITIALIZER(
2434079dcbb8STomasz Duszynski 		struct cmd_suspend_port_tm_node_result, node, "node");
2435ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_suspend_port_tm_node_port_id =
2436079dcbb8STomasz Duszynski 	TOKEN_NUM_INITIALIZER(
2437c2341bb6SDmitry Kozlyuk 		struct cmd_suspend_port_tm_node_result, port_id,
2438c2341bb6SDmitry Kozlyuk 		RTE_UINT16);
2439ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_suspend_port_tm_node_node_id =
2440079dcbb8STomasz Duszynski 	TOKEN_NUM_INITIALIZER(
2441c2341bb6SDmitry Kozlyuk 		struct cmd_suspend_port_tm_node_result, node_id,
2442c2341bb6SDmitry Kozlyuk 		RTE_UINT32);
2443079dcbb8STomasz Duszynski 
2444079dcbb8STomasz Duszynski static void cmd_suspend_port_tm_node_parsed(void *parsed_result,
2445f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
2446f2fc83b4SThomas Monjalon 	__rte_unused void *data)
2447079dcbb8STomasz Duszynski {
2448079dcbb8STomasz Duszynski 	struct cmd_suspend_port_tm_node_result *res = parsed_result;
2449079dcbb8STomasz Duszynski 	struct rte_tm_error error;
2450079dcbb8STomasz Duszynski 	uint32_t node_id = res->node_id;
2451079dcbb8STomasz Duszynski 	portid_t port_id = res->port_id;
2452079dcbb8STomasz Duszynski 	int ret;
2453079dcbb8STomasz Duszynski 
2454079dcbb8STomasz Duszynski 	if (port_id_is_invalid(port_id, ENABLED_WARN))
2455079dcbb8STomasz Duszynski 		return;
2456079dcbb8STomasz Duszynski 
2457a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
2458079dcbb8STomasz Duszynski 	ret = rte_tm_node_suspend(port_id, node_id, &error);
2459079dcbb8STomasz Duszynski 	if (ret != 0) {
2460079dcbb8STomasz Duszynski 		print_err_msg(&error);
2461079dcbb8STomasz Duszynski 		return;
2462079dcbb8STomasz Duszynski 	}
2463079dcbb8STomasz Duszynski }
2464079dcbb8STomasz Duszynski 
2465079dcbb8STomasz Duszynski cmdline_parse_inst_t cmd_suspend_port_tm_node = {
2466079dcbb8STomasz Duszynski 	.f = cmd_suspend_port_tm_node_parsed,
2467079dcbb8STomasz Duszynski 	.data = NULL,
2468079dcbb8STomasz Duszynski 	.help_str = "Suspend port tm node",
2469079dcbb8STomasz Duszynski 	.tokens = {
2470079dcbb8STomasz Duszynski 		(void *)&cmd_suspend_port_tm_node_suspend,
2471079dcbb8STomasz Duszynski 		(void *)&cmd_suspend_port_tm_node_port,
2472079dcbb8STomasz Duszynski 		(void *)&cmd_suspend_port_tm_node_tm,
2473079dcbb8STomasz Duszynski 		(void *)&cmd_suspend_port_tm_node_node,
2474079dcbb8STomasz Duszynski 		(void *)&cmd_suspend_port_tm_node_port_id,
2475079dcbb8STomasz Duszynski 		(void *)&cmd_suspend_port_tm_node_node_id,
2476079dcbb8STomasz Duszynski 		NULL,
2477079dcbb8STomasz Duszynski 	},
2478079dcbb8STomasz Duszynski };
2479079dcbb8STomasz Duszynski 
248012f76f52STomasz Duszynski /* *** Resume Port TM Node *** */
248112f76f52STomasz Duszynski struct cmd_resume_port_tm_node_result {
248212f76f52STomasz Duszynski 	cmdline_fixed_string_t resume;
248312f76f52STomasz Duszynski 	cmdline_fixed_string_t port;
248412f76f52STomasz Duszynski 	cmdline_fixed_string_t tm;
248512f76f52STomasz Duszynski 	cmdline_fixed_string_t node;
248612f76f52STomasz Duszynski 	uint16_t port_id;
248712f76f52STomasz Duszynski 	uint32_t node_id;
248812f76f52STomasz Duszynski };
248912f76f52STomasz Duszynski 
2490ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_resume_port_tm_node_resume =
249112f76f52STomasz Duszynski 	TOKEN_STRING_INITIALIZER(
249212f76f52STomasz Duszynski 		struct cmd_resume_port_tm_node_result, resume, "resume");
2493ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_resume_port_tm_node_port =
249412f76f52STomasz Duszynski 	TOKEN_STRING_INITIALIZER(
249512f76f52STomasz Duszynski 		struct cmd_resume_port_tm_node_result, port, "port");
2496ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_resume_port_tm_node_tm =
249712f76f52STomasz Duszynski 	TOKEN_STRING_INITIALIZER(
249812f76f52STomasz Duszynski 		struct cmd_resume_port_tm_node_result, tm, "tm");
2499ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_resume_port_tm_node_node =
250012f76f52STomasz Duszynski 	TOKEN_STRING_INITIALIZER(
250112f76f52STomasz Duszynski 		struct cmd_resume_port_tm_node_result, node, "node");
2502ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_resume_port_tm_node_port_id =
250312f76f52STomasz Duszynski 	TOKEN_NUM_INITIALIZER(
2504c2341bb6SDmitry Kozlyuk 		struct cmd_resume_port_tm_node_result, port_id, RTE_UINT16);
2505ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_resume_port_tm_node_node_id =
250612f76f52STomasz Duszynski 	TOKEN_NUM_INITIALIZER(
2507c2341bb6SDmitry Kozlyuk 		struct cmd_resume_port_tm_node_result, node_id, RTE_UINT32);
250812f76f52STomasz Duszynski 
250912f76f52STomasz Duszynski static void cmd_resume_port_tm_node_parsed(void *parsed_result,
2510f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
2511f2fc83b4SThomas Monjalon 	__rte_unused void *data)
251212f76f52STomasz Duszynski {
251312f76f52STomasz Duszynski 	struct cmd_resume_port_tm_node_result *res = parsed_result;
251412f76f52STomasz Duszynski 	struct rte_tm_error error;
251512f76f52STomasz Duszynski 	uint32_t node_id = res->node_id;
251612f76f52STomasz Duszynski 	portid_t port_id = res->port_id;
251712f76f52STomasz Duszynski 	int ret;
251812f76f52STomasz Duszynski 
251912f76f52STomasz Duszynski 	if (port_id_is_invalid(port_id, ENABLED_WARN))
252012f76f52STomasz Duszynski 		return;
252112f76f52STomasz Duszynski 
2522a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
252312f76f52STomasz Duszynski 	ret = rte_tm_node_resume(port_id, node_id, &error);
252412f76f52STomasz Duszynski 	if (ret != 0) {
252512f76f52STomasz Duszynski 		print_err_msg(&error);
252612f76f52STomasz Duszynski 		return;
252712f76f52STomasz Duszynski 	}
252812f76f52STomasz Duszynski }
252912f76f52STomasz Duszynski 
253012f76f52STomasz Duszynski cmdline_parse_inst_t cmd_resume_port_tm_node = {
253112f76f52STomasz Duszynski 	.f = cmd_resume_port_tm_node_parsed,
253212f76f52STomasz Duszynski 	.data = NULL,
253312f76f52STomasz Duszynski 	.help_str = "Resume port tm node",
253412f76f52STomasz Duszynski 	.tokens = {
253512f76f52STomasz Duszynski 		(void *)&cmd_resume_port_tm_node_resume,
253612f76f52STomasz Duszynski 		(void *)&cmd_resume_port_tm_node_port,
253712f76f52STomasz Duszynski 		(void *)&cmd_resume_port_tm_node_tm,
253812f76f52STomasz Duszynski 		(void *)&cmd_resume_port_tm_node_node,
253912f76f52STomasz Duszynski 		(void *)&cmd_resume_port_tm_node_port_id,
254012f76f52STomasz Duszynski 		(void *)&cmd_resume_port_tm_node_node_id,
254112f76f52STomasz Duszynski 		NULL,
254212f76f52STomasz Duszynski 	},
254312f76f52STomasz Duszynski };
254412f76f52STomasz Duszynski 
2545996cb153SJasvinder Singh /* *** Port TM Hierarchy Commit *** */
2546996cb153SJasvinder Singh struct cmd_port_tm_hierarchy_commit_result {
2547996cb153SJasvinder Singh 	cmdline_fixed_string_t port;
2548996cb153SJasvinder Singh 	cmdline_fixed_string_t tm;
2549996cb153SJasvinder Singh 	cmdline_fixed_string_t hierarchy;
2550996cb153SJasvinder Singh 	cmdline_fixed_string_t commit;
2551996cb153SJasvinder Singh 	uint16_t port_id;
2552996cb153SJasvinder Singh 	cmdline_fixed_string_t clean_on_fail;
2553996cb153SJasvinder Singh };
2554996cb153SJasvinder Singh 
2555ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port =
2556996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2557996cb153SJasvinder Singh 		struct cmd_port_tm_hierarchy_commit_result, port, "port");
2558ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm =
2559996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2560996cb153SJasvinder Singh 		struct cmd_port_tm_hierarchy_commit_result, tm, "tm");
2561ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy =
2562996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2563996cb153SJasvinder Singh 		struct cmd_port_tm_hierarchy_commit_result,
2564996cb153SJasvinder Singh 			hierarchy, "hierarchy");
2565ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit =
2566996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(
2567996cb153SJasvinder Singh 		struct cmd_port_tm_hierarchy_commit_result, commit, "commit");
2568ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id =
2569996cb153SJasvinder Singh 	TOKEN_NUM_INITIALIZER(
2570996cb153SJasvinder Singh 		struct cmd_port_tm_hierarchy_commit_result,
2571c2341bb6SDmitry Kozlyuk 			port_id, RTE_UINT16);
2572ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_clean_on_fail =
2573996cb153SJasvinder Singh 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result,
2574996cb153SJasvinder Singh 		 clean_on_fail, "yes#no");
2575996cb153SJasvinder Singh 
2576996cb153SJasvinder Singh static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result,
2577f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
2578f2fc83b4SThomas Monjalon 	__rte_unused void *data)
2579996cb153SJasvinder Singh {
2580996cb153SJasvinder Singh 	struct cmd_port_tm_hierarchy_commit_result *res = parsed_result;
2581996cb153SJasvinder Singh 	struct rte_tm_error error;
2582996cb153SJasvinder Singh 	uint32_t clean_on_fail;
2583996cb153SJasvinder Singh 	portid_t port_id = res->port_id;
2584996cb153SJasvinder Singh 	int ret;
2585996cb153SJasvinder Singh 
2586996cb153SJasvinder Singh 	if (port_id_is_invalid(port_id, ENABLED_WARN))
2587996cb153SJasvinder Singh 		return;
2588996cb153SJasvinder Singh 
2589996cb153SJasvinder Singh 	if (strcmp(res->clean_on_fail, "yes") == 0)
2590996cb153SJasvinder Singh 		clean_on_fail = 1;
2591996cb153SJasvinder Singh 	else
2592996cb153SJasvinder Singh 		clean_on_fail = 0;
2593996cb153SJasvinder Singh 
2594a27e56d2SKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
2595996cb153SJasvinder Singh 	ret = rte_tm_hierarchy_commit(port_id, clean_on_fail, &error);
2596996cb153SJasvinder Singh 	if (ret != 0) {
2597996cb153SJasvinder Singh 		print_err_msg(&error);
2598996cb153SJasvinder Singh 		return;
2599996cb153SJasvinder Singh 	}
2600996cb153SJasvinder Singh }
2601996cb153SJasvinder Singh 
2602996cb153SJasvinder Singh cmdline_parse_inst_t cmd_port_tm_hierarchy_commit = {
2603996cb153SJasvinder Singh 	.f = cmd_port_tm_hierarchy_commit_parsed,
2604996cb153SJasvinder Singh 	.data = NULL,
26052e9bf3a1SKrzysztof Kanas 	.help_str = "Commit port tm hierarchy",
2606996cb153SJasvinder Singh 	.tokens = {
2607996cb153SJasvinder Singh 		(void *)&cmd_port_tm_hierarchy_commit_port,
2608996cb153SJasvinder Singh 		(void *)&cmd_port_tm_hierarchy_commit_tm,
2609996cb153SJasvinder Singh 		(void *)&cmd_port_tm_hierarchy_commit_hierarchy,
2610996cb153SJasvinder Singh 		(void *)&cmd_port_tm_hierarchy_commit_commit,
2611996cb153SJasvinder Singh 		(void *)&cmd_port_tm_hierarchy_commit_port_id,
2612996cb153SJasvinder Singh 		(void *)&cmd_port_tm_hierarchy_commit_clean_on_fail,
2613996cb153SJasvinder Singh 		NULL,
2614996cb153SJasvinder Singh 	},
2615996cb153SJasvinder Singh };
26166673fe0cSKrzysztof Kanas 
26176673fe0cSKrzysztof Kanas /* *** Port TM Mark IP ECN *** */
26186673fe0cSKrzysztof Kanas struct cmd_port_tm_mark_ip_ecn_result {
26196673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t set;
26206673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t port;
26216673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t tm;
26226673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t mark;
26236673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t ip_ecn;
26246673fe0cSKrzysztof Kanas 	uint16_t port_id;
26256673fe0cSKrzysztof Kanas 	uint16_t green;
26266673fe0cSKrzysztof Kanas 	uint16_t yellow;
26276673fe0cSKrzysztof Kanas 	uint16_t red;
26286673fe0cSKrzysztof Kanas };
26296673fe0cSKrzysztof Kanas 
2630ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_set =
26316673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
26326673fe0cSKrzysztof Kanas 				 set, "set");
26336673fe0cSKrzysztof Kanas 
2634ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_port =
26356673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
26366673fe0cSKrzysztof Kanas 				 port, "port");
26376673fe0cSKrzysztof Kanas 
2638ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_tm =
26396673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result, tm,
26406673fe0cSKrzysztof Kanas 				 "tm");
26416673fe0cSKrzysztof Kanas 
2642ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_mark =
26436673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
26446673fe0cSKrzysztof Kanas 				 mark, "mark");
26456673fe0cSKrzysztof Kanas 
2646ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_ip_ecn =
26476673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
26486673fe0cSKrzysztof Kanas 				 ip_ecn, "ip_ecn");
2649ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_port_id =
26506673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2651c2341bb6SDmitry Kozlyuk 			      port_id, RTE_UINT16);
26526673fe0cSKrzysztof Kanas 
2653ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_green =
26546673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2655c2341bb6SDmitry Kozlyuk 			      green, RTE_UINT16);
2656ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_yellow =
26576673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2658c2341bb6SDmitry Kozlyuk 			      yellow, RTE_UINT16);
2659ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_red =
26606673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2661c2341bb6SDmitry Kozlyuk 				red, RTE_UINT16);
26626673fe0cSKrzysztof Kanas 
26636673fe0cSKrzysztof Kanas static void cmd_port_tm_mark_ip_ecn_parsed(void *parsed_result,
2664f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
2665f2fc83b4SThomas Monjalon 	__rte_unused void *data)
26666673fe0cSKrzysztof Kanas {
26676673fe0cSKrzysztof Kanas 	struct cmd_port_tm_mark_ip_ecn_result *res = parsed_result;
26686673fe0cSKrzysztof Kanas 	struct rte_tm_error error;
26696673fe0cSKrzysztof Kanas 	portid_t port_id = res->port_id;
26706673fe0cSKrzysztof Kanas 	int green = res->green;
26716673fe0cSKrzysztof Kanas 	int yellow = res->yellow;
26726673fe0cSKrzysztof Kanas 	int red = res->red;
26736673fe0cSKrzysztof Kanas 	int ret;
26746673fe0cSKrzysztof Kanas 	if (port_id_is_invalid(port_id, ENABLED_WARN))
26756673fe0cSKrzysztof Kanas 		return;
26766673fe0cSKrzysztof Kanas 
26776673fe0cSKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
26786673fe0cSKrzysztof Kanas 	ret = rte_tm_mark_ip_ecn(port_id, green, yellow, red, &error);
26796673fe0cSKrzysztof Kanas 	if (ret != 0) {
26806673fe0cSKrzysztof Kanas 		print_err_msg(&error);
26816673fe0cSKrzysztof Kanas 		return;
26826673fe0cSKrzysztof Kanas 	}
26836673fe0cSKrzysztof Kanas }
26846673fe0cSKrzysztof Kanas 
26856673fe0cSKrzysztof Kanas cmdline_parse_inst_t cmd_port_tm_mark_ip_ecn = {
26866673fe0cSKrzysztof Kanas 	.f = cmd_port_tm_mark_ip_ecn_parsed,
26876673fe0cSKrzysztof Kanas 	.data = NULL,
26886673fe0cSKrzysztof Kanas 	.help_str = "set port tm mark ip_ecn <port> <green> <yellow> <red>",
26896673fe0cSKrzysztof Kanas 	.tokens = {
26906673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_ecn_set,
26916673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_ecn_port,
26926673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_ecn_tm,
26936673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_ecn_mark,
26946673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_ecn_ip_ecn,
26956673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_ecn_port_id,
26966673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_ecn_green,
26976673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_ecn_yellow,
26986673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_ecn_red,
26996673fe0cSKrzysztof Kanas 		NULL,
27006673fe0cSKrzysztof Kanas 	},
27016673fe0cSKrzysztof Kanas };
27026673fe0cSKrzysztof Kanas 
27036673fe0cSKrzysztof Kanas 
27046673fe0cSKrzysztof Kanas /* *** Port TM Mark IP DSCP *** */
27056673fe0cSKrzysztof Kanas struct cmd_port_tm_mark_ip_dscp_result {
27066673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t set;
27076673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t port;
27086673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t tm;
27096673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t mark;
27106673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t ip_dscp;
27116673fe0cSKrzysztof Kanas 	uint16_t port_id;
27126673fe0cSKrzysztof Kanas 	uint16_t green;
27136673fe0cSKrzysztof Kanas 	uint16_t yellow;
27146673fe0cSKrzysztof Kanas 	uint16_t red;
27156673fe0cSKrzysztof Kanas };
27166673fe0cSKrzysztof Kanas 
2717ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_set =
27186673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
27196673fe0cSKrzysztof Kanas 				 set, "set");
27206673fe0cSKrzysztof Kanas 
2721ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_port =
27226673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
27236673fe0cSKrzysztof Kanas 				 port, "port");
27246673fe0cSKrzysztof Kanas 
2725ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_tm =
27266673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result, tm,
27276673fe0cSKrzysztof Kanas 				 "tm");
27286673fe0cSKrzysztof Kanas 
2729ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_mark =
27306673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
27316673fe0cSKrzysztof Kanas 				 mark, "mark");
27326673fe0cSKrzysztof Kanas 
2733ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_ip_dscp =
27346673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
27356673fe0cSKrzysztof Kanas 				 ip_dscp, "ip_dscp");
2736ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_port_id =
27376673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2738c2341bb6SDmitry Kozlyuk 			      port_id, RTE_UINT16);
27396673fe0cSKrzysztof Kanas 
2740ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_green =
27416673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2742c2341bb6SDmitry Kozlyuk 				green, RTE_UINT16);
2743ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_yellow =
27446673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2745c2341bb6SDmitry Kozlyuk 				yellow, RTE_UINT16);
2746ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_red =
27476673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2748c2341bb6SDmitry Kozlyuk 				red, RTE_UINT16);
27496673fe0cSKrzysztof Kanas 
27506673fe0cSKrzysztof Kanas static void cmd_port_tm_mark_ip_dscp_parsed(void *parsed_result,
2751f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
2752f2fc83b4SThomas Monjalon 	__rte_unused void *data)
27536673fe0cSKrzysztof Kanas {
27546673fe0cSKrzysztof Kanas 	struct cmd_port_tm_mark_ip_dscp_result *res = parsed_result;
27556673fe0cSKrzysztof Kanas 	struct rte_tm_error error;
27566673fe0cSKrzysztof Kanas 	portid_t port_id = res->port_id;
27576673fe0cSKrzysztof Kanas 	int green = res->green;
27586673fe0cSKrzysztof Kanas 	int yellow = res->yellow;
27596673fe0cSKrzysztof Kanas 	int red = res->red;
27606673fe0cSKrzysztof Kanas 	int ret;
27616673fe0cSKrzysztof Kanas 	if (port_id_is_invalid(port_id, ENABLED_WARN))
27626673fe0cSKrzysztof Kanas 		return;
27636673fe0cSKrzysztof Kanas 
27646673fe0cSKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
27656673fe0cSKrzysztof Kanas 	ret = rte_tm_mark_ip_dscp(port_id, green, yellow, red, &error);
27666673fe0cSKrzysztof Kanas 	if (ret != 0) {
27676673fe0cSKrzysztof Kanas 		print_err_msg(&error);
27686673fe0cSKrzysztof Kanas 		return;
27696673fe0cSKrzysztof Kanas 	}
27706673fe0cSKrzysztof Kanas }
27716673fe0cSKrzysztof Kanas 
27726673fe0cSKrzysztof Kanas cmdline_parse_inst_t cmd_port_tm_mark_ip_dscp = {
27736673fe0cSKrzysztof Kanas 	.f = cmd_port_tm_mark_ip_dscp_parsed,
27746673fe0cSKrzysztof Kanas 	.data = NULL,
27756673fe0cSKrzysztof Kanas 	.help_str = "set port tm mark ip_dscp <port> <green> <yellow> <red>",
27766673fe0cSKrzysztof Kanas 	.tokens = {
27776673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_dscp_set,
27786673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_dscp_port,
27796673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_dscp_tm,
27806673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_dscp_mark,
27816673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_dscp_ip_dscp,
27826673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_dscp_port_id,
27836673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_dscp_green,
27846673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_dscp_yellow,
27856673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_ip_dscp_red,
27866673fe0cSKrzysztof Kanas 		NULL,
27876673fe0cSKrzysztof Kanas 	},
27886673fe0cSKrzysztof Kanas };
27896673fe0cSKrzysztof Kanas 
27906673fe0cSKrzysztof Kanas 
27916673fe0cSKrzysztof Kanas /* *** Port TM Mark VLAN_DEI *** */
27926673fe0cSKrzysztof Kanas struct cmd_port_tm_mark_vlan_dei_result {
27936673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t set;
27946673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t port;
27956673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t tm;
27966673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t mark;
27976673fe0cSKrzysztof Kanas 	cmdline_fixed_string_t vlan_dei;
27986673fe0cSKrzysztof Kanas 	uint16_t port_id;
27996673fe0cSKrzysztof Kanas 	uint16_t green;
28006673fe0cSKrzysztof Kanas 	uint16_t yellow;
28016673fe0cSKrzysztof Kanas 	uint16_t red;
28026673fe0cSKrzysztof Kanas };
28036673fe0cSKrzysztof Kanas 
2804ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_set =
28056673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
28066673fe0cSKrzysztof Kanas 				 set, "set");
28076673fe0cSKrzysztof Kanas 
2808ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_port =
28096673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
28106673fe0cSKrzysztof Kanas 				 port, "port");
28116673fe0cSKrzysztof Kanas 
2812ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_tm =
28136673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result, tm,
28146673fe0cSKrzysztof Kanas 				 "tm");
28156673fe0cSKrzysztof Kanas 
2816ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_mark =
28176673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
28186673fe0cSKrzysztof Kanas 				 mark, "mark");
28196673fe0cSKrzysztof Kanas 
2820ea0774ffSDavid Marchand static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_vlan_dei =
28216673fe0cSKrzysztof Kanas 	TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
28226673fe0cSKrzysztof Kanas 				 vlan_dei, "vlan_dei");
2823ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_port_id =
28246673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2825c2341bb6SDmitry Kozlyuk 			      port_id, RTE_UINT16);
28266673fe0cSKrzysztof Kanas 
2827ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_green =
28286673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2829c2341bb6SDmitry Kozlyuk 				green, RTE_UINT16);
2830ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_yellow =
28316673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2832c2341bb6SDmitry Kozlyuk 				yellow, RTE_UINT16);
2833ea0774ffSDavid Marchand static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_red =
28346673fe0cSKrzysztof Kanas 	TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2835c2341bb6SDmitry Kozlyuk 				red, RTE_UINT16);
28366673fe0cSKrzysztof Kanas 
28376673fe0cSKrzysztof Kanas static void cmd_port_tm_mark_vlan_dei_parsed(void *parsed_result,
2838f2fc83b4SThomas Monjalon 	__rte_unused struct cmdline *cl,
2839f2fc83b4SThomas Monjalon 	__rte_unused void *data)
28406673fe0cSKrzysztof Kanas {
28416673fe0cSKrzysztof Kanas 	struct cmd_port_tm_mark_vlan_dei_result *res = parsed_result;
28426673fe0cSKrzysztof Kanas 	struct rte_tm_error error;
28436673fe0cSKrzysztof Kanas 	portid_t port_id = res->port_id;
28446673fe0cSKrzysztof Kanas 	int green = res->green;
28456673fe0cSKrzysztof Kanas 	int yellow = res->yellow;
28466673fe0cSKrzysztof Kanas 	int red = res->red;
28476673fe0cSKrzysztof Kanas 	int ret;
28486673fe0cSKrzysztof Kanas 	if (port_id_is_invalid(port_id, ENABLED_WARN))
28496673fe0cSKrzysztof Kanas 		return;
28506673fe0cSKrzysztof Kanas 
28516673fe0cSKrzysztof Kanas 	memset(&error, 0, sizeof(struct rte_tm_error));
28526673fe0cSKrzysztof Kanas 	ret = rte_tm_mark_vlan_dei(port_id, green, yellow, red, &error);
28536673fe0cSKrzysztof Kanas 	if (ret != 0) {
28546673fe0cSKrzysztof Kanas 		print_err_msg(&error);
28556673fe0cSKrzysztof Kanas 		return;
28566673fe0cSKrzysztof Kanas 	}
28576673fe0cSKrzysztof Kanas }
28586673fe0cSKrzysztof Kanas 
28596673fe0cSKrzysztof Kanas cmdline_parse_inst_t cmd_port_tm_mark_vlan_dei = {
28606673fe0cSKrzysztof Kanas 	.f = cmd_port_tm_mark_vlan_dei_parsed,
28616673fe0cSKrzysztof Kanas 	.data = NULL,
28626673fe0cSKrzysztof Kanas 	.help_str = "set port tm mark vlan_dei <port> <green> <yellow> <red>",
28636673fe0cSKrzysztof Kanas 	.tokens = {
28646673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_vlan_dei_set,
28656673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_vlan_dei_port,
28666673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_vlan_dei_tm,
28676673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_vlan_dei_mark,
28686673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_vlan_dei_vlan_dei,
28696673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_vlan_dei_port_id,
28706673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_vlan_dei_green,
28716673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_vlan_dei_yellow,
28726673fe0cSKrzysztof Kanas 		(void *)&cmd_port_tm_mark_vlan_dei_red,
28736673fe0cSKrzysztof Kanas 		NULL,
28746673fe0cSKrzysztof Kanas 	},
28756673fe0cSKrzysztof Kanas };
2876