xref: /dpdk/lib/ethdev/rte_tm.h (revision 7917b0d38e92e8b9ec5a870415b791420e10f11a)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation.
3  * Copyright(c) 2017 Cavium.
4  * Copyright(c) 2017 NXP.
5  */
6 
7 #ifndef __INCLUDE_RTE_TM_H__
8 #define __INCLUDE_RTE_TM_H__
9 
10 /**
11  * @file
12  * RTE Generic Traffic Manager API
13  *
14  * This interface provides the ability to configure the traffic manager in a
15  * generic way. It includes features such as: hierarchical scheduling,
16  * traffic shaping, congestion management, packet marking, etc.
17  */
18 
19 #include <stdint.h>
20 
21 #include <rte_common.h>
22 #include <rte_meter.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * Ethernet framing overhead.
30  *
31  * Overhead fields per Ethernet frame:
32  * 1. Preamble:                                            7 bytes;
33  * 2. Start of Frame Delimiter (SFD):                      1 byte;
34  * 3. Inter-Frame Gap (IFG):                              12 bytes.
35  *
36  * One of the typical values for the *pkt_length_adjust* field of the shaper
37  * profile.
38  *
39  * @see struct rte_tm_shaper_params
40  */
41 #define RTE_TM_ETH_FRAMING_OVERHEAD                  20
42 
43 /**
44  * Ethernet framing overhead including the Frame Check Sequence (FCS) field.
45  * Useful when FCS is generated and added at the end of the Ethernet frame on
46  * Tx side without any SW intervention.
47  *
48  * One of the typical values for the pkt_length_adjust field of the shaper
49  * profile.
50  *
51  * @see struct rte_tm_shaper_params
52  */
53 #define RTE_TM_ETH_FRAMING_OVERHEAD_FCS              24
54 
55 /**
56  * Invalid WRED profile ID.
57  *
58  * @see struct rte_tm_node_params
59  * @see rte_tm_node_add()
60  * @see rte_tm_node_wred_context_update()
61  */
62 #define RTE_TM_WRED_PROFILE_ID_NONE                  UINT32_MAX
63 
64 /**
65  *Invalid shaper profile ID.
66  *
67  * @see struct rte_tm_node_params
68  * @see rte_tm_node_add()
69  * @see rte_tm_node_shaper_update()
70  */
71 #define RTE_TM_SHAPER_PROFILE_ID_NONE                UINT32_MAX
72 
73 /**
74  * Node ID for the parent of the root node.
75  *
76  * @see rte_tm_node_add()
77  */
78 #define RTE_TM_NODE_ID_NULL                          UINT32_MAX
79 
80 /**
81  * Node level ID used to disable level ID checking.
82  *
83  * @see rte_tm_node_add()
84  */
85 #define RTE_TM_NODE_LEVEL_ID_ANY                     UINT32_MAX
86 
87 /**
88  * Node statistics counter type
89  */
90 enum rte_tm_stats_type {
91 	/** Number of packets scheduled from current node. */
92 	RTE_TM_STATS_N_PKTS = 1 << 0,
93 
94 	/** Number of bytes scheduled from current node. */
95 	RTE_TM_STATS_N_BYTES = 1 << 1,
96 
97 	/** Number of green packets dropped by current leaf node.  */
98 	RTE_TM_STATS_N_PKTS_GREEN_DROPPED = 1 << 2,
99 
100 	/** Number of yellow packets dropped by current leaf node.  */
101 	RTE_TM_STATS_N_PKTS_YELLOW_DROPPED = 1 << 3,
102 
103 	/** Number of red packets dropped by current leaf node.  */
104 	RTE_TM_STATS_N_PKTS_RED_DROPPED = 1 << 4,
105 
106 	/** Number of green bytes dropped by current leaf node.  */
107 	RTE_TM_STATS_N_BYTES_GREEN_DROPPED = 1 << 5,
108 
109 	/** Number of yellow bytes dropped by current leaf node.  */
110 	RTE_TM_STATS_N_BYTES_YELLOW_DROPPED = 1 << 6,
111 
112 	/** Number of red bytes dropped by current leaf node.  */
113 	RTE_TM_STATS_N_BYTES_RED_DROPPED = 1 << 7,
114 
115 	/** Number of packets currently waiting in the packet queue of current
116 	 * leaf node.
117 	 */
118 	RTE_TM_STATS_N_PKTS_QUEUED = 1 << 8,
119 
120 	/** Number of bytes currently waiting in the packet queue of current
121 	 * leaf node.
122 	 */
123 	RTE_TM_STATS_N_BYTES_QUEUED = 1 << 9,
124 };
125 
126 /**
127  * Node statistics counters
128  */
129 struct rte_tm_node_stats {
130 	/** Number of packets scheduled from current node. */
131 	uint64_t n_pkts;
132 
133 	/** Number of bytes scheduled from current node. */
134 	uint64_t n_bytes;
135 
136 	/** Statistics counters for leaf nodes only. */
137 	struct {
138 		/** Number of packets dropped by current leaf node per each
139 		 * color.
140 		 */
141 		uint64_t n_pkts_dropped[RTE_COLORS];
142 
143 		/** Number of bytes dropped by current leaf node per each
144 		 * color.
145 		 */
146 		uint64_t n_bytes_dropped[RTE_COLORS];
147 
148 		/** Number of packets currently waiting in the packet queue of
149 		 * current leaf node.
150 		 */
151 		uint64_t n_pkts_queued;
152 
153 		/** Number of bytes currently waiting in the packet queue of
154 		 * current leaf node.
155 		 */
156 		uint64_t n_bytes_queued;
157 	} leaf;
158 };
159 
160 /**
161  * Traffic manager dynamic updates
162  */
163 enum rte_tm_dynamic_update_type {
164 	/** Dynamic parent node update. The new parent node is located on same
165 	 * hierarchy level as the former parent node. Consequently, the node
166 	 * whose parent is changed preserves its hierarchy level.
167 	 */
168 	RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL = 1 << 0,
169 
170 	/** Dynamic parent node update. The new parent node is located on
171 	 * different hierarchy level than the former parent node. Consequently,
172 	 * the node whose parent is changed also changes its hierarchy level.
173 	 */
174 	RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL = 1 << 1,
175 
176 	/** Dynamic node add/delete. */
177 	RTE_TM_UPDATE_NODE_ADD_DELETE = 1 << 2,
178 
179 	/** Suspend/resume nodes. */
180 	RTE_TM_UPDATE_NODE_SUSPEND_RESUME = 1 << 3,
181 
182 	/** Dynamic switch between byte-based and packet-based WFQ weights. */
183 	RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE = 1 << 4,
184 
185 	/** Dynamic update on number of SP priorities. */
186 	RTE_TM_UPDATE_NODE_N_SP_PRIORITIES = 1 << 5,
187 
188 	/** Dynamic update of congestion management mode for leaf nodes. */
189 	RTE_TM_UPDATE_NODE_CMAN = 1 << 6,
190 
191 	/** Dynamic update of the set of enabled stats counter types. */
192 	RTE_TM_UPDATE_NODE_STATS = 1 << 7,
193 };
194 
195 /**
196  * Traffic manager capabilities
197  */
198 struct rte_tm_capabilities {
199 	/** Maximum number of nodes. */
200 	uint32_t n_nodes_max;
201 
202 	/** Maximum number of levels (i.e. number of nodes connecting the root
203 	 * node with any leaf node, including the root and the leaf).
204 	 */
205 	uint32_t n_levels_max;
206 
207 	/** When non-zero, this flag indicates that all the non-leaf nodes
208 	 * (with the exception of the root node) have identical capability set.
209 	 */
210 	int non_leaf_nodes_identical;
211 
212 	/** When non-zero, this flag indicates that all the leaf nodes have
213 	 * identical capability set.
214 	 */
215 	int leaf_nodes_identical;
216 
217 	/** Maximum number of shapers, either private or shared. In case the
218 	 * implementation does not share any resources between private and
219 	 * shared shapers, it is typically equal to the sum of
220 	 * *shaper_private_n_max* and *shaper_shared_n_max*. The
221 	 * value of zero indicates that traffic shaping is not supported.
222 	 */
223 	uint32_t shaper_n_max;
224 
225 	/** Maximum number of private shapers. Indicates the maximum number of
226 	 * nodes that can concurrently have their private shaper enabled. The
227 	 * value of zero indicates that private shapers are not supported.
228 	 */
229 	uint32_t shaper_private_n_max;
230 
231 	/** Maximum number of private shapers that support dual rate shaping.
232 	 * Indicates the maximum number of nodes that can concurrently have
233 	 * their private shaper enabled with dual rate support. Only valid when
234 	 * private shapers are supported. The value of zero indicates that dual
235 	 * rate shaping is not available for private shapers. The maximum value
236 	 * is *shaper_private_n_max*.
237 	 */
238 	int shaper_private_dual_rate_n_max;
239 
240 	/** Minimum committed/peak rate (bytes per second) for any private
241 	 * shaper. Valid only when private shapers are supported.
242 	 */
243 	uint64_t shaper_private_rate_min;
244 
245 	/** Maximum committed/peak rate (bytes per second) for any private
246 	 * shaper. Valid only when private shapers are supported.
247 	 */
248 	uint64_t shaper_private_rate_max;
249 
250 	/** Shaper private packet mode supported. When non-zero, this parameter
251 	 * indicates that there is at least one node that can be configured
252 	 * with packet mode in its private shaper. When shaper is configured
253 	 * in packet mode, committed/peak rate provided is interpreted
254 	 * in packets per second.
255 	 */
256 	int shaper_private_packet_mode_supported;
257 
258 	/** Shaper private byte mode supported. When non-zero, this parameter
259 	 * indicates that there is at least one node that can be configured
260 	 * with byte mode in its private shaper. When shaper is configured
261 	 * in byte mode, committed/peak rate provided is interpreted in
262 	 * bytes per second.
263 	 */
264 	int shaper_private_byte_mode_supported;
265 
266 
267 	/** Maximum number of shared shapers. The value of zero indicates that
268 	 * shared shapers are not supported.
269 	 */
270 	uint32_t shaper_shared_n_max;
271 
272 	/** Maximum number of nodes that can share the same shared shaper.
273 	 * Only valid when shared shapers are supported.
274 	 */
275 	uint32_t shaper_shared_n_nodes_per_shaper_max;
276 
277 	/** Maximum number of shared shapers a node can be part of. This
278 	 * parameter indicates that there is at least one node that can be
279 	 * configured with this many shared shapers, which might not be true for
280 	 * all the nodes. Only valid when shared shapers are supported, in which
281 	 * case it ranges from 1 to *shaper_shared_n_max*.
282 	 */
283 	uint32_t shaper_shared_n_shapers_per_node_max;
284 
285 	/** Maximum number of shared shapers that can be configured with dual
286 	 * rate shaping. The value of zero indicates that dual rate shaping
287 	 * support is not available for shared shapers.
288 	 */
289 	uint32_t shaper_shared_dual_rate_n_max;
290 
291 	/** Minimum committed/peak rate (bytes per second) for any shared
292 	 * shaper. Only valid when shared shapers are supported.
293 	 */
294 	uint64_t shaper_shared_rate_min;
295 
296 	/** Maximum committed/peak rate (bytes per second) for any shared
297 	 * shaper. Only valid when shared shapers are supported.
298 	 */
299 	uint64_t shaper_shared_rate_max;
300 
301 	/** Shaper shared packet mode supported. When non-zero, this parameter
302 	 * indicates a shared shaper can be configured with packet mode.
303 	 * When shared shaper is configured in packet mode, committed/peak rate
304 	 * provided is interpreted in packets per second.
305 	 */
306 	int shaper_shared_packet_mode_supported;
307 
308 	/** Shaper shared byte mode supported. When non-zero, this parameter
309 	 * indicates that a shared shaper can be configured with byte mode.
310 	 * When shared shaper is configured in byte mode, committed/peak rate
311 	 * provided is interpreted in bytes per second.
312 	 */
313 	int shaper_shared_byte_mode_supported;
314 
315 
316 	/** Minimum value allowed for packet length adjustment for any private
317 	 * or shared shaper.
318 	 */
319 	int shaper_pkt_length_adjust_min;
320 
321 	/** Maximum value allowed for packet length adjustment for any private
322 	 * or shared shaper.
323 	 */
324 	int shaper_pkt_length_adjust_max;
325 
326 	/** Maximum number of children nodes. This parameter indicates that
327 	 * there is at least one non-leaf node that can be configured with this
328 	 * many children nodes, which might not be true for all the non-leaf
329 	 * nodes.
330 	 */
331 	uint32_t sched_n_children_max;
332 
333 	/** Maximum number of supported priority levels. This parameter
334 	 * indicates that there is at least one non-leaf node that can be
335 	 * configured with this many priority levels for managing its children
336 	 * nodes, which might not be true for all the non-leaf nodes. The value
337 	 * of zero is invalid. The value of 1 indicates that only priority 0 is
338 	 * supported, which essentially means that Strict Priority (SP)
339 	 * algorithm is not supported.
340 	 */
341 	uint32_t sched_sp_n_priorities_max;
342 
343 	/** Maximum number of sibling nodes that can have the same priority at
344 	 * any given time, i.e. maximum size of the WFQ sibling node group. This
345 	 * parameter indicates there is at least one non-leaf node that meets
346 	 * this condition, which might not be true for all the non-leaf nodes.
347 	 * The value of zero is invalid. The value of 1 indicates that WFQ
348 	 * algorithm is not supported. The maximum value is
349 	 * *sched_n_children_max*.
350 	 */
351 	uint32_t sched_wfq_n_children_per_group_max;
352 
353 	/** Maximum number of priority levels that can have more than one child
354 	 * node at any given time, i.e. maximum number of WFQ sibling node
355 	 * groups that have two or more members. This parameter indicates there
356 	 * is at least one non-leaf node that meets this condition, which might
357 	 * not be true for all the non-leaf nodes. The value of zero states that
358 	 * WFQ algorithm is not supported. The value of 1 indicates that
359 	 * (*sched_sp_n_priorities_max* - 1) priority levels have at most one
360 	 * child node, so there can be only one priority level with two or
361 	 * more sibling nodes making up a WFQ group. The maximum value is:
362 	 * min(floor(*sched_n_children_max* / 2), *sched_sp_n_priorities_max*).
363 	 */
364 	uint32_t sched_wfq_n_groups_max;
365 
366 	/** Maximum WFQ weight. The value of 1 indicates that all sibling nodes
367 	 * with same priority have the same WFQ weight, so WFQ is reduced to FQ.
368 	 */
369 	uint32_t sched_wfq_weight_max;
370 
371 	/** WFQ packet mode supported. When non-zero, this parameter indicates
372 	 * that there is at least one non-leaf node that supports packet mode
373 	 * for WFQ among its children. WFQ weights will be applied against
374 	 * packet count for scheduling children when a non-leaf node
375 	 * is configured appropriately.
376 	 */
377 	int sched_wfq_packet_mode_supported;
378 
379 	/** WFQ byte mode supported. When non-zero, this parameter indicates
380 	 * that there is at least one non-leaf node that supports byte mode
381 	 * for WFQ among its children. WFQ weights will be applied against
382 	 * bytes for scheduling children when a non-leaf node is configured
383 	 * appropriately.
384 	 */
385 	int sched_wfq_byte_mode_supported;
386 
387 	/** WRED packet mode support. When non-zero, this parameter indicates
388 	 * that there is at least one leaf node that supports the WRED packet
389 	 * mode, which might not be true for all the leaf nodes. In packet
390 	 * mode, the WRED thresholds specify the queue length in packets, as
391 	 * opposed to bytes.
392 	 */
393 	int cman_wred_packet_mode_supported;
394 
395 	/** WRED byte mode support. When non-zero, this parameter indicates that
396 	 * there is at least one leaf node that supports the WRED byte mode,
397 	 * which might not be true for all the leaf nodes. In byte mode, the
398 	 * WRED thresholds specify the queue length in bytes, as opposed to
399 	 * packets.
400 	 */
401 	int cman_wred_byte_mode_supported;
402 
403 	/** Head drop algorithm support. When non-zero, this parameter
404 	 * indicates that there is at least one leaf node that supports the head
405 	 * drop algorithm, which might not be true for all the leaf nodes.
406 	 */
407 	int cman_head_drop_supported;
408 
409 	/** Maximum number of WRED contexts, either private or shared. In case
410 	 * the implementation does not share any resources between private and
411 	 * shared WRED contexts, it is typically equal to the sum of
412 	 * *cman_wred_context_private_n_max* and
413 	 * *cman_wred_context_shared_n_max*. The value of zero indicates that
414 	 * WRED is not supported.
415 	 */
416 	uint32_t cman_wred_context_n_max;
417 
418 	/** Maximum number of private WRED contexts. Indicates the maximum
419 	 * number of leaf nodes that can concurrently have their private WRED
420 	 * context enabled. The value of zero indicates that private WRED
421 	 * contexts are not supported.
422 	 */
423 	uint32_t cman_wred_context_private_n_max;
424 
425 	/** Maximum number of shared WRED contexts. The value of zero
426 	 * indicates that shared WRED contexts are not supported.
427 	 */
428 	uint32_t cman_wred_context_shared_n_max;
429 
430 	/** Maximum number of leaf nodes that can share the same WRED context.
431 	 * Only valid when shared WRED contexts are supported.
432 	 */
433 	uint32_t cman_wred_context_shared_n_nodes_per_context_max;
434 
435 	/** Maximum number of shared WRED contexts a leaf node can be part of.
436 	 * This parameter indicates that there is at least one leaf node that
437 	 * can be configured with this many shared WRED contexts, which might
438 	 * not be true for all the leaf nodes. Only valid when shared WRED
439 	 * contexts are supported, in which case it ranges from 1 to
440 	 * *cman_wred_context_shared_n_max*.
441 	 */
442 	uint32_t cman_wred_context_shared_n_contexts_per_node_max;
443 
444 	/** Support for VLAN DEI packet marking (per color). */
445 	int mark_vlan_dei_supported[RTE_COLORS];
446 
447 	/** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */
448 	int mark_ip_ecn_tcp_supported[RTE_COLORS];
449 
450 	/** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */
451 	int mark_ip_ecn_sctp_supported[RTE_COLORS];
452 
453 	/** Support for IPv4/IPv6 DSCP packet marking (per color). */
454 	int mark_ip_dscp_supported[RTE_COLORS];
455 
456 	/** Set of supported dynamic update operations.
457 	 * @see enum rte_tm_dynamic_update_type
458 	 */
459 	uint64_t dynamic_update_mask;
460 
461 	/** Set of supported statistics counter types.
462 	 * @see enum rte_tm_stats_type
463 	 */
464 	uint64_t stats_mask;
465 };
466 
467 /**
468  * Traffic manager level capabilities
469  */
470 struct rte_tm_level_capabilities {
471 	/** Maximum number of nodes for the current hierarchy level. */
472 	uint32_t n_nodes_max;
473 
474 	/** Maximum number of non-leaf nodes for the current hierarchy level.
475 	 * The value of 0 indicates that current level only supports leaf
476 	 * nodes. The maximum value is *n_nodes_max*.
477 	 */
478 	uint32_t n_nodes_nonleaf_max;
479 
480 	/** Maximum number of leaf nodes for the current hierarchy level. The
481 	 * value of 0 indicates that current level only supports non-leaf
482 	 * nodes. The maximum value is *n_nodes_max*.
483 	 */
484 	uint32_t n_nodes_leaf_max;
485 
486 	/** When non-zero, this flag indicates that all the non-leaf nodes on
487 	 * this level have identical capability set. Valid only when
488 	 * *n_nodes_nonleaf_max* is non-zero.
489 	 */
490 	int non_leaf_nodes_identical;
491 
492 	/** When non-zero, this flag indicates that all the leaf nodes on this
493 	 * level have identical capability set. Valid only when
494 	 * *n_nodes_leaf_max* is non-zero.
495 	 */
496 	int leaf_nodes_identical;
497 
498 	union {
499 		/** Items valid only for the non-leaf nodes on this level. */
500 		struct {
501 			/** Private shaper support. When non-zero, it indicates
502 			 * there is at least one non-leaf node on this level
503 			 * with private shaper support, which may not be the
504 			 * case for all the non-leaf nodes on this level.
505 			 */
506 			int shaper_private_supported;
507 
508 			/** Dual rate support for private shaper. Valid only
509 			 * when private shaper is supported for the non-leaf
510 			 * nodes on the current level. When non-zero, it
511 			 * indicates there is at least one non-leaf node on this
512 			 * level with dual rate private shaper support, which
513 			 * may not be the case for all the non-leaf nodes on
514 			 * this level.
515 			 */
516 			int shaper_private_dual_rate_supported;
517 
518 			/** Minimum committed/peak rate (bytes per second) for
519 			 * private shapers of the non-leaf nodes of this level.
520 			 * Valid only when private shaper is supported on this
521 			 * level.
522 			 */
523 			uint64_t shaper_private_rate_min;
524 
525 			/** Maximum committed/peak rate (bytes per second) for
526 			 * private shapers of the non-leaf nodes on this level.
527 			 * Valid only when private shaper is supported on this
528 			 * level.
529 			 */
530 			uint64_t shaper_private_rate_max;
531 
532 			/** Shaper private packet mode supported. When non-zero,
533 			 * this parameter indicates there is at least one
534 			 * non-leaf node at this level that can be configured
535 			 * with packet mode in its private shaper. When private
536 			 * shaper is configured in packet mode, committed/peak
537 			 * rate provided is interpreted in packets per second.
538 			 */
539 			int shaper_private_packet_mode_supported;
540 
541 			/** Shaper private byte mode supported. When non-zero,
542 			 * this parameter indicates there is at least one
543 			 * non-leaf node at this level that can be configured
544 			 * with byte mode in its private shaper. When private
545 			 * shaper is configured in byte mode, committed/peak
546 			 * rate provided is interpreted in bytes per second.
547 			 */
548 			int shaper_private_byte_mode_supported;
549 
550 			/** Maximum number of shared shapers that any non-leaf
551 			 * node on this level can be part of. The value of zero
552 			 * indicates that shared shapers are not supported by
553 			 * the non-leaf nodes on this level. When non-zero, it
554 			 * indicates there is at least one non-leaf node on this
555 			 * level that meets this condition, which may not be the
556 			 * case for all the non-leaf nodes on this level.
557 			 */
558 			uint32_t shaper_shared_n_max;
559 
560 			/** Shaper shared packet mode supported. When non-zero,
561 			 * this parameter indicates that there is at least one
562 			 * non-leaf node on this level that can be part of
563 			 * shared shapers which work in packet mode.
564 			 */
565 			int shaper_shared_packet_mode_supported;
566 
567 			/** Shaper shared byte mode supported. When non-zero,
568 			 * this parameter indicates that there is at least one
569 			 * non-leaf node on this level that can be part of
570 			 * shared shapers which work in byte mode.
571 			 */
572 			int shaper_shared_byte_mode_supported;
573 
574 			/** Maximum number of children nodes. This parameter
575 			 * indicates that there is at least one non-leaf node on
576 			 * this level that can be configured with this many
577 			 * children nodes, which might not be true for all the
578 			 * non-leaf nodes on this level.
579 			 */
580 			uint32_t sched_n_children_max;
581 
582 			/** Maximum number of supported priority levels. This
583 			 * parameter indicates that there is at least one
584 			 * non-leaf node on this level that can be configured
585 			 * with this many priority levels for managing its
586 			 * children nodes, which might not be true for all the
587 			 * non-leaf nodes on this level. The value of zero is
588 			 * invalid. The value of 1 indicates that only priority
589 			 * 0 is supported, which essentially means that Strict
590 			 * Priority (SP) algorithm is not supported on this
591 			 * level.
592 			 */
593 			uint32_t sched_sp_n_priorities_max;
594 
595 			/** Maximum number of sibling nodes that can have the
596 			 * same priority at any given time, i.e. maximum size of
597 			 * the WFQ sibling node group. This parameter indicates
598 			 * there is at least one non-leaf node on this level
599 			 * that meets this condition, which may not be true for
600 			 * all the non-leaf nodes on this level. The value of
601 			 * zero is invalid. The value of 1 indicates that WFQ
602 			 * algorithm is not supported on this level. The maximum
603 			 * value is *sched_n_children_max*.
604 			 */
605 			uint32_t sched_wfq_n_children_per_group_max;
606 
607 			/** Maximum number of priority levels that can have
608 			 * more than one child node at any given time, i.e.
609 			 * maximum number of WFQ sibling node groups that
610 			 * have two or more members. This parameter indicates
611 			 * there is at least one non-leaf node on this level
612 			 * that meets this condition, which might not be true
613 			 * for all the non-leaf nodes. The value of zero states
614 			 * that WFQ algorithm is not supported on this level.
615 			 * The value of 1 indicates that
616 			 * (*sched_sp_n_priorities_max* - 1) priority levels on
617 			 * this level have at most one child node, so there can
618 			 * be only one priority level with two or more sibling
619 			 * nodes making up a WFQ group on this level. The
620 			 * maximum value is:
621 			 * min(floor(*sched_n_children_max* / 2),
622 			 * *sched_sp_n_priorities_max*).
623 			 */
624 			uint32_t sched_wfq_n_groups_max;
625 
626 			/** Maximum WFQ weight. The value of 1 indicates that
627 			 * all sibling nodes on this level with same priority
628 			 * have the same WFQ weight, so on this level WFQ is
629 			 * reduced to FQ.
630 			 */
631 			uint32_t sched_wfq_weight_max;
632 
633 			/** WFQ packet mode supported. When non-zero, this
634 			 * parameter indicates that there is at least one
635 			 * non-leaf node at this level that supports packet
636 			 * mode for WFQ among its children. WFQ weights will
637 			 * be applied against packet count for scheduling
638 			 * children when a non-leaf node is configured
639 			 * appropriately.
640 			 */
641 			int sched_wfq_packet_mode_supported;
642 
643 			/** WFQ byte mode supported. When non-zero, this
644 			 * parameter indicates that there is at least one
645 			 * non-leaf node at this level that supports byte
646 			 * mode for WFQ among its children. WFQ weights will
647 			 * be applied against bytes for scheduling children
648 			 * when a non-leaf node is configured appropriately.
649 			 */
650 			int sched_wfq_byte_mode_supported;
651 
652 			/** Mask of statistics counter types supported by the
653 			 * non-leaf nodes on this level. Every supported
654 			 * statistics counter type is supported by at least one
655 			 * non-leaf node on this level, which may not be true
656 			 * for all the non-leaf nodes on this level.
657 			 * @see enum rte_tm_stats_type
658 			 */
659 			uint64_t stats_mask;
660 		} nonleaf;
661 
662 		/** Items valid only for the leaf nodes on this level. */
663 		struct {
664 			/** Private shaper support. When non-zero, it indicates
665 			 * there is at least one leaf node on this level with
666 			 * private shaper support, which may not be the case for
667 			 * all the leaf nodes on this level.
668 			 */
669 			int shaper_private_supported;
670 
671 			/** Dual rate support for private shaper. Valid only
672 			 * when private shaper is supported for the leaf nodes
673 			 * on this level. When non-zero, it indicates there is
674 			 * at least one leaf node on this level with dual rate
675 			 * private shaper support, which may not be the case for
676 			 * all the leaf nodes on this level.
677 			 */
678 			int shaper_private_dual_rate_supported;
679 
680 			/** Minimum committed/peak rate (bytes per second) for
681 			 * private shapers of the leaf nodes of this level.
682 			 * Valid only when private shaper is supported for the
683 			 * leaf nodes on this level.
684 			 */
685 			uint64_t shaper_private_rate_min;
686 
687 			/** Maximum committed/peak rate (bytes per second) for
688 			 * private shapers of the leaf nodes on this level.
689 			 * Valid only when private shaper is supported for the
690 			 * leaf nodes on this level.
691 			 */
692 			uint64_t shaper_private_rate_max;
693 
694 			/** Shaper private packet mode supported. When non-zero,
695 			 * this parameter indicates there is at least one leaf
696 			 * node at this level that can be configured with
697 			 * packet mode in its private shaper. When private
698 			 * shaper is configured in packet mode, committed/peak
699 			 * rate provided is interpreted in packets per second.
700 			 */
701 			int shaper_private_packet_mode_supported;
702 
703 			/** Shaper private byte mode supported. When non-zero,
704 			 * this parameter indicates there is at least one leaf
705 			 * node at this level that can be configured with
706 			 * byte mode in its private shaper. When private shaper
707 			 * is configured in byte mode, committed/peak rate
708 			 * provided is interpreted in bytes per second.
709 			 */
710 			int shaper_private_byte_mode_supported;
711 
712 			/** Maximum number of shared shapers that any leaf node
713 			 * on this level can be part of. The value of zero
714 			 * indicates that shared shapers are not supported by
715 			 * the leaf nodes on this level. When non-zero, it
716 			 * indicates there is at least one leaf node on this
717 			 * level that meets this condition, which may not be the
718 			 * case for all the leaf nodes on this level.
719 			 */
720 			uint32_t shaper_shared_n_max;
721 
722 			/** Shaper shared packet mode supported. When non-zero,
723 			 * this parameter indicates that there is at least one
724 			 * leaf node on this level that can be part of
725 			 * shared shapers which work in packet mode.
726 			 */
727 			int shaper_shared_packet_mode_supported;
728 
729 			/** Shaper shared byte mode supported. When non-zero,
730 			 * this parameter indicates that there is at least one
731 			 * leaf node on this level that can be part of
732 			 * shared shapers which work in byte mode.
733 			 */
734 			int shaper_shared_byte_mode_supported;
735 
736 			/** WRED packet mode support. When non-zero, this
737 			 * parameter indicates that there is at least one leaf
738 			 * node on this level that supports the WRED packet
739 			 * mode, which might not be true for all the leaf
740 			 * nodes. In packet mode, the WRED thresholds specify
741 			 * the queue length in packets, as opposed to bytes.
742 			 */
743 			int cman_wred_packet_mode_supported;
744 
745 			/** WRED byte mode support. When non-zero, this
746 			 * parameter indicates that there is at least one leaf
747 			 * node on this level that supports the WRED byte mode,
748 			 * which might not be true for all the leaf nodes. In
749 			 * byte mode, the WRED thresholds specify the queue
750 			 * length in bytes, as opposed to packets.
751 			 */
752 			int cman_wred_byte_mode_supported;
753 
754 			/** Head drop algorithm support. When non-zero, this
755 			 * parameter indicates that there is at least one leaf
756 			 * node on this level that supports the head drop
757 			 * algorithm, which might not be true for all the leaf
758 			 * nodes on this level.
759 			 */
760 			int cman_head_drop_supported;
761 
762 			/** Private WRED context support. When non-zero, it
763 			 * indicates there is at least one node on this level
764 			 * with private WRED context support, which may not be
765 			 * true for all the leaf nodes on this level.
766 			 */
767 			int cman_wred_context_private_supported;
768 
769 			/** Maximum number of shared WRED contexts that any
770 			 * leaf node on this level can be part of. The value of
771 			 * zero indicates that shared WRED contexts are not
772 			 * supported by the leaf nodes on this level. When
773 			 * non-zero, it indicates there is at least one leaf
774 			 * node on this level that meets this condition, which
775 			 * may not be the case for all the leaf nodes on this
776 			 * level.
777 			 */
778 			uint32_t cman_wred_context_shared_n_max;
779 
780 			/** Mask of statistics counter types supported by the
781 			 * leaf nodes on this level. Every supported statistics
782 			 * counter type is supported by at least one leaf node
783 			 * on this level, which may not be true for all the leaf
784 			 * nodes on this level.
785 			 * @see enum rte_tm_stats_type
786 			 */
787 			uint64_t stats_mask;
788 		} leaf;
789 	};
790 };
791 
792 /**
793  * Traffic manager node capabilities
794  */
795 struct rte_tm_node_capabilities {
796 	/** Private shaper support for the current node. */
797 	int shaper_private_supported;
798 
799 	/** Dual rate shaping support for private shaper of current node.
800 	 * Valid only when private shaper is supported by the current node.
801 	 */
802 	int shaper_private_dual_rate_supported;
803 
804 	/** Minimum committed/peak rate (bytes per second) for private
805 	 * shaper of current node. Valid only when private shaper is supported
806 	 * by the current node.
807 	 */
808 	uint64_t shaper_private_rate_min;
809 
810 	/** Maximum committed/peak rate (bytes per second) for private
811 	 * shaper of current node. Valid only when private shaper is supported
812 	 * by the current node.
813 	 */
814 	uint64_t shaper_private_rate_max;
815 
816 	/** Shaper private packet mode supported. When non-zero, this parameter
817 	 * indicates private shaper of current node can be configured with
818 	 * packet mode. When configured in packet mode, committed/peak rate
819 	 * provided is interpreted in packets per second.
820 	 */
821 	int shaper_private_packet_mode_supported;
822 
823 	/** Shaper private byte mode supported. When non-zero, this parameter
824 	 * indicates private shaper of current node can be configured with
825 	 * byte mode. When configured in byte mode, committed/peak rate
826 	 * provided is interpreted in bytes per second.
827 	 */
828 	int shaper_private_byte_mode_supported;
829 
830 	/** Maximum number of shared shapers the current node can be part of.
831 	 * The value of zero indicates that shared shapers are not supported by
832 	 * the current node.
833 	 */
834 	uint32_t shaper_shared_n_max;
835 
836 	/** Shaper shared packet mode supported. When non-zero,
837 	 * this parameter indicates that current node can be part of
838 	 * shared shapers which work in packet mode.
839 	 */
840 	int shaper_shared_packet_mode_supported;
841 
842 	/** Shaper shared byte mode supported. When non-zero,
843 	 * this parameter indicates that current node can be part of
844 	 * shared shapers which work in byte mode.
845 	 */
846 	int shaper_shared_byte_mode_supported;
847 
848 	union {
849 		/** Items valid only for non-leaf nodes. */
850 		struct {
851 			/** Maximum number of children nodes. */
852 			uint32_t sched_n_children_max;
853 
854 			/** Maximum number of supported priority levels. The
855 			 * value of zero is invalid. The value of 1 indicates
856 			 * that only priority 0 is supported, which essentially
857 			 * means that Strict Priority (SP) algorithm is not
858 			 * supported.
859 			 */
860 			uint32_t sched_sp_n_priorities_max;
861 
862 			/** Maximum number of sibling nodes that can have the
863 			 * same priority at any given time, i.e. maximum size
864 			 * of the WFQ sibling node group. The value of zero
865 			 * is invalid. The value of 1 indicates that WFQ
866 			 * algorithm is not supported. The maximum value is
867 			 * *sched_n_children_max*.
868 			 */
869 			uint32_t sched_wfq_n_children_per_group_max;
870 
871 			/** Maximum number of priority levels that can have
872 			 * more than one child node at any given time, i.e.
873 			 * maximum number of WFQ sibling node groups that have
874 			 * two or more members. The value of zero states that
875 			 * WFQ algorithm is not supported. The value of 1
876 			 * indicates that (*sched_sp_n_priorities_max* - 1)
877 			 * priority levels have at most one child node, so there
878 			 * can be only one priority level with two or more
879 			 * sibling nodes making up a WFQ group. The maximum
880 			 * value is: min(floor(*sched_n_children_max* / 2),
881 			 * *sched_sp_n_priorities_max*).
882 			 */
883 			uint32_t sched_wfq_n_groups_max;
884 
885 			/** Maximum WFQ weight. The value of 1 indicates that
886 			 * all sibling nodes with same priority have the same
887 			 * WFQ weight, so WFQ is reduced to FQ.
888 			 */
889 			uint32_t sched_wfq_weight_max;
890 
891 			/** WFQ packet mode supported. When non-zero, this
892 			 * parameter indicates that current node supports packet
893 			 * mode for WFQ among its children. WFQ weights will be
894 			 * applied against packet count for scheduling children
895 			 * when configured appropriately.
896 			 */
897 			int sched_wfq_packet_mode_supported;
898 
899 			/** WFQ byte mode supported. When non-zero, this
900 			 * parameter indicates that current node supports byte
901 			 * mode for WFQ among its children. WFQ weights will be
902 			 * applied against  bytes for scheduling children when
903 			 * configured appropriately.
904 			 */
905 			int sched_wfq_byte_mode_supported;
906 
907 		} nonleaf;
908 
909 		/** Items valid only for leaf nodes. */
910 		struct {
911 			/** WRED packet mode support for current node. */
912 			int cman_wred_packet_mode_supported;
913 
914 			/** WRED byte mode support for current node. */
915 			int cman_wred_byte_mode_supported;
916 
917 			/** Head drop algorithm support for current node. */
918 			int cman_head_drop_supported;
919 
920 			/** Private WRED context support for current node. */
921 			int cman_wred_context_private_supported;
922 
923 			/** Maximum number of shared WRED contexts the current
924 			 * node can be part of. The value of zero indicates that
925 			 * shared WRED contexts are not supported by the current
926 			 * node.
927 			 */
928 			uint32_t cman_wred_context_shared_n_max;
929 		} leaf;
930 	};
931 
932 	/** Mask of statistics counter types supported by the current node.
933 	 * @see enum rte_tm_stats_type
934 	 */
935 	uint64_t stats_mask;
936 };
937 
938 /**
939  * Congestion management (CMAN) mode
940  *
941  * This is used for controlling the admission of packets into a packet queue or
942  * group of packet queues on congestion. On request of writing a new packet
943  * into the current queue while the queue is full, the *tail drop* algorithm
944  * drops the new packet while leaving the queue unmodified, as opposed to *head
945  * drop* algorithm, which drops the packet at the head of the queue (the oldest
946  * packet waiting in the queue) and admits the new packet at the tail of the
947  * queue.
948  *
949  * The *Random Early Detection (RED)* algorithm works by proactively dropping
950  * more and more input packets as the queue occupancy builds up. When the queue
951  * is full or almost full, RED effectively works as *tail drop*. The *Weighted
952  * RED* algorithm uses a separate set of RED thresholds for each packet color.
953  */
954 enum rte_tm_cman_mode {
955 	RTE_TM_CMAN_TAIL_DROP = 0, /**< Tail drop */
956 	RTE_TM_CMAN_HEAD_DROP, /**< Head drop */
957 	RTE_TM_CMAN_WRED, /**< Weighted Random Early Detection (WRED) */
958 };
959 
960 /**
961  * Random Early Detection (RED) profile
962  */
963 struct rte_tm_red_params {
964 	/** Minimum queue threshold */
965 	uint64_t min_th;
966 
967 	/** Maximum queue threshold */
968 	uint64_t max_th;
969 
970 	/** Inverse of packet marking probability maximum value (maxp), i.e.
971 	 * maxp_inv = 1 / maxp
972 	 */
973 	uint16_t maxp_inv;
974 
975 	/** Negated log2 of queue weight (wq), i.e. wq = 1 / (2 ^ wq_log2) */
976 	uint16_t wq_log2;
977 };
978 
979 /**
980  * Weighted RED (WRED) profile
981  *
982  * Multiple WRED contexts can share the same WRED profile. Each leaf node with
983  * WRED enabled as its congestion management mode has zero or one private WRED
984  * context (only one leaf node using it) and/or zero, one or several shared
985  * WRED contexts (multiple leaf nodes use the same WRED context). A private
986  * WRED context is used to perform congestion management for a single leaf
987  * node, while a shared WRED context is used to perform congestion management
988  * for a group of leaf nodes.
989  *
990  * @see struct rte_tm_capabilities::cman_wred_packet_mode_supported
991  * @see struct rte_tm_capabilities::cman_wred_byte_mode_supported
992  */
993 struct rte_tm_wred_params {
994 	/** One set of RED parameters per packet color */
995 	struct rte_tm_red_params red_params[RTE_COLORS];
996 
997 	/** When non-zero, the *min_th* and *max_th* thresholds are specified
998 	 * in packets (WRED packet mode). When zero, the *min_th* and *max_th*
999 	 * thresholds are specified in bytes (WRED byte mode)
1000 	 */
1001 	int packet_mode;
1002 };
1003 
1004 /**
1005  * Token bucket
1006  */
1007 struct rte_tm_token_bucket {
1008 	/** Token bucket rate (bytes per second or packets per second) */
1009 	uint64_t rate;
1010 
1011 	/** Token bucket size (bytes or packets), a.k.a. max burst size */
1012 	uint64_t size;
1013 };
1014 
1015 /**
1016  * Shaper (rate limiter) profile
1017  *
1018  * Multiple shaper instances can share the same shaper profile. Each node has
1019  * zero or one private shaper (only one node using it) and/or zero, one or
1020  * several shared shapers (multiple nodes use the same shaper instance).
1021  * A private shaper is used to perform traffic shaping for a single node, while
1022  * a shared shaper is used to perform traffic shaping for a group of nodes.
1023  *
1024  * Single rate shapers use a single token bucket. A single rate shaper can be
1025  * configured by setting the rate of the committed bucket to zero, which
1026  * effectively disables this bucket. The peak bucket is used to limit the rate
1027  * and the burst size for the current shaper.
1028  *
1029  * Dual rate shapers use both the committed and the peak token buckets. The
1030  * rate of the peak bucket has to be bigger than zero, as well as greater than
1031  * or equal to the rate of the committed bucket.
1032  *
1033  * @see struct rte_tm_capabilities::shaper_private_packet_mode_supported
1034  * @see struct rte_tm_capabilities::shaper_private_byte_mode_supported
1035  * @see struct rte_tm_capabilities::shaper_shared_packet_mode_supported
1036  * @see struct rte_tm_capabilities::shaper_shared_byte_mode_supported
1037  */
1038 struct rte_tm_shaper_params {
1039 	/** Committed token bucket */
1040 	struct rte_tm_token_bucket committed;
1041 
1042 	/** Peak token bucket */
1043 	struct rte_tm_token_bucket peak;
1044 
1045 	/** Signed value to be added to the length of each packet for the
1046 	 * purpose of shaping. Can be used to correct the packet length with
1047 	 * the framing overhead bytes that are also consumed on the wire (e.g.
1048 	 * RTE_TM_ETH_FRAMING_OVERHEAD_FCS).
1049 	 * This field is ignored when the profile enables packet mode.
1050 	 */
1051 	int32_t pkt_length_adjust;
1052 
1053 	/** When zero, the byte mode is enabled for the current profile, so the
1054 	 * *rate* and *size* fields in both the committed and peak token buckets
1055 	 * are specified in bytes per second and bytes, respectively.
1056 	 * When non-zero, the packet mode is enabled for the current profile,
1057 	 * so the *rate* and *size* fields in both the committed and peak token
1058 	 * buckets are specified in packets per second and packets,
1059 	 * respectively.
1060 	 */
1061 	int packet_mode;
1062 };
1063 
1064 /**
1065  * Node parameters
1066  *
1067  * Each non-leaf node has multiple inputs (its children nodes) and single output
1068  * (which is input to its parent node). It arbitrates its inputs using Strict
1069  * Priority (SP) and Weighted Fair Queuing (WFQ) algorithms to schedule input
1070  * packets to its output while observing its shaping (rate limiting)
1071  * constraints.
1072  *
1073  * Algorithms such as Weighted Round Robin (WRR), Byte-level WRR, Deficit WRR
1074  * (DWRR), etc. are considered approximations of the WFQ ideal and are
1075  * assimilated to WFQ, although an associated implementation-dependent trade-off
1076  * on accuracy, performance and resource usage might exist.
1077  *
1078  * Children nodes with different priorities are scheduled using the SP algorithm
1079  * based on their priority, with zero (0) as the highest priority. Children with
1080  * the same priority are scheduled using the WFQ algorithm according to their
1081  * weights. The WFQ weight of a given child node is relative to the sum of the
1082  * weights of all its sibling nodes that have the same priority, with one (1) as
1083  * the lowest weight. For each SP priority, the WFQ weight mode can be set as
1084  * either byte-based or packet-based.
1085  *
1086  * Each leaf node sits on top of a Tx queue of the current Ethernet port. Hence,
1087  * the leaf nodes are predefined, with their node IDs set to 0 .. (N-1), where N
1088  * is the number of Tx queues configured for the current Ethernet port. The
1089  * non-leaf nodes have their IDs generated by the application.
1090  */
1091 struct rte_tm_node_params {
1092 	/** Shaper profile for the private shaper. The absence of the private
1093 	 * shaper for the current node is indicated by setting this parameter
1094 	 * to RTE_TM_SHAPER_PROFILE_ID_NONE.
1095 	 */
1096 	uint32_t shaper_profile_id;
1097 
1098 	/** User allocated array of valid shared shaper IDs. */
1099 	uint32_t *shared_shaper_id;
1100 
1101 	/** Number of shared shaper IDs in the *shared_shaper_id* array. */
1102 	uint32_t n_shared_shapers;
1103 
1104 	union {
1105 		/** Parameters only valid for non-leaf nodes. */
1106 		struct {
1107 			/** WFQ weight mode for each SP priority. When NULL, it
1108 			 * indicates that WFQ is to be used for all priorities.
1109 			 * When non-NULL, it points to a pre-allocated array of
1110 			 * *n_sp_priorities* values, with non-zero value for
1111 			 * byte-mode and zero for packet-mode.
1112 			 * @see struct rte_tm_node_capabilities::sched_wfq_packet_mode_supported
1113 			 * @see struct rte_tm_node_capabilities::sched_wfq_byte_mode_supported
1114 			 */
1115 			int *wfq_weight_mode;
1116 
1117 			/** Number of SP priorities. */
1118 			uint32_t n_sp_priorities;
1119 		} nonleaf;
1120 
1121 		/** Parameters only valid for leaf nodes. */
1122 		struct {
1123 			/** Congestion management mode */
1124 			enum rte_tm_cman_mode cman;
1125 
1126 			/** WRED parameters (only valid when *cman* is set to
1127 			 * WRED).
1128 			 */
1129 			struct {
1130 				/** WRED profile for private WRED context. The
1131 				 * absence of a private WRED context for the
1132 				 * current leaf node is indicated by value
1133 				 * RTE_TM_WRED_PROFILE_ID_NONE.
1134 				 */
1135 				uint32_t wred_profile_id;
1136 
1137 				/** User allocated array of shared WRED context
1138 				 * IDs. When set to NULL, it indicates that the
1139 				 * current leaf node should not currently be
1140 				 * part of any shared WRED contexts.
1141 				 */
1142 				uint32_t *shared_wred_context_id;
1143 
1144 				/** Number of elements in the
1145 				 * *shared_wred_context_id* array. Only valid
1146 				 * when *shared_wred_context_id* is non-NULL,
1147 				 * in which case it should be non-zero.
1148 				 */
1149 				uint32_t n_shared_wred_contexts;
1150 			} wred;
1151 		} leaf;
1152 	};
1153 
1154 	/** Mask of statistics counter types to be enabled for this node. This
1155 	 * needs to be a subset of the statistics counter types available for
1156 	 * the current node. Any statistics counter type not included in this
1157 	 * set is to be disabled for the current node.
1158 	 * @see enum rte_tm_stats_type
1159 	 */
1160 	uint64_t stats_mask;
1161 };
1162 
1163 /**
1164  * Verbose error types.
1165  *
1166  * Most of them provide the type of the object referenced by struct
1167  * rte_tm_error::cause.
1168  */
1169 enum rte_tm_error_type {
1170 	RTE_TM_ERROR_TYPE_NONE, /**< No error. */
1171 	RTE_TM_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
1172 	RTE_TM_ERROR_TYPE_CAPABILITIES,
1173 	RTE_TM_ERROR_TYPE_LEVEL_ID,
1174 	RTE_TM_ERROR_TYPE_WRED_PROFILE,
1175 	RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN,
1176 	RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW,
1177 	RTE_TM_ERROR_TYPE_WRED_PROFILE_RED,
1178 	RTE_TM_ERROR_TYPE_WRED_PROFILE_ID,
1179 	RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID,
1180 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
1181 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE,
1182 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE,
1183 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
1184 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
1185 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN,
1186 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PACKET_MODE,
1187 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
1188 	RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID,
1189 	RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID,
1190 	RTE_TM_ERROR_TYPE_NODE_PRIORITY,
1191 	RTE_TM_ERROR_TYPE_NODE_WEIGHT,
1192 	RTE_TM_ERROR_TYPE_NODE_PARAMS,
1193 	RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID,
1194 	RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID,
1195 	RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS,
1196 	RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE,
1197 	RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES,
1198 	RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN,
1199 	RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID,
1200 	RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID,
1201 	RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS,
1202 	RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
1203 	RTE_TM_ERROR_TYPE_NODE_ID,
1204 };
1205 
1206 /**
1207  * Verbose error structure definition.
1208  *
1209  * This object is normally allocated by applications and set by PMDs, the
1210  * message points to a constant string which does not need to be freed by
1211  * the application, however its pointer can be considered valid only as long
1212  * as its associated DPDK port remains configured. Closing the underlying
1213  * device or unloading the PMD invalidates it.
1214  *
1215  * Both cause and message may be NULL regardless of the error type.
1216  */
1217 struct rte_tm_error {
1218 	enum rte_tm_error_type type; /**< Cause field and error type. */
1219 	const void *cause; /**< Object responsible for the error. */
1220 	const char *message; /**< Human-readable error message. */
1221 };
1222 
1223 /**
1224  * Traffic manager get number of leaf nodes
1225  *
1226  * Each leaf node sits on top of a Tx queue of the current Ethernet port.
1227  * Therefore, the set of leaf nodes is predefined, their number is always equal
1228  * to N (where N is the number of Tx queues configured for the current port)
1229  * and their IDs are 0 .. (N-1).
1230  *
1231  * @param[in] port_id
1232  *   The port identifier of the Ethernet device.
1233  * @param[out] n_leaf_nodes
1234  *   Number of leaf nodes for the current port.
1235  * @param[out] error
1236  *   Error details. Filled in only on error, when not NULL.
1237  * @return
1238  *   0 on success, non-zero error code otherwise.
1239  */
1240 int
1241 rte_tm_get_number_of_leaf_nodes(uint16_t port_id,
1242 	uint32_t *n_leaf_nodes,
1243 	struct rte_tm_error *error);
1244 
1245 /**
1246  * Traffic manager node ID validate and type (i.e. leaf or non-leaf) get
1247  *
1248  * The leaf nodes have predefined IDs in the range of 0 .. (N-1), where N is
1249  * the number of Tx queues of the current Ethernet port. The non-leaf nodes
1250  * have their IDs generated by the application outside of the above range,
1251  * which is reserved for leaf nodes.
1252  *
1253  * @param[in] port_id
1254  *   The port identifier of the Ethernet device.
1255  * @param[in] node_id
1256  *   Node ID value. Needs to be valid.
1257  * @param[out] is_leaf
1258  *   Set to non-zero value when node is leaf and to zero otherwise (non-leaf).
1259  * @param[out] error
1260  *   Error details. Filled in only on error, when not NULL.
1261  * @return
1262  *   0 on success, non-zero error code otherwise.
1263  */
1264 int
1265 rte_tm_node_type_get(uint16_t port_id,
1266 	uint32_t node_id,
1267 	int *is_leaf,
1268 	struct rte_tm_error *error);
1269 
1270 /**
1271  * Traffic manager capabilities get
1272  *
1273  * @param[in] port_id
1274  *   The port identifier of the Ethernet device.
1275  * @param[out] cap
1276  *   Traffic manager capabilities. Needs to be pre-allocated and valid.
1277  * @param[out] error
1278  *   Error details. Filled in only on error, when not NULL.
1279  * @return
1280  *   0 on success, non-zero error code otherwise.
1281  */
1282 int
1283 rte_tm_capabilities_get(uint16_t port_id,
1284 	struct rte_tm_capabilities *cap,
1285 	struct rte_tm_error *error);
1286 
1287 /**
1288  * Traffic manager level capabilities get
1289  *
1290  * @param[in] port_id
1291  *   The port identifier of the Ethernet device.
1292  * @param[in] level_id
1293  *   The hierarchy level identifier. The value of 0 identifies the level of the
1294  *   root node.
1295  * @param[out] cap
1296  *   Traffic manager level capabilities. Needs to be pre-allocated and valid.
1297  * @param[out] error
1298  *   Error details. Filled in only on error, when not NULL.
1299  * @return
1300  *   0 on success, non-zero error code otherwise.
1301  */
1302 int
1303 rte_tm_level_capabilities_get(uint16_t port_id,
1304 	uint32_t level_id,
1305 	struct rte_tm_level_capabilities *cap,
1306 	struct rte_tm_error *error);
1307 
1308 /**
1309  * Traffic manager node capabilities get
1310  *
1311  * @param[in] port_id
1312  *   The port identifier of the Ethernet device.
1313  * @param[in] node_id
1314  *   Node ID. Needs to be valid.
1315  * @param[out] cap
1316  *   Traffic manager node capabilities. Needs to be pre-allocated and valid.
1317  * @param[out] error
1318  *   Error details. Filled in only on error, when not NULL.
1319  * @return
1320  *   0 on success, non-zero error code otherwise.
1321  */
1322 int
1323 rte_tm_node_capabilities_get(uint16_t port_id,
1324 	uint32_t node_id,
1325 	struct rte_tm_node_capabilities *cap,
1326 	struct rte_tm_error *error);
1327 
1328 /**
1329  * Traffic manager WRED profile add
1330  *
1331  * Create a new WRED profile with ID set to *wred_profile_id*. The new profile
1332  * is used to create one or several WRED contexts.
1333  *
1334  * @param[in] port_id
1335  *   The port identifier of the Ethernet device.
1336  * @param[in] wred_profile_id
1337  *   WRED profile ID for the new profile. Needs to be unused.
1338  * @param[in] profile
1339  *   WRED profile parameters. Needs to be pre-allocated and valid.
1340  * @param[out] error
1341  *   Error details. Filled in only on error, when not NULL.
1342  * @return
1343  *   0 on success, non-zero error code otherwise.
1344  *
1345  * @see struct rte_tm_capabilities::cman_wred_context_n_max
1346  */
1347 int
1348 rte_tm_wred_profile_add(uint16_t port_id,
1349 	uint32_t wred_profile_id,
1350 	const struct rte_tm_wred_params *profile,
1351 	struct rte_tm_error *error);
1352 
1353 /**
1354  * Traffic manager WRED profile delete
1355  *
1356  * Delete an existing WRED profile. This operation fails when there is
1357  * currently at least one user (i.e. WRED context) of this WRED profile.
1358  *
1359  * @param[in] port_id
1360  *   The port identifier of the Ethernet device.
1361  * @param[in] wred_profile_id
1362  *   WRED profile ID. Needs to be the valid.
1363  * @param[out] error
1364  *   Error details. Filled in only on error, when not NULL.
1365  * @return
1366  *   0 on success, non-zero error code otherwise.
1367  *
1368  * @see struct rte_tm_capabilities::cman_wred_context_n_max
1369  */
1370 int
1371 rte_tm_wred_profile_delete(uint16_t port_id,
1372 	uint32_t wred_profile_id,
1373 	struct rte_tm_error *error);
1374 
1375 /**
1376  * Traffic manager shared WRED context add or update
1377  *
1378  * When *shared_wred_context_id* is invalid, a new WRED context with this ID is
1379  * created by using the WRED profile identified by *wred_profile_id*.
1380  *
1381  * When *shared_wred_context_id* is valid, this WRED context is no longer using
1382  * the profile previously assigned to it and is updated to use the profile
1383  * identified by *wred_profile_id*.
1384  *
1385  * A valid shared WRED context can be assigned to several hierarchy leaf nodes
1386  * configured to use WRED as the congestion management mode.
1387  *
1388  * @param[in] port_id
1389  *   The port identifier of the Ethernet device.
1390  * @param[in] shared_wred_context_id
1391  *   Shared WRED context ID
1392  * @param[in] wred_profile_id
1393  *   WRED profile ID. Needs to be the valid.
1394  * @param[out] error
1395  *   Error details. Filled in only on error, when not NULL.
1396  * @return
1397  *   0 on success, non-zero error code otherwise.
1398  *
1399  * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1400  */
1401 int
1402 rte_tm_shared_wred_context_add_update(uint16_t port_id,
1403 	uint32_t shared_wred_context_id,
1404 	uint32_t wred_profile_id,
1405 	struct rte_tm_error *error);
1406 
1407 /**
1408  * Traffic manager shared WRED context delete
1409  *
1410  * Delete an existing shared WRED context. This operation fails when there is
1411  * currently at least one user (i.e. hierarchy leaf node) of this shared WRED
1412  * context.
1413  *
1414  * @param[in] port_id
1415  *   The port identifier of the Ethernet device.
1416  * @param[in] shared_wred_context_id
1417  *   Shared WRED context ID. Needs to be the valid.
1418  * @param[out] error
1419  *   Error details. Filled in only on error, when not NULL.
1420  * @return
1421  *   0 on success, non-zero error code otherwise.
1422  *
1423  * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1424  */
1425 int
1426 rte_tm_shared_wred_context_delete(uint16_t port_id,
1427 	uint32_t shared_wred_context_id,
1428 	struct rte_tm_error *error);
1429 
1430 /**
1431  * Traffic manager shaper profile add
1432  *
1433  * Create a new shaper profile with ID set to *shaper_profile_id*. The new
1434  * shaper profile is used to create one or several shapers.
1435  *
1436  * @param[in] port_id
1437  *   The port identifier of the Ethernet device.
1438  * @param[in] shaper_profile_id
1439  *   Shaper profile ID for the new profile. Needs to be unused.
1440  * @param[in] profile
1441  *   Shaper profile parameters. Needs to be pre-allocated and valid.
1442  * @param[out] error
1443  *   Error details. Filled in only on error, when not NULL.
1444  * @return
1445  *   0 on success, non-zero error code otherwise.
1446  *
1447  * @see struct rte_tm_capabilities::shaper_n_max
1448  */
1449 int
1450 rte_tm_shaper_profile_add(uint16_t port_id,
1451 	uint32_t shaper_profile_id,
1452 	const struct rte_tm_shaper_params *profile,
1453 	struct rte_tm_error *error);
1454 
1455 /**
1456  * Traffic manager shaper profile delete
1457  *
1458  * Delete an existing shaper profile. This operation fails when there is
1459  * currently at least one user (i.e. shaper) of this shaper profile.
1460  *
1461  * @param[in] port_id
1462  *   The port identifier of the Ethernet device.
1463  * @param[in] shaper_profile_id
1464  *   Shaper profile ID. Needs to be the valid.
1465  * @param[out] error
1466  *   Error details. Filled in only on error, when not NULL.
1467  * @return
1468  *   0 on success, non-zero error code otherwise.
1469  *
1470  * @see struct rte_tm_capabilities::shaper_n_max
1471  */
1472 int
1473 rte_tm_shaper_profile_delete(uint16_t port_id,
1474 	uint32_t shaper_profile_id,
1475 	struct rte_tm_error *error);
1476 
1477 /**
1478  * Traffic manager shared shaper add or update
1479  *
1480  * When *shared_shaper_id* is not a valid shared shaper ID, a new shared shaper
1481  * with this ID is created using the shaper profile identified by
1482  * *shaper_profile_id*.
1483  *
1484  * When *shared_shaper_id* is a valid shared shaper ID, this shared shaper is
1485  * no longer using the shaper profile previously assigned to it and is updated
1486  * to use the shaper profile identified by *shaper_profile_id*.
1487  *
1488  * @param[in] port_id
1489  *   The port identifier of the Ethernet device.
1490  * @param[in] shared_shaper_id
1491  *   Shared shaper ID
1492  * @param[in] shaper_profile_id
1493  *   Shaper profile ID. Needs to be the valid.
1494  * @param[out] error
1495  *   Error details. Filled in only on error, when not NULL.
1496  * @return
1497  *   0 on success, non-zero error code otherwise.
1498  *
1499  * @see struct rte_tm_capabilities::shaper_shared_n_max
1500  */
1501 int
1502 rte_tm_shared_shaper_add_update(uint16_t port_id,
1503 	uint32_t shared_shaper_id,
1504 	uint32_t shaper_profile_id,
1505 	struct rte_tm_error *error);
1506 
1507 /**
1508  * Traffic manager shared shaper delete
1509  *
1510  * Delete an existing shared shaper. This operation fails when there is
1511  * currently at least one user (i.e. hierarchy node) of this shared shaper.
1512  *
1513  * @param[in] port_id
1514  *   The port identifier of the Ethernet device.
1515  * @param[in] shared_shaper_id
1516  *   Shared shaper ID. Needs to be the valid.
1517  * @param[out] error
1518  *   Error details. Filled in only on error, when not NULL.
1519  * @return
1520  *   0 on success, non-zero error code otherwise.
1521  *
1522  * @see struct rte_tm_capabilities::shaper_shared_n_max
1523  */
1524 int
1525 rte_tm_shared_shaper_delete(uint16_t port_id,
1526 	uint32_t shared_shaper_id,
1527 	struct rte_tm_error *error);
1528 
1529 /**
1530  * Traffic manager node add
1531  *
1532  * Create new node and connect it as child of an existing node. The new node is
1533  * further identified by *node_id*, which needs to be unused by any of the
1534  * existing nodes. The parent node is identified by *parent_node_id*, which
1535  * needs to be the valid ID of an existing non-leaf node. The parent node is
1536  * going to use the provided SP *priority* and WFQ *weight* to schedule its new
1537  * child node.
1538  *
1539  * This function has to be called for both leaf and non-leaf nodes. In the case
1540  * of leaf nodes (i.e. *node_id* is within the range of 0 .. (N-1), with N as
1541  * the number of configured Tx queues of the current port), the leaf node is
1542  * configured rather than created (as the set of leaf nodes is predefined) and
1543  * it is also connected as child of an existing node.
1544  *
1545  * The first node that is added becomes the root node and all the nodes that
1546  * are subsequently added have to be added as descendants of the root node. The
1547  * parent of the root node has to be specified as RTE_TM_NODE_ID_NULL and there
1548  * can only be one node with this parent ID (i.e. the root node). Further
1549  * restrictions for root node: needs to be non-leaf, its private shaper profile
1550  * needs to be valid and single rate, cannot use any shared shapers.
1551  *
1552  * When called before rte_tm_hierarchy_commit() invocation, this function is
1553  * typically used to define the initial start-up hierarchy for the port.
1554  * Provided that dynamic hierarchy updates are supported by the current port (as
1555  * advertised in the port capability set), this function can be also called
1556  * after the rte_tm_hierarchy_commit() invocation.
1557  *
1558  * @param[in] port_id
1559  *   The port identifier of the Ethernet device.
1560  * @param[in] node_id
1561  *   Node ID. Needs to be unused by any of the existing nodes.
1562  * @param[in] parent_node_id
1563  *   Parent node ID. Needs to be the valid.
1564  * @param[in] priority
1565  *   Node priority. The highest node priority is zero. Used by the SP algorithm
1566  *   running on the parent of the current node for scheduling this child node.
1567  * @param[in] weight
1568  *   Node weight. The node weight is relative to the weight sum of all siblings
1569  *   that have the same priority. The lowest weight is one. Used by the WFQ
1570  *   algorithm running on the parent of the current node for scheduling this
1571  *   child node.
1572  * @param[in] level_id
1573  *   Level ID that should be met by this node. The hierarchy level of the
1574  *   current node is already fully specified through its parent node (i.e. the
1575  *   level of this node is equal to the level of its parent node plus one),
1576  *   therefore the reason for providing this parameter is to enable the
1577  *   application to perform step-by-step checking of the node level during
1578  *   successive invocations of this function. When not desired, this check can
1579  *   be disabled by assigning value RTE_TM_NODE_LEVEL_ID_ANY to this parameter.
1580  * @param[in] params
1581  *   Node parameters. Needs to be pre-allocated and valid.
1582  * @param[out] error
1583  *   Error details. Filled in only on error, when not NULL.
1584  * @return
1585  *   0 on success, non-zero error code otherwise.
1586  *
1587  * @see rte_tm_hierarchy_commit()
1588  * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1589  * @see RTE_TM_NODE_LEVEL_ID_ANY
1590  * @see struct rte_tm_capabilities
1591  */
1592 int
1593 rte_tm_node_add(uint16_t port_id,
1594 	uint32_t node_id,
1595 	uint32_t parent_node_id,
1596 	uint32_t priority,
1597 	uint32_t weight,
1598 	uint32_t level_id,
1599 	const struct rte_tm_node_params *params,
1600 	struct rte_tm_error *error);
1601 
1602 /**
1603  * Traffic manager node delete
1604  *
1605  * Delete an existing node. This operation fails when this node currently has
1606  * at least one user (i.e. child node).
1607  *
1608  * When called before rte_tm_hierarchy_commit() invocation, this function is
1609  * typically used to define the initial start-up hierarchy for the port.
1610  * Provided that dynamic hierarchy updates are supported by the current port (as
1611  * advertised in the port capability set), this function can be also called
1612  * after the rte_tm_hierarchy_commit() invocation.
1613  *
1614  * @param[in] port_id
1615  *   The port identifier of the Ethernet device.
1616  * @param[in] node_id
1617  *   Node ID. Needs to be valid.
1618  * @param[out] error
1619  *   Error details. Filled in only on error, when not NULL.
1620  * @return
1621  *   0 on success, non-zero error code otherwise.
1622  *
1623  * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1624  */
1625 int
1626 rte_tm_node_delete(uint16_t port_id,
1627 	uint32_t node_id,
1628 	struct rte_tm_error *error);
1629 
1630 /**
1631  * Traffic manager node suspend
1632  *
1633  * Suspend an existing node. While the node is in suspended state, no packet is
1634  * scheduled from this node and its descendants. The node exits the suspended
1635  * state through the node resume operation.
1636  *
1637  * @param[in] port_id
1638  *   The port identifier of the Ethernet device.
1639  * @param[in] node_id
1640  *   Node ID. Needs to be valid.
1641  * @param[out] error
1642  *   Error details. Filled in only on error, when not NULL.
1643  * @return
1644  *   0 on success, non-zero error code otherwise.
1645  *
1646  * @see rte_tm_node_resume()
1647  * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1648  */
1649 int
1650 rte_tm_node_suspend(uint16_t port_id,
1651 	uint32_t node_id,
1652 	struct rte_tm_error *error);
1653 
1654 /**
1655  * Traffic manager node resume
1656  *
1657  * Resume an existing node that is currently in suspended state. The node
1658  * entered the suspended state as result of a previous node suspend operation.
1659  *
1660  * @param[in] port_id
1661  *   The port identifier of the Ethernet device.
1662  * @param[in] node_id
1663  *   Node ID. Needs to be valid.
1664  * @param[out] error
1665  *   Error details. Filled in only on error, when not NULL.
1666  * @return
1667  *   0 on success, non-zero error code otherwise.
1668  *
1669  * @see rte_tm_node_suspend()
1670  * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1671  */
1672 int
1673 rte_tm_node_resume(uint16_t port_id,
1674 	uint32_t node_id,
1675 	struct rte_tm_error *error);
1676 
1677 /**
1678  * Traffic manager hierarchy commit
1679  *
1680  * This function is called during the port initialization phase (before the
1681  * Ethernet port is started) to freeze the start-up hierarchy.
1682  *
1683  * This function typically performs the following steps:
1684  *    a) It validates the start-up hierarchy that was previously defined for the
1685  *       current port through successive rte_tm_node_add() invocations;
1686  *    b) Assuming successful validation, it performs all the necessary port
1687  *       specific configuration operations to install the specified hierarchy on
1688  *       the current port, with immediate effect once the port is started.
1689  *
1690  * This function fails when the currently configured hierarchy is not supported
1691  * by the Ethernet port, in which case the user can abort or try out another
1692  * hierarchy configuration (e.g. a hierarchy with less leaf nodes), which can be
1693  * build from scratch (when *clear_on_fail* is enabled) or by modifying the
1694  * existing hierarchy configuration (when *clear_on_fail* is disabled).
1695  *
1696  * Note that this function can still fail due to other causes (e.g. not enough
1697  * memory available in the system, etc), even though the specified hierarchy is
1698  * supported in principle by the current port.
1699  *
1700  * @param[in] port_id
1701  *   The port identifier of the Ethernet device.
1702  * @param[in] clear_on_fail
1703  *   On function call failure, hierarchy is cleared when this parameter is
1704  *   non-zero and preserved when this parameter is equal to zero.
1705  * @param[out] error
1706  *   Error details. Filled in only on error, when not NULL.
1707  * @return
1708  *   0 on success, non-zero error code otherwise.
1709  *
1710  * @see rte_tm_node_add()
1711  * @see rte_tm_node_delete()
1712  */
1713 int
1714 rte_tm_hierarchy_commit(uint16_t port_id,
1715 	int clear_on_fail,
1716 	struct rte_tm_error *error);
1717 
1718 /**
1719  * Traffic manager node parent update
1720  *
1721  * This function may be used to move a node and its children to a different
1722  * parent.  Additionally, if the new parent is the same as the current parent,
1723  * this function will update the priority/weight of an existing node.
1724  *
1725  * Restriction for root node: its parent cannot be changed.
1726  *
1727  * This function can only be called after the rte_tm_hierarchy_commit()
1728  * invocation. Its success depends on the port support for this operation, as
1729  * advertised through the port capability set.
1730  *
1731  * @param[in] port_id
1732  *   The port identifier of the Ethernet device.
1733  * @param[in] node_id
1734  *   Node ID. Needs to be valid.
1735  * @param[in] parent_node_id
1736  *   Node ID for the new parent. Needs to be valid.
1737  * @param[in] priority
1738  *   Node priority. The highest node priority is zero. Used by the SP algorithm
1739  *   running on the parent of the current node for scheduling this child node.
1740  * @param[in] weight
1741  *   Node weight. The node weight is relative to the weight sum of all siblings
1742  *   that have the same priority. The lowest weight is zero. Used by the WFQ
1743  *   algorithm running on the parent of the current node for scheduling this
1744  *   child node.
1745  * @param[out] error
1746  *   Error details. Filled in only on error, when not NULL.
1747  * @return
1748  *   0 on success, non-zero error code otherwise.
1749  *
1750  * @see RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL
1751  * @see RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL
1752  */
1753 int
1754 rte_tm_node_parent_update(uint16_t port_id,
1755 	uint32_t node_id,
1756 	uint32_t parent_node_id,
1757 	uint32_t priority,
1758 	uint32_t weight,
1759 	struct rte_tm_error *error);
1760 
1761 /**
1762  * Traffic manager node private shaper update
1763  *
1764  * Restriction for the root node: its private shaper profile needs to be valid
1765  * and single rate.
1766  *
1767  * @param[in] port_id
1768  *   The port identifier of the Ethernet device.
1769  * @param[in] node_id
1770  *   Node ID. Needs to be valid.
1771  * @param[in] shaper_profile_id
1772  *   Shaper profile ID for the private shaper of the current node. Needs to be
1773  *   either valid shaper profile ID or RTE_TM_SHAPER_PROFILE_ID_NONE, with
1774  *   the latter disabling the private shaper of the current node.
1775  * @param[out] error
1776  *   Error details. Filled in only on error, when not NULL.
1777  * @return
1778  *   0 on success, non-zero error code otherwise.
1779  *
1780  * @see struct rte_tm_capabilities::shaper_private_n_max
1781  */
1782 int
1783 rte_tm_node_shaper_update(uint16_t port_id,
1784 	uint32_t node_id,
1785 	uint32_t shaper_profile_id,
1786 	struct rte_tm_error *error);
1787 
1788 /**
1789  * Traffic manager node shared shapers update
1790  *
1791  * Restriction for root node: cannot use any shared rate shapers.
1792  *
1793  * @param[in] port_id
1794  *   The port identifier of the Ethernet device.
1795  * @param[in] node_id
1796  *   Node ID. Needs to be valid.
1797  * @param[in] shared_shaper_id
1798  *   Shared shaper ID. Needs to be valid.
1799  * @param[in] add
1800  *   Set to non-zero value to add this shared shaper to current node or to zero
1801  *   to delete this shared shaper from current node.
1802  * @param[out] error
1803  *   Error details. Filled in only on error, when not NULL.
1804  * @return
1805  *   0 on success, non-zero error code otherwise.
1806  *
1807  * @see struct rte_tm_capabilities::shaper_shared_n_max
1808  */
1809 int
1810 rte_tm_node_shared_shaper_update(uint16_t port_id,
1811 	uint32_t node_id,
1812 	uint32_t shared_shaper_id,
1813 	int add,
1814 	struct rte_tm_error *error);
1815 
1816 /**
1817  * Traffic manager node enabled statistics counters update
1818  *
1819  * @param[in] port_id
1820  *   The port identifier of the Ethernet device.
1821  * @param[in] node_id
1822  *   Node ID. Needs to be valid.
1823  * @param[in] stats_mask
1824  *   Mask of statistics counter types to be enabled for the current node. This
1825  *   needs to be a subset of the statistics counter types available for the
1826  *   current node. Any statistics counter type not included in this set is to
1827  *   be disabled for the current node.
1828  * @param[out] error
1829  *   Error details. Filled in only on error, when not NULL.
1830  * @return
1831  *   0 on success, non-zero error code otherwise.
1832  *
1833  * @see enum rte_tm_stats_type
1834  * @see RTE_TM_UPDATE_NODE_STATS
1835  */
1836 int
1837 rte_tm_node_stats_update(uint16_t port_id,
1838 	uint32_t node_id,
1839 	uint64_t stats_mask,
1840 	struct rte_tm_error *error);
1841 
1842 /**
1843  * Traffic manager node WFQ weight mode update
1844  *
1845  * @param[in] port_id
1846  *   The port identifier of the Ethernet device.
1847  * @param[in] node_id
1848  *   Node ID. Needs to be valid non-leaf node ID.
1849  * @param[in] wfq_weight_mode
1850  *   WFQ weight mode for each SP priority. When NULL, it indicates that WFQ is
1851  *   to be used for all priorities. When non-NULL, it points to a pre-allocated
1852  *   array of *n_sp_priorities* values, with non-zero value for byte-mode and
1853  *   zero for packet-mode.
1854  * @param[in] n_sp_priorities
1855  *   Number of SP priorities.
1856  * @param[out] error
1857  *   Error details. Filled in only on error, when not NULL.
1858  * @return
1859  *   0 on success, non-zero error code otherwise.
1860  *
1861  * @see RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE
1862  * @see RTE_TM_UPDATE_NODE_N_SP_PRIORITIES
1863  */
1864 int
1865 rte_tm_node_wfq_weight_mode_update(uint16_t port_id,
1866 	uint32_t node_id,
1867 	int *wfq_weight_mode,
1868 	uint32_t n_sp_priorities,
1869 	struct rte_tm_error *error);
1870 
1871 /**
1872  * Traffic manager node congestion management mode update
1873  *
1874  * @param[in] port_id
1875  *   The port identifier of the Ethernet device.
1876  * @param[in] node_id
1877  *   Node ID. Needs to be valid leaf node ID.
1878  * @param[in] cman
1879  *   Congestion management mode.
1880  * @param[out] error
1881  *   Error details. Filled in only on error, when not NULL.
1882  * @return
1883  *   0 on success, non-zero error code otherwise.
1884  *
1885  * @see RTE_TM_UPDATE_NODE_CMAN
1886  */
1887 int
1888 rte_tm_node_cman_update(uint16_t port_id,
1889 	uint32_t node_id,
1890 	enum rte_tm_cman_mode cman,
1891 	struct rte_tm_error *error);
1892 
1893 /**
1894  * Traffic manager node private WRED context update
1895  *
1896  * @param[in] port_id
1897  *   The port identifier of the Ethernet device.
1898  * @param[in] node_id
1899  *   Node ID. Needs to be valid leaf node ID.
1900  * @param[in] wred_profile_id
1901  *   WRED profile ID for the private WRED context of the current node. Needs to
1902  *   be either valid WRED profile ID or RTE_TM_WRED_PROFILE_ID_NONE, with the
1903  *   latter disabling the private WRED context of the current node.
1904  * @param[out] error
1905  *   Error details. Filled in only on error, when not NULL.
1906  * @return
1907  *   0 on success, non-zero error code otherwise.
1908  *
1909  * @see struct rte_tm_capabilities::cman_wred_context_private_n_max
1910  */
1911 int
1912 rte_tm_node_wred_context_update(uint16_t port_id,
1913 	uint32_t node_id,
1914 	uint32_t wred_profile_id,
1915 	struct rte_tm_error *error);
1916 
1917 /**
1918  * Traffic manager node shared WRED context update
1919  *
1920  * @param[in] port_id
1921  *   The port identifier of the Ethernet device.
1922  * @param[in] node_id
1923  *   Node ID. Needs to be valid leaf node ID.
1924  * @param[in] shared_wred_context_id
1925  *   Shared WRED context ID. Needs to be valid.
1926  * @param[in] add
1927  *   Set to non-zero value to add this shared WRED context to current node or
1928  *   to zero to delete this shared WRED context from current node.
1929  * @param[out] error
1930  *   Error details. Filled in only on error, when not NULL.
1931  * @return
1932  *   0 on success, non-zero error code otherwise.
1933  *
1934  * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1935  */
1936 int
1937 rte_tm_node_shared_wred_context_update(uint16_t port_id,
1938 	uint32_t node_id,
1939 	uint32_t shared_wred_context_id,
1940 	int add,
1941 	struct rte_tm_error *error);
1942 
1943 /**
1944  * Traffic manager node statistics counters read
1945  *
1946  * @param[in] port_id
1947  *   The port identifier of the Ethernet device.
1948  * @param[in] node_id
1949  *   Node ID. Needs to be valid.
1950  * @param[out] stats
1951  *   When non-NULL, it contains the current value for the statistics counters
1952  *   enabled for the current node.
1953  * @param[out] stats_mask
1954  *   When non-NULL, it contains the mask of statistics counter types that are
1955  *   currently enabled for this node, indicating which of the counters
1956  *   retrieved with the *stats* structure are valid.
1957  * @param[in] clear
1958  *   When this parameter has a non-zero value, the statistics counters are
1959  *   cleared (i.e. set to zero) immediately after they have been read,
1960  *   otherwise the statistics counters are left untouched.
1961  * @param[out] error
1962  *   Error details. Filled in only on error, when not NULL.
1963  * @return
1964  *   0 on success, non-zero error code otherwise.
1965  *
1966  * @see enum rte_tm_stats_type
1967  */
1968 int
1969 rte_tm_node_stats_read(uint16_t port_id,
1970 	uint32_t node_id,
1971 	struct rte_tm_node_stats *stats,
1972 	uint64_t *stats_mask,
1973 	int clear,
1974 	struct rte_tm_error *error);
1975 
1976 /**
1977  * Traffic manager packet marking - VLAN DEI (IEEE 802.1Q)
1978  *
1979  * IEEE 802.1p maps the traffic class to the VLAN Priority Code Point (PCP)
1980  * field (3 bits), while IEEE 802.1q maps the drop priority to the VLAN Drop
1981  * Eligible Indicator (DEI) field (1 bit), which was previously named Canonical
1982  * Format Indicator (CFI).
1983  *
1984  * All VLAN frames of a given color get their DEI bit set if marking is enabled
1985  * for this color; otherwise, their DEI bit is left as is (either set or not).
1986  *
1987  * @param[in] port_id
1988  *   The port identifier of the Ethernet device.
1989  * @param[in] mark_green
1990  *   Set to non-zero value to enable marking of green packets and to zero to
1991  *   disable it.
1992  * @param[in] mark_yellow
1993  *   Set to non-zero value to enable marking of yellow packets and to zero to
1994  *   disable it.
1995  * @param[in] mark_red
1996  *   Set to non-zero value to enable marking of red packets and to zero to
1997  *   disable it.
1998  * @param[out] error
1999  *   Error details. Filled in only on error, when not NULL.
2000  * @return
2001  *   0 on success, non-zero error code otherwise.
2002  *
2003  * @see struct rte_tm_capabilities::mark_vlan_dei_supported
2004  */
2005 int
2006 rte_tm_mark_vlan_dei(uint16_t port_id,
2007 	int mark_green,
2008 	int mark_yellow,
2009 	int mark_red,
2010 	struct rte_tm_error *error);
2011 
2012 /**
2013  * Traffic manager packet marking - IPv4 / IPv6 ECN (IETF RFC 3168)
2014  *
2015  * IETF RFCs 2474 and 3168 reorganize the IPv4 Type of Service (TOS) field
2016  * (8 bits) and the IPv6 Traffic Class (TC) field (8 bits) into Differentiated
2017  * Services Codepoint (DSCP) field (6 bits) and Explicit Congestion
2018  * Notification (ECN) field (2 bits). The DSCP field is typically used to
2019  * encode the traffic class and/or drop priority (RFC 2597), while the ECN
2020  * field is used by RFC 3168 to implement a congestion notification mechanism
2021  * to be leveraged by transport layer protocols such as TCP and SCTP that have
2022  * congestion control mechanisms.
2023  *
2024  * When congestion is experienced, as alternative to dropping the packet,
2025  * routers can change the ECN field of input packets from 2'b01 or 2'b10
2026  * (values indicating that source endpoint is ECN-capable) to 2'b11 (meaning
2027  * that congestion is experienced). The destination endpoint can use the
2028  * ECN-Echo (ECE) TCP flag to relay the congestion indication back to the
2029  * source endpoint, which acknowledges it back to the destination endpoint with
2030  * the Congestion Window Reduced (CWR) TCP flag.
2031  *
2032  * All IPv4/IPv6 packets of a given color with ECN set to 2’b01 or 2’b10
2033  * carrying TCP or SCTP have their ECN set to 2’b11 if the marking feature is
2034  * enabled for the current color, otherwise the ECN field is left as is.
2035  *
2036  * @param[in] port_id
2037  *   The port identifier of the Ethernet device.
2038  * @param[in] mark_green
2039  *   Set to non-zero value to enable marking of green packets and to zero to
2040  *   disable it.
2041  * @param[in] mark_yellow
2042  *   Set to non-zero value to enable marking of yellow packets and to zero to
2043  *   disable it.
2044  * @param[in] mark_red
2045  *   Set to non-zero value to enable marking of red packets and to zero to
2046  *   disable it.
2047  * @param[out] error
2048  *   Error details. Filled in only on error, when not NULL.
2049  * @return
2050  *   0 on success, non-zero error code otherwise.
2051  *
2052  * @see struct rte_tm_capabilities::mark_ip_ecn_tcp_supported
2053  * @see struct rte_tm_capabilities::mark_ip_ecn_sctp_supported
2054  */
2055 int
2056 rte_tm_mark_ip_ecn(uint16_t port_id,
2057 	int mark_green,
2058 	int mark_yellow,
2059 	int mark_red,
2060 	struct rte_tm_error *error);
2061 
2062 /**
2063  * Traffic manager packet marking - IPv4 / IPv6 DSCP (IETF RFC 2597)
2064  *
2065  * IETF RFC 2597 maps the traffic class and the drop priority to the IPv4/IPv6
2066  * Differentiated Services Codepoint (DSCP) field (6 bits). Here are the DSCP
2067  * values proposed by this RFC:
2068  *
2069  * <pre>                   Class 1    Class 2    Class 3    Class 4   </pre>
2070  * <pre>                 +----------+----------+----------+----------+</pre>
2071  * <pre>Low Drop Prec    |  001010  |  010010  |  011010  |  100010  |</pre>
2072  * <pre>Medium Drop Prec |  001100  |  010100  |  011100  |  100100  |</pre>
2073  * <pre>High Drop Prec   |  001110  |  010110  |  011110  |  100110  |</pre>
2074  * <pre>                 +----------+----------+----------+----------+</pre>
2075  *
2076  * There are 4 traffic classes (classes 1 .. 4) encoded by DSCP bits 1 and 2,
2077  * as well as 3 drop priorities (low/medium/high) encoded by DSCP bits 3 and 4.
2078  *
2079  * All IPv4/IPv6 packets have their color marked into DSCP bits 3 and 4 as
2080  * follows: green mapped to Low Drop Precedence (2’b01), yellow to Medium
2081  * (2’b10) and red to High (2’b11). Marking needs to be explicitly enabled
2082  * for each color; when not enabled for a given color, the DSCP field of all
2083  * packets with that color is left as is.
2084  *
2085  * @param[in] port_id
2086  *   The port identifier of the Ethernet device.
2087  * @param[in] mark_green
2088  *   Set to non-zero value to enable marking of green packets and to zero to
2089  *   disable it.
2090  * @param[in] mark_yellow
2091  *   Set to non-zero value to enable marking of yellow packets and to zero to
2092  *   disable it.
2093  * @param[in] mark_red
2094  *   Set to non-zero value to enable marking of red packets and to zero to
2095  *   disable it.
2096  * @param[out] error
2097  *   Error details. Filled in only on error, when not NULL.
2098  * @return
2099  *   0 on success, non-zero error code otherwise.
2100  *
2101  * @see struct rte_tm_capabilities::mark_ip_dscp_supported
2102  */
2103 int
2104 rte_tm_mark_ip_dscp(uint16_t port_id,
2105 	int mark_green,
2106 	int mark_yellow,
2107 	int mark_red,
2108 	struct rte_tm_error *error);
2109 
2110 #ifdef __cplusplus
2111 }
2112 #endif
2113 
2114 #endif /* __INCLUDE_RTE_TM_H__ */
2115