4 * Copyright(c) 2017 Intel Corporation.
5 * Copyright(c) 2017 Cavium.
6 * Copyright(c) 2017 NXP.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
19 * * Neither the name of Intel Corporation nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #ifndef __INCLUDE_RTE_TM_H__
37 #define __INCLUDE_RTE_TM_H__
41 * RTE Generic Traffic Manager API
43 * This interface provides the ability to configure the traffic manager in a
44 * generic way. It includes features such as: hierarchical scheduling,
45 * traffic shaping, congestion management, packet marking, etc.
48 * @b EXPERIMENTAL: this API may change without prior notice
53 #include <rte_common.h>
60 * Ethernet framing overhead.
62 * Overhead fields per Ethernet frame:
63 * 1. Preamble: 7 bytes;
64 * 2. Start of Frame Delimiter (SFD): 1 byte;
65 * 3. Inter-Frame Gap (IFG): 12 bytes.
67 * One of the typical values for the *pkt_length_adjust* field of the shaper
70 * @see struct rte_tm_shaper_params
72 #define RTE_TM_ETH_FRAMING_OVERHEAD 20
75 * Ethernet framing overhead including the Frame Check Sequence (FCS) field.
76 * Useful when FCS is generated and added at the end of the Ethernet frame on
77 * TX side without any SW intervention.
79 * One of the typical values for the pkt_length_adjust field of the shaper
82 * @see struct rte_tm_shaper_params
84 #define RTE_TM_ETH_FRAMING_OVERHEAD_FCS 24
87 * Invalid WRED profile ID.
89 * @see struct rte_tm_node_params
90 * @see rte_tm_node_add()
91 * @see rte_tm_node_wred_context_update()
93 #define RTE_TM_WRED_PROFILE_ID_NONE UINT32_MAX
96 *Invalid shaper profile ID.
98 * @see struct rte_tm_node_params
99 * @see rte_tm_node_add()
100 * @see rte_tm_node_shaper_update()
102 #define RTE_TM_SHAPER_PROFILE_ID_NONE UINT32_MAX
105 * Node ID for the parent of the root node.
107 * @see rte_tm_node_add()
109 #define RTE_TM_NODE_ID_NULL UINT32_MAX
112 * Node level ID used to disable level ID checking.
114 * @see rte_tm_node_add()
116 #define RTE_TM_NODE_LEVEL_ID_ANY UINT32_MAX
122 RTE_TM_GREEN = 0, /**< Green */
123 RTE_TM_YELLOW, /**< Yellow */
124 RTE_TM_RED, /**< Red */
125 RTE_TM_COLORS /**< Number of colors */
129 * Node statistics counter type
131 enum rte_tm_stats_type {
132 /** Number of packets scheduled from current node. */
133 RTE_TM_STATS_N_PKTS = 1 << 0,
135 /** Number of bytes scheduled from current node. */
136 RTE_TM_STATS_N_BYTES = 1 << 1,
138 /** Number of green packets dropped by current leaf node. */
139 RTE_TM_STATS_N_PKTS_GREEN_DROPPED = 1 << 2,
141 /** Number of yellow packets dropped by current leaf node. */
142 RTE_TM_STATS_N_PKTS_YELLOW_DROPPED = 1 << 3,
144 /** Number of red packets dropped by current leaf node. */
145 RTE_TM_STATS_N_PKTS_RED_DROPPED = 1 << 4,
147 /** Number of green bytes dropped by current leaf node. */
148 RTE_TM_STATS_N_BYTES_GREEN_DROPPED = 1 << 5,
150 /** Number of yellow bytes dropped by current leaf node. */
151 RTE_TM_STATS_N_BYTES_YELLOW_DROPPED = 1 << 6,
153 /** Number of red bytes dropped by current leaf node. */
154 RTE_TM_STATS_N_BYTES_RED_DROPPED = 1 << 7,
156 /** Number of packets currently waiting in the packet queue of current
159 RTE_TM_STATS_N_PKTS_QUEUED = 1 << 8,
161 /** Number of bytes currently waiting in the packet queue of current
164 RTE_TM_STATS_N_BYTES_QUEUED = 1 << 9,
168 * Node statistics counters
170 struct rte_tm_node_stats {
171 /** Number of packets scheduled from current node. */
174 /** Number of bytes scheduled from current node. */
177 /** Statistics counters for leaf nodes only. */
179 /** Number of packets dropped by current leaf node per each
182 uint64_t n_pkts_dropped[RTE_TM_COLORS];
184 /** Number of bytes dropped by current leaf node per each
187 uint64_t n_bytes_dropped[RTE_TM_COLORS];
189 /** Number of packets currently waiting in the packet queue of
192 uint64_t n_pkts_queued;
194 /** Number of bytes currently waiting in the packet queue of
197 uint64_t n_bytes_queued;
202 * Traffic manager dynamic updates
204 enum rte_tm_dynamic_update_type {
205 /** Dynamic parent node update. The new parent node is located on same
206 * hierarchy level as the former parent node. Consequently, the node
207 * whose parent is changed preserves its hierarchy level.
209 RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL = 1 << 0,
211 /** Dynamic parent node update. The new parent node is located on
212 * different hierarchy level than the former parent node. Consequently,
213 * the node whose parent is changed also changes its hierarchy level.
215 RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL = 1 << 1,
217 /** Dynamic node add/delete. */
218 RTE_TM_UPDATE_NODE_ADD_DELETE = 1 << 2,
220 /** Suspend/resume nodes. */
221 RTE_TM_UPDATE_NODE_SUSPEND_RESUME = 1 << 3,
223 /** Dynamic switch between byte-based and packet-based WFQ weights. */
224 RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE = 1 << 4,
226 /** Dynamic update on number of SP priorities. */
227 RTE_TM_UPDATE_NODE_N_SP_PRIORITIES = 1 << 5,
229 /** Dynamic update of congestion management mode for leaf nodes. */
230 RTE_TM_UPDATE_NODE_CMAN = 1 << 6,
232 /** Dynamic update of the set of enabled stats counter types. */
233 RTE_TM_UPDATE_NODE_STATS = 1 << 7,
237 * Traffic manager capabilities
239 struct rte_tm_capabilities {
240 /** Maximum number of nodes. */
241 uint32_t n_nodes_max;
243 /** Maximum number of levels (i.e. number of nodes connecting the root
244 * node with any leaf node, including the root and the leaf).
246 uint32_t n_levels_max;
248 /** When non-zero, this flag indicates that all the non-leaf nodes
249 * (with the exception of the root node) have identical capability set.
251 int non_leaf_nodes_identical;
253 /** When non-zero, this flag indicates that all the leaf nodes have
254 * identical capability set.
256 int leaf_nodes_identical;
258 /** Maximum number of shapers, either private or shared. In case the
259 * implementation does not share any resources between private and
260 * shared shapers, it is typically equal to the sum of
261 * *shaper_private_n_max* and *shaper_shared_n_max*. The
262 * value of zero indicates that traffic shaping is not supported.
264 uint32_t shaper_n_max;
266 /** Maximum number of private shapers. Indicates the maximum number of
267 * nodes that can concurrently have their private shaper enabled. The
268 * value of zero indicates that private shapers are not supported.
270 uint32_t shaper_private_n_max;
272 /** Maximum number of private shapers that support dual rate shaping.
273 * Indicates the maximum number of nodes that can concurrently have
274 * their private shaper enabled with dual rate support. Only valid when
275 * private shapers are supported. The value of zero indicates that dual
276 * rate shaping is not available for private shapers. The maximum value
277 * is *shaper_private_n_max*.
279 int shaper_private_dual_rate_n_max;
281 /** Minimum committed/peak rate (bytes per second) for any private
282 * shaper. Valid only when private shapers are supported.
284 uint64_t shaper_private_rate_min;
286 /** Maximum committed/peak rate (bytes per second) for any private
287 * shaper. Valid only when private shapers are supported.
289 uint64_t shaper_private_rate_max;
291 /** Maximum number of shared shapers. The value of zero indicates that
292 * shared shapers are not supported.
294 uint32_t shaper_shared_n_max;
296 /** Maximum number of nodes that can share the same shared shaper.
297 * Only valid when shared shapers are supported.
299 uint32_t shaper_shared_n_nodes_per_shaper_max;
301 /** Maximum number of shared shapers a node can be part of. This
302 * parameter indicates that there is at least one node that can be
303 * configured with this many shared shapers, which might not be true for
304 * all the nodes. Only valid when shared shapers are supported, in which
305 * case it ranges from 1 to *shaper_shared_n_max*.
307 uint32_t shaper_shared_n_shapers_per_node_max;
309 /** Maximum number of shared shapers that can be configured with dual
310 * rate shaping. The value of zero indicates that dual rate shaping
311 * support is not available for shared shapers.
313 uint32_t shaper_shared_dual_rate_n_max;
315 /** Minimum committed/peak rate (bytes per second) for any shared
316 * shaper. Only valid when shared shapers are supported.
318 uint64_t shaper_shared_rate_min;
320 /** Maximum committed/peak rate (bytes per second) for any shared
321 * shaper. Only valid when shared shapers are supported.
323 uint64_t shaper_shared_rate_max;
325 /** Minimum value allowed for packet length adjustment for any private
328 int shaper_pkt_length_adjust_min;
330 /** Maximum value allowed for packet length adjustment for any private
333 int shaper_pkt_length_adjust_max;
335 /** Maximum number of children nodes. This parameter indicates that
336 * there is at least one non-leaf node that can be configured with this
337 * many children nodes, which might not be true for all the non-leaf
340 uint32_t sched_n_children_max;
342 /** Maximum number of supported priority levels. This parameter
343 * indicates that there is at least one non-leaf node that can be
344 * configured with this many priority levels for managing its children
345 * nodes, which might not be true for all the non-leaf nodes. The value
346 * of zero is invalid. The value of 1 indicates that only priority 0 is
347 * supported, which essentially means that Strict Priority (SP)
348 * algorithm is not supported.
350 uint32_t sched_sp_n_priorities_max;
352 /** Maximum number of sibling nodes that can have the same priority at
353 * any given time, i.e. maximum size of the WFQ sibling node group. This
354 * parameter indicates there is at least one non-leaf node that meets
355 * this condition, which might not be true for all the non-leaf nodes.
356 * The value of zero is invalid. The value of 1 indicates that WFQ
357 * algorithm is not supported. The maximum value is
358 * *sched_n_children_max*.
360 uint32_t sched_wfq_n_children_per_group_max;
362 /** Maximum number of priority levels that can have more than one child
363 * node at any given time, i.e. maximum number of WFQ sibling node
364 * groups that have two or more members. This parameter indicates there
365 * is at least one non-leaf node that meets this condition, which might
366 * not be true for all the non-leaf nodes. The value of zero states that
367 * WFQ algorithm is not supported. The value of 1 indicates that
368 * (*sched_sp_n_priorities_max* - 1) priority levels have at most one
369 * child node, so there can be only one priority level with two or
370 * more sibling nodes making up a WFQ group. The maximum value is:
371 * min(floor(*sched_n_children_max* / 2), *sched_sp_n_priorities_max*).
373 uint32_t sched_wfq_n_groups_max;
375 /** Maximum WFQ weight. The value of 1 indicates that all sibling nodes
376 * with same priority have the same WFQ weight, so WFQ is reduced to FQ.
378 uint32_t sched_wfq_weight_max;
380 /** Head drop algorithm support. When non-zero, this parameter
381 * indicates that there is at least one leaf node that supports the head
382 * drop algorithm, which might not be true for all the leaf nodes.
384 int cman_head_drop_supported;
386 /** Maximum number of WRED contexts, either private or shared. In case
387 * the implementation does not share any resources between private and
388 * shared WRED contexts, it is typically equal to the sum of
389 * *cman_wred_context_private_n_max* and
390 * *cman_wred_context_shared_n_max*. The value of zero indicates that
391 * WRED is not supported.
393 uint32_t cman_wred_context_n_max;
395 /** Maximum number of private WRED contexts. Indicates the maximum
396 * number of leaf nodes that can concurrently have their private WRED
397 * context enabled. The value of zero indicates that private WRED
398 * contexts are not supported.
400 uint32_t cman_wred_context_private_n_max;
402 /** Maximum number of shared WRED contexts. The value of zero
403 * indicates that shared WRED contexts are not supported.
405 uint32_t cman_wred_context_shared_n_max;
407 /** Maximum number of leaf nodes that can share the same WRED context.
408 * Only valid when shared WRED contexts are supported.
410 uint32_t cman_wred_context_shared_n_nodes_per_context_max;
412 /** Maximum number of shared WRED contexts a leaf node can be part of.
413 * This parameter indicates that there is at least one leaf node that
414 * can be configured with this many shared WRED contexts, which might
415 * not be true for all the leaf nodes. Only valid when shared WRED
416 * contexts are supported, in which case it ranges from 1 to
417 * *cman_wred_context_shared_n_max*.
419 uint32_t cman_wred_context_shared_n_contexts_per_node_max;
421 /** Support for VLAN DEI packet marking (per color). */
422 int mark_vlan_dei_supported[RTE_TM_COLORS];
424 /** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */
425 int mark_ip_ecn_tcp_supported[RTE_TM_COLORS];
427 /** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */
428 int mark_ip_ecn_sctp_supported[RTE_TM_COLORS];
430 /** Support for IPv4/IPv6 DSCP packet marking (per color). */
431 int mark_ip_dscp_supported[RTE_TM_COLORS];
433 /** Set of supported dynamic update operations.
434 * @see enum rte_tm_dynamic_update_type
436 uint64_t dynamic_update_mask;
438 /** Set of supported statistics counter types.
439 * @see enum rte_tm_stats_type
445 * Traffic manager level capabilities
447 struct rte_tm_level_capabilities {
448 /** Maximum number of nodes for the current hierarchy level. */
449 uint32_t n_nodes_max;
451 /** Maximum number of non-leaf nodes for the current hierarchy level.
452 * The value of 0 indicates that current level only supports leaf
453 * nodes. The maximum value is *n_nodes_max*.
455 uint32_t n_nodes_nonleaf_max;
457 /** Maximum number of leaf nodes for the current hierarchy level. The
458 * value of 0 indicates that current level only supports non-leaf
459 * nodes. The maximum value is *n_nodes_max*.
461 uint32_t n_nodes_leaf_max;
463 /** When non-zero, this flag indicates that all the non-leaf nodes on
464 * this level have identical capability set. Valid only when
465 * *n_nodes_nonleaf_max* is non-zero.
467 int non_leaf_nodes_identical;
469 /** When non-zero, this flag indicates that all the leaf nodes on this
470 * level have identical capability set. Valid only when
471 * *n_nodes_leaf_max* is non-zero.
473 int leaf_nodes_identical;
477 /** Items valid only for the non-leaf nodes on this level. */
479 /** Private shaper support. When non-zero, it indicates
480 * there is at least one non-leaf node on this level
481 * with private shaper support, which may not be the
482 * case for all the non-leaf nodes on this level.
484 int shaper_private_supported;
486 /** Dual rate support for private shaper. Valid only
487 * when private shaper is supported for the non-leaf
488 * nodes on the current level. When non-zero, it
489 * indicates there is at least one non-leaf node on this
490 * level with dual rate private shaper support, which
491 * may not be the case for all the non-leaf nodes on
494 int shaper_private_dual_rate_supported;
496 /** Minimum committed/peak rate (bytes per second) for
497 * private shapers of the non-leaf nodes of this level.
498 * Valid only when private shaper is supported on this
501 uint64_t shaper_private_rate_min;
503 /** Maximum committed/peak rate (bytes per second) for
504 * private shapers of the non-leaf nodes on this level.
505 * Valid only when private shaper is supported on this
508 uint64_t shaper_private_rate_max;
510 /** Maximum number of shared shapers that any non-leaf
511 * node on this level can be part of. The value of zero
512 * indicates that shared shapers are not supported by
513 * the non-leaf nodes on this level. When non-zero, it
514 * indicates there is at least one non-leaf node on this
515 * level that meets this condition, which may not be the
516 * case for all the non-leaf nodes on this level.
518 uint32_t shaper_shared_n_max;
520 /** Maximum number of children nodes. This parameter
521 * indicates that there is at least one non-leaf node on
522 * this level that can be configured with this many
523 * children nodes, which might not be true for all the
524 * non-leaf nodes on this level.
526 uint32_t sched_n_children_max;
528 /** Maximum number of supported priority levels. This
529 * parameter indicates that there is at least one
530 * non-leaf node on this level that can be configured
531 * with this many priority levels for managing its
532 * children nodes, which might not be true for all the
533 * non-leaf nodes on this level. The value of zero is
534 * invalid. The value of 1 indicates that only priority
535 * 0 is supported, which essentially means that Strict
536 * Priority (SP) algorithm is not supported on this
539 uint32_t sched_sp_n_priorities_max;
541 /** Maximum number of sibling nodes that can have the
542 * same priority at any given time, i.e. maximum size of
543 * the WFQ sibling node group. This parameter indicates
544 * there is at least one non-leaf node on this level
545 * that meets this condition, which may not be true for
546 * all the non-leaf nodes on this level. The value of
547 * zero is invalid. The value of 1 indicates that WFQ
548 * algorithm is not supported on this level. The maximum
549 * value is *sched_n_children_max*.
551 uint32_t sched_wfq_n_children_per_group_max;
553 /** Maximum number of priority levels that can have
554 * more than one child node at any given time, i.e.
555 * maximum number of WFQ sibling node groups that
556 * have two or more members. This parameter indicates
557 * there is at least one non-leaf node on this level
558 * that meets this condition, which might not be true
559 * for all the non-leaf nodes. The value of zero states
560 * that WFQ algorithm is not supported on this level.
561 * The value of 1 indicates that
562 * (*sched_sp_n_priorities_max* - 1) priority levels on
563 * this level have at most one child node, so there can
564 * be only one priority level with two or more sibling
565 * nodes making up a WFQ group on this level. The
567 * min(floor(*sched_n_children_max* / 2),
568 * *sched_sp_n_priorities_max*).
570 uint32_t sched_wfq_n_groups_max;
572 /** Maximum WFQ weight. The value of 1 indicates that
573 * all sibling nodes on this level with same priority
574 * have the same WFQ weight, so on this level WFQ is
577 uint32_t sched_wfq_weight_max;
579 /** Mask of statistics counter types supported by the
580 * non-leaf nodes on this level. Every supported
581 * statistics counter type is supported by at least one
582 * non-leaf node on this level, which may not be true
583 * for all the non-leaf nodes on this level.
584 * @see enum rte_tm_stats_type
589 /** Items valid only for the leaf nodes on this level. */
591 /** Private shaper support. When non-zero, it indicates
592 * there is at least one leaf node on this level with
593 * private shaper support, which may not be the case for
594 * all the leaf nodes on this level.
596 int shaper_private_supported;
598 /** Dual rate support for private shaper. Valid only
599 * when private shaper is supported for the leaf nodes
600 * on this level. When non-zero, it indicates there is
601 * at least one leaf node on this level with dual rate
602 * private shaper support, which may not be the case for
603 * all the leaf nodes on this level.
605 int shaper_private_dual_rate_supported;
607 /** Minimum committed/peak rate (bytes per second) for
608 * private shapers of the leaf nodes of this level.
609 * Valid only when private shaper is supported for the
610 * leaf nodes on this level.
612 uint64_t shaper_private_rate_min;
614 /** Maximum committed/peak rate (bytes per second) for
615 * private shapers of the leaf nodes on this level.
616 * Valid only when private shaper is supported for the
617 * leaf nodes on this level.
619 uint64_t shaper_private_rate_max;
621 /** Maximum number of shared shapers that any leaf node
622 * on this level can be part of. The value of zero
623 * indicates that shared shapers are not supported by
624 * the leaf nodes on this level. When non-zero, it
625 * indicates there is at least one leaf node on this
626 * level that meets this condition, which may not be the
627 * case for all the leaf nodes on this level.
629 uint32_t shaper_shared_n_max;
631 /** Head drop algorithm support. When non-zero, this
632 * parameter indicates that there is at least one leaf
633 * node on this level that supports the head drop
634 * algorithm, which might not be true for all the leaf
635 * nodes on this level.
637 int cman_head_drop_supported;
639 /** Private WRED context support. When non-zero, it
640 * indicates there is at least one node on this level
641 * with private WRED context support, which may not be
642 * true for all the leaf nodes on this level.
644 int cman_wred_context_private_supported;
646 /** Maximum number of shared WRED contexts that any
647 * leaf node on this level can be part of. The value of
648 * zero indicates that shared WRED contexts are not
649 * supported by the leaf nodes on this level. When
650 * non-zero, it indicates there is at least one leaf
651 * node on this level that meets this condition, which
652 * may not be the case for all the leaf nodes on this
655 uint32_t cman_wred_context_shared_n_max;
657 /** Mask of statistics counter types supported by the
658 * leaf nodes on this level. Every supported statistics
659 * counter type is supported by at least one leaf node
660 * on this level, which may not be true for all the leaf
661 * nodes on this level.
662 * @see enum rte_tm_stats_type
670 * Traffic manager node capabilities
672 struct rte_tm_node_capabilities {
673 /** Private shaper support for the current node. */
674 int shaper_private_supported;
676 /** Dual rate shaping support for private shaper of current node.
677 * Valid only when private shaper is supported by the current node.
679 int shaper_private_dual_rate_supported;
681 /** Minimum committed/peak rate (bytes per second) for private
682 * shaper of current node. Valid only when private shaper is supported
683 * by the current node.
685 uint64_t shaper_private_rate_min;
687 /** Maximum committed/peak rate (bytes per second) for private
688 * shaper of current node. Valid only when private shaper is supported
689 * by the current node.
691 uint64_t shaper_private_rate_max;
693 /** Maximum number of shared shapers the current node can be part of.
694 * The value of zero indicates that shared shapers are not supported by
697 uint32_t shaper_shared_n_max;
701 /** Items valid only for non-leaf nodes. */
703 /** Maximum number of children nodes. */
704 uint32_t sched_n_children_max;
706 /** Maximum number of supported priority levels. The
707 * value of zero is invalid. The value of 1 indicates
708 * that only priority 0 is supported, which essentially
709 * means that Strict Priority (SP) algorithm is not
712 uint32_t sched_sp_n_priorities_max;
714 /** Maximum number of sibling nodes that can have the
715 * same priority at any given time, i.e. maximum size
716 * of the WFQ sibling node group. The value of zero
717 * is invalid. The value of 1 indicates that WFQ
718 * algorithm is not supported. The maximum value is
719 * *sched_n_children_max*.
721 uint32_t sched_wfq_n_children_per_group_max;
723 /** Maximum number of priority levels that can have
724 * more than one child node at any given time, i.e.
725 * maximum number of WFQ sibling node groups that have
726 * two or more members. The value of zero states that
727 * WFQ algorithm is not supported. The value of 1
728 * indicates that (*sched_sp_n_priorities_max* - 1)
729 * priority levels have at most one child node, so there
730 * can be only one priority level with two or more
731 * sibling nodes making up a WFQ group. The maximum
732 * value is: min(floor(*sched_n_children_max* / 2),
733 * *sched_sp_n_priorities_max*).
735 uint32_t sched_wfq_n_groups_max;
737 /** Maximum WFQ weight. The value of 1 indicates that
738 * all sibling nodes with same priority have the same
739 * WFQ weight, so WFQ is reduced to FQ.
741 uint32_t sched_wfq_weight_max;
744 /** Items valid only for leaf nodes. */
746 /** Head drop algorithm support for current node. */
747 int cman_head_drop_supported;
749 /** Private WRED context support for current node. */
750 int cman_wred_context_private_supported;
752 /** Maximum number of shared WRED contexts the current
753 * node can be part of. The value of zero indicates that
754 * shared WRED contexts are not supported by the current
757 uint32_t cman_wred_context_shared_n_max;
761 /** Mask of statistics counter types supported by the current node.
762 * @see enum rte_tm_stats_type
768 * Congestion management (CMAN) mode
770 * This is used for controlling the admission of packets into a packet queue or
771 * group of packet queues on congestion. On request of writing a new packet
772 * into the current queue while the queue is full, the *tail drop* algorithm
773 * drops the new packet while leaving the queue unmodified, as opposed to *head
774 * drop* algorithm, which drops the packet at the head of the queue (the oldest
775 * packet waiting in the queue) and admits the new packet at the tail of the
778 * The *Random Early Detection (RED)* algorithm works by proactively dropping
779 * more and more input packets as the queue occupancy builds up. When the queue
780 * is full or almost full, RED effectively works as *tail drop*. The *Weighted
781 * RED* algorithm uses a separate set of RED thresholds for each packet color.
783 enum rte_tm_cman_mode {
784 RTE_TM_CMAN_TAIL_DROP = 0, /**< Tail drop */
785 RTE_TM_CMAN_HEAD_DROP, /**< Head drop */
786 RTE_TM_CMAN_WRED, /**< Weighted Random Early Detection (WRED) */
790 * Random Early Detection (RED) profile
792 struct rte_tm_red_params {
793 /** Minimum queue threshold */
796 /** Maximum queue threshold */
799 /** Inverse of packet marking probability maximum value (maxp), i.e.
800 * maxp_inv = 1 / maxp
804 /** Negated log2 of queue weight (wq), i.e. wq = 1 / (2 ^ wq_log2) */
809 * Weighted RED (WRED) profile
811 * Multiple WRED contexts can share the same WRED profile. Each leaf node with
812 * WRED enabled as its congestion management mode has zero or one private WRED
813 * context (only one leaf node using it) and/or zero, one or several shared
814 * WRED contexts (multiple leaf nodes use the same WRED context). A private
815 * WRED context is used to perform congestion management for a single leaf
816 * node, while a shared WRED context is used to perform congestion management
817 * for a group of leaf nodes.
819 struct rte_tm_wred_params {
820 /** One set of RED parameters per packet color */
821 struct rte_tm_red_params red_params[RTE_TM_COLORS];
827 struct rte_tm_token_bucket {
828 /** Token bucket rate (bytes per second) */
831 /** Token bucket size (bytes), a.k.a. max burst size */
836 * Shaper (rate limiter) profile
838 * Multiple shaper instances can share the same shaper profile. Each node has
839 * zero or one private shaper (only one node using it) and/or zero, one or
840 * several shared shapers (multiple nodes use the same shaper instance).
841 * A private shaper is used to perform traffic shaping for a single node, while
842 * a shared shaper is used to perform traffic shaping for a group of nodes.
844 * Single rate shapers use a single token bucket. A single rate shaper can be
845 * configured by setting the rate of the committed bucket to zero, which
846 * effectively disables this bucket. The peak bucket is used to limit the rate
847 * and the burst size for the current shaper.
849 * Dual rate shapers use both the committed and the peak token buckets. The
850 * rate of the peak bucket has to be bigger than zero, as well as greater than
851 * or equal to the rate of the committed bucket.
853 struct rte_tm_shaper_params {
854 /** Committed token bucket */
855 struct rte_tm_token_bucket committed;
857 /** Peak token bucket */
858 struct rte_tm_token_bucket peak;
860 /** Signed value to be added to the length of each packet for the
861 * purpose of shaping. Can be used to correct the packet length with
862 * the framing overhead bytes that are also consumed on the wire (e.g.
863 * RTE_TM_ETH_FRAMING_OVERHEAD_FCS).
865 int32_t pkt_length_adjust;
871 * Each non-leaf node has multiple inputs (its children nodes) and single output
872 * (which is input to its parent node). It arbitrates its inputs using Strict
873 * Priority (SP) and Weighted Fair Queuing (WFQ) algorithms to schedule input
874 * packets to its output while observing its shaping (rate limiting)
877 * Algorithms such as Weighted Round Robin (WRR), Byte-level WRR, Deficit WRR
878 * (DWRR), etc. are considered approximations of the WFQ ideal and are
879 * assimilated to WFQ, although an associated implementation-dependent trade-off
880 * on accuracy, performance and resource usage might exist.
882 * Children nodes with different priorities are scheduled using the SP algorithm
883 * based on their priority, with zero (0) as the highest priority. Children with
884 * the same priority are scheduled using the WFQ algorithm according to their
885 * weights. The WFQ weight of a given child node is relative to the sum of the
886 * weights of all its sibling nodes that have the same priority, with one (1) as
887 * the lowest weight. For each SP priority, the WFQ weight mode can be set as
888 * either byte-based or packet-based.
890 * Each leaf node sits on top of a TX queue of the current Ethernet port. Hence,
891 * the leaf nodes are predefined, with their node IDs set to 0 .. (N-1), where N
892 * is the number of TX queues configured for the current Ethernet port. The
893 * non-leaf nodes have their IDs generated by the application.
895 struct rte_tm_node_params {
896 /** Shaper profile for the private shaper. The absence of the private
897 * shaper for the current node is indicated by setting this parameter
898 * to RTE_TM_SHAPER_PROFILE_ID_NONE.
900 uint32_t shaper_profile_id;
902 /** User allocated array of valid shared shaper IDs. */
903 uint32_t *shared_shaper_id;
905 /** Number of shared shaper IDs in the *shared_shaper_id* array. */
906 uint32_t n_shared_shapers;
910 /** Parameters only valid for non-leaf nodes. */
912 /** WFQ weight mode for each SP priority. When NULL, it
913 * indicates that WFQ is to be used for all priorities.
914 * When non-NULL, it points to a pre-allocated array of
915 * *n_sp_priorities* values, with non-zero value for
916 * byte-mode and zero for packet-mode.
918 int *wfq_weight_mode;
920 /** Number of SP priorities. */
921 uint32_t n_sp_priorities;
924 /** Parameters only valid for leaf nodes. */
926 /** Congestion management mode */
927 enum rte_tm_cman_mode cman;
929 /** WRED parameters (only valid when *cman* is set to
933 /** WRED profile for private WRED context. The
934 * absence of a private WRED context for the
935 * current leaf node is indicated by value
936 * RTE_TM_WRED_PROFILE_ID_NONE.
938 uint32_t wred_profile_id;
940 /** User allocated array of shared WRED context
941 * IDs. When set to NULL, it indicates that the
942 * current leaf node should not currently be
943 * part of any shared WRED contexts.
945 uint32_t *shared_wred_context_id;
947 /** Number of elements in the
948 * *shared_wred_context_id* array. Only valid
949 * when *shared_wred_context_id* is non-NULL,
950 * in which case it should be non-zero.
952 uint32_t n_shared_wred_contexts;
957 /** Mask of statistics counter types to be enabled for this node. This
958 * needs to be a subset of the statistics counter types available for
959 * the current node. Any statistics counter type not included in this
960 * set is to be disabled for the current node.
961 * @see enum rte_tm_stats_type
967 * Verbose error types.
969 * Most of them provide the type of the object referenced by struct
970 * rte_tm_error::cause.
972 enum rte_tm_error_type {
973 RTE_TM_ERROR_TYPE_NONE, /**< No error. */
974 RTE_TM_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
975 RTE_TM_ERROR_TYPE_CAPABILITIES,
976 RTE_TM_ERROR_TYPE_LEVEL_ID,
977 RTE_TM_ERROR_TYPE_WRED_PROFILE,
978 RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN,
979 RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW,
980 RTE_TM_ERROR_TYPE_WRED_PROFILE_RED,
981 RTE_TM_ERROR_TYPE_WRED_PROFILE_ID,
982 RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID,
983 RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
984 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE,
985 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE,
986 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
987 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
988 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN,
989 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
990 RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID,
991 RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID,
992 RTE_TM_ERROR_TYPE_NODE_PRIORITY,
993 RTE_TM_ERROR_TYPE_NODE_WEIGHT,
994 RTE_TM_ERROR_TYPE_NODE_PARAMS,
995 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID,
996 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID,
997 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS,
998 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE,
999 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES,
1000 RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN,
1001 RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID,
1002 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID,
1003 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS,
1004 RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
1005 RTE_TM_ERROR_TYPE_NODE_ID,
1009 * Verbose error structure definition.
1011 * This object is normally allocated by applications and set by PMDs, the
1012 * message points to a constant string which does not need to be freed by
1013 * the application, however its pointer can be considered valid only as long
1014 * as its associated DPDK port remains configured. Closing the underlying
1015 * device or unloading the PMD invalidates it.
1017 * Both cause and message may be NULL regardless of the error type.
1019 struct rte_tm_error {
1020 enum rte_tm_error_type type; /**< Cause field and error type. */
1021 const void *cause; /**< Object responsible for the error. */
1022 const char *message; /**< Human-readable error message. */
1026 * Traffic manager get number of leaf nodes
1028 * Each leaf node sits on on top of a TX queue of the current Ethernet port.
1029 * Therefore, the set of leaf nodes is predefined, their number is always equal
1030 * to N (where N is the number of TX queues configured for the current port)
1031 * and their IDs are 0 .. (N-1).
1033 * @param[in] port_id
1034 * The port identifier of the Ethernet device.
1035 * @param[out] n_leaf_nodes
1036 * Number of leaf nodes for the current port.
1038 * Error details. Filled in only on error, when not NULL.
1040 * 0 on success, non-zero error code otherwise.
1043 rte_tm_get_number_of_leaf_nodes(uint16_t port_id,
1044 uint32_t *n_leaf_nodes,
1045 struct rte_tm_error *error);
1048 * Traffic manager node ID validate and type (i.e. leaf or non-leaf) get
1050 * The leaf nodes have predefined IDs in the range of 0 .. (N-1), where N is
1051 * the number of TX queues of the current Ethernet port. The non-leaf nodes
1052 * have their IDs generated by the application outside of the above range,
1053 * which is reserved for leaf nodes.
1055 * @param[in] port_id
1056 * The port identifier of the Ethernet device.
1057 * @param[in] node_id
1058 * Node ID value. Needs to be valid.
1059 * @param[out] is_leaf
1060 * Set to non-zero value when node is leaf and to zero otherwise (non-leaf).
1062 * Error details. Filled in only on error, when not NULL.
1064 * 0 on success, non-zero error code otherwise.
1067 rte_tm_node_type_get(uint16_t port_id,
1070 struct rte_tm_error *error);
1073 * Traffic manager capabilities get
1075 * @param[in] port_id
1076 * The port identifier of the Ethernet device.
1078 * Traffic manager capabilities. Needs to be pre-allocated and valid.
1080 * Error details. Filled in only on error, when not NULL.
1082 * 0 on success, non-zero error code otherwise.
1085 rte_tm_capabilities_get(uint16_t port_id,
1086 struct rte_tm_capabilities *cap,
1087 struct rte_tm_error *error);
1090 * Traffic manager level capabilities get
1092 * @param[in] port_id
1093 * The port identifier of the Ethernet device.
1094 * @param[in] level_id
1095 * The hierarchy level identifier. The value of 0 identifies the level of the
1098 * Traffic manager level capabilities. Needs to be pre-allocated and valid.
1100 * Error details. Filled in only on error, when not NULL.
1102 * 0 on success, non-zero error code otherwise.
1105 rte_tm_level_capabilities_get(uint16_t port_id,
1107 struct rte_tm_level_capabilities *cap,
1108 struct rte_tm_error *error);
1111 * Traffic manager node capabilities get
1113 * @param[in] port_id
1114 * The port identifier of the Ethernet device.
1115 * @param[in] node_id
1116 * Node ID. Needs to be valid.
1118 * Traffic manager node capabilities. Needs to be pre-allocated and valid.
1120 * Error details. Filled in only on error, when not NULL.
1122 * 0 on success, non-zero error code otherwise.
1125 rte_tm_node_capabilities_get(uint16_t port_id,
1127 struct rte_tm_node_capabilities *cap,
1128 struct rte_tm_error *error);
1131 * Traffic manager WRED profile add
1133 * Create a new WRED profile with ID set to *wred_profile_id*. The new profile
1134 * is used to create one or several WRED contexts.
1136 * @param[in] port_id
1137 * The port identifier of the Ethernet device.
1138 * @param[in] wred_profile_id
1139 * WRED profile ID for the new profile. Needs to be unused.
1140 * @param[in] profile
1141 * WRED profile parameters. Needs to be pre-allocated and valid.
1143 * Error details. Filled in only on error, when not NULL.
1145 * 0 on success, non-zero error code otherwise.
1147 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1150 rte_tm_wred_profile_add(uint16_t port_id,
1151 uint32_t wred_profile_id,
1152 struct rte_tm_wred_params *profile,
1153 struct rte_tm_error *error);
1156 * Traffic manager WRED profile delete
1158 * Delete an existing WRED profile. This operation fails when there is
1159 * currently at least one user (i.e. WRED context) of this WRED profile.
1161 * @param[in] port_id
1162 * The port identifier of the Ethernet device.
1163 * @param[in] wred_profile_id
1164 * WRED profile ID. Needs to be the valid.
1166 * Error details. Filled in only on error, when not NULL.
1168 * 0 on success, non-zero error code otherwise.
1170 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1173 rte_tm_wred_profile_delete(uint16_t port_id,
1174 uint32_t wred_profile_id,
1175 struct rte_tm_error *error);
1178 * Traffic manager shared WRED context add or update
1180 * When *shared_wred_context_id* is invalid, a new WRED context with this ID is
1181 * created by using the WRED profile identified by *wred_profile_id*.
1183 * When *shared_wred_context_id* is valid, this WRED context is no longer using
1184 * the profile previously assigned to it and is updated to use the profile
1185 * identified by *wred_profile_id*.
1187 * A valid shared WRED context can be assigned to several hierarchy leaf nodes
1188 * configured to use WRED as the congestion management mode.
1190 * @param[in] port_id
1191 * The port identifier of the Ethernet device.
1192 * @param[in] shared_wred_context_id
1193 * Shared WRED context ID
1194 * @param[in] wred_profile_id
1195 * WRED profile ID. Needs to be the valid.
1197 * Error details. Filled in only on error, when not NULL.
1199 * 0 on success, non-zero error code otherwise.
1201 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1204 rte_tm_shared_wred_context_add_update(uint16_t port_id,
1205 uint32_t shared_wred_context_id,
1206 uint32_t wred_profile_id,
1207 struct rte_tm_error *error);
1210 * Traffic manager shared WRED context delete
1212 * Delete an existing shared WRED context. This operation fails when there is
1213 * currently at least one user (i.e. hierarchy leaf node) of this shared WRED
1216 * @param[in] port_id
1217 * The port identifier of the Ethernet device.
1218 * @param[in] shared_wred_context_id
1219 * Shared WRED context ID. Needs to be the valid.
1221 * Error details. Filled in only on error, when not NULL.
1223 * 0 on success, non-zero error code otherwise.
1225 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1228 rte_tm_shared_wred_context_delete(uint16_t port_id,
1229 uint32_t shared_wred_context_id,
1230 struct rte_tm_error *error);
1233 * Traffic manager shaper profile add
1235 * Create a new shaper profile with ID set to *shaper_profile_id*. The new
1236 * shaper profile is used to create one or several shapers.
1238 * @param[in] port_id
1239 * The port identifier of the Ethernet device.
1240 * @param[in] shaper_profile_id
1241 * Shaper profile ID for the new profile. Needs to be unused.
1242 * @param[in] profile
1243 * Shaper profile parameters. Needs to be pre-allocated and valid.
1245 * Error details. Filled in only on error, when not NULL.
1247 * 0 on success, non-zero error code otherwise.
1249 * @see struct rte_tm_capabilities::shaper_n_max
1252 rte_tm_shaper_profile_add(uint16_t port_id,
1253 uint32_t shaper_profile_id,
1254 struct rte_tm_shaper_params *profile,
1255 struct rte_tm_error *error);
1258 * Traffic manager shaper profile delete
1260 * Delete an existing shaper profile. This operation fails when there is
1261 * currently at least one user (i.e. shaper) of this shaper profile.
1263 * @param[in] port_id
1264 * The port identifier of the Ethernet device.
1265 * @param[in] shaper_profile_id
1266 * Shaper profile ID. Needs to be the valid.
1268 * Error details. Filled in only on error, when not NULL.
1270 * 0 on success, non-zero error code otherwise.
1272 * @see struct rte_tm_capabilities::shaper_n_max
1275 rte_tm_shaper_profile_delete(uint16_t port_id,
1276 uint32_t shaper_profile_id,
1277 struct rte_tm_error *error);
1280 * Traffic manager shared shaper add or update
1282 * When *shared_shaper_id* is not a valid shared shaper ID, a new shared shaper
1283 * with this ID is created using the shaper profile identified by
1284 * *shaper_profile_id*.
1286 * When *shared_shaper_id* is a valid shared shaper ID, this shared shaper is
1287 * no longer using the shaper profile previously assigned to it and is updated
1288 * to use the shaper profile identified by *shaper_profile_id*.
1290 * @param[in] port_id
1291 * The port identifier of the Ethernet device.
1292 * @param[in] shared_shaper_id
1294 * @param[in] shaper_profile_id
1295 * Shaper profile ID. Needs to be the valid.
1297 * Error details. Filled in only on error, when not NULL.
1299 * 0 on success, non-zero error code otherwise.
1301 * @see struct rte_tm_capabilities::shaper_shared_n_max
1304 rte_tm_shared_shaper_add_update(uint16_t port_id,
1305 uint32_t shared_shaper_id,
1306 uint32_t shaper_profile_id,
1307 struct rte_tm_error *error);
1310 * Traffic manager shared shaper delete
1312 * Delete an existing shared shaper. This operation fails when there is
1313 * currently at least one user (i.e. hierarchy node) of this shared shaper.
1315 * @param[in] port_id
1316 * The port identifier of the Ethernet device.
1317 * @param[in] shared_shaper_id
1318 * Shared shaper 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
1327 rte_tm_shared_shaper_delete(uint16_t port_id,
1328 uint32_t shared_shaper_id,
1329 struct rte_tm_error *error);
1332 * Traffic manager node add
1334 * Create new node and connect it as child of an existing node. The new node is
1335 * further identified by *node_id*, which needs to be unused by any of the
1336 * existing nodes. The parent node is identified by *parent_node_id*, which
1337 * needs to be the valid ID of an existing non-leaf node. The parent node is
1338 * going to use the provided SP *priority* and WFQ *weight* to schedule its new
1341 * This function has to be called for both leaf and non-leaf nodes. In the case
1342 * of leaf nodes (i.e. *node_id* is within the range of 0 .. (N-1), with N as
1343 * the number of configured TX queues of the current port), the leaf node is
1344 * configured rather than created (as the set of leaf nodes is predefined) and
1345 * it is also connected as child of an existing node.
1347 * The first node that is added becomes the root node and all the nodes that
1348 * are subsequently added have to be added as descendants of the root node. The
1349 * parent of the root node has to be specified as RTE_TM_NODE_ID_NULL and there
1350 * can only be one node with this parent ID (i.e. the root node). Further
1351 * restrictions for root node: needs to be non-leaf, its private shaper profile
1352 * needs to be valid and single rate, cannot use any shared shapers.
1354 * When called before rte_tm_hierarchy_commit() invocation, this function is
1355 * typically used to define the initial start-up hierarchy for the port.
1356 * Provided that dynamic hierarchy updates are supported by the current port (as
1357 * advertised in the port capability set), this function can be also called
1358 * after the rte_tm_hierarchy_commit() invocation.
1360 * @param[in] port_id
1361 * The port identifier of the Ethernet device.
1362 * @param[in] node_id
1363 * Node ID. Needs to be unused by any of the existing nodes.
1364 * @param[in] parent_node_id
1365 * Parent node ID. Needs to be the valid.
1366 * @param[in] priority
1367 * Node priority. The highest node priority is zero. Used by the SP algorithm
1368 * running on the parent of the current node for scheduling this child node.
1370 * Node weight. The node weight is relative to the weight sum of all siblings
1371 * that have the same priority. The lowest weight is one. Used by the WFQ
1372 * algorithm running on the parent of the current node for scheduling this
1374 * @param[in] level_id
1375 * Level ID that should be met by this node. The hierarchy level of the
1376 * current node is already fully specified through its parent node (i.e. the
1377 * level of this node is equal to the level of its parent node plus one),
1378 * therefore the reason for providing this parameter is to enable the
1379 * application to perform step-by-step checking of the node level during
1380 * successive invocations of this function. When not desired, this check can
1381 * be disabled by assigning value RTE_TM_NODE_LEVEL_ID_ANY to this parameter.
1383 * Node parameters. Needs to be pre-allocated and valid.
1385 * Error details. Filled in only on error, when not NULL.
1387 * 0 on success, non-zero error code otherwise.
1389 * @see rte_tm_hierarchy_commit()
1390 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1391 * @see RTE_TM_NODE_LEVEL_ID_ANY
1392 * @see struct rte_tm_capabilities
1395 rte_tm_node_add(uint16_t port_id,
1397 uint32_t parent_node_id,
1401 struct rte_tm_node_params *params,
1402 struct rte_tm_error *error);
1405 * Traffic manager node delete
1407 * Delete an existing node. This operation fails when this node currently has
1408 * at least one user (i.e. child node).
1410 * When called before rte_tm_hierarchy_commit() invocation, this function is
1411 * typically used to define the initial start-up hierarchy for the port.
1412 * Provided that dynamic hierarchy updates are supported by the current port (as
1413 * advertised in the port capability set), this function can be also called
1414 * after the rte_tm_hierarchy_commit() invocation.
1416 * @param[in] port_id
1417 * The port identifier of the Ethernet device.
1418 * @param[in] node_id
1419 * Node ID. Needs to be valid.
1421 * Error details. Filled in only on error, when not NULL.
1423 * 0 on success, non-zero error code otherwise.
1425 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1428 rte_tm_node_delete(uint16_t port_id,
1430 struct rte_tm_error *error);
1433 * Traffic manager node suspend
1435 * Suspend an existing node. While the node is in suspended state, no packet is
1436 * scheduled from this node and its descendants. The node exits the suspended
1437 * state through the node resume operation.
1439 * @param[in] port_id
1440 * The port identifier of the Ethernet device.
1441 * @param[in] node_id
1442 * Node ID. Needs to be valid.
1444 * Error details. Filled in only on error, when not NULL.
1446 * 0 on success, non-zero error code otherwise.
1448 * @see rte_tm_node_resume()
1449 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1452 rte_tm_node_suspend(uint16_t port_id,
1454 struct rte_tm_error *error);
1457 * Traffic manager node resume
1459 * Resume an existing node that is currently in suspended state. The node
1460 * entered the suspended state as result of a previous node suspend operation.
1462 * @param[in] port_id
1463 * The port identifier of the Ethernet device.
1464 * @param[in] node_id
1465 * Node ID. Needs to be valid.
1467 * Error details. Filled in only on error, when not NULL.
1469 * 0 on success, non-zero error code otherwise.
1471 * @see rte_tm_node_suspend()
1472 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1475 rte_tm_node_resume(uint16_t port_id,
1477 struct rte_tm_error *error);
1480 * Traffic manager hierarchy commit
1482 * This function is called during the port initialization phase (before the
1483 * Ethernet port is started) to freeze the start-up hierarchy.
1485 * This function typically performs the following steps:
1486 * a) It validates the start-up hierarchy that was previously defined for the
1487 * current port through successive rte_tm_node_add() invocations;
1488 * b) Assuming successful validation, it performs all the necessary port
1489 * specific configuration operations to install the specified hierarchy on
1490 * the current port, with immediate effect once the port is started.
1492 * This function fails when the currently configured hierarchy is not supported
1493 * by the Ethernet port, in which case the user can abort or try out another
1494 * hierarchy configuration (e.g. a hierarchy with less leaf nodes), which can be
1495 * build from scratch (when *clear_on_fail* is enabled) or by modifying the
1496 * existing hierarchy configuration (when *clear_on_fail* is disabled).
1498 * Note that this function can still fail due to other causes (e.g. not enough
1499 * memory available in the system, etc), even though the specified hierarchy is
1500 * supported in principle by the current port.
1502 * @param[in] port_id
1503 * The port identifier of the Ethernet device.
1504 * @param[in] clear_on_fail
1505 * On function call failure, hierarchy is cleared when this parameter is
1506 * non-zero and preserved when this parameter is equal to zero.
1508 * Error details. Filled in only on error, when not NULL.
1510 * 0 on success, non-zero error code otherwise.
1512 * @see rte_tm_node_add()
1513 * @see rte_tm_node_delete()
1516 rte_tm_hierarchy_commit(uint16_t port_id,
1518 struct rte_tm_error *error);
1521 * Traffic manager node parent update
1523 * Restriction for root node: its parent cannot be changed.
1525 * This function can only be called after the rte_tm_hierarchy_commit()
1526 * invocation. Its success depends on the port support for this operation, as
1527 * advertised through the port capability set.
1529 * @param[in] port_id
1530 * The port identifier of the Ethernet device.
1531 * @param[in] node_id
1532 * Node ID. Needs to be valid.
1533 * @param[in] parent_node_id
1534 * Node ID for the new parent. Needs to be valid.
1535 * @param[in] priority
1536 * Node priority. The highest node priority is zero. Used by the SP algorithm
1537 * running on the parent of the current node for scheduling this child node.
1539 * Node weight. The node weight is relative to the weight sum of all siblings
1540 * that have the same priority. The lowest weight is zero. Used by the WFQ
1541 * algorithm running on the parent of the current node for scheduling this
1544 * Error details. Filled in only on error, when not NULL.
1546 * 0 on success, non-zero error code otherwise.
1548 * @see RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL
1549 * @see RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL
1552 rte_tm_node_parent_update(uint16_t port_id,
1554 uint32_t parent_node_id,
1557 struct rte_tm_error *error);
1560 * Traffic manager node private shaper update
1562 * Restriction for the root node: its private shaper profile needs to be valid
1565 * @param[in] port_id
1566 * The port identifier of the Ethernet device.
1567 * @param[in] node_id
1568 * Node ID. Needs to be valid.
1569 * @param[in] shaper_profile_id
1570 * Shaper profile ID for the private shaper of the current node. Needs to be
1571 * either valid shaper profile ID or RTE_TM_SHAPER_PROFILE_ID_NONE, with
1572 * the latter disabling the private shaper of the current node.
1574 * Error details. Filled in only on error, when not NULL.
1576 * 0 on success, non-zero error code otherwise.
1578 * @see struct rte_tm_capabilities::shaper_private_n_max
1581 rte_tm_node_shaper_update(uint16_t port_id,
1583 uint32_t shaper_profile_id,
1584 struct rte_tm_error *error);
1587 * Traffic manager node shared shapers update
1589 * Restriction for root node: cannot use any shared rate shapers.
1591 * @param[in] port_id
1592 * The port identifier of the Ethernet device.
1593 * @param[in] node_id
1594 * Node ID. Needs to be valid.
1595 * @param[in] shared_shaper_id
1596 * Shared shaper ID. Needs to be valid.
1598 * Set to non-zero value to add this shared shaper to current node or to zero
1599 * to delete this shared shaper from current node.
1601 * Error details. Filled in only on error, when not NULL.
1603 * 0 on success, non-zero error code otherwise.
1605 * @see struct rte_tm_capabilities::shaper_shared_n_max
1608 rte_tm_node_shared_shaper_update(uint16_t port_id,
1610 uint32_t shared_shaper_id,
1612 struct rte_tm_error *error);
1615 * Traffic manager node enabled statistics counters update
1617 * @param[in] port_id
1618 * The port identifier of the Ethernet device.
1619 * @param[in] node_id
1620 * Node ID. Needs to be valid.
1621 * @param[in] stats_mask
1622 * Mask of statistics counter types to be enabled for the current node. This
1623 * needs to be a subset of the statistics counter types available for the
1624 * current node. Any statistics counter type not included in this set is to
1625 * be disabled for the current node.
1627 * Error details. Filled in only on error, when not NULL.
1629 * 0 on success, non-zero error code otherwise.
1631 * @see enum rte_tm_stats_type
1632 * @see RTE_TM_UPDATE_NODE_STATS
1635 rte_tm_node_stats_update(uint16_t port_id,
1637 uint64_t stats_mask,
1638 struct rte_tm_error *error);
1641 * Traffic manager node WFQ weight mode update
1643 * @param[in] port_id
1644 * The port identifier of the Ethernet device.
1645 * @param[in] node_id
1646 * Node ID. Needs to be valid leaf node ID.
1647 * @param[in] wfq_weight_mode
1648 * WFQ weight mode for each SP priority. When NULL, it indicates that WFQ is
1649 * to be used for all priorities. When non-NULL, it points to a pre-allocated
1650 * array of *n_sp_priorities* values, with non-zero value for byte-mode and
1651 * zero for packet-mode.
1652 * @param[in] n_sp_priorities
1653 * Number of SP priorities.
1655 * Error details. Filled in only on error, when not NULL.
1657 * 0 on success, non-zero error code otherwise.
1659 * @see RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE
1660 * @see RTE_TM_UPDATE_NODE_N_SP_PRIORITIES
1663 rte_tm_node_wfq_weight_mode_update(uint16_t port_id,
1665 int *wfq_weight_mode,
1666 uint32_t n_sp_priorities,
1667 struct rte_tm_error *error);
1670 * Traffic manager node congestion management mode update
1672 * @param[in] port_id
1673 * The port identifier of the Ethernet device.
1674 * @param[in] node_id
1675 * Node ID. Needs to be valid leaf node ID.
1677 * Congestion management mode.
1679 * Error details. Filled in only on error, when not NULL.
1681 * 0 on success, non-zero error code otherwise.
1683 * @see RTE_TM_UPDATE_NODE_CMAN
1686 rte_tm_node_cman_update(uint16_t port_id,
1688 enum rte_tm_cman_mode cman,
1689 struct rte_tm_error *error);
1692 * Traffic manager node private WRED context update
1694 * @param[in] port_id
1695 * The port identifier of the Ethernet device.
1696 * @param[in] node_id
1697 * Node ID. Needs to be valid leaf node ID.
1698 * @param[in] wred_profile_id
1699 * WRED profile ID for the private WRED context of the current node. Needs to
1700 * be either valid WRED profile ID or RTE_TM_WRED_PROFILE_ID_NONE, with the
1701 * latter disabling the private WRED context of the current node.
1703 * Error details. Filled in only on error, when not NULL.
1705 * 0 on success, non-zero error code otherwise.
1707 * @see struct rte_tm_capabilities::cman_wred_context_private_n_max
1710 rte_tm_node_wred_context_update(uint16_t port_id,
1712 uint32_t wred_profile_id,
1713 struct rte_tm_error *error);
1716 * Traffic manager node shared WRED context update
1718 * @param[in] port_id
1719 * The port identifier of the Ethernet device.
1720 * @param[in] node_id
1721 * Node ID. Needs to be valid leaf node ID.
1722 * @param[in] shared_wred_context_id
1723 * Shared WRED context ID. Needs to be valid.
1725 * Set to non-zero value to add this shared WRED context to current node or
1726 * to zero to delete this shared WRED context from current node.
1728 * Error details. Filled in only on error, when not NULL.
1730 * 0 on success, non-zero error code otherwise.
1732 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1735 rte_tm_node_shared_wred_context_update(uint16_t port_id,
1737 uint32_t shared_wred_context_id,
1739 struct rte_tm_error *error);
1742 * Traffic manager node statistics counters read
1744 * @param[in] port_id
1745 * The port identifier of the Ethernet device.
1746 * @param[in] node_id
1747 * Node ID. Needs to be valid.
1749 * When non-NULL, it contains the current value for the statistics counters
1750 * enabled for the current node.
1751 * @param[out] stats_mask
1752 * When non-NULL, it contains the mask of statistics counter types that are
1753 * currently enabled for this node, indicating which of the counters
1754 * retrieved with the *stats* structure are valid.
1756 * When this parameter has a non-zero value, the statistics counters are
1757 * cleared (i.e. set to zero) immediately after they have been read,
1758 * otherwise the statistics counters are left untouched.
1760 * Error details. Filled in only on error, when not NULL.
1762 * 0 on success, non-zero error code otherwise.
1764 * @see enum rte_tm_stats_type
1767 rte_tm_node_stats_read(uint16_t port_id,
1769 struct rte_tm_node_stats *stats,
1770 uint64_t *stats_mask,
1772 struct rte_tm_error *error);
1775 * Traffic manager packet marking - VLAN DEI (IEEE 802.1Q)
1777 * IEEE 802.1p maps the traffic class to the VLAN Priority Code Point (PCP)
1778 * field (3 bits), while IEEE 802.1q maps the drop priority to the VLAN Drop
1779 * Eligible Indicator (DEI) field (1 bit), which was previously named Canonical
1780 * Format Indicator (CFI).
1782 * All VLAN frames of a given color get their DEI bit set if marking is enabled
1783 * for this color; otherwise, their DEI bit is left as is (either set or not).
1785 * @param[in] port_id
1786 * The port identifier of the Ethernet device.
1787 * @param[in] mark_green
1788 * Set to non-zero value to enable marking of green packets and to zero to
1790 * @param[in] mark_yellow
1791 * Set to non-zero value to enable marking of yellow packets and to zero to
1793 * @param[in] mark_red
1794 * Set to non-zero value to enable marking of red packets and to zero to
1797 * Error details. Filled in only on error, when not NULL.
1799 * 0 on success, non-zero error code otherwise.
1801 * @see struct rte_tm_capabilities::mark_vlan_dei_supported
1804 rte_tm_mark_vlan_dei(uint16_t port_id,
1808 struct rte_tm_error *error);
1811 * Traffic manager packet marking - IPv4 / IPv6 ECN (IETF RFC 3168)
1813 * IETF RFCs 2474 and 3168 reorganize the IPv4 Type of Service (TOS) field
1814 * (8 bits) and the IPv6 Traffic Class (TC) field (8 bits) into Differentiated
1815 * Services Codepoint (DSCP) field (6 bits) and Explicit Congestion
1816 * Notification (ECN) field (2 bits). The DSCP field is typically used to
1817 * encode the traffic class and/or drop priority (RFC 2597), while the ECN
1818 * field is used by RFC 3168 to implement a congestion notification mechanism
1819 * to be leveraged by transport layer protocols such as TCP and SCTP that have
1820 * congestion control mechanisms.
1822 * When congestion is experienced, as alternative to dropping the packet,
1823 * routers can change the ECN field of input packets from 2'b01 or 2'b10
1824 * (values indicating that source endpoint is ECN-capable) to 2'b11 (meaning
1825 * that congestion is experienced). The destination endpoint can use the
1826 * ECN-Echo (ECE) TCP flag to relay the congestion indication back to the
1827 * source endpoint, which acknowledges it back to the destination endpoint with
1828 * the Congestion Window Reduced (CWR) TCP flag.
1830 * All IPv4/IPv6 packets of a given color with ECN set to 2’b01 or 2’b10
1831 * carrying TCP or SCTP have their ECN set to 2’b11 if the marking feature is
1832 * enabled for the current color, otherwise the ECN field is left as is.
1834 * @param[in] port_id
1835 * The port identifier of the Ethernet device.
1836 * @param[in] mark_green
1837 * Set to non-zero value to enable marking of green packets and to zero to
1839 * @param[in] mark_yellow
1840 * Set to non-zero value to enable marking of yellow packets and to zero to
1842 * @param[in] mark_red
1843 * Set to non-zero value to enable marking of red packets and to zero to
1846 * Error details. Filled in only on error, when not NULL.
1848 * 0 on success, non-zero error code otherwise.
1850 * @see struct rte_tm_capabilities::mark_ip_ecn_tcp_supported
1851 * @see struct rte_tm_capabilities::mark_ip_ecn_sctp_supported
1854 rte_tm_mark_ip_ecn(uint16_t port_id,
1858 struct rte_tm_error *error);
1861 * Traffic manager packet marking - IPv4 / IPv6 DSCP (IETF RFC 2597)
1863 * IETF RFC 2597 maps the traffic class and the drop priority to the IPv4/IPv6
1864 * Differentiated Services Codepoint (DSCP) field (6 bits). Here are the DSCP
1865 * values proposed by this RFC:
1867 * <pre> Class 1 Class 2 Class 3 Class 4 </pre>
1868 * <pre> +----------+----------+----------+----------+</pre>
1869 * <pre>Low Drop Prec | 001010 | 010010 | 011010 | 100010 |</pre>
1870 * <pre>Medium Drop Prec | 001100 | 010100 | 011100 | 100100 |</pre>
1871 * <pre>High Drop Prec | 001110 | 010110 | 011110 | 100110 |</pre>
1872 * <pre> +----------+----------+----------+----------+</pre>
1874 * There are 4 traffic classes (classes 1 .. 4) encoded by DSCP bits 1 and 2,
1875 * as well as 3 drop priorities (low/medium/high) encoded by DSCP bits 3 and 4.
1877 * All IPv4/IPv6 packets have their color marked into DSCP bits 3 and 4 as
1878 * follows: green mapped to Low Drop Precedence (2’b01), yellow to Medium
1879 * (2’b10) and red to High (2’b11). Marking needs to be explicitly enabled
1880 * for each color; when not enabled for a given color, the DSCP field of all
1881 * packets with that color is left as is.
1883 * @param[in] port_id
1884 * The port identifier of the Ethernet device.
1885 * @param[in] mark_green
1886 * Set to non-zero value to enable marking of green packets and to zero to
1888 * @param[in] mark_yellow
1889 * Set to non-zero value to enable marking of yellow packets and to zero to
1891 * @param[in] mark_red
1892 * Set to non-zero value to enable marking of red packets and to zero to
1895 * Error details. Filled in only on error, when not NULL.
1897 * 0 on success, non-zero error code otherwise.
1899 * @see struct rte_tm_capabilities::mark_ip_dscp_supported
1902 rte_tm_mark_ip_dscp(uint16_t port_id,
1906 struct rte_tm_error *error);
1912 #endif /* __INCLUDE_RTE_TM_H__ */