Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Intel Corporation
3 : : */
4 : :
5 : : #include <ctype.h>
6 : : #include <stdlib.h>
7 : :
8 : : #include <cmdline_parse.h>
9 : : #include <cmdline_parse_num.h>
10 : : #include <cmdline_parse_string.h>
11 : :
12 : : #include <rte_ethdev.h>
13 : : #include <rte_flow.h>
14 : : #include <rte_string_fns.h>
15 : : #include <rte_tm.h>
16 : :
17 : : #include "testpmd.h"
18 : : #include "cmdline_tm.h"
19 : :
20 : : #define PARSE_DELIMITER " \f\n\r\t\v"
21 : : #define MAX_NUM_SHARED_SHAPERS 256
22 : :
23 : : /** Display TM Error Message */
24 : : static void
25 : 0 : print_err_msg(struct rte_tm_error *error)
26 : : {
27 : : static const char *const errstrlist[] = {
28 : : [RTE_TM_ERROR_TYPE_NONE] = "no error",
29 : : [RTE_TM_ERROR_TYPE_UNSPECIFIED] = "cause unspecified",
30 : : [RTE_TM_ERROR_TYPE_CAPABILITIES]
31 : : = "capability parameter null",
32 : : [RTE_TM_ERROR_TYPE_LEVEL_ID] = "level id",
33 : : [RTE_TM_ERROR_TYPE_WRED_PROFILE]
34 : : = "wred profile null",
35 : : [RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN] = "wred profile(green)",
36 : : [RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW]
37 : : = "wred profile(yellow)",
38 : : [RTE_TM_ERROR_TYPE_WRED_PROFILE_RED] = "wred profile(red)",
39 : : [RTE_TM_ERROR_TYPE_WRED_PROFILE_ID] = "wred profile id",
40 : : [RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID]
41 : : = "shared wred context id",
42 : : [RTE_TM_ERROR_TYPE_SHAPER_PROFILE] = "shaper profile null",
43 : : [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE]
44 : : = "committed rate field (shaper profile)",
45 : : [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE]
46 : : = "committed size field (shaper profile)",
47 : : [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE]
48 : : = "peak rate field (shaper profile)",
49 : : [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE]
50 : : = "peak size field (shaper profile)",
51 : : [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN]
52 : : = "packet adjust length field (shaper profile)",
53 : : [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PACKET_MODE]
54 : : = "packet mode field (shaper profile)",
55 : : [RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID] = "shaper profile id",
56 : : [RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID] = "shared shaper id",
57 : : [RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID] = "parent node id",
58 : : [RTE_TM_ERROR_TYPE_NODE_PRIORITY] = "node priority",
59 : : [RTE_TM_ERROR_TYPE_NODE_WEIGHT] = "node weight",
60 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS] = "node parameter null",
61 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID]
62 : : = "shaper profile id field (node params)",
63 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID]
64 : : = "shared shaper id field (node params)",
65 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS]
66 : : = "num shared shapers field (node params)",
67 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE]
68 : : = "wfq weight mode field (node params)",
69 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES]
70 : : = "num strict priorities field (node params)",
71 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN]
72 : : = "congestion management mode field (node params)",
73 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID] =
74 : : "wred profile id field (node params)",
75 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID]
76 : : = "shared wred context id field (node params)",
77 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS]
78 : : = "num shared wred contexts field (node params)",
79 : : [RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS]
80 : : = "stats field (node params)",
81 : : [RTE_TM_ERROR_TYPE_NODE_ID] = "node id",
82 : : };
83 : :
84 : : const char *errstr;
85 : : char buf[64];
86 : :
87 : 0 : if ((unsigned int)error->type >= RTE_DIM(errstrlist) ||
88 : 0 : !errstrlist[error->type])
89 : : errstr = "unknown type";
90 : : else
91 : : errstr = errstrlist[error->type];
92 : :
93 : 0 : if (error->cause)
94 : : snprintf(buf, sizeof(buf), "cause: %p, ", error->cause);
95 : :
96 : 0 : fprintf(stderr, "%s: %s%s (error %d)\n",
97 : 0 : errstr, error->cause ? buf : "",
98 : 0 : error->message ? error->message : "(no stated reason)",
99 : 0 : error->type);
100 : 0 : }
101 : :
102 : : static int
103 : 0 : read_uint64(uint64_t *value, const char *p)
104 : : {
105 : : char *next;
106 : : uint64_t val;
107 : :
108 : 0 : p = rte_str_skip_leading_spaces(p);
109 : 0 : if (!isdigit(*p))
110 : : return -EINVAL;
111 : :
112 : 0 : val = strtoul(p, &next, 10);
113 : 0 : if (p == next)
114 : : return -EINVAL;
115 : :
116 : : p = next;
117 : 0 : switch (*p) {
118 : 0 : case 'T':
119 : 0 : val *= 1024ULL;
120 : : /* fall through */
121 : 0 : case 'G':
122 : 0 : val *= 1024ULL;
123 : : /* fall through */
124 : 0 : case 'M':
125 : 0 : val *= 1024ULL;
126 : : /* fall through */
127 : 0 : case 'k':
128 : : case 'K':
129 : 0 : val *= 1024ULL;
130 : 0 : p++;
131 : 0 : break;
132 : : }
133 : :
134 : 0 : p = rte_str_skip_leading_spaces(p);
135 : 0 : if (*p != '\0')
136 : : return -EINVAL;
137 : :
138 : 0 : *value = val;
139 : 0 : return 0;
140 : : }
141 : :
142 : : static int
143 : : read_uint32(uint32_t *value, const char *p)
144 : : {
145 : 0 : uint64_t val = 0;
146 : 0 : int ret = read_uint64(&val, p);
147 : :
148 : 0 : if (ret < 0)
149 : : return ret;
150 : :
151 : 0 : if (val > UINT32_MAX)
152 : : return -ERANGE;
153 : :
154 : 0 : *value = val;
155 : : return 0;
156 : : }
157 : :
158 : : static int
159 : 0 : parse_multi_ss_id_str(char *s_str, uint32_t *n_ssp, uint32_t shaper_id[])
160 : : {
161 : : uint32_t n_shared_shapers = 0, i = 0;
162 : : char *token;
163 : :
164 : : /* First token: num of shared shapers */
165 : 0 : token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
166 : 0 : if (token == NULL)
167 : : return -1;
168 : :
169 : : if (read_uint32(&n_shared_shapers, token))
170 : 0 : return -1;
171 : :
172 : : /* Check: num of shared shaper */
173 : 0 : if (n_shared_shapers >= MAX_NUM_SHARED_SHAPERS) {
174 : 0 : fprintf(stderr,
175 : : " Number of shared shapers exceed the max (error)\n");
176 : 0 : return -1;
177 : : }
178 : :
179 : : /* Parse shared shaper ids */
180 : : while (1) {
181 : 0 : token = strtok_r(s_str, PARSE_DELIMITER, &s_str);
182 : 0 : if ((token != NULL && n_shared_shapers == 0) ||
183 : 0 : (token == NULL && i < n_shared_shapers))
184 : : return -1;
185 : :
186 : 0 : if (token == NULL)
187 : : break;
188 : :
189 : 0 : if (read_uint32(&shaper_id[i], token))
190 : 0 : return -1;
191 : 0 : i++;
192 : : }
193 : 0 : *n_ssp = n_shared_shapers;
194 : :
195 : 0 : return 0;
196 : : }
197 : : /* *** Port TM Capability *** */
198 : : struct cmd_show_port_tm_cap_result {
199 : : cmdline_fixed_string_t show;
200 : : cmdline_fixed_string_t port;
201 : : cmdline_fixed_string_t tm;
202 : : cmdline_fixed_string_t cap;
203 : : uint16_t port_id;
204 : : };
205 : :
206 : : static cmdline_parse_token_string_t cmd_show_port_tm_cap_show =
207 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
208 : : show, "show");
209 : : static cmdline_parse_token_string_t cmd_show_port_tm_cap_port =
210 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
211 : : port, "port");
212 : : static cmdline_parse_token_string_t cmd_show_port_tm_cap_tm =
213 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
214 : : tm, "tm");
215 : : static cmdline_parse_token_string_t cmd_show_port_tm_cap_cap =
216 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_cap_result,
217 : : cap, "cap");
218 : : static cmdline_parse_token_num_t cmd_show_port_tm_cap_port_id =
219 : : TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_cap_result,
220 : : port_id, RTE_UINT16);
221 : :
222 : 0 : static void cmd_show_port_tm_cap_parsed(void *parsed_result,
223 : : __rte_unused struct cmdline *cl,
224 : : __rte_unused void *data)
225 : : {
226 : : struct cmd_show_port_tm_cap_result *res = parsed_result;
227 : : struct rte_tm_capabilities cap;
228 : : struct rte_tm_error error;
229 : 0 : portid_t port_id = res->port_id;
230 : : uint32_t i;
231 : : int ret;
232 : :
233 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
234 : 0 : return;
235 : :
236 : : memset(&cap, 0, sizeof(struct rte_tm_capabilities));
237 : : memset(&error, 0, sizeof(struct rte_tm_error));
238 : 0 : ret = rte_tm_capabilities_get(port_id, &cap, &error);
239 : 0 : if (ret) {
240 : 0 : print_err_msg(&error);
241 : 0 : return;
242 : : }
243 : :
244 : : printf("\n**** Port TM Capabilities ****\n\n");
245 : 0 : printf("cap.n_nodes_max %" PRIu32 "\n", cap.n_nodes_max);
246 : 0 : printf("cap.n_levels_max %" PRIu32 "\n", cap.n_levels_max);
247 : 0 : printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
248 : : cap.non_leaf_nodes_identical);
249 : 0 : printf("cap.leaf_nodes_identical %" PRId32 "\n",
250 : : cap.leaf_nodes_identical);
251 : 0 : printf("cap.shaper_n_max %u\n", cap.shaper_n_max);
252 : 0 : printf("cap.shaper_private_n_max %" PRIu32 "\n",
253 : : cap.shaper_private_n_max);
254 : 0 : printf("cap.shaper_private_dual_rate_n_max %" PRId32 "\n",
255 : : cap.shaper_private_dual_rate_n_max);
256 : 0 : printf("cap.shaper_private_rate_min %" PRIu64 "\n",
257 : : cap.shaper_private_rate_min);
258 : 0 : printf("cap.shaper_private_rate_max %" PRIu64 "\n",
259 : : cap.shaper_private_rate_max);
260 : 0 : printf("cap.shaper_private_packet_mode_supported %" PRId32 "\n",
261 : : cap.shaper_private_packet_mode_supported);
262 : 0 : printf("cap.shaper_private_byte_mode_supported %" PRId32 "\n",
263 : : cap.shaper_private_byte_mode_supported);
264 : 0 : printf("cap.shaper_shared_n_max %" PRIu32 "\n",
265 : : cap.shaper_shared_n_max);
266 : 0 : printf("cap.shaper_shared_n_nodes_per_shaper_max %" PRIu32 "\n",
267 : : cap.shaper_shared_n_nodes_per_shaper_max);
268 : 0 : printf("cap.shaper_shared_n_shapers_per_node_max %" PRIu32 "\n",
269 : : cap.shaper_shared_n_shapers_per_node_max);
270 : 0 : printf("cap.shaper_shared_dual_rate_n_max %" PRIu32 "\n",
271 : : cap.shaper_shared_dual_rate_n_max);
272 : 0 : printf("cap.shaper_shared_rate_min %" PRIu64 "\n",
273 : : cap.shaper_shared_rate_min);
274 : 0 : printf("cap.shaper_shared_rate_max %" PRIu64 "\n",
275 : : cap.shaper_shared_rate_max);
276 : 0 : printf("cap.shaper_shared_packet_mode_supported %" PRId32 "\n",
277 : : cap.shaper_shared_packet_mode_supported);
278 : 0 : printf("cap.shaper_shared_byte_mode_supported %" PRId32 "\n",
279 : : cap.shaper_shared_byte_mode_supported);
280 : 0 : printf("cap.shaper_pkt_length_adjust_min %" PRId32 "\n",
281 : : cap.shaper_pkt_length_adjust_min);
282 : 0 : printf("cap.shaper_pkt_length_adjust_max %" PRId32 "\n",
283 : : cap.shaper_pkt_length_adjust_max);
284 : 0 : printf("cap.sched_n_children_max %" PRIu32 "\n",
285 : : cap.sched_n_children_max);
286 : 0 : printf("cap.sched_sp_n_priorities_max %" PRIu32 "\n",
287 : : cap.sched_sp_n_priorities_max);
288 : 0 : printf("cap.sched_wfq_n_children_per_group_max %" PRIu32 "\n",
289 : : cap.sched_wfq_n_children_per_group_max);
290 : 0 : printf("cap.sched_wfq_n_groups_max %" PRIu32 "\n",
291 : : cap.sched_wfq_n_groups_max);
292 : 0 : printf("cap.sched_wfq_weight_max %" PRIu32 "\n",
293 : : cap.sched_wfq_weight_max);
294 : 0 : printf("cap.sched_wfq_packet_mode_supported %" PRId32 "\n",
295 : : cap.sched_wfq_packet_mode_supported);
296 : 0 : printf("cap.sched_wfq_byte_mode_supported %" PRId32 "\n",
297 : : cap.sched_wfq_byte_mode_supported);
298 : 0 : printf("cap.cman_head_drop_supported %" PRId32 "\n",
299 : : cap.cman_head_drop_supported);
300 : 0 : printf("cap.cman_wred_context_n_max %" PRIu32 "\n",
301 : : cap.cman_wred_context_n_max);
302 : 0 : printf("cap.cman_wred_context_private_n_max %" PRIu32 "\n",
303 : : cap.cman_wred_context_private_n_max);
304 : 0 : printf("cap.cman_wred_context_shared_n_max %" PRIu32 "\n",
305 : : cap.cman_wred_context_shared_n_max);
306 : 0 : printf("cap.cman_wred_context_shared_n_nodes_per_context_max %" PRIu32
307 : : "\n", cap.cman_wred_context_shared_n_nodes_per_context_max);
308 : 0 : printf("cap.cman_wred_context_shared_n_contexts_per_node_max %" PRIu32
309 : : "\n", cap.cman_wred_context_shared_n_contexts_per_node_max);
310 : :
311 : 0 : for (i = 0; i < RTE_COLORS; i++) {
312 : 0 : printf("cap.mark_vlan_dei_supported %" PRId32 "\n",
313 : : cap.mark_vlan_dei_supported[i]);
314 : 0 : printf("cap.mark_ip_ecn_tcp_supported %" PRId32 "\n",
315 : : cap.mark_ip_ecn_tcp_supported[i]);
316 : 0 : printf("cap.mark_ip_ecn_sctp_supported %" PRId32 "\n",
317 : : cap.mark_ip_ecn_sctp_supported[i]);
318 : 0 : printf("cap.mark_ip_dscp_supported %" PRId32 "\n",
319 : : cap.mark_ip_dscp_supported[i]);
320 : : }
321 : :
322 : 0 : printf("cap.dynamic_update_mask %" PRIx64 "\n",
323 : : cap.dynamic_update_mask);
324 : 0 : printf("cap.stats_mask %" PRIx64 "\n", cap.stats_mask);
325 : : }
326 : :
327 : : cmdline_parse_inst_t cmd_show_port_tm_cap = {
328 : : .f = cmd_show_port_tm_cap_parsed,
329 : : .data = NULL,
330 : : .help_str = "Show Port TM Capabilities",
331 : : .tokens = {
332 : : (void *)&cmd_show_port_tm_cap_show,
333 : : (void *)&cmd_show_port_tm_cap_port,
334 : : (void *)&cmd_show_port_tm_cap_tm,
335 : : (void *)&cmd_show_port_tm_cap_cap,
336 : : (void *)&cmd_show_port_tm_cap_port_id,
337 : : NULL,
338 : : },
339 : : };
340 : :
341 : : /* *** Port TM Hierarchical Level Capability *** */
342 : : struct cmd_show_port_tm_level_cap_result {
343 : : cmdline_fixed_string_t show;
344 : : cmdline_fixed_string_t port;
345 : : cmdline_fixed_string_t tm;
346 : : cmdline_fixed_string_t level;
347 : : cmdline_fixed_string_t cap;
348 : : uint16_t port_id;
349 : : uint32_t level_id;
350 : : };
351 : :
352 : : static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_show =
353 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
354 : : show, "show");
355 : : static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_port =
356 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
357 : : port, "port");
358 : : static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_tm =
359 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
360 : : tm, "tm");
361 : : static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_level =
362 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
363 : : level, "level");
364 : : static cmdline_parse_token_string_t cmd_show_port_tm_level_cap_cap =
365 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
366 : : cap, "cap");
367 : : static cmdline_parse_token_num_t cmd_show_port_tm_level_cap_port_id =
368 : : TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
369 : : port_id, RTE_UINT16);
370 : : static cmdline_parse_token_num_t cmd_show_port_tm_level_cap_level_id =
371 : : TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_level_cap_result,
372 : : level_id, RTE_UINT32);
373 : :
374 : :
375 : 0 : static void cmd_show_port_tm_level_cap_parsed(void *parsed_result,
376 : : __rte_unused struct cmdline *cl,
377 : : __rte_unused void *data)
378 : : {
379 : : struct cmd_show_port_tm_level_cap_result *res = parsed_result;
380 : : struct rte_tm_level_capabilities lcap;
381 : : struct rte_tm_error error;
382 : 0 : portid_t port_id = res->port_id;
383 : 0 : uint32_t level_id = res->level_id;
384 : : int ret;
385 : :
386 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
387 : 0 : return;
388 : :
389 : : memset(&lcap, 0, sizeof(struct rte_tm_level_capabilities));
390 : : memset(&error, 0, sizeof(struct rte_tm_error));
391 : 0 : ret = rte_tm_level_capabilities_get(port_id, level_id, &lcap, &error);
392 : 0 : if (ret) {
393 : 0 : print_err_msg(&error);
394 : 0 : return;
395 : : }
396 : : printf("\n** Port TM Hierarchy level %" PRIu32 " Capability **\n\n",
397 : : level_id);
398 : :
399 : 0 : printf("cap.n_nodes_max %" PRIu32 "\n", lcap.n_nodes_max);
400 : 0 : printf("cap.n_nodes_nonleaf_max %" PRIu32 "\n",
401 : : lcap.n_nodes_nonleaf_max);
402 : 0 : printf("cap.n_nodes_leaf_max %" PRIu32 "\n", lcap.n_nodes_leaf_max);
403 : 0 : printf("cap.non_leaf_nodes_identical %" PRId32 "\n",
404 : : lcap.non_leaf_nodes_identical);
405 : 0 : printf("cap.leaf_nodes_identical %" PRId32 "\n",
406 : : lcap.leaf_nodes_identical);
407 : 0 : if (level_id <= 3) {
408 : 0 : printf("cap.nonleaf.shaper_private_supported %" PRId32 "\n",
409 : : lcap.nonleaf.shaper_private_supported);
410 : 0 : printf("cap.nonleaf.shaper_private_dual_rate_supported %" PRId32
411 : : "\n", lcap.nonleaf.shaper_private_dual_rate_supported);
412 : 0 : printf("cap.nonleaf.shaper_private_rate_min %" PRIu64 "\n",
413 : : lcap.nonleaf.shaper_private_rate_min);
414 : 0 : printf("cap.nonleaf.shaper_private_rate_max %" PRIu64 "\n",
415 : : lcap.nonleaf.shaper_private_rate_max);
416 : 0 : printf("cap.nonleaf.shaper_private_packet_mode_supported %"
417 : : PRId32 "\n",
418 : : lcap.nonleaf.shaper_private_packet_mode_supported);
419 : 0 : printf("cap.nonleaf.shaper_private_byte_mode_supported %" PRId32
420 : : "\n", lcap.nonleaf.shaper_private_byte_mode_supported);
421 : 0 : printf("cap.nonleaf.shaper_shared_n_max %" PRIu32 "\n",
422 : : lcap.nonleaf.shaper_shared_n_max);
423 : 0 : printf("cap.nonleaf.shaper_shared_packet_mode_supported %"
424 : : PRId32 "\n",
425 : : lcap.nonleaf.shaper_shared_packet_mode_supported);
426 : 0 : printf("cap.nonleaf.shaper_shared_byte_mode_supported %"
427 : : PRId32 "\n",
428 : : lcap.nonleaf.shaper_shared_byte_mode_supported);
429 : 0 : printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
430 : : lcap.nonleaf.sched_n_children_max);
431 : 0 : printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
432 : : lcap.nonleaf.sched_sp_n_priorities_max);
433 : 0 : printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
434 : : "\n", lcap.nonleaf.sched_wfq_n_children_per_group_max);
435 : 0 : printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
436 : : lcap.nonleaf.sched_wfq_n_groups_max);
437 : 0 : printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
438 : : lcap.nonleaf.sched_wfq_weight_max);
439 : 0 : printf("cap.nonleaf.sched_wfq_packet_mode_supported %" PRId32 "\n",
440 : : lcap.nonleaf.sched_wfq_packet_mode_supported);
441 : 0 : printf("cap.nonleaf.sched_wfq_byte_mode_supported %" PRId32
442 : : "\n", lcap.nonleaf.sched_wfq_byte_mode_supported);
443 : 0 : printf("cap.nonleaf.stats_mask %" PRIx64 "\n",
444 : : lcap.nonleaf.stats_mask);
445 : : } else {
446 : 0 : printf("cap.leaf.shaper_private_supported %" PRId32 "\n",
447 : : lcap.leaf.shaper_private_supported);
448 : 0 : printf("cap.leaf.shaper_private_dual_rate_supported %" PRId32
449 : : "\n", lcap.leaf.shaper_private_dual_rate_supported);
450 : 0 : printf("cap.leaf.shaper_private_rate_min %" PRIu64 "\n",
451 : : lcap.leaf.shaper_private_rate_min);
452 : 0 : printf("cap.leaf.shaper_private_rate_max %" PRIu64 "\n",
453 : : lcap.leaf.shaper_private_rate_max);
454 : 0 : printf("cap.leaf.shaper_private_packet_mode_supported %" PRId32
455 : : "\n", lcap.leaf.shaper_private_packet_mode_supported);
456 : 0 : printf("cap.leaf.shaper_private_byte_mode_supported %" PRId32 "\n",
457 : : lcap.leaf.shaper_private_byte_mode_supported);
458 : 0 : printf("cap.leaf.shaper_shared_n_max %" PRIu32 "\n",
459 : : lcap.leaf.shaper_shared_n_max);
460 : 0 : printf("cap.leaf.shaper_shared_packet_mode_supported %" PRId32 "\n",
461 : : lcap.leaf.shaper_shared_packet_mode_supported);
462 : 0 : printf("cap.leaf.shaper_shared_byte_mode_supported %" PRId32 "\n",
463 : : lcap.leaf.shaper_shared_byte_mode_supported);
464 : 0 : printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
465 : : lcap.leaf.cman_head_drop_supported);
466 : 0 : printf("cap.leaf.cman_wred_context_private_supported %" PRId32
467 : : "\n", lcap.leaf.cman_wred_context_private_supported);
468 : 0 : printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
469 : : lcap.leaf.cman_wred_context_shared_n_max);
470 : 0 : printf("cap.leaf.stats_mask %" PRIx64 "\n",
471 : : lcap.leaf.stats_mask);
472 : : }
473 : : }
474 : :
475 : : cmdline_parse_inst_t cmd_show_port_tm_level_cap = {
476 : : .f = cmd_show_port_tm_level_cap_parsed,
477 : : .data = NULL,
478 : : .help_str = "Show port TM hierarchical level capabilities",
479 : : .tokens = {
480 : : (void *)&cmd_show_port_tm_level_cap_show,
481 : : (void *)&cmd_show_port_tm_level_cap_port,
482 : : (void *)&cmd_show_port_tm_level_cap_tm,
483 : : (void *)&cmd_show_port_tm_level_cap_level,
484 : : (void *)&cmd_show_port_tm_level_cap_cap,
485 : : (void *)&cmd_show_port_tm_level_cap_port_id,
486 : : (void *)&cmd_show_port_tm_level_cap_level_id,
487 : : NULL,
488 : : },
489 : : };
490 : :
491 : : /* *** Port TM Hierarchy Node Capability *** */
492 : : struct cmd_show_port_tm_node_cap_result {
493 : : cmdline_fixed_string_t show;
494 : : cmdline_fixed_string_t port;
495 : : cmdline_fixed_string_t tm;
496 : : cmdline_fixed_string_t node;
497 : : cmdline_fixed_string_t cap;
498 : : uint16_t port_id;
499 : : uint32_t node_id;
500 : : };
501 : :
502 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_show =
503 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
504 : : show, "show");
505 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_port =
506 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
507 : : port, "port");
508 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_tm =
509 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
510 : : tm, "tm");
511 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_node =
512 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
513 : : node, "node");
514 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_cap_cap =
515 : : TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
516 : : cap, "cap");
517 : : static cmdline_parse_token_num_t cmd_show_port_tm_node_cap_port_id =
518 : : TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
519 : : port_id, RTE_UINT16);
520 : : static cmdline_parse_token_num_t cmd_show_port_tm_node_cap_node_id =
521 : : TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_cap_result,
522 : : node_id, RTE_UINT32);
523 : :
524 : 0 : static void cmd_show_port_tm_node_cap_parsed(void *parsed_result,
525 : : __rte_unused struct cmdline *cl,
526 : : __rte_unused void *data)
527 : : {
528 : : struct cmd_show_port_tm_node_cap_result *res = parsed_result;
529 : : struct rte_tm_node_capabilities ncap;
530 : : struct rte_tm_error error;
531 : 0 : uint32_t node_id = res->node_id;
532 : 0 : portid_t port_id = res->port_id;
533 : 0 : int ret, is_leaf = 0;
534 : :
535 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
536 : 0 : return;
537 : :
538 : : memset(&error, 0, sizeof(struct rte_tm_error));
539 : : /* Node id must be valid */
540 : 0 : ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
541 : 0 : if (ret != 0) {
542 : 0 : print_err_msg(&error);
543 : 0 : return;
544 : : }
545 : :
546 : : memset(&ncap, 0, sizeof(struct rte_tm_node_capabilities));
547 : 0 : ret = rte_tm_node_capabilities_get(port_id, node_id, &ncap, &error);
548 : 0 : if (ret != 0) {
549 : 0 : print_err_msg(&error);
550 : 0 : return;
551 : : }
552 : : printf("\n** Port TM Hierarchy node %" PRIu32 " Capability **\n\n",
553 : : node_id);
554 : 0 : printf("cap.shaper_private_supported %" PRId32 "\n",
555 : : ncap.shaper_private_supported);
556 : 0 : printf("cap.shaper_private_dual_rate_supported %" PRId32 "\n",
557 : : ncap.shaper_private_dual_rate_supported);
558 : 0 : printf("cap.shaper_private_rate_min %" PRIu64 "\n",
559 : : ncap.shaper_private_rate_min);
560 : 0 : printf("cap.shaper_private_rate_max %" PRIu64 "\n",
561 : : ncap.shaper_private_rate_max);
562 : 0 : printf("cap.shaper_private_packet_mode_supported %" PRId32 "\n",
563 : : ncap.shaper_private_packet_mode_supported);
564 : 0 : printf("cap.shaper_private_byte_mode_supported %" PRId32 "\n",
565 : : ncap.shaper_private_byte_mode_supported);
566 : 0 : printf("cap.shaper_shared_n_max %" PRIu32 "\n",
567 : : ncap.shaper_shared_n_max);
568 : 0 : printf("cap.shaper_shared_packet_mode_supported %" PRId32 "\n",
569 : : ncap.shaper_shared_packet_mode_supported);
570 : 0 : printf("cap.shaper_shared_byte_mode_supported %" PRId32 "\n",
571 : : ncap.shaper_shared_byte_mode_supported);
572 : 0 : if (!is_leaf) {
573 : 0 : printf("cap.nonleaf.sched_n_children_max %" PRIu32 "\n",
574 : : ncap.nonleaf.sched_n_children_max);
575 : 0 : printf("cap.nonleaf.sched_sp_n_priorities_max %" PRIu32 "\n",
576 : : ncap.nonleaf.sched_sp_n_priorities_max);
577 : 0 : printf("cap.nonleaf.sched_wfq_n_children_per_group_max %" PRIu32
578 : : "\n", ncap.nonleaf.sched_wfq_n_children_per_group_max);
579 : 0 : printf("cap.nonleaf.sched_wfq_n_groups_max %" PRIu32 "\n",
580 : : ncap.nonleaf.sched_wfq_n_groups_max);
581 : 0 : printf("cap.nonleaf.sched_wfq_weight_max %" PRIu32 "\n",
582 : : ncap.nonleaf.sched_wfq_weight_max);
583 : 0 : printf("cap.nonleaf.sched_wfq_packet_mode_supported %" PRId32 "\n",
584 : : ncap.nonleaf.sched_wfq_packet_mode_supported);
585 : 0 : printf("cap.nonleaf.sched_wfq_byte_mode_supported %" PRId32 "\n",
586 : : ncap.nonleaf.sched_wfq_byte_mode_supported);
587 : : } else {
588 : 0 : printf("cap.leaf.cman_head_drop_supported %" PRId32 "\n",
589 : : ncap.leaf.cman_head_drop_supported);
590 : 0 : printf("cap.leaf.cman_wred_context_private_supported %" PRId32
591 : : "\n", ncap.leaf.cman_wred_context_private_supported);
592 : 0 : printf("cap.leaf.cman_wred_context_shared_n_max %" PRIu32 "\n",
593 : : ncap.leaf.cman_wred_context_shared_n_max);
594 : : }
595 : 0 : printf("cap.stats_mask %" PRIx64 "\n", ncap.stats_mask);
596 : : }
597 : :
598 : : cmdline_parse_inst_t cmd_show_port_tm_node_cap = {
599 : : .f = cmd_show_port_tm_node_cap_parsed,
600 : : .data = NULL,
601 : : .help_str = "Show Port TM Hierarchy node capabilities",
602 : : .tokens = {
603 : : (void *)&cmd_show_port_tm_node_cap_show,
604 : : (void *)&cmd_show_port_tm_node_cap_port,
605 : : (void *)&cmd_show_port_tm_node_cap_tm,
606 : : (void *)&cmd_show_port_tm_node_cap_node,
607 : : (void *)&cmd_show_port_tm_node_cap_cap,
608 : : (void *)&cmd_show_port_tm_node_cap_port_id,
609 : : (void *)&cmd_show_port_tm_node_cap_node_id,
610 : : NULL,
611 : : },
612 : : };
613 : :
614 : : /* *** Show Port TM Node Statistics *** */
615 : : struct cmd_show_port_tm_node_stats_result {
616 : : cmdline_fixed_string_t show;
617 : : cmdline_fixed_string_t port;
618 : : cmdline_fixed_string_t tm;
619 : : cmdline_fixed_string_t node;
620 : : cmdline_fixed_string_t stats;
621 : : uint16_t port_id;
622 : : uint32_t node_id;
623 : : uint32_t clear;
624 : : };
625 : :
626 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_show =
627 : : TOKEN_STRING_INITIALIZER(
628 : : struct cmd_show_port_tm_node_stats_result, show, "show");
629 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_port =
630 : : TOKEN_STRING_INITIALIZER(
631 : : struct cmd_show_port_tm_node_stats_result, port, "port");
632 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_tm =
633 : : TOKEN_STRING_INITIALIZER(
634 : : struct cmd_show_port_tm_node_stats_result, tm, "tm");
635 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_node =
636 : : TOKEN_STRING_INITIALIZER(
637 : : struct cmd_show_port_tm_node_stats_result, node, "node");
638 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_stats_stats =
639 : : TOKEN_STRING_INITIALIZER(
640 : : struct cmd_show_port_tm_node_stats_result, stats, "stats");
641 : : static cmdline_parse_token_num_t cmd_show_port_tm_node_stats_port_id =
642 : : TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_stats_result,
643 : : port_id, RTE_UINT16);
644 : : static cmdline_parse_token_num_t cmd_show_port_tm_node_stats_node_id =
645 : : TOKEN_NUM_INITIALIZER(
646 : : struct cmd_show_port_tm_node_stats_result,
647 : : node_id, RTE_UINT32);
648 : : static cmdline_parse_token_num_t cmd_show_port_tm_node_stats_clear =
649 : : TOKEN_NUM_INITIALIZER(
650 : : struct cmd_show_port_tm_node_stats_result, clear, RTE_UINT32);
651 : :
652 : 0 : static void cmd_show_port_tm_node_stats_parsed(void *parsed_result,
653 : : __rte_unused struct cmdline *cl,
654 : : __rte_unused void *data)
655 : : {
656 : : struct cmd_show_port_tm_node_stats_result *res = parsed_result;
657 : : struct rte_tm_node_stats stats;
658 : : struct rte_tm_error error;
659 : 0 : uint64_t stats_mask = 0;
660 : 0 : uint32_t node_id = res->node_id;
661 : 0 : uint32_t clear = res->clear;
662 : 0 : portid_t port_id = res->port_id;
663 : : int ret;
664 : :
665 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
666 : 0 : return;
667 : :
668 : : memset(&error, 0, sizeof(struct rte_tm_error));
669 : : /* Port status */
670 : 0 : if (!port_is_started(port_id)) {
671 : 0 : fprintf(stderr, " Port %u not started (error)\n", port_id);
672 : 0 : return;
673 : : }
674 : :
675 : : memset(&stats, 0, sizeof(struct rte_tm_node_stats));
676 : 0 : ret = rte_tm_node_stats_read(port_id, node_id, &stats,
677 : : &stats_mask, clear, &error);
678 : 0 : if (ret != 0) {
679 : 0 : print_err_msg(&error);
680 : 0 : return;
681 : : }
682 : :
683 : : /* Display stats */
684 : 0 : if (stats_mask & RTE_TM_STATS_N_PKTS)
685 : 0 : printf("\tPkts scheduled from node: %" PRIu64 "\n",
686 : : stats.n_pkts);
687 : 0 : if (stats_mask & RTE_TM_STATS_N_BYTES)
688 : 0 : printf("\tBytes scheduled from node: %" PRIu64 "\n",
689 : : stats.n_bytes);
690 : 0 : if (stats_mask & RTE_TM_STATS_N_PKTS_GREEN_DROPPED)
691 : 0 : printf("\tPkts dropped (green): %" PRIu64 "\n",
692 : : stats.leaf.n_pkts_dropped[RTE_COLOR_GREEN]);
693 : 0 : if (stats_mask & RTE_TM_STATS_N_PKTS_YELLOW_DROPPED)
694 : 0 : printf("\tPkts dropped (yellow): %" PRIu64 "\n",
695 : : stats.leaf.n_pkts_dropped[RTE_COLOR_YELLOW]);
696 : 0 : if (stats_mask & RTE_TM_STATS_N_PKTS_RED_DROPPED)
697 : 0 : printf("\tPkts dropped (red): %" PRIu64 "\n",
698 : : stats.leaf.n_pkts_dropped[RTE_COLOR_RED]);
699 : 0 : if (stats_mask & RTE_TM_STATS_N_BYTES_GREEN_DROPPED)
700 : 0 : printf("\tBytes dropped (green): %" PRIu64 "\n",
701 : : stats.leaf.n_bytes_dropped[RTE_COLOR_GREEN]);
702 : 0 : if (stats_mask & RTE_TM_STATS_N_BYTES_YELLOW_DROPPED)
703 : 0 : printf("\tBytes dropped (yellow): %" PRIu64 "\n",
704 : : stats.leaf.n_bytes_dropped[RTE_COLOR_YELLOW]);
705 : 0 : if (stats_mask & RTE_TM_STATS_N_BYTES_RED_DROPPED)
706 : 0 : printf("\tBytes dropped (red): %" PRIu64 "\n",
707 : : stats.leaf.n_bytes_dropped[RTE_COLOR_RED]);
708 : 0 : if (stats_mask & RTE_TM_STATS_N_PKTS_QUEUED)
709 : 0 : printf("\tPkts queued: %" PRIu64 "\n",
710 : : stats.leaf.n_pkts_queued);
711 : 0 : if (stats_mask & RTE_TM_STATS_N_BYTES_QUEUED)
712 : 0 : printf("\tBytes queued: %" PRIu64 "\n",
713 : : stats.leaf.n_bytes_queued);
714 : : }
715 : :
716 : : cmdline_parse_inst_t cmd_show_port_tm_node_stats = {
717 : : .f = cmd_show_port_tm_node_stats_parsed,
718 : : .data = NULL,
719 : : .help_str = "Show port tm node stats",
720 : : .tokens = {
721 : : (void *)&cmd_show_port_tm_node_stats_show,
722 : : (void *)&cmd_show_port_tm_node_stats_port,
723 : : (void *)&cmd_show_port_tm_node_stats_tm,
724 : : (void *)&cmd_show_port_tm_node_stats_node,
725 : : (void *)&cmd_show_port_tm_node_stats_stats,
726 : : (void *)&cmd_show_port_tm_node_stats_port_id,
727 : : (void *)&cmd_show_port_tm_node_stats_node_id,
728 : : (void *)&cmd_show_port_tm_node_stats_clear,
729 : : NULL,
730 : : },
731 : : };
732 : :
733 : : /* *** Show Port TM Node Type *** */
734 : : struct cmd_show_port_tm_node_type_result {
735 : : cmdline_fixed_string_t show;
736 : : cmdline_fixed_string_t port;
737 : : cmdline_fixed_string_t tm;
738 : : cmdline_fixed_string_t node;
739 : : cmdline_fixed_string_t type;
740 : : uint16_t port_id;
741 : : uint32_t node_id;
742 : : };
743 : :
744 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_type_show =
745 : : TOKEN_STRING_INITIALIZER(
746 : : struct cmd_show_port_tm_node_type_result, show, "show");
747 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_type_port =
748 : : TOKEN_STRING_INITIALIZER(
749 : : struct cmd_show_port_tm_node_type_result, port, "port");
750 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_type_tm =
751 : : TOKEN_STRING_INITIALIZER(
752 : : struct cmd_show_port_tm_node_type_result, tm, "tm");
753 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_type_node =
754 : : TOKEN_STRING_INITIALIZER(
755 : : struct cmd_show_port_tm_node_type_result, node, "node");
756 : : static cmdline_parse_token_string_t cmd_show_port_tm_node_type_type =
757 : : TOKEN_STRING_INITIALIZER(
758 : : struct cmd_show_port_tm_node_type_result, type, "type");
759 : : static cmdline_parse_token_num_t cmd_show_port_tm_node_type_port_id =
760 : : TOKEN_NUM_INITIALIZER(
761 : : struct cmd_show_port_tm_node_type_result,
762 : : port_id, RTE_UINT16);
763 : : static cmdline_parse_token_num_t cmd_show_port_tm_node_type_node_id =
764 : : TOKEN_NUM_INITIALIZER(
765 : : struct cmd_show_port_tm_node_type_result,
766 : : node_id, RTE_UINT32);
767 : :
768 : 0 : static void cmd_show_port_tm_node_type_parsed(void *parsed_result,
769 : : __rte_unused struct cmdline *cl,
770 : : __rte_unused void *data)
771 : : {
772 : : struct cmd_show_port_tm_node_type_result *res = parsed_result;
773 : : struct rte_tm_error error;
774 : 0 : uint32_t node_id = res->node_id;
775 : 0 : portid_t port_id = res->port_id;
776 : 0 : int ret, is_leaf = 0;
777 : :
778 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
779 : 0 : return;
780 : :
781 : : memset(&error, 0, sizeof(struct rte_tm_error));
782 : 0 : ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error);
783 : 0 : if (ret != 0) {
784 : 0 : print_err_msg(&error);
785 : 0 : return;
786 : : }
787 : :
788 : 0 : if (is_leaf == 1)
789 : : printf("leaf node\n");
790 : : else
791 : : printf("nonleaf node\n");
792 : :
793 : : }
794 : :
795 : : cmdline_parse_inst_t cmd_show_port_tm_node_type = {
796 : : .f = cmd_show_port_tm_node_type_parsed,
797 : : .data = NULL,
798 : : .help_str = "Show port tm node type",
799 : : .tokens = {
800 : : (void *)&cmd_show_port_tm_node_type_show,
801 : : (void *)&cmd_show_port_tm_node_type_port,
802 : : (void *)&cmd_show_port_tm_node_type_tm,
803 : : (void *)&cmd_show_port_tm_node_type_node,
804 : : (void *)&cmd_show_port_tm_node_type_type,
805 : : (void *)&cmd_show_port_tm_node_type_port_id,
806 : : (void *)&cmd_show_port_tm_node_type_node_id,
807 : : NULL,
808 : : },
809 : : };
810 : :
811 : : /* *** Add Port TM Private Shaper Profile *** */
812 : : struct cmd_add_port_tm_node_shaper_profile_result {
813 : : cmdline_fixed_string_t add;
814 : : cmdline_fixed_string_t port;
815 : : cmdline_fixed_string_t tm;
816 : : cmdline_fixed_string_t node;
817 : : cmdline_fixed_string_t shaper;
818 : : cmdline_fixed_string_t profile;
819 : : uint16_t port_id;
820 : : uint32_t shaper_id;
821 : : uint64_t cmit_tb_rate;
822 : : uint64_t cmit_tb_size;
823 : : uint64_t peak_tb_rate;
824 : : uint64_t peak_tb_size;
825 : : uint32_t pktlen_adjust;
826 : : int pkt_mode;
827 : : };
828 : :
829 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_add =
830 : : TOKEN_STRING_INITIALIZER(
831 : : struct cmd_add_port_tm_node_shaper_profile_result, add, "add");
832 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_port =
833 : : TOKEN_STRING_INITIALIZER(
834 : : struct cmd_add_port_tm_node_shaper_profile_result,
835 : : port, "port");
836 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_tm =
837 : : TOKEN_STRING_INITIALIZER(
838 : : struct cmd_add_port_tm_node_shaper_profile_result,
839 : : tm, "tm");
840 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_node =
841 : : TOKEN_STRING_INITIALIZER(
842 : : struct cmd_add_port_tm_node_shaper_profile_result,
843 : : node, "node");
844 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_shaper =
845 : : TOKEN_STRING_INITIALIZER(
846 : : struct cmd_add_port_tm_node_shaper_profile_result,
847 : : shaper, "shaper");
848 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shaper_profile_profile =
849 : : TOKEN_STRING_INITIALIZER(
850 : : struct cmd_add_port_tm_node_shaper_profile_result,
851 : : profile, "profile");
852 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_port_id =
853 : : TOKEN_NUM_INITIALIZER(
854 : : struct cmd_add_port_tm_node_shaper_profile_result,
855 : : port_id, RTE_UINT16);
856 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_shaper_id =
857 : : TOKEN_NUM_INITIALIZER(
858 : : struct cmd_add_port_tm_node_shaper_profile_result,
859 : : shaper_id, RTE_UINT32);
860 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_rate =
861 : : TOKEN_NUM_INITIALIZER(
862 : : struct cmd_add_port_tm_node_shaper_profile_result,
863 : : cmit_tb_rate, RTE_UINT64);
864 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_cmit_tb_size =
865 : : TOKEN_NUM_INITIALIZER(
866 : : struct cmd_add_port_tm_node_shaper_profile_result,
867 : : cmit_tb_size, RTE_UINT64);
868 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_rate =
869 : : TOKEN_NUM_INITIALIZER(
870 : : struct cmd_add_port_tm_node_shaper_profile_result,
871 : : peak_tb_rate, RTE_UINT64);
872 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_peak_tb_size =
873 : : TOKEN_NUM_INITIALIZER(
874 : : struct cmd_add_port_tm_node_shaper_profile_result,
875 : : peak_tb_size, RTE_UINT64);
876 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_pktlen_adjust =
877 : : TOKEN_NUM_INITIALIZER(
878 : : struct cmd_add_port_tm_node_shaper_profile_result,
879 : : pktlen_adjust, RTE_UINT32);
880 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_packet_mode =
881 : : TOKEN_NUM_INITIALIZER(
882 : : struct cmd_add_port_tm_node_shaper_profile_result,
883 : : pkt_mode, RTE_UINT32);
884 : :
885 : 0 : static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result,
886 : : __rte_unused struct cmdline *cl,
887 : : __rte_unused void *data)
888 : : {
889 : : struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result;
890 : : struct rte_tm_shaper_params sp;
891 : : struct rte_tm_error error;
892 : 0 : uint32_t shaper_id = res->shaper_id;
893 : 0 : uint32_t pkt_len_adjust = res->pktlen_adjust;
894 : 0 : portid_t port_id = res->port_id;
895 : : int ret;
896 : :
897 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
898 : 0 : return;
899 : :
900 : : /* Private shaper profile params */
901 : : memset(&sp, 0, sizeof(struct rte_tm_shaper_params));
902 : : memset(&error, 0, sizeof(struct rte_tm_error));
903 : 0 : sp.committed.rate = res->cmit_tb_rate;
904 : 0 : sp.committed.size = res->cmit_tb_size;
905 : 0 : sp.peak.rate = res->peak_tb_rate;
906 : 0 : sp.peak.size = res->peak_tb_size;
907 : 0 : sp.pkt_length_adjust = pkt_len_adjust;
908 : 0 : sp.packet_mode = res->pkt_mode;
909 : :
910 : 0 : ret = rte_tm_shaper_profile_add(port_id, shaper_id, &sp, &error);
911 : 0 : if (ret != 0) {
912 : 0 : print_err_msg(&error);
913 : 0 : return;
914 : : }
915 : : }
916 : :
917 : : cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile = {
918 : : .f = cmd_add_port_tm_node_shaper_profile_parsed,
919 : : .data = NULL,
920 : : .help_str = "Add port tm node private shaper profile",
921 : : .tokens = {
922 : : (void *)&cmd_add_port_tm_node_shaper_profile_add,
923 : : (void *)&cmd_add_port_tm_node_shaper_profile_port,
924 : : (void *)&cmd_add_port_tm_node_shaper_profile_tm,
925 : : (void *)&cmd_add_port_tm_node_shaper_profile_node,
926 : : (void *)&cmd_add_port_tm_node_shaper_profile_shaper,
927 : : (void *)&cmd_add_port_tm_node_shaper_profile_profile,
928 : : (void *)&cmd_add_port_tm_node_shaper_profile_port_id,
929 : : (void *)&cmd_add_port_tm_node_shaper_profile_shaper_id,
930 : : (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_rate,
931 : : (void *)&cmd_add_port_tm_node_shaper_profile_cmit_tb_size,
932 : : (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_rate,
933 : : (void *)&cmd_add_port_tm_node_shaper_profile_peak_tb_size,
934 : : (void *)&cmd_add_port_tm_node_shaper_profile_pktlen_adjust,
935 : : (void *)&cmd_add_port_tm_node_shaper_profile_packet_mode,
936 : : NULL,
937 : : },
938 : : };
939 : :
940 : : /* *** Delete Port TM Private Shaper Profile *** */
941 : : struct cmd_del_port_tm_node_shaper_profile_result {
942 : : cmdline_fixed_string_t del;
943 : : cmdline_fixed_string_t port;
944 : : cmdline_fixed_string_t tm;
945 : : cmdline_fixed_string_t node;
946 : : cmdline_fixed_string_t shaper;
947 : : cmdline_fixed_string_t profile;
948 : : uint16_t port_id;
949 : : uint32_t shaper_id;
950 : : };
951 : :
952 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_del =
953 : : TOKEN_STRING_INITIALIZER(
954 : : struct cmd_del_port_tm_node_shaper_profile_result, del, "del");
955 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_port =
956 : : TOKEN_STRING_INITIALIZER(
957 : : struct cmd_del_port_tm_node_shaper_profile_result,
958 : : port, "port");
959 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_tm =
960 : : TOKEN_STRING_INITIALIZER(
961 : : struct cmd_del_port_tm_node_shaper_profile_result, tm, "tm");
962 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_node =
963 : : TOKEN_STRING_INITIALIZER(
964 : : struct cmd_del_port_tm_node_shaper_profile_result,
965 : : node, "node");
966 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_shaper =
967 : : TOKEN_STRING_INITIALIZER(
968 : : struct cmd_del_port_tm_node_shaper_profile_result,
969 : : shaper, "shaper");
970 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shaper_profile_profile =
971 : : TOKEN_STRING_INITIALIZER(
972 : : struct cmd_del_port_tm_node_shaper_profile_result,
973 : : profile, "profile");
974 : : static cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_port_id =
975 : : TOKEN_NUM_INITIALIZER(
976 : : struct cmd_del_port_tm_node_shaper_profile_result,
977 : : port_id, RTE_UINT16);
978 : : static cmdline_parse_token_num_t cmd_del_port_tm_node_shaper_profile_shaper_id =
979 : : TOKEN_NUM_INITIALIZER(
980 : : struct cmd_del_port_tm_node_shaper_profile_result,
981 : : shaper_id, RTE_UINT32);
982 : :
983 : 0 : static void cmd_del_port_tm_node_shaper_profile_parsed(void *parsed_result,
984 : : __rte_unused struct cmdline *cl,
985 : : __rte_unused void *data)
986 : : {
987 : : struct cmd_del_port_tm_node_shaper_profile_result *res = parsed_result;
988 : : struct rte_tm_error error;
989 : 0 : uint32_t shaper_id = res->shaper_id;
990 : 0 : portid_t port_id = res->port_id;
991 : : int ret;
992 : :
993 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
994 : 0 : return;
995 : :
996 : : memset(&error, 0, sizeof(struct rte_tm_error));
997 : 0 : ret = rte_tm_shaper_profile_delete(port_id, shaper_id, &error);
998 : 0 : if (ret != 0) {
999 : 0 : print_err_msg(&error);
1000 : 0 : return;
1001 : : }
1002 : : }
1003 : :
1004 : : cmdline_parse_inst_t cmd_del_port_tm_node_shaper_profile = {
1005 : : .f = cmd_del_port_tm_node_shaper_profile_parsed,
1006 : : .data = NULL,
1007 : : .help_str = "Delete port tm node private shaper profile",
1008 : : .tokens = {
1009 : : (void *)&cmd_del_port_tm_node_shaper_profile_del,
1010 : : (void *)&cmd_del_port_tm_node_shaper_profile_port,
1011 : : (void *)&cmd_del_port_tm_node_shaper_profile_tm,
1012 : : (void *)&cmd_del_port_tm_node_shaper_profile_node,
1013 : : (void *)&cmd_del_port_tm_node_shaper_profile_shaper,
1014 : : (void *)&cmd_del_port_tm_node_shaper_profile_profile,
1015 : : (void *)&cmd_del_port_tm_node_shaper_profile_port_id,
1016 : : (void *)&cmd_del_port_tm_node_shaper_profile_shaper_id,
1017 : : NULL,
1018 : : },
1019 : : };
1020 : :
1021 : : /* *** Add/Update Port TM shared Shaper *** */
1022 : : struct cmd_add_port_tm_node_shared_shaper_result {
1023 : : cmdline_fixed_string_t cmd_type;
1024 : : cmdline_fixed_string_t port;
1025 : : cmdline_fixed_string_t tm;
1026 : : cmdline_fixed_string_t node;
1027 : : cmdline_fixed_string_t shared;
1028 : : cmdline_fixed_string_t shaper;
1029 : : uint16_t port_id;
1030 : : uint32_t shared_shaper_id;
1031 : : uint32_t shaper_profile_id;
1032 : : };
1033 : :
1034 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_cmd_type =
1035 : : TOKEN_STRING_INITIALIZER(
1036 : : struct cmd_add_port_tm_node_shared_shaper_result,
1037 : : cmd_type, "add#set");
1038 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_port =
1039 : : TOKEN_STRING_INITIALIZER(
1040 : : struct cmd_add_port_tm_node_shared_shaper_result, port, "port");
1041 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_tm =
1042 : : TOKEN_STRING_INITIALIZER(
1043 : : struct cmd_add_port_tm_node_shared_shaper_result, tm, "tm");
1044 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_node =
1045 : : TOKEN_STRING_INITIALIZER(
1046 : : struct cmd_add_port_tm_node_shared_shaper_result, node, "node");
1047 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shared =
1048 : : TOKEN_STRING_INITIALIZER(
1049 : : struct cmd_add_port_tm_node_shared_shaper_result,
1050 : : shared, "shared");
1051 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_shared_shaper_shaper =
1052 : : TOKEN_STRING_INITIALIZER(
1053 : : struct cmd_add_port_tm_node_shared_shaper_result,
1054 : : shaper, "shaper");
1055 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_port_id =
1056 : : TOKEN_NUM_INITIALIZER(
1057 : : struct cmd_add_port_tm_node_shared_shaper_result,
1058 : : port_id, RTE_UINT16);
1059 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shared_shaper_id =
1060 : : TOKEN_NUM_INITIALIZER(
1061 : : struct cmd_add_port_tm_node_shared_shaper_result,
1062 : : shared_shaper_id, RTE_UINT32);
1063 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_shared_shaper_shaper_profile_id =
1064 : : TOKEN_NUM_INITIALIZER(
1065 : : struct cmd_add_port_tm_node_shared_shaper_result,
1066 : : shaper_profile_id, RTE_UINT32);
1067 : :
1068 : 0 : static void cmd_add_port_tm_node_shared_shaper_parsed(void *parsed_result,
1069 : : __rte_unused struct cmdline *cl,
1070 : : __rte_unused void *data)
1071 : : {
1072 : : struct cmd_add_port_tm_node_shared_shaper_result *res = parsed_result;
1073 : : struct rte_tm_error error;
1074 : 0 : uint32_t shared_shaper_id = res->shared_shaper_id;
1075 : 0 : uint32_t shaper_profile_id = res->shaper_profile_id;
1076 : 0 : portid_t port_id = res->port_id;
1077 : : int ret;
1078 : :
1079 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
1080 : 0 : return;
1081 : :
1082 : : memset(&error, 0, sizeof(struct rte_tm_error));
1083 : : /* Command type: add */
1084 : 0 : if ((strcmp(res->cmd_type, "add") == 0) &&
1085 : 0 : (port_is_started(port_id))) {
1086 : 0 : fprintf(stderr, " Port %u not stopped (error)\n", port_id);
1087 : 0 : return;
1088 : : }
1089 : :
1090 : : /* Command type: set (update) */
1091 : 0 : if ((strcmp(res->cmd_type, "set") == 0) &&
1092 : 0 : (!port_is_started(port_id))) {
1093 : 0 : fprintf(stderr, " Port %u not started (error)\n", port_id);
1094 : 0 : return;
1095 : : }
1096 : :
1097 : 0 : ret = rte_tm_shared_shaper_add_update(port_id, shared_shaper_id,
1098 : : shaper_profile_id, &error);
1099 : 0 : if (ret != 0) {
1100 : 0 : print_err_msg(&error);
1101 : 0 : return;
1102 : : }
1103 : : }
1104 : :
1105 : : cmdline_parse_inst_t cmd_add_port_tm_node_shared_shaper = {
1106 : : .f = cmd_add_port_tm_node_shared_shaper_parsed,
1107 : : .data = NULL,
1108 : : .help_str = "add/update port tm node shared shaper",
1109 : : .tokens = {
1110 : : (void *)&cmd_add_port_tm_node_shared_shaper_cmd_type,
1111 : : (void *)&cmd_add_port_tm_node_shared_shaper_port,
1112 : : (void *)&cmd_add_port_tm_node_shared_shaper_tm,
1113 : : (void *)&cmd_add_port_tm_node_shared_shaper_node,
1114 : : (void *)&cmd_add_port_tm_node_shared_shaper_shared,
1115 : : (void *)&cmd_add_port_tm_node_shared_shaper_shaper,
1116 : : (void *)&cmd_add_port_tm_node_shared_shaper_port_id,
1117 : : (void *)&cmd_add_port_tm_node_shared_shaper_shared_shaper_id,
1118 : : (void *)&cmd_add_port_tm_node_shared_shaper_shaper_profile_id,
1119 : : NULL,
1120 : : },
1121 : : };
1122 : :
1123 : : /* *** Delete Port TM shared Shaper *** */
1124 : : struct cmd_del_port_tm_node_shared_shaper_result {
1125 : : cmdline_fixed_string_t del;
1126 : : cmdline_fixed_string_t port;
1127 : : cmdline_fixed_string_t tm;
1128 : : cmdline_fixed_string_t node;
1129 : : cmdline_fixed_string_t shared;
1130 : : cmdline_fixed_string_t shaper;
1131 : : uint16_t port_id;
1132 : : uint32_t shared_shaper_id;
1133 : : };
1134 : :
1135 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_del =
1136 : : TOKEN_STRING_INITIALIZER(
1137 : : struct cmd_del_port_tm_node_shared_shaper_result, del, "del");
1138 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_port =
1139 : : TOKEN_STRING_INITIALIZER(
1140 : : struct cmd_del_port_tm_node_shared_shaper_result, port, "port");
1141 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_tm =
1142 : : TOKEN_STRING_INITIALIZER(
1143 : : struct cmd_del_port_tm_node_shared_shaper_result, tm, "tm");
1144 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_node =
1145 : : TOKEN_STRING_INITIALIZER(
1146 : : struct cmd_del_port_tm_node_shared_shaper_result, node, "node");
1147 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shared =
1148 : : TOKEN_STRING_INITIALIZER(
1149 : : struct cmd_del_port_tm_node_shared_shaper_result,
1150 : : shared, "shared");
1151 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_shared_shaper_shaper =
1152 : : TOKEN_STRING_INITIALIZER(
1153 : : struct cmd_del_port_tm_node_shared_shaper_result,
1154 : : shaper, "shaper");
1155 : : static cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_port_id =
1156 : : TOKEN_NUM_INITIALIZER(
1157 : : struct cmd_del_port_tm_node_shared_shaper_result,
1158 : : port_id, RTE_UINT16);
1159 : : static cmdline_parse_token_num_t cmd_del_port_tm_node_shared_shaper_shared_shaper_id =
1160 : : TOKEN_NUM_INITIALIZER(
1161 : : struct cmd_del_port_tm_node_shared_shaper_result,
1162 : : shared_shaper_id, RTE_UINT32);
1163 : :
1164 : 0 : static void cmd_del_port_tm_node_shared_shaper_parsed(void *parsed_result,
1165 : : __rte_unused struct cmdline *cl,
1166 : : __rte_unused void *data)
1167 : : {
1168 : : struct cmd_del_port_tm_node_shared_shaper_result *res = parsed_result;
1169 : : struct rte_tm_error error;
1170 : 0 : uint32_t shared_shaper_id = res->shared_shaper_id;
1171 : 0 : portid_t port_id = res->port_id;
1172 : : int ret;
1173 : :
1174 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
1175 : 0 : return;
1176 : :
1177 : : memset(&error, 0, sizeof(struct rte_tm_error));
1178 : 0 : ret = rte_tm_shared_shaper_delete(port_id, shared_shaper_id, &error);
1179 : 0 : if (ret != 0) {
1180 : 0 : print_err_msg(&error);
1181 : 0 : return;
1182 : : }
1183 : : }
1184 : :
1185 : : cmdline_parse_inst_t cmd_del_port_tm_node_shared_shaper = {
1186 : : .f = cmd_del_port_tm_node_shared_shaper_parsed,
1187 : : .data = NULL,
1188 : : .help_str = "delete port tm node shared shaper",
1189 : : .tokens = {
1190 : : (void *)&cmd_del_port_tm_node_shared_shaper_del,
1191 : : (void *)&cmd_del_port_tm_node_shared_shaper_port,
1192 : : (void *)&cmd_del_port_tm_node_shared_shaper_tm,
1193 : : (void *)&cmd_del_port_tm_node_shared_shaper_node,
1194 : : (void *)&cmd_del_port_tm_node_shared_shaper_shared,
1195 : : (void *)&cmd_del_port_tm_node_shared_shaper_shaper,
1196 : : (void *)&cmd_del_port_tm_node_shared_shaper_port_id,
1197 : : (void *)&cmd_del_port_tm_node_shared_shaper_shared_shaper_id,
1198 : : NULL,
1199 : : },
1200 : : };
1201 : :
1202 : : /* *** Add Port TM Node WRED Profile *** */
1203 : : struct cmd_add_port_tm_node_wred_profile_result {
1204 : : cmdline_fixed_string_t add;
1205 : : cmdline_fixed_string_t port;
1206 : : cmdline_fixed_string_t tm;
1207 : : cmdline_fixed_string_t node;
1208 : : cmdline_fixed_string_t wred;
1209 : : cmdline_fixed_string_t profile;
1210 : : uint16_t port_id;
1211 : : uint32_t wred_profile_id;
1212 : : cmdline_fixed_string_t color_g;
1213 : : uint64_t min_th_g;
1214 : : uint64_t max_th_g;
1215 : : uint16_t maxp_inv_g;
1216 : : uint16_t wq_log2_g;
1217 : : cmdline_fixed_string_t color_y;
1218 : : uint64_t min_th_y;
1219 : : uint64_t max_th_y;
1220 : : uint16_t maxp_inv_y;
1221 : : uint16_t wq_log2_y;
1222 : : cmdline_fixed_string_t color_r;
1223 : : uint64_t min_th_r;
1224 : : uint64_t max_th_r;
1225 : : uint16_t maxp_inv_r;
1226 : : uint16_t wq_log2_r;
1227 : : };
1228 : :
1229 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_add =
1230 : : TOKEN_STRING_INITIALIZER(
1231 : : struct cmd_add_port_tm_node_wred_profile_result, add, "add");
1232 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_port =
1233 : : TOKEN_STRING_INITIALIZER(
1234 : : struct cmd_add_port_tm_node_wred_profile_result, port, "port");
1235 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_tm =
1236 : : TOKEN_STRING_INITIALIZER(
1237 : : struct cmd_add_port_tm_node_wred_profile_result, tm, "tm");
1238 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_node =
1239 : : TOKEN_STRING_INITIALIZER(
1240 : : struct cmd_add_port_tm_node_wred_profile_result, node, "node");
1241 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_wred =
1242 : : TOKEN_STRING_INITIALIZER(
1243 : : struct cmd_add_port_tm_node_wred_profile_result, wred, "wred");
1244 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_profile =
1245 : : TOKEN_STRING_INITIALIZER(
1246 : : struct cmd_add_port_tm_node_wred_profile_result,
1247 : : profile, "profile");
1248 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_port_id =
1249 : : TOKEN_NUM_INITIALIZER(
1250 : : struct cmd_add_port_tm_node_wred_profile_result,
1251 : : port_id, RTE_UINT16);
1252 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wred_profile_id =
1253 : : TOKEN_NUM_INITIALIZER(
1254 : : struct cmd_add_port_tm_node_wred_profile_result,
1255 : : wred_profile_id, RTE_UINT32);
1256 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_g =
1257 : : TOKEN_STRING_INITIALIZER(
1258 : : struct cmd_add_port_tm_node_wred_profile_result,
1259 : : color_g, "G#g");
1260 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_g =
1261 : : TOKEN_NUM_INITIALIZER(
1262 : : struct cmd_add_port_tm_node_wred_profile_result,
1263 : : min_th_g, RTE_UINT64);
1264 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_g =
1265 : : TOKEN_NUM_INITIALIZER(
1266 : : struct cmd_add_port_tm_node_wred_profile_result,
1267 : : max_th_g, RTE_UINT64);
1268 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_g =
1269 : : TOKEN_NUM_INITIALIZER(
1270 : : struct cmd_add_port_tm_node_wred_profile_result,
1271 : : maxp_inv_g, RTE_UINT16);
1272 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_g =
1273 : : TOKEN_NUM_INITIALIZER(
1274 : : struct cmd_add_port_tm_node_wred_profile_result,
1275 : : wq_log2_g, RTE_UINT16);
1276 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_y =
1277 : : TOKEN_STRING_INITIALIZER(
1278 : : struct cmd_add_port_tm_node_wred_profile_result,
1279 : : color_y, "Y#y");
1280 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_y =
1281 : : TOKEN_NUM_INITIALIZER(
1282 : : struct cmd_add_port_tm_node_wred_profile_result,
1283 : : min_th_y, RTE_UINT64);
1284 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_y =
1285 : : TOKEN_NUM_INITIALIZER(
1286 : : struct cmd_add_port_tm_node_wred_profile_result,
1287 : : max_th_y, RTE_UINT64);
1288 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_y =
1289 : : TOKEN_NUM_INITIALIZER(
1290 : : struct cmd_add_port_tm_node_wred_profile_result,
1291 : : maxp_inv_y, RTE_UINT16);
1292 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_y =
1293 : : TOKEN_NUM_INITIALIZER(
1294 : : struct cmd_add_port_tm_node_wred_profile_result,
1295 : : wq_log2_y, RTE_UINT16);
1296 : : static cmdline_parse_token_string_t cmd_add_port_tm_node_wred_profile_color_r =
1297 : : TOKEN_STRING_INITIALIZER(
1298 : : struct cmd_add_port_tm_node_wred_profile_result,
1299 : : color_r, "R#r");
1300 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_min_th_r =
1301 : : TOKEN_NUM_INITIALIZER(
1302 : : struct cmd_add_port_tm_node_wred_profile_result,
1303 : : min_th_r, RTE_UINT64);
1304 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_max_th_r =
1305 : : TOKEN_NUM_INITIALIZER(
1306 : : struct cmd_add_port_tm_node_wred_profile_result,
1307 : : max_th_r, RTE_UINT64);
1308 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_maxp_inv_r =
1309 : : TOKEN_NUM_INITIALIZER(
1310 : : struct cmd_add_port_tm_node_wred_profile_result,
1311 : : maxp_inv_r, RTE_UINT16);
1312 : : static cmdline_parse_token_num_t cmd_add_port_tm_node_wred_profile_wq_log2_r =
1313 : : TOKEN_NUM_INITIALIZER(
1314 : : struct cmd_add_port_tm_node_wred_profile_result,
1315 : : wq_log2_r, RTE_UINT16);
1316 : :
1317 : :
1318 : 0 : static void cmd_add_port_tm_node_wred_profile_parsed(void *parsed_result,
1319 : : __rte_unused struct cmdline *cl,
1320 : : __rte_unused void *data)
1321 : : {
1322 : : struct cmd_add_port_tm_node_wred_profile_result *res = parsed_result;
1323 : : struct rte_tm_wred_params wp;
1324 : : enum rte_color color;
1325 : : struct rte_tm_error error;
1326 : 0 : uint32_t wred_profile_id = res->wred_profile_id;
1327 : 0 : portid_t port_id = res->port_id;
1328 : : int ret;
1329 : :
1330 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
1331 : 0 : return;
1332 : :
1333 : : memset(&wp, 0, sizeof(struct rte_tm_wred_params));
1334 : : memset(&error, 0, sizeof(struct rte_tm_error));
1335 : :
1336 : : /* WRED Params (Green Color)*/
1337 : : color = RTE_COLOR_GREEN;
1338 : 0 : wp.red_params[color].min_th = res->min_th_g;
1339 : 0 : wp.red_params[color].max_th = res->max_th_g;
1340 : 0 : wp.red_params[color].maxp_inv = res->maxp_inv_g;
1341 : 0 : wp.red_params[color].wq_log2 = res->wq_log2_g;
1342 : :
1343 : :
1344 : : /* WRED Params (Yellow Color)*/
1345 : : color = RTE_COLOR_YELLOW;
1346 : 0 : wp.red_params[color].min_th = res->min_th_y;
1347 : 0 : wp.red_params[color].max_th = res->max_th_y;
1348 : 0 : wp.red_params[color].maxp_inv = res->maxp_inv_y;
1349 : 0 : wp.red_params[color].wq_log2 = res->wq_log2_y;
1350 : :
1351 : : /* WRED Params (Red Color)*/
1352 : : color = RTE_COLOR_RED;
1353 : 0 : wp.red_params[color].min_th = res->min_th_r;
1354 : 0 : wp.red_params[color].max_th = res->max_th_r;
1355 : 0 : wp.red_params[color].maxp_inv = res->maxp_inv_r;
1356 : 0 : wp.red_params[color].wq_log2 = res->wq_log2_r;
1357 : :
1358 : 0 : ret = rte_tm_wred_profile_add(port_id, wred_profile_id, &wp, &error);
1359 : 0 : if (ret != 0) {
1360 : 0 : print_err_msg(&error);
1361 : 0 : return;
1362 : : }
1363 : : }
1364 : :
1365 : : cmdline_parse_inst_t cmd_add_port_tm_node_wred_profile = {
1366 : : .f = cmd_add_port_tm_node_wred_profile_parsed,
1367 : : .data = NULL,
1368 : : .help_str = "Add port tm node wred profile",
1369 : : .tokens = {
1370 : : (void *)&cmd_add_port_tm_node_wred_profile_add,
1371 : : (void *)&cmd_add_port_tm_node_wred_profile_port,
1372 : : (void *)&cmd_add_port_tm_node_wred_profile_tm,
1373 : : (void *)&cmd_add_port_tm_node_wred_profile_node,
1374 : : (void *)&cmd_add_port_tm_node_wred_profile_wred,
1375 : : (void *)&cmd_add_port_tm_node_wred_profile_profile,
1376 : : (void *)&cmd_add_port_tm_node_wred_profile_port_id,
1377 : : (void *)&cmd_add_port_tm_node_wred_profile_wred_profile_id,
1378 : : (void *)&cmd_add_port_tm_node_wred_profile_color_g,
1379 : : (void *)&cmd_add_port_tm_node_wred_profile_min_th_g,
1380 : : (void *)&cmd_add_port_tm_node_wred_profile_max_th_g,
1381 : : (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_g,
1382 : : (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_g,
1383 : : (void *)&cmd_add_port_tm_node_wred_profile_color_y,
1384 : : (void *)&cmd_add_port_tm_node_wred_profile_min_th_y,
1385 : : (void *)&cmd_add_port_tm_node_wred_profile_max_th_y,
1386 : : (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_y,
1387 : : (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_y,
1388 : : (void *)&cmd_add_port_tm_node_wred_profile_color_r,
1389 : : (void *)&cmd_add_port_tm_node_wred_profile_min_th_r,
1390 : : (void *)&cmd_add_port_tm_node_wred_profile_max_th_r,
1391 : : (void *)&cmd_add_port_tm_node_wred_profile_maxp_inv_r,
1392 : : (void *)&cmd_add_port_tm_node_wred_profile_wq_log2_r,
1393 : : NULL,
1394 : : },
1395 : : };
1396 : :
1397 : : /* *** Delete Port TM node WRED Profile *** */
1398 : : struct cmd_del_port_tm_node_wred_profile_result {
1399 : : cmdline_fixed_string_t del;
1400 : : cmdline_fixed_string_t port;
1401 : : cmdline_fixed_string_t tm;
1402 : : cmdline_fixed_string_t node;
1403 : : cmdline_fixed_string_t wred;
1404 : : cmdline_fixed_string_t profile;
1405 : : uint16_t port_id;
1406 : : uint32_t wred_profile_id;
1407 : : };
1408 : :
1409 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_del =
1410 : : TOKEN_STRING_INITIALIZER(
1411 : : struct cmd_del_port_tm_node_wred_profile_result, del, "del");
1412 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_port =
1413 : : TOKEN_STRING_INITIALIZER(
1414 : : struct cmd_del_port_tm_node_wred_profile_result, port, "port");
1415 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_tm =
1416 : : TOKEN_STRING_INITIALIZER(
1417 : : struct cmd_del_port_tm_node_wred_profile_result, tm, "tm");
1418 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_node =
1419 : : TOKEN_STRING_INITIALIZER(
1420 : : struct cmd_del_port_tm_node_wred_profile_result, node, "node");
1421 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_wred =
1422 : : TOKEN_STRING_INITIALIZER(
1423 : : struct cmd_del_port_tm_node_wred_profile_result, wred, "wred");
1424 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_wred_profile_profile =
1425 : : TOKEN_STRING_INITIALIZER(
1426 : : struct cmd_del_port_tm_node_wred_profile_result,
1427 : : profile, "profile");
1428 : : static cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_port_id =
1429 : : TOKEN_NUM_INITIALIZER(
1430 : : struct cmd_del_port_tm_node_wred_profile_result,
1431 : : port_id, RTE_UINT16);
1432 : : static cmdline_parse_token_num_t cmd_del_port_tm_node_wred_profile_wred_profile_id =
1433 : : TOKEN_NUM_INITIALIZER(
1434 : : struct cmd_del_port_tm_node_wred_profile_result,
1435 : : wred_profile_id, RTE_UINT32);
1436 : :
1437 : 0 : static void cmd_del_port_tm_node_wred_profile_parsed(void *parsed_result,
1438 : : __rte_unused struct cmdline *cl,
1439 : : __rte_unused void *data)
1440 : : {
1441 : : struct cmd_del_port_tm_node_wred_profile_result *res = parsed_result;
1442 : : struct rte_tm_error error;
1443 : 0 : uint32_t wred_profile_id = res->wred_profile_id;
1444 : 0 : portid_t port_id = res->port_id;
1445 : : int ret;
1446 : :
1447 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
1448 : 0 : return;
1449 : :
1450 : : memset(&error, 0, sizeof(struct rte_tm_error));
1451 : 0 : ret = rte_tm_wred_profile_delete(port_id, wred_profile_id, &error);
1452 : 0 : if (ret != 0) {
1453 : 0 : print_err_msg(&error);
1454 : 0 : return;
1455 : : }
1456 : : }
1457 : :
1458 : : cmdline_parse_inst_t cmd_del_port_tm_node_wred_profile = {
1459 : : .f = cmd_del_port_tm_node_wred_profile_parsed,
1460 : : .data = NULL,
1461 : : .help_str = "Delete port tm node wred profile",
1462 : : .tokens = {
1463 : : (void *)&cmd_del_port_tm_node_wred_profile_del,
1464 : : (void *)&cmd_del_port_tm_node_wred_profile_port,
1465 : : (void *)&cmd_del_port_tm_node_wred_profile_tm,
1466 : : (void *)&cmd_del_port_tm_node_wred_profile_node,
1467 : : (void *)&cmd_del_port_tm_node_wred_profile_wred,
1468 : : (void *)&cmd_del_port_tm_node_wred_profile_profile,
1469 : : (void *)&cmd_del_port_tm_node_wred_profile_port_id,
1470 : : (void *)&cmd_del_port_tm_node_wred_profile_wred_profile_id,
1471 : : NULL,
1472 : : },
1473 : : };
1474 : :
1475 : : /* *** Update Port TM Node Shaper profile *** */
1476 : : struct cmd_set_port_tm_node_shaper_profile_result {
1477 : : cmdline_fixed_string_t set;
1478 : : cmdline_fixed_string_t port;
1479 : : cmdline_fixed_string_t tm;
1480 : : cmdline_fixed_string_t node;
1481 : : cmdline_fixed_string_t shaper;
1482 : : cmdline_fixed_string_t profile;
1483 : : uint16_t port_id;
1484 : : uint32_t node_id;
1485 : : uint32_t shaper_profile_id;
1486 : : };
1487 : :
1488 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_set =
1489 : : TOKEN_STRING_INITIALIZER(
1490 : : struct cmd_set_port_tm_node_shaper_profile_result, set, "set");
1491 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_port =
1492 : : TOKEN_STRING_INITIALIZER(
1493 : : struct cmd_set_port_tm_node_shaper_profile_result,
1494 : : port, "port");
1495 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_tm =
1496 : : TOKEN_STRING_INITIALIZER(
1497 : : struct cmd_set_port_tm_node_shaper_profile_result, tm, "tm");
1498 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_node =
1499 : : TOKEN_STRING_INITIALIZER(
1500 : : struct cmd_set_port_tm_node_shaper_profile_result,
1501 : : node, "node");
1502 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_shaper =
1503 : : TOKEN_STRING_INITIALIZER(
1504 : : struct cmd_set_port_tm_node_shaper_profile_result,
1505 : : shaper, "shaper");
1506 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_shaper_profile_profile =
1507 : : TOKEN_STRING_INITIALIZER(
1508 : : struct cmd_set_port_tm_node_shaper_profile_result,
1509 : : profile, "profile");
1510 : : static cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_port_id =
1511 : : TOKEN_NUM_INITIALIZER(
1512 : : struct cmd_set_port_tm_node_shaper_profile_result,
1513 : : port_id, RTE_UINT16);
1514 : : static cmdline_parse_token_num_t cmd_set_port_tm_node_shaper_profile_node_id =
1515 : : TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_shaper_profile_result,
1516 : : node_id, RTE_UINT32);
1517 : : static cmdline_parse_token_num_t
1518 : : cmd_set_port_tm_node_shaper_shaper_profile_profile_id =
1519 : : TOKEN_NUM_INITIALIZER(
1520 : : struct cmd_set_port_tm_node_shaper_profile_result,
1521 : : shaper_profile_id, RTE_UINT32);
1522 : :
1523 : 0 : static void cmd_set_port_tm_node_shaper_profile_parsed(void *parsed_result,
1524 : : __rte_unused struct cmdline *cl,
1525 : : __rte_unused void *data)
1526 : : {
1527 : : struct cmd_set_port_tm_node_shaper_profile_result *res = parsed_result;
1528 : : struct rte_tm_error error;
1529 : 0 : uint32_t node_id = res->node_id;
1530 : 0 : uint32_t shaper_profile_id = res->shaper_profile_id;
1531 : 0 : portid_t port_id = res->port_id;
1532 : : int ret;
1533 : :
1534 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
1535 : 0 : return;
1536 : :
1537 : : memset(&error, 0, sizeof(struct rte_tm_error));
1538 : : /* Port status */
1539 : 0 : if (!port_is_started(port_id)) {
1540 : 0 : fprintf(stderr, " Port %u not started (error)\n", port_id);
1541 : 0 : return;
1542 : : }
1543 : :
1544 : 0 : ret = rte_tm_node_shaper_update(port_id, node_id,
1545 : : shaper_profile_id, &error);
1546 : 0 : if (ret != 0) {
1547 : 0 : print_err_msg(&error);
1548 : 0 : return;
1549 : : }
1550 : : }
1551 : :
1552 : : cmdline_parse_inst_t cmd_set_port_tm_node_shaper_profile = {
1553 : : .f = cmd_set_port_tm_node_shaper_profile_parsed,
1554 : : .data = NULL,
1555 : : .help_str = "Set port tm node shaper profile",
1556 : : .tokens = {
1557 : : (void *)&cmd_set_port_tm_node_shaper_profile_set,
1558 : : (void *)&cmd_set_port_tm_node_shaper_profile_port,
1559 : : (void *)&cmd_set_port_tm_node_shaper_profile_tm,
1560 : : (void *)&cmd_set_port_tm_node_shaper_profile_node,
1561 : : (void *)&cmd_set_port_tm_node_shaper_profile_shaper,
1562 : : (void *)&cmd_set_port_tm_node_shaper_profile_profile,
1563 : : (void *)&cmd_set_port_tm_node_shaper_profile_port_id,
1564 : : (void *)&cmd_set_port_tm_node_shaper_profile_node_id,
1565 : : (void *)&cmd_set_port_tm_node_shaper_shaper_profile_profile_id,
1566 : : NULL,
1567 : : },
1568 : : };
1569 : :
1570 : : /* *** Add Port TM nonleaf node *** */
1571 : : struct cmd_add_port_tm_nonleaf_node_result {
1572 : : cmdline_fixed_string_t add;
1573 : : cmdline_fixed_string_t port;
1574 : : cmdline_fixed_string_t tm;
1575 : : cmdline_fixed_string_t nonleaf;
1576 : : cmdline_fixed_string_t node;
1577 : : uint16_t port_id;
1578 : : uint32_t node_id;
1579 : : int32_t parent_node_id;
1580 : : uint32_t priority;
1581 : : uint32_t weight;
1582 : : uint32_t level_id;
1583 : : int32_t shaper_profile_id;
1584 : : uint32_t n_sp_priorities;
1585 : : uint64_t stats_mask;
1586 : : cmdline_multi_string_t multi_shared_shaper_id;
1587 : : };
1588 : :
1589 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_add =
1590 : : TOKEN_STRING_INITIALIZER(
1591 : : struct cmd_add_port_tm_nonleaf_node_result, add, "add");
1592 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_port =
1593 : : TOKEN_STRING_INITIALIZER(
1594 : : struct cmd_add_port_tm_nonleaf_node_result, port, "port");
1595 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_tm =
1596 : : TOKEN_STRING_INITIALIZER(
1597 : : struct cmd_add_port_tm_nonleaf_node_result, tm, "tm");
1598 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_nonleaf =
1599 : : TOKEN_STRING_INITIALIZER(
1600 : : struct cmd_add_port_tm_nonleaf_node_result, nonleaf, "nonleaf");
1601 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_node =
1602 : : TOKEN_STRING_INITIALIZER(
1603 : : struct cmd_add_port_tm_nonleaf_node_result, node, "node");
1604 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_port_id =
1605 : : TOKEN_NUM_INITIALIZER(
1606 : : struct cmd_add_port_tm_nonleaf_node_result,
1607 : : port_id, RTE_UINT16);
1608 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_node_id =
1609 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1610 : : node_id, RTE_UINT32);
1611 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_parent_node_id =
1612 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1613 : : parent_node_id, RTE_INT32);
1614 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_priority =
1615 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1616 : : priority, RTE_UINT32);
1617 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_weight =
1618 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1619 : : weight, RTE_UINT32);
1620 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_level_id =
1621 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1622 : : level_id, RTE_UINT32);
1623 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_shaper_profile_id =
1624 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1625 : : shaper_profile_id, RTE_INT32);
1626 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_n_sp_priorities =
1627 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1628 : : n_sp_priorities, RTE_UINT32);
1629 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_stats_mask =
1630 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1631 : : stats_mask, RTE_UINT64);
1632 : : static cmdline_parse_token_string_t
1633 : : cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id =
1634 : : TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_result,
1635 : : multi_shared_shaper_id, TOKEN_STRING_MULTI);
1636 : :
1637 : 0 : static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
1638 : : __rte_unused struct cmdline *cl,
1639 : : __rte_unused void *data)
1640 : : {
1641 : : struct cmd_add_port_tm_nonleaf_node_result *res = parsed_result;
1642 : : struct rte_tm_error error;
1643 : : struct rte_tm_node_params np;
1644 : : uint32_t *shared_shaper_id;
1645 : 0 : uint32_t parent_node_id, n_shared_shapers = 0;
1646 : 0 : char *s_str = res->multi_shared_shaper_id;
1647 : 0 : portid_t port_id = res->port_id;
1648 : : int ret;
1649 : :
1650 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
1651 : 0 : return;
1652 : :
1653 : : memset(&np, 0, sizeof(struct rte_tm_node_params));
1654 : : memset(&error, 0, sizeof(struct rte_tm_error));
1655 : :
1656 : : /* Node parameters */
1657 : 0 : if (res->parent_node_id < 0)
1658 : : parent_node_id = UINT32_MAX;
1659 : : else
1660 : 0 : parent_node_id = res->parent_node_id;
1661 : :
1662 : 0 : shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1663 : : sizeof(uint32_t));
1664 : 0 : if (shared_shaper_id == NULL) {
1665 : 0 : fprintf(stderr,
1666 : : " Memory not allocated for shared shapers (error)\n");
1667 : 0 : return;
1668 : : }
1669 : :
1670 : : /* Parse multi shared shaper id string */
1671 : 0 : ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1672 : 0 : if (ret) {
1673 : 0 : fprintf(stderr, " Shared shapers params string parse error\n");
1674 : 0 : free(shared_shaper_id);
1675 : 0 : return;
1676 : : }
1677 : :
1678 : 0 : if (res->shaper_profile_id < 0)
1679 : 0 : np.shaper_profile_id = UINT32_MAX;
1680 : : else
1681 : 0 : np.shaper_profile_id = res->shaper_profile_id;
1682 : :
1683 : 0 : np.n_shared_shapers = n_shared_shapers;
1684 : 0 : if (np.n_shared_shapers) {
1685 : 0 : np.shared_shaper_id = &shared_shaper_id[0];
1686 : : } else {
1687 : 0 : free(shared_shaper_id);
1688 : : shared_shaper_id = NULL;
1689 : : }
1690 : :
1691 : 0 : np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1692 : 0 : np.stats_mask = res->stats_mask;
1693 : 0 : np.nonleaf.wfq_weight_mode = NULL;
1694 : :
1695 : 0 : ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1696 : : res->priority, res->weight, res->level_id,
1697 : : &np, &error);
1698 : 0 : if (ret != 0) {
1699 : 0 : print_err_msg(&error);
1700 : 0 : free(shared_shaper_id);
1701 : 0 : return;
1702 : : }
1703 : : }
1704 : :
1705 : : cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node = {
1706 : : .f = cmd_add_port_tm_nonleaf_node_parsed,
1707 : : .data = NULL,
1708 : : .help_str = "Add port tm nonleaf node",
1709 : : .tokens = {
1710 : : (void *)&cmd_add_port_tm_nonleaf_node_add,
1711 : : (void *)&cmd_add_port_tm_nonleaf_node_port,
1712 : : (void *)&cmd_add_port_tm_nonleaf_node_tm,
1713 : : (void *)&cmd_add_port_tm_nonleaf_node_nonleaf,
1714 : : (void *)&cmd_add_port_tm_nonleaf_node_node,
1715 : : (void *)&cmd_add_port_tm_nonleaf_node_port_id,
1716 : : (void *)&cmd_add_port_tm_nonleaf_node_node_id,
1717 : : (void *)&cmd_add_port_tm_nonleaf_node_parent_node_id,
1718 : : (void *)&cmd_add_port_tm_nonleaf_node_priority,
1719 : : (void *)&cmd_add_port_tm_nonleaf_node_weight,
1720 : : (void *)&cmd_add_port_tm_nonleaf_node_level_id,
1721 : : (void *)&cmd_add_port_tm_nonleaf_node_shaper_profile_id,
1722 : : (void *)&cmd_add_port_tm_nonleaf_node_n_sp_priorities,
1723 : : (void *)&cmd_add_port_tm_nonleaf_node_stats_mask,
1724 : : (void *)&cmd_add_port_tm_nonleaf_node_multi_shared_shaper_id,
1725 : : NULL,
1726 : : },
1727 : : };
1728 : :
1729 : : /* *** Add Port TM nonleaf node pkt mode *** */
1730 : : struct cmd_add_port_tm_nonleaf_node_pmode_result {
1731 : : cmdline_fixed_string_t add;
1732 : : cmdline_fixed_string_t port;
1733 : : cmdline_fixed_string_t tm;
1734 : : cmdline_fixed_string_t nonleaf;
1735 : : cmdline_fixed_string_t node;
1736 : : uint16_t port_id;
1737 : : uint32_t node_id;
1738 : : int32_t parent_node_id;
1739 : : uint32_t priority;
1740 : : uint32_t weight;
1741 : : uint32_t level_id;
1742 : : int32_t shaper_profile_id;
1743 : : uint32_t n_sp_priorities;
1744 : : uint64_t stats_mask;
1745 : : cmdline_multi_string_t multi_shared_shaper_id;
1746 : : };
1747 : :
1748 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_add =
1749 : : TOKEN_STRING_INITIALIZER(
1750 : : struct cmd_add_port_tm_nonleaf_node_pmode_result, add, "add");
1751 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_port =
1752 : : TOKEN_STRING_INITIALIZER(
1753 : : struct cmd_add_port_tm_nonleaf_node_pmode_result, port, "port");
1754 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_tm =
1755 : : TOKEN_STRING_INITIALIZER(
1756 : : struct cmd_add_port_tm_nonleaf_node_pmode_result, tm, "tm");
1757 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_nonleaf =
1758 : : TOKEN_STRING_INITIALIZER(
1759 : : struct cmd_add_port_tm_nonleaf_node_pmode_result, nonleaf, "nonleaf");
1760 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_node =
1761 : : TOKEN_STRING_INITIALIZER(
1762 : : struct cmd_add_port_tm_nonleaf_node_pmode_result, node, "node");
1763 : : static cmdline_parse_token_string_t cmd_add_port_tm_nonleaf_node_pmode_pktmode =
1764 : : TOKEN_STRING_INITIALIZER(
1765 : : struct cmd_add_port_tm_nonleaf_node_pmode_result, node, "pktmode");
1766 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_port_id =
1767 : : TOKEN_NUM_INITIALIZER(
1768 : : struct cmd_add_port_tm_nonleaf_node_pmode_result,
1769 : : port_id, RTE_UINT16);
1770 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_node_id =
1771 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1772 : : node_id, RTE_UINT32);
1773 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_parent_node_id =
1774 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1775 : : parent_node_id, RTE_INT32);
1776 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_priority =
1777 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1778 : : priority, RTE_UINT32);
1779 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_weight =
1780 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1781 : : weight, RTE_UINT32);
1782 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_level_id =
1783 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1784 : : level_id, RTE_UINT32);
1785 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_shaper_profile_id =
1786 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1787 : : shaper_profile_id, RTE_INT32);
1788 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_n_sp_priorities =
1789 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1790 : : n_sp_priorities, RTE_UINT32);
1791 : : static cmdline_parse_token_num_t cmd_add_port_tm_nonleaf_node_pmode_stats_mask =
1792 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_nonleaf_node_pmode_result,
1793 : : stats_mask, RTE_UINT64);
1794 : : static cmdline_parse_token_string_t
1795 : : cmd_add_port_tm_nonleaf_node_pmode_multi_shrd_shpr_id =
1796 : : TOKEN_STRING_INITIALIZER(
1797 : : struct cmd_add_port_tm_nonleaf_node_pmode_result,
1798 : : multi_shared_shaper_id, TOKEN_STRING_MULTI);
1799 : :
1800 : 0 : static void cmd_add_port_tm_nonleaf_node_pmode_parsed(void *parsed_result,
1801 : : __rte_unused struct cmdline *cl,
1802 : : __rte_unused void *data)
1803 : : {
1804 : : struct cmd_add_port_tm_nonleaf_node_pmode_result *res = parsed_result;
1805 : 0 : uint32_t parent_node_id, n_shared_shapers = 0;
1806 : 0 : char *s_str = res->multi_shared_shaper_id;
1807 : 0 : portid_t port_id = res->port_id;
1808 : : struct rte_tm_node_params np;
1809 : : int *wfq_weight_mode = NULL;
1810 : : uint32_t *shared_shaper_id;
1811 : : struct rte_tm_error error;
1812 : : int ret;
1813 : :
1814 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
1815 : 0 : return;
1816 : :
1817 : : memset(&np, 0, sizeof(struct rte_tm_node_params));
1818 : : memset(&error, 0, sizeof(struct rte_tm_error));
1819 : :
1820 : : /* Node parameters */
1821 : 0 : if (res->parent_node_id < 0)
1822 : : parent_node_id = UINT32_MAX;
1823 : : else
1824 : 0 : parent_node_id = res->parent_node_id;
1825 : :
1826 : 0 : shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1827 : : sizeof(uint32_t));
1828 : 0 : if (shared_shaper_id == NULL) {
1829 : 0 : fprintf(stderr,
1830 : : " Memory not allocated for shared shapers (error)\n");
1831 : 0 : return;
1832 : : }
1833 : :
1834 : : /* Parse multi shared shaper id string */
1835 : 0 : ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
1836 : 0 : if (ret) {
1837 : 0 : fprintf(stderr, " Shared shapers params string parse error\n");
1838 : 0 : free(shared_shaper_id);
1839 : 0 : return;
1840 : : }
1841 : :
1842 : 0 : if (res->shaper_profile_id < 0)
1843 : 0 : np.shaper_profile_id = UINT32_MAX;
1844 : : else
1845 : 0 : np.shaper_profile_id = res->shaper_profile_id;
1846 : :
1847 : 0 : np.n_shared_shapers = n_shared_shapers;
1848 : 0 : if (np.n_shared_shapers) {
1849 : 0 : np.shared_shaper_id = &shared_shaper_id[0];
1850 : : } else {
1851 : 0 : free(shared_shaper_id);
1852 : : shared_shaper_id = NULL;
1853 : : }
1854 : :
1855 : 0 : if (res->n_sp_priorities)
1856 : 0 : wfq_weight_mode = calloc(res->n_sp_priorities, sizeof(int));
1857 : 0 : np.nonleaf.n_sp_priorities = res->n_sp_priorities;
1858 : 0 : np.stats_mask = res->stats_mask;
1859 : 0 : np.nonleaf.wfq_weight_mode = wfq_weight_mode;
1860 : :
1861 : 0 : ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
1862 : : res->priority, res->weight, res->level_id,
1863 : : &np, &error);
1864 : 0 : if (ret != 0) {
1865 : 0 : print_err_msg(&error);
1866 : 0 : free(shared_shaper_id);
1867 : 0 : free(wfq_weight_mode);
1868 : 0 : return;
1869 : : }
1870 : : }
1871 : :
1872 : : cmdline_parse_inst_t cmd_add_port_tm_nonleaf_node_pmode = {
1873 : : .f = cmd_add_port_tm_nonleaf_node_pmode_parsed,
1874 : : .data = NULL,
1875 : : .help_str = "Add port tm nonleaf node pktmode",
1876 : : .tokens = {
1877 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_add,
1878 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_port,
1879 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_tm,
1880 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_nonleaf,
1881 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_node,
1882 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_pktmode,
1883 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_port_id,
1884 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_node_id,
1885 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_parent_node_id,
1886 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_priority,
1887 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_weight,
1888 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_level_id,
1889 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_shaper_profile_id,
1890 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_n_sp_priorities,
1891 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_stats_mask,
1892 : : (void *)&cmd_add_port_tm_nonleaf_node_pmode_multi_shrd_shpr_id,
1893 : : NULL,
1894 : : },
1895 : : };
1896 : : /* *** Add Port TM leaf node *** */
1897 : : struct cmd_add_port_tm_leaf_node_result {
1898 : : cmdline_fixed_string_t add;
1899 : : cmdline_fixed_string_t port;
1900 : : cmdline_fixed_string_t tm;
1901 : : cmdline_fixed_string_t leaf;
1902 : : cmdline_fixed_string_t node;
1903 : : uint16_t port_id;
1904 : : uint32_t node_id;
1905 : : int32_t parent_node_id;
1906 : : uint32_t priority;
1907 : : uint32_t weight;
1908 : : uint32_t level_id;
1909 : : int32_t shaper_profile_id;
1910 : : uint32_t cman_mode;
1911 : : uint32_t wred_profile_id;
1912 : : uint64_t stats_mask;
1913 : : cmdline_multi_string_t multi_shared_shaper_id;
1914 : : };
1915 : :
1916 : : static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_add =
1917 : : TOKEN_STRING_INITIALIZER(
1918 : : struct cmd_add_port_tm_leaf_node_result, add, "add");
1919 : : static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_port =
1920 : : TOKEN_STRING_INITIALIZER(
1921 : : struct cmd_add_port_tm_leaf_node_result, port, "port");
1922 : : static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_tm =
1923 : : TOKEN_STRING_INITIALIZER(
1924 : : struct cmd_add_port_tm_leaf_node_result, tm, "tm");
1925 : : static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_nonleaf =
1926 : : TOKEN_STRING_INITIALIZER(
1927 : : struct cmd_add_port_tm_leaf_node_result, leaf, "leaf");
1928 : : static cmdline_parse_token_string_t cmd_add_port_tm_leaf_node_node =
1929 : : TOKEN_STRING_INITIALIZER(
1930 : : struct cmd_add_port_tm_leaf_node_result, node, "node");
1931 : : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_port_id =
1932 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1933 : : port_id, RTE_UINT16);
1934 : : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_node_id =
1935 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1936 : : node_id, RTE_UINT32);
1937 : : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_parent_node_id =
1938 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1939 : : parent_node_id, RTE_INT32);
1940 : : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_priority =
1941 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1942 : : priority, RTE_UINT32);
1943 : : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_weight =
1944 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1945 : : weight, RTE_UINT32);
1946 : : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_level_id =
1947 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1948 : : level_id, RTE_UINT32);
1949 : : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_shaper_profile_id =
1950 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1951 : : shaper_profile_id, RTE_INT32);
1952 : : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_cman_mode =
1953 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1954 : : cman_mode, RTE_UINT32);
1955 : : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_wred_profile_id =
1956 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1957 : : wred_profile_id, RTE_UINT32);
1958 : : static cmdline_parse_token_num_t cmd_add_port_tm_leaf_node_stats_mask =
1959 : : TOKEN_NUM_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1960 : : stats_mask, RTE_UINT64);
1961 : : static cmdline_parse_token_string_t
1962 : : cmd_add_port_tm_leaf_node_multi_shared_shaper_id =
1963 : : TOKEN_STRING_INITIALIZER(struct cmd_add_port_tm_leaf_node_result,
1964 : : multi_shared_shaper_id, TOKEN_STRING_MULTI);
1965 : :
1966 : 0 : static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
1967 : : __rte_unused struct cmdline *cl,
1968 : : __rte_unused void *data)
1969 : : {
1970 : : struct cmd_add_port_tm_leaf_node_result *res = parsed_result;
1971 : : struct rte_tm_error error;
1972 : : struct rte_tm_node_params np;
1973 : : uint32_t *shared_shaper_id;
1974 : 0 : uint32_t parent_node_id, n_shared_shapers = 0;
1975 : 0 : portid_t port_id = res->port_id;
1976 : 0 : char *s_str = res->multi_shared_shaper_id;
1977 : : int ret;
1978 : :
1979 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
1980 : 0 : return;
1981 : :
1982 : : memset(&np, 0, sizeof(struct rte_tm_node_params));
1983 : : memset(&error, 0, sizeof(struct rte_tm_error));
1984 : :
1985 : : /* Node parameters */
1986 : 0 : if (res->parent_node_id < 0)
1987 : : parent_node_id = UINT32_MAX;
1988 : : else
1989 : 0 : parent_node_id = res->parent_node_id;
1990 : :
1991 : 0 : shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS *
1992 : : sizeof(uint32_t));
1993 : 0 : if (shared_shaper_id == NULL) {
1994 : 0 : fprintf(stderr,
1995 : : " Memory not allocated for shared shapers (error)\n");
1996 : 0 : return;
1997 : : }
1998 : :
1999 : : /* Parse multi shared shaper id string */
2000 : 0 : ret = parse_multi_ss_id_str(s_str, &n_shared_shapers, shared_shaper_id);
2001 : 0 : if (ret) {
2002 : 0 : fprintf(stderr, " Shared shapers params string parse error\n");
2003 : 0 : free(shared_shaper_id);
2004 : 0 : return;
2005 : : }
2006 : :
2007 : 0 : if (res->shaper_profile_id < 0)
2008 : 0 : np.shaper_profile_id = UINT32_MAX;
2009 : : else
2010 : 0 : np.shaper_profile_id = res->shaper_profile_id;
2011 : :
2012 : 0 : np.n_shared_shapers = n_shared_shapers;
2013 : :
2014 : 0 : if (np.n_shared_shapers) {
2015 : 0 : np.shared_shaper_id = &shared_shaper_id[0];
2016 : : } else {
2017 : 0 : free(shared_shaper_id);
2018 : : shared_shaper_id = NULL;
2019 : : }
2020 : :
2021 : 0 : np.leaf.cman = res->cman_mode;
2022 : 0 : np.leaf.wred.wred_profile_id = res->wred_profile_id;
2023 : 0 : np.stats_mask = res->stats_mask;
2024 : :
2025 : 0 : ret = rte_tm_node_add(port_id, res->node_id, parent_node_id,
2026 : : res->priority, res->weight, res->level_id,
2027 : : &np, &error);
2028 : 0 : if (ret != 0) {
2029 : 0 : print_err_msg(&error);
2030 : 0 : free(shared_shaper_id);
2031 : 0 : return;
2032 : : }
2033 : : }
2034 : :
2035 : : cmdline_parse_inst_t cmd_add_port_tm_leaf_node = {
2036 : : .f = cmd_add_port_tm_leaf_node_parsed,
2037 : : .data = NULL,
2038 : : .help_str = "Add port tm leaf node",
2039 : : .tokens = {
2040 : : (void *)&cmd_add_port_tm_leaf_node_add,
2041 : : (void *)&cmd_add_port_tm_leaf_node_port,
2042 : : (void *)&cmd_add_port_tm_leaf_node_tm,
2043 : : (void *)&cmd_add_port_tm_leaf_node_nonleaf,
2044 : : (void *)&cmd_add_port_tm_leaf_node_node,
2045 : : (void *)&cmd_add_port_tm_leaf_node_port_id,
2046 : : (void *)&cmd_add_port_tm_leaf_node_node_id,
2047 : : (void *)&cmd_add_port_tm_leaf_node_parent_node_id,
2048 : : (void *)&cmd_add_port_tm_leaf_node_priority,
2049 : : (void *)&cmd_add_port_tm_leaf_node_weight,
2050 : : (void *)&cmd_add_port_tm_leaf_node_level_id,
2051 : : (void *)&cmd_add_port_tm_leaf_node_shaper_profile_id,
2052 : : (void *)&cmd_add_port_tm_leaf_node_cman_mode,
2053 : : (void *)&cmd_add_port_tm_leaf_node_wred_profile_id,
2054 : : (void *)&cmd_add_port_tm_leaf_node_stats_mask,
2055 : : (void *)&cmd_add_port_tm_leaf_node_multi_shared_shaper_id,
2056 : : NULL,
2057 : : },
2058 : : };
2059 : :
2060 : : /* *** Delete Port TM Node *** */
2061 : : struct cmd_del_port_tm_node_result {
2062 : : cmdline_fixed_string_t del;
2063 : : cmdline_fixed_string_t port;
2064 : : cmdline_fixed_string_t tm;
2065 : : cmdline_fixed_string_t node;
2066 : : uint16_t port_id;
2067 : : uint32_t node_id;
2068 : : };
2069 : :
2070 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_del =
2071 : : TOKEN_STRING_INITIALIZER(
2072 : : struct cmd_del_port_tm_node_result, del, "del");
2073 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_port =
2074 : : TOKEN_STRING_INITIALIZER(
2075 : : struct cmd_del_port_tm_node_result, port, "port");
2076 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_tm =
2077 : : TOKEN_STRING_INITIALIZER(
2078 : : struct cmd_del_port_tm_node_result, tm, "tm");
2079 : : static cmdline_parse_token_string_t cmd_del_port_tm_node_node =
2080 : : TOKEN_STRING_INITIALIZER(
2081 : : struct cmd_del_port_tm_node_result, node, "node");
2082 : : static cmdline_parse_token_num_t cmd_del_port_tm_node_port_id =
2083 : : TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
2084 : : port_id, RTE_UINT16);
2085 : : static cmdline_parse_token_num_t cmd_del_port_tm_node_node_id =
2086 : : TOKEN_NUM_INITIALIZER(struct cmd_del_port_tm_node_result,
2087 : : node_id, RTE_UINT32);
2088 : :
2089 : 0 : static void cmd_del_port_tm_node_parsed(void *parsed_result,
2090 : : __rte_unused struct cmdline *cl,
2091 : : __rte_unused void *data)
2092 : : {
2093 : : struct cmd_del_port_tm_node_result *res = parsed_result;
2094 : : struct rte_tm_error error;
2095 : 0 : uint32_t node_id = res->node_id;
2096 : 0 : portid_t port_id = res->port_id;
2097 : : int ret;
2098 : :
2099 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
2100 : 0 : return;
2101 : :
2102 : : memset(&error, 0, sizeof(struct rte_tm_error));
2103 : : /* Port status */
2104 : 0 : if (port_is_started(port_id)) {
2105 : 0 : fprintf(stderr, " Port %u not stopped (error)\n", port_id);
2106 : 0 : return;
2107 : : }
2108 : :
2109 : 0 : ret = rte_tm_node_delete(port_id, node_id, &error);
2110 : 0 : if (ret != 0) {
2111 : 0 : print_err_msg(&error);
2112 : 0 : return;
2113 : : }
2114 : : }
2115 : :
2116 : : cmdline_parse_inst_t cmd_del_port_tm_node = {
2117 : : .f = cmd_del_port_tm_node_parsed,
2118 : : .data = NULL,
2119 : : .help_str = "Delete port tm node",
2120 : : .tokens = {
2121 : : (void *)&cmd_del_port_tm_node_del,
2122 : : (void *)&cmd_del_port_tm_node_port,
2123 : : (void *)&cmd_del_port_tm_node_tm,
2124 : : (void *)&cmd_del_port_tm_node_node,
2125 : : (void *)&cmd_del_port_tm_node_port_id,
2126 : : (void *)&cmd_del_port_tm_node_node_id,
2127 : : NULL,
2128 : : },
2129 : : };
2130 : :
2131 : : /* *** Update Port TM Node Parent *** */
2132 : : struct cmd_set_port_tm_node_parent_result {
2133 : : cmdline_fixed_string_t set;
2134 : : cmdline_fixed_string_t port;
2135 : : cmdline_fixed_string_t tm;
2136 : : cmdline_fixed_string_t node;
2137 : : cmdline_fixed_string_t parent;
2138 : : uint16_t port_id;
2139 : : uint32_t node_id;
2140 : : uint32_t parent_id;
2141 : : uint32_t priority;
2142 : : uint32_t weight;
2143 : : };
2144 : :
2145 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_set =
2146 : : TOKEN_STRING_INITIALIZER(
2147 : : struct cmd_set_port_tm_node_parent_result, set, "set");
2148 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_port =
2149 : : TOKEN_STRING_INITIALIZER(
2150 : : struct cmd_set_port_tm_node_parent_result, port, "port");
2151 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_tm =
2152 : : TOKEN_STRING_INITIALIZER(
2153 : : struct cmd_set_port_tm_node_parent_result, tm, "tm");
2154 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_node =
2155 : : TOKEN_STRING_INITIALIZER(
2156 : : struct cmd_set_port_tm_node_parent_result, node, "node");
2157 : : static cmdline_parse_token_string_t cmd_set_port_tm_node_parent_parent =
2158 : : TOKEN_STRING_INITIALIZER(
2159 : : struct cmd_set_port_tm_node_parent_result, parent, "parent");
2160 : : static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_port_id =
2161 : : TOKEN_NUM_INITIALIZER(
2162 : : struct cmd_set_port_tm_node_parent_result, port_id,
2163 : : RTE_UINT16);
2164 : : static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_node_id =
2165 : : TOKEN_NUM_INITIALIZER(
2166 : : struct cmd_set_port_tm_node_parent_result, node_id,
2167 : : RTE_UINT32);
2168 : : static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_parent_id =
2169 : : TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2170 : : parent_id, RTE_UINT32);
2171 : : static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_priority =
2172 : : TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2173 : : priority, RTE_UINT32);
2174 : : static cmdline_parse_token_num_t cmd_set_port_tm_node_parent_weight =
2175 : : TOKEN_NUM_INITIALIZER(struct cmd_set_port_tm_node_parent_result,
2176 : : weight, RTE_UINT32);
2177 : :
2178 : 0 : static void cmd_set_port_tm_node_parent_parsed(void *parsed_result,
2179 : : __rte_unused struct cmdline *cl,
2180 : : __rte_unused void *data)
2181 : : {
2182 : : struct cmd_set_port_tm_node_parent_result *res = parsed_result;
2183 : : struct rte_tm_error error;
2184 : 0 : uint32_t node_id = res->node_id;
2185 : 0 : uint32_t parent_id = res->parent_id;
2186 : 0 : uint32_t priority = res->priority;
2187 : 0 : uint32_t weight = res->weight;
2188 : 0 : portid_t port_id = res->port_id;
2189 : : int ret;
2190 : :
2191 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
2192 : 0 : return;
2193 : :
2194 : : memset(&error, 0, sizeof(struct rte_tm_error));
2195 : : /* Port status */
2196 : 0 : if (!port_is_started(port_id)) {
2197 : 0 : fprintf(stderr, " Port %u not started (error)\n", port_id);
2198 : 0 : return;
2199 : : }
2200 : :
2201 : 0 : ret = rte_tm_node_parent_update(port_id, node_id,
2202 : : parent_id, priority, weight, &error);
2203 : 0 : if (ret != 0) {
2204 : 0 : print_err_msg(&error);
2205 : 0 : return;
2206 : : }
2207 : : }
2208 : :
2209 : : cmdline_parse_inst_t cmd_set_port_tm_node_parent = {
2210 : : .f = cmd_set_port_tm_node_parent_parsed,
2211 : : .data = NULL,
2212 : : .help_str = "Set port tm node parent",
2213 : : .tokens = {
2214 : : (void *)&cmd_set_port_tm_node_parent_set,
2215 : : (void *)&cmd_set_port_tm_node_parent_port,
2216 : : (void *)&cmd_set_port_tm_node_parent_tm,
2217 : : (void *)&cmd_set_port_tm_node_parent_node,
2218 : : (void *)&cmd_set_port_tm_node_parent_parent,
2219 : : (void *)&cmd_set_port_tm_node_parent_port_id,
2220 : : (void *)&cmd_set_port_tm_node_parent_node_id,
2221 : : (void *)&cmd_set_port_tm_node_parent_parent_id,
2222 : : (void *)&cmd_set_port_tm_node_parent_priority,
2223 : : (void *)&cmd_set_port_tm_node_parent_weight,
2224 : : NULL,
2225 : : },
2226 : : };
2227 : :
2228 : : /* *** Suspend Port TM Node *** */
2229 : : struct cmd_suspend_port_tm_node_result {
2230 : : cmdline_fixed_string_t suspend;
2231 : : cmdline_fixed_string_t port;
2232 : : cmdline_fixed_string_t tm;
2233 : : cmdline_fixed_string_t node;
2234 : : uint16_t port_id;
2235 : : uint32_t node_id;
2236 : : };
2237 : :
2238 : : static cmdline_parse_token_string_t cmd_suspend_port_tm_node_suspend =
2239 : : TOKEN_STRING_INITIALIZER(
2240 : : struct cmd_suspend_port_tm_node_result, suspend, "suspend");
2241 : : static cmdline_parse_token_string_t cmd_suspend_port_tm_node_port =
2242 : : TOKEN_STRING_INITIALIZER(
2243 : : struct cmd_suspend_port_tm_node_result, port, "port");
2244 : : static cmdline_parse_token_string_t cmd_suspend_port_tm_node_tm =
2245 : : TOKEN_STRING_INITIALIZER(
2246 : : struct cmd_suspend_port_tm_node_result, tm, "tm");
2247 : : static cmdline_parse_token_string_t cmd_suspend_port_tm_node_node =
2248 : : TOKEN_STRING_INITIALIZER(
2249 : : struct cmd_suspend_port_tm_node_result, node, "node");
2250 : : static cmdline_parse_token_num_t cmd_suspend_port_tm_node_port_id =
2251 : : TOKEN_NUM_INITIALIZER(
2252 : : struct cmd_suspend_port_tm_node_result, port_id,
2253 : : RTE_UINT16);
2254 : : static cmdline_parse_token_num_t cmd_suspend_port_tm_node_node_id =
2255 : : TOKEN_NUM_INITIALIZER(
2256 : : struct cmd_suspend_port_tm_node_result, node_id,
2257 : : RTE_UINT32);
2258 : :
2259 : 0 : static void cmd_suspend_port_tm_node_parsed(void *parsed_result,
2260 : : __rte_unused struct cmdline *cl,
2261 : : __rte_unused void *data)
2262 : : {
2263 : : struct cmd_suspend_port_tm_node_result *res = parsed_result;
2264 : : struct rte_tm_error error;
2265 : 0 : uint32_t node_id = res->node_id;
2266 : 0 : portid_t port_id = res->port_id;
2267 : : int ret;
2268 : :
2269 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
2270 : 0 : return;
2271 : :
2272 : : memset(&error, 0, sizeof(struct rte_tm_error));
2273 : 0 : ret = rte_tm_node_suspend(port_id, node_id, &error);
2274 : 0 : if (ret != 0) {
2275 : 0 : print_err_msg(&error);
2276 : 0 : return;
2277 : : }
2278 : : }
2279 : :
2280 : : cmdline_parse_inst_t cmd_suspend_port_tm_node = {
2281 : : .f = cmd_suspend_port_tm_node_parsed,
2282 : : .data = NULL,
2283 : : .help_str = "Suspend port tm node",
2284 : : .tokens = {
2285 : : (void *)&cmd_suspend_port_tm_node_suspend,
2286 : : (void *)&cmd_suspend_port_tm_node_port,
2287 : : (void *)&cmd_suspend_port_tm_node_tm,
2288 : : (void *)&cmd_suspend_port_tm_node_node,
2289 : : (void *)&cmd_suspend_port_tm_node_port_id,
2290 : : (void *)&cmd_suspend_port_tm_node_node_id,
2291 : : NULL,
2292 : : },
2293 : : };
2294 : :
2295 : : /* *** Resume Port TM Node *** */
2296 : : struct cmd_resume_port_tm_node_result {
2297 : : cmdline_fixed_string_t resume;
2298 : : cmdline_fixed_string_t port;
2299 : : cmdline_fixed_string_t tm;
2300 : : cmdline_fixed_string_t node;
2301 : : uint16_t port_id;
2302 : : uint32_t node_id;
2303 : : };
2304 : :
2305 : : static cmdline_parse_token_string_t cmd_resume_port_tm_node_resume =
2306 : : TOKEN_STRING_INITIALIZER(
2307 : : struct cmd_resume_port_tm_node_result, resume, "resume");
2308 : : static cmdline_parse_token_string_t cmd_resume_port_tm_node_port =
2309 : : TOKEN_STRING_INITIALIZER(
2310 : : struct cmd_resume_port_tm_node_result, port, "port");
2311 : : static cmdline_parse_token_string_t cmd_resume_port_tm_node_tm =
2312 : : TOKEN_STRING_INITIALIZER(
2313 : : struct cmd_resume_port_tm_node_result, tm, "tm");
2314 : : static cmdline_parse_token_string_t cmd_resume_port_tm_node_node =
2315 : : TOKEN_STRING_INITIALIZER(
2316 : : struct cmd_resume_port_tm_node_result, node, "node");
2317 : : static cmdline_parse_token_num_t cmd_resume_port_tm_node_port_id =
2318 : : TOKEN_NUM_INITIALIZER(
2319 : : struct cmd_resume_port_tm_node_result, port_id, RTE_UINT16);
2320 : : static cmdline_parse_token_num_t cmd_resume_port_tm_node_node_id =
2321 : : TOKEN_NUM_INITIALIZER(
2322 : : struct cmd_resume_port_tm_node_result, node_id, RTE_UINT32);
2323 : :
2324 : 0 : static void cmd_resume_port_tm_node_parsed(void *parsed_result,
2325 : : __rte_unused struct cmdline *cl,
2326 : : __rte_unused void *data)
2327 : : {
2328 : : struct cmd_resume_port_tm_node_result *res = parsed_result;
2329 : : struct rte_tm_error error;
2330 : 0 : uint32_t node_id = res->node_id;
2331 : 0 : portid_t port_id = res->port_id;
2332 : : int ret;
2333 : :
2334 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
2335 : 0 : return;
2336 : :
2337 : : memset(&error, 0, sizeof(struct rte_tm_error));
2338 : 0 : ret = rte_tm_node_resume(port_id, node_id, &error);
2339 : 0 : if (ret != 0) {
2340 : 0 : print_err_msg(&error);
2341 : 0 : return;
2342 : : }
2343 : : }
2344 : :
2345 : : cmdline_parse_inst_t cmd_resume_port_tm_node = {
2346 : : .f = cmd_resume_port_tm_node_parsed,
2347 : : .data = NULL,
2348 : : .help_str = "Resume port tm node",
2349 : : .tokens = {
2350 : : (void *)&cmd_resume_port_tm_node_resume,
2351 : : (void *)&cmd_resume_port_tm_node_port,
2352 : : (void *)&cmd_resume_port_tm_node_tm,
2353 : : (void *)&cmd_resume_port_tm_node_node,
2354 : : (void *)&cmd_resume_port_tm_node_port_id,
2355 : : (void *)&cmd_resume_port_tm_node_node_id,
2356 : : NULL,
2357 : : },
2358 : : };
2359 : :
2360 : : /* *** Port TM Hierarchy Commit *** */
2361 : : struct cmd_port_tm_hierarchy_commit_result {
2362 : : cmdline_fixed_string_t port;
2363 : : cmdline_fixed_string_t tm;
2364 : : cmdline_fixed_string_t hierarchy;
2365 : : cmdline_fixed_string_t commit;
2366 : : uint16_t port_id;
2367 : : cmdline_fixed_string_t clean_on_fail;
2368 : : };
2369 : :
2370 : : static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_port =
2371 : : TOKEN_STRING_INITIALIZER(
2372 : : struct cmd_port_tm_hierarchy_commit_result, port, "port");
2373 : : static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_tm =
2374 : : TOKEN_STRING_INITIALIZER(
2375 : : struct cmd_port_tm_hierarchy_commit_result, tm, "tm");
2376 : : static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_hierarchy =
2377 : : TOKEN_STRING_INITIALIZER(
2378 : : struct cmd_port_tm_hierarchy_commit_result,
2379 : : hierarchy, "hierarchy");
2380 : : static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_commit =
2381 : : TOKEN_STRING_INITIALIZER(
2382 : : struct cmd_port_tm_hierarchy_commit_result, commit, "commit");
2383 : : static cmdline_parse_token_num_t cmd_port_tm_hierarchy_commit_port_id =
2384 : : TOKEN_NUM_INITIALIZER(
2385 : : struct cmd_port_tm_hierarchy_commit_result,
2386 : : port_id, RTE_UINT16);
2387 : : static cmdline_parse_token_string_t cmd_port_tm_hierarchy_commit_clean_on_fail =
2388 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_hierarchy_commit_result,
2389 : : clean_on_fail, "yes#no");
2390 : :
2391 : 0 : static void cmd_port_tm_hierarchy_commit_parsed(void *parsed_result,
2392 : : __rte_unused struct cmdline *cl,
2393 : : __rte_unused void *data)
2394 : : {
2395 : : struct cmd_port_tm_hierarchy_commit_result *res = parsed_result;
2396 : : struct rte_tm_error error;
2397 : : uint32_t clean_on_fail;
2398 : 0 : portid_t port_id = res->port_id;
2399 : : int ret;
2400 : :
2401 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
2402 : 0 : return;
2403 : :
2404 : 0 : if (strcmp(res->clean_on_fail, "yes") == 0)
2405 : : clean_on_fail = 1;
2406 : : else
2407 : : clean_on_fail = 0;
2408 : :
2409 : : memset(&error, 0, sizeof(struct rte_tm_error));
2410 : 0 : ret = rte_tm_hierarchy_commit(port_id, clean_on_fail, &error);
2411 : 0 : if (ret != 0) {
2412 : 0 : print_err_msg(&error);
2413 : 0 : return;
2414 : : }
2415 : : }
2416 : :
2417 : : cmdline_parse_inst_t cmd_port_tm_hierarchy_commit = {
2418 : : .f = cmd_port_tm_hierarchy_commit_parsed,
2419 : : .data = NULL,
2420 : : .help_str = "Commit port tm hierarchy",
2421 : : .tokens = {
2422 : : (void *)&cmd_port_tm_hierarchy_commit_port,
2423 : : (void *)&cmd_port_tm_hierarchy_commit_tm,
2424 : : (void *)&cmd_port_tm_hierarchy_commit_hierarchy,
2425 : : (void *)&cmd_port_tm_hierarchy_commit_commit,
2426 : : (void *)&cmd_port_tm_hierarchy_commit_port_id,
2427 : : (void *)&cmd_port_tm_hierarchy_commit_clean_on_fail,
2428 : : NULL,
2429 : : },
2430 : : };
2431 : :
2432 : : /* *** Port TM Mark IP ECN *** */
2433 : : struct cmd_port_tm_mark_ip_ecn_result {
2434 : : cmdline_fixed_string_t set;
2435 : : cmdline_fixed_string_t port;
2436 : : cmdline_fixed_string_t tm;
2437 : : cmdline_fixed_string_t mark;
2438 : : cmdline_fixed_string_t ip_ecn;
2439 : : uint16_t port_id;
2440 : : uint16_t green;
2441 : : uint16_t yellow;
2442 : : uint16_t red;
2443 : : };
2444 : :
2445 : : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_set =
2446 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2447 : : set, "set");
2448 : :
2449 : : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_port =
2450 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2451 : : port, "port");
2452 : :
2453 : : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_tm =
2454 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result, tm,
2455 : : "tm");
2456 : :
2457 : : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_mark =
2458 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2459 : : mark, "mark");
2460 : :
2461 : : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_ecn_ip_ecn =
2462 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2463 : : ip_ecn, "ip_ecn");
2464 : : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_port_id =
2465 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2466 : : port_id, RTE_UINT16);
2467 : :
2468 : : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_green =
2469 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2470 : : green, RTE_UINT16);
2471 : : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_yellow =
2472 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2473 : : yellow, RTE_UINT16);
2474 : : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_ecn_red =
2475 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_ecn_result,
2476 : : red, RTE_UINT16);
2477 : :
2478 : 0 : static void cmd_port_tm_mark_ip_ecn_parsed(void *parsed_result,
2479 : : __rte_unused struct cmdline *cl,
2480 : : __rte_unused void *data)
2481 : : {
2482 : : struct cmd_port_tm_mark_ip_ecn_result *res = parsed_result;
2483 : : struct rte_tm_error error;
2484 : 0 : portid_t port_id = res->port_id;
2485 : 0 : int green = res->green;
2486 : 0 : int yellow = res->yellow;
2487 : 0 : int red = res->red;
2488 : : int ret;
2489 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
2490 : 0 : return;
2491 : :
2492 : : memset(&error, 0, sizeof(struct rte_tm_error));
2493 : 0 : ret = rte_tm_mark_ip_ecn(port_id, green, yellow, red, &error);
2494 : 0 : if (ret != 0) {
2495 : 0 : print_err_msg(&error);
2496 : 0 : return;
2497 : : }
2498 : : }
2499 : :
2500 : : cmdline_parse_inst_t cmd_port_tm_mark_ip_ecn = {
2501 : : .f = cmd_port_tm_mark_ip_ecn_parsed,
2502 : : .data = NULL,
2503 : : .help_str = "set port tm mark ip_ecn <port> <green> <yellow> <red>",
2504 : : .tokens = {
2505 : : (void *)&cmd_port_tm_mark_ip_ecn_set,
2506 : : (void *)&cmd_port_tm_mark_ip_ecn_port,
2507 : : (void *)&cmd_port_tm_mark_ip_ecn_tm,
2508 : : (void *)&cmd_port_tm_mark_ip_ecn_mark,
2509 : : (void *)&cmd_port_tm_mark_ip_ecn_ip_ecn,
2510 : : (void *)&cmd_port_tm_mark_ip_ecn_port_id,
2511 : : (void *)&cmd_port_tm_mark_ip_ecn_green,
2512 : : (void *)&cmd_port_tm_mark_ip_ecn_yellow,
2513 : : (void *)&cmd_port_tm_mark_ip_ecn_red,
2514 : : NULL,
2515 : : },
2516 : : };
2517 : :
2518 : :
2519 : : /* *** Port TM Mark IP DSCP *** */
2520 : : struct cmd_port_tm_mark_ip_dscp_result {
2521 : : cmdline_fixed_string_t set;
2522 : : cmdline_fixed_string_t port;
2523 : : cmdline_fixed_string_t tm;
2524 : : cmdline_fixed_string_t mark;
2525 : : cmdline_fixed_string_t ip_dscp;
2526 : : uint16_t port_id;
2527 : : uint16_t green;
2528 : : uint16_t yellow;
2529 : : uint16_t red;
2530 : : };
2531 : :
2532 : : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_set =
2533 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2534 : : set, "set");
2535 : :
2536 : : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_port =
2537 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2538 : : port, "port");
2539 : :
2540 : : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_tm =
2541 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result, tm,
2542 : : "tm");
2543 : :
2544 : : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_mark =
2545 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2546 : : mark, "mark");
2547 : :
2548 : : static cmdline_parse_token_string_t cmd_port_tm_mark_ip_dscp_ip_dscp =
2549 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2550 : : ip_dscp, "ip_dscp");
2551 : : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_port_id =
2552 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2553 : : port_id, RTE_UINT16);
2554 : :
2555 : : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_green =
2556 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2557 : : green, RTE_UINT16);
2558 : : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_yellow =
2559 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2560 : : yellow, RTE_UINT16);
2561 : : static cmdline_parse_token_num_t cmd_port_tm_mark_ip_dscp_red =
2562 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_ip_dscp_result,
2563 : : red, RTE_UINT16);
2564 : :
2565 : 0 : static void cmd_port_tm_mark_ip_dscp_parsed(void *parsed_result,
2566 : : __rte_unused struct cmdline *cl,
2567 : : __rte_unused void *data)
2568 : : {
2569 : : struct cmd_port_tm_mark_ip_dscp_result *res = parsed_result;
2570 : : struct rte_tm_error error;
2571 : 0 : portid_t port_id = res->port_id;
2572 : 0 : int green = res->green;
2573 : 0 : int yellow = res->yellow;
2574 : 0 : int red = res->red;
2575 : : int ret;
2576 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
2577 : 0 : return;
2578 : :
2579 : : memset(&error, 0, sizeof(struct rte_tm_error));
2580 : 0 : ret = rte_tm_mark_ip_dscp(port_id, green, yellow, red, &error);
2581 : 0 : if (ret != 0) {
2582 : 0 : print_err_msg(&error);
2583 : 0 : return;
2584 : : }
2585 : : }
2586 : :
2587 : : cmdline_parse_inst_t cmd_port_tm_mark_ip_dscp = {
2588 : : .f = cmd_port_tm_mark_ip_dscp_parsed,
2589 : : .data = NULL,
2590 : : .help_str = "set port tm mark ip_dscp <port> <green> <yellow> <red>",
2591 : : .tokens = {
2592 : : (void *)&cmd_port_tm_mark_ip_dscp_set,
2593 : : (void *)&cmd_port_tm_mark_ip_dscp_port,
2594 : : (void *)&cmd_port_tm_mark_ip_dscp_tm,
2595 : : (void *)&cmd_port_tm_mark_ip_dscp_mark,
2596 : : (void *)&cmd_port_tm_mark_ip_dscp_ip_dscp,
2597 : : (void *)&cmd_port_tm_mark_ip_dscp_port_id,
2598 : : (void *)&cmd_port_tm_mark_ip_dscp_green,
2599 : : (void *)&cmd_port_tm_mark_ip_dscp_yellow,
2600 : : (void *)&cmd_port_tm_mark_ip_dscp_red,
2601 : : NULL,
2602 : : },
2603 : : };
2604 : :
2605 : :
2606 : : /* *** Port TM Mark VLAN_DEI *** */
2607 : : struct cmd_port_tm_mark_vlan_dei_result {
2608 : : cmdline_fixed_string_t set;
2609 : : cmdline_fixed_string_t port;
2610 : : cmdline_fixed_string_t tm;
2611 : : cmdline_fixed_string_t mark;
2612 : : cmdline_fixed_string_t vlan_dei;
2613 : : uint16_t port_id;
2614 : : uint16_t green;
2615 : : uint16_t yellow;
2616 : : uint16_t red;
2617 : : };
2618 : :
2619 : : static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_set =
2620 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2621 : : set, "set");
2622 : :
2623 : : static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_port =
2624 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2625 : : port, "port");
2626 : :
2627 : : static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_tm =
2628 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result, tm,
2629 : : "tm");
2630 : :
2631 : : static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_mark =
2632 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2633 : : mark, "mark");
2634 : :
2635 : : static cmdline_parse_token_string_t cmd_port_tm_mark_vlan_dei_vlan_dei =
2636 : : TOKEN_STRING_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2637 : : vlan_dei, "vlan_dei");
2638 : : static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_port_id =
2639 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2640 : : port_id, RTE_UINT16);
2641 : :
2642 : : static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_green =
2643 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2644 : : green, RTE_UINT16);
2645 : : static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_yellow =
2646 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2647 : : yellow, RTE_UINT16);
2648 : : static cmdline_parse_token_num_t cmd_port_tm_mark_vlan_dei_red =
2649 : : TOKEN_NUM_INITIALIZER(struct cmd_port_tm_mark_vlan_dei_result,
2650 : : red, RTE_UINT16);
2651 : :
2652 : 0 : static void cmd_port_tm_mark_vlan_dei_parsed(void *parsed_result,
2653 : : __rte_unused struct cmdline *cl,
2654 : : __rte_unused void *data)
2655 : : {
2656 : : struct cmd_port_tm_mark_vlan_dei_result *res = parsed_result;
2657 : : struct rte_tm_error error;
2658 : 0 : portid_t port_id = res->port_id;
2659 : 0 : int green = res->green;
2660 : 0 : int yellow = res->yellow;
2661 : 0 : int red = res->red;
2662 : : int ret;
2663 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
2664 : 0 : return;
2665 : :
2666 : : memset(&error, 0, sizeof(struct rte_tm_error));
2667 : 0 : ret = rte_tm_mark_vlan_dei(port_id, green, yellow, red, &error);
2668 : 0 : if (ret != 0) {
2669 : 0 : print_err_msg(&error);
2670 : 0 : return;
2671 : : }
2672 : : }
2673 : :
2674 : : cmdline_parse_inst_t cmd_port_tm_mark_vlan_dei = {
2675 : : .f = cmd_port_tm_mark_vlan_dei_parsed,
2676 : : .data = NULL,
2677 : : .help_str = "set port tm mark vlan_dei <port> <green> <yellow> <red>",
2678 : : .tokens = {
2679 : : (void *)&cmd_port_tm_mark_vlan_dei_set,
2680 : : (void *)&cmd_port_tm_mark_vlan_dei_port,
2681 : : (void *)&cmd_port_tm_mark_vlan_dei_tm,
2682 : : (void *)&cmd_port_tm_mark_vlan_dei_mark,
2683 : : (void *)&cmd_port_tm_mark_vlan_dei_vlan_dei,
2684 : : (void *)&cmd_port_tm_mark_vlan_dei_port_id,
2685 : : (void *)&cmd_port_tm_mark_vlan_dei_green,
2686 : : (void *)&cmd_port_tm_mark_vlan_dei_yellow,
2687 : : (void *)&cmd_port_tm_mark_vlan_dei_red,
2688 : : NULL,
2689 : : },
2690 : : };
|