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.
19 * @b EXPERIMENTAL: this API may change without prior notice
24 #include <rte_common.h>
25 #include <rte_meter.h>
32 * Ethernet framing overhead.
34 * Overhead fields per Ethernet frame:
35 * 1. Preamble: 7 bytes;
36 * 2. Start of Frame Delimiter (SFD): 1 byte;
37 * 3. Inter-Frame Gap (IFG): 12 bytes.
39 * One of the typical values for the *pkt_length_adjust* field of the shaper
42 * @see struct rte_tm_shaper_params
44 #define RTE_TM_ETH_FRAMING_OVERHEAD 20
47 * Ethernet framing overhead including the Frame Check Sequence (FCS) field.
48 * Useful when FCS is generated and added at the end of the Ethernet frame on
49 * TX side without any SW intervention.
51 * One of the typical values for the pkt_length_adjust field of the shaper
54 * @see struct rte_tm_shaper_params
56 #define RTE_TM_ETH_FRAMING_OVERHEAD_FCS 24
59 * Invalid WRED profile ID.
61 * @see struct rte_tm_node_params
62 * @see rte_tm_node_add()
63 * @see rte_tm_node_wred_context_update()
65 #define RTE_TM_WRED_PROFILE_ID_NONE UINT32_MAX
68 *Invalid shaper profile ID.
70 * @see struct rte_tm_node_params
71 * @see rte_tm_node_add()
72 * @see rte_tm_node_shaper_update()
74 #define RTE_TM_SHAPER_PROFILE_ID_NONE UINT32_MAX
77 * Node ID for the parent of the root node.
79 * @see rte_tm_node_add()
81 #define RTE_TM_NODE_ID_NULL UINT32_MAX
84 * Node level ID used to disable level ID checking.
86 * @see rte_tm_node_add()
88 #define RTE_TM_NODE_LEVEL_ID_ANY UINT32_MAX
91 * Node statistics counter type
93 enum rte_tm_stats_type {
94 /** Number of packets scheduled from current node. */
95 RTE_TM_STATS_N_PKTS = 1 << 0,
97 /** Number of bytes scheduled from current node. */
98 RTE_TM_STATS_N_BYTES = 1 << 1,
100 /** Number of green packets dropped by current leaf node. */
101 RTE_TM_STATS_N_PKTS_GREEN_DROPPED = 1 << 2,
103 /** Number of yellow packets dropped by current leaf node. */
104 RTE_TM_STATS_N_PKTS_YELLOW_DROPPED = 1 << 3,
106 /** Number of red packets dropped by current leaf node. */
107 RTE_TM_STATS_N_PKTS_RED_DROPPED = 1 << 4,
109 /** Number of green bytes dropped by current leaf node. */
110 RTE_TM_STATS_N_BYTES_GREEN_DROPPED = 1 << 5,
112 /** Number of yellow bytes dropped by current leaf node. */
113 RTE_TM_STATS_N_BYTES_YELLOW_DROPPED = 1 << 6,
115 /** Number of red bytes dropped by current leaf node. */
116 RTE_TM_STATS_N_BYTES_RED_DROPPED = 1 << 7,
118 /** Number of packets currently waiting in the packet queue of current
121 RTE_TM_STATS_N_PKTS_QUEUED = 1 << 8,
123 /** Number of bytes currently waiting in the packet queue of current
126 RTE_TM_STATS_N_BYTES_QUEUED = 1 << 9,
130 * Node statistics counters
132 struct rte_tm_node_stats {
133 /** Number of packets scheduled from current node. */
136 /** Number of bytes scheduled from current node. */
139 /** Statistics counters for leaf nodes only. */
141 /** Number of packets dropped by current leaf node per each
144 uint64_t n_pkts_dropped[RTE_COLORS];
146 /** Number of bytes dropped by current leaf node per each
149 uint64_t n_bytes_dropped[RTE_COLORS];
151 /** Number of packets currently waiting in the packet queue of
154 uint64_t n_pkts_queued;
156 /** Number of bytes currently waiting in the packet queue of
159 uint64_t n_bytes_queued;
164 * Traffic manager dynamic updates
166 enum rte_tm_dynamic_update_type {
167 /** Dynamic parent node update. The new parent node is located on same
168 * hierarchy level as the former parent node. Consequently, the node
169 * whose parent is changed preserves its hierarchy level.
171 RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL = 1 << 0,
173 /** Dynamic parent node update. The new parent node is located on
174 * different hierarchy level than the former parent node. Consequently,
175 * the node whose parent is changed also changes its hierarchy level.
177 RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL = 1 << 1,
179 /** Dynamic node add/delete. */
180 RTE_TM_UPDATE_NODE_ADD_DELETE = 1 << 2,
182 /** Suspend/resume nodes. */
183 RTE_TM_UPDATE_NODE_SUSPEND_RESUME = 1 << 3,
185 /** Dynamic switch between byte-based and packet-based WFQ weights. */
186 RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE = 1 << 4,
188 /** Dynamic update on number of SP priorities. */
189 RTE_TM_UPDATE_NODE_N_SP_PRIORITIES = 1 << 5,
191 /** Dynamic update of congestion management mode for leaf nodes. */
192 RTE_TM_UPDATE_NODE_CMAN = 1 << 6,
194 /** Dynamic update of the set of enabled stats counter types. */
195 RTE_TM_UPDATE_NODE_STATS = 1 << 7,
199 * Traffic manager capabilities
201 struct rte_tm_capabilities {
202 /** Maximum number of nodes. */
203 uint32_t n_nodes_max;
205 /** Maximum number of levels (i.e. number of nodes connecting the root
206 * node with any leaf node, including the root and the leaf).
208 uint32_t n_levels_max;
210 /** When non-zero, this flag indicates that all the non-leaf nodes
211 * (with the exception of the root node) have identical capability set.
213 int non_leaf_nodes_identical;
215 /** When non-zero, this flag indicates that all the leaf nodes have
216 * identical capability set.
218 int leaf_nodes_identical;
220 /** Maximum number of shapers, either private or shared. In case the
221 * implementation does not share any resources between private and
222 * shared shapers, it is typically equal to the sum of
223 * *shaper_private_n_max* and *shaper_shared_n_max*. The
224 * value of zero indicates that traffic shaping is not supported.
226 uint32_t shaper_n_max;
228 /** Maximum number of private shapers. Indicates the maximum number of
229 * nodes that can concurrently have their private shaper enabled. The
230 * value of zero indicates that private shapers are not supported.
232 uint32_t shaper_private_n_max;
234 /** Maximum number of private shapers that support dual rate shaping.
235 * Indicates the maximum number of nodes that can concurrently have
236 * their private shaper enabled with dual rate support. Only valid when
237 * private shapers are supported. The value of zero indicates that dual
238 * rate shaping is not available for private shapers. The maximum value
239 * is *shaper_private_n_max*.
241 int shaper_private_dual_rate_n_max;
243 /** Minimum committed/peak rate (bytes per second) for any private
244 * shaper. Valid only when private shapers are supported.
246 uint64_t shaper_private_rate_min;
248 /** Maximum committed/peak rate (bytes per second) for any private
249 * shaper. Valid only when private shapers are supported.
251 uint64_t shaper_private_rate_max;
253 /** Maximum number of shared shapers. The value of zero indicates that
254 * shared shapers are not supported.
256 uint32_t shaper_shared_n_max;
258 /** Maximum number of nodes that can share the same shared shaper.
259 * Only valid when shared shapers are supported.
261 uint32_t shaper_shared_n_nodes_per_shaper_max;
263 /** Maximum number of shared shapers a node can be part of. This
264 * parameter indicates that there is at least one node that can be
265 * configured with this many shared shapers, which might not be true for
266 * all the nodes. Only valid when shared shapers are supported, in which
267 * case it ranges from 1 to *shaper_shared_n_max*.
269 uint32_t shaper_shared_n_shapers_per_node_max;
271 /** Maximum number of shared shapers that can be configured with dual
272 * rate shaping. The value of zero indicates that dual rate shaping
273 * support is not available for shared shapers.
275 uint32_t shaper_shared_dual_rate_n_max;
277 /** Minimum committed/peak rate (bytes per second) for any shared
278 * shaper. Only valid when shared shapers are supported.
280 uint64_t shaper_shared_rate_min;
282 /** Maximum committed/peak rate (bytes per second) for any shared
283 * shaper. Only valid when shared shapers are supported.
285 uint64_t shaper_shared_rate_max;
287 /** Minimum value allowed for packet length adjustment for any private
290 int shaper_pkt_length_adjust_min;
292 /** Maximum value allowed for packet length adjustment for any private
295 int shaper_pkt_length_adjust_max;
297 /** Maximum number of children nodes. This parameter indicates that
298 * there is at least one non-leaf node that can be configured with this
299 * many children nodes, which might not be true for all the non-leaf
302 uint32_t sched_n_children_max;
304 /** Maximum number of supported priority levels. This parameter
305 * indicates that there is at least one non-leaf node that can be
306 * configured with this many priority levels for managing its children
307 * nodes, which might not be true for all the non-leaf nodes. The value
308 * of zero is invalid. The value of 1 indicates that only priority 0 is
309 * supported, which essentially means that Strict Priority (SP)
310 * algorithm is not supported.
312 uint32_t sched_sp_n_priorities_max;
314 /** Maximum number of sibling nodes that can have the same priority at
315 * any given time, i.e. maximum size of the WFQ sibling node group. This
316 * parameter indicates there is at least one non-leaf node that meets
317 * this condition, which might not be true for all the non-leaf nodes.
318 * The value of zero is invalid. The value of 1 indicates that WFQ
319 * algorithm is not supported. The maximum value is
320 * *sched_n_children_max*.
322 uint32_t sched_wfq_n_children_per_group_max;
324 /** Maximum number of priority levels that can have more than one child
325 * node at any given time, i.e. maximum number of WFQ sibling node
326 * groups that have two or more members. This parameter indicates there
327 * is at least one non-leaf node that meets this condition, which might
328 * not be true for all the non-leaf nodes. The value of zero states that
329 * WFQ algorithm is not supported. The value of 1 indicates that
330 * (*sched_sp_n_priorities_max* - 1) priority levels have at most one
331 * child node, so there can be only one priority level with two or
332 * more sibling nodes making up a WFQ group. The maximum value is:
333 * min(floor(*sched_n_children_max* / 2), *sched_sp_n_priorities_max*).
335 uint32_t sched_wfq_n_groups_max;
337 /** Maximum WFQ weight. The value of 1 indicates that all sibling nodes
338 * with same priority have the same WFQ weight, so WFQ is reduced to FQ.
340 uint32_t sched_wfq_weight_max;
342 /** WRED packet mode support. When non-zero, this parameter indicates
343 * that there is at least one leaf node that supports the WRED packet
344 * mode, which might not be true for all the leaf nodes. In packet
345 * mode, the WRED thresholds specify the queue length in packets, as
348 int cman_wred_packet_mode_supported;
350 /** WRED byte mode support. When non-zero, this parameter indicates that
351 * there is at least one leaf node that supports the WRED byte mode,
352 * which might not be true for all the leaf nodes. In byte mode, the
353 * WRED thresholds specify the queue length in bytes, as opposed to
356 int cman_wred_byte_mode_supported;
358 /** Head drop algorithm support. When non-zero, this parameter
359 * indicates that there is at least one leaf node that supports the head
360 * drop algorithm, which might not be true for all the leaf nodes.
362 int cman_head_drop_supported;
364 /** Maximum number of WRED contexts, either private or shared. In case
365 * the implementation does not share any resources between private and
366 * shared WRED contexts, it is typically equal to the sum of
367 * *cman_wred_context_private_n_max* and
368 * *cman_wred_context_shared_n_max*. The value of zero indicates that
369 * WRED is not supported.
371 uint32_t cman_wred_context_n_max;
373 /** Maximum number of private WRED contexts. Indicates the maximum
374 * number of leaf nodes that can concurrently have their private WRED
375 * context enabled. The value of zero indicates that private WRED
376 * contexts are not supported.
378 uint32_t cman_wred_context_private_n_max;
380 /** Maximum number of shared WRED contexts. The value of zero
381 * indicates that shared WRED contexts are not supported.
383 uint32_t cman_wred_context_shared_n_max;
385 /** Maximum number of leaf nodes that can share the same WRED context.
386 * Only valid when shared WRED contexts are supported.
388 uint32_t cman_wred_context_shared_n_nodes_per_context_max;
390 /** Maximum number of shared WRED contexts a leaf node can be part of.
391 * This parameter indicates that there is at least one leaf node that
392 * can be configured with this many shared WRED contexts, which might
393 * not be true for all the leaf nodes. Only valid when shared WRED
394 * contexts are supported, in which case it ranges from 1 to
395 * *cman_wred_context_shared_n_max*.
397 uint32_t cman_wred_context_shared_n_contexts_per_node_max;
399 /** Support for VLAN DEI packet marking (per color). */
400 int mark_vlan_dei_supported[RTE_COLORS];
402 /** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */
403 int mark_ip_ecn_tcp_supported[RTE_COLORS];
405 /** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */
406 int mark_ip_ecn_sctp_supported[RTE_COLORS];
408 /** Support for IPv4/IPv6 DSCP packet marking (per color). */
409 int mark_ip_dscp_supported[RTE_COLORS];
411 /** Set of supported dynamic update operations.
412 * @see enum rte_tm_dynamic_update_type
414 uint64_t dynamic_update_mask;
416 /** Set of supported statistics counter types.
417 * @see enum rte_tm_stats_type
423 * Traffic manager level capabilities
425 struct rte_tm_level_capabilities {
426 /** Maximum number of nodes for the current hierarchy level. */
427 uint32_t n_nodes_max;
429 /** Maximum number of non-leaf nodes for the current hierarchy level.
430 * The value of 0 indicates that current level only supports leaf
431 * nodes. The maximum value is *n_nodes_max*.
433 uint32_t n_nodes_nonleaf_max;
435 /** Maximum number of leaf nodes for the current hierarchy level. The
436 * value of 0 indicates that current level only supports non-leaf
437 * nodes. The maximum value is *n_nodes_max*.
439 uint32_t n_nodes_leaf_max;
441 /** When non-zero, this flag indicates that all the non-leaf nodes on
442 * this level have identical capability set. Valid only when
443 * *n_nodes_nonleaf_max* is non-zero.
445 int non_leaf_nodes_identical;
447 /** When non-zero, this flag indicates that all the leaf nodes on this
448 * level have identical capability set. Valid only when
449 * *n_nodes_leaf_max* is non-zero.
451 int leaf_nodes_identical;
455 /** Items valid only for the non-leaf nodes on this level. */
457 /** Private shaper support. When non-zero, it indicates
458 * there is at least one non-leaf node on this level
459 * with private shaper support, which may not be the
460 * case for all the non-leaf nodes on this level.
462 int shaper_private_supported;
464 /** Dual rate support for private shaper. Valid only
465 * when private shaper is supported for the non-leaf
466 * nodes on the current level. When non-zero, it
467 * indicates there is at least one non-leaf node on this
468 * level with dual rate private shaper support, which
469 * may not be the case for all the non-leaf nodes on
472 int shaper_private_dual_rate_supported;
474 /** Minimum committed/peak rate (bytes per second) for
475 * private shapers of the non-leaf nodes of this level.
476 * Valid only when private shaper is supported on this
479 uint64_t shaper_private_rate_min;
481 /** Maximum committed/peak rate (bytes per second) for
482 * private shapers of the non-leaf nodes on this level.
483 * Valid only when private shaper is supported on this
486 uint64_t shaper_private_rate_max;
488 /** Maximum number of shared shapers that any non-leaf
489 * node on this level can be part of. The value of zero
490 * indicates that shared shapers are not supported by
491 * the non-leaf nodes on this level. When non-zero, it
492 * indicates there is at least one non-leaf node on this
493 * level that meets this condition, which may not be the
494 * case for all the non-leaf nodes on this level.
496 uint32_t shaper_shared_n_max;
498 /** Maximum number of children nodes. This parameter
499 * indicates that there is at least one non-leaf node on
500 * this level that can be configured with this many
501 * children nodes, which might not be true for all the
502 * non-leaf nodes on this level.
504 uint32_t sched_n_children_max;
506 /** Maximum number of supported priority levels. This
507 * parameter indicates that there is at least one
508 * non-leaf node on this level that can be configured
509 * with this many priority levels for managing its
510 * children nodes, which might not be true for all the
511 * non-leaf nodes on this level. The value of zero is
512 * invalid. The value of 1 indicates that only priority
513 * 0 is supported, which essentially means that Strict
514 * Priority (SP) algorithm is not supported on this
517 uint32_t sched_sp_n_priorities_max;
519 /** Maximum number of sibling nodes that can have the
520 * same priority at any given time, i.e. maximum size of
521 * the WFQ sibling node group. This parameter indicates
522 * there is at least one non-leaf node on this level
523 * that meets this condition, which may not be true for
524 * all the non-leaf nodes on this level. The value of
525 * zero is invalid. The value of 1 indicates that WFQ
526 * algorithm is not supported on this level. The maximum
527 * value is *sched_n_children_max*.
529 uint32_t sched_wfq_n_children_per_group_max;
531 /** Maximum number of priority levels that can have
532 * more than one child node at any given time, i.e.
533 * maximum number of WFQ sibling node groups that
534 * have two or more members. This parameter indicates
535 * there is at least one non-leaf node on this level
536 * that meets this condition, which might not be true
537 * for all the non-leaf nodes. The value of zero states
538 * that WFQ algorithm is not supported on this level.
539 * The value of 1 indicates that
540 * (*sched_sp_n_priorities_max* - 1) priority levels on
541 * this level have at most one child node, so there can
542 * be only one priority level with two or more sibling
543 * nodes making up a WFQ group on this level. The
545 * min(floor(*sched_n_children_max* / 2),
546 * *sched_sp_n_priorities_max*).
548 uint32_t sched_wfq_n_groups_max;
550 /** Maximum WFQ weight. The value of 1 indicates that
551 * all sibling nodes on this level with same priority
552 * have the same WFQ weight, so on this level WFQ is
555 uint32_t sched_wfq_weight_max;
557 /** Mask of statistics counter types supported by the
558 * non-leaf nodes on this level. Every supported
559 * statistics counter type is supported by at least one
560 * non-leaf node on this level, which may not be true
561 * for all the non-leaf nodes on this level.
562 * @see enum rte_tm_stats_type
567 /** Items valid only for the leaf nodes on this level. */
569 /** Private shaper support. When non-zero, it indicates
570 * there is at least one leaf node on this level with
571 * private shaper support, which may not be the case for
572 * all the leaf nodes on this level.
574 int shaper_private_supported;
576 /** Dual rate support for private shaper. Valid only
577 * when private shaper is supported for the leaf nodes
578 * on this level. When non-zero, it indicates there is
579 * at least one leaf node on this level with dual rate
580 * private shaper support, which may not be the case for
581 * all the leaf nodes on this level.
583 int shaper_private_dual_rate_supported;
585 /** Minimum committed/peak rate (bytes per second) for
586 * private shapers of the leaf nodes of this level.
587 * Valid only when private shaper is supported for the
588 * leaf nodes on this level.
590 uint64_t shaper_private_rate_min;
592 /** Maximum committed/peak rate (bytes per second) for
593 * private shapers of the leaf nodes on this level.
594 * Valid only when private shaper is supported for the
595 * leaf nodes on this level.
597 uint64_t shaper_private_rate_max;
599 /** Maximum number of shared shapers that any leaf node
600 * on this level can be part of. The value of zero
601 * indicates that shared shapers are not supported by
602 * the leaf nodes on this level. When non-zero, it
603 * indicates there is at least one leaf node on this
604 * level that meets this condition, which may not be the
605 * case for all the leaf nodes on this level.
607 uint32_t shaper_shared_n_max;
609 /** WRED packet mode support. When non-zero, this
610 * parameter indicates that there is at least one leaf
611 * node on this level that supports the WRED packet
612 * mode, which might not be true for all the leaf
613 * nodes. In packet mode, the WRED thresholds specify
614 * the queue length in packets, as opposed to bytes.
616 int cman_wred_packet_mode_supported;
618 /** WRED byte mode support. When non-zero, this
619 * parameter indicates that there is at least one leaf
620 * node on this level that supports the WRED byte mode,
621 * which might not be true for all the leaf nodes. In
622 * byte mode, the WRED thresholds specify the queue
623 * length in bytes, as opposed to packets.
625 int cman_wred_byte_mode_supported;
627 /** Head drop algorithm support. When non-zero, this
628 * parameter indicates that there is at least one leaf
629 * node on this level that supports the head drop
630 * algorithm, which might not be true for all the leaf
631 * nodes on this level.
633 int cman_head_drop_supported;
635 /** Private WRED context support. When non-zero, it
636 * indicates there is at least one node on this level
637 * with private WRED context support, which may not be
638 * true for all the leaf nodes on this level.
640 int cman_wred_context_private_supported;
642 /** Maximum number of shared WRED contexts that any
643 * leaf node on this level can be part of. The value of
644 * zero indicates that shared WRED contexts are not
645 * supported by the leaf nodes on this level. When
646 * non-zero, it indicates there is at least one leaf
647 * node on this level that meets this condition, which
648 * may not be the case for all the leaf nodes on this
651 uint32_t cman_wred_context_shared_n_max;
653 /** Mask of statistics counter types supported by the
654 * leaf nodes on this level. Every supported statistics
655 * counter type is supported by at least one leaf node
656 * on this level, which may not be true for all the leaf
657 * nodes on this level.
658 * @see enum rte_tm_stats_type
666 * Traffic manager node capabilities
668 struct rte_tm_node_capabilities {
669 /** Private shaper support for the current node. */
670 int shaper_private_supported;
672 /** Dual rate shaping support for private shaper of current node.
673 * Valid only when private shaper is supported by the current node.
675 int shaper_private_dual_rate_supported;
677 /** Minimum committed/peak rate (bytes per second) for private
678 * shaper of current node. Valid only when private shaper is supported
679 * by the current node.
681 uint64_t shaper_private_rate_min;
683 /** Maximum committed/peak rate (bytes per second) for private
684 * shaper of current node. Valid only when private shaper is supported
685 * by the current node.
687 uint64_t shaper_private_rate_max;
689 /** Maximum number of shared shapers the current node can be part of.
690 * The value of zero indicates that shared shapers are not supported by
693 uint32_t shaper_shared_n_max;
697 /** Items valid only for non-leaf nodes. */
699 /** Maximum number of children nodes. */
700 uint32_t sched_n_children_max;
702 /** Maximum number of supported priority levels. The
703 * value of zero is invalid. The value of 1 indicates
704 * that only priority 0 is supported, which essentially
705 * means that Strict Priority (SP) algorithm is not
708 uint32_t sched_sp_n_priorities_max;
710 /** Maximum number of sibling nodes that can have the
711 * same priority at any given time, i.e. maximum size
712 * of the WFQ sibling node group. The value of zero
713 * is invalid. The value of 1 indicates that WFQ
714 * algorithm is not supported. The maximum value is
715 * *sched_n_children_max*.
717 uint32_t sched_wfq_n_children_per_group_max;
719 /** Maximum number of priority levels that can have
720 * more than one child node at any given time, i.e.
721 * maximum number of WFQ sibling node groups that have
722 * two or more members. The value of zero states that
723 * WFQ algorithm is not supported. The value of 1
724 * indicates that (*sched_sp_n_priorities_max* - 1)
725 * priority levels have at most one child node, so there
726 * can be only one priority level with two or more
727 * sibling nodes making up a WFQ group. The maximum
728 * value is: min(floor(*sched_n_children_max* / 2),
729 * *sched_sp_n_priorities_max*).
731 uint32_t sched_wfq_n_groups_max;
733 /** Maximum WFQ weight. The value of 1 indicates that
734 * all sibling nodes with same priority have the same
735 * WFQ weight, so WFQ is reduced to FQ.
737 uint32_t sched_wfq_weight_max;
740 /** Items valid only for leaf nodes. */
742 /** WRED packet mode support for current node. */
743 int cman_wred_packet_mode_supported;
745 /** WRED byte mode support for current node. */
746 int cman_wred_byte_mode_supported;
748 /** Head drop algorithm support for current node. */
749 int cman_head_drop_supported;
751 /** Private WRED context support for current node. */
752 int cman_wred_context_private_supported;
754 /** Maximum number of shared WRED contexts the current
755 * node can be part of. The value of zero indicates that
756 * shared WRED contexts are not supported by the current
759 uint32_t cman_wred_context_shared_n_max;
763 /** Mask of statistics counter types supported by the current node.
764 * @see enum rte_tm_stats_type
770 * Congestion management (CMAN) mode
772 * This is used for controlling the admission of packets into a packet queue or
773 * group of packet queues on congestion. On request of writing a new packet
774 * into the current queue while the queue is full, the *tail drop* algorithm
775 * drops the new packet while leaving the queue unmodified, as opposed to *head
776 * drop* algorithm, which drops the packet at the head of the queue (the oldest
777 * packet waiting in the queue) and admits the new packet at the tail of the
780 * The *Random Early Detection (RED)* algorithm works by proactively dropping
781 * more and more input packets as the queue occupancy builds up. When the queue
782 * is full or almost full, RED effectively works as *tail drop*. The *Weighted
783 * RED* algorithm uses a separate set of RED thresholds for each packet color.
785 enum rte_tm_cman_mode {
786 RTE_TM_CMAN_TAIL_DROP = 0, /**< Tail drop */
787 RTE_TM_CMAN_HEAD_DROP, /**< Head drop */
788 RTE_TM_CMAN_WRED, /**< Weighted Random Early Detection (WRED) */
792 * Random Early Detection (RED) profile
794 struct rte_tm_red_params {
795 /** Minimum queue threshold */
798 /** Maximum queue threshold */
801 /** Inverse of packet marking probability maximum value (maxp), i.e.
802 * maxp_inv = 1 / maxp
806 /** Negated log2 of queue weight (wq), i.e. wq = 1 / (2 ^ wq_log2) */
811 * Weighted RED (WRED) profile
813 * Multiple WRED contexts can share the same WRED profile. Each leaf node with
814 * WRED enabled as its congestion management mode has zero or one private WRED
815 * context (only one leaf node using it) and/or zero, one or several shared
816 * WRED contexts (multiple leaf nodes use the same WRED context). A private
817 * WRED context is used to perform congestion management for a single leaf
818 * node, while a shared WRED context is used to perform congestion management
819 * for a group of leaf nodes.
821 * @see struct rte_tm_capabilities::cman_wred_packet_mode_supported
822 * @see struct rte_tm_capabilities::cman_wred_byte_mode_supported
824 struct rte_tm_wred_params {
825 /** One set of RED parameters per packet color */
826 struct rte_tm_red_params red_params[RTE_COLORS];
828 /** When non-zero, the *min_th* and *max_th* thresholds are specified
829 * in packets (WRED packet mode). When zero, the *min_th* and *max_th*
830 * thresholds are specified in bytes (WRED byte mode)
838 struct rte_tm_token_bucket {
839 /** Token bucket rate (bytes per second) */
842 /** Token bucket size (bytes), a.k.a. max burst size */
847 * Shaper (rate limiter) profile
849 * Multiple shaper instances can share the same shaper profile. Each node has
850 * zero or one private shaper (only one node using it) and/or zero, one or
851 * several shared shapers (multiple nodes use the same shaper instance).
852 * A private shaper is used to perform traffic shaping for a single node, while
853 * a shared shaper is used to perform traffic shaping for a group of nodes.
855 * Single rate shapers use a single token bucket. A single rate shaper can be
856 * configured by setting the rate of the committed bucket to zero, which
857 * effectively disables this bucket. The peak bucket is used to limit the rate
858 * and the burst size for the current shaper.
860 * Dual rate shapers use both the committed and the peak token buckets. The
861 * rate of the peak bucket has to be bigger than zero, as well as greater than
862 * or equal to the rate of the committed bucket.
864 struct rte_tm_shaper_params {
865 /** Committed token bucket */
866 struct rte_tm_token_bucket committed;
868 /** Peak token bucket */
869 struct rte_tm_token_bucket peak;
871 /** Signed value to be added to the length of each packet for the
872 * purpose of shaping. Can be used to correct the packet length with
873 * the framing overhead bytes that are also consumed on the wire (e.g.
874 * RTE_TM_ETH_FRAMING_OVERHEAD_FCS).
876 int32_t pkt_length_adjust;
882 * Each non-leaf node has multiple inputs (its children nodes) and single output
883 * (which is input to its parent node). It arbitrates its inputs using Strict
884 * Priority (SP) and Weighted Fair Queuing (WFQ) algorithms to schedule input
885 * packets to its output while observing its shaping (rate limiting)
888 * Algorithms such as Weighted Round Robin (WRR), Byte-level WRR, Deficit WRR
889 * (DWRR), etc. are considered approximations of the WFQ ideal and are
890 * assimilated to WFQ, although an associated implementation-dependent trade-off
891 * on accuracy, performance and resource usage might exist.
893 * Children nodes with different priorities are scheduled using the SP algorithm
894 * based on their priority, with zero (0) as the highest priority. Children with
895 * the same priority are scheduled using the WFQ algorithm according to their
896 * weights. The WFQ weight of a given child node is relative to the sum of the
897 * weights of all its sibling nodes that have the same priority, with one (1) as
898 * the lowest weight. For each SP priority, the WFQ weight mode can be set as
899 * either byte-based or packet-based.
901 * Each leaf node sits on top of a TX queue of the current Ethernet port. Hence,
902 * the leaf nodes are predefined, with their node IDs set to 0 .. (N-1), where N
903 * is the number of TX queues configured for the current Ethernet port. The
904 * non-leaf nodes have their IDs generated by the application.
906 struct rte_tm_node_params {
907 /** Shaper profile for the private shaper. The absence of the private
908 * shaper for the current node is indicated by setting this parameter
909 * to RTE_TM_SHAPER_PROFILE_ID_NONE.
911 uint32_t shaper_profile_id;
913 /** User allocated array of valid shared shaper IDs. */
914 uint32_t *shared_shaper_id;
916 /** Number of shared shaper IDs in the *shared_shaper_id* array. */
917 uint32_t n_shared_shapers;
921 /** Parameters only valid for non-leaf nodes. */
923 /** WFQ weight mode for each SP priority. When NULL, it
924 * indicates that WFQ is to be used for all priorities.
925 * When non-NULL, it points to a pre-allocated array of
926 * *n_sp_priorities* values, with non-zero value for
927 * byte-mode and zero for packet-mode.
929 int *wfq_weight_mode;
931 /** Number of SP priorities. */
932 uint32_t n_sp_priorities;
935 /** Parameters only valid for leaf nodes. */
937 /** Congestion management mode */
938 enum rte_tm_cman_mode cman;
940 /** WRED parameters (only valid when *cman* is set to
944 /** WRED profile for private WRED context. The
945 * absence of a private WRED context for the
946 * current leaf node is indicated by value
947 * RTE_TM_WRED_PROFILE_ID_NONE.
949 uint32_t wred_profile_id;
951 /** User allocated array of shared WRED context
952 * IDs. When set to NULL, it indicates that the
953 * current leaf node should not currently be
954 * part of any shared WRED contexts.
956 uint32_t *shared_wred_context_id;
958 /** Number of elements in the
959 * *shared_wred_context_id* array. Only valid
960 * when *shared_wred_context_id* is non-NULL,
961 * in which case it should be non-zero.
963 uint32_t n_shared_wred_contexts;
968 /** Mask of statistics counter types to be enabled for this node. This
969 * needs to be a subset of the statistics counter types available for
970 * the current node. Any statistics counter type not included in this
971 * set is to be disabled for the current node.
972 * @see enum rte_tm_stats_type
978 * Verbose error types.
980 * Most of them provide the type of the object referenced by struct
981 * rte_tm_error::cause.
983 enum rte_tm_error_type {
984 RTE_TM_ERROR_TYPE_NONE, /**< No error. */
985 RTE_TM_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
986 RTE_TM_ERROR_TYPE_CAPABILITIES,
987 RTE_TM_ERROR_TYPE_LEVEL_ID,
988 RTE_TM_ERROR_TYPE_WRED_PROFILE,
989 RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN,
990 RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW,
991 RTE_TM_ERROR_TYPE_WRED_PROFILE_RED,
992 RTE_TM_ERROR_TYPE_WRED_PROFILE_ID,
993 RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID,
994 RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
995 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE,
996 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE,
997 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
998 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
999 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN,
1000 RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
1001 RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID,
1002 RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID,
1003 RTE_TM_ERROR_TYPE_NODE_PRIORITY,
1004 RTE_TM_ERROR_TYPE_NODE_WEIGHT,
1005 RTE_TM_ERROR_TYPE_NODE_PARAMS,
1006 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID,
1007 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID,
1008 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS,
1009 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE,
1010 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES,
1011 RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN,
1012 RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID,
1013 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID,
1014 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS,
1015 RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
1016 RTE_TM_ERROR_TYPE_NODE_ID,
1020 * Verbose error structure definition.
1022 * This object is normally allocated by applications and set by PMDs, the
1023 * message points to a constant string which does not need to be freed by
1024 * the application, however its pointer can be considered valid only as long
1025 * as its associated DPDK port remains configured. Closing the underlying
1026 * device or unloading the PMD invalidates it.
1028 * Both cause and message may be NULL regardless of the error type.
1030 struct rte_tm_error {
1031 enum rte_tm_error_type type; /**< Cause field and error type. */
1032 const void *cause; /**< Object responsible for the error. */
1033 const char *message; /**< Human-readable error message. */
1037 * Traffic manager get number of leaf nodes
1039 * Each leaf node sits on on top of a TX queue of the current Ethernet port.
1040 * Therefore, the set of leaf nodes is predefined, their number is always equal
1041 * to N (where N is the number of TX queues configured for the current port)
1042 * and their IDs are 0 .. (N-1).
1044 * @param[in] port_id
1045 * The port identifier of the Ethernet device.
1046 * @param[out] n_leaf_nodes
1047 * Number of leaf nodes for the current port.
1049 * Error details. Filled in only on error, when not NULL.
1051 * 0 on success, non-zero error code otherwise.
1054 rte_tm_get_number_of_leaf_nodes(uint16_t port_id,
1055 uint32_t *n_leaf_nodes,
1056 struct rte_tm_error *error);
1059 * Traffic manager node ID validate and type (i.e. leaf or non-leaf) get
1061 * The leaf nodes have predefined IDs in the range of 0 .. (N-1), where N is
1062 * the number of TX queues of the current Ethernet port. The non-leaf nodes
1063 * have their IDs generated by the application outside of the above range,
1064 * which is reserved for leaf nodes.
1066 * @param[in] port_id
1067 * The port identifier of the Ethernet device.
1068 * @param[in] node_id
1069 * Node ID value. Needs to be valid.
1070 * @param[out] is_leaf
1071 * Set to non-zero value when node is leaf and to zero otherwise (non-leaf).
1073 * Error details. Filled in only on error, when not NULL.
1075 * 0 on success, non-zero error code otherwise.
1078 rte_tm_node_type_get(uint16_t port_id,
1081 struct rte_tm_error *error);
1084 * Traffic manager capabilities get
1086 * @param[in] port_id
1087 * The port identifier of the Ethernet device.
1089 * Traffic manager capabilities. Needs to be pre-allocated and valid.
1091 * Error details. Filled in only on error, when not NULL.
1093 * 0 on success, non-zero error code otherwise.
1096 rte_tm_capabilities_get(uint16_t port_id,
1097 struct rte_tm_capabilities *cap,
1098 struct rte_tm_error *error);
1101 * Traffic manager level capabilities get
1103 * @param[in] port_id
1104 * The port identifier of the Ethernet device.
1105 * @param[in] level_id
1106 * The hierarchy level identifier. The value of 0 identifies the level of the
1109 * Traffic manager level capabilities. Needs to be pre-allocated and valid.
1111 * Error details. Filled in only on error, when not NULL.
1113 * 0 on success, non-zero error code otherwise.
1116 rte_tm_level_capabilities_get(uint16_t port_id,
1118 struct rte_tm_level_capabilities *cap,
1119 struct rte_tm_error *error);
1122 * Traffic manager node capabilities get
1124 * @param[in] port_id
1125 * The port identifier of the Ethernet device.
1126 * @param[in] node_id
1127 * Node ID. Needs to be valid.
1129 * Traffic manager node capabilities. Needs to be pre-allocated and valid.
1131 * Error details. Filled in only on error, when not NULL.
1133 * 0 on success, non-zero error code otherwise.
1136 rte_tm_node_capabilities_get(uint16_t port_id,
1138 struct rte_tm_node_capabilities *cap,
1139 struct rte_tm_error *error);
1142 * Traffic manager WRED profile add
1144 * Create a new WRED profile with ID set to *wred_profile_id*. The new profile
1145 * is used to create one or several WRED contexts.
1147 * @param[in] port_id
1148 * The port identifier of the Ethernet device.
1149 * @param[in] wred_profile_id
1150 * WRED profile ID for the new profile. Needs to be unused.
1151 * @param[in] profile
1152 * WRED profile parameters. Needs to be pre-allocated and valid.
1154 * Error details. Filled in only on error, when not NULL.
1156 * 0 on success, non-zero error code otherwise.
1158 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1161 rte_tm_wred_profile_add(uint16_t port_id,
1162 uint32_t wred_profile_id,
1163 struct rte_tm_wred_params *profile,
1164 struct rte_tm_error *error);
1167 * Traffic manager WRED profile delete
1169 * Delete an existing WRED profile. This operation fails when there is
1170 * currently at least one user (i.e. WRED context) of this WRED profile.
1172 * @param[in] port_id
1173 * The port identifier of the Ethernet device.
1174 * @param[in] wred_profile_id
1175 * WRED profile ID. Needs to be the valid.
1177 * Error details. Filled in only on error, when not NULL.
1179 * 0 on success, non-zero error code otherwise.
1181 * @see struct rte_tm_capabilities::cman_wred_context_n_max
1184 rte_tm_wred_profile_delete(uint16_t port_id,
1185 uint32_t wred_profile_id,
1186 struct rte_tm_error *error);
1189 * Traffic manager shared WRED context add or update
1191 * When *shared_wred_context_id* is invalid, a new WRED context with this ID is
1192 * created by using the WRED profile identified by *wred_profile_id*.
1194 * When *shared_wred_context_id* is valid, this WRED context is no longer using
1195 * the profile previously assigned to it and is updated to use the profile
1196 * identified by *wred_profile_id*.
1198 * A valid shared WRED context can be assigned to several hierarchy leaf nodes
1199 * configured to use WRED as the congestion management mode.
1201 * @param[in] port_id
1202 * The port identifier of the Ethernet device.
1203 * @param[in] shared_wred_context_id
1204 * Shared WRED context ID
1205 * @param[in] wred_profile_id
1206 * WRED profile ID. Needs to be the valid.
1208 * Error details. Filled in only on error, when not NULL.
1210 * 0 on success, non-zero error code otherwise.
1212 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1215 rte_tm_shared_wred_context_add_update(uint16_t port_id,
1216 uint32_t shared_wred_context_id,
1217 uint32_t wred_profile_id,
1218 struct rte_tm_error *error);
1221 * Traffic manager shared WRED context delete
1223 * Delete an existing shared WRED context. This operation fails when there is
1224 * currently at least one user (i.e. hierarchy leaf node) of this shared WRED
1227 * @param[in] port_id
1228 * The port identifier of the Ethernet device.
1229 * @param[in] shared_wred_context_id
1230 * Shared WRED context ID. Needs to be the valid.
1232 * Error details. Filled in only on error, when not NULL.
1234 * 0 on success, non-zero error code otherwise.
1236 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1239 rte_tm_shared_wred_context_delete(uint16_t port_id,
1240 uint32_t shared_wred_context_id,
1241 struct rte_tm_error *error);
1244 * Traffic manager shaper profile add
1246 * Create a new shaper profile with ID set to *shaper_profile_id*. The new
1247 * shaper profile is used to create one or several shapers.
1249 * @param[in] port_id
1250 * The port identifier of the Ethernet device.
1251 * @param[in] shaper_profile_id
1252 * Shaper profile ID for the new profile. Needs to be unused.
1253 * @param[in] profile
1254 * Shaper profile parameters. Needs to be pre-allocated and valid.
1256 * Error details. Filled in only on error, when not NULL.
1258 * 0 on success, non-zero error code otherwise.
1260 * @see struct rte_tm_capabilities::shaper_n_max
1263 rte_tm_shaper_profile_add(uint16_t port_id,
1264 uint32_t shaper_profile_id,
1265 struct rte_tm_shaper_params *profile,
1266 struct rte_tm_error *error);
1269 * Traffic manager shaper profile delete
1271 * Delete an existing shaper profile. This operation fails when there is
1272 * currently at least one user (i.e. shaper) of this shaper profile.
1274 * @param[in] port_id
1275 * The port identifier of the Ethernet device.
1276 * @param[in] shaper_profile_id
1277 * Shaper profile ID. Needs to be the valid.
1279 * Error details. Filled in only on error, when not NULL.
1281 * 0 on success, non-zero error code otherwise.
1283 * @see struct rte_tm_capabilities::shaper_n_max
1286 rte_tm_shaper_profile_delete(uint16_t port_id,
1287 uint32_t shaper_profile_id,
1288 struct rte_tm_error *error);
1291 * Traffic manager shared shaper add or update
1293 * When *shared_shaper_id* is not a valid shared shaper ID, a new shared shaper
1294 * with this ID is created using the shaper profile identified by
1295 * *shaper_profile_id*.
1297 * When *shared_shaper_id* is a valid shared shaper ID, this shared shaper is
1298 * no longer using the shaper profile previously assigned to it and is updated
1299 * to use the shaper profile identified by *shaper_profile_id*.
1301 * @param[in] port_id
1302 * The port identifier of the Ethernet device.
1303 * @param[in] shared_shaper_id
1305 * @param[in] shaper_profile_id
1306 * Shaper profile ID. Needs to be the valid.
1308 * Error details. Filled in only on error, when not NULL.
1310 * 0 on success, non-zero error code otherwise.
1312 * @see struct rte_tm_capabilities::shaper_shared_n_max
1315 rte_tm_shared_shaper_add_update(uint16_t port_id,
1316 uint32_t shared_shaper_id,
1317 uint32_t shaper_profile_id,
1318 struct rte_tm_error *error);
1321 * Traffic manager shared shaper delete
1323 * Delete an existing shared shaper. This operation fails when there is
1324 * currently at least one user (i.e. hierarchy node) of this shared shaper.
1326 * @param[in] port_id
1327 * The port identifier of the Ethernet device.
1328 * @param[in] shared_shaper_id
1329 * Shared shaper ID. Needs to be the valid.
1331 * Error details. Filled in only on error, when not NULL.
1333 * 0 on success, non-zero error code otherwise.
1335 * @see struct rte_tm_capabilities::shaper_shared_n_max
1338 rte_tm_shared_shaper_delete(uint16_t port_id,
1339 uint32_t shared_shaper_id,
1340 struct rte_tm_error *error);
1343 * Traffic manager node add
1345 * Create new node and connect it as child of an existing node. The new node is
1346 * further identified by *node_id*, which needs to be unused by any of the
1347 * existing nodes. The parent node is identified by *parent_node_id*, which
1348 * needs to be the valid ID of an existing non-leaf node. The parent node is
1349 * going to use the provided SP *priority* and WFQ *weight* to schedule its new
1352 * This function has to be called for both leaf and non-leaf nodes. In the case
1353 * of leaf nodes (i.e. *node_id* is within the range of 0 .. (N-1), with N as
1354 * the number of configured TX queues of the current port), the leaf node is
1355 * configured rather than created (as the set of leaf nodes is predefined) and
1356 * it is also connected as child of an existing node.
1358 * The first node that is added becomes the root node and all the nodes that
1359 * are subsequently added have to be added as descendants of the root node. The
1360 * parent of the root node has to be specified as RTE_TM_NODE_ID_NULL and there
1361 * can only be one node with this parent ID (i.e. the root node). Further
1362 * restrictions for root node: needs to be non-leaf, its private shaper profile
1363 * needs to be valid and single rate, cannot use any shared shapers.
1365 * When called before rte_tm_hierarchy_commit() invocation, this function is
1366 * typically used to define the initial start-up hierarchy for the port.
1367 * Provided that dynamic hierarchy updates are supported by the current port (as
1368 * advertised in the port capability set), this function can be also called
1369 * after the rte_tm_hierarchy_commit() invocation.
1371 * @param[in] port_id
1372 * The port identifier of the Ethernet device.
1373 * @param[in] node_id
1374 * Node ID. Needs to be unused by any of the existing nodes.
1375 * @param[in] parent_node_id
1376 * Parent node ID. Needs to be the valid.
1377 * @param[in] priority
1378 * Node priority. The highest node priority is zero. Used by the SP algorithm
1379 * running on the parent of the current node for scheduling this child node.
1381 * Node weight. The node weight is relative to the weight sum of all siblings
1382 * that have the same priority. The lowest weight is one. Used by the WFQ
1383 * algorithm running on the parent of the current node for scheduling this
1385 * @param[in] level_id
1386 * Level ID that should be met by this node. The hierarchy level of the
1387 * current node is already fully specified through its parent node (i.e. the
1388 * level of this node is equal to the level of its parent node plus one),
1389 * therefore the reason for providing this parameter is to enable the
1390 * application to perform step-by-step checking of the node level during
1391 * successive invocations of this function. When not desired, this check can
1392 * be disabled by assigning value RTE_TM_NODE_LEVEL_ID_ANY to this parameter.
1394 * Node parameters. Needs to be pre-allocated and valid.
1396 * Error details. Filled in only on error, when not NULL.
1398 * 0 on success, non-zero error code otherwise.
1400 * @see rte_tm_hierarchy_commit()
1401 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1402 * @see RTE_TM_NODE_LEVEL_ID_ANY
1403 * @see struct rte_tm_capabilities
1406 rte_tm_node_add(uint16_t port_id,
1408 uint32_t parent_node_id,
1412 struct rte_tm_node_params *params,
1413 struct rte_tm_error *error);
1416 * Traffic manager node delete
1418 * Delete an existing node. This operation fails when this node currently has
1419 * at least one user (i.e. child node).
1421 * When called before rte_tm_hierarchy_commit() invocation, this function is
1422 * typically used to define the initial start-up hierarchy for the port.
1423 * Provided that dynamic hierarchy updates are supported by the current port (as
1424 * advertised in the port capability set), this function can be also called
1425 * after the rte_tm_hierarchy_commit() invocation.
1427 * @param[in] port_id
1428 * The port identifier of the Ethernet device.
1429 * @param[in] node_id
1430 * Node ID. Needs to be valid.
1432 * Error details. Filled in only on error, when not NULL.
1434 * 0 on success, non-zero error code otherwise.
1436 * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1439 rte_tm_node_delete(uint16_t port_id,
1441 struct rte_tm_error *error);
1444 * Traffic manager node suspend
1446 * Suspend an existing node. While the node is in suspended state, no packet is
1447 * scheduled from this node and its descendants. The node exits the suspended
1448 * state through the node resume operation.
1450 * @param[in] port_id
1451 * The port identifier of the Ethernet device.
1452 * @param[in] node_id
1453 * Node ID. Needs to be valid.
1455 * Error details. Filled in only on error, when not NULL.
1457 * 0 on success, non-zero error code otherwise.
1459 * @see rte_tm_node_resume()
1460 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1463 rte_tm_node_suspend(uint16_t port_id,
1465 struct rte_tm_error *error);
1468 * Traffic manager node resume
1470 * Resume an existing node that is currently in suspended state. The node
1471 * entered the suspended state as result of a previous node suspend operation.
1473 * @param[in] port_id
1474 * The port identifier of the Ethernet device.
1475 * @param[in] node_id
1476 * Node ID. Needs to be valid.
1478 * Error details. Filled in only on error, when not NULL.
1480 * 0 on success, non-zero error code otherwise.
1482 * @see rte_tm_node_suspend()
1483 * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1486 rte_tm_node_resume(uint16_t port_id,
1488 struct rte_tm_error *error);
1491 * Traffic manager hierarchy commit
1493 * This function is called during the port initialization phase (before the
1494 * Ethernet port is started) to freeze the start-up hierarchy.
1496 * This function typically performs the following steps:
1497 * a) It validates the start-up hierarchy that was previously defined for the
1498 * current port through successive rte_tm_node_add() invocations;
1499 * b) Assuming successful validation, it performs all the necessary port
1500 * specific configuration operations to install the specified hierarchy on
1501 * the current port, with immediate effect once the port is started.
1503 * This function fails when the currently configured hierarchy is not supported
1504 * by the Ethernet port, in which case the user can abort or try out another
1505 * hierarchy configuration (e.g. a hierarchy with less leaf nodes), which can be
1506 * build from scratch (when *clear_on_fail* is enabled) or by modifying the
1507 * existing hierarchy configuration (when *clear_on_fail* is disabled).
1509 * Note that this function can still fail due to other causes (e.g. not enough
1510 * memory available in the system, etc), even though the specified hierarchy is
1511 * supported in principle by the current port.
1513 * @param[in] port_id
1514 * The port identifier of the Ethernet device.
1515 * @param[in] clear_on_fail
1516 * On function call failure, hierarchy is cleared when this parameter is
1517 * non-zero and preserved when this parameter is equal to zero.
1519 * Error details. Filled in only on error, when not NULL.
1521 * 0 on success, non-zero error code otherwise.
1523 * @see rte_tm_node_add()
1524 * @see rte_tm_node_delete()
1527 rte_tm_hierarchy_commit(uint16_t port_id,
1529 struct rte_tm_error *error);
1532 * Traffic manager node parent update
1534 * This function may be used to move a node and its children to a different
1535 * parent. Additionally, if the new parent is the same as the current parent,
1536 * this function will update the priority/weight of an existing node.
1538 * Restriction for root node: its parent cannot be changed.
1540 * This function can only be called after the rte_tm_hierarchy_commit()
1541 * invocation. Its success depends on the port support for this operation, as
1542 * advertised through the port capability set.
1544 * @param[in] port_id
1545 * The port identifier of the Ethernet device.
1546 * @param[in] node_id
1547 * Node ID. Needs to be valid.
1548 * @param[in] parent_node_id
1549 * Node ID for the new parent. Needs to be valid.
1550 * @param[in] priority
1551 * Node priority. The highest node priority is zero. Used by the SP algorithm
1552 * running on the parent of the current node for scheduling this child node.
1554 * Node weight. The node weight is relative to the weight sum of all siblings
1555 * that have the same priority. The lowest weight is zero. Used by the WFQ
1556 * algorithm running on the parent of the current node for scheduling this
1559 * Error details. Filled in only on error, when not NULL.
1561 * 0 on success, non-zero error code otherwise.
1563 * @see RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL
1564 * @see RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL
1567 rte_tm_node_parent_update(uint16_t port_id,
1569 uint32_t parent_node_id,
1572 struct rte_tm_error *error);
1575 * Traffic manager node private shaper update
1577 * Restriction for the root node: its private shaper profile needs to be valid
1580 * @param[in] port_id
1581 * The port identifier of the Ethernet device.
1582 * @param[in] node_id
1583 * Node ID. Needs to be valid.
1584 * @param[in] shaper_profile_id
1585 * Shaper profile ID for the private shaper of the current node. Needs to be
1586 * either valid shaper profile ID or RTE_TM_SHAPER_PROFILE_ID_NONE, with
1587 * the latter disabling the private shaper of the current node.
1589 * Error details. Filled in only on error, when not NULL.
1591 * 0 on success, non-zero error code otherwise.
1593 * @see struct rte_tm_capabilities::shaper_private_n_max
1596 rte_tm_node_shaper_update(uint16_t port_id,
1598 uint32_t shaper_profile_id,
1599 struct rte_tm_error *error);
1602 * Traffic manager node shared shapers update
1604 * Restriction for root node: cannot use any shared rate shapers.
1606 * @param[in] port_id
1607 * The port identifier of the Ethernet device.
1608 * @param[in] node_id
1609 * Node ID. Needs to be valid.
1610 * @param[in] shared_shaper_id
1611 * Shared shaper ID. Needs to be valid.
1613 * Set to non-zero value to add this shared shaper to current node or to zero
1614 * to delete this shared shaper from current node.
1616 * Error details. Filled in only on error, when not NULL.
1618 * 0 on success, non-zero error code otherwise.
1620 * @see struct rte_tm_capabilities::shaper_shared_n_max
1623 rte_tm_node_shared_shaper_update(uint16_t port_id,
1625 uint32_t shared_shaper_id,
1627 struct rte_tm_error *error);
1630 * Traffic manager node enabled statistics counters update
1632 * @param[in] port_id
1633 * The port identifier of the Ethernet device.
1634 * @param[in] node_id
1635 * Node ID. Needs to be valid.
1636 * @param[in] stats_mask
1637 * Mask of statistics counter types to be enabled for the current node. This
1638 * needs to be a subset of the statistics counter types available for the
1639 * current node. Any statistics counter type not included in this set is to
1640 * be disabled for the current node.
1642 * Error details. Filled in only on error, when not NULL.
1644 * 0 on success, non-zero error code otherwise.
1646 * @see enum rte_tm_stats_type
1647 * @see RTE_TM_UPDATE_NODE_STATS
1650 rte_tm_node_stats_update(uint16_t port_id,
1652 uint64_t stats_mask,
1653 struct rte_tm_error *error);
1656 * Traffic manager node WFQ weight mode update
1658 * @param[in] port_id
1659 * The port identifier of the Ethernet device.
1660 * @param[in] node_id
1661 * Node ID. Needs to be valid non-leaf node ID.
1662 * @param[in] wfq_weight_mode
1663 * WFQ weight mode for each SP priority. When NULL, it indicates that WFQ is
1664 * to be used for all priorities. When non-NULL, it points to a pre-allocated
1665 * array of *n_sp_priorities* values, with non-zero value for byte-mode and
1666 * zero for packet-mode.
1667 * @param[in] n_sp_priorities
1668 * Number of SP priorities.
1670 * Error details. Filled in only on error, when not NULL.
1672 * 0 on success, non-zero error code otherwise.
1674 * @see RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE
1675 * @see RTE_TM_UPDATE_NODE_N_SP_PRIORITIES
1678 rte_tm_node_wfq_weight_mode_update(uint16_t port_id,
1680 int *wfq_weight_mode,
1681 uint32_t n_sp_priorities,
1682 struct rte_tm_error *error);
1685 * Traffic manager node congestion management mode update
1687 * @param[in] port_id
1688 * The port identifier of the Ethernet device.
1689 * @param[in] node_id
1690 * Node ID. Needs to be valid leaf node ID.
1692 * Congestion management mode.
1694 * Error details. Filled in only on error, when not NULL.
1696 * 0 on success, non-zero error code otherwise.
1698 * @see RTE_TM_UPDATE_NODE_CMAN
1701 rte_tm_node_cman_update(uint16_t port_id,
1703 enum rte_tm_cman_mode cman,
1704 struct rte_tm_error *error);
1707 * Traffic manager node private WRED context update
1709 * @param[in] port_id
1710 * The port identifier of the Ethernet device.
1711 * @param[in] node_id
1712 * Node ID. Needs to be valid leaf node ID.
1713 * @param[in] wred_profile_id
1714 * WRED profile ID for the private WRED context of the current node. Needs to
1715 * be either valid WRED profile ID or RTE_TM_WRED_PROFILE_ID_NONE, with the
1716 * latter disabling the private WRED context of the current node.
1718 * Error details. Filled in only on error, when not NULL.
1720 * 0 on success, non-zero error code otherwise.
1722 * @see struct rte_tm_capabilities::cman_wred_context_private_n_max
1725 rte_tm_node_wred_context_update(uint16_t port_id,
1727 uint32_t wred_profile_id,
1728 struct rte_tm_error *error);
1731 * Traffic manager node shared WRED context update
1733 * @param[in] port_id
1734 * The port identifier of the Ethernet device.
1735 * @param[in] node_id
1736 * Node ID. Needs to be valid leaf node ID.
1737 * @param[in] shared_wred_context_id
1738 * Shared WRED context ID. Needs to be valid.
1740 * Set to non-zero value to add this shared WRED context to current node or
1741 * to zero to delete this shared WRED context from current node.
1743 * Error details. Filled in only on error, when not NULL.
1745 * 0 on success, non-zero error code otherwise.
1747 * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1750 rte_tm_node_shared_wred_context_update(uint16_t port_id,
1752 uint32_t shared_wred_context_id,
1754 struct rte_tm_error *error);
1757 * Traffic manager node statistics counters read
1759 * @param[in] port_id
1760 * The port identifier of the Ethernet device.
1761 * @param[in] node_id
1762 * Node ID. Needs to be valid.
1764 * When non-NULL, it contains the current value for the statistics counters
1765 * enabled for the current node.
1766 * @param[out] stats_mask
1767 * When non-NULL, it contains the mask of statistics counter types that are
1768 * currently enabled for this node, indicating which of the counters
1769 * retrieved with the *stats* structure are valid.
1771 * When this parameter has a non-zero value, the statistics counters are
1772 * cleared (i.e. set to zero) immediately after they have been read,
1773 * otherwise the statistics counters are left untouched.
1775 * Error details. Filled in only on error, when not NULL.
1777 * 0 on success, non-zero error code otherwise.
1779 * @see enum rte_tm_stats_type
1782 rte_tm_node_stats_read(uint16_t port_id,
1784 struct rte_tm_node_stats *stats,
1785 uint64_t *stats_mask,
1787 struct rte_tm_error *error);
1790 * Traffic manager packet marking - VLAN DEI (IEEE 802.1Q)
1792 * IEEE 802.1p maps the traffic class to the VLAN Priority Code Point (PCP)
1793 * field (3 bits), while IEEE 802.1q maps the drop priority to the VLAN Drop
1794 * Eligible Indicator (DEI) field (1 bit), which was previously named Canonical
1795 * Format Indicator (CFI).
1797 * All VLAN frames of a given color get their DEI bit set if marking is enabled
1798 * for this color; otherwise, their DEI bit is left as is (either set or not).
1800 * @param[in] port_id
1801 * The port identifier of the Ethernet device.
1802 * @param[in] mark_green
1803 * Set to non-zero value to enable marking of green packets and to zero to
1805 * @param[in] mark_yellow
1806 * Set to non-zero value to enable marking of yellow packets and to zero to
1808 * @param[in] mark_red
1809 * Set to non-zero value to enable marking of red packets and to zero to
1812 * Error details. Filled in only on error, when not NULL.
1814 * 0 on success, non-zero error code otherwise.
1816 * @see struct rte_tm_capabilities::mark_vlan_dei_supported
1819 rte_tm_mark_vlan_dei(uint16_t port_id,
1823 struct rte_tm_error *error);
1826 * Traffic manager packet marking - IPv4 / IPv6 ECN (IETF RFC 3168)
1828 * IETF RFCs 2474 and 3168 reorganize the IPv4 Type of Service (TOS) field
1829 * (8 bits) and the IPv6 Traffic Class (TC) field (8 bits) into Differentiated
1830 * Services Codepoint (DSCP) field (6 bits) and Explicit Congestion
1831 * Notification (ECN) field (2 bits). The DSCP field is typically used to
1832 * encode the traffic class and/or drop priority (RFC 2597), while the ECN
1833 * field is used by RFC 3168 to implement a congestion notification mechanism
1834 * to be leveraged by transport layer protocols such as TCP and SCTP that have
1835 * congestion control mechanisms.
1837 * When congestion is experienced, as alternative to dropping the packet,
1838 * routers can change the ECN field of input packets from 2'b01 or 2'b10
1839 * (values indicating that source endpoint is ECN-capable) to 2'b11 (meaning
1840 * that congestion is experienced). The destination endpoint can use the
1841 * ECN-Echo (ECE) TCP flag to relay the congestion indication back to the
1842 * source endpoint, which acknowledges it back to the destination endpoint with
1843 * the Congestion Window Reduced (CWR) TCP flag.
1845 * All IPv4/IPv6 packets of a given color with ECN set to 2’b01 or 2’b10
1846 * carrying TCP or SCTP have their ECN set to 2’b11 if the marking feature is
1847 * enabled for the current color, otherwise the ECN field is left as is.
1849 * @param[in] port_id
1850 * The port identifier of the Ethernet device.
1851 * @param[in] mark_green
1852 * Set to non-zero value to enable marking of green packets and to zero to
1854 * @param[in] mark_yellow
1855 * Set to non-zero value to enable marking of yellow packets and to zero to
1857 * @param[in] mark_red
1858 * Set to non-zero value to enable marking of red packets and to zero to
1861 * Error details. Filled in only on error, when not NULL.
1863 * 0 on success, non-zero error code otherwise.
1865 * @see struct rte_tm_capabilities::mark_ip_ecn_tcp_supported
1866 * @see struct rte_tm_capabilities::mark_ip_ecn_sctp_supported
1869 rte_tm_mark_ip_ecn(uint16_t port_id,
1873 struct rte_tm_error *error);
1876 * Traffic manager packet marking - IPv4 / IPv6 DSCP (IETF RFC 2597)
1878 * IETF RFC 2597 maps the traffic class and the drop priority to the IPv4/IPv6
1879 * Differentiated Services Codepoint (DSCP) field (6 bits). Here are the DSCP
1880 * values proposed by this RFC:
1882 * <pre> Class 1 Class 2 Class 3 Class 4 </pre>
1883 * <pre> +----------+----------+----------+----------+</pre>
1884 * <pre>Low Drop Prec | 001010 | 010010 | 011010 | 100010 |</pre>
1885 * <pre>Medium Drop Prec | 001100 | 010100 | 011100 | 100100 |</pre>
1886 * <pre>High Drop Prec | 001110 | 010110 | 011110 | 100110 |</pre>
1887 * <pre> +----------+----------+----------+----------+</pre>
1889 * There are 4 traffic classes (classes 1 .. 4) encoded by DSCP bits 1 and 2,
1890 * as well as 3 drop priorities (low/medium/high) encoded by DSCP bits 3 and 4.
1892 * All IPv4/IPv6 packets have their color marked into DSCP bits 3 and 4 as
1893 * follows: green mapped to Low Drop Precedence (2’b01), yellow to Medium
1894 * (2’b10) and red to High (2’b11). Marking needs to be explicitly enabled
1895 * for each color; when not enabled for a given color, the DSCP field of all
1896 * packets with that color is left as is.
1898 * @param[in] port_id
1899 * The port identifier of the Ethernet device.
1900 * @param[in] mark_green
1901 * Set to non-zero value to enable marking of green packets and to zero to
1903 * @param[in] mark_yellow
1904 * Set to non-zero value to enable marking of yellow packets and to zero to
1906 * @param[in] mark_red
1907 * Set to non-zero value to enable marking of red packets and to zero to
1910 * Error details. Filled in only on error, when not NULL.
1912 * 0 on success, non-zero error code otherwise.
1914 * @see struct rte_tm_capabilities::mark_ip_dscp_supported
1917 rte_tm_mark_ip_dscp(uint16_t port_id,
1921 struct rte_tm_error *error);
1927 #endif /* __INCLUDE_RTE_TM_H__ */