1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation.
3 * Copyright(c) 2017 Cavium.
4 * Copyright(c) 2017 NXP.
7 #ifndef __INCLUDE_RTE_TM_H__
8 #define __INCLUDE_RTE_TM_H__
12 * RTE Generic Traffic Manager API
14 * This interface provides the ability to configure the traffic manager in a
15 * generic way. It includes features such as: hierarchical scheduling,
16 * traffic shaping, congestion management, packet marking, etc.
20 * All functions in this file may be changed or removed without prior notice.
25 #include <rte_common.h>
26 #include <rte_meter.h>
33 * Ethernet framing overhead.
35 * Overhead fields per Ethernet frame:
36 * 1. Preamble: 7 bytes;
37 * 2. Start of Frame Delimiter (SFD): 1 byte;
38 * 3. Inter-Frame Gap (IFG): 12 bytes.
40 * One of the typical values for the *pkt_length_adjust* field of the shaper
43 * @see struct rte_tm_shaper_params
45 #define RTE_TM_ETH_FRAMING_OVERHEAD 20
48 * Ethernet framing overhead including the Frame Check Sequence (FCS) field.
49 * Useful when FCS is generated and added at the end of the Ethernet frame on
50 * TX side without any SW intervention.
52 * One of the typical values for the pkt_length_adjust field of the shaper
55 * @see struct rte_tm_shaper_params
57 #define RTE_TM_ETH_FRAMING_OVERHEAD_FCS 24
60 * Invalid WRED profile ID.
62 * @see struct rte_tm_node_params
63 * @see rte_tm_node_add()
64 * @see rte_tm_node_wred_context_update()
66 #define RTE_TM_WRED_PROFILE_ID_NONE UINT32_MAX
69 *Invalid shaper profile ID.
71 * @see struct rte_tm_node_params
72 * @see rte_tm_node_add()
73 * @see rte_tm_node_shaper_update()
75 #define RTE_TM_SHAPER_PROFILE_ID_NONE UINT32_MAX
78 * Node ID for the parent of the root node.
80 * @see rte_tm_node_add()
82 #define RTE_TM_NODE_ID_NULL UINT32_MAX
85 * Node level ID used to disable level ID checking.
87 * @see rte_tm_node_add()
89 #define RTE_TM_NODE_LEVEL_ID_ANY UINT32_MAX
92 * Node statistics counter type
94 enum rte_tm_stats_type {
95 /** Number of packets scheduled from current node. */
96 RTE_TM_STATS_N_PKTS = 1 << 0,
98 /** Number of bytes scheduled from current node. */
99 RTE_TM_STATS_N_BYTES = 1 << 1,
101 /** Number of green packets dropped by current leaf node. */
102 RTE_TM_STATS_N_PKTS_GREEN_DROPPED = 1 << 2,
104 /** Number of yellow packets dropped by current leaf node. */
105 RTE_TM_STATS_N_PKTS_YELLOW_DROPPED = 1 << 3,
107 /** Number of red packets dropped by current leaf node. */
108 RTE_TM_STATS_N_PKTS_RED_DROPPED = 1 << 4,
110 /** Number of green bytes dropped by current leaf node. */
111 RTE_TM_STATS_N_BYTES_GREEN_DROPPED = 1 << 5,
113 /** Number of yellow bytes dropped by current leaf node. */
114 RTE_TM_STATS_N_BYTES_YELLOW_DROPPED = 1 << 6,
116 /** Number of red bytes dropped by current leaf node. */
117 RTE_TM_STATS_N_BYTES_RED_DROPPED = 1 << 7,
119 /** Number of packets currently waiting in the packet queue of current
122 RTE_TM_STATS_N_PKTS_QUEUED = 1 << 8,
124 /** Number of bytes currently waiting in the packet queue of current
127 RTE_TM_STATS_N_BYTES_QUEUED = 1 << 9,
131 * Node statistics counters
133 struct rte_tm_node_stats {
134 /** Number of packets scheduled from current node. */
137 /** Number of bytes scheduled from current node. */
140 /** Statistics counters for leaf nodes only. */
142 /** Number of packets dropped by current leaf node per each
145 uint64_t n_pkts_dropped[RTE_COLORS];
147 /** Number of bytes dropped by current leaf node per each
150 uint64_t n_bytes_dropped[RTE_COLORS];
152 /** Number of packets currently waiting in the packet queue of
155 uint64_t n_pkts_queued;
157 /** Number of bytes currently waiting in the packet queue of
160 uint64_t n_bytes_queued;
165 * Traffic manager dynamic updates
167 enum rte_tm_dynamic_update_type {
168 /** Dynamic parent node update. The new parent node is located on same
169 * hierarchy level as the former parent node. Consequently, the node
170 * whose parent is changed preserves its hierarchy level.
172 RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL = 1 << 0,
174 /** Dynamic parent node update. The new parent node is located on
175 * different hierarchy level than the former parent node. Consequently,
176 * the node whose parent is changed also changes its hierarchy level.
178 RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL = 1 << 1,
180 /** Dynamic node add/delete. */
181 RTE_TM_UPDATE_NODE_ADD_DELETE = 1 << 2,
183 /** Suspend/resume nodes. */
184 RTE_TM_UPDATE_NODE_SUSPEND_RESUME = 1 << 3,
186 /** Dynamic switch between byte-based and packet-based WFQ weights. */
187 RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE = 1 << 4,
189 /** Dynamic update on number of SP priorities. */
190 RTE_TM_UPDATE_NODE_N_SP_PRIORITIES = 1 << 5,
192 /** Dynamic update of congestion management mode for leaf nodes. */
193 RTE_TM_UPDATE_NODE_CMAN = 1 << 6,
195 /** Dynamic update of the set of enabled stats counter types. */
196 RTE_TM_UPDATE_NODE_STATS = 1 << 7,
200 * Traffic manager capabilities
202 struct rte_tm_capabilities {
203 /** Maximum number of nodes. */
204 uint32_t n_nodes_max;
206 /** Maximum number of levels (i.e. number of nodes connecting the root
207 * node with any leaf node, including the root and the leaf).
209 uint32_t n_levels_max;
211 /** When non-zero, this flag indicates that all the non-leaf nodes
212 * (with the exception of the root node) have identical capability set.
214 int non_leaf_nodes_identical;
216 /** When non-zero, this flag indicates that all the leaf nodes have
217 * identical capability set.
219 int leaf_nodes_identical;
221 /** Maximum number of shapers, either private or shared. In case the
222 * implementation does not share any resources between private and
223 * shared shapers, it is typically equal to the sum of
224 * *shaper_private_n_max* and *shaper_shared_n_max*. The
225 * value of zero indicates that traffic shaping is not supported.
227 uint32_t shaper_n_max;
229 /** Maximum number of private shapers. Indicates the maximum number of
230 * nodes that can concurrently have their private shaper enabled. The
231 * value of zero indicates that private shapers are not supported.
233 uint32_t shaper_private_n_max;
235 /** Maximum number of private shapers that support dual rate shaping.
236 * Indicates the maximum number of nodes that can concurrently have
237 * their private shaper enabled with dual rate support. Only valid when
238 * private shapers are supported. The value of zero indicates that dual
239 * rate shaping is not available for private shapers. The maximum value
240 * is *shaper_private_n_max*.
242 int shaper_private_dual_rate_n_max;
244 /** Minimum committed/peak rate (bytes per second) for any private
245 * shaper. Valid only when private shapers are supported.
247 uint64_t shaper_private_rate_min;
249 /** Maximum committed/peak rate (bytes per second) for any private
250 * shaper. Valid only when private shapers are supported.
252 uint64_t shaper_private_rate_max;
254 /** Shaper private packet mode supported. When non-zero, this parameter
255 * indicates that there is at least one node that can be configured
256 * with packet mode in its private shaper. When shaper is configured
257 * in packet mode, committed/peak rate provided is interpreted
258 * in packets per second.
260 int shaper_private_packet_mode_supported;
262 /** Shaper private byte mode supported. When non-zero, this parameter
263 * indicates that there is at least one node that can be configured
264 * with byte mode in its private shaper. When shaper is configured
265 * in byte mode, committed/peak rate provided is interpreted in
268 int shaper_private_byte_mode_supported;
271 /** Maximum number of shared shapers. The value of zero indicates that
272 * shared shapers are not supported.
274 uint32_t shaper_shared_n_max;
276 /** Maximum number of nodes that can share the same shared shaper.
277 * Only valid when shared shapers are supported.
279 uint32_t shaper_shared_n_nodes_per_shaper_max;
281 /** Maximum number of shared shapers a node can be part of. This
282 * parameter indicates that there is at least one node that can be
283 * configured with this many shared shapers, which might not be true for
284 * all the nodes. Only valid when shared shapers are supported, in which
285 * case it ranges from 1 to *shaper_shared_n_max*.
287 uint32_t shaper_shared_n_shapers_per_node_max;
289 /** Maximum number of shared shapers that can be configured with dual
290 * rate shaping. The value of zero indicates that dual rate shaping
291 * support is not available for shared shapers.
293 uint32_t shaper_shared_dual_rate_n_max;
295 /** Minimum committed/peak rate (bytes per second) for any shared
296 * shaper. Only valid when shared shapers are supported.
298 uint64_t shaper_shared_rate_min;
300 /** Maximum committed/peak rate (bytes per second) for any shared
301 * shaper. Only valid when shared shapers are supported.
303 uint64_t shaper_shared_rate_max;
305 /** Shaper shared packet mode supported. When non-zero, this parameter
306 * indicates a shared shaper can be configured with packet mode.
307 * When shared shaper is configured in packet mode, committed/peak rate
308 * provided is interpreted in packets per second.
310 int shaper_shared_packet_mode_supported;
312 /** Shaper shared byte mode supported. When non-zero, this parameter
313 * indicates that a shared shaper can be configured with byte mode.
314 * When shared shaper is configured in byte mode, committed/peak rate
315 * provided is interpreted in bytes per second.
317 int shaper_shared_byte_mode_supported;
320 /** Minimum value allowed for packet length adjustment for any private
323 int shaper_pkt_length_adjust_min;
325 /** Maximum value allowed for packet length adjustment for any private
328 int shaper_pkt_length_adjust_max;
330 /** Maximum number of children nodes. This parameter indicates that
331 * there is at least one non-leaf node that can be configured with this
332 * many children nodes, which might not be true for all the non-leaf
335 uint32_t sched_n_children_max;
337 /** Maximum number of supported priority levels. This parameter
338 * indicates that there is at least one non-leaf node that can be
339 * configured with this many priority levels for managing its children
340 * nodes, which might not be true for all the non-leaf nodes. The value
341 * of zero is invalid. The value of 1 indicates that only priority 0 is
342 * supported, which essentially means that Strict Priority (SP)
343 * algorithm is not supported.
345 uint32_t sched_sp_n_priorities_max;
347 /** Maximum number of sibling nodes that can have the same priority at
348 * any given time, i.e. maximum size of the WFQ sibling node group. This
349 * parameter indicates there is at least one non-leaf node that meets
350 * this condition, which might not be true for all the non-leaf nodes.
351 * The value of zero is invalid. The value of 1 indicates that WFQ
352 * algorithm is not supported. The maximum value is
353 * *sched_n_children_max*.
355 uint32_t sched_wfq_n_children_per_group_max;
357 /** Maximum number of priority levels that can have more than one child
358 * node at any given time, i.e. maximum number of WFQ sibling node
359 * groups that have two or more members. This parameter indicates there
360 * is at least one non-leaf node that meets this condition, which might
361 * not be true for all the non-leaf nodes. The value of zero states that
362 * WFQ algorithm is not supported. The value of 1 indicates that
363 * (*sched_sp_n_priorities_max* - 1) priority levels have at most one
364 * child node, so there can be only one priority level with two or
365 * more sibling nodes making up a WFQ group. The maximum value is:
366 * min(floor(*sched_n_children_max* / 2), *sched_sp_n_priorities_max*).
368 uint32_t sched_wfq_n_groups_max;
370 /** Maximum WFQ weight. The value of 1 indicates that all sibling nodes
371 * with same priority have the same WFQ weight, so WFQ is reduced to FQ.
373 uint32_t sched_wfq_weight_max;
375 /** WFQ packet mode supported. When non-zero, this parameter indicates
376 * that there is at least one non-leaf node that supports packet mode
377 * for WFQ among its children. WFQ weights will be applied against
378 * packet count for scheduling children when a non-leaf node
379 * is configured appropriately.
381 int sched_wfq_packet_mode_supported;
383 /** WFQ byte mode supported. When non-zero, this parameter indicates
384 * that there is at least one non-leaf node that supports byte mode
385 * for WFQ among its children. WFQ weights will be applied against
386 * bytes for scheduling children when a non-leaf node is configured
389 int sched_wfq_byte_mode_supported;
391 /** WRED packet mode support. When non-zero, this parameter indicates
392 * that there is at least one leaf node that supports the WRED packet
393 * mode, which might not be true for all the leaf nodes. In packet
394 * mode, the WRED thresholds specify the queue length in packets, as
397 int cman_wred_packet_mode_supported;
399 /** WRED byte mode support. When non-zero, this parameter indicates that
400 * there is at least one leaf node that supports the WRED byte mode,
401 * which might not be true for all the leaf nodes. In byte mode, the
402 * WRED thresholds specify the queue length in bytes, as opposed to
405 int cman_wred_byte_mode_supported;
407 /** Head drop algorithm support. When non-zero, this parameter
408 * indicates that there is at least one leaf node that supports the head
409 * drop algorithm, which might not be true for all the leaf nodes.
411 int cman_head_drop_supported;
413 /** Maximum number of WRED contexts, either private or shared. In case
414 * the implementation does not share any resources between private and
415 * shared WRED contexts, it is typically equal to the sum of
416 * *cman_wred_context_private_n_max* and
417 * *cman_wred_context_shared_n_max*. The value of zero indicates that
418 * WRED is not supported.
420 uint32_t cman_wred_context_n_max;
422 /** Maximum number of private WRED contexts. Indicates the maximum
423 * number of leaf nodes that can concurrently have their private WRED
424 * context enabled. The value of zero indicates that private WRED
425 * contexts are not supported.
427 uint32_t cman_wred_context_private_n_max;
429 /** Maximum number of shared WRED contexts. The value of zero
430 * indicates that shared WRED contexts are not supported.
432 uint32_t cman_wred_context_shared_n_max;
434 /** Maximum number of leaf nodes that can share the same WRED context.
435 * Only valid when shared WRED contexts are supported.
437 uint32_t cman_wred_context_shared_n_nodes_per_context_max;
439 /** Maximum number of shared WRED contexts a leaf node can be part of.
440 * This parameter indicates that there is at least one leaf node that
441 * can be configured with this many shared WRED contexts, which might
442 * not be true for all the leaf nodes. Only valid when shared WRED
443 * contexts are supported, in which case it ranges from 1 to
444 * *cman_wred_context_shared_n_max*.
446 uint32_t cman_wred_context_shared_n_contexts_per_node_max;
448 /** Support for VLAN DEI packet marking (per color). */
449 int mark_vlan_dei_supported[RTE_COLORS];
451 /** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */
452 int mark_ip_ecn_tcp_supported[RTE_COLORS];
454 /** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */
455 int mark_ip_ecn_sctp_supported[RTE_COLORS];
457 /** Support for IPv4/IPv6 DSCP packet marking (per color). */
458 int mark_ip_dscp_supported[RTE_COLORS];
460 /** Set of supported dynamic update operations.
461 * @see enum rte_tm_dynamic_update_type
463 uint64_t dynamic_update_mask;
465 /** Set of supported statistics counter types.
466 * @see enum rte_tm_stats_type
472 * Traffic manager level capabilities
474 struct rte_tm_level_capabilities {
475 /** Maximum number of nodes for the current hierarchy level. */
476 uint32_t n_nodes_max;
478 /** Maximum number of non-leaf nodes for the current hierarchy level.
479 * The value of 0 indicates that current level only supports leaf
480 * nodes. The maximum value is *n_nodes_max*.
482 uint32_t n_nodes_nonleaf_max;
484 /** Maximum number of leaf nodes for the current hierarchy level. The
485 * value of 0 indicates that current level only supports non-leaf
486 * nodes. The maximum value is *n_nodes_max*.
488 uint32_t n_nodes_leaf_max;
490 /** When non-zero, this flag indicates that all the non-leaf nodes on
491 * this level have identical capability set. Valid only when
492 * *n_nodes_nonleaf_max* is non-zero.
494 int non_leaf_nodes_identical;
496 /** When non-zero, this flag indicates that all the leaf nodes on this
497 * level have identical capability set. Valid only when
498 * *n_nodes_leaf_max* is non-zero.
500 int leaf_nodes_identical;
504 /** Items valid only for the non-leaf nodes on this level. */
506 /** Private shaper support. When non-zero, it indicates
507 * there is at least one non-leaf node on this level
508 * with private shaper support, which may not be the
509 * case for all the non-leaf nodes on this level.
511 int shaper_private_supported;
513 /** Dual rate support for private shaper. Valid only
514 * when private shaper is supported for the non-leaf
515 * nodes on the current level. When non-zero, it
516 * indicates there is at least one non-leaf node on this
517 * level with dual rate private shaper support, which
518 * may not be the case for all the non-leaf nodes on
521 int shaper_private_dual_rate_supported;
523 /** Minimum committed/peak rate (bytes per second) for
524 * private shapers of the non-leaf nodes of this level.
525 * Valid only when private shaper is supported on this
528 uint64_t shaper_private_rate_min;
530 /** Maximum committed/peak rate (bytes per second) for
531 * private shapers of the non-leaf nodes on this level.
532 * Valid only when private shaper is supported on this
535 uint64_t shaper_private_rate_max;
537 /** Shaper private packet mode supported. When non-zero,
538 * this parameter indicates there is at least one
539 * non-leaf node at this level that can be configured
540 * with packet mode in its private shaper. When private
541 * shaper is configured in packet mode, committed/peak
542 * rate provided is interpreted in packets per second.
544 int shaper_private_packet_mode_supported;
546 /** Shaper private byte mode supported. When non-zero,
547 * this parameter indicates there is at least one
548 * non-leaf node at this level that can be configured
549 * with byte mode in its private shaper. When private
550 * shaper is configured in byte mode, committed/peak
551 * rate provided is interpreted in bytes per second.
553 int shaper_private_byte_mode_supported;
555 /** Maximum number of shared shapers that any non-leaf
556 * node on this level can be part of. The value of zero
557 * indicates that shared shapers are not supported by
558 * the non-leaf nodes on this level. When non-zero, it
559 * indicates there is at least one non-leaf node on this
560 * level that meets this condition, which may not be the
561 * case for all the non-leaf nodes on this level.
563 uint32_t shaper_shared_n_max;
565 /** Shaper shared packet mode supported. When non-zero,
566 * this parameter indicates that there is at least one
567 * non-leaf node on this level that can be part of
568 * shared shapers which work in packet mode.
570 int shaper_shared_packet_mode_supported;
572 /** Shaper shared byte mode supported. When non-zero,
573 * this parameter indicates that there is at least one
574 * non-leaf node on this level that can be part of
575 * shared shapers which work in byte mode.
577 int shaper_shared_byte_mode_supported;
579 /** Maximum number of children nodes. This parameter
580 * indicates that there is at least one non-leaf node on
581 * this level that can be configured with this many
582 * children nodes, which might not be true for all the
583 * non-leaf nodes on this level.
585 uint32_t sched_n_children_max;
587 /** Maximum number of supported priority levels. This
588 * parameter indicates that there is at least one
589 * non-leaf node on this level that can be configured
590 * with this many priority levels for managing its
591 * children nodes, which might not be true for all the
592 * non-leaf nodes on this level. The value of zero is
593 * invalid. The value of 1 indicates that only priority
594 * 0 is supported, which essentially means that Strict
595 * Priority (SP) algorithm is not supported on this
598 uint32_t sched_sp_n_priorities_max;
600 /** Maximum number of sibling nodes that can have the
601 * same priority at any given time, i.e. maximum size of
602 * the WFQ sibling node group. This parameter indicates
603 * there is at least one non-leaf node on this level
604 * that meets this condition, which may not be true for
605 * all the non-leaf nodes on this level. The value of
606 * zero is invalid. The value of 1 indicates that WFQ
607 * algorithm is not supported on this level. The maximum
608 * value is *sched_n_children_max*.
610 uint32_t sched_wfq_n_children_per_group_max;
612 /** Maximum number of priority levels that can have
613 * more than one child node at any given time, i.e.
614 * maximum number of WFQ sibling node groups that
615 * have two or more members. This parameter indicates
616 * there is at least one non-leaf node on this level
617 * that meets this condition, which might not be true
618 * for all the non-leaf nodes. The value of zero states
619 * that WFQ algorithm is not supported on this level.
620 * The value of 1 indicates that
621 * (*sched_sp_n_priorities_max* - 1) priority levels on
622 * this level have at most one child node, so there can
623 * be only one priority level with two or more sibling
624 * nodes making up a WFQ group on this level. The
626 * min(floor(*sched_n_children_max* / 2),
627 * *sched_sp_n_priorities_max*).
629 uint32_t sched_wfq_n_groups_max;
631 /** Maximum WFQ weight. The value of 1 indicates that
632 * all sibling nodes on this level with same priority
633 * have the same WFQ weight, so on this level WFQ is
636 uint32_t sched_wfq_weight_max;
638 /** WFQ packet mode supported. When non-zero, this
639 * parameter indicates that there is at least one
640 * non-leaf node at this level that supports packet
641 * mode for WFQ among its children. WFQ weights will
642 * be applied against packet count for scheduling
643 * children when a non-leaf node is configured
646 int sched_wfq_packet_mode_supported;
648 /** WFQ byte mode supported. When non-zero, this
649 * parameter indicates that there is at least one
650 * non-leaf node at this level that supports byte
651 * mode for WFQ among its children. WFQ weights will
652 * be applied against bytes for scheduling children
653 * when a non-leaf node is configured appropriately.
655 int sched_wfq_byte_mode_supported;
657 /** Mask of statistics counter types supported by the
658 * non-leaf nodes on this level. Every supported
659 * statistics counter type is supported by at least one
660 * non-leaf node on this level, which may not be true
661 * for all the non-leaf nodes on this level.
662 * @see enum rte_tm_stats_type
667 /** Items valid only for the leaf nodes on this level. */
669 /** Private shaper support. When non-zero, it indicates
670 * there is at least one leaf node on this level with
671 * private shaper support, which may not be the case for
672 * all the leaf nodes on this level.
674 int shaper_private_supported;
676 /** Dual rate support for private shaper. Valid only
677 * when private shaper is supported for the leaf nodes
678 * on this level. When non-zero, it indicates there is
679 * at least one leaf node on this level with dual rate
680 * private shaper support, which may not be the case for
681 * all the leaf nodes on this level.
683 int shaper_private_dual_rate_supported;
685 /** Minimum committed/peak rate (bytes per second) for
686 * private shapers of the leaf nodes of this level.
687 * Valid only when private shaper is supported for the
688 * leaf nodes on this level.
690 uint64_t shaper_private_rate_min;
692 /** Maximum committed/peak rate (bytes per second) for
693 * private shapers of the leaf nodes on this level.
694 * Valid only when private shaper is supported for the
695 * leaf nodes on this level.
697 uint64_t shaper_private_rate_max;
699 /** Shaper private packet mode supported. When non-zero,
700 * this parameter indicates there is at least one leaf
701 * node at this level that can be configured with
702 * packet mode in its private shaper. When private
703 * shaper is configured in packet mode, committed/peak
704 * rate provided is interpreted in packets per second.
706 int shaper_private_packet_mode_supported;
708 /** Shaper private byte mode supported. When non-zero,
709 * this parameter indicates there is at least one leaf
710 * node at this level that can be configured with
711 * byte mode in its private shaper. When private shaper
712 * is configured in byte mode, committed/peak rate
713 * provided is interpreted in bytes per second.
715 int shaper_private_byte_mode_supported;
717 /** Maximum number of shared shapers that any leaf node
718 * on this level can be part of. The value of zero
719 * indicates that shared shapers are not supported by
720 * the leaf nodes on this level. When non-zero, it
721 * indicates there is at least one leaf node on this
722 * level that meets this condition, which may not be the
723 * case for all the leaf nodes on this level.
725 uint32_t shaper_shared_n_max;
727 /** Shaper shared packet mode supported. When non-zero,
728 * this parameter indicates that there is at least one
729 * leaf node on this level that can be part of
730 * shared shapers which work in packet mode.
732 int shaper_shared_packet_mode_supported;
734 /** Shaper shared byte mode supported. When non-zero,
735 * this parameter indicates that there is at least one
736 * leaf node on this level that can be part of
737 * shared shapers which work in byte mode.
739 int shaper_shared_byte_mode_supported;
741 /** WRED packet mode support. When non-zero, this
742 * parameter indicates that there is at least one leaf
743 * node on this level that supports the WRED packet
744 * mode, which might not be true for all the leaf
745 * nodes. In packet mode, the WRED thresholds specify
746 * the queue length in packets, as opposed to bytes.
748 int cman_wred_packet_mode_supported;
750 /** WRED byte mode support. When non-zero, this
751 * parameter indicates that there is at least one leaf
752 * node on this level that supports the WRED byte mode,
753 * which might not be true for all the leaf nodes. In
754 * byte mode, the WRED thresholds specify the queue
755 * length in bytes, as opposed to packets.
757 int cman_wred_byte_mode_supported;
759 /** Head drop algorithm support. When non-zero, this
760 * parameter indicates that there is at least one leaf
761 * node on this level that supports the head drop
762 * algorithm, which might not be true for all the leaf
763 * nodes on this level.
765 int cman_head_drop_supported;
767 /** Private WRED context support. When non-zero, it
768 * indicates there is at least one node on this level
769 * with private WRED context support, which may not be
770 * true for all the leaf nodes on this level.
772 int cman_wred_context_private_supported;
774 /** Maximum number of shared WRED contexts that any
775 * leaf node on this level can be part of. The value of
776 * zero indicates that shared WRED contexts are not
777 * supported by the leaf nodes on this level. When
778 * non-zero, it indicates there is at least one leaf
779 * node on this level that meets this condition, which
780 * may not be the case for all the leaf nodes on this
783 uint32_t cman_wred_context_shared_n_max;
785 /** Mask of statistics counter types supported by the
786 * leaf nodes on this level. Every supported statistics
787 * counter type is supported by at least one leaf node
788 * on this level, which may not be true for all the leaf
789 * nodes on this level.
790 * @see enum rte_tm_stats_type
798 * Traffic manager node capabilities
800 struct rte_tm_node_capabilities {
801 /** Private shaper support for the current node. */
802 int shaper_private_supported;
804 /** Dual rate shaping support for private shaper of current node.
805 * Valid only when private shaper is supported by the current node.
807 int shaper_private_dual_rate_supported;
809 /** Minimum committed/peak rate (bytes per second) for private
810 * shaper of current node. Valid only when private shaper is supported
811 * by the current node.
813 uint64_t shaper_private_rate_min;
815 /** Maximum committed/peak rate (bytes per second) for private
816 * shaper of current node. Valid only when private shaper is supported
817 * by the current node.
819 uint64_t shaper_private_rate_max;
821 /** Shaper private packet mode supported. When non-zero, this parameter
822 * indicates private shaper of current node can be configured with
823 * packet mode. When configured in packet mode, committed/peak rate
824 * provided is interpreted in packets per second.
826 int shaper_private_packet_mode_supported;
828 /** Shaper private byte mode supported. When non-zero, this parameter
829 * indicates private shaper of current node can be configured with
830 * byte mode. When configured in byte mode, committed/peak rate
831 * provided is interpreted in bytes per second.
833 int shaper_private_byte_mode_supported;
835 /** Maximum number of shared shapers the current node can be part of.
836 * The value of zero indicates that shared shapers are not supported by
839 uint32_t shaper_shared_n_max;
841 /** Shaper shared packet mode supported. When non-zero,
842 * this parameter indicates that current node can be part of
843 * shared shapers which work in packet mode.
845 int shaper_shared_packet_mode_supported;
847 /** Shaper shared byte mode supported. When non-zero,
848 * this parameter indicates that current node can be part of
849 * shared shapers which work in byte mode.
851 int shaper_shared_byte_mode_supported;
855 /** Items valid only for non-leaf nodes. */
857 /** Maximum number of children nodes. */
858 uint32_t sched_n_children_max;
860 /** Maximum number of supported priority levels. The
861 * value of zero is invalid. The value of 1 indicates
862 * that only priority 0 is supported, which essentially
863 * means that Strict Priority (SP) algorithm is not
866 uint32_t sched_sp_n_priorities_max;
868 /** Maximum number of sibling nodes that can have the
869 * same priority at any given time, i.e. maximum size
870 * of the WFQ sibling node group. The value of zero
871 * is invalid. The value of 1 indicates that WFQ
872 * algorithm is not supported. The maximum value is
873 * *sched_n_children_max*.
875 uint32_t sched_wfq_n_children_per_group_max;
877 /** Maximum number of priority levels that can have
878 * more than one child node at any given time, i.e.
879 * maximum number of WFQ sibling node groups that have
880 * two or more members. The value of zero states that
881 * WFQ algorithm is not supported. The value of 1
882 * indicates that (*sched_sp_n_priorities_max* - 1)
883 * priority levels have at most one child node, so there
884 * can be only one priority level with two or more
885 * sibling nodes making up a WFQ group. The maximum
886 * value is: min(floor(*sched_n_children_max* / 2),
887 * *sched_sp_n_priorities_max*).
889 uint32_t sched_wfq_n_groups_max;
891 /** Maximum WFQ weight. The value of 1 indicates that
892 * all sibling nodes with same priority have the same
893 * WFQ weight, so WFQ is reduced to FQ.
895 uint32_t sched_wfq_weight_max;
897 /** WFQ packet mode supported. When non-zero, this
898 * parameter indicates that current node supports packet
899 * mode for WFQ among its children. WFQ weights will be
900 * applied against packet count for scheduling children
901 * when configured appropriately.
903 int sched_wfq_packet_mode_supported;
905 /** WFQ byte mode supported. When non-zero, this
906 * parameter indicates that current node supports byte
907 * mode for WFQ among its children. WFQ weights will be
908 * applied against bytes for scheduling children when
909 * configured appropriately.
911 int sched_wfq_byte_mode_supported;
915 /** Items valid only for leaf nodes. */
917 /** WRED packet mode support for current node. */
918 int cman_wred_packet_mode_supported;
920 /** WRED byte mode support for current node. */
921 int cman_wred_byte_mode_supported;
923 /** Head drop algorithm support for current node. */
924 int cman_head_drop_supported;
926 /** Private WRED context support for current node. */
927 int cman_wred_context_private_supported;
929 /** Maximum number of shared WRED contexts the current
930 * node can be part of. The value of zero indicates that
931 * shared WRED contexts are not supported by the current
934 uint32_t cman_wred_context_shared_n_max;
938 /** Mask of statistics counter types supported by the current node.
939 * @see enum rte_tm_stats_type
945 * Congestion management (CMAN) mode
947 * This is used for controlling the admission of packets into a packet queue or
948 * group of packet queues on congestion. On request of writing a new packet
949 * into the current queue while the queue is full, the *tail drop* algorithm
950 * drops the new packet while leaving the queue unmodified, as opposed to *head
951 * drop* algorithm, which drops the packet at the head of the queue (the oldest
952 * packet waiting in the queue) and admits the new packet at the tail of the
955 * The *Random Early Detection (RED)* algorithm works by proactively dropping
956 * more and more input packets as the queue occupancy builds up. When the queue
957 * is full or almost full, RED effectively works as *tail drop*. The *Weighted
958 * RED* algorithm uses a separate set of RED thresholds for each packet color.
960 enum rte_tm_cman_mode {
961 RTE_TM_CMAN_TAIL_DROP = 0, /**< Tail drop */
962 RTE_TM_CMAN_HEAD_DROP, /**< Head drop */
963 RTE_TM_CMAN_WRED, /**< Weighted Random Early Detection (WRED) */
967 * Random Early Detection (RED) profile
969 struct rte_tm_red_params {
970 /** Minimum queue threshold */
973 /** Maximum queue threshold */
976 /** Inverse of packet marking probability maximum value (maxp), i.e.
977 * maxp_inv = 1 / maxp
981 /** Negated log2 of queue weight (wq), i.e. wq = 1 / (2 ^ wq_log2) */
986 * Weighted RED (WRED) profile
988 * Multiple WRED contexts can share the same WRED profile. Each leaf node with
989 * WRED enabled as its congestion management mode has zero or one private WRED
990 * context (only one leaf node using it) and/or zero, one or several shared
991 * WRED contexts (multiple leaf nodes use the same WRED context). A private
992 * WRED context is used to perform congestion management for a single leaf
993 * node, while a shared WRED context is used to perform congestion management
994 * for a group of leaf nodes.
996 * @see struct rte_tm_capabilities::cman_wred_packet_mode_supported
997 * @see struct rte_tm_capabilities::cman_wred_byte_mode_supported
999 struct rte_tm_wred_params {
1000 /** One set of RED parameters per packet color */
1001 struct rte_tm_red_params red_params[RTE_COLORS];
1003 /** When non-zero, the *min_th* and *max_th* thresholds are specified
1004 * in packets (WRED packet mode). When zero, the *min_th* and *max_th*
1005 * thresholds are specified in bytes (WRED byte mode)
1013 struct rte_tm_token_bucket {
1014 /** Token bucket rate (bytes per second or packets per second) */
1017 /** Token bucket size (bytes or packets), a.k.a. max burst size */
1022 * Shaper (rate limiter) profile
1024 * Multiple shaper instances can share the same shaper profile. Each node has
1025 * zero or one private shaper (only one node using it) and/or zero, one or
1026 * several shared shapers (multiple nodes use the same shaper instance).
1027 * A private shaper is used to perform traffic shaping for a single node, while
1028 * a shared shaper is used to perform traffic shaping for a group of nodes.
1030 * Single rate shapers use a single token bucket. A single rate shaper can be
1031 * configured by setting the rate of the committed bucket to zero, which
1032 * effectively disables this bucket. The peak bucket is used to limit the rate
1033 * and the burst size for the current shaper.
1035 * Dual rate shapers use both the committed and the peak token buckets. The
1036 * rate of the peak bucket has to be bigger than zero, as well as greater than
1037 * or equal to the rate of the committed bucket.
1039 * @see struct rte_tm_capabilities::shaper_private_packet_mode_supported
1040 * @see struct rte_tm_capabilities::shaper_private_byte_mode_supported
1041 * @see struct rte_tm_capabilities::shaper_shared_packet_mode_supported
1042 * @see struct rte_tm_capabilities::shaper_shared_byte_mode_supported
1044 struct rte_tm_shaper_params {
1045 /** Committed token bucket */
1046 struct rte_tm_token_bucket committed;
1048 /** Peak token bucket */
1049 struct rte_tm_token_bucket peak;
1051 /** Signed value to be added to the length of each packet for the
1052 * purpose of shaping. Can be used to correct the packet length with
1053 * the framing overhead bytes that are also consumed on the wire (e.g.
1054 * RTE_TM_ETH_FRAMING_OVERHEAD_FCS).
1055 * This field is ignored when the profile enables packet mode.
1057 int32_t pkt_length_adjust;
1059 /** When zero, the byte mode is enabled for the current profile, so the
1060 * *rate* and *size* fields in both the committed and peak token buckets
1061 * are specified in bytes per second and bytes, respectively.
1062 * When non-zero, the packet mode is enabled for the current profile,
1063 * so the *rate* and *size* fields in both the committed and peak token
1064 * buckets are specified in packets per second and packets,
1073 * Each non-leaf node has multiple inputs (its children nodes) and single output
1074 * (which is input to its parent node). It arbitrates its inputs using Strict
1075 * Priority (SP) and Weighted Fair Queuing (WFQ) algorithms to schedule input
1076 * packets to its output while observing its shaping (rate limiting)
1079 * Algorithms such as Weighted Round Robin (WRR), Byte-level WRR, Deficit WRR
1080 * (DWRR), etc. are considered approximations of the WFQ ideal and are
1081 * assimilated to WFQ, although an associated implementation-dependent trade-off
1082 * on accuracy, performance and resource usage might exist.
1084 * Children nodes with different priorities are scheduled using the SP algorithm
1085 * based on their priority, with zero (0) as the highest priority. Children with
1086 * the same priority are scheduled using the WFQ algorithm according to their
1087 * weights. The WFQ weight of a given child node is relative to the sum of the
1088 * weights of all its sibling nodes that have the same priority, with one (1) as
1089 * the lowest weight. For each SP priority, the WFQ weight mode can be set as
1090 * either byte-based or packet-based.
1092 * Each leaf node sits on top of a TX queue of the current Ethernet port. Hence,
1093 * the leaf nodes are predefined, with their node IDs set to 0 .. (N-1), where N
1094 * is the number of TX queues configured for the current Ethernet port. The
1095 * non-leaf nodes have their IDs generated by the application.
1097 struct rte_tm_node_params {
1098 /** Shaper profile for the private shaper. The absence of the private
1099 * shaper for the current node is indicated by setting this parameter
1100 * to RTE_TM_SHAPER_PROFILE_ID_NONE.
1102 uint32_t shaper_profile_id;
1104 /** User allocated array of valid shared shaper IDs. */
1105 uint32_t *shared_shaper_id;
1107 /** Number of shared shaper IDs in the *shared_shaper_id* array. */
1108 uint32_t n_shared_shapers;
1112 /** Parameters only valid for non-leaf nodes. */
1114 /** WFQ weight mode for each SP priority. When NULL, it
1115 * indicates that WFQ is to be used for all priorities.
1116 * When non-NULL, it points to a pre-allocated array of
1117 * *n_sp_priorities* values, with non-zero value for
1118 * byte-mode and zero for packet-mode.
1119 * @see struct rte_tm_node_capabilities::sched_wfq_packet_mode_supported
1120 * @see struct rte_tm_node_capabilities::sched_wfq_byte_mode_supported
1122 int *wfq_weight_mode;
1124 /** Number of SP priorities. */
1125 uint32_t n_sp_priorities;
1128 /** Parameters only valid for leaf nodes. */
1130 /** Congestion management mode */
1131 enum rte_tm_cman_mode cman;
1133 /** WRED parameters (only valid when *cman* is set to
1137 /** WRED profile for private WRED context. The
1138 * absence of a private WRED context for the
1139 * current leaf node is indicated by value
1140 * RTE_TM_WRED_PROFILE_ID_NONE.
1142 uint32_t wred_profile_id;
1144 /** User allocated array of shared WRED context
1145 * IDs. When set to NULL, it indicates that the
1146 * current leaf node should not currently be
1147 * part of any shared WRED contexts.
1149 uint32_t *shared_wred_context_id;
1151 /** Number of elements in the
1152 * *shared_wred_context_id* array. Only valid
1153 * when *shared_wred_context_id* is non-NULL,
1154 * in which case it should be non-zero.
1156 uint32_t n_shared_wred_contexts;
1161 /** Mask of statistics counter types to be enabled for this node. This
1162 * needs to be a subset of the statistics counter types available for
1163 * the current node. Any statistics counter type not included in this
1164 * set is to be disabled for the current node.
1165 * @see enum rte_tm_stats_type
1167 uint64_t stats_mask;
1171 * Verbose error types.
1173 * Most of them provide the type of the object referenced by struct
1174 * rte_tm_error::cause.
1176 enum rte_tm_error_type {
1177 RTE_TM_ERROR_TYPE_NONE, /**< No error. */
1178 RTE_TM_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
1179 RTE_TM_ERROR_TYPE_CAPABILITIES,
1180 RTE_TM_ERROR_TYPE_LEVEL_ID,
1181 RTE_TM_ERROR_TYPE_WRED_PROFILE,
1182 RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN,
1183 RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW,
1184 RTE_TM_ERROR_TYPE_WRED_PROFILE_RED,
1185 RTE_TM_ERROR_TYPE_WRED_PROFILE_ID,
1186 RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID,
1187 RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
1188 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE,
1189 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE,
1190 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
1191 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
1192 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN,
1193 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PACKET_MODE,
1194 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
1195 RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID,
1196 RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID,
1197 RTE_TM_ERROR_TYPE_NODE_PRIORITY,
1198 RTE_TM_ERROR_TYPE_NODE_WEIGHT,
1199 RTE_TM_ERROR_TYPE_NODE_PARAMS,
1200 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID,
1201 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID,
1202 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS,
1203 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE,
1204 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES,
1205 RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN,
1206 RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID,
1207 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID,
1208 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS,
1209 RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
1210 RTE_TM_ERROR_TYPE_NODE_ID,
1214 * Verbose error structure definition.
1216 * This object is normally allocated by applications and set by PMDs, the
1217 * message points to a constant string which does not need to be freed by
1218 * the application, however its pointer can be considered valid only as long
1219 * as its associated DPDK port remains configured. Closing the underlying
1220 * device or unloading the PMD invalidates it.
1222 * Both cause and message may be NULL regardless of the error type.
1224 struct rte_tm_error {
1225 enum rte_tm_error_type type; /**< Cause field and error type. */
1226 const void *cause; /**< Object responsible for the error. */
1227 const char *message; /**< Human-readable error message. */
1231 * Traffic manager get number of leaf nodes
1233 * Each leaf node sits on on top of a TX queue of the current Ethernet port.
1234 * Therefore, the set of leaf nodes is predefined, their number is always equal
1235 * to N (where N is the number of TX queues configured for the current port)
1236 * and their IDs are 0 .. (N-1).
1238 * @param[in] port_id
1239 * The port identifier of the Ethernet device.
1240 * @param[out] n_leaf_nodes
1241 * Number of leaf nodes for the current port.
1243 * Error details. Filled in only on error, when not NULL.
1245 * 0 on success, non-zero error code otherwise.
1249 rte_tm_get_number_of_leaf_nodes(uint16_t port_id,
1250 uint32_t *n_leaf_nodes,
1251 struct rte_tm_error *error);
1254 * Traffic manager node ID validate and type (i.e. leaf or non-leaf) get
1256 * The leaf nodes have predefined IDs in the range of 0 .. (N-1), where N is
1257 * the number of TX queues of the current Ethernet port. The non-leaf nodes
1258 * have their IDs generated by the application outside of the above range,
1259 * which is reserved for leaf nodes.
1261 * @param[in] port_id
1262 * The port identifier of the Ethernet device.
1263 * @param[in] node_id
1264 * Node ID value. Needs to be valid.
1265 * @param[out] is_leaf
1266 * Set to non-zero value when node is leaf and to zero otherwise (non-leaf).
1268 * Error details. Filled in only on error, when not NULL.
1270 * 0 on success, non-zero error code otherwise.
1274 rte_tm_node_type_get(uint16_t port_id,
1277 struct rte_tm_error *error);
1280 * Traffic manager capabilities get
1282 * @param[in] port_id
1283 * The port identifier of the Ethernet device.
1285 * Traffic manager capabilities. Needs to be pre-allocated and valid.
1287 * Error details. Filled in only on error, when not NULL.
1289 * 0 on success, non-zero error code otherwise.
1293 rte_tm_capabilities_get(uint16_t port_id,
1294 struct rte_tm_capabilities *cap,
1295 struct rte_tm_error *error);
1298 * Traffic manager level capabilities get
1300 * @param[in] port_id
1301 * The port identifier of the Ethernet device.
1302 * @param[in] level_id
1303 * The hierarchy level identifier. The value of 0 identifies the level of the
1306 * Traffic manager level capabilities. Needs to be pre-allocated and valid.
1308 * Error details. Filled in only on error, when not NULL.
1310 * 0 on success, non-zero error code otherwise.
1314 rte_tm_level_capabilities_get(uint16_t port_id,
1316 struct rte_tm_level_capabilities *cap,
1317 struct rte_tm_error *error);
1320 * Traffic manager node capabilities get
1322 * @param[in] port_id
1323 * The port identifier of the Ethernet device.
1324 * @param[in] node_id
1325 * Node ID. Needs to be valid.
1327 * Traffic manager node capabilities. Needs to be pre-allocated and valid.
1329 * Error details. Filled in only on error, when not NULL.
1331 * 0 on success, non-zero error code otherwise.
1335 rte_tm_node_capabilities_get(uint16_t port_id,
1337 struct rte_tm_node_capabilities *cap,
1338 struct rte_tm_error *error);
1341 * Traffic manager WRED profile add
1343 * Create a new WRED profile with ID set to *wred_profile_id*. The new profile
1344 * is used to create one or several WRED contexts.
1346 * @param[in] port_id
1347 * The port identifier of the Ethernet device.
1348 * @param[in] wred_profile_id
1349 * WRED profile ID for the new profile. Needs to be unused.
1350 * @param[in] profile
1351 * WRED profile parameters. Needs to be pre-allocated and valid.
1353 * Error details. Filled in only on error, when not NULL.
1355 * 0 on success, non-zero error code otherwise.
1357 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1361 rte_tm_wred_profile_add(uint16_t port_id,
1362 uint32_t wred_profile_id,
1363 struct rte_tm_wred_params *profile,
1364 struct rte_tm_error *error);
1367 * Traffic manager WRED profile delete
1369 * Delete an existing WRED profile. This operation fails when there is
1370 * currently at least one user (i.e. WRED context) of this WRED profile.
1372 * @param[in] port_id
1373 * The port identifier of the Ethernet device.
1374 * @param[in] wred_profile_id
1375 * WRED profile ID. Needs to be the valid.
1377 * Error details. Filled in only on error, when not NULL.
1379 * 0 on success, non-zero error code otherwise.
1381 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1385 rte_tm_wred_profile_delete(uint16_t port_id,
1386 uint32_t wred_profile_id,
1387 struct rte_tm_error *error);
1390 * Traffic manager shared WRED context add or update
1392 * When *shared_wred_context_id* is invalid, a new WRED context with this ID is
1393 * created by using the WRED profile identified by *wred_profile_id*.
1395 * When *shared_wred_context_id* is valid, this WRED context is no longer using
1396 * the profile previously assigned to it and is updated to use the profile
1397 * identified by *wred_profile_id*.
1399 * A valid shared WRED context can be assigned to several hierarchy leaf nodes
1400 * configured to use WRED as the congestion management mode.
1402 * @param[in] port_id
1403 * The port identifier of the Ethernet device.
1404 * @param[in] shared_wred_context_id
1405 * Shared WRED context ID
1406 * @param[in] wred_profile_id
1407 * WRED profile ID. Needs to be the valid.
1409 * Error details. Filled in only on error, when not NULL.
1411 * 0 on success, non-zero error code otherwise.
1413 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1417 rte_tm_shared_wred_context_add_update(uint16_t port_id,
1418 uint32_t shared_wred_context_id,
1419 uint32_t wred_profile_id,
1420 struct rte_tm_error *error);
1423 * Traffic manager shared WRED context delete
1425 * Delete an existing shared WRED context. This operation fails when there is
1426 * currently at least one user (i.e. hierarchy leaf node) of this shared WRED
1429 * @param[in] port_id
1430 * The port identifier of the Ethernet device.
1431 * @param[in] shared_wred_context_id
1432 * Shared WRED context ID. Needs to be the valid.
1434 * Error details. Filled in only on error, when not NULL.
1436 * 0 on success, non-zero error code otherwise.
1438 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1442 rte_tm_shared_wred_context_delete(uint16_t port_id,
1443 uint32_t shared_wred_context_id,
1444 struct rte_tm_error *error);
1447 * Traffic manager shaper profile add
1449 * Create a new shaper profile with ID set to *shaper_profile_id*. The new
1450 * shaper profile is used to create one or several shapers.
1452 * @param[in] port_id
1453 * The port identifier of the Ethernet device.
1454 * @param[in] shaper_profile_id
1455 * Shaper profile ID for the new profile. Needs to be unused.
1456 * @param[in] profile
1457 * Shaper profile parameters. Needs to be pre-allocated and valid.
1459 * Error details. Filled in only on error, when not NULL.
1461 * 0 on success, non-zero error code otherwise.
1463 * @see struct rte_tm_capabilities::shaper_n_max
1467 rte_tm_shaper_profile_add(uint16_t port_id,
1468 uint32_t shaper_profile_id,
1469 struct rte_tm_shaper_params *profile,
1470 struct rte_tm_error *error);
1473 * Traffic manager shaper profile delete
1475 * Delete an existing shaper profile. This operation fails when there is
1476 * currently at least one user (i.e. shaper) of this shaper profile.
1478 * @param[in] port_id
1479 * The port identifier of the Ethernet device.
1480 * @param[in] shaper_profile_id
1481 * Shaper profile ID. Needs to be the valid.
1483 * Error details. Filled in only on error, when not NULL.
1485 * 0 on success, non-zero error code otherwise.
1487 * @see struct rte_tm_capabilities::shaper_n_max
1491 rte_tm_shaper_profile_delete(uint16_t port_id,
1492 uint32_t shaper_profile_id,
1493 struct rte_tm_error *error);
1496 * Traffic manager shared shaper add or update
1498 * When *shared_shaper_id* is not a valid shared shaper ID, a new shared shaper
1499 * with this ID is created using the shaper profile identified by
1500 * *shaper_profile_id*.
1502 * When *shared_shaper_id* is a valid shared shaper ID, this shared shaper is
1503 * no longer using the shaper profile previously assigned to it and is updated
1504 * to use the shaper profile identified by *shaper_profile_id*.
1506 * @param[in] port_id
1507 * The port identifier of the Ethernet device.
1508 * @param[in] shared_shaper_id
1510 * @param[in] shaper_profile_id
1511 * Shaper profile ID. Needs to be the valid.
1513 * Error details. Filled in only on error, when not NULL.
1515 * 0 on success, non-zero error code otherwise.
1517 * @see struct rte_tm_capabilities::shaper_shared_n_max
1521 rte_tm_shared_shaper_add_update(uint16_t port_id,
1522 uint32_t shared_shaper_id,
1523 uint32_t shaper_profile_id,
1524 struct rte_tm_error *error);
1527 * Traffic manager shared shaper delete
1529 * Delete an existing shared shaper. This operation fails when there is
1530 * currently at least one user (i.e. hierarchy node) of this shared shaper.
1532 * @param[in] port_id
1533 * The port identifier of the Ethernet device.
1534 * @param[in] shared_shaper_id
1535 * Shared shaper ID. Needs to be the valid.
1537 * Error details. Filled in only on error, when not NULL.
1539 * 0 on success, non-zero error code otherwise.
1541 * @see struct rte_tm_capabilities::shaper_shared_n_max
1545 rte_tm_shared_shaper_delete(uint16_t port_id,
1546 uint32_t shared_shaper_id,
1547 struct rte_tm_error *error);
1550 * Traffic manager node add
1552 * Create new node and connect it as child of an existing node. The new node is
1553 * further identified by *node_id*, which needs to be unused by any of the
1554 * existing nodes. The parent node is identified by *parent_node_id*, which
1555 * needs to be the valid ID of an existing non-leaf node. The parent node is
1556 * going to use the provided SP *priority* and WFQ *weight* to schedule its new
1559 * This function has to be called for both leaf and non-leaf nodes. In the case
1560 * of leaf nodes (i.e. *node_id* is within the range of 0 .. (N-1), with N as
1561 * the number of configured TX queues of the current port), the leaf node is
1562 * configured rather than created (as the set of leaf nodes is predefined) and
1563 * it is also connected as child of an existing node.
1565 * The first node that is added becomes the root node and all the nodes that
1566 * are subsequently added have to be added as descendants of the root node. The
1567 * parent of the root node has to be specified as RTE_TM_NODE_ID_NULL and there
1568 * can only be one node with this parent ID (i.e. the root node). Further
1569 * restrictions for root node: needs to be non-leaf, its private shaper profile
1570 * needs to be valid and single rate, cannot use any shared shapers.
1572 * When called before rte_tm_hierarchy_commit() invocation, this function is
1573 * typically used to define the initial start-up hierarchy for the port.
1574 * Provided that dynamic hierarchy updates are supported by the current port (as
1575 * advertised in the port capability set), this function can be also called
1576 * after the rte_tm_hierarchy_commit() invocation.
1578 * @param[in] port_id
1579 * The port identifier of the Ethernet device.
1580 * @param[in] node_id
1581 * Node ID. Needs to be unused by any of the existing nodes.
1582 * @param[in] parent_node_id
1583 * Parent node ID. Needs to be the 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 one. Used by the WFQ
1590 * algorithm running on the parent of the current node for scheduling this
1592 * @param[in] level_id
1593 * Level ID that should be met by this node. The hierarchy level of the
1594 * current node is already fully specified through its parent node (i.e. the
1595 * level of this node is equal to the level of its parent node plus one),
1596 * therefore the reason for providing this parameter is to enable the
1597 * application to perform step-by-step checking of the node level during
1598 * successive invocations of this function. When not desired, this check can
1599 * be disabled by assigning value RTE_TM_NODE_LEVEL_ID_ANY to this parameter.
1601 * Node parameters. Needs to be pre-allocated and valid.
1603 * Error details. Filled in only on error, when not NULL.
1605 * 0 on success, non-zero error code otherwise.
1607 * @see rte_tm_hierarchy_commit()
1608 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1609 * @see RTE_TM_NODE_LEVEL_ID_ANY
1610 * @see struct rte_tm_capabilities
1614 rte_tm_node_add(uint16_t port_id,
1616 uint32_t parent_node_id,
1620 struct rte_tm_node_params *params,
1621 struct rte_tm_error *error);
1624 * Traffic manager node delete
1626 * Delete an existing node. This operation fails when this node currently has
1627 * at least one user (i.e. child node).
1629 * When called before rte_tm_hierarchy_commit() invocation, this function is
1630 * typically used to define the initial start-up hierarchy for the port.
1631 * Provided that dynamic hierarchy updates are supported by the current port (as
1632 * advertised in the port capability set), this function can be also called
1633 * after the rte_tm_hierarchy_commit() invocation.
1635 * @param[in] port_id
1636 * The port identifier of the Ethernet device.
1637 * @param[in] node_id
1638 * Node ID. Needs to be valid.
1640 * Error details. Filled in only on error, when not NULL.
1642 * 0 on success, non-zero error code otherwise.
1644 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1648 rte_tm_node_delete(uint16_t port_id,
1650 struct rte_tm_error *error);
1653 * Traffic manager node suspend
1655 * Suspend an existing node. While the node is in suspended state, no packet is
1656 * scheduled from this node and its descendants. The node exits the suspended
1657 * state through the node resume operation.
1659 * @param[in] port_id
1660 * The port identifier of the Ethernet device.
1661 * @param[in] node_id
1662 * Node ID. Needs to be valid.
1664 * Error details. Filled in only on error, when not NULL.
1666 * 0 on success, non-zero error code otherwise.
1668 * @see rte_tm_node_resume()
1669 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1673 rte_tm_node_suspend(uint16_t port_id,
1675 struct rte_tm_error *error);
1678 * Traffic manager node resume
1680 * Resume an existing node that is currently in suspended state. The node
1681 * entered the suspended state as result of a previous node suspend operation.
1683 * @param[in] port_id
1684 * The port identifier of the Ethernet device.
1685 * @param[in] node_id
1686 * Node ID. Needs to be valid.
1688 * Error details. Filled in only on error, when not NULL.
1690 * 0 on success, non-zero error code otherwise.
1692 * @see rte_tm_node_suspend()
1693 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1697 rte_tm_node_resume(uint16_t port_id,
1699 struct rte_tm_error *error);
1702 * Traffic manager hierarchy commit
1704 * This function is called during the port initialization phase (before the
1705 * Ethernet port is started) to freeze the start-up hierarchy.
1707 * This function typically performs the following steps:
1708 * a) It validates the start-up hierarchy that was previously defined for the
1709 * current port through successive rte_tm_node_add() invocations;
1710 * b) Assuming successful validation, it performs all the necessary port
1711 * specific configuration operations to install the specified hierarchy on
1712 * the current port, with immediate effect once the port is started.
1714 * This function fails when the currently configured hierarchy is not supported
1715 * by the Ethernet port, in which case the user can abort or try out another
1716 * hierarchy configuration (e.g. a hierarchy with less leaf nodes), which can be
1717 * build from scratch (when *clear_on_fail* is enabled) or by modifying the
1718 * existing hierarchy configuration (when *clear_on_fail* is disabled).
1720 * Note that this function can still fail due to other causes (e.g. not enough
1721 * memory available in the system, etc), even though the specified hierarchy is
1722 * supported in principle by the current port.
1724 * @param[in] port_id
1725 * The port identifier of the Ethernet device.
1726 * @param[in] clear_on_fail
1727 * On function call failure, hierarchy is cleared when this parameter is
1728 * non-zero and preserved when this parameter is equal to zero.
1730 * Error details. Filled in only on error, when not NULL.
1732 * 0 on success, non-zero error code otherwise.
1734 * @see rte_tm_node_add()
1735 * @see rte_tm_node_delete()
1739 rte_tm_hierarchy_commit(uint16_t port_id,
1741 struct rte_tm_error *error);
1744 * Traffic manager node parent update
1746 * This function may be used to move a node and its children to a different
1747 * parent. Additionally, if the new parent is the same as the current parent,
1748 * this function will update the priority/weight of an existing node.
1750 * Restriction for root node: its parent cannot be changed.
1752 * This function can only be called after the rte_tm_hierarchy_commit()
1753 * invocation. Its success depends on the port support for this operation, as
1754 * advertised through the port capability set.
1756 * @param[in] port_id
1757 * The port identifier of the Ethernet device.
1758 * @param[in] node_id
1759 * Node ID. Needs to be valid.
1760 * @param[in] parent_node_id
1761 * Node ID for the new parent. Needs to be valid.
1762 * @param[in] priority
1763 * Node priority. The highest node priority is zero. Used by the SP algorithm
1764 * running on the parent of the current node for scheduling this child node.
1766 * Node weight. The node weight is relative to the weight sum of all siblings
1767 * that have the same priority. The lowest weight is zero. Used by the WFQ
1768 * algorithm running on the parent of the current node for scheduling this
1771 * Error details. Filled in only on error, when not NULL.
1773 * 0 on success, non-zero error code otherwise.
1775 * @see RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL
1776 * @see RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL
1780 rte_tm_node_parent_update(uint16_t port_id,
1782 uint32_t parent_node_id,
1785 struct rte_tm_error *error);
1788 * Traffic manager node private shaper update
1790 * Restriction for the root node: its private shaper profile needs to be valid
1793 * @param[in] port_id
1794 * The port identifier of the Ethernet device.
1795 * @param[in] node_id
1796 * Node ID. Needs to be valid.
1797 * @param[in] shaper_profile_id
1798 * Shaper profile ID for the private shaper of the current node. Needs to be
1799 * either valid shaper profile ID or RTE_TM_SHAPER_PROFILE_ID_NONE, with
1800 * the latter disabling the private shaper of the current node.
1802 * Error details. Filled in only on error, when not NULL.
1804 * 0 on success, non-zero error code otherwise.
1806 * @see struct rte_tm_capabilities::shaper_private_n_max
1810 rte_tm_node_shaper_update(uint16_t port_id,
1812 uint32_t shaper_profile_id,
1813 struct rte_tm_error *error);
1816 * Traffic manager node shared shapers update
1818 * Restriction for root node: cannot use any shared rate shapers.
1820 * @param[in] port_id
1821 * The port identifier of the Ethernet device.
1822 * @param[in] node_id
1823 * Node ID. Needs to be valid.
1824 * @param[in] shared_shaper_id
1825 * Shared shaper ID. Needs to be valid.
1827 * Set to non-zero value to add this shared shaper to current node or to zero
1828 * to delete this shared shaper from current node.
1830 * Error details. Filled in only on error, when not NULL.
1832 * 0 on success, non-zero error code otherwise.
1834 * @see struct rte_tm_capabilities::shaper_shared_n_max
1838 rte_tm_node_shared_shaper_update(uint16_t port_id,
1840 uint32_t shared_shaper_id,
1842 struct rte_tm_error *error);
1845 * Traffic manager node enabled statistics counters update
1847 * @param[in] port_id
1848 * The port identifier of the Ethernet device.
1849 * @param[in] node_id
1850 * Node ID. Needs to be valid.
1851 * @param[in] stats_mask
1852 * Mask of statistics counter types to be enabled for the current node. This
1853 * needs to be a subset of the statistics counter types available for the
1854 * current node. Any statistics counter type not included in this set is to
1855 * be disabled for the current node.
1857 * Error details. Filled in only on error, when not NULL.
1859 * 0 on success, non-zero error code otherwise.
1861 * @see enum rte_tm_stats_type
1862 * @see RTE_TM_UPDATE_NODE_STATS
1866 rte_tm_node_stats_update(uint16_t port_id,
1868 uint64_t stats_mask,
1869 struct rte_tm_error *error);
1872 * Traffic manager node WFQ weight mode update
1874 * @param[in] port_id
1875 * The port identifier of the Ethernet device.
1876 * @param[in] node_id
1877 * Node ID. Needs to be valid non-leaf node ID.
1878 * @param[in] wfq_weight_mode
1879 * WFQ weight mode for each SP priority. When NULL, it indicates that WFQ is
1880 * to be used for all priorities. When non-NULL, it points to a pre-allocated
1881 * array of *n_sp_priorities* values, with non-zero value for byte-mode and
1882 * zero for packet-mode.
1883 * @param[in] n_sp_priorities
1884 * Number of SP priorities.
1886 * Error details. Filled in only on error, when not NULL.
1888 * 0 on success, non-zero error code otherwise.
1890 * @see RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE
1891 * @see RTE_TM_UPDATE_NODE_N_SP_PRIORITIES
1895 rte_tm_node_wfq_weight_mode_update(uint16_t port_id,
1897 int *wfq_weight_mode,
1898 uint32_t n_sp_priorities,
1899 struct rte_tm_error *error);
1902 * Traffic manager node congestion management mode update
1904 * @param[in] port_id
1905 * The port identifier of the Ethernet device.
1906 * @param[in] node_id
1907 * Node ID. Needs to be valid leaf node ID.
1909 * Congestion management mode.
1911 * Error details. Filled in only on error, when not NULL.
1913 * 0 on success, non-zero error code otherwise.
1915 * @see RTE_TM_UPDATE_NODE_CMAN
1919 rte_tm_node_cman_update(uint16_t port_id,
1921 enum rte_tm_cman_mode cman,
1922 struct rte_tm_error *error);
1925 * Traffic manager node private WRED context update
1927 * @param[in] port_id
1928 * The port identifier of the Ethernet device.
1929 * @param[in] node_id
1930 * Node ID. Needs to be valid leaf node ID.
1931 * @param[in] wred_profile_id
1932 * WRED profile ID for the private WRED context of the current node. Needs to
1933 * be either valid WRED profile ID or RTE_TM_WRED_PROFILE_ID_NONE, with the
1934 * latter disabling the private WRED context of the current node.
1936 * Error details. Filled in only on error, when not NULL.
1938 * 0 on success, non-zero error code otherwise.
1940 * @see struct rte_tm_capabilities::cman_wred_context_private_n_max
1944 rte_tm_node_wred_context_update(uint16_t port_id,
1946 uint32_t wred_profile_id,
1947 struct rte_tm_error *error);
1950 * Traffic manager node shared WRED context update
1952 * @param[in] port_id
1953 * The port identifier of the Ethernet device.
1954 * @param[in] node_id
1955 * Node ID. Needs to be valid leaf node ID.
1956 * @param[in] shared_wred_context_id
1957 * Shared WRED context ID. Needs to be valid.
1959 * Set to non-zero value to add this shared WRED context to current node or
1960 * to zero to delete this shared WRED context from current node.
1962 * Error details. Filled in only on error, when not NULL.
1964 * 0 on success, non-zero error code otherwise.
1966 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1970 rte_tm_node_shared_wred_context_update(uint16_t port_id,
1972 uint32_t shared_wred_context_id,
1974 struct rte_tm_error *error);
1977 * Traffic manager node statistics counters read
1979 * @param[in] port_id
1980 * The port identifier of the Ethernet device.
1981 * @param[in] node_id
1982 * Node ID. Needs to be valid.
1984 * When non-NULL, it contains the current value for the statistics counters
1985 * enabled for the current node.
1986 * @param[out] stats_mask
1987 * When non-NULL, it contains the mask of statistics counter types that are
1988 * currently enabled for this node, indicating which of the counters
1989 * retrieved with the *stats* structure are valid.
1991 * When this parameter has a non-zero value, the statistics counters are
1992 * cleared (i.e. set to zero) immediately after they have been read,
1993 * otherwise the statistics counters are left untouched.
1995 * Error details. Filled in only on error, when not NULL.
1997 * 0 on success, non-zero error code otherwise.
1999 * @see enum rte_tm_stats_type
2003 rte_tm_node_stats_read(uint16_t port_id,
2005 struct rte_tm_node_stats *stats,
2006 uint64_t *stats_mask,
2008 struct rte_tm_error *error);
2011 * Traffic manager packet marking - VLAN DEI (IEEE 802.1Q)
2013 * IEEE 802.1p maps the traffic class to the VLAN Priority Code Point (PCP)
2014 * field (3 bits), while IEEE 802.1q maps the drop priority to the VLAN Drop
2015 * Eligible Indicator (DEI) field (1 bit), which was previously named Canonical
2016 * Format Indicator (CFI).
2018 * All VLAN frames of a given color get their DEI bit set if marking is enabled
2019 * for this color; otherwise, their DEI bit is left as is (either set or not).
2021 * @param[in] port_id
2022 * The port identifier of the Ethernet device.
2023 * @param[in] mark_green
2024 * Set to non-zero value to enable marking of green packets and to zero to
2026 * @param[in] mark_yellow
2027 * Set to non-zero value to enable marking of yellow packets and to zero to
2029 * @param[in] mark_red
2030 * Set to non-zero value to enable marking of red packets and to zero to
2033 * Error details. Filled in only on error, when not NULL.
2035 * 0 on success, non-zero error code otherwise.
2037 * @see struct rte_tm_capabilities::mark_vlan_dei_supported
2041 rte_tm_mark_vlan_dei(uint16_t port_id,
2045 struct rte_tm_error *error);
2048 * Traffic manager packet marking - IPv4 / IPv6 ECN (IETF RFC 3168)
2050 * IETF RFCs 2474 and 3168 reorganize the IPv4 Type of Service (TOS) field
2051 * (8 bits) and the IPv6 Traffic Class (TC) field (8 bits) into Differentiated
2052 * Services Codepoint (DSCP) field (6 bits) and Explicit Congestion
2053 * Notification (ECN) field (2 bits). The DSCP field is typically used to
2054 * encode the traffic class and/or drop priority (RFC 2597), while the ECN
2055 * field is used by RFC 3168 to implement a congestion notification mechanism
2056 * to be leveraged by transport layer protocols such as TCP and SCTP that have
2057 * congestion control mechanisms.
2059 * When congestion is experienced, as alternative to dropping the packet,
2060 * routers can change the ECN field of input packets from 2'b01 or 2'b10
2061 * (values indicating that source endpoint is ECN-capable) to 2'b11 (meaning
2062 * that congestion is experienced). The destination endpoint can use the
2063 * ECN-Echo (ECE) TCP flag to relay the congestion indication back to the
2064 * source endpoint, which acknowledges it back to the destination endpoint with
2065 * the Congestion Window Reduced (CWR) TCP flag.
2067 * All IPv4/IPv6 packets of a given color with ECN set to 2’b01 or 2’b10
2068 * carrying TCP or SCTP have their ECN set to 2’b11 if the marking feature is
2069 * enabled for the current color, otherwise the ECN field is left as is.
2071 * @param[in] port_id
2072 * The port identifier of the Ethernet device.
2073 * @param[in] mark_green
2074 * Set to non-zero value to enable marking of green packets and to zero to
2076 * @param[in] mark_yellow
2077 * Set to non-zero value to enable marking of yellow packets and to zero to
2079 * @param[in] mark_red
2080 * Set to non-zero value to enable marking of red packets and to zero to
2083 * Error details. Filled in only on error, when not NULL.
2085 * 0 on success, non-zero error code otherwise.
2087 * @see struct rte_tm_capabilities::mark_ip_ecn_tcp_supported
2088 * @see struct rte_tm_capabilities::mark_ip_ecn_sctp_supported
2092 rte_tm_mark_ip_ecn(uint16_t port_id,
2096 struct rte_tm_error *error);
2099 * Traffic manager packet marking - IPv4 / IPv6 DSCP (IETF RFC 2597)
2101 * IETF RFC 2597 maps the traffic class and the drop priority to the IPv4/IPv6
2102 * Differentiated Services Codepoint (DSCP) field (6 bits). Here are the DSCP
2103 * values proposed by this RFC:
2105 * <pre> Class 1 Class 2 Class 3 Class 4 </pre>
2106 * <pre> +----------+----------+----------+----------+</pre>
2107 * <pre>Low Drop Prec | 001010 | 010010 | 011010 | 100010 |</pre>
2108 * <pre>Medium Drop Prec | 001100 | 010100 | 011100 | 100100 |</pre>
2109 * <pre>High Drop Prec | 001110 | 010110 | 011110 | 100110 |</pre>
2110 * <pre> +----------+----------+----------+----------+</pre>
2112 * There are 4 traffic classes (classes 1 .. 4) encoded by DSCP bits 1 and 2,
2113 * as well as 3 drop priorities (low/medium/high) encoded by DSCP bits 3 and 4.
2115 * All IPv4/IPv6 packets have their color marked into DSCP bits 3 and 4 as
2116 * follows: green mapped to Low Drop Precedence (2’b01), yellow to Medium
2117 * (2’b10) and red to High (2’b11). Marking needs to be explicitly enabled
2118 * for each color; when not enabled for a given color, the DSCP field of all
2119 * packets with that color is left as is.
2121 * @param[in] port_id
2122 * The port identifier of the Ethernet device.
2123 * @param[in] mark_green
2124 * Set to non-zero value to enable marking of green packets and to zero to
2126 * @param[in] mark_yellow
2127 * Set to non-zero value to enable marking of yellow packets and to zero to
2129 * @param[in] mark_red
2130 * Set to non-zero value to enable marking of red packets and to zero to
2133 * Error details. Filled in only on error, when not NULL.
2135 * 0 on success, non-zero error code otherwise.
2137 * @see struct rte_tm_capabilities::mark_ip_dscp_supported
2141 rte_tm_mark_ip_dscp(uint16_t port_id,
2145 struct rte_tm_error *error);
2151 #endif /* __INCLUDE_RTE_TM_H__ */