1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation.
3 * Copyright(c) 2017 Cavium.
4 * Copyright(c) 2017 NXP.
7 #ifndef __INCLUDE_RTE_TM_H__
8 #define __INCLUDE_RTE_TM_H__
12 * RTE Generic Traffic Manager API
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.
20 * All functions in this file may be changed or removed without prior notice.
25 #include <rte_common.h>
26 #include <rte_meter.h>
33 * Ethernet framing overhead.
35 * Overhead fields per Ethernet frame:
36 * 1. Preamble: 7 bytes;
37 * 2. Start of Frame Delimiter (SFD): 1 byte;
38 * 3. Inter-Frame Gap (IFG): 12 bytes.
40 * One of the typical values for the *pkt_length_adjust* field of the shaper
43 * @see struct rte_tm_shaper_params
45 #define RTE_TM_ETH_FRAMING_OVERHEAD 20
48 * Ethernet framing overhead including the Frame Check Sequence (FCS) field.
49 * Useful when FCS is generated and added at the end of the Ethernet frame on
50 * TX side without any SW intervention.
52 * One of the typical values for the pkt_length_adjust field of the shaper
55 * @see struct rte_tm_shaper_params
57 #define RTE_TM_ETH_FRAMING_OVERHEAD_FCS 24
60 * Invalid WRED profile ID.
62 * @see struct rte_tm_node_params
63 * @see rte_tm_node_add()
64 * @see rte_tm_node_wred_context_update()
66 #define RTE_TM_WRED_PROFILE_ID_NONE UINT32_MAX
69 *Invalid shaper profile ID.
71 * @see struct rte_tm_node_params
72 * @see rte_tm_node_add()
73 * @see rte_tm_node_shaper_update()
75 #define RTE_TM_SHAPER_PROFILE_ID_NONE UINT32_MAX
78 * Node ID for the parent of the root node.
80 * @see rte_tm_node_add()
82 #define RTE_TM_NODE_ID_NULL UINT32_MAX
85 * Node level ID used to disable level ID checking.
87 * @see rte_tm_node_add()
89 #define RTE_TM_NODE_LEVEL_ID_ANY UINT32_MAX
92 * Node statistics counter type
94 enum rte_tm_stats_type {
95 /** Number of packets scheduled from current node. */
96 RTE_TM_STATS_N_PKTS = 1 << 0,
98 /** Number of bytes scheduled from current node. */
99 RTE_TM_STATS_N_BYTES = 1 << 1,
101 /** Number of green packets dropped by current leaf node. */
102 RTE_TM_STATS_N_PKTS_GREEN_DROPPED = 1 << 2,
104 /** Number of yellow packets dropped by current leaf node. */
105 RTE_TM_STATS_N_PKTS_YELLOW_DROPPED = 1 << 3,
107 /** Number of red packets dropped by current leaf node. */
108 RTE_TM_STATS_N_PKTS_RED_DROPPED = 1 << 4,
110 /** Number of green bytes dropped by current leaf node. */
111 RTE_TM_STATS_N_BYTES_GREEN_DROPPED = 1 << 5,
113 /** Number of yellow bytes dropped by current leaf node. */
114 RTE_TM_STATS_N_BYTES_YELLOW_DROPPED = 1 << 6,
116 /** Number of red bytes dropped by current leaf node. */
117 RTE_TM_STATS_N_BYTES_RED_DROPPED = 1 << 7,
119 /** Number of packets currently waiting in the packet queue of current
122 RTE_TM_STATS_N_PKTS_QUEUED = 1 << 8,
124 /** Number of bytes currently waiting in the packet queue of current
127 RTE_TM_STATS_N_BYTES_QUEUED = 1 << 9,
131 * Node statistics counters
133 struct rte_tm_node_stats {
134 /** Number of packets scheduled from current node. */
137 /** Number of bytes scheduled from current node. */
140 /** Statistics counters for leaf nodes only. */
142 /** Number of packets dropped by current leaf node per each
145 uint64_t n_pkts_dropped[RTE_COLORS];
147 /** Number of bytes dropped by current leaf node per each
150 uint64_t n_bytes_dropped[RTE_COLORS];
152 /** Number of packets currently waiting in the packet queue of
155 uint64_t n_pkts_queued;
157 /** Number of bytes currently waiting in the packet queue of
160 uint64_t n_bytes_queued;
165 * Traffic manager dynamic updates
167 enum rte_tm_dynamic_update_type {
168 /** Dynamic parent node update. The new parent node is located on same
169 * hierarchy level as the former parent node. Consequently, the node
170 * whose parent is changed preserves its hierarchy level.
172 RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL = 1 << 0,
174 /** Dynamic parent node update. The new parent node is located on
175 * different hierarchy level than the former parent node. Consequently,
176 * the node whose parent is changed also changes its hierarchy level.
178 RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL = 1 << 1,
180 /** Dynamic node add/delete. */
181 RTE_TM_UPDATE_NODE_ADD_DELETE = 1 << 2,
183 /** Suspend/resume nodes. */
184 RTE_TM_UPDATE_NODE_SUSPEND_RESUME = 1 << 3,
186 /** Dynamic switch between byte-based and packet-based WFQ weights. */
187 RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE = 1 << 4,
189 /** Dynamic update on number of SP priorities. */
190 RTE_TM_UPDATE_NODE_N_SP_PRIORITIES = 1 << 5,
192 /** Dynamic update of congestion management mode for leaf nodes. */
193 RTE_TM_UPDATE_NODE_CMAN = 1 << 6,
195 /** Dynamic update of the set of enabled stats counter types. */
196 RTE_TM_UPDATE_NODE_STATS = 1 << 7,
200 * Traffic manager capabilities
202 struct rte_tm_capabilities {
203 /** Maximum number of nodes. */
204 uint32_t n_nodes_max;
206 /** Maximum number of levels (i.e. number of nodes connecting the root
207 * node with any leaf node, including the root and the leaf).
209 uint32_t n_levels_max;
211 /** When non-zero, this flag indicates that all the non-leaf nodes
212 * (with the exception of the root node) have identical capability set.
214 int non_leaf_nodes_identical;
216 /** When non-zero, this flag indicates that all the leaf nodes have
217 * identical capability set.
219 int leaf_nodes_identical;
221 /** Maximum number of shapers, either private or shared. In case the
222 * implementation does not share any resources between private and
223 * shared shapers, it is typically equal to the sum of
224 * *shaper_private_n_max* and *shaper_shared_n_max*. The
225 * value of zero indicates that traffic shaping is not supported.
227 uint32_t shaper_n_max;
229 /** Maximum number of private shapers. Indicates the maximum number of
230 * nodes that can concurrently have their private shaper enabled. The
231 * value of zero indicates that private shapers are not supported.
233 uint32_t shaper_private_n_max;
235 /** Maximum number of private shapers that support dual rate shaping.
236 * Indicates the maximum number of nodes that can concurrently have
237 * their private shaper enabled with dual rate support. Only valid when
238 * private shapers are supported. The value of zero indicates that dual
239 * rate shaping is not available for private shapers. The maximum value
240 * is *shaper_private_n_max*.
242 int shaper_private_dual_rate_n_max;
244 /** Minimum committed/peak rate (bytes per second) for any private
245 * shaper. Valid only when private shapers are supported.
247 uint64_t shaper_private_rate_min;
249 /** Maximum committed/peak rate (bytes per second) for any private
250 * shaper. Valid only when private shapers are supported.
252 uint64_t shaper_private_rate_max;
254 /** Maximum number of shared shapers. The value of zero indicates that
255 * shared shapers are not supported.
257 uint32_t shaper_shared_n_max;
259 /** Maximum number of nodes that can share the same shared shaper.
260 * Only valid when shared shapers are supported.
262 uint32_t shaper_shared_n_nodes_per_shaper_max;
264 /** Maximum number of shared shapers a node can be part of. This
265 * parameter indicates that there is at least one node that can be
266 * configured with this many shared shapers, which might not be true for
267 * all the nodes. Only valid when shared shapers are supported, in which
268 * case it ranges from 1 to *shaper_shared_n_max*.
270 uint32_t shaper_shared_n_shapers_per_node_max;
272 /** Maximum number of shared shapers that can be configured with dual
273 * rate shaping. The value of zero indicates that dual rate shaping
274 * support is not available for shared shapers.
276 uint32_t shaper_shared_dual_rate_n_max;
278 /** Minimum committed/peak rate (bytes per second) for any shared
279 * shaper. Only valid when shared shapers are supported.
281 uint64_t shaper_shared_rate_min;
283 /** Maximum committed/peak rate (bytes per second) for any shared
284 * shaper. Only valid when shared shapers are supported.
286 uint64_t shaper_shared_rate_max;
288 /** Minimum value allowed for packet length adjustment for any private
291 int shaper_pkt_length_adjust_min;
293 /** Maximum value allowed for packet length adjustment for any private
296 int shaper_pkt_length_adjust_max;
298 /** Maximum number of children nodes. This parameter indicates that
299 * there is at least one non-leaf node that can be configured with this
300 * many children nodes, which might not be true for all the non-leaf
303 uint32_t sched_n_children_max;
305 /** Maximum number of supported priority levels. This parameter
306 * indicates that there is at least one non-leaf node that can be
307 * configured with this many priority levels for managing its children
308 * nodes, which might not be true for all the non-leaf nodes. The value
309 * of zero is invalid. The value of 1 indicates that only priority 0 is
310 * supported, which essentially means that Strict Priority (SP)
311 * algorithm is not supported.
313 uint32_t sched_sp_n_priorities_max;
315 /** Maximum number of sibling nodes that can have the same priority at
316 * any given time, i.e. maximum size of the WFQ sibling node group. This
317 * parameter indicates there is at least one non-leaf node that meets
318 * this condition, which might not be true for all the non-leaf nodes.
319 * The value of zero is invalid. The value of 1 indicates that WFQ
320 * algorithm is not supported. The maximum value is
321 * *sched_n_children_max*.
323 uint32_t sched_wfq_n_children_per_group_max;
325 /** Maximum number of priority levels that can have more than one child
326 * node at any given time, i.e. maximum number of WFQ sibling node
327 * groups that have two or more members. This parameter indicates there
328 * is at least one non-leaf node that meets this condition, which might
329 * not be true for all the non-leaf nodes. The value of zero states that
330 * WFQ algorithm is not supported. The value of 1 indicates that
331 * (*sched_sp_n_priorities_max* - 1) priority levels have at most one
332 * child node, so there can be only one priority level with two or
333 * more sibling nodes making up a WFQ group. The maximum value is:
334 * min(floor(*sched_n_children_max* / 2), *sched_sp_n_priorities_max*).
336 uint32_t sched_wfq_n_groups_max;
338 /** Maximum WFQ weight. The value of 1 indicates that all sibling nodes
339 * with same priority have the same WFQ weight, so WFQ is reduced to FQ.
341 uint32_t sched_wfq_weight_max;
343 /** WRED packet mode support. When non-zero, this parameter indicates
344 * that there is at least one leaf node that supports the WRED packet
345 * mode, which might not be true for all the leaf nodes. In packet
346 * mode, the WRED thresholds specify the queue length in packets, as
349 int cman_wred_packet_mode_supported;
351 /** WRED byte mode support. When non-zero, this parameter indicates that
352 * there is at least one leaf node that supports the WRED byte mode,
353 * which might not be true for all the leaf nodes. In byte mode, the
354 * WRED thresholds specify the queue length in bytes, as opposed to
357 int cman_wred_byte_mode_supported;
359 /** Head drop algorithm support. When non-zero, this parameter
360 * indicates that there is at least one leaf node that supports the head
361 * drop algorithm, which might not be true for all the leaf nodes.
363 int cman_head_drop_supported;
365 /** Maximum number of WRED contexts, either private or shared. In case
366 * the implementation does not share any resources between private and
367 * shared WRED contexts, it is typically equal to the sum of
368 * *cman_wred_context_private_n_max* and
369 * *cman_wred_context_shared_n_max*. The value of zero indicates that
370 * WRED is not supported.
372 uint32_t cman_wred_context_n_max;
374 /** Maximum number of private WRED contexts. Indicates the maximum
375 * number of leaf nodes that can concurrently have their private WRED
376 * context enabled. The value of zero indicates that private WRED
377 * contexts are not supported.
379 uint32_t cman_wred_context_private_n_max;
381 /** Maximum number of shared WRED contexts. The value of zero
382 * indicates that shared WRED contexts are not supported.
384 uint32_t cman_wred_context_shared_n_max;
386 /** Maximum number of leaf nodes that can share the same WRED context.
387 * Only valid when shared WRED contexts are supported.
389 uint32_t cman_wred_context_shared_n_nodes_per_context_max;
391 /** Maximum number of shared WRED contexts a leaf node can be part of.
392 * This parameter indicates that there is at least one leaf node that
393 * can be configured with this many shared WRED contexts, which might
394 * not be true for all the leaf nodes. Only valid when shared WRED
395 * contexts are supported, in which case it ranges from 1 to
396 * *cman_wred_context_shared_n_max*.
398 uint32_t cman_wred_context_shared_n_contexts_per_node_max;
400 /** Support for VLAN DEI packet marking (per color). */
401 int mark_vlan_dei_supported[RTE_COLORS];
403 /** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */
404 int mark_ip_ecn_tcp_supported[RTE_COLORS];
406 /** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */
407 int mark_ip_ecn_sctp_supported[RTE_COLORS];
409 /** Support for IPv4/IPv6 DSCP packet marking (per color). */
410 int mark_ip_dscp_supported[RTE_COLORS];
412 /** Set of supported dynamic update operations.
413 * @see enum rte_tm_dynamic_update_type
415 uint64_t dynamic_update_mask;
417 /** Set of supported statistics counter types.
418 * @see enum rte_tm_stats_type
424 * Traffic manager level capabilities
426 struct rte_tm_level_capabilities {
427 /** Maximum number of nodes for the current hierarchy level. */
428 uint32_t n_nodes_max;
430 /** Maximum number of non-leaf nodes for the current hierarchy level.
431 * The value of 0 indicates that current level only supports leaf
432 * nodes. The maximum value is *n_nodes_max*.
434 uint32_t n_nodes_nonleaf_max;
436 /** Maximum number of leaf nodes for the current hierarchy level. The
437 * value of 0 indicates that current level only supports non-leaf
438 * nodes. The maximum value is *n_nodes_max*.
440 uint32_t n_nodes_leaf_max;
442 /** When non-zero, this flag indicates that all the non-leaf nodes on
443 * this level have identical capability set. Valid only when
444 * *n_nodes_nonleaf_max* is non-zero.
446 int non_leaf_nodes_identical;
448 /** When non-zero, this flag indicates that all the leaf nodes on this
449 * level have identical capability set. Valid only when
450 * *n_nodes_leaf_max* is non-zero.
452 int leaf_nodes_identical;
456 /** Items valid only for the non-leaf nodes on this level. */
458 /** Private shaper support. When non-zero, it indicates
459 * there is at least one non-leaf node on this level
460 * with private shaper support, which may not be the
461 * case for all the non-leaf nodes on this level.
463 int shaper_private_supported;
465 /** Dual rate support for private shaper. Valid only
466 * when private shaper is supported for the non-leaf
467 * nodes on the current level. When non-zero, it
468 * indicates there is at least one non-leaf node on this
469 * level with dual rate private shaper support, which
470 * may not be the case for all the non-leaf nodes on
473 int shaper_private_dual_rate_supported;
475 /** Minimum committed/peak rate (bytes per second) for
476 * private shapers of the non-leaf nodes of this level.
477 * Valid only when private shaper is supported on this
480 uint64_t shaper_private_rate_min;
482 /** Maximum committed/peak rate (bytes per second) for
483 * private shapers of the non-leaf nodes on this level.
484 * Valid only when private shaper is supported on this
487 uint64_t shaper_private_rate_max;
489 /** Maximum number of shared shapers that any non-leaf
490 * node on this level can be part of. The value of zero
491 * indicates that shared shapers are not supported by
492 * the non-leaf nodes on this level. When non-zero, it
493 * indicates there is at least one non-leaf node on this
494 * level that meets this condition, which may not be the
495 * case for all the non-leaf nodes on this level.
497 uint32_t shaper_shared_n_max;
499 /** Maximum number of children nodes. This parameter
500 * indicates that there is at least one non-leaf node on
501 * this level that can be configured with this many
502 * children nodes, which might not be true for all the
503 * non-leaf nodes on this level.
505 uint32_t sched_n_children_max;
507 /** Maximum number of supported priority levels. This
508 * parameter indicates that there is at least one
509 * non-leaf node on this level that can be configured
510 * with this many priority levels for managing its
511 * children nodes, which might not be true for all the
512 * non-leaf nodes on this level. The value of zero is
513 * invalid. The value of 1 indicates that only priority
514 * 0 is supported, which essentially means that Strict
515 * Priority (SP) algorithm is not supported on this
518 uint32_t sched_sp_n_priorities_max;
520 /** Maximum number of sibling nodes that can have the
521 * same priority at any given time, i.e. maximum size of
522 * the WFQ sibling node group. This parameter indicates
523 * there is at least one non-leaf node on this level
524 * that meets this condition, which may not be true for
525 * all the non-leaf nodes on this level. The value of
526 * zero is invalid. The value of 1 indicates that WFQ
527 * algorithm is not supported on this level. The maximum
528 * value is *sched_n_children_max*.
530 uint32_t sched_wfq_n_children_per_group_max;
532 /** Maximum number of priority levels that can have
533 * more than one child node at any given time, i.e.
534 * maximum number of WFQ sibling node groups that
535 * have two or more members. This parameter indicates
536 * there is at least one non-leaf node on this level
537 * that meets this condition, which might not be true
538 * for all the non-leaf nodes. The value of zero states
539 * that WFQ algorithm is not supported on this level.
540 * The value of 1 indicates that
541 * (*sched_sp_n_priorities_max* - 1) priority levels on
542 * this level have at most one child node, so there can
543 * be only one priority level with two or more sibling
544 * nodes making up a WFQ group on this level. The
546 * min(floor(*sched_n_children_max* / 2),
547 * *sched_sp_n_priorities_max*).
549 uint32_t sched_wfq_n_groups_max;
551 /** Maximum WFQ weight. The value of 1 indicates that
552 * all sibling nodes on this level with same priority
553 * have the same WFQ weight, so on this level WFQ is
556 uint32_t sched_wfq_weight_max;
558 /** Mask of statistics counter types supported by the
559 * non-leaf nodes on this level. Every supported
560 * statistics counter type is supported by at least one
561 * non-leaf node on this level, which may not be true
562 * for all the non-leaf nodes on this level.
563 * @see enum rte_tm_stats_type
568 /** Items valid only for the leaf nodes on this level. */
570 /** Private shaper support. When non-zero, it indicates
571 * there is at least one leaf node on this level with
572 * private shaper support, which may not be the case for
573 * all the leaf nodes on this level.
575 int shaper_private_supported;
577 /** Dual rate support for private shaper. Valid only
578 * when private shaper is supported for the leaf nodes
579 * on this level. When non-zero, it indicates there is
580 * at least one leaf node on this level with dual rate
581 * private shaper support, which may not be the case for
582 * all the leaf nodes on this level.
584 int shaper_private_dual_rate_supported;
586 /** Minimum committed/peak rate (bytes per second) for
587 * private shapers of the leaf nodes of this level.
588 * Valid only when private shaper is supported for the
589 * leaf nodes on this level.
591 uint64_t shaper_private_rate_min;
593 /** Maximum committed/peak rate (bytes per second) for
594 * private shapers of the leaf nodes on this level.
595 * Valid only when private shaper is supported for the
596 * leaf nodes on this level.
598 uint64_t shaper_private_rate_max;
600 /** Maximum number of shared shapers that any leaf node
601 * on this level can be part of. The value of zero
602 * indicates that shared shapers are not supported by
603 * the leaf nodes on this level. When non-zero, it
604 * indicates there is at least one leaf node on this
605 * level that meets this condition, which may not be the
606 * case for all the leaf nodes on this level.
608 uint32_t shaper_shared_n_max;
610 /** WRED packet mode support. When non-zero, this
611 * parameter indicates that there is at least one leaf
612 * node on this level that supports the WRED packet
613 * mode, which might not be true for all the leaf
614 * nodes. In packet mode, the WRED thresholds specify
615 * the queue length in packets, as opposed to bytes.
617 int cman_wred_packet_mode_supported;
619 /** WRED byte mode support. When non-zero, this
620 * parameter indicates that there is at least one leaf
621 * node on this level that supports the WRED byte mode,
622 * which might not be true for all the leaf nodes. In
623 * byte mode, the WRED thresholds specify the queue
624 * length in bytes, as opposed to packets.
626 int cman_wred_byte_mode_supported;
628 /** Head drop algorithm support. When non-zero, this
629 * parameter indicates that there is at least one leaf
630 * node on this level that supports the head drop
631 * algorithm, which might not be true for all the leaf
632 * nodes on this level.
634 int cman_head_drop_supported;
636 /** Private WRED context support. When non-zero, it
637 * indicates there is at least one node on this level
638 * with private WRED context support, which may not be
639 * true for all the leaf nodes on this level.
641 int cman_wred_context_private_supported;
643 /** Maximum number of shared WRED contexts that any
644 * leaf node on this level can be part of. The value of
645 * zero indicates that shared WRED contexts are not
646 * supported by the leaf nodes on this level. When
647 * non-zero, it indicates there is at least one leaf
648 * node on this level that meets this condition, which
649 * may not be the case for all the leaf nodes on this
652 uint32_t cman_wred_context_shared_n_max;
654 /** Mask of statistics counter types supported by the
655 * leaf nodes on this level. Every supported statistics
656 * counter type is supported by at least one leaf node
657 * on this level, which may not be true for all the leaf
658 * nodes on this level.
659 * @see enum rte_tm_stats_type
667 * Traffic manager node capabilities
669 struct rte_tm_node_capabilities {
670 /** Private shaper support for the current node. */
671 int shaper_private_supported;
673 /** Dual rate shaping support for private shaper of current node.
674 * Valid only when private shaper is supported by the current node.
676 int shaper_private_dual_rate_supported;
678 /** Minimum committed/peak rate (bytes per second) for private
679 * shaper of current node. Valid only when private shaper is supported
680 * by the current node.
682 uint64_t shaper_private_rate_min;
684 /** Maximum committed/peak rate (bytes per second) for private
685 * shaper of current node. Valid only when private shaper is supported
686 * by the current node.
688 uint64_t shaper_private_rate_max;
690 /** Maximum number of shared shapers the current node can be part of.
691 * The value of zero indicates that shared shapers are not supported by
694 uint32_t shaper_shared_n_max;
698 /** Items valid only for non-leaf nodes. */
700 /** Maximum number of children nodes. */
701 uint32_t sched_n_children_max;
703 /** Maximum number of supported priority levels. The
704 * value of zero is invalid. The value of 1 indicates
705 * that only priority 0 is supported, which essentially
706 * means that Strict Priority (SP) algorithm is not
709 uint32_t sched_sp_n_priorities_max;
711 /** Maximum number of sibling nodes that can have the
712 * same priority at any given time, i.e. maximum size
713 * of the WFQ sibling node group. The value of zero
714 * is invalid. The value of 1 indicates that WFQ
715 * algorithm is not supported. The maximum value is
716 * *sched_n_children_max*.
718 uint32_t sched_wfq_n_children_per_group_max;
720 /** Maximum number of priority levels that can have
721 * more than one child node at any given time, i.e.
722 * maximum number of WFQ sibling node groups that have
723 * two or more members. The value of zero states that
724 * WFQ algorithm is not supported. The value of 1
725 * indicates that (*sched_sp_n_priorities_max* - 1)
726 * priority levels have at most one child node, so there
727 * can be only one priority level with two or more
728 * sibling nodes making up a WFQ group. The maximum
729 * value is: min(floor(*sched_n_children_max* / 2),
730 * *sched_sp_n_priorities_max*).
732 uint32_t sched_wfq_n_groups_max;
734 /** Maximum WFQ weight. The value of 1 indicates that
735 * all sibling nodes with same priority have the same
736 * WFQ weight, so WFQ is reduced to FQ.
738 uint32_t sched_wfq_weight_max;
741 /** Items valid only for leaf nodes. */
743 /** WRED packet mode support for current node. */
744 int cman_wred_packet_mode_supported;
746 /** WRED byte mode support for current node. */
747 int cman_wred_byte_mode_supported;
749 /** Head drop algorithm support for current node. */
750 int cman_head_drop_supported;
752 /** Private WRED context support for current node. */
753 int cman_wred_context_private_supported;
755 /** Maximum number of shared WRED contexts the current
756 * node can be part of. The value of zero indicates that
757 * shared WRED contexts are not supported by the current
760 uint32_t cman_wred_context_shared_n_max;
764 /** Mask of statistics counter types supported by the current node.
765 * @see enum rte_tm_stats_type
771 * Congestion management (CMAN) mode
773 * This is used for controlling the admission of packets into a packet queue or
774 * group of packet queues on congestion. On request of writing a new packet
775 * into the current queue while the queue is full, the *tail drop* algorithm
776 * drops the new packet while leaving the queue unmodified, as opposed to *head
777 * drop* algorithm, which drops the packet at the head of the queue (the oldest
778 * packet waiting in the queue) and admits the new packet at the tail of the
781 * The *Random Early Detection (RED)* algorithm works by proactively dropping
782 * more and more input packets as the queue occupancy builds up. When the queue
783 * is full or almost full, RED effectively works as *tail drop*. The *Weighted
784 * RED* algorithm uses a separate set of RED thresholds for each packet color.
786 enum rte_tm_cman_mode {
787 RTE_TM_CMAN_TAIL_DROP = 0, /**< Tail drop */
788 RTE_TM_CMAN_HEAD_DROP, /**< Head drop */
789 RTE_TM_CMAN_WRED, /**< Weighted Random Early Detection (WRED) */
793 * Random Early Detection (RED) profile
795 struct rte_tm_red_params {
796 /** Minimum queue threshold */
799 /** Maximum queue threshold */
802 /** Inverse of packet marking probability maximum value (maxp), i.e.
803 * maxp_inv = 1 / maxp
807 /** Negated log2 of queue weight (wq), i.e. wq = 1 / (2 ^ wq_log2) */
812 * Weighted RED (WRED) profile
814 * Multiple WRED contexts can share the same WRED profile. Each leaf node with
815 * WRED enabled as its congestion management mode has zero or one private WRED
816 * context (only one leaf node using it) and/or zero, one or several shared
817 * WRED contexts (multiple leaf nodes use the same WRED context). A private
818 * WRED context is used to perform congestion management for a single leaf
819 * node, while a shared WRED context is used to perform congestion management
820 * for a group of leaf nodes.
822 * @see struct rte_tm_capabilities::cman_wred_packet_mode_supported
823 * @see struct rte_tm_capabilities::cman_wred_byte_mode_supported
825 struct rte_tm_wred_params {
826 /** One set of RED parameters per packet color */
827 struct rte_tm_red_params red_params[RTE_COLORS];
829 /** When non-zero, the *min_th* and *max_th* thresholds are specified
830 * in packets (WRED packet mode). When zero, the *min_th* and *max_th*
831 * thresholds are specified in bytes (WRED byte mode)
839 struct rte_tm_token_bucket {
840 /** Token bucket rate (bytes per second) */
843 /** Token bucket size (bytes), a.k.a. max burst size */
848 * Shaper (rate limiter) profile
850 * Multiple shaper instances can share the same shaper profile. Each node has
851 * zero or one private shaper (only one node using it) and/or zero, one or
852 * several shared shapers (multiple nodes use the same shaper instance).
853 * A private shaper is used to perform traffic shaping for a single node, while
854 * a shared shaper is used to perform traffic shaping for a group of nodes.
856 * Single rate shapers use a single token bucket. A single rate shaper can be
857 * configured by setting the rate of the committed bucket to zero, which
858 * effectively disables this bucket. The peak bucket is used to limit the rate
859 * and the burst size for the current shaper.
861 * Dual rate shapers use both the committed and the peak token buckets. The
862 * rate of the peak bucket has to be bigger than zero, as well as greater than
863 * or equal to the rate of the committed bucket.
865 struct rte_tm_shaper_params {
866 /** Committed token bucket */
867 struct rte_tm_token_bucket committed;
869 /** Peak token bucket */
870 struct rte_tm_token_bucket peak;
872 /** Signed value to be added to the length of each packet for the
873 * purpose of shaping. Can be used to correct the packet length with
874 * the framing overhead bytes that are also consumed on the wire (e.g.
875 * RTE_TM_ETH_FRAMING_OVERHEAD_FCS).
877 int32_t pkt_length_adjust;
883 * Each non-leaf node has multiple inputs (its children nodes) and single output
884 * (which is input to its parent node). It arbitrates its inputs using Strict
885 * Priority (SP) and Weighted Fair Queuing (WFQ) algorithms to schedule input
886 * packets to its output while observing its shaping (rate limiting)
889 * Algorithms such as Weighted Round Robin (WRR), Byte-level WRR, Deficit WRR
890 * (DWRR), etc. are considered approximations of the WFQ ideal and are
891 * assimilated to WFQ, although an associated implementation-dependent trade-off
892 * on accuracy, performance and resource usage might exist.
894 * Children nodes with different priorities are scheduled using the SP algorithm
895 * based on their priority, with zero (0) as the highest priority. Children with
896 * the same priority are scheduled using the WFQ algorithm according to their
897 * weights. The WFQ weight of a given child node is relative to the sum of the
898 * weights of all its sibling nodes that have the same priority, with one (1) as
899 * the lowest weight. For each SP priority, the WFQ weight mode can be set as
900 * either byte-based or packet-based.
902 * Each leaf node sits on top of a TX queue of the current Ethernet port. Hence,
903 * the leaf nodes are predefined, with their node IDs set to 0 .. (N-1), where N
904 * is the number of TX queues configured for the current Ethernet port. The
905 * non-leaf nodes have their IDs generated by the application.
907 struct rte_tm_node_params {
908 /** Shaper profile for the private shaper. The absence of the private
909 * shaper for the current node is indicated by setting this parameter
910 * to RTE_TM_SHAPER_PROFILE_ID_NONE.
912 uint32_t shaper_profile_id;
914 /** User allocated array of valid shared shaper IDs. */
915 uint32_t *shared_shaper_id;
917 /** Number of shared shaper IDs in the *shared_shaper_id* array. */
918 uint32_t n_shared_shapers;
922 /** Parameters only valid for non-leaf nodes. */
924 /** WFQ weight mode for each SP priority. When NULL, it
925 * indicates that WFQ is to be used for all priorities.
926 * When non-NULL, it points to a pre-allocated array of
927 * *n_sp_priorities* values, with non-zero value for
928 * byte-mode and zero for packet-mode.
930 int *wfq_weight_mode;
932 /** Number of SP priorities. */
933 uint32_t n_sp_priorities;
936 /** Parameters only valid for leaf nodes. */
938 /** Congestion management mode */
939 enum rte_tm_cman_mode cman;
941 /** WRED parameters (only valid when *cman* is set to
945 /** WRED profile for private WRED context. The
946 * absence of a private WRED context for the
947 * current leaf node is indicated by value
948 * RTE_TM_WRED_PROFILE_ID_NONE.
950 uint32_t wred_profile_id;
952 /** User allocated array of shared WRED context
953 * IDs. When set to NULL, it indicates that the
954 * current leaf node should not currently be
955 * part of any shared WRED contexts.
957 uint32_t *shared_wred_context_id;
959 /** Number of elements in the
960 * *shared_wred_context_id* array. Only valid
961 * when *shared_wred_context_id* is non-NULL,
962 * in which case it should be non-zero.
964 uint32_t n_shared_wred_contexts;
969 /** Mask of statistics counter types to be enabled for this node. This
970 * needs to be a subset of the statistics counter types available for
971 * the current node. Any statistics counter type not included in this
972 * set is to be disabled for the current node.
973 * @see enum rte_tm_stats_type
979 * Verbose error types.
981 * Most of them provide the type of the object referenced by struct
982 * rte_tm_error::cause.
984 enum rte_tm_error_type {
985 RTE_TM_ERROR_TYPE_NONE, /**< No error. */
986 RTE_TM_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
987 RTE_TM_ERROR_TYPE_CAPABILITIES,
988 RTE_TM_ERROR_TYPE_LEVEL_ID,
989 RTE_TM_ERROR_TYPE_WRED_PROFILE,
990 RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN,
991 RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW,
992 RTE_TM_ERROR_TYPE_WRED_PROFILE_RED,
993 RTE_TM_ERROR_TYPE_WRED_PROFILE_ID,
994 RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID,
995 RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
996 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE,
997 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE,
998 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
999 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
1000 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN,
1001 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
1002 RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID,
1003 RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID,
1004 RTE_TM_ERROR_TYPE_NODE_PRIORITY,
1005 RTE_TM_ERROR_TYPE_NODE_WEIGHT,
1006 RTE_TM_ERROR_TYPE_NODE_PARAMS,
1007 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID,
1008 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID,
1009 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS,
1010 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE,
1011 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES,
1012 RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN,
1013 RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID,
1014 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID,
1015 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS,
1016 RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
1017 RTE_TM_ERROR_TYPE_NODE_ID,
1021 * Verbose error structure definition.
1023 * This object is normally allocated by applications and set by PMDs, the
1024 * message points to a constant string which does not need to be freed by
1025 * the application, however its pointer can be considered valid only as long
1026 * as its associated DPDK port remains configured. Closing the underlying
1027 * device or unloading the PMD invalidates it.
1029 * Both cause and message may be NULL regardless of the error type.
1031 struct rte_tm_error {
1032 enum rte_tm_error_type type; /**< Cause field and error type. */
1033 const void *cause; /**< Object responsible for the error. */
1034 const char *message; /**< Human-readable error message. */
1038 * Traffic manager get number of leaf nodes
1040 * Each leaf node sits on on top of a TX queue of the current Ethernet port.
1041 * Therefore, the set of leaf nodes is predefined, their number is always equal
1042 * to N (where N is the number of TX queues configured for the current port)
1043 * and their IDs are 0 .. (N-1).
1045 * @param[in] port_id
1046 * The port identifier of the Ethernet device.
1047 * @param[out] n_leaf_nodes
1048 * Number of leaf nodes for the current port.
1050 * Error details. Filled in only on error, when not NULL.
1052 * 0 on success, non-zero error code otherwise.
1056 rte_tm_get_number_of_leaf_nodes(uint16_t port_id,
1057 uint32_t *n_leaf_nodes,
1058 struct rte_tm_error *error);
1061 * Traffic manager node ID validate and type (i.e. leaf or non-leaf) get
1063 * The leaf nodes have predefined IDs in the range of 0 .. (N-1), where N is
1064 * the number of TX queues of the current Ethernet port. The non-leaf nodes
1065 * have their IDs generated by the application outside of the above range,
1066 * which is reserved for leaf nodes.
1068 * @param[in] port_id
1069 * The port identifier of the Ethernet device.
1070 * @param[in] node_id
1071 * Node ID value. Needs to be valid.
1072 * @param[out] is_leaf
1073 * Set to non-zero value when node is leaf and to zero otherwise (non-leaf).
1075 * Error details. Filled in only on error, when not NULL.
1077 * 0 on success, non-zero error code otherwise.
1081 rte_tm_node_type_get(uint16_t port_id,
1084 struct rte_tm_error *error);
1087 * Traffic manager capabilities get
1089 * @param[in] port_id
1090 * The port identifier of the Ethernet device.
1092 * Traffic manager capabilities. Needs to be pre-allocated and valid.
1094 * Error details. Filled in only on error, when not NULL.
1096 * 0 on success, non-zero error code otherwise.
1100 rte_tm_capabilities_get(uint16_t port_id,
1101 struct rte_tm_capabilities *cap,
1102 struct rte_tm_error *error);
1105 * Traffic manager level capabilities get
1107 * @param[in] port_id
1108 * The port identifier of the Ethernet device.
1109 * @param[in] level_id
1110 * The hierarchy level identifier. The value of 0 identifies the level of the
1113 * Traffic manager level capabilities. Needs to be pre-allocated and valid.
1115 * Error details. Filled in only on error, when not NULL.
1117 * 0 on success, non-zero error code otherwise.
1121 rte_tm_level_capabilities_get(uint16_t port_id,
1123 struct rte_tm_level_capabilities *cap,
1124 struct rte_tm_error *error);
1127 * Traffic manager node capabilities get
1129 * @param[in] port_id
1130 * The port identifier of the Ethernet device.
1131 * @param[in] node_id
1132 * Node ID. Needs to be valid.
1134 * Traffic manager node capabilities. Needs to be pre-allocated and valid.
1136 * Error details. Filled in only on error, when not NULL.
1138 * 0 on success, non-zero error code otherwise.
1142 rte_tm_node_capabilities_get(uint16_t port_id,
1144 struct rte_tm_node_capabilities *cap,
1145 struct rte_tm_error *error);
1148 * Traffic manager WRED profile add
1150 * Create a new WRED profile with ID set to *wred_profile_id*. The new profile
1151 * is used to create one or several WRED contexts.
1153 * @param[in] port_id
1154 * The port identifier of the Ethernet device.
1155 * @param[in] wred_profile_id
1156 * WRED profile ID for the new profile. Needs to be unused.
1157 * @param[in] profile
1158 * WRED profile parameters. Needs to be pre-allocated and valid.
1160 * Error details. Filled in only on error, when not NULL.
1162 * 0 on success, non-zero error code otherwise.
1164 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1168 rte_tm_wred_profile_add(uint16_t port_id,
1169 uint32_t wred_profile_id,
1170 struct rte_tm_wred_params *profile,
1171 struct rte_tm_error *error);
1174 * Traffic manager WRED profile delete
1176 * Delete an existing WRED profile. This operation fails when there is
1177 * currently at least one user (i.e. WRED context) of this WRED profile.
1179 * @param[in] port_id
1180 * The port identifier of the Ethernet device.
1181 * @param[in] wred_profile_id
1182 * WRED profile ID. Needs to be the valid.
1184 * Error details. Filled in only on error, when not NULL.
1186 * 0 on success, non-zero error code otherwise.
1188 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1192 rte_tm_wred_profile_delete(uint16_t port_id,
1193 uint32_t wred_profile_id,
1194 struct rte_tm_error *error);
1197 * Traffic manager shared WRED context add or update
1199 * When *shared_wred_context_id* is invalid, a new WRED context with this ID is
1200 * created by using the WRED profile identified by *wred_profile_id*.
1202 * When *shared_wred_context_id* is valid, this WRED context is no longer using
1203 * the profile previously assigned to it and is updated to use the profile
1204 * identified by *wred_profile_id*.
1206 * A valid shared WRED context can be assigned to several hierarchy leaf nodes
1207 * configured to use WRED as the congestion management mode.
1209 * @param[in] port_id
1210 * The port identifier of the Ethernet device.
1211 * @param[in] shared_wred_context_id
1212 * Shared WRED context ID
1213 * @param[in] wred_profile_id
1214 * WRED profile ID. Needs to be the valid.
1216 * Error details. Filled in only on error, when not NULL.
1218 * 0 on success, non-zero error code otherwise.
1220 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1224 rte_tm_shared_wred_context_add_update(uint16_t port_id,
1225 uint32_t shared_wred_context_id,
1226 uint32_t wred_profile_id,
1227 struct rte_tm_error *error);
1230 * Traffic manager shared WRED context delete
1232 * Delete an existing shared WRED context. This operation fails when there is
1233 * currently at least one user (i.e. hierarchy leaf node) of this shared WRED
1236 * @param[in] port_id
1237 * The port identifier of the Ethernet device.
1238 * @param[in] shared_wred_context_id
1239 * Shared WRED context ID. Needs to be the valid.
1241 * Error details. Filled in only on error, when not NULL.
1243 * 0 on success, non-zero error code otherwise.
1245 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1249 rte_tm_shared_wred_context_delete(uint16_t port_id,
1250 uint32_t shared_wred_context_id,
1251 struct rte_tm_error *error);
1254 * Traffic manager shaper profile add
1256 * Create a new shaper profile with ID set to *shaper_profile_id*. The new
1257 * shaper profile is used to create one or several shapers.
1259 * @param[in] port_id
1260 * The port identifier of the Ethernet device.
1261 * @param[in] shaper_profile_id
1262 * Shaper profile ID for the new profile. Needs to be unused.
1263 * @param[in] profile
1264 * Shaper profile parameters. Needs to be pre-allocated and valid.
1266 * Error details. Filled in only on error, when not NULL.
1268 * 0 on success, non-zero error code otherwise.
1270 * @see struct rte_tm_capabilities::shaper_n_max
1274 rte_tm_shaper_profile_add(uint16_t port_id,
1275 uint32_t shaper_profile_id,
1276 struct rte_tm_shaper_params *profile,
1277 struct rte_tm_error *error);
1280 * Traffic manager shaper profile delete
1282 * Delete an existing shaper profile. This operation fails when there is
1283 * currently at least one user (i.e. shaper) of this shaper profile.
1285 * @param[in] port_id
1286 * The port identifier of the Ethernet device.
1287 * @param[in] shaper_profile_id
1288 * Shaper profile ID. Needs to be the valid.
1290 * Error details. Filled in only on error, when not NULL.
1292 * 0 on success, non-zero error code otherwise.
1294 * @see struct rte_tm_capabilities::shaper_n_max
1298 rte_tm_shaper_profile_delete(uint16_t port_id,
1299 uint32_t shaper_profile_id,
1300 struct rte_tm_error *error);
1303 * Traffic manager shared shaper add or update
1305 * When *shared_shaper_id* is not a valid shared shaper ID, a new shared shaper
1306 * with this ID is created using the shaper profile identified by
1307 * *shaper_profile_id*.
1309 * When *shared_shaper_id* is a valid shared shaper ID, this shared shaper is
1310 * no longer using the shaper profile previously assigned to it and is updated
1311 * to use the shaper profile identified by *shaper_profile_id*.
1313 * @param[in] port_id
1314 * The port identifier of the Ethernet device.
1315 * @param[in] shared_shaper_id
1317 * @param[in] shaper_profile_id
1318 * Shaper profile ID. Needs to be the valid.
1320 * Error details. Filled in only on error, when not NULL.
1322 * 0 on success, non-zero error code otherwise.
1324 * @see struct rte_tm_capabilities::shaper_shared_n_max
1328 rte_tm_shared_shaper_add_update(uint16_t port_id,
1329 uint32_t shared_shaper_id,
1330 uint32_t shaper_profile_id,
1331 struct rte_tm_error *error);
1334 * Traffic manager shared shaper delete
1336 * Delete an existing shared shaper. This operation fails when there is
1337 * currently at least one user (i.e. hierarchy node) of this shared shaper.
1339 * @param[in] port_id
1340 * The port identifier of the Ethernet device.
1341 * @param[in] shared_shaper_id
1342 * Shared shaper ID. Needs to be the valid.
1344 * Error details. Filled in only on error, when not NULL.
1346 * 0 on success, non-zero error code otherwise.
1348 * @see struct rte_tm_capabilities::shaper_shared_n_max
1352 rte_tm_shared_shaper_delete(uint16_t port_id,
1353 uint32_t shared_shaper_id,
1354 struct rte_tm_error *error);
1357 * Traffic manager node add
1359 * Create new node and connect it as child of an existing node. The new node is
1360 * further identified by *node_id*, which needs to be unused by any of the
1361 * existing nodes. The parent node is identified by *parent_node_id*, which
1362 * needs to be the valid ID of an existing non-leaf node. The parent node is
1363 * going to use the provided SP *priority* and WFQ *weight* to schedule its new
1366 * This function has to be called for both leaf and non-leaf nodes. In the case
1367 * of leaf nodes (i.e. *node_id* is within the range of 0 .. (N-1), with N as
1368 * the number of configured TX queues of the current port), the leaf node is
1369 * configured rather than created (as the set of leaf nodes is predefined) and
1370 * it is also connected as child of an existing node.
1372 * The first node that is added becomes the root node and all the nodes that
1373 * are subsequently added have to be added as descendants of the root node. The
1374 * parent of the root node has to be specified as RTE_TM_NODE_ID_NULL and there
1375 * can only be one node with this parent ID (i.e. the root node). Further
1376 * restrictions for root node: needs to be non-leaf, its private shaper profile
1377 * needs to be valid and single rate, cannot use any shared shapers.
1379 * When called before rte_tm_hierarchy_commit() invocation, this function is
1380 * typically used to define the initial start-up hierarchy for the port.
1381 * Provided that dynamic hierarchy updates are supported by the current port (as
1382 * advertised in the port capability set), this function can be also called
1383 * after the rte_tm_hierarchy_commit() invocation.
1385 * @param[in] port_id
1386 * The port identifier of the Ethernet device.
1387 * @param[in] node_id
1388 * Node ID. Needs to be unused by any of the existing nodes.
1389 * @param[in] parent_node_id
1390 * Parent node ID. Needs to be the valid.
1391 * @param[in] priority
1392 * Node priority. The highest node priority is zero. Used by the SP algorithm
1393 * running on the parent of the current node for scheduling this child node.
1395 * Node weight. The node weight is relative to the weight sum of all siblings
1396 * that have the same priority. The lowest weight is one. Used by the WFQ
1397 * algorithm running on the parent of the current node for scheduling this
1399 * @param[in] level_id
1400 * Level ID that should be met by this node. The hierarchy level of the
1401 * current node is already fully specified through its parent node (i.e. the
1402 * level of this node is equal to the level of its parent node plus one),
1403 * therefore the reason for providing this parameter is to enable the
1404 * application to perform step-by-step checking of the node level during
1405 * successive invocations of this function. When not desired, this check can
1406 * be disabled by assigning value RTE_TM_NODE_LEVEL_ID_ANY to this parameter.
1408 * Node parameters. Needs to be pre-allocated and valid.
1410 * Error details. Filled in only on error, when not NULL.
1412 * 0 on success, non-zero error code otherwise.
1414 * @see rte_tm_hierarchy_commit()
1415 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1416 * @see RTE_TM_NODE_LEVEL_ID_ANY
1417 * @see struct rte_tm_capabilities
1421 rte_tm_node_add(uint16_t port_id,
1423 uint32_t parent_node_id,
1427 struct rte_tm_node_params *params,
1428 struct rte_tm_error *error);
1431 * Traffic manager node delete
1433 * Delete an existing node. This operation fails when this node currently has
1434 * at least one user (i.e. child node).
1436 * When called before rte_tm_hierarchy_commit() invocation, this function is
1437 * typically used to define the initial start-up hierarchy for the port.
1438 * Provided that dynamic hierarchy updates are supported by the current port (as
1439 * advertised in the port capability set), this function can be also called
1440 * after the rte_tm_hierarchy_commit() invocation.
1442 * @param[in] port_id
1443 * The port identifier of the Ethernet device.
1444 * @param[in] node_id
1445 * Node ID. Needs to be valid.
1447 * Error details. Filled in only on error, when not NULL.
1449 * 0 on success, non-zero error code otherwise.
1451 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1455 rte_tm_node_delete(uint16_t port_id,
1457 struct rte_tm_error *error);
1460 * Traffic manager node suspend
1462 * Suspend an existing node. While the node is in suspended state, no packet is
1463 * scheduled from this node and its descendants. The node exits the suspended
1464 * state through the node resume operation.
1466 * @param[in] port_id
1467 * The port identifier of the Ethernet device.
1468 * @param[in] node_id
1469 * Node ID. Needs to be valid.
1471 * Error details. Filled in only on error, when not NULL.
1473 * 0 on success, non-zero error code otherwise.
1475 * @see rte_tm_node_resume()
1476 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1480 rte_tm_node_suspend(uint16_t port_id,
1482 struct rte_tm_error *error);
1485 * Traffic manager node resume
1487 * Resume an existing node that is currently in suspended state. The node
1488 * entered the suspended state as result of a previous node suspend operation.
1490 * @param[in] port_id
1491 * The port identifier of the Ethernet device.
1492 * @param[in] node_id
1493 * Node ID. Needs to be valid.
1495 * Error details. Filled in only on error, when not NULL.
1497 * 0 on success, non-zero error code otherwise.
1499 * @see rte_tm_node_suspend()
1500 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1504 rte_tm_node_resume(uint16_t port_id,
1506 struct rte_tm_error *error);
1509 * Traffic manager hierarchy commit
1511 * This function is called during the port initialization phase (before the
1512 * Ethernet port is started) to freeze the start-up hierarchy.
1514 * This function typically performs the following steps:
1515 * a) It validates the start-up hierarchy that was previously defined for the
1516 * current port through successive rte_tm_node_add() invocations;
1517 * b) Assuming successful validation, it performs all the necessary port
1518 * specific configuration operations to install the specified hierarchy on
1519 * the current port, with immediate effect once the port is started.
1521 * This function fails when the currently configured hierarchy is not supported
1522 * by the Ethernet port, in which case the user can abort or try out another
1523 * hierarchy configuration (e.g. a hierarchy with less leaf nodes), which can be
1524 * build from scratch (when *clear_on_fail* is enabled) or by modifying the
1525 * existing hierarchy configuration (when *clear_on_fail* is disabled).
1527 * Note that this function can still fail due to other causes (e.g. not enough
1528 * memory available in the system, etc), even though the specified hierarchy is
1529 * supported in principle by the current port.
1531 * @param[in] port_id
1532 * The port identifier of the Ethernet device.
1533 * @param[in] clear_on_fail
1534 * On function call failure, hierarchy is cleared when this parameter is
1535 * non-zero and preserved when this parameter is equal to zero.
1537 * Error details. Filled in only on error, when not NULL.
1539 * 0 on success, non-zero error code otherwise.
1541 * @see rte_tm_node_add()
1542 * @see rte_tm_node_delete()
1546 rte_tm_hierarchy_commit(uint16_t port_id,
1548 struct rte_tm_error *error);
1551 * Traffic manager node parent update
1553 * This function may be used to move a node and its children to a different
1554 * parent. Additionally, if the new parent is the same as the current parent,
1555 * this function will update the priority/weight of an existing node.
1557 * Restriction for root node: its parent cannot be changed.
1559 * This function can only be called after the rte_tm_hierarchy_commit()
1560 * invocation. Its success depends on the port support for this operation, as
1561 * advertised through the port capability set.
1563 * @param[in] port_id
1564 * The port identifier of the Ethernet device.
1565 * @param[in] node_id
1566 * Node ID. Needs to be valid.
1567 * @param[in] parent_node_id
1568 * Node ID for the new parent. Needs to be valid.
1569 * @param[in] priority
1570 * Node priority. The highest node priority is zero. Used by the SP algorithm
1571 * running on the parent of the current node for scheduling this child node.
1573 * Node weight. The node weight is relative to the weight sum of all siblings
1574 * that have the same priority. The lowest weight is zero. Used by the WFQ
1575 * algorithm running on the parent of the current node for scheduling this
1578 * Error details. Filled in only on error, when not NULL.
1580 * 0 on success, non-zero error code otherwise.
1582 * @see RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL
1583 * @see RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL
1587 rte_tm_node_parent_update(uint16_t port_id,
1589 uint32_t parent_node_id,
1592 struct rte_tm_error *error);
1595 * Traffic manager node private shaper update
1597 * Restriction for the root node: its private shaper profile needs to be valid
1600 * @param[in] port_id
1601 * The port identifier of the Ethernet device.
1602 * @param[in] node_id
1603 * Node ID. Needs to be valid.
1604 * @param[in] shaper_profile_id
1605 * Shaper profile ID for the private shaper of the current node. Needs to be
1606 * either valid shaper profile ID or RTE_TM_SHAPER_PROFILE_ID_NONE, with
1607 * the latter disabling the private shaper of the current node.
1609 * Error details. Filled in only on error, when not NULL.
1611 * 0 on success, non-zero error code otherwise.
1613 * @see struct rte_tm_capabilities::shaper_private_n_max
1617 rte_tm_node_shaper_update(uint16_t port_id,
1619 uint32_t shaper_profile_id,
1620 struct rte_tm_error *error);
1623 * Traffic manager node shared shapers update
1625 * Restriction for root node: cannot use any shared rate shapers.
1627 * @param[in] port_id
1628 * The port identifier of the Ethernet device.
1629 * @param[in] node_id
1630 * Node ID. Needs to be valid.
1631 * @param[in] shared_shaper_id
1632 * Shared shaper ID. Needs to be valid.
1634 * Set to non-zero value to add this shared shaper to current node or to zero
1635 * to delete this shared shaper from current node.
1637 * Error details. Filled in only on error, when not NULL.
1639 * 0 on success, non-zero error code otherwise.
1641 * @see struct rte_tm_capabilities::shaper_shared_n_max
1645 rte_tm_node_shared_shaper_update(uint16_t port_id,
1647 uint32_t shared_shaper_id,
1649 struct rte_tm_error *error);
1652 * Traffic manager node enabled statistics counters update
1654 * @param[in] port_id
1655 * The port identifier of the Ethernet device.
1656 * @param[in] node_id
1657 * Node ID. Needs to be valid.
1658 * @param[in] stats_mask
1659 * Mask of statistics counter types to be enabled for the current node. This
1660 * needs to be a subset of the statistics counter types available for the
1661 * current node. Any statistics counter type not included in this set is to
1662 * be disabled for the current node.
1664 * Error details. Filled in only on error, when not NULL.
1666 * 0 on success, non-zero error code otherwise.
1668 * @see enum rte_tm_stats_type
1669 * @see RTE_TM_UPDATE_NODE_STATS
1673 rte_tm_node_stats_update(uint16_t port_id,
1675 uint64_t stats_mask,
1676 struct rte_tm_error *error);
1679 * Traffic manager node WFQ weight mode update
1681 * @param[in] port_id
1682 * The port identifier of the Ethernet device.
1683 * @param[in] node_id
1684 * Node ID. Needs to be valid non-leaf node ID.
1685 * @param[in] wfq_weight_mode
1686 * WFQ weight mode for each SP priority. When NULL, it indicates that WFQ is
1687 * to be used for all priorities. When non-NULL, it points to a pre-allocated
1688 * array of *n_sp_priorities* values, with non-zero value for byte-mode and
1689 * zero for packet-mode.
1690 * @param[in] n_sp_priorities
1691 * Number of SP priorities.
1693 * Error details. Filled in only on error, when not NULL.
1695 * 0 on success, non-zero error code otherwise.
1697 * @see RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE
1698 * @see RTE_TM_UPDATE_NODE_N_SP_PRIORITIES
1702 rte_tm_node_wfq_weight_mode_update(uint16_t port_id,
1704 int *wfq_weight_mode,
1705 uint32_t n_sp_priorities,
1706 struct rte_tm_error *error);
1709 * Traffic manager node congestion management mode update
1711 * @param[in] port_id
1712 * The port identifier of the Ethernet device.
1713 * @param[in] node_id
1714 * Node ID. Needs to be valid leaf node ID.
1716 * Congestion management mode.
1718 * Error details. Filled in only on error, when not NULL.
1720 * 0 on success, non-zero error code otherwise.
1722 * @see RTE_TM_UPDATE_NODE_CMAN
1726 rte_tm_node_cman_update(uint16_t port_id,
1728 enum rte_tm_cman_mode cman,
1729 struct rte_tm_error *error);
1732 * Traffic manager node private WRED context update
1734 * @param[in] port_id
1735 * The port identifier of the Ethernet device.
1736 * @param[in] node_id
1737 * Node ID. Needs to be valid leaf node ID.
1738 * @param[in] wred_profile_id
1739 * WRED profile ID for the private WRED context of the current node. Needs to
1740 * be either valid WRED profile ID or RTE_TM_WRED_PROFILE_ID_NONE, with the
1741 * latter disabling the private WRED context of the current node.
1743 * Error details. Filled in only on error, when not NULL.
1745 * 0 on success, non-zero error code otherwise.
1747 * @see struct rte_tm_capabilities::cman_wred_context_private_n_max
1751 rte_tm_node_wred_context_update(uint16_t port_id,
1753 uint32_t wred_profile_id,
1754 struct rte_tm_error *error);
1757 * Traffic manager node shared WRED context update
1759 * @param[in] port_id
1760 * The port identifier of the Ethernet device.
1761 * @param[in] node_id
1762 * Node ID. Needs to be valid leaf node ID.
1763 * @param[in] shared_wred_context_id
1764 * Shared WRED context ID. Needs to be valid.
1766 * Set to non-zero value to add this shared WRED context to current node or
1767 * to zero to delete this shared WRED context from current node.
1769 * Error details. Filled in only on error, when not NULL.
1771 * 0 on success, non-zero error code otherwise.
1773 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1777 rte_tm_node_shared_wred_context_update(uint16_t port_id,
1779 uint32_t shared_wred_context_id,
1781 struct rte_tm_error *error);
1784 * Traffic manager node statistics counters read
1786 * @param[in] port_id
1787 * The port identifier of the Ethernet device.
1788 * @param[in] node_id
1789 * Node ID. Needs to be valid.
1791 * When non-NULL, it contains the current value for the statistics counters
1792 * enabled for the current node.
1793 * @param[out] stats_mask
1794 * When non-NULL, it contains the mask of statistics counter types that are
1795 * currently enabled for this node, indicating which of the counters
1796 * retrieved with the *stats* structure are valid.
1798 * When this parameter has a non-zero value, the statistics counters are
1799 * cleared (i.e. set to zero) immediately after they have been read,
1800 * otherwise the statistics counters are left untouched.
1802 * Error details. Filled in only on error, when not NULL.
1804 * 0 on success, non-zero error code otherwise.
1806 * @see enum rte_tm_stats_type
1810 rte_tm_node_stats_read(uint16_t port_id,
1812 struct rte_tm_node_stats *stats,
1813 uint64_t *stats_mask,
1815 struct rte_tm_error *error);
1818 * Traffic manager packet marking - VLAN DEI (IEEE 802.1Q)
1820 * IEEE 802.1p maps the traffic class to the VLAN Priority Code Point (PCP)
1821 * field (3 bits), while IEEE 802.1q maps the drop priority to the VLAN Drop
1822 * Eligible Indicator (DEI) field (1 bit), which was previously named Canonical
1823 * Format Indicator (CFI).
1825 * All VLAN frames of a given color get their DEI bit set if marking is enabled
1826 * for this color; otherwise, their DEI bit is left as is (either set or not).
1828 * @param[in] port_id
1829 * The port identifier of the Ethernet device.
1830 * @param[in] mark_green
1831 * Set to non-zero value to enable marking of green packets and to zero to
1833 * @param[in] mark_yellow
1834 * Set to non-zero value to enable marking of yellow packets and to zero to
1836 * @param[in] mark_red
1837 * Set to non-zero value to enable marking of red packets and to zero to
1840 * Error details. Filled in only on error, when not NULL.
1842 * 0 on success, non-zero error code otherwise.
1844 * @see struct rte_tm_capabilities::mark_vlan_dei_supported
1848 rte_tm_mark_vlan_dei(uint16_t port_id,
1852 struct rte_tm_error *error);
1855 * Traffic manager packet marking - IPv4 / IPv6 ECN (IETF RFC 3168)
1857 * IETF RFCs 2474 and 3168 reorganize the IPv4 Type of Service (TOS) field
1858 * (8 bits) and the IPv6 Traffic Class (TC) field (8 bits) into Differentiated
1859 * Services Codepoint (DSCP) field (6 bits) and Explicit Congestion
1860 * Notification (ECN) field (2 bits). The DSCP field is typically used to
1861 * encode the traffic class and/or drop priority (RFC 2597), while the ECN
1862 * field is used by RFC 3168 to implement a congestion notification mechanism
1863 * to be leveraged by transport layer protocols such as TCP and SCTP that have
1864 * congestion control mechanisms.
1866 * When congestion is experienced, as alternative to dropping the packet,
1867 * routers can change the ECN field of input packets from 2'b01 or 2'b10
1868 * (values indicating that source endpoint is ECN-capable) to 2'b11 (meaning
1869 * that congestion is experienced). The destination endpoint can use the
1870 * ECN-Echo (ECE) TCP flag to relay the congestion indication back to the
1871 * source endpoint, which acknowledges it back to the destination endpoint with
1872 * the Congestion Window Reduced (CWR) TCP flag.
1874 * All IPv4/IPv6 packets of a given color with ECN set to 2’b01 or 2’b10
1875 * carrying TCP or SCTP have their ECN set to 2’b11 if the marking feature is
1876 * enabled for the current color, otherwise the ECN field is left as is.
1878 * @param[in] port_id
1879 * The port identifier of the Ethernet device.
1880 * @param[in] mark_green
1881 * Set to non-zero value to enable marking of green packets and to zero to
1883 * @param[in] mark_yellow
1884 * Set to non-zero value to enable marking of yellow packets and to zero to
1886 * @param[in] mark_red
1887 * Set to non-zero value to enable marking of red packets and to zero to
1890 * Error details. Filled in only on error, when not NULL.
1892 * 0 on success, non-zero error code otherwise.
1894 * @see struct rte_tm_capabilities::mark_ip_ecn_tcp_supported
1895 * @see struct rte_tm_capabilities::mark_ip_ecn_sctp_supported
1899 rte_tm_mark_ip_ecn(uint16_t port_id,
1903 struct rte_tm_error *error);
1906 * Traffic manager packet marking - IPv4 / IPv6 DSCP (IETF RFC 2597)
1908 * IETF RFC 2597 maps the traffic class and the drop priority to the IPv4/IPv6
1909 * Differentiated Services Codepoint (DSCP) field (6 bits). Here are the DSCP
1910 * values proposed by this RFC:
1912 * <pre> Class 1 Class 2 Class 3 Class 4 </pre>
1913 * <pre> +----------+----------+----------+----------+</pre>
1914 * <pre>Low Drop Prec | 001010 | 010010 | 011010 | 100010 |</pre>
1915 * <pre>Medium Drop Prec | 001100 | 010100 | 011100 | 100100 |</pre>
1916 * <pre>High Drop Prec | 001110 | 010110 | 011110 | 100110 |</pre>
1917 * <pre> +----------+----------+----------+----------+</pre>
1919 * There are 4 traffic classes (classes 1 .. 4) encoded by DSCP bits 1 and 2,
1920 * as well as 3 drop priorities (low/medium/high) encoded by DSCP bits 3 and 4.
1922 * All IPv4/IPv6 packets have their color marked into DSCP bits 3 and 4 as
1923 * follows: green mapped to Low Drop Precedence (2’b01), yellow to Medium
1924 * (2’b10) and red to High (2’b11). Marking needs to be explicitly enabled
1925 * for each color; when not enabled for a given color, the DSCP field of all
1926 * packets with that color is left as is.
1928 * @param[in] port_id
1929 * The port identifier of the Ethernet device.
1930 * @param[in] mark_green
1931 * Set to non-zero value to enable marking of green packets and to zero to
1933 * @param[in] mark_yellow
1934 * Set to non-zero value to enable marking of yellow packets and to zero to
1936 * @param[in] mark_red
1937 * Set to non-zero value to enable marking of red packets and to zero to
1940 * Error details. Filled in only on error, when not NULL.
1942 * 0 on success, non-zero error code otherwise.
1944 * @see struct rte_tm_capabilities::mark_ip_dscp_supported
1948 rte_tm_mark_ip_dscp(uint16_t port_id,
1952 struct rte_tm_error *error);
1958 #endif /* __INCLUDE_RTE_TM_H__ */