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 /** WRED packet mode support. When non-zero, this parameter indicates
381 * that there is atleast one leaf node that supports the WRED packet
382 * mode, which might not be true for all the leaf nodes. In packet
383 * mode, the WRED thresholds specify the queue length in packets, as
386 int cman_wred_packet_mode_supported;
388 /** WRED byte mode support. When non-zero, this parameter indicates that
389 * there is atleast one leaf node that supports the WRED byte mode,
390 * which might not be true for all the leaf nodes. In byte mode, the
391 * WRED thresholds specify the queue length in bytes, as opposed to
394 int cman_wred_byte_mode_supported;
396 /** Head drop algorithm support. When non-zero, this parameter
397 * indicates that there is at least one leaf node that supports the head
398 * drop algorithm, which might not be true for all the leaf nodes.
400 int cman_head_drop_supported;
402 /** Maximum number of WRED contexts, either private or shared. In case
403 * the implementation does not share any resources between private and
404 * shared WRED contexts, it is typically equal to the sum of
405 * *cman_wred_context_private_n_max* and
406 * *cman_wred_context_shared_n_max*. The value of zero indicates that
407 * WRED is not supported.
409 uint32_t cman_wred_context_n_max;
411 /** Maximum number of private WRED contexts. Indicates the maximum
412 * number of leaf nodes that can concurrently have their private WRED
413 * context enabled. The value of zero indicates that private WRED
414 * contexts are not supported.
416 uint32_t cman_wred_context_private_n_max;
418 /** Maximum number of shared WRED contexts. The value of zero
419 * indicates that shared WRED contexts are not supported.
421 uint32_t cman_wred_context_shared_n_max;
423 /** Maximum number of leaf nodes that can share the same WRED context.
424 * Only valid when shared WRED contexts are supported.
426 uint32_t cman_wred_context_shared_n_nodes_per_context_max;
428 /** Maximum number of shared WRED contexts a leaf node can be part of.
429 * This parameter indicates that there is at least one leaf node that
430 * can be configured with this many shared WRED contexts, which might
431 * not be true for all the leaf nodes. Only valid when shared WRED
432 * contexts are supported, in which case it ranges from 1 to
433 * *cman_wred_context_shared_n_max*.
435 uint32_t cman_wred_context_shared_n_contexts_per_node_max;
437 /** Support for VLAN DEI packet marking (per color). */
438 int mark_vlan_dei_supported[RTE_TM_COLORS];
440 /** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */
441 int mark_ip_ecn_tcp_supported[RTE_TM_COLORS];
443 /** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */
444 int mark_ip_ecn_sctp_supported[RTE_TM_COLORS];
446 /** Support for IPv4/IPv6 DSCP packet marking (per color). */
447 int mark_ip_dscp_supported[RTE_TM_COLORS];
449 /** Set of supported dynamic update operations.
450 * @see enum rte_tm_dynamic_update_type
452 uint64_t dynamic_update_mask;
454 /** Set of supported statistics counter types.
455 * @see enum rte_tm_stats_type
461 * Traffic manager level capabilities
463 struct rte_tm_level_capabilities {
464 /** Maximum number of nodes for the current hierarchy level. */
465 uint32_t n_nodes_max;
467 /** Maximum number of non-leaf nodes for the current hierarchy level.
468 * The value of 0 indicates that current level only supports leaf
469 * nodes. The maximum value is *n_nodes_max*.
471 uint32_t n_nodes_nonleaf_max;
473 /** Maximum number of leaf nodes for the current hierarchy level. The
474 * value of 0 indicates that current level only supports non-leaf
475 * nodes. The maximum value is *n_nodes_max*.
477 uint32_t n_nodes_leaf_max;
479 /** When non-zero, this flag indicates that all the non-leaf nodes on
480 * this level have identical capability set. Valid only when
481 * *n_nodes_nonleaf_max* is non-zero.
483 int non_leaf_nodes_identical;
485 /** When non-zero, this flag indicates that all the leaf nodes on this
486 * level have identical capability set. Valid only when
487 * *n_nodes_leaf_max* is non-zero.
489 int leaf_nodes_identical;
493 /** Items valid only for the non-leaf nodes on this level. */
495 /** Private shaper support. When non-zero, it indicates
496 * there is at least one non-leaf node on this level
497 * with private shaper support, which may not be the
498 * case for all the non-leaf nodes on this level.
500 int shaper_private_supported;
502 /** Dual rate support for private shaper. Valid only
503 * when private shaper is supported for the non-leaf
504 * nodes on the current level. When non-zero, it
505 * indicates there is at least one non-leaf node on this
506 * level with dual rate private shaper support, which
507 * may not be the case for all the non-leaf nodes on
510 int shaper_private_dual_rate_supported;
512 /** Minimum committed/peak rate (bytes per second) for
513 * private shapers of the non-leaf nodes of this level.
514 * Valid only when private shaper is supported on this
517 uint64_t shaper_private_rate_min;
519 /** Maximum committed/peak rate (bytes per second) for
520 * private shapers of the non-leaf nodes on this level.
521 * Valid only when private shaper is supported on this
524 uint64_t shaper_private_rate_max;
526 /** Maximum number of shared shapers that any non-leaf
527 * node on this level can be part of. The value of zero
528 * indicates that shared shapers are not supported by
529 * the non-leaf nodes on this level. When non-zero, it
530 * indicates there is at least one non-leaf node on this
531 * level that meets this condition, which may not be the
532 * case for all the non-leaf nodes on this level.
534 uint32_t shaper_shared_n_max;
536 /** Maximum number of children nodes. This parameter
537 * indicates that there is at least one non-leaf node on
538 * this level that can be configured with this many
539 * children nodes, which might not be true for all the
540 * non-leaf nodes on this level.
542 uint32_t sched_n_children_max;
544 /** Maximum number of supported priority levels. This
545 * parameter indicates that there is at least one
546 * non-leaf node on this level that can be configured
547 * with this many priority levels for managing its
548 * children nodes, which might not be true for all the
549 * non-leaf nodes on this level. The value of zero is
550 * invalid. The value of 1 indicates that only priority
551 * 0 is supported, which essentially means that Strict
552 * Priority (SP) algorithm is not supported on this
555 uint32_t sched_sp_n_priorities_max;
557 /** Maximum number of sibling nodes that can have the
558 * same priority at any given time, i.e. maximum size of
559 * the WFQ sibling node group. This parameter indicates
560 * there is at least one non-leaf node on this level
561 * that meets this condition, which may not be true for
562 * all the non-leaf nodes on this level. The value of
563 * zero is invalid. The value of 1 indicates that WFQ
564 * algorithm is not supported on this level. The maximum
565 * value is *sched_n_children_max*.
567 uint32_t sched_wfq_n_children_per_group_max;
569 /** Maximum number of priority levels that can have
570 * more than one child node at any given time, i.e.
571 * maximum number of WFQ sibling node groups that
572 * have two or more members. This parameter indicates
573 * there is at least one non-leaf node on this level
574 * that meets this condition, which might not be true
575 * for all the non-leaf nodes. The value of zero states
576 * that WFQ algorithm is not supported on this level.
577 * The value of 1 indicates that
578 * (*sched_sp_n_priorities_max* - 1) priority levels on
579 * this level have at most one child node, so there can
580 * be only one priority level with two or more sibling
581 * nodes making up a WFQ group on this level. The
583 * min(floor(*sched_n_children_max* / 2),
584 * *sched_sp_n_priorities_max*).
586 uint32_t sched_wfq_n_groups_max;
588 /** Maximum WFQ weight. The value of 1 indicates that
589 * all sibling nodes on this level with same priority
590 * have the same WFQ weight, so on this level WFQ is
593 uint32_t sched_wfq_weight_max;
595 /** Mask of statistics counter types supported by the
596 * non-leaf nodes on this level. Every supported
597 * statistics counter type is supported by at least one
598 * non-leaf node on this level, which may not be true
599 * for all the non-leaf nodes on this level.
600 * @see enum rte_tm_stats_type
605 /** Items valid only for the leaf nodes on this level. */
607 /** Private shaper support. When non-zero, it indicates
608 * there is at least one leaf node on this level with
609 * private shaper support, which may not be the case for
610 * all the leaf nodes on this level.
612 int shaper_private_supported;
614 /** Dual rate support for private shaper. Valid only
615 * when private shaper is supported for the leaf nodes
616 * on this level. When non-zero, it indicates there is
617 * at least one leaf node on this level with dual rate
618 * private shaper support, which may not be the case for
619 * all the leaf nodes on this level.
621 int shaper_private_dual_rate_supported;
623 /** Minimum committed/peak rate (bytes per second) for
624 * private shapers of the leaf nodes of this level.
625 * Valid only when private shaper is supported for the
626 * leaf nodes on this level.
628 uint64_t shaper_private_rate_min;
630 /** Maximum committed/peak rate (bytes per second) for
631 * private shapers of the leaf nodes on this level.
632 * Valid only when private shaper is supported for the
633 * leaf nodes on this level.
635 uint64_t shaper_private_rate_max;
637 /** Maximum number of shared shapers that any leaf node
638 * on this level can be part of. The value of zero
639 * indicates that shared shapers are not supported by
640 * the leaf nodes on this level. When non-zero, it
641 * indicates there is at least one leaf node on this
642 * level that meets this condition, which may not be the
643 * case for all the leaf nodes on this level.
645 uint32_t shaper_shared_n_max;
647 /** WRED packet mode support. When non-zero, this
648 * parameter indicates that there is atleast one leaf
649 * node on this level that supports the WRED packet
650 * mode, which might not be true for all the leaf
651 * nodes. In packet mode, the WRED thresholds specify
652 * the queue length in packets, as opposed to bytes.
654 int cman_wred_packet_mode_supported;
656 /** WRED byte mode support. When non-zero, this
657 * parameter indicates that there is atleast one leaf
658 * node on this level that supports the WRED byte mode,
659 * which might not be true for all the leaf nodes. In
660 * byte mode, the WRED thresholds specify the queue
661 * length in bytes, as opposed to packets.
663 int cman_wred_byte_mode_supported;
665 /** Head drop algorithm support. When non-zero, this
666 * parameter indicates that there is at least one leaf
667 * node on this level that supports the head drop
668 * algorithm, which might not be true for all the leaf
669 * nodes on this level.
671 int cman_head_drop_supported;
673 /** Private WRED context support. When non-zero, it
674 * indicates there is at least one node on this level
675 * with private WRED context support, which may not be
676 * true for all the leaf nodes on this level.
678 int cman_wred_context_private_supported;
680 /** Maximum number of shared WRED contexts that any
681 * leaf node on this level can be part of. The value of
682 * zero indicates that shared WRED contexts are not
683 * supported by the leaf nodes on this level. When
684 * non-zero, it indicates there is at least one leaf
685 * node on this level that meets this condition, which
686 * may not be the case for all the leaf nodes on this
689 uint32_t cman_wred_context_shared_n_max;
691 /** Mask of statistics counter types supported by the
692 * leaf nodes on this level. Every supported statistics
693 * counter type is supported by at least one leaf node
694 * on this level, which may not be true for all the leaf
695 * nodes on this level.
696 * @see enum rte_tm_stats_type
704 * Traffic manager node capabilities
706 struct rte_tm_node_capabilities {
707 /** Private shaper support for the current node. */
708 int shaper_private_supported;
710 /** Dual rate shaping support for private shaper of current node.
711 * Valid only when private shaper is supported by the current node.
713 int shaper_private_dual_rate_supported;
715 /** Minimum committed/peak rate (bytes per second) for private
716 * shaper of current node. Valid only when private shaper is supported
717 * by the current node.
719 uint64_t shaper_private_rate_min;
721 /** Maximum committed/peak rate (bytes per second) for private
722 * shaper of current node. Valid only when private shaper is supported
723 * by the current node.
725 uint64_t shaper_private_rate_max;
727 /** Maximum number of shared shapers the current node can be part of.
728 * The value of zero indicates that shared shapers are not supported by
731 uint32_t shaper_shared_n_max;
735 /** Items valid only for non-leaf nodes. */
737 /** Maximum number of children nodes. */
738 uint32_t sched_n_children_max;
740 /** Maximum number of supported priority levels. The
741 * value of zero is invalid. The value of 1 indicates
742 * that only priority 0 is supported, which essentially
743 * means that Strict Priority (SP) algorithm is not
746 uint32_t sched_sp_n_priorities_max;
748 /** Maximum number of sibling nodes that can have the
749 * same priority at any given time, i.e. maximum size
750 * of the WFQ sibling node group. The value of zero
751 * is invalid. The value of 1 indicates that WFQ
752 * algorithm is not supported. The maximum value is
753 * *sched_n_children_max*.
755 uint32_t sched_wfq_n_children_per_group_max;
757 /** Maximum number of priority levels that can have
758 * more than one child node at any given time, i.e.
759 * maximum number of WFQ sibling node groups that have
760 * two or more members. The value of zero states that
761 * WFQ algorithm is not supported. The value of 1
762 * indicates that (*sched_sp_n_priorities_max* - 1)
763 * priority levels have at most one child node, so there
764 * can be only one priority level with two or more
765 * sibling nodes making up a WFQ group. The maximum
766 * value is: min(floor(*sched_n_children_max* / 2),
767 * *sched_sp_n_priorities_max*).
769 uint32_t sched_wfq_n_groups_max;
771 /** Maximum WFQ weight. The value of 1 indicates that
772 * all sibling nodes with same priority have the same
773 * WFQ weight, so WFQ is reduced to FQ.
775 uint32_t sched_wfq_weight_max;
778 /** Items valid only for leaf nodes. */
780 /** WRED packet mode support for current node. */
781 int cman_wred_packet_mode_supported;
783 /** WRED byte mode support for current node. */
784 int cman_wred_byte_mode_supported;
786 /** Head drop algorithm support for current node. */
787 int cman_head_drop_supported;
789 /** Private WRED context support for current node. */
790 int cman_wred_context_private_supported;
792 /** Maximum number of shared WRED contexts the current
793 * node can be part of. The value of zero indicates that
794 * shared WRED contexts are not supported by the current
797 uint32_t cman_wred_context_shared_n_max;
801 /** Mask of statistics counter types supported by the current node.
802 * @see enum rte_tm_stats_type
808 * Congestion management (CMAN) mode
810 * This is used for controlling the admission of packets into a packet queue or
811 * group of packet queues on congestion. On request of writing a new packet
812 * into the current queue while the queue is full, the *tail drop* algorithm
813 * drops the new packet while leaving the queue unmodified, as opposed to *head
814 * drop* algorithm, which drops the packet at the head of the queue (the oldest
815 * packet waiting in the queue) and admits the new packet at the tail of the
818 * The *Random Early Detection (RED)* algorithm works by proactively dropping
819 * more and more input packets as the queue occupancy builds up. When the queue
820 * is full or almost full, RED effectively works as *tail drop*. The *Weighted
821 * RED* algorithm uses a separate set of RED thresholds for each packet color.
823 enum rte_tm_cman_mode {
824 RTE_TM_CMAN_TAIL_DROP = 0, /**< Tail drop */
825 RTE_TM_CMAN_HEAD_DROP, /**< Head drop */
826 RTE_TM_CMAN_WRED, /**< Weighted Random Early Detection (WRED) */
830 * Random Early Detection (RED) profile
832 struct rte_tm_red_params {
833 /** Minimum queue threshold */
836 /** Maximum queue threshold */
839 /** Inverse of packet marking probability maximum value (maxp), i.e.
840 * maxp_inv = 1 / maxp
844 /** Negated log2 of queue weight (wq), i.e. wq = 1 / (2 ^ wq_log2) */
849 * Weighted RED (WRED) profile
851 * Multiple WRED contexts can share the same WRED profile. Each leaf node with
852 * WRED enabled as its congestion management mode has zero or one private WRED
853 * context (only one leaf node using it) and/or zero, one or several shared
854 * WRED contexts (multiple leaf nodes use the same WRED context). A private
855 * WRED context is used to perform congestion management for a single leaf
856 * node, while a shared WRED context is used to perform congestion management
857 * for a group of leaf nodes.
859 * @see struct rte_tm_capabilities::cman_wred_packet_mode_supported
860 * @see struct rte_tm_capabilities::cman_wred_byte_mode_supported
862 struct rte_tm_wred_params {
863 /** One set of RED parameters per packet color */
864 struct rte_tm_red_params red_params[RTE_TM_COLORS];
866 /** When non-zero, the *min_th* and *max_th* thresholds are specified
867 * in packets (WRED packet mode). When zero, the *min_th* and *max_th*
868 * thresholds are specified in bytes (WRED byte mode)
876 struct rte_tm_token_bucket {
877 /** Token bucket rate (bytes per second) */
880 /** Token bucket size (bytes), a.k.a. max burst size */
885 * Shaper (rate limiter) profile
887 * Multiple shaper instances can share the same shaper profile. Each node has
888 * zero or one private shaper (only one node using it) and/or zero, one or
889 * several shared shapers (multiple nodes use the same shaper instance).
890 * A private shaper is used to perform traffic shaping for a single node, while
891 * a shared shaper is used to perform traffic shaping for a group of nodes.
893 * Single rate shapers use a single token bucket. A single rate shaper can be
894 * configured by setting the rate of the committed bucket to zero, which
895 * effectively disables this bucket. The peak bucket is used to limit the rate
896 * and the burst size for the current shaper.
898 * Dual rate shapers use both the committed and the peak token buckets. The
899 * rate of the peak bucket has to be bigger than zero, as well as greater than
900 * or equal to the rate of the committed bucket.
902 struct rte_tm_shaper_params {
903 /** Committed token bucket */
904 struct rte_tm_token_bucket committed;
906 /** Peak token bucket */
907 struct rte_tm_token_bucket peak;
909 /** Signed value to be added to the length of each packet for the
910 * purpose of shaping. Can be used to correct the packet length with
911 * the framing overhead bytes that are also consumed on the wire (e.g.
912 * RTE_TM_ETH_FRAMING_OVERHEAD_FCS).
914 int32_t pkt_length_adjust;
920 * Each non-leaf node has multiple inputs (its children nodes) and single output
921 * (which is input to its parent node). It arbitrates its inputs using Strict
922 * Priority (SP) and Weighted Fair Queuing (WFQ) algorithms to schedule input
923 * packets to its output while observing its shaping (rate limiting)
926 * Algorithms such as Weighted Round Robin (WRR), Byte-level WRR, Deficit WRR
927 * (DWRR), etc. are considered approximations of the WFQ ideal and are
928 * assimilated to WFQ, although an associated implementation-dependent trade-off
929 * on accuracy, performance and resource usage might exist.
931 * Children nodes with different priorities are scheduled using the SP algorithm
932 * based on their priority, with zero (0) as the highest priority. Children with
933 * the same priority are scheduled using the WFQ algorithm according to their
934 * weights. The WFQ weight of a given child node is relative to the sum of the
935 * weights of all its sibling nodes that have the same priority, with one (1) as
936 * the lowest weight. For each SP priority, the WFQ weight mode can be set as
937 * either byte-based or packet-based.
939 * Each leaf node sits on top of a TX queue of the current Ethernet port. Hence,
940 * the leaf nodes are predefined, with their node IDs set to 0 .. (N-1), where N
941 * is the number of TX queues configured for the current Ethernet port. The
942 * non-leaf nodes have their IDs generated by the application.
944 struct rte_tm_node_params {
945 /** Shaper profile for the private shaper. The absence of the private
946 * shaper for the current node is indicated by setting this parameter
947 * to RTE_TM_SHAPER_PROFILE_ID_NONE.
949 uint32_t shaper_profile_id;
951 /** User allocated array of valid shared shaper IDs. */
952 uint32_t *shared_shaper_id;
954 /** Number of shared shaper IDs in the *shared_shaper_id* array. */
955 uint32_t n_shared_shapers;
959 /** Parameters only valid for non-leaf nodes. */
961 /** WFQ weight mode for each SP priority. When NULL, it
962 * indicates that WFQ is to be used for all priorities.
963 * When non-NULL, it points to a pre-allocated array of
964 * *n_sp_priorities* values, with non-zero value for
965 * byte-mode and zero for packet-mode.
967 int *wfq_weight_mode;
969 /** Number of SP priorities. */
970 uint32_t n_sp_priorities;
973 /** Parameters only valid for leaf nodes. */
975 /** Congestion management mode */
976 enum rte_tm_cman_mode cman;
978 /** WRED parameters (only valid when *cman* is set to
982 /** WRED profile for private WRED context. The
983 * absence of a private WRED context for the
984 * current leaf node is indicated by value
985 * RTE_TM_WRED_PROFILE_ID_NONE.
987 uint32_t wred_profile_id;
989 /** User allocated array of shared WRED context
990 * IDs. When set to NULL, it indicates that the
991 * current leaf node should not currently be
992 * part of any shared WRED contexts.
994 uint32_t *shared_wred_context_id;
996 /** Number of elements in the
997 * *shared_wred_context_id* array. Only valid
998 * when *shared_wred_context_id* is non-NULL,
999 * in which case it should be non-zero.
1001 uint32_t n_shared_wred_contexts;
1006 /** Mask of statistics counter types to be enabled for this node. This
1007 * needs to be a subset of the statistics counter types available for
1008 * the current node. Any statistics counter type not included in this
1009 * set is to be disabled for the current node.
1010 * @see enum rte_tm_stats_type
1012 uint64_t stats_mask;
1016 * Verbose error types.
1018 * Most of them provide the type of the object referenced by struct
1019 * rte_tm_error::cause.
1021 enum rte_tm_error_type {
1022 RTE_TM_ERROR_TYPE_NONE, /**< No error. */
1023 RTE_TM_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
1024 RTE_TM_ERROR_TYPE_CAPABILITIES,
1025 RTE_TM_ERROR_TYPE_LEVEL_ID,
1026 RTE_TM_ERROR_TYPE_WRED_PROFILE,
1027 RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN,
1028 RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW,
1029 RTE_TM_ERROR_TYPE_WRED_PROFILE_RED,
1030 RTE_TM_ERROR_TYPE_WRED_PROFILE_ID,
1031 RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID,
1032 RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
1033 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE,
1034 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE,
1035 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
1036 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
1037 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN,
1038 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
1039 RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID,
1040 RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID,
1041 RTE_TM_ERROR_TYPE_NODE_PRIORITY,
1042 RTE_TM_ERROR_TYPE_NODE_WEIGHT,
1043 RTE_TM_ERROR_TYPE_NODE_PARAMS,
1044 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID,
1045 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID,
1046 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS,
1047 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE,
1048 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES,
1049 RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN,
1050 RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID,
1051 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID,
1052 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS,
1053 RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
1054 RTE_TM_ERROR_TYPE_NODE_ID,
1058 * Verbose error structure definition.
1060 * This object is normally allocated by applications and set by PMDs, the
1061 * message points to a constant string which does not need to be freed by
1062 * the application, however its pointer can be considered valid only as long
1063 * as its associated DPDK port remains configured. Closing the underlying
1064 * device or unloading the PMD invalidates it.
1066 * Both cause and message may be NULL regardless of the error type.
1068 struct rte_tm_error {
1069 enum rte_tm_error_type type; /**< Cause field and error type. */
1070 const void *cause; /**< Object responsible for the error. */
1071 const char *message; /**< Human-readable error message. */
1075 * Traffic manager get number of leaf nodes
1077 * Each leaf node sits on on top of a TX queue of the current Ethernet port.
1078 * Therefore, the set of leaf nodes is predefined, their number is always equal
1079 * to N (where N is the number of TX queues configured for the current port)
1080 * and their IDs are 0 .. (N-1).
1082 * @param[in] port_id
1083 * The port identifier of the Ethernet device.
1084 * @param[out] n_leaf_nodes
1085 * Number of leaf nodes for the current port.
1087 * Error details. Filled in only on error, when not NULL.
1089 * 0 on success, non-zero error code otherwise.
1092 rte_tm_get_number_of_leaf_nodes(uint16_t port_id,
1093 uint32_t *n_leaf_nodes,
1094 struct rte_tm_error *error);
1097 * Traffic manager node ID validate and type (i.e. leaf or non-leaf) get
1099 * The leaf nodes have predefined IDs in the range of 0 .. (N-1), where N is
1100 * the number of TX queues of the current Ethernet port. The non-leaf nodes
1101 * have their IDs generated by the application outside of the above range,
1102 * which is reserved for leaf nodes.
1104 * @param[in] port_id
1105 * The port identifier of the Ethernet device.
1106 * @param[in] node_id
1107 * Node ID value. Needs to be valid.
1108 * @param[out] is_leaf
1109 * Set to non-zero value when node is leaf and to zero otherwise (non-leaf).
1111 * Error details. Filled in only on error, when not NULL.
1113 * 0 on success, non-zero error code otherwise.
1116 rte_tm_node_type_get(uint16_t port_id,
1119 struct rte_tm_error *error);
1122 * Traffic manager capabilities get
1124 * @param[in] port_id
1125 * The port identifier of the Ethernet device.
1127 * Traffic manager capabilities. Needs to be pre-allocated and valid.
1129 * Error details. Filled in only on error, when not NULL.
1131 * 0 on success, non-zero error code otherwise.
1134 rte_tm_capabilities_get(uint16_t port_id,
1135 struct rte_tm_capabilities *cap,
1136 struct rte_tm_error *error);
1139 * Traffic manager level capabilities get
1141 * @param[in] port_id
1142 * The port identifier of the Ethernet device.
1143 * @param[in] level_id
1144 * The hierarchy level identifier. The value of 0 identifies the level of the
1147 * Traffic manager level capabilities. Needs to be pre-allocated and valid.
1149 * Error details. Filled in only on error, when not NULL.
1151 * 0 on success, non-zero error code otherwise.
1154 rte_tm_level_capabilities_get(uint16_t port_id,
1156 struct rte_tm_level_capabilities *cap,
1157 struct rte_tm_error *error);
1160 * Traffic manager node capabilities get
1162 * @param[in] port_id
1163 * The port identifier of the Ethernet device.
1164 * @param[in] node_id
1165 * Node ID. Needs to be valid.
1167 * Traffic manager node capabilities. Needs to be pre-allocated and valid.
1169 * Error details. Filled in only on error, when not NULL.
1171 * 0 on success, non-zero error code otherwise.
1174 rte_tm_node_capabilities_get(uint16_t port_id,
1176 struct rte_tm_node_capabilities *cap,
1177 struct rte_tm_error *error);
1180 * Traffic manager WRED profile add
1182 * Create a new WRED profile with ID set to *wred_profile_id*. The new profile
1183 * is used to create one or several WRED contexts.
1185 * @param[in] port_id
1186 * The port identifier of the Ethernet device.
1187 * @param[in] wred_profile_id
1188 * WRED profile ID for the new profile. Needs to be unused.
1189 * @param[in] profile
1190 * WRED profile parameters. Needs to be pre-allocated and valid.
1192 * Error details. Filled in only on error, when not NULL.
1194 * 0 on success, non-zero error code otherwise.
1196 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1199 rte_tm_wred_profile_add(uint16_t port_id,
1200 uint32_t wred_profile_id,
1201 struct rte_tm_wred_params *profile,
1202 struct rte_tm_error *error);
1205 * Traffic manager WRED profile delete
1207 * Delete an existing WRED profile. This operation fails when there is
1208 * currently at least one user (i.e. WRED context) of this WRED profile.
1210 * @param[in] port_id
1211 * The port identifier of the Ethernet device.
1212 * @param[in] wred_profile_id
1213 * WRED profile ID. Needs to be the valid.
1215 * Error details. Filled in only on error, when not NULL.
1217 * 0 on success, non-zero error code otherwise.
1219 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1222 rte_tm_wred_profile_delete(uint16_t port_id,
1223 uint32_t wred_profile_id,
1224 struct rte_tm_error *error);
1227 * Traffic manager shared WRED context add or update
1229 * When *shared_wred_context_id* is invalid, a new WRED context with this ID is
1230 * created by using the WRED profile identified by *wred_profile_id*.
1232 * When *shared_wred_context_id* is valid, this WRED context is no longer using
1233 * the profile previously assigned to it and is updated to use the profile
1234 * identified by *wred_profile_id*.
1236 * A valid shared WRED context can be assigned to several hierarchy leaf nodes
1237 * configured to use WRED as the congestion management mode.
1239 * @param[in] port_id
1240 * The port identifier of the Ethernet device.
1241 * @param[in] shared_wred_context_id
1242 * Shared WRED context ID
1243 * @param[in] wred_profile_id
1244 * WRED profile ID. Needs to be the valid.
1246 * Error details. Filled in only on error, when not NULL.
1248 * 0 on success, non-zero error code otherwise.
1250 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1253 rte_tm_shared_wred_context_add_update(uint16_t port_id,
1254 uint32_t shared_wred_context_id,
1255 uint32_t wred_profile_id,
1256 struct rte_tm_error *error);
1259 * Traffic manager shared WRED context delete
1261 * Delete an existing shared WRED context. This operation fails when there is
1262 * currently at least one user (i.e. hierarchy leaf node) of this shared WRED
1265 * @param[in] port_id
1266 * The port identifier of the Ethernet device.
1267 * @param[in] shared_wred_context_id
1268 * Shared WRED context ID. Needs to be the valid.
1270 * Error details. Filled in only on error, when not NULL.
1272 * 0 on success, non-zero error code otherwise.
1274 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1277 rte_tm_shared_wred_context_delete(uint16_t port_id,
1278 uint32_t shared_wred_context_id,
1279 struct rte_tm_error *error);
1282 * Traffic manager shaper profile add
1284 * Create a new shaper profile with ID set to *shaper_profile_id*. The new
1285 * shaper profile is used to create one or several shapers.
1287 * @param[in] port_id
1288 * The port identifier of the Ethernet device.
1289 * @param[in] shaper_profile_id
1290 * Shaper profile ID for the new profile. Needs to be unused.
1291 * @param[in] profile
1292 * Shaper profile parameters. Needs to be pre-allocated and valid.
1294 * Error details. Filled in only on error, when not NULL.
1296 * 0 on success, non-zero error code otherwise.
1298 * @see struct rte_tm_capabilities::shaper_n_max
1301 rte_tm_shaper_profile_add(uint16_t port_id,
1302 uint32_t shaper_profile_id,
1303 struct rte_tm_shaper_params *profile,
1304 struct rte_tm_error *error);
1307 * Traffic manager shaper profile delete
1309 * Delete an existing shaper profile. This operation fails when there is
1310 * currently at least one user (i.e. shaper) of this shaper profile.
1312 * @param[in] port_id
1313 * The port identifier of the Ethernet device.
1314 * @param[in] shaper_profile_id
1315 * Shaper profile ID. Needs to be the valid.
1317 * Error details. Filled in only on error, when not NULL.
1319 * 0 on success, non-zero error code otherwise.
1321 * @see struct rte_tm_capabilities::shaper_n_max
1324 rte_tm_shaper_profile_delete(uint16_t port_id,
1325 uint32_t shaper_profile_id,
1326 struct rte_tm_error *error);
1329 * Traffic manager shared shaper add or update
1331 * When *shared_shaper_id* is not a valid shared shaper ID, a new shared shaper
1332 * with this ID is created using the shaper profile identified by
1333 * *shaper_profile_id*.
1335 * When *shared_shaper_id* is a valid shared shaper ID, this shared shaper is
1336 * no longer using the shaper profile previously assigned to it and is updated
1337 * to use the shaper profile identified by *shaper_profile_id*.
1339 * @param[in] port_id
1340 * The port identifier of the Ethernet device.
1341 * @param[in] shared_shaper_id
1343 * @param[in] shaper_profile_id
1344 * Shaper profile ID. Needs to be the valid.
1346 * Error details. Filled in only on error, when not NULL.
1348 * 0 on success, non-zero error code otherwise.
1350 * @see struct rte_tm_capabilities::shaper_shared_n_max
1353 rte_tm_shared_shaper_add_update(uint16_t port_id,
1354 uint32_t shared_shaper_id,
1355 uint32_t shaper_profile_id,
1356 struct rte_tm_error *error);
1359 * Traffic manager shared shaper delete
1361 * Delete an existing shared shaper. This operation fails when there is
1362 * currently at least one user (i.e. hierarchy node) of this shared shaper.
1364 * @param[in] port_id
1365 * The port identifier of the Ethernet device.
1366 * @param[in] shared_shaper_id
1367 * Shared shaper ID. Needs to be the valid.
1369 * Error details. Filled in only on error, when not NULL.
1371 * 0 on success, non-zero error code otherwise.
1373 * @see struct rte_tm_capabilities::shaper_shared_n_max
1376 rte_tm_shared_shaper_delete(uint16_t port_id,
1377 uint32_t shared_shaper_id,
1378 struct rte_tm_error *error);
1381 * Traffic manager node add
1383 * Create new node and connect it as child of an existing node. The new node is
1384 * further identified by *node_id*, which needs to be unused by any of the
1385 * existing nodes. The parent node is identified by *parent_node_id*, which
1386 * needs to be the valid ID of an existing non-leaf node. The parent node is
1387 * going to use the provided SP *priority* and WFQ *weight* to schedule its new
1390 * This function has to be called for both leaf and non-leaf nodes. In the case
1391 * of leaf nodes (i.e. *node_id* is within the range of 0 .. (N-1), with N as
1392 * the number of configured TX queues of the current port), the leaf node is
1393 * configured rather than created (as the set of leaf nodes is predefined) and
1394 * it is also connected as child of an existing node.
1396 * The first node that is added becomes the root node and all the nodes that
1397 * are subsequently added have to be added as descendants of the root node. The
1398 * parent of the root node has to be specified as RTE_TM_NODE_ID_NULL and there
1399 * can only be one node with this parent ID (i.e. the root node). Further
1400 * restrictions for root node: needs to be non-leaf, its private shaper profile
1401 * needs to be valid and single rate, cannot use any shared shapers.
1403 * When called before rte_tm_hierarchy_commit() invocation, this function is
1404 * typically used to define the initial start-up hierarchy for the port.
1405 * Provided that dynamic hierarchy updates are supported by the current port (as
1406 * advertised in the port capability set), this function can be also called
1407 * after the rte_tm_hierarchy_commit() invocation.
1409 * @param[in] port_id
1410 * The port identifier of the Ethernet device.
1411 * @param[in] node_id
1412 * Node ID. Needs to be unused by any of the existing nodes.
1413 * @param[in] parent_node_id
1414 * Parent node ID. Needs to be the valid.
1415 * @param[in] priority
1416 * Node priority. The highest node priority is zero. Used by the SP algorithm
1417 * running on the parent of the current node for scheduling this child node.
1419 * Node weight. The node weight is relative to the weight sum of all siblings
1420 * that have the same priority. The lowest weight is one. Used by the WFQ
1421 * algorithm running on the parent of the current node for scheduling this
1423 * @param[in] level_id
1424 * Level ID that should be met by this node. The hierarchy level of the
1425 * current node is already fully specified through its parent node (i.e. the
1426 * level of this node is equal to the level of its parent node plus one),
1427 * therefore the reason for providing this parameter is to enable the
1428 * application to perform step-by-step checking of the node level during
1429 * successive invocations of this function. When not desired, this check can
1430 * be disabled by assigning value RTE_TM_NODE_LEVEL_ID_ANY to this parameter.
1432 * Node parameters. Needs to be pre-allocated and valid.
1434 * Error details. Filled in only on error, when not NULL.
1436 * 0 on success, non-zero error code otherwise.
1438 * @see rte_tm_hierarchy_commit()
1439 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1440 * @see RTE_TM_NODE_LEVEL_ID_ANY
1441 * @see struct rte_tm_capabilities
1444 rte_tm_node_add(uint16_t port_id,
1446 uint32_t parent_node_id,
1450 struct rte_tm_node_params *params,
1451 struct rte_tm_error *error);
1454 * Traffic manager node delete
1456 * Delete an existing node. This operation fails when this node currently has
1457 * at least one user (i.e. child node).
1459 * When called before rte_tm_hierarchy_commit() invocation, this function is
1460 * typically used to define the initial start-up hierarchy for the port.
1461 * Provided that dynamic hierarchy updates are supported by the current port (as
1462 * advertised in the port capability set), this function can be also called
1463 * after the rte_tm_hierarchy_commit() invocation.
1465 * @param[in] port_id
1466 * The port identifier of the Ethernet device.
1467 * @param[in] node_id
1468 * Node ID. Needs to be valid.
1470 * Error details. Filled in only on error, when not NULL.
1472 * 0 on success, non-zero error code otherwise.
1474 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1477 rte_tm_node_delete(uint16_t port_id,
1479 struct rte_tm_error *error);
1482 * Traffic manager node suspend
1484 * Suspend an existing node. While the node is in suspended state, no packet is
1485 * scheduled from this node and its descendants. The node exits the suspended
1486 * state through the node resume operation.
1488 * @param[in] port_id
1489 * The port identifier of the Ethernet device.
1490 * @param[in] node_id
1491 * Node ID. Needs to be valid.
1493 * Error details. Filled in only on error, when not NULL.
1495 * 0 on success, non-zero error code otherwise.
1497 * @see rte_tm_node_resume()
1498 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1501 rte_tm_node_suspend(uint16_t port_id,
1503 struct rte_tm_error *error);
1506 * Traffic manager node resume
1508 * Resume an existing node that is currently in suspended state. The node
1509 * entered the suspended state as result of a previous node suspend operation.
1511 * @param[in] port_id
1512 * The port identifier of the Ethernet device.
1513 * @param[in] node_id
1514 * Node ID. Needs to be valid.
1516 * Error details. Filled in only on error, when not NULL.
1518 * 0 on success, non-zero error code otherwise.
1520 * @see rte_tm_node_suspend()
1521 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1524 rte_tm_node_resume(uint16_t port_id,
1526 struct rte_tm_error *error);
1529 * Traffic manager hierarchy commit
1531 * This function is called during the port initialization phase (before the
1532 * Ethernet port is started) to freeze the start-up hierarchy.
1534 * This function typically performs the following steps:
1535 * a) It validates the start-up hierarchy that was previously defined for the
1536 * current port through successive rte_tm_node_add() invocations;
1537 * b) Assuming successful validation, it performs all the necessary port
1538 * specific configuration operations to install the specified hierarchy on
1539 * the current port, with immediate effect once the port is started.
1541 * This function fails when the currently configured hierarchy is not supported
1542 * by the Ethernet port, in which case the user can abort or try out another
1543 * hierarchy configuration (e.g. a hierarchy with less leaf nodes), which can be
1544 * build from scratch (when *clear_on_fail* is enabled) or by modifying the
1545 * existing hierarchy configuration (when *clear_on_fail* is disabled).
1547 * Note that this function can still fail due to other causes (e.g. not enough
1548 * memory available in the system, etc), even though the specified hierarchy is
1549 * supported in principle by the current port.
1551 * @param[in] port_id
1552 * The port identifier of the Ethernet device.
1553 * @param[in] clear_on_fail
1554 * On function call failure, hierarchy is cleared when this parameter is
1555 * non-zero and preserved when this parameter is equal to zero.
1557 * Error details. Filled in only on error, when not NULL.
1559 * 0 on success, non-zero error code otherwise.
1561 * @see rte_tm_node_add()
1562 * @see rte_tm_node_delete()
1565 rte_tm_hierarchy_commit(uint16_t port_id,
1567 struct rte_tm_error *error);
1570 * Traffic manager node parent update
1572 * Restriction for root node: its parent cannot be changed.
1574 * This function can only be called after the rte_tm_hierarchy_commit()
1575 * invocation. Its success depends on the port support for this operation, as
1576 * advertised through the port capability set.
1578 * @param[in] port_id
1579 * The port identifier of the Ethernet device.
1580 * @param[in] node_id
1581 * Node ID. Needs to be valid.
1582 * @param[in] parent_node_id
1583 * Node ID for the new parent. Needs to be valid.
1584 * @param[in] priority
1585 * Node priority. The highest node priority is zero. Used by the SP algorithm
1586 * running on the parent of the current node for scheduling this child node.
1588 * Node weight. The node weight is relative to the weight sum of all siblings
1589 * that have the same priority. The lowest weight is zero. Used by the WFQ
1590 * algorithm running on the parent of the current node for scheduling this
1593 * Error details. Filled in only on error, when not NULL.
1595 * 0 on success, non-zero error code otherwise.
1597 * @see RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL
1598 * @see RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL
1601 rte_tm_node_parent_update(uint16_t port_id,
1603 uint32_t parent_node_id,
1606 struct rte_tm_error *error);
1609 * Traffic manager node private shaper update
1611 * Restriction for the root node: its private shaper profile needs to be valid
1614 * @param[in] port_id
1615 * The port identifier of the Ethernet device.
1616 * @param[in] node_id
1617 * Node ID. Needs to be valid.
1618 * @param[in] shaper_profile_id
1619 * Shaper profile ID for the private shaper of the current node. Needs to be
1620 * either valid shaper profile ID or RTE_TM_SHAPER_PROFILE_ID_NONE, with
1621 * the latter disabling the private shaper of the current node.
1623 * Error details. Filled in only on error, when not NULL.
1625 * 0 on success, non-zero error code otherwise.
1627 * @see struct rte_tm_capabilities::shaper_private_n_max
1630 rte_tm_node_shaper_update(uint16_t port_id,
1632 uint32_t shaper_profile_id,
1633 struct rte_tm_error *error);
1636 * Traffic manager node shared shapers update
1638 * Restriction for root node: cannot use any shared rate shapers.
1640 * @param[in] port_id
1641 * The port identifier of the Ethernet device.
1642 * @param[in] node_id
1643 * Node ID. Needs to be valid.
1644 * @param[in] shared_shaper_id
1645 * Shared shaper ID. Needs to be valid.
1647 * Set to non-zero value to add this shared shaper to current node or to zero
1648 * to delete this shared shaper from current node.
1650 * Error details. Filled in only on error, when not NULL.
1652 * 0 on success, non-zero error code otherwise.
1654 * @see struct rte_tm_capabilities::shaper_shared_n_max
1657 rte_tm_node_shared_shaper_update(uint16_t port_id,
1659 uint32_t shared_shaper_id,
1661 struct rte_tm_error *error);
1664 * Traffic manager node enabled statistics counters update
1666 * @param[in] port_id
1667 * The port identifier of the Ethernet device.
1668 * @param[in] node_id
1669 * Node ID. Needs to be valid.
1670 * @param[in] stats_mask
1671 * Mask of statistics counter types to be enabled for the current node. This
1672 * needs to be a subset of the statistics counter types available for the
1673 * current node. Any statistics counter type not included in this set is to
1674 * be disabled for the current node.
1676 * Error details. Filled in only on error, when not NULL.
1678 * 0 on success, non-zero error code otherwise.
1680 * @see enum rte_tm_stats_type
1681 * @see RTE_TM_UPDATE_NODE_STATS
1684 rte_tm_node_stats_update(uint16_t port_id,
1686 uint64_t stats_mask,
1687 struct rte_tm_error *error);
1690 * Traffic manager node WFQ weight mode update
1692 * @param[in] port_id
1693 * The port identifier of the Ethernet device.
1694 * @param[in] node_id
1695 * Node ID. Needs to be valid non-leaf node ID.
1696 * @param[in] wfq_weight_mode
1697 * WFQ weight mode for each SP priority. When NULL, it indicates that WFQ is
1698 * to be used for all priorities. When non-NULL, it points to a pre-allocated
1699 * array of *n_sp_priorities* values, with non-zero value for byte-mode and
1700 * zero for packet-mode.
1701 * @param[in] n_sp_priorities
1702 * Number of SP priorities.
1704 * Error details. Filled in only on error, when not NULL.
1706 * 0 on success, non-zero error code otherwise.
1708 * @see RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE
1709 * @see RTE_TM_UPDATE_NODE_N_SP_PRIORITIES
1712 rte_tm_node_wfq_weight_mode_update(uint16_t port_id,
1714 int *wfq_weight_mode,
1715 uint32_t n_sp_priorities,
1716 struct rte_tm_error *error);
1719 * Traffic manager node congestion management mode update
1721 * @param[in] port_id
1722 * The port identifier of the Ethernet device.
1723 * @param[in] node_id
1724 * Node ID. Needs to be valid leaf node ID.
1726 * Congestion management mode.
1728 * Error details. Filled in only on error, when not NULL.
1730 * 0 on success, non-zero error code otherwise.
1732 * @see RTE_TM_UPDATE_NODE_CMAN
1735 rte_tm_node_cman_update(uint16_t port_id,
1737 enum rte_tm_cman_mode cman,
1738 struct rte_tm_error *error);
1741 * Traffic manager node private WRED context update
1743 * @param[in] port_id
1744 * The port identifier of the Ethernet device.
1745 * @param[in] node_id
1746 * Node ID. Needs to be valid leaf node ID.
1747 * @param[in] wred_profile_id
1748 * WRED profile ID for the private WRED context of the current node. Needs to
1749 * be either valid WRED profile ID or RTE_TM_WRED_PROFILE_ID_NONE, with the
1750 * latter disabling the private WRED context of the current node.
1752 * Error details. Filled in only on error, when not NULL.
1754 * 0 on success, non-zero error code otherwise.
1756 * @see struct rte_tm_capabilities::cman_wred_context_private_n_max
1759 rte_tm_node_wred_context_update(uint16_t port_id,
1761 uint32_t wred_profile_id,
1762 struct rte_tm_error *error);
1765 * Traffic manager node shared WRED context update
1767 * @param[in] port_id
1768 * The port identifier of the Ethernet device.
1769 * @param[in] node_id
1770 * Node ID. Needs to be valid leaf node ID.
1771 * @param[in] shared_wred_context_id
1772 * Shared WRED context ID. Needs to be valid.
1774 * Set to non-zero value to add this shared WRED context to current node or
1775 * to zero to delete this shared WRED context from current node.
1777 * Error details. Filled in only on error, when not NULL.
1779 * 0 on success, non-zero error code otherwise.
1781 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1784 rte_tm_node_shared_wred_context_update(uint16_t port_id,
1786 uint32_t shared_wred_context_id,
1788 struct rte_tm_error *error);
1791 * Traffic manager node statistics counters read
1793 * @param[in] port_id
1794 * The port identifier of the Ethernet device.
1795 * @param[in] node_id
1796 * Node ID. Needs to be valid.
1798 * When non-NULL, it contains the current value for the statistics counters
1799 * enabled for the current node.
1800 * @param[out] stats_mask
1801 * When non-NULL, it contains the mask of statistics counter types that are
1802 * currently enabled for this node, indicating which of the counters
1803 * retrieved with the *stats* structure are valid.
1805 * When this parameter has a non-zero value, the statistics counters are
1806 * cleared (i.e. set to zero) immediately after they have been read,
1807 * otherwise the statistics counters are left untouched.
1809 * Error details. Filled in only on error, when not NULL.
1811 * 0 on success, non-zero error code otherwise.
1813 * @see enum rte_tm_stats_type
1816 rte_tm_node_stats_read(uint16_t port_id,
1818 struct rte_tm_node_stats *stats,
1819 uint64_t *stats_mask,
1821 struct rte_tm_error *error);
1824 * Traffic manager packet marking - VLAN DEI (IEEE 802.1Q)
1826 * IEEE 802.1p maps the traffic class to the VLAN Priority Code Point (PCP)
1827 * field (3 bits), while IEEE 802.1q maps the drop priority to the VLAN Drop
1828 * Eligible Indicator (DEI) field (1 bit), which was previously named Canonical
1829 * Format Indicator (CFI).
1831 * All VLAN frames of a given color get their DEI bit set if marking is enabled
1832 * for this color; otherwise, their DEI bit is left as is (either set or not).
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_vlan_dei_supported
1853 rte_tm_mark_vlan_dei(uint16_t port_id,
1857 struct rte_tm_error *error);
1860 * Traffic manager packet marking - IPv4 / IPv6 ECN (IETF RFC 3168)
1862 * IETF RFCs 2474 and 3168 reorganize the IPv4 Type of Service (TOS) field
1863 * (8 bits) and the IPv6 Traffic Class (TC) field (8 bits) into Differentiated
1864 * Services Codepoint (DSCP) field (6 bits) and Explicit Congestion
1865 * Notification (ECN) field (2 bits). The DSCP field is typically used to
1866 * encode the traffic class and/or drop priority (RFC 2597), while the ECN
1867 * field is used by RFC 3168 to implement a congestion notification mechanism
1868 * to be leveraged by transport layer protocols such as TCP and SCTP that have
1869 * congestion control mechanisms.
1871 * When congestion is experienced, as alternative to dropping the packet,
1872 * routers can change the ECN field of input packets from 2'b01 or 2'b10
1873 * (values indicating that source endpoint is ECN-capable) to 2'b11 (meaning
1874 * that congestion is experienced). The destination endpoint can use the
1875 * ECN-Echo (ECE) TCP flag to relay the congestion indication back to the
1876 * source endpoint, which acknowledges it back to the destination endpoint with
1877 * the Congestion Window Reduced (CWR) TCP flag.
1879 * All IPv4/IPv6 packets of a given color with ECN set to 2’b01 or 2’b10
1880 * carrying TCP or SCTP have their ECN set to 2’b11 if the marking feature is
1881 * enabled for the current color, otherwise the ECN field 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_ecn_tcp_supported
1900 * @see struct rte_tm_capabilities::mark_ip_ecn_sctp_supported
1903 rte_tm_mark_ip_ecn(uint16_t port_id,
1907 struct rte_tm_error *error);
1910 * Traffic manager packet marking - IPv4 / IPv6 DSCP (IETF RFC 2597)
1912 * IETF RFC 2597 maps the traffic class and the drop priority to the IPv4/IPv6
1913 * Differentiated Services Codepoint (DSCP) field (6 bits). Here are the DSCP
1914 * values proposed by this RFC:
1916 * <pre> Class 1 Class 2 Class 3 Class 4 </pre>
1917 * <pre> +----------+----------+----------+----------+</pre>
1918 * <pre>Low Drop Prec | 001010 | 010010 | 011010 | 100010 |</pre>
1919 * <pre>Medium Drop Prec | 001100 | 010100 | 011100 | 100100 |</pre>
1920 * <pre>High Drop Prec | 001110 | 010110 | 011110 | 100110 |</pre>
1921 * <pre> +----------+----------+----------+----------+</pre>
1923 * There are 4 traffic classes (classes 1 .. 4) encoded by DSCP bits 1 and 2,
1924 * as well as 3 drop priorities (low/medium/high) encoded by DSCP bits 3 and 4.
1926 * All IPv4/IPv6 packets have their color marked into DSCP bits 3 and 4 as
1927 * follows: green mapped to Low Drop Precedence (2’b01), yellow to Medium
1928 * (2’b10) and red to High (2’b11). Marking needs to be explicitly enabled
1929 * for each color; when not enabled for a given color, the DSCP field of all
1930 * packets with that color is left as is.
1932 * @param[in] port_id
1933 * The port identifier of the Ethernet device.
1934 * @param[in] mark_green
1935 * Set to non-zero value to enable marking of green packets and to zero to
1937 * @param[in] mark_yellow
1938 * Set to non-zero value to enable marking of yellow packets and to zero to
1940 * @param[in] mark_red
1941 * Set to non-zero value to enable marking of red packets and to zero to
1944 * Error details. Filled in only on error, when not NULL.
1946 * 0 on success, non-zero error code otherwise.
1948 * @see struct rte_tm_capabilities::mark_ip_dscp_supported
1951 rte_tm_mark_ip_dscp(uint16_t port_id,
1955 struct rte_tm_error *error);
1961 #endif /* __INCLUDE_RTE_TM_H__ */