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>
54 #include <rte_meter.h>
61 * Ethernet framing overhead.
63 * Overhead fields per Ethernet frame:
64 * 1. Preamble: 7 bytes;
65 * 2. Start of Frame Delimiter (SFD): 1 byte;
66 * 3. Inter-Frame Gap (IFG): 12 bytes.
68 * One of the typical values for the *pkt_length_adjust* field of the shaper
71 * @see struct rte_tm_shaper_params
73 #define RTE_TM_ETH_FRAMING_OVERHEAD 20
76 * Ethernet framing overhead including the Frame Check Sequence (FCS) field.
77 * Useful when FCS is generated and added at the end of the Ethernet frame on
78 * TX side without any SW intervention.
80 * One of the typical values for the pkt_length_adjust field of the shaper
83 * @see struct rte_tm_shaper_params
85 #define RTE_TM_ETH_FRAMING_OVERHEAD_FCS 24
88 * Invalid WRED profile ID.
90 * @see struct rte_tm_node_params
91 * @see rte_tm_node_add()
92 * @see rte_tm_node_wred_context_update()
94 #define RTE_TM_WRED_PROFILE_ID_NONE UINT32_MAX
97 *Invalid shaper profile ID.
99 * @see struct rte_tm_node_params
100 * @see rte_tm_node_add()
101 * @see rte_tm_node_shaper_update()
103 #define RTE_TM_SHAPER_PROFILE_ID_NONE UINT32_MAX
106 * Node ID for the parent of the root node.
108 * @see rte_tm_node_add()
110 #define RTE_TM_NODE_ID_NULL UINT32_MAX
113 * Node level ID used to disable level ID checking.
115 * @see rte_tm_node_add()
117 #define RTE_TM_NODE_LEVEL_ID_ANY UINT32_MAX
119 /* New rte_color is defined and used to deprecate rte_tm_color soon. */
120 #define rte_tm_color rte_color
121 #define RTE_TM_GREEN RTE_COLOR_GREEN
122 #define RTE_TM_YELLOW RTE_COLOR_YELLOW
123 #define RTE_TM_RED RTE_COLOR_RED
124 #define RTE_TM_COLORS RTE_COLORS
127 * Node statistics counter type
129 enum rte_tm_stats_type {
130 /** Number of packets scheduled from current node. */
131 RTE_TM_STATS_N_PKTS = 1 << 0,
133 /** Number of bytes scheduled from current node. */
134 RTE_TM_STATS_N_BYTES = 1 << 1,
136 /** Number of green packets dropped by current leaf node. */
137 RTE_TM_STATS_N_PKTS_GREEN_DROPPED = 1 << 2,
139 /** Number of yellow packets dropped by current leaf node. */
140 RTE_TM_STATS_N_PKTS_YELLOW_DROPPED = 1 << 3,
142 /** Number of red packets dropped by current leaf node. */
143 RTE_TM_STATS_N_PKTS_RED_DROPPED = 1 << 4,
145 /** Number of green bytes dropped by current leaf node. */
146 RTE_TM_STATS_N_BYTES_GREEN_DROPPED = 1 << 5,
148 /** Number of yellow bytes dropped by current leaf node. */
149 RTE_TM_STATS_N_BYTES_YELLOW_DROPPED = 1 << 6,
151 /** Number of red bytes dropped by current leaf node. */
152 RTE_TM_STATS_N_BYTES_RED_DROPPED = 1 << 7,
154 /** Number of packets currently waiting in the packet queue of current
157 RTE_TM_STATS_N_PKTS_QUEUED = 1 << 8,
159 /** Number of bytes currently waiting in the packet queue of current
162 RTE_TM_STATS_N_BYTES_QUEUED = 1 << 9,
166 * Node statistics counters
168 struct rte_tm_node_stats {
169 /** Number of packets scheduled from current node. */
172 /** Number of bytes scheduled from current node. */
175 /** Statistics counters for leaf nodes only. */
177 /** Number of packets dropped by current leaf node per each
180 uint64_t n_pkts_dropped[RTE_TM_COLORS];
182 /** Number of bytes dropped by current leaf node per each
185 uint64_t n_bytes_dropped[RTE_TM_COLORS];
187 /** Number of packets currently waiting in the packet queue of
190 uint64_t n_pkts_queued;
192 /** Number of bytes currently waiting in the packet queue of
195 uint64_t n_bytes_queued;
200 * Traffic manager dynamic updates
202 enum rte_tm_dynamic_update_type {
203 /** Dynamic parent node update. The new parent node is located on same
204 * hierarchy level as the former parent node. Consequently, the node
205 * whose parent is changed preserves its hierarchy level.
207 RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL = 1 << 0,
209 /** Dynamic parent node update. The new parent node is located on
210 * different hierarchy level than the former parent node. Consequently,
211 * the node whose parent is changed also changes its hierarchy level.
213 RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL = 1 << 1,
215 /** Dynamic node add/delete. */
216 RTE_TM_UPDATE_NODE_ADD_DELETE = 1 << 2,
218 /** Suspend/resume nodes. */
219 RTE_TM_UPDATE_NODE_SUSPEND_RESUME = 1 << 3,
221 /** Dynamic switch between byte-based and packet-based WFQ weights. */
222 RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE = 1 << 4,
224 /** Dynamic update on number of SP priorities. */
225 RTE_TM_UPDATE_NODE_N_SP_PRIORITIES = 1 << 5,
227 /** Dynamic update of congestion management mode for leaf nodes. */
228 RTE_TM_UPDATE_NODE_CMAN = 1 << 6,
230 /** Dynamic update of the set of enabled stats counter types. */
231 RTE_TM_UPDATE_NODE_STATS = 1 << 7,
235 * Traffic manager capabilities
237 struct rte_tm_capabilities {
238 /** Maximum number of nodes. */
239 uint32_t n_nodes_max;
241 /** Maximum number of levels (i.e. number of nodes connecting the root
242 * node with any leaf node, including the root and the leaf).
244 uint32_t n_levels_max;
246 /** When non-zero, this flag indicates that all the non-leaf nodes
247 * (with the exception of the root node) have identical capability set.
249 int non_leaf_nodes_identical;
251 /** When non-zero, this flag indicates that all the leaf nodes have
252 * identical capability set.
254 int leaf_nodes_identical;
256 /** Maximum number of shapers, either private or shared. In case the
257 * implementation does not share any resources between private and
258 * shared shapers, it is typically equal to the sum of
259 * *shaper_private_n_max* and *shaper_shared_n_max*. The
260 * value of zero indicates that traffic shaping is not supported.
262 uint32_t shaper_n_max;
264 /** Maximum number of private shapers. Indicates the maximum number of
265 * nodes that can concurrently have their private shaper enabled. The
266 * value of zero indicates that private shapers are not supported.
268 uint32_t shaper_private_n_max;
270 /** Maximum number of private shapers that support dual rate shaping.
271 * Indicates the maximum number of nodes that can concurrently have
272 * their private shaper enabled with dual rate support. Only valid when
273 * private shapers are supported. The value of zero indicates that dual
274 * rate shaping is not available for private shapers. The maximum value
275 * is *shaper_private_n_max*.
277 int shaper_private_dual_rate_n_max;
279 /** Minimum committed/peak rate (bytes per second) for any private
280 * shaper. Valid only when private shapers are supported.
282 uint64_t shaper_private_rate_min;
284 /** Maximum committed/peak rate (bytes per second) for any private
285 * shaper. Valid only when private shapers are supported.
287 uint64_t shaper_private_rate_max;
289 /** Maximum number of shared shapers. The value of zero indicates that
290 * shared shapers are not supported.
292 uint32_t shaper_shared_n_max;
294 /** Maximum number of nodes that can share the same shared shaper.
295 * Only valid when shared shapers are supported.
297 uint32_t shaper_shared_n_nodes_per_shaper_max;
299 /** Maximum number of shared shapers a node can be part of. This
300 * parameter indicates that there is at least one node that can be
301 * configured with this many shared shapers, which might not be true for
302 * all the nodes. Only valid when shared shapers are supported, in which
303 * case it ranges from 1 to *shaper_shared_n_max*.
305 uint32_t shaper_shared_n_shapers_per_node_max;
307 /** Maximum number of shared shapers that can be configured with dual
308 * rate shaping. The value of zero indicates that dual rate shaping
309 * support is not available for shared shapers.
311 uint32_t shaper_shared_dual_rate_n_max;
313 /** Minimum committed/peak rate (bytes per second) for any shared
314 * shaper. Only valid when shared shapers are supported.
316 uint64_t shaper_shared_rate_min;
318 /** Maximum committed/peak rate (bytes per second) for any shared
319 * shaper. Only valid when shared shapers are supported.
321 uint64_t shaper_shared_rate_max;
323 /** Minimum value allowed for packet length adjustment for any private
326 int shaper_pkt_length_adjust_min;
328 /** Maximum value allowed for packet length adjustment for any private
331 int shaper_pkt_length_adjust_max;
333 /** Maximum number of children nodes. This parameter indicates that
334 * there is at least one non-leaf node that can be configured with this
335 * many children nodes, which might not be true for all the non-leaf
338 uint32_t sched_n_children_max;
340 /** Maximum number of supported priority levels. This parameter
341 * indicates that there is at least one non-leaf node that can be
342 * configured with this many priority levels for managing its children
343 * nodes, which might not be true for all the non-leaf nodes. The value
344 * of zero is invalid. The value of 1 indicates that only priority 0 is
345 * supported, which essentially means that Strict Priority (SP)
346 * algorithm is not supported.
348 uint32_t sched_sp_n_priorities_max;
350 /** Maximum number of sibling nodes that can have the same priority at
351 * any given time, i.e. maximum size of the WFQ sibling node group. This
352 * parameter indicates there is at least one non-leaf node that meets
353 * this condition, which might not be true for all the non-leaf nodes.
354 * The value of zero is invalid. The value of 1 indicates that WFQ
355 * algorithm is not supported. The maximum value is
356 * *sched_n_children_max*.
358 uint32_t sched_wfq_n_children_per_group_max;
360 /** Maximum number of priority levels that can have more than one child
361 * node at any given time, i.e. maximum number of WFQ sibling node
362 * groups that have two or more members. This parameter indicates there
363 * is at least one non-leaf node that meets this condition, which might
364 * not be true for all the non-leaf nodes. The value of zero states that
365 * WFQ algorithm is not supported. The value of 1 indicates that
366 * (*sched_sp_n_priorities_max* - 1) priority levels have at most one
367 * child node, so there can be only one priority level with two or
368 * more sibling nodes making up a WFQ group. The maximum value is:
369 * min(floor(*sched_n_children_max* / 2), *sched_sp_n_priorities_max*).
371 uint32_t sched_wfq_n_groups_max;
373 /** Maximum WFQ weight. The value of 1 indicates that all sibling nodes
374 * with same priority have the same WFQ weight, so WFQ is reduced to FQ.
376 uint32_t sched_wfq_weight_max;
378 /** WRED packet mode support. When non-zero, this parameter indicates
379 * that there is atleast one leaf node that supports the WRED packet
380 * mode, which might not be true for all the leaf nodes. In packet
381 * mode, the WRED thresholds specify the queue length in packets, as
384 int cman_wred_packet_mode_supported;
386 /** WRED byte mode support. When non-zero, this parameter indicates that
387 * there is atleast one leaf node that supports the WRED byte mode,
388 * which might not be true for all the leaf nodes. In byte mode, the
389 * WRED thresholds specify the queue length in bytes, as opposed to
392 int cman_wred_byte_mode_supported;
394 /** Head drop algorithm support. When non-zero, this parameter
395 * indicates that there is at least one leaf node that supports the head
396 * drop algorithm, which might not be true for all the leaf nodes.
398 int cman_head_drop_supported;
400 /** Maximum number of WRED contexts, either private or shared. In case
401 * the implementation does not share any resources between private and
402 * shared WRED contexts, it is typically equal to the sum of
403 * *cman_wred_context_private_n_max* and
404 * *cman_wred_context_shared_n_max*. The value of zero indicates that
405 * WRED is not supported.
407 uint32_t cman_wred_context_n_max;
409 /** Maximum number of private WRED contexts. Indicates the maximum
410 * number of leaf nodes that can concurrently have their private WRED
411 * context enabled. The value of zero indicates that private WRED
412 * contexts are not supported.
414 uint32_t cman_wred_context_private_n_max;
416 /** Maximum number of shared WRED contexts. The value of zero
417 * indicates that shared WRED contexts are not supported.
419 uint32_t cman_wred_context_shared_n_max;
421 /** Maximum number of leaf nodes that can share the same WRED context.
422 * Only valid when shared WRED contexts are supported.
424 uint32_t cman_wred_context_shared_n_nodes_per_context_max;
426 /** Maximum number of shared WRED contexts a leaf node can be part of.
427 * This parameter indicates that there is at least one leaf node that
428 * can be configured with this many shared WRED contexts, which might
429 * not be true for all the leaf nodes. Only valid when shared WRED
430 * contexts are supported, in which case it ranges from 1 to
431 * *cman_wred_context_shared_n_max*.
433 uint32_t cman_wred_context_shared_n_contexts_per_node_max;
435 /** Support for VLAN DEI packet marking (per color). */
436 int mark_vlan_dei_supported[RTE_TM_COLORS];
438 /** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */
439 int mark_ip_ecn_tcp_supported[RTE_TM_COLORS];
441 /** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */
442 int mark_ip_ecn_sctp_supported[RTE_TM_COLORS];
444 /** Support for IPv4/IPv6 DSCP packet marking (per color). */
445 int mark_ip_dscp_supported[RTE_TM_COLORS];
447 /** Set of supported dynamic update operations.
448 * @see enum rte_tm_dynamic_update_type
450 uint64_t dynamic_update_mask;
452 /** Set of supported statistics counter types.
453 * @see enum rte_tm_stats_type
459 * Traffic manager level capabilities
461 struct rte_tm_level_capabilities {
462 /** Maximum number of nodes for the current hierarchy level. */
463 uint32_t n_nodes_max;
465 /** Maximum number of non-leaf nodes for the current hierarchy level.
466 * The value of 0 indicates that current level only supports leaf
467 * nodes. The maximum value is *n_nodes_max*.
469 uint32_t n_nodes_nonleaf_max;
471 /** Maximum number of leaf nodes for the current hierarchy level. The
472 * value of 0 indicates that current level only supports non-leaf
473 * nodes. The maximum value is *n_nodes_max*.
475 uint32_t n_nodes_leaf_max;
477 /** When non-zero, this flag indicates that all the non-leaf nodes on
478 * this level have identical capability set. Valid only when
479 * *n_nodes_nonleaf_max* is non-zero.
481 int non_leaf_nodes_identical;
483 /** When non-zero, this flag indicates that all the leaf nodes on this
484 * level have identical capability set. Valid only when
485 * *n_nodes_leaf_max* is non-zero.
487 int leaf_nodes_identical;
491 /** Items valid only for the non-leaf nodes on this level. */
493 /** Private shaper support. When non-zero, it indicates
494 * there is at least one non-leaf node on this level
495 * with private shaper support, which may not be the
496 * case for all the non-leaf nodes on this level.
498 int shaper_private_supported;
500 /** Dual rate support for private shaper. Valid only
501 * when private shaper is supported for the non-leaf
502 * nodes on the current level. When non-zero, it
503 * indicates there is at least one non-leaf node on this
504 * level with dual rate private shaper support, which
505 * may not be the case for all the non-leaf nodes on
508 int shaper_private_dual_rate_supported;
510 /** Minimum committed/peak rate (bytes per second) for
511 * private shapers of the non-leaf nodes of this level.
512 * Valid only when private shaper is supported on this
515 uint64_t shaper_private_rate_min;
517 /** Maximum committed/peak rate (bytes per second) for
518 * private shapers of the non-leaf nodes on this level.
519 * Valid only when private shaper is supported on this
522 uint64_t shaper_private_rate_max;
524 /** Maximum number of shared shapers that any non-leaf
525 * node on this level can be part of. The value of zero
526 * indicates that shared shapers are not supported by
527 * the non-leaf nodes on this level. When non-zero, it
528 * indicates there is at least one non-leaf node on this
529 * level that meets this condition, which may not be the
530 * case for all the non-leaf nodes on this level.
532 uint32_t shaper_shared_n_max;
534 /** Maximum number of children nodes. This parameter
535 * indicates that there is at least one non-leaf node on
536 * this level that can be configured with this many
537 * children nodes, which might not be true for all the
538 * non-leaf nodes on this level.
540 uint32_t sched_n_children_max;
542 /** Maximum number of supported priority levels. This
543 * parameter indicates that there is at least one
544 * non-leaf node on this level that can be configured
545 * with this many priority levels for managing its
546 * children nodes, which might not be true for all the
547 * non-leaf nodes on this level. The value of zero is
548 * invalid. The value of 1 indicates that only priority
549 * 0 is supported, which essentially means that Strict
550 * Priority (SP) algorithm is not supported on this
553 uint32_t sched_sp_n_priorities_max;
555 /** Maximum number of sibling nodes that can have the
556 * same priority at any given time, i.e. maximum size of
557 * the WFQ sibling node group. This parameter indicates
558 * there is at least one non-leaf node on this level
559 * that meets this condition, which may not be true for
560 * all the non-leaf nodes on this level. The value of
561 * zero is invalid. The value of 1 indicates that WFQ
562 * algorithm is not supported on this level. The maximum
563 * value is *sched_n_children_max*.
565 uint32_t sched_wfq_n_children_per_group_max;
567 /** Maximum number of priority levels that can have
568 * more than one child node at any given time, i.e.
569 * maximum number of WFQ sibling node groups that
570 * have two or more members. This parameter indicates
571 * there is at least one non-leaf node on this level
572 * that meets this condition, which might not be true
573 * for all the non-leaf nodes. The value of zero states
574 * that WFQ algorithm is not supported on this level.
575 * The value of 1 indicates that
576 * (*sched_sp_n_priorities_max* - 1) priority levels on
577 * this level have at most one child node, so there can
578 * be only one priority level with two or more sibling
579 * nodes making up a WFQ group on this level. The
581 * min(floor(*sched_n_children_max* / 2),
582 * *sched_sp_n_priorities_max*).
584 uint32_t sched_wfq_n_groups_max;
586 /** Maximum WFQ weight. The value of 1 indicates that
587 * all sibling nodes on this level with same priority
588 * have the same WFQ weight, so on this level WFQ is
591 uint32_t sched_wfq_weight_max;
593 /** Mask of statistics counter types supported by the
594 * non-leaf nodes on this level. Every supported
595 * statistics counter type is supported by at least one
596 * non-leaf node on this level, which may not be true
597 * for all the non-leaf nodes on this level.
598 * @see enum rte_tm_stats_type
603 /** Items valid only for the leaf nodes on this level. */
605 /** Private shaper support. When non-zero, it indicates
606 * there is at least one leaf node on this level with
607 * private shaper support, which may not be the case for
608 * all the leaf nodes on this level.
610 int shaper_private_supported;
612 /** Dual rate support for private shaper. Valid only
613 * when private shaper is supported for the leaf nodes
614 * on this level. When non-zero, it indicates there is
615 * at least one leaf node on this level with dual rate
616 * private shaper support, which may not be the case for
617 * all the leaf nodes on this level.
619 int shaper_private_dual_rate_supported;
621 /** Minimum committed/peak rate (bytes per second) for
622 * private shapers of the leaf nodes of this level.
623 * Valid only when private shaper is supported for the
624 * leaf nodes on this level.
626 uint64_t shaper_private_rate_min;
628 /** Maximum committed/peak rate (bytes per second) for
629 * private shapers of the leaf nodes on this level.
630 * Valid only when private shaper is supported for the
631 * leaf nodes on this level.
633 uint64_t shaper_private_rate_max;
635 /** Maximum number of shared shapers that any leaf node
636 * on this level can be part of. The value of zero
637 * indicates that shared shapers are not supported by
638 * the leaf nodes on this level. When non-zero, it
639 * indicates there is at least one leaf node on this
640 * level that meets this condition, which may not be the
641 * case for all the leaf nodes on this level.
643 uint32_t shaper_shared_n_max;
645 /** WRED packet mode support. When non-zero, this
646 * parameter indicates that there is atleast one leaf
647 * node on this level that supports the WRED packet
648 * mode, which might not be true for all the leaf
649 * nodes. In packet mode, the WRED thresholds specify
650 * the queue length in packets, as opposed to bytes.
652 int cman_wred_packet_mode_supported;
654 /** WRED byte mode support. When non-zero, this
655 * parameter indicates that there is atleast one leaf
656 * node on this level that supports the WRED byte mode,
657 * which might not be true for all the leaf nodes. In
658 * byte mode, the WRED thresholds specify the queue
659 * length in bytes, as opposed to packets.
661 int cman_wred_byte_mode_supported;
663 /** Head drop algorithm support. When non-zero, this
664 * parameter indicates that there is at least one leaf
665 * node on this level that supports the head drop
666 * algorithm, which might not be true for all the leaf
667 * nodes on this level.
669 int cman_head_drop_supported;
671 /** Private WRED context support. When non-zero, it
672 * indicates there is at least one node on this level
673 * with private WRED context support, which may not be
674 * true for all the leaf nodes on this level.
676 int cman_wred_context_private_supported;
678 /** Maximum number of shared WRED contexts that any
679 * leaf node on this level can be part of. The value of
680 * zero indicates that shared WRED contexts are not
681 * supported by the leaf nodes on this level. When
682 * non-zero, it indicates there is at least one leaf
683 * node on this level that meets this condition, which
684 * may not be the case for all the leaf nodes on this
687 uint32_t cman_wred_context_shared_n_max;
689 /** Mask of statistics counter types supported by the
690 * leaf nodes on this level. Every supported statistics
691 * counter type is supported by at least one leaf node
692 * on this level, which may not be true for all the leaf
693 * nodes on this level.
694 * @see enum rte_tm_stats_type
702 * Traffic manager node capabilities
704 struct rte_tm_node_capabilities {
705 /** Private shaper support for the current node. */
706 int shaper_private_supported;
708 /** Dual rate shaping support for private shaper of current node.
709 * Valid only when private shaper is supported by the current node.
711 int shaper_private_dual_rate_supported;
713 /** Minimum committed/peak rate (bytes per second) for private
714 * shaper of current node. Valid only when private shaper is supported
715 * by the current node.
717 uint64_t shaper_private_rate_min;
719 /** Maximum committed/peak rate (bytes per second) for private
720 * shaper of current node. Valid only when private shaper is supported
721 * by the current node.
723 uint64_t shaper_private_rate_max;
725 /** Maximum number of shared shapers the current node can be part of.
726 * The value of zero indicates that shared shapers are not supported by
729 uint32_t shaper_shared_n_max;
733 /** Items valid only for non-leaf nodes. */
735 /** Maximum number of children nodes. */
736 uint32_t sched_n_children_max;
738 /** Maximum number of supported priority levels. The
739 * value of zero is invalid. The value of 1 indicates
740 * that only priority 0 is supported, which essentially
741 * means that Strict Priority (SP) algorithm is not
744 uint32_t sched_sp_n_priorities_max;
746 /** Maximum number of sibling nodes that can have the
747 * same priority at any given time, i.e. maximum size
748 * of the WFQ sibling node group. The value of zero
749 * is invalid. The value of 1 indicates that WFQ
750 * algorithm is not supported. The maximum value is
751 * *sched_n_children_max*.
753 uint32_t sched_wfq_n_children_per_group_max;
755 /** Maximum number of priority levels that can have
756 * more than one child node at any given time, i.e.
757 * maximum number of WFQ sibling node groups that have
758 * two or more members. The value of zero states that
759 * WFQ algorithm is not supported. The value of 1
760 * indicates that (*sched_sp_n_priorities_max* - 1)
761 * priority levels have at most one child node, so there
762 * can be only one priority level with two or more
763 * sibling nodes making up a WFQ group. The maximum
764 * value is: min(floor(*sched_n_children_max* / 2),
765 * *sched_sp_n_priorities_max*).
767 uint32_t sched_wfq_n_groups_max;
769 /** Maximum WFQ weight. The value of 1 indicates that
770 * all sibling nodes with same priority have the same
771 * WFQ weight, so WFQ is reduced to FQ.
773 uint32_t sched_wfq_weight_max;
776 /** Items valid only for leaf nodes. */
778 /** WRED packet mode support for current node. */
779 int cman_wred_packet_mode_supported;
781 /** WRED byte mode support for current node. */
782 int cman_wred_byte_mode_supported;
784 /** Head drop algorithm support for current node. */
785 int cman_head_drop_supported;
787 /** Private WRED context support for current node. */
788 int cman_wred_context_private_supported;
790 /** Maximum number of shared WRED contexts the current
791 * node can be part of. The value of zero indicates that
792 * shared WRED contexts are not supported by the current
795 uint32_t cman_wred_context_shared_n_max;
799 /** Mask of statistics counter types supported by the current node.
800 * @see enum rte_tm_stats_type
806 * Congestion management (CMAN) mode
808 * This is used for controlling the admission of packets into a packet queue or
809 * group of packet queues on congestion. On request of writing a new packet
810 * into the current queue while the queue is full, the *tail drop* algorithm
811 * drops the new packet while leaving the queue unmodified, as opposed to *head
812 * drop* algorithm, which drops the packet at the head of the queue (the oldest
813 * packet waiting in the queue) and admits the new packet at the tail of the
816 * The *Random Early Detection (RED)* algorithm works by proactively dropping
817 * more and more input packets as the queue occupancy builds up. When the queue
818 * is full or almost full, RED effectively works as *tail drop*. The *Weighted
819 * RED* algorithm uses a separate set of RED thresholds for each packet color.
821 enum rte_tm_cman_mode {
822 RTE_TM_CMAN_TAIL_DROP = 0, /**< Tail drop */
823 RTE_TM_CMAN_HEAD_DROP, /**< Head drop */
824 RTE_TM_CMAN_WRED, /**< Weighted Random Early Detection (WRED) */
828 * Random Early Detection (RED) profile
830 struct rte_tm_red_params {
831 /** Minimum queue threshold */
834 /** Maximum queue threshold */
837 /** Inverse of packet marking probability maximum value (maxp), i.e.
838 * maxp_inv = 1 / maxp
842 /** Negated log2 of queue weight (wq), i.e. wq = 1 / (2 ^ wq_log2) */
847 * Weighted RED (WRED) profile
849 * Multiple WRED contexts can share the same WRED profile. Each leaf node with
850 * WRED enabled as its congestion management mode has zero or one private WRED
851 * context (only one leaf node using it) and/or zero, one or several shared
852 * WRED contexts (multiple leaf nodes use the same WRED context). A private
853 * WRED context is used to perform congestion management for a single leaf
854 * node, while a shared WRED context is used to perform congestion management
855 * for a group of leaf nodes.
857 * @see struct rte_tm_capabilities::cman_wred_packet_mode_supported
858 * @see struct rte_tm_capabilities::cman_wred_byte_mode_supported
860 struct rte_tm_wred_params {
861 /** One set of RED parameters per packet color */
862 struct rte_tm_red_params red_params[RTE_TM_COLORS];
864 /** When non-zero, the *min_th* and *max_th* thresholds are specified
865 * in packets (WRED packet mode). When zero, the *min_th* and *max_th*
866 * thresholds are specified in bytes (WRED byte mode)
874 struct rte_tm_token_bucket {
875 /** Token bucket rate (bytes per second) */
878 /** Token bucket size (bytes), a.k.a. max burst size */
883 * Shaper (rate limiter) profile
885 * Multiple shaper instances can share the same shaper profile. Each node has
886 * zero or one private shaper (only one node using it) and/or zero, one or
887 * several shared shapers (multiple nodes use the same shaper instance).
888 * A private shaper is used to perform traffic shaping for a single node, while
889 * a shared shaper is used to perform traffic shaping for a group of nodes.
891 * Single rate shapers use a single token bucket. A single rate shaper can be
892 * configured by setting the rate of the committed bucket to zero, which
893 * effectively disables this bucket. The peak bucket is used to limit the rate
894 * and the burst size for the current shaper.
896 * Dual rate shapers use both the committed and the peak token buckets. The
897 * rate of the peak bucket has to be bigger than zero, as well as greater than
898 * or equal to the rate of the committed bucket.
900 struct rte_tm_shaper_params {
901 /** Committed token bucket */
902 struct rte_tm_token_bucket committed;
904 /** Peak token bucket */
905 struct rte_tm_token_bucket peak;
907 /** Signed value to be added to the length of each packet for the
908 * purpose of shaping. Can be used to correct the packet length with
909 * the framing overhead bytes that are also consumed on the wire (e.g.
910 * RTE_TM_ETH_FRAMING_OVERHEAD_FCS).
912 int32_t pkt_length_adjust;
918 * Each non-leaf node has multiple inputs (its children nodes) and single output
919 * (which is input to its parent node). It arbitrates its inputs using Strict
920 * Priority (SP) and Weighted Fair Queuing (WFQ) algorithms to schedule input
921 * packets to its output while observing its shaping (rate limiting)
924 * Algorithms such as Weighted Round Robin (WRR), Byte-level WRR, Deficit WRR
925 * (DWRR), etc. are considered approximations of the WFQ ideal and are
926 * assimilated to WFQ, although an associated implementation-dependent trade-off
927 * on accuracy, performance and resource usage might exist.
929 * Children nodes with different priorities are scheduled using the SP algorithm
930 * based on their priority, with zero (0) as the highest priority. Children with
931 * the same priority are scheduled using the WFQ algorithm according to their
932 * weights. The WFQ weight of a given child node is relative to the sum of the
933 * weights of all its sibling nodes that have the same priority, with one (1) as
934 * the lowest weight. For each SP priority, the WFQ weight mode can be set as
935 * either byte-based or packet-based.
937 * Each leaf node sits on top of a TX queue of the current Ethernet port. Hence,
938 * the leaf nodes are predefined, with their node IDs set to 0 .. (N-1), where N
939 * is the number of TX queues configured for the current Ethernet port. The
940 * non-leaf nodes have their IDs generated by the application.
942 struct rte_tm_node_params {
943 /** Shaper profile for the private shaper. The absence of the private
944 * shaper for the current node is indicated by setting this parameter
945 * to RTE_TM_SHAPER_PROFILE_ID_NONE.
947 uint32_t shaper_profile_id;
949 /** User allocated array of valid shared shaper IDs. */
950 uint32_t *shared_shaper_id;
952 /** Number of shared shaper IDs in the *shared_shaper_id* array. */
953 uint32_t n_shared_shapers;
957 /** Parameters only valid for non-leaf nodes. */
959 /** WFQ weight mode for each SP priority. When NULL, it
960 * indicates that WFQ is to be used for all priorities.
961 * When non-NULL, it points to a pre-allocated array of
962 * *n_sp_priorities* values, with non-zero value for
963 * byte-mode and zero for packet-mode.
965 int *wfq_weight_mode;
967 /** Number of SP priorities. */
968 uint32_t n_sp_priorities;
971 /** Parameters only valid for leaf nodes. */
973 /** Congestion management mode */
974 enum rte_tm_cman_mode cman;
976 /** WRED parameters (only valid when *cman* is set to
980 /** WRED profile for private WRED context. The
981 * absence of a private WRED context for the
982 * current leaf node is indicated by value
983 * RTE_TM_WRED_PROFILE_ID_NONE.
985 uint32_t wred_profile_id;
987 /** User allocated array of shared WRED context
988 * IDs. When set to NULL, it indicates that the
989 * current leaf node should not currently be
990 * part of any shared WRED contexts.
992 uint32_t *shared_wred_context_id;
994 /** Number of elements in the
995 * *shared_wred_context_id* array. Only valid
996 * when *shared_wred_context_id* is non-NULL,
997 * in which case it should be non-zero.
999 uint32_t n_shared_wred_contexts;
1004 /** Mask of statistics counter types to be enabled for this node. This
1005 * needs to be a subset of the statistics counter types available for
1006 * the current node. Any statistics counter type not included in this
1007 * set is to be disabled for the current node.
1008 * @see enum rte_tm_stats_type
1010 uint64_t stats_mask;
1014 * Verbose error types.
1016 * Most of them provide the type of the object referenced by struct
1017 * rte_tm_error::cause.
1019 enum rte_tm_error_type {
1020 RTE_TM_ERROR_TYPE_NONE, /**< No error. */
1021 RTE_TM_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
1022 RTE_TM_ERROR_TYPE_CAPABILITIES,
1023 RTE_TM_ERROR_TYPE_LEVEL_ID,
1024 RTE_TM_ERROR_TYPE_WRED_PROFILE,
1025 RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN,
1026 RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW,
1027 RTE_TM_ERROR_TYPE_WRED_PROFILE_RED,
1028 RTE_TM_ERROR_TYPE_WRED_PROFILE_ID,
1029 RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID,
1030 RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
1031 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE,
1032 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE,
1033 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
1034 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
1035 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN,
1036 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
1037 RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID,
1038 RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID,
1039 RTE_TM_ERROR_TYPE_NODE_PRIORITY,
1040 RTE_TM_ERROR_TYPE_NODE_WEIGHT,
1041 RTE_TM_ERROR_TYPE_NODE_PARAMS,
1042 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID,
1043 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID,
1044 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS,
1045 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE,
1046 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES,
1047 RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN,
1048 RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID,
1049 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID,
1050 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS,
1051 RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
1052 RTE_TM_ERROR_TYPE_NODE_ID,
1056 * Verbose error structure definition.
1058 * This object is normally allocated by applications and set by PMDs, the
1059 * message points to a constant string which does not need to be freed by
1060 * the application, however its pointer can be considered valid only as long
1061 * as its associated DPDK port remains configured. Closing the underlying
1062 * device or unloading the PMD invalidates it.
1064 * Both cause and message may be NULL regardless of the error type.
1066 struct rte_tm_error {
1067 enum rte_tm_error_type type; /**< Cause field and error type. */
1068 const void *cause; /**< Object responsible for the error. */
1069 const char *message; /**< Human-readable error message. */
1073 * Traffic manager get number of leaf nodes
1075 * Each leaf node sits on on top of a TX queue of the current Ethernet port.
1076 * Therefore, the set of leaf nodes is predefined, their number is always equal
1077 * to N (where N is the number of TX queues configured for the current port)
1078 * and their IDs are 0 .. (N-1).
1080 * @param[in] port_id
1081 * The port identifier of the Ethernet device.
1082 * @param[out] n_leaf_nodes
1083 * Number of leaf nodes for the current port.
1085 * Error details. Filled in only on error, when not NULL.
1087 * 0 on success, non-zero error code otherwise.
1090 rte_tm_get_number_of_leaf_nodes(uint16_t port_id,
1091 uint32_t *n_leaf_nodes,
1092 struct rte_tm_error *error);
1095 * Traffic manager node ID validate and type (i.e. leaf or non-leaf) get
1097 * The leaf nodes have predefined IDs in the range of 0 .. (N-1), where N is
1098 * the number of TX queues of the current Ethernet port. The non-leaf nodes
1099 * have their IDs generated by the application outside of the above range,
1100 * which is reserved for leaf nodes.
1102 * @param[in] port_id
1103 * The port identifier of the Ethernet device.
1104 * @param[in] node_id
1105 * Node ID value. Needs to be valid.
1106 * @param[out] is_leaf
1107 * Set to non-zero value when node is leaf and to zero otherwise (non-leaf).
1109 * Error details. Filled in only on error, when not NULL.
1111 * 0 on success, non-zero error code otherwise.
1114 rte_tm_node_type_get(uint16_t port_id,
1117 struct rte_tm_error *error);
1120 * Traffic manager capabilities get
1122 * @param[in] port_id
1123 * The port identifier of the Ethernet device.
1125 * Traffic manager capabilities. Needs to be pre-allocated and valid.
1127 * Error details. Filled in only on error, when not NULL.
1129 * 0 on success, non-zero error code otherwise.
1132 rte_tm_capabilities_get(uint16_t port_id,
1133 struct rte_tm_capabilities *cap,
1134 struct rte_tm_error *error);
1137 * Traffic manager level capabilities get
1139 * @param[in] port_id
1140 * The port identifier of the Ethernet device.
1141 * @param[in] level_id
1142 * The hierarchy level identifier. The value of 0 identifies the level of the
1145 * Traffic manager level capabilities. Needs to be pre-allocated and valid.
1147 * Error details. Filled in only on error, when not NULL.
1149 * 0 on success, non-zero error code otherwise.
1152 rte_tm_level_capabilities_get(uint16_t port_id,
1154 struct rte_tm_level_capabilities *cap,
1155 struct rte_tm_error *error);
1158 * Traffic manager node capabilities get
1160 * @param[in] port_id
1161 * The port identifier of the Ethernet device.
1162 * @param[in] node_id
1163 * Node ID. Needs to be valid.
1165 * Traffic manager node capabilities. Needs to be pre-allocated and valid.
1167 * Error details. Filled in only on error, when not NULL.
1169 * 0 on success, non-zero error code otherwise.
1172 rte_tm_node_capabilities_get(uint16_t port_id,
1174 struct rte_tm_node_capabilities *cap,
1175 struct rte_tm_error *error);
1178 * Traffic manager WRED profile add
1180 * Create a new WRED profile with ID set to *wred_profile_id*. The new profile
1181 * is used to create one or several WRED contexts.
1183 * @param[in] port_id
1184 * The port identifier of the Ethernet device.
1185 * @param[in] wred_profile_id
1186 * WRED profile ID for the new profile. Needs to be unused.
1187 * @param[in] profile
1188 * WRED profile parameters. Needs to be pre-allocated and valid.
1190 * Error details. Filled in only on error, when not NULL.
1192 * 0 on success, non-zero error code otherwise.
1194 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1197 rte_tm_wred_profile_add(uint16_t port_id,
1198 uint32_t wred_profile_id,
1199 struct rte_tm_wred_params *profile,
1200 struct rte_tm_error *error);
1203 * Traffic manager WRED profile delete
1205 * Delete an existing WRED profile. This operation fails when there is
1206 * currently at least one user (i.e. WRED context) of this WRED profile.
1208 * @param[in] port_id
1209 * The port identifier of the Ethernet device.
1210 * @param[in] wred_profile_id
1211 * WRED profile ID. Needs to be the valid.
1213 * Error details. Filled in only on error, when not NULL.
1215 * 0 on success, non-zero error code otherwise.
1217 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1220 rte_tm_wred_profile_delete(uint16_t port_id,
1221 uint32_t wred_profile_id,
1222 struct rte_tm_error *error);
1225 * Traffic manager shared WRED context add or update
1227 * When *shared_wred_context_id* is invalid, a new WRED context with this ID is
1228 * created by using the WRED profile identified by *wred_profile_id*.
1230 * When *shared_wred_context_id* is valid, this WRED context is no longer using
1231 * the profile previously assigned to it and is updated to use the profile
1232 * identified by *wred_profile_id*.
1234 * A valid shared WRED context can be assigned to several hierarchy leaf nodes
1235 * configured to use WRED as the congestion management mode.
1237 * @param[in] port_id
1238 * The port identifier of the Ethernet device.
1239 * @param[in] shared_wred_context_id
1240 * Shared WRED context ID
1241 * @param[in] wred_profile_id
1242 * WRED profile ID. Needs to be the valid.
1244 * Error details. Filled in only on error, when not NULL.
1246 * 0 on success, non-zero error code otherwise.
1248 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1251 rte_tm_shared_wred_context_add_update(uint16_t port_id,
1252 uint32_t shared_wred_context_id,
1253 uint32_t wred_profile_id,
1254 struct rte_tm_error *error);
1257 * Traffic manager shared WRED context delete
1259 * Delete an existing shared WRED context. This operation fails when there is
1260 * currently at least one user (i.e. hierarchy leaf node) of this shared WRED
1263 * @param[in] port_id
1264 * The port identifier of the Ethernet device.
1265 * @param[in] shared_wred_context_id
1266 * Shared WRED context 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::cman_wred_context_shared_n_max
1275 rte_tm_shared_wred_context_delete(uint16_t port_id,
1276 uint32_t shared_wred_context_id,
1277 struct rte_tm_error *error);
1280 * Traffic manager shaper profile add
1282 * Create a new shaper profile with ID set to *shaper_profile_id*. The new
1283 * shaper profile is used to create one or several shapers.
1285 * @param[in] port_id
1286 * The port identifier of the Ethernet device.
1287 * @param[in] shaper_profile_id
1288 * Shaper profile ID for the new profile. Needs to be unused.
1289 * @param[in] profile
1290 * Shaper profile parameters. Needs to be pre-allocated and valid.
1292 * Error details. Filled in only on error, when not NULL.
1294 * 0 on success, non-zero error code otherwise.
1296 * @see struct rte_tm_capabilities::shaper_n_max
1299 rte_tm_shaper_profile_add(uint16_t port_id,
1300 uint32_t shaper_profile_id,
1301 struct rte_tm_shaper_params *profile,
1302 struct rte_tm_error *error);
1305 * Traffic manager shaper profile delete
1307 * Delete an existing shaper profile. This operation fails when there is
1308 * currently at least one user (i.e. shaper) of this shaper profile.
1310 * @param[in] port_id
1311 * The port identifier of the Ethernet device.
1312 * @param[in] shaper_profile_id
1313 * Shaper profile ID. Needs to be the valid.
1315 * Error details. Filled in only on error, when not NULL.
1317 * 0 on success, non-zero error code otherwise.
1319 * @see struct rte_tm_capabilities::shaper_n_max
1322 rte_tm_shaper_profile_delete(uint16_t port_id,
1323 uint32_t shaper_profile_id,
1324 struct rte_tm_error *error);
1327 * Traffic manager shared shaper add or update
1329 * When *shared_shaper_id* is not a valid shared shaper ID, a new shared shaper
1330 * with this ID is created using the shaper profile identified by
1331 * *shaper_profile_id*.
1333 * When *shared_shaper_id* is a valid shared shaper ID, this shared shaper is
1334 * no longer using the shaper profile previously assigned to it and is updated
1335 * to use the shaper profile identified by *shaper_profile_id*.
1337 * @param[in] port_id
1338 * The port identifier of the Ethernet device.
1339 * @param[in] shared_shaper_id
1341 * @param[in] shaper_profile_id
1342 * Shaper profile 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
1351 rte_tm_shared_shaper_add_update(uint16_t port_id,
1352 uint32_t shared_shaper_id,
1353 uint32_t shaper_profile_id,
1354 struct rte_tm_error *error);
1357 * Traffic manager shared shaper delete
1359 * Delete an existing shared shaper. This operation fails when there is
1360 * currently at least one user (i.e. hierarchy node) of this shared shaper.
1362 * @param[in] port_id
1363 * The port identifier of the Ethernet device.
1364 * @param[in] shared_shaper_id
1365 * Shared shaper ID. Needs to be the valid.
1367 * Error details. Filled in only on error, when not NULL.
1369 * 0 on success, non-zero error code otherwise.
1371 * @see struct rte_tm_capabilities::shaper_shared_n_max
1374 rte_tm_shared_shaper_delete(uint16_t port_id,
1375 uint32_t shared_shaper_id,
1376 struct rte_tm_error *error);
1379 * Traffic manager node add
1381 * Create new node and connect it as child of an existing node. The new node is
1382 * further identified by *node_id*, which needs to be unused by any of the
1383 * existing nodes. The parent node is identified by *parent_node_id*, which
1384 * needs to be the valid ID of an existing non-leaf node. The parent node is
1385 * going to use the provided SP *priority* and WFQ *weight* to schedule its new
1388 * This function has to be called for both leaf and non-leaf nodes. In the case
1389 * of leaf nodes (i.e. *node_id* is within the range of 0 .. (N-1), with N as
1390 * the number of configured TX queues of the current port), the leaf node is
1391 * configured rather than created (as the set of leaf nodes is predefined) and
1392 * it is also connected as child of an existing node.
1394 * The first node that is added becomes the root node and all the nodes that
1395 * are subsequently added have to be added as descendants of the root node. The
1396 * parent of the root node has to be specified as RTE_TM_NODE_ID_NULL and there
1397 * can only be one node with this parent ID (i.e. the root node). Further
1398 * restrictions for root node: needs to be non-leaf, its private shaper profile
1399 * needs to be valid and single rate, cannot use any shared shapers.
1401 * When called before rte_tm_hierarchy_commit() invocation, this function is
1402 * typically used to define the initial start-up hierarchy for the port.
1403 * Provided that dynamic hierarchy updates are supported by the current port (as
1404 * advertised in the port capability set), this function can be also called
1405 * after the rte_tm_hierarchy_commit() invocation.
1407 * @param[in] port_id
1408 * The port identifier of the Ethernet device.
1409 * @param[in] node_id
1410 * Node ID. Needs to be unused by any of the existing nodes.
1411 * @param[in] parent_node_id
1412 * Parent node ID. Needs to be the valid.
1413 * @param[in] priority
1414 * Node priority. The highest node priority is zero. Used by the SP algorithm
1415 * running on the parent of the current node for scheduling this child node.
1417 * Node weight. The node weight is relative to the weight sum of all siblings
1418 * that have the same priority. The lowest weight is one. Used by the WFQ
1419 * algorithm running on the parent of the current node for scheduling this
1421 * @param[in] level_id
1422 * Level ID that should be met by this node. The hierarchy level of the
1423 * current node is already fully specified through its parent node (i.e. the
1424 * level of this node is equal to the level of its parent node plus one),
1425 * therefore the reason for providing this parameter is to enable the
1426 * application to perform step-by-step checking of the node level during
1427 * successive invocations of this function. When not desired, this check can
1428 * be disabled by assigning value RTE_TM_NODE_LEVEL_ID_ANY to this parameter.
1430 * Node parameters. Needs to be pre-allocated and valid.
1432 * Error details. Filled in only on error, when not NULL.
1434 * 0 on success, non-zero error code otherwise.
1436 * @see rte_tm_hierarchy_commit()
1437 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1438 * @see RTE_TM_NODE_LEVEL_ID_ANY
1439 * @see struct rte_tm_capabilities
1442 rte_tm_node_add(uint16_t port_id,
1444 uint32_t parent_node_id,
1448 struct rte_tm_node_params *params,
1449 struct rte_tm_error *error);
1452 * Traffic manager node delete
1454 * Delete an existing node. This operation fails when this node currently has
1455 * at least one user (i.e. child node).
1457 * When called before rte_tm_hierarchy_commit() invocation, this function is
1458 * typically used to define the initial start-up hierarchy for the port.
1459 * Provided that dynamic hierarchy updates are supported by the current port (as
1460 * advertised in the port capability set), this function can be also called
1461 * after the rte_tm_hierarchy_commit() invocation.
1463 * @param[in] port_id
1464 * The port identifier of the Ethernet device.
1465 * @param[in] node_id
1466 * Node ID. Needs to be valid.
1468 * Error details. Filled in only on error, when not NULL.
1470 * 0 on success, non-zero error code otherwise.
1472 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1475 rte_tm_node_delete(uint16_t port_id,
1477 struct rte_tm_error *error);
1480 * Traffic manager node suspend
1482 * Suspend an existing node. While the node is in suspended state, no packet is
1483 * scheduled from this node and its descendants. The node exits the suspended
1484 * state through the node resume operation.
1486 * @param[in] port_id
1487 * The port identifier of the Ethernet device.
1488 * @param[in] node_id
1489 * Node ID. Needs to be valid.
1491 * Error details. Filled in only on error, when not NULL.
1493 * 0 on success, non-zero error code otherwise.
1495 * @see rte_tm_node_resume()
1496 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1499 rte_tm_node_suspend(uint16_t port_id,
1501 struct rte_tm_error *error);
1504 * Traffic manager node resume
1506 * Resume an existing node that is currently in suspended state. The node
1507 * entered the suspended state as result of a previous node suspend operation.
1509 * @param[in] port_id
1510 * The port identifier of the Ethernet device.
1511 * @param[in] node_id
1512 * Node ID. Needs to be valid.
1514 * Error details. Filled in only on error, when not NULL.
1516 * 0 on success, non-zero error code otherwise.
1518 * @see rte_tm_node_suspend()
1519 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1522 rte_tm_node_resume(uint16_t port_id,
1524 struct rte_tm_error *error);
1527 * Traffic manager hierarchy commit
1529 * This function is called during the port initialization phase (before the
1530 * Ethernet port is started) to freeze the start-up hierarchy.
1532 * This function typically performs the following steps:
1533 * a) It validates the start-up hierarchy that was previously defined for the
1534 * current port through successive rte_tm_node_add() invocations;
1535 * b) Assuming successful validation, it performs all the necessary port
1536 * specific configuration operations to install the specified hierarchy on
1537 * the current port, with immediate effect once the port is started.
1539 * This function fails when the currently configured hierarchy is not supported
1540 * by the Ethernet port, in which case the user can abort or try out another
1541 * hierarchy configuration (e.g. a hierarchy with less leaf nodes), which can be
1542 * build from scratch (when *clear_on_fail* is enabled) or by modifying the
1543 * existing hierarchy configuration (when *clear_on_fail* is disabled).
1545 * Note that this function can still fail due to other causes (e.g. not enough
1546 * memory available in the system, etc), even though the specified hierarchy is
1547 * supported in principle by the current port.
1549 * @param[in] port_id
1550 * The port identifier of the Ethernet device.
1551 * @param[in] clear_on_fail
1552 * On function call failure, hierarchy is cleared when this parameter is
1553 * non-zero and preserved when this parameter is equal to zero.
1555 * Error details. Filled in only on error, when not NULL.
1557 * 0 on success, non-zero error code otherwise.
1559 * @see rte_tm_node_add()
1560 * @see rte_tm_node_delete()
1563 rte_tm_hierarchy_commit(uint16_t port_id,
1565 struct rte_tm_error *error);
1568 * Traffic manager node parent update
1570 * This function may be used to move a node and its children to a different
1571 * parent. Additionally, if the new parent is the same as the current parent,
1572 * this function will update the priority/weight of an existing node.
1574 * Restriction for root node: its parent cannot be changed.
1576 * This function can only be called after the rte_tm_hierarchy_commit()
1577 * invocation. Its success depends on the port support for this operation, as
1578 * advertised through the port capability set.
1580 * @param[in] port_id
1581 * The port identifier of the Ethernet device.
1582 * @param[in] node_id
1583 * Node ID. Needs to be valid.
1584 * @param[in] parent_node_id
1585 * Node ID for the new parent. Needs to be valid.
1586 * @param[in] priority
1587 * Node priority. The highest node priority is zero. Used by the SP algorithm
1588 * running on the parent of the current node for scheduling this child node.
1590 * Node weight. The node weight is relative to the weight sum of all siblings
1591 * that have the same priority. The lowest weight is zero. Used by the WFQ
1592 * algorithm running on the parent of the current node for scheduling this
1595 * Error details. Filled in only on error, when not NULL.
1597 * 0 on success, non-zero error code otherwise.
1599 * @see RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL
1600 * @see RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL
1603 rte_tm_node_parent_update(uint16_t port_id,
1605 uint32_t parent_node_id,
1608 struct rte_tm_error *error);
1611 * Traffic manager node private shaper update
1613 * Restriction for the root node: its private shaper profile needs to be valid
1616 * @param[in] port_id
1617 * The port identifier of the Ethernet device.
1618 * @param[in] node_id
1619 * Node ID. Needs to be valid.
1620 * @param[in] shaper_profile_id
1621 * Shaper profile ID for the private shaper of the current node. Needs to be
1622 * either valid shaper profile ID or RTE_TM_SHAPER_PROFILE_ID_NONE, with
1623 * the latter disabling the private shaper of the current node.
1625 * Error details. Filled in only on error, when not NULL.
1627 * 0 on success, non-zero error code otherwise.
1629 * @see struct rte_tm_capabilities::shaper_private_n_max
1632 rte_tm_node_shaper_update(uint16_t port_id,
1634 uint32_t shaper_profile_id,
1635 struct rte_tm_error *error);
1638 * Traffic manager node shared shapers update
1640 * Restriction for root node: cannot use any shared rate shapers.
1642 * @param[in] port_id
1643 * The port identifier of the Ethernet device.
1644 * @param[in] node_id
1645 * Node ID. Needs to be valid.
1646 * @param[in] shared_shaper_id
1647 * Shared shaper ID. Needs to be valid.
1649 * Set to non-zero value to add this shared shaper to current node or to zero
1650 * to delete this shared shaper from current node.
1652 * Error details. Filled in only on error, when not NULL.
1654 * 0 on success, non-zero error code otherwise.
1656 * @see struct rte_tm_capabilities::shaper_shared_n_max
1659 rte_tm_node_shared_shaper_update(uint16_t port_id,
1661 uint32_t shared_shaper_id,
1663 struct rte_tm_error *error);
1666 * Traffic manager node enabled statistics counters update
1668 * @param[in] port_id
1669 * The port identifier of the Ethernet device.
1670 * @param[in] node_id
1671 * Node ID. Needs to be valid.
1672 * @param[in] stats_mask
1673 * Mask of statistics counter types to be enabled for the current node. This
1674 * needs to be a subset of the statistics counter types available for the
1675 * current node. Any statistics counter type not included in this set is to
1676 * be disabled for the current node.
1678 * Error details. Filled in only on error, when not NULL.
1680 * 0 on success, non-zero error code otherwise.
1682 * @see enum rte_tm_stats_type
1683 * @see RTE_TM_UPDATE_NODE_STATS
1686 rte_tm_node_stats_update(uint16_t port_id,
1688 uint64_t stats_mask,
1689 struct rte_tm_error *error);
1692 * Traffic manager node WFQ weight mode 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 non-leaf node ID.
1698 * @param[in] wfq_weight_mode
1699 * WFQ weight mode for each SP priority. When NULL, it indicates that WFQ is
1700 * to be used for all priorities. When non-NULL, it points to a pre-allocated
1701 * array of *n_sp_priorities* values, with non-zero value for byte-mode and
1702 * zero for packet-mode.
1703 * @param[in] n_sp_priorities
1704 * Number of SP priorities.
1706 * Error details. Filled in only on error, when not NULL.
1708 * 0 on success, non-zero error code otherwise.
1710 * @see RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE
1711 * @see RTE_TM_UPDATE_NODE_N_SP_PRIORITIES
1714 rte_tm_node_wfq_weight_mode_update(uint16_t port_id,
1716 int *wfq_weight_mode,
1717 uint32_t n_sp_priorities,
1718 struct rte_tm_error *error);
1721 * Traffic manager node congestion management mode update
1723 * @param[in] port_id
1724 * The port identifier of the Ethernet device.
1725 * @param[in] node_id
1726 * Node ID. Needs to be valid leaf node ID.
1728 * Congestion management mode.
1730 * Error details. Filled in only on error, when not NULL.
1732 * 0 on success, non-zero error code otherwise.
1734 * @see RTE_TM_UPDATE_NODE_CMAN
1737 rte_tm_node_cman_update(uint16_t port_id,
1739 enum rte_tm_cman_mode cman,
1740 struct rte_tm_error *error);
1743 * Traffic manager node private WRED context update
1745 * @param[in] port_id
1746 * The port identifier of the Ethernet device.
1747 * @param[in] node_id
1748 * Node ID. Needs to be valid leaf node ID.
1749 * @param[in] wred_profile_id
1750 * WRED profile ID for the private WRED context of the current node. Needs to
1751 * be either valid WRED profile ID or RTE_TM_WRED_PROFILE_ID_NONE, with the
1752 * latter disabling the private WRED context of the current node.
1754 * Error details. Filled in only on error, when not NULL.
1756 * 0 on success, non-zero error code otherwise.
1758 * @see struct rte_tm_capabilities::cman_wred_context_private_n_max
1761 rte_tm_node_wred_context_update(uint16_t port_id,
1763 uint32_t wred_profile_id,
1764 struct rte_tm_error *error);
1767 * Traffic manager node shared WRED context update
1769 * @param[in] port_id
1770 * The port identifier of the Ethernet device.
1771 * @param[in] node_id
1772 * Node ID. Needs to be valid leaf node ID.
1773 * @param[in] shared_wred_context_id
1774 * Shared WRED context ID. Needs to be valid.
1776 * Set to non-zero value to add this shared WRED context to current node or
1777 * to zero to delete this shared WRED context from current node.
1779 * Error details. Filled in only on error, when not NULL.
1781 * 0 on success, non-zero error code otherwise.
1783 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1786 rte_tm_node_shared_wred_context_update(uint16_t port_id,
1788 uint32_t shared_wred_context_id,
1790 struct rte_tm_error *error);
1793 * Traffic manager node statistics counters read
1795 * @param[in] port_id
1796 * The port identifier of the Ethernet device.
1797 * @param[in] node_id
1798 * Node ID. Needs to be valid.
1800 * When non-NULL, it contains the current value for the statistics counters
1801 * enabled for the current node.
1802 * @param[out] stats_mask
1803 * When non-NULL, it contains the mask of statistics counter types that are
1804 * currently enabled for this node, indicating which of the counters
1805 * retrieved with the *stats* structure are valid.
1807 * When this parameter has a non-zero value, the statistics counters are
1808 * cleared (i.e. set to zero) immediately after they have been read,
1809 * otherwise the statistics counters are left untouched.
1811 * Error details. Filled in only on error, when not NULL.
1813 * 0 on success, non-zero error code otherwise.
1815 * @see enum rte_tm_stats_type
1818 rte_tm_node_stats_read(uint16_t port_id,
1820 struct rte_tm_node_stats *stats,
1821 uint64_t *stats_mask,
1823 struct rte_tm_error *error);
1826 * Traffic manager packet marking - VLAN DEI (IEEE 802.1Q)
1828 * IEEE 802.1p maps the traffic class to the VLAN Priority Code Point (PCP)
1829 * field (3 bits), while IEEE 802.1q maps the drop priority to the VLAN Drop
1830 * Eligible Indicator (DEI) field (1 bit), which was previously named Canonical
1831 * Format Indicator (CFI).
1833 * All VLAN frames of a given color get their DEI bit set if marking is enabled
1834 * for this color; otherwise, their DEI bit is left as is (either set or not).
1836 * @param[in] port_id
1837 * The port identifier of the Ethernet device.
1838 * @param[in] mark_green
1839 * Set to non-zero value to enable marking of green packets and to zero to
1841 * @param[in] mark_yellow
1842 * Set to non-zero value to enable marking of yellow packets and to zero to
1844 * @param[in] mark_red
1845 * Set to non-zero value to enable marking of red packets and to zero to
1848 * Error details. Filled in only on error, when not NULL.
1850 * 0 on success, non-zero error code otherwise.
1852 * @see struct rte_tm_capabilities::mark_vlan_dei_supported
1855 rte_tm_mark_vlan_dei(uint16_t port_id,
1859 struct rte_tm_error *error);
1862 * Traffic manager packet marking - IPv4 / IPv6 ECN (IETF RFC 3168)
1864 * IETF RFCs 2474 and 3168 reorganize the IPv4 Type of Service (TOS) field
1865 * (8 bits) and the IPv6 Traffic Class (TC) field (8 bits) into Differentiated
1866 * Services Codepoint (DSCP) field (6 bits) and Explicit Congestion
1867 * Notification (ECN) field (2 bits). The DSCP field is typically used to
1868 * encode the traffic class and/or drop priority (RFC 2597), while the ECN
1869 * field is used by RFC 3168 to implement a congestion notification mechanism
1870 * to be leveraged by transport layer protocols such as TCP and SCTP that have
1871 * congestion control mechanisms.
1873 * When congestion is experienced, as alternative to dropping the packet,
1874 * routers can change the ECN field of input packets from 2'b01 or 2'b10
1875 * (values indicating that source endpoint is ECN-capable) to 2'b11 (meaning
1876 * that congestion is experienced). The destination endpoint can use the
1877 * ECN-Echo (ECE) TCP flag to relay the congestion indication back to the
1878 * source endpoint, which acknowledges it back to the destination endpoint with
1879 * the Congestion Window Reduced (CWR) TCP flag.
1881 * All IPv4/IPv6 packets of a given color with ECN set to 2’b01 or 2’b10
1882 * carrying TCP or SCTP have their ECN set to 2’b11 if the marking feature is
1883 * enabled for the current color, otherwise the ECN field is left as is.
1885 * @param[in] port_id
1886 * The port identifier of the Ethernet device.
1887 * @param[in] mark_green
1888 * Set to non-zero value to enable marking of green packets and to zero to
1890 * @param[in] mark_yellow
1891 * Set to non-zero value to enable marking of yellow packets and to zero to
1893 * @param[in] mark_red
1894 * Set to non-zero value to enable marking of red packets and to zero to
1897 * Error details. Filled in only on error, when not NULL.
1899 * 0 on success, non-zero error code otherwise.
1901 * @see struct rte_tm_capabilities::mark_ip_ecn_tcp_supported
1902 * @see struct rte_tm_capabilities::mark_ip_ecn_sctp_supported
1905 rte_tm_mark_ip_ecn(uint16_t port_id,
1909 struct rte_tm_error *error);
1912 * Traffic manager packet marking - IPv4 / IPv6 DSCP (IETF RFC 2597)
1914 * IETF RFC 2597 maps the traffic class and the drop priority to the IPv4/IPv6
1915 * Differentiated Services Codepoint (DSCP) field (6 bits). Here are the DSCP
1916 * values proposed by this RFC:
1918 * <pre> Class 1 Class 2 Class 3 Class 4 </pre>
1919 * <pre> +----------+----------+----------+----------+</pre>
1920 * <pre>Low Drop Prec | 001010 | 010010 | 011010 | 100010 |</pre>
1921 * <pre>Medium Drop Prec | 001100 | 010100 | 011100 | 100100 |</pre>
1922 * <pre>High Drop Prec | 001110 | 010110 | 011110 | 100110 |</pre>
1923 * <pre> +----------+----------+----------+----------+</pre>
1925 * There are 4 traffic classes (classes 1 .. 4) encoded by DSCP bits 1 and 2,
1926 * as well as 3 drop priorities (low/medium/high) encoded by DSCP bits 3 and 4.
1928 * All IPv4/IPv6 packets have their color marked into DSCP bits 3 and 4 as
1929 * follows: green mapped to Low Drop Precedence (2’b01), yellow to Medium
1930 * (2’b10) and red to High (2’b11). Marking needs to be explicitly enabled
1931 * for each color; when not enabled for a given color, the DSCP field of all
1932 * packets with that color is left as is.
1934 * @param[in] port_id
1935 * The port identifier of the Ethernet device.
1936 * @param[in] mark_green
1937 * Set to non-zero value to enable marking of green packets and to zero to
1939 * @param[in] mark_yellow
1940 * Set to non-zero value to enable marking of yellow packets and to zero to
1942 * @param[in] mark_red
1943 * Set to non-zero value to enable marking of red packets and to zero to
1946 * Error details. Filled in only on error, when not NULL.
1948 * 0 on success, non-zero error code otherwise.
1950 * @see struct rte_tm_capabilities::mark_ip_dscp_supported
1953 rte_tm_mark_ip_dscp(uint16_t port_id,
1957 struct rte_tm_error *error);
1963 #endif /* __INCLUDE_RTE_TM_H__ */