xref: /dpdk/lib/ethdev/rte_tm.h (revision 25a2a0dc3de31ca0a6fbc9371cf3dd85dfd74b07)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright(c) 2017 Intel Corporation.
399a2dd95SBruce Richardson  * Copyright(c) 2017 Cavium.
499a2dd95SBruce Richardson  * Copyright(c) 2017 NXP.
599a2dd95SBruce Richardson  */
699a2dd95SBruce Richardson 
799a2dd95SBruce Richardson #ifndef __INCLUDE_RTE_TM_H__
899a2dd95SBruce Richardson #define __INCLUDE_RTE_TM_H__
999a2dd95SBruce Richardson 
1099a2dd95SBruce Richardson /**
1199a2dd95SBruce Richardson  * @file
1299a2dd95SBruce Richardson  * RTE Generic Traffic Manager API
1399a2dd95SBruce Richardson  *
1499a2dd95SBruce Richardson  * This interface provides the ability to configure the traffic manager in a
1599a2dd95SBruce Richardson  * generic way. It includes features such as: hierarchical scheduling,
1699a2dd95SBruce Richardson  * traffic shaping, congestion management, packet marking, etc.
1799a2dd95SBruce Richardson  */
1899a2dd95SBruce Richardson 
1999a2dd95SBruce Richardson #include <stdint.h>
2099a2dd95SBruce Richardson 
2199a2dd95SBruce Richardson #include <rte_common.h>
2299a2dd95SBruce Richardson #include <rte_meter.h>
23*25a2a0dcSBruce Richardson #include <rte_compat.h>
2499a2dd95SBruce Richardson 
2599a2dd95SBruce Richardson #ifdef __cplusplus
2699a2dd95SBruce Richardson extern "C" {
2799a2dd95SBruce Richardson #endif
2899a2dd95SBruce Richardson 
2999a2dd95SBruce Richardson /**
3099a2dd95SBruce Richardson  * Ethernet framing overhead.
3199a2dd95SBruce Richardson  *
3299a2dd95SBruce Richardson  * Overhead fields per Ethernet frame:
3399a2dd95SBruce Richardson  * 1. Preamble:                                            7 bytes;
3499a2dd95SBruce Richardson  * 2. Start of Frame Delimiter (SFD):                      1 byte;
3599a2dd95SBruce Richardson  * 3. Inter-Frame Gap (IFG):                              12 bytes.
3699a2dd95SBruce Richardson  *
3799a2dd95SBruce Richardson  * One of the typical values for the *pkt_length_adjust* field of the shaper
3899a2dd95SBruce Richardson  * profile.
3999a2dd95SBruce Richardson  *
4099a2dd95SBruce Richardson  * @see struct rte_tm_shaper_params
4199a2dd95SBruce Richardson  */
4299a2dd95SBruce Richardson #define RTE_TM_ETH_FRAMING_OVERHEAD                  20
4399a2dd95SBruce Richardson 
4499a2dd95SBruce Richardson /**
4599a2dd95SBruce Richardson  * Ethernet framing overhead including the Frame Check Sequence (FCS) field.
4699a2dd95SBruce Richardson  * Useful when FCS is generated and added at the end of the Ethernet frame on
4709fd4227SAndrew Rybchenko  * Tx side without any SW intervention.
4899a2dd95SBruce Richardson  *
4999a2dd95SBruce Richardson  * One of the typical values for the pkt_length_adjust field of the shaper
5099a2dd95SBruce Richardson  * profile.
5199a2dd95SBruce Richardson  *
5299a2dd95SBruce Richardson  * @see struct rte_tm_shaper_params
5399a2dd95SBruce Richardson  */
5499a2dd95SBruce Richardson #define RTE_TM_ETH_FRAMING_OVERHEAD_FCS              24
5599a2dd95SBruce Richardson 
5699a2dd95SBruce Richardson /**
5799a2dd95SBruce Richardson  * Invalid WRED profile ID.
5899a2dd95SBruce Richardson  *
5999a2dd95SBruce Richardson  * @see struct rte_tm_node_params
6099a2dd95SBruce Richardson  * @see rte_tm_node_add()
6199a2dd95SBruce Richardson  * @see rte_tm_node_wred_context_update()
6299a2dd95SBruce Richardson  */
6399a2dd95SBruce Richardson #define RTE_TM_WRED_PROFILE_ID_NONE                  UINT32_MAX
6499a2dd95SBruce Richardson 
6599a2dd95SBruce Richardson /**
6699a2dd95SBruce Richardson  *Invalid shaper profile ID.
6799a2dd95SBruce Richardson  *
6899a2dd95SBruce Richardson  * @see struct rte_tm_node_params
6999a2dd95SBruce Richardson  * @see rte_tm_node_add()
7099a2dd95SBruce Richardson  * @see rte_tm_node_shaper_update()
7199a2dd95SBruce Richardson  */
7299a2dd95SBruce Richardson #define RTE_TM_SHAPER_PROFILE_ID_NONE                UINT32_MAX
7399a2dd95SBruce Richardson 
7499a2dd95SBruce Richardson /**
7599a2dd95SBruce Richardson  * Node ID for the parent of the root node.
7699a2dd95SBruce Richardson  *
7799a2dd95SBruce Richardson  * @see rte_tm_node_add()
7899a2dd95SBruce Richardson  */
7999a2dd95SBruce Richardson #define RTE_TM_NODE_ID_NULL                          UINT32_MAX
8099a2dd95SBruce Richardson 
8199a2dd95SBruce Richardson /**
8299a2dd95SBruce Richardson  * Node level ID used to disable level ID checking.
8399a2dd95SBruce Richardson  *
8499a2dd95SBruce Richardson  * @see rte_tm_node_add()
8599a2dd95SBruce Richardson  */
8699a2dd95SBruce Richardson #define RTE_TM_NODE_LEVEL_ID_ANY                     UINT32_MAX
8799a2dd95SBruce Richardson 
8899a2dd95SBruce Richardson /**
8999a2dd95SBruce Richardson  * Node statistics counter type
9099a2dd95SBruce Richardson  */
9199a2dd95SBruce Richardson enum rte_tm_stats_type {
9299a2dd95SBruce Richardson 	/** Number of packets scheduled from current node. */
9399a2dd95SBruce Richardson 	RTE_TM_STATS_N_PKTS = 1 << 0,
9499a2dd95SBruce Richardson 
9599a2dd95SBruce Richardson 	/** Number of bytes scheduled from current node. */
9699a2dd95SBruce Richardson 	RTE_TM_STATS_N_BYTES = 1 << 1,
9799a2dd95SBruce Richardson 
9899a2dd95SBruce Richardson 	/** Number of green packets dropped by current leaf node.  */
9999a2dd95SBruce Richardson 	RTE_TM_STATS_N_PKTS_GREEN_DROPPED = 1 << 2,
10099a2dd95SBruce Richardson 
10199a2dd95SBruce Richardson 	/** Number of yellow packets dropped by current leaf node.  */
10299a2dd95SBruce Richardson 	RTE_TM_STATS_N_PKTS_YELLOW_DROPPED = 1 << 3,
10399a2dd95SBruce Richardson 
10499a2dd95SBruce Richardson 	/** Number of red packets dropped by current leaf node.  */
10599a2dd95SBruce Richardson 	RTE_TM_STATS_N_PKTS_RED_DROPPED = 1 << 4,
10699a2dd95SBruce Richardson 
10799a2dd95SBruce Richardson 	/** Number of green bytes dropped by current leaf node.  */
10899a2dd95SBruce Richardson 	RTE_TM_STATS_N_BYTES_GREEN_DROPPED = 1 << 5,
10999a2dd95SBruce Richardson 
11099a2dd95SBruce Richardson 	/** Number of yellow bytes dropped by current leaf node.  */
11199a2dd95SBruce Richardson 	RTE_TM_STATS_N_BYTES_YELLOW_DROPPED = 1 << 6,
11299a2dd95SBruce Richardson 
11399a2dd95SBruce Richardson 	/** Number of red bytes dropped by current leaf node.  */
11499a2dd95SBruce Richardson 	RTE_TM_STATS_N_BYTES_RED_DROPPED = 1 << 7,
11599a2dd95SBruce Richardson 
11699a2dd95SBruce Richardson 	/** Number of packets currently waiting in the packet queue of current
11799a2dd95SBruce Richardson 	 * leaf node.
11899a2dd95SBruce Richardson 	 */
11999a2dd95SBruce Richardson 	RTE_TM_STATS_N_PKTS_QUEUED = 1 << 8,
12099a2dd95SBruce Richardson 
12199a2dd95SBruce Richardson 	/** Number of bytes currently waiting in the packet queue of current
12299a2dd95SBruce Richardson 	 * leaf node.
12399a2dd95SBruce Richardson 	 */
12499a2dd95SBruce Richardson 	RTE_TM_STATS_N_BYTES_QUEUED = 1 << 9,
12599a2dd95SBruce Richardson };
12699a2dd95SBruce Richardson 
12799a2dd95SBruce Richardson /**
12899a2dd95SBruce Richardson  * Node statistics counters
12999a2dd95SBruce Richardson  */
13099a2dd95SBruce Richardson struct rte_tm_node_stats {
13199a2dd95SBruce Richardson 	/** Number of packets scheduled from current node. */
13299a2dd95SBruce Richardson 	uint64_t n_pkts;
13399a2dd95SBruce Richardson 
13499a2dd95SBruce Richardson 	/** Number of bytes scheduled from current node. */
13599a2dd95SBruce Richardson 	uint64_t n_bytes;
13699a2dd95SBruce Richardson 
13799a2dd95SBruce Richardson 	/** Statistics counters for leaf nodes only. */
13899a2dd95SBruce Richardson 	struct {
13999a2dd95SBruce Richardson 		/** Number of packets dropped by current leaf node per each
14099a2dd95SBruce Richardson 		 * color.
14199a2dd95SBruce Richardson 		 */
14299a2dd95SBruce Richardson 		uint64_t n_pkts_dropped[RTE_COLORS];
14399a2dd95SBruce Richardson 
14499a2dd95SBruce Richardson 		/** Number of bytes dropped by current leaf node per each
14599a2dd95SBruce Richardson 		 * color.
14699a2dd95SBruce Richardson 		 */
14799a2dd95SBruce Richardson 		uint64_t n_bytes_dropped[RTE_COLORS];
14899a2dd95SBruce Richardson 
14999a2dd95SBruce Richardson 		/** Number of packets currently waiting in the packet queue of
15099a2dd95SBruce Richardson 		 * current leaf node.
15199a2dd95SBruce Richardson 		 */
15299a2dd95SBruce Richardson 		uint64_t n_pkts_queued;
15399a2dd95SBruce Richardson 
15499a2dd95SBruce Richardson 		/** Number of bytes currently waiting in the packet queue of
15599a2dd95SBruce Richardson 		 * current leaf node.
15699a2dd95SBruce Richardson 		 */
15799a2dd95SBruce Richardson 		uint64_t n_bytes_queued;
15899a2dd95SBruce Richardson 	} leaf;
15999a2dd95SBruce Richardson };
16099a2dd95SBruce Richardson 
16199a2dd95SBruce Richardson /**
16299a2dd95SBruce Richardson  * Traffic manager dynamic updates
16399a2dd95SBruce Richardson  */
16499a2dd95SBruce Richardson enum rte_tm_dynamic_update_type {
16599a2dd95SBruce Richardson 	/** Dynamic parent node update. The new parent node is located on same
16699a2dd95SBruce Richardson 	 * hierarchy level as the former parent node. Consequently, the node
16799a2dd95SBruce Richardson 	 * whose parent is changed preserves its hierarchy level.
16899a2dd95SBruce Richardson 	 */
16999a2dd95SBruce Richardson 	RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL = 1 << 0,
17099a2dd95SBruce Richardson 
17199a2dd95SBruce Richardson 	/** Dynamic parent node update. The new parent node is located on
17299a2dd95SBruce Richardson 	 * different hierarchy level than the former parent node. Consequently,
17399a2dd95SBruce Richardson 	 * the node whose parent is changed also changes its hierarchy level.
17499a2dd95SBruce Richardson 	 */
17599a2dd95SBruce Richardson 	RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL = 1 << 1,
17699a2dd95SBruce Richardson 
17799a2dd95SBruce Richardson 	/** Dynamic node add/delete. */
17899a2dd95SBruce Richardson 	RTE_TM_UPDATE_NODE_ADD_DELETE = 1 << 2,
17999a2dd95SBruce Richardson 
18099a2dd95SBruce Richardson 	/** Suspend/resume nodes. */
18199a2dd95SBruce Richardson 	RTE_TM_UPDATE_NODE_SUSPEND_RESUME = 1 << 3,
18299a2dd95SBruce Richardson 
18399a2dd95SBruce Richardson 	/** Dynamic switch between byte-based and packet-based WFQ weights. */
18499a2dd95SBruce Richardson 	RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE = 1 << 4,
18599a2dd95SBruce Richardson 
18699a2dd95SBruce Richardson 	/** Dynamic update on number of SP priorities. */
18799a2dd95SBruce Richardson 	RTE_TM_UPDATE_NODE_N_SP_PRIORITIES = 1 << 5,
18899a2dd95SBruce Richardson 
18999a2dd95SBruce Richardson 	/** Dynamic update of congestion management mode for leaf nodes. */
19099a2dd95SBruce Richardson 	RTE_TM_UPDATE_NODE_CMAN = 1 << 6,
19199a2dd95SBruce Richardson 
19299a2dd95SBruce Richardson 	/** Dynamic update of the set of enabled stats counter types. */
19399a2dd95SBruce Richardson 	RTE_TM_UPDATE_NODE_STATS = 1 << 7,
19499a2dd95SBruce Richardson };
19599a2dd95SBruce Richardson 
19699a2dd95SBruce Richardson /**
19799a2dd95SBruce Richardson  * Traffic manager capabilities
19899a2dd95SBruce Richardson  */
19999a2dd95SBruce Richardson struct rte_tm_capabilities {
20099a2dd95SBruce Richardson 	/** Maximum number of nodes. */
20199a2dd95SBruce Richardson 	uint32_t n_nodes_max;
20299a2dd95SBruce Richardson 
20399a2dd95SBruce Richardson 	/** Maximum number of levels (i.e. number of nodes connecting the root
20499a2dd95SBruce Richardson 	 * node with any leaf node, including the root and the leaf).
20599a2dd95SBruce Richardson 	 */
20699a2dd95SBruce Richardson 	uint32_t n_levels_max;
20799a2dd95SBruce Richardson 
20899a2dd95SBruce Richardson 	/** When non-zero, this flag indicates that all the non-leaf nodes
20999a2dd95SBruce Richardson 	 * (with the exception of the root node) have identical capability set.
21099a2dd95SBruce Richardson 	 */
21199a2dd95SBruce Richardson 	int non_leaf_nodes_identical;
21299a2dd95SBruce Richardson 
21399a2dd95SBruce Richardson 	/** When non-zero, this flag indicates that all the leaf nodes have
21499a2dd95SBruce Richardson 	 * identical capability set.
21599a2dd95SBruce Richardson 	 */
21699a2dd95SBruce Richardson 	int leaf_nodes_identical;
21799a2dd95SBruce Richardson 
21899a2dd95SBruce Richardson 	/** Maximum number of shapers, either private or shared. In case the
21999a2dd95SBruce Richardson 	 * implementation does not share any resources between private and
22099a2dd95SBruce Richardson 	 * shared shapers, it is typically equal to the sum of
22199a2dd95SBruce Richardson 	 * *shaper_private_n_max* and *shaper_shared_n_max*. The
22299a2dd95SBruce Richardson 	 * value of zero indicates that traffic shaping is not supported.
22399a2dd95SBruce Richardson 	 */
22499a2dd95SBruce Richardson 	uint32_t shaper_n_max;
22599a2dd95SBruce Richardson 
22699a2dd95SBruce Richardson 	/** Maximum number of private shapers. Indicates the maximum number of
22799a2dd95SBruce Richardson 	 * nodes that can concurrently have their private shaper enabled. The
22899a2dd95SBruce Richardson 	 * value of zero indicates that private shapers are not supported.
22999a2dd95SBruce Richardson 	 */
23099a2dd95SBruce Richardson 	uint32_t shaper_private_n_max;
23199a2dd95SBruce Richardson 
23299a2dd95SBruce Richardson 	/** Maximum number of private shapers that support dual rate shaping.
23399a2dd95SBruce Richardson 	 * Indicates the maximum number of nodes that can concurrently have
23499a2dd95SBruce Richardson 	 * their private shaper enabled with dual rate support. Only valid when
23599a2dd95SBruce Richardson 	 * private shapers are supported. The value of zero indicates that dual
23699a2dd95SBruce Richardson 	 * rate shaping is not available for private shapers. The maximum value
23799a2dd95SBruce Richardson 	 * is *shaper_private_n_max*.
23899a2dd95SBruce Richardson 	 */
23999a2dd95SBruce Richardson 	int shaper_private_dual_rate_n_max;
24099a2dd95SBruce Richardson 
24199a2dd95SBruce Richardson 	/** Minimum committed/peak rate (bytes per second) for any private
24299a2dd95SBruce Richardson 	 * shaper. Valid only when private shapers are supported.
24399a2dd95SBruce Richardson 	 */
24499a2dd95SBruce Richardson 	uint64_t shaper_private_rate_min;
24599a2dd95SBruce Richardson 
24699a2dd95SBruce Richardson 	/** Maximum committed/peak rate (bytes per second) for any private
24799a2dd95SBruce Richardson 	 * shaper. Valid only when private shapers are supported.
24899a2dd95SBruce Richardson 	 */
24999a2dd95SBruce Richardson 	uint64_t shaper_private_rate_max;
25099a2dd95SBruce Richardson 
25199a2dd95SBruce Richardson 	/** Shaper private packet mode supported. When non-zero, this parameter
25299a2dd95SBruce Richardson 	 * indicates that there is at least one node that can be configured
25399a2dd95SBruce Richardson 	 * with packet mode in its private shaper. When shaper is configured
25499a2dd95SBruce Richardson 	 * in packet mode, committed/peak rate provided is interpreted
25599a2dd95SBruce Richardson 	 * in packets per second.
25699a2dd95SBruce Richardson 	 */
25799a2dd95SBruce Richardson 	int shaper_private_packet_mode_supported;
25899a2dd95SBruce Richardson 
25999a2dd95SBruce Richardson 	/** Shaper private byte mode supported. When non-zero, this parameter
26099a2dd95SBruce Richardson 	 * indicates that there is at least one node that can be configured
26199a2dd95SBruce Richardson 	 * with byte mode in its private shaper. When shaper is configured
26299a2dd95SBruce Richardson 	 * in byte mode, committed/peak rate provided is interpreted in
26399a2dd95SBruce Richardson 	 * bytes per second.
26499a2dd95SBruce Richardson 	 */
26599a2dd95SBruce Richardson 	int shaper_private_byte_mode_supported;
26699a2dd95SBruce Richardson 
26799a2dd95SBruce Richardson 
26899a2dd95SBruce Richardson 	/** Maximum number of shared shapers. The value of zero indicates that
26999a2dd95SBruce Richardson 	 * shared shapers are not supported.
27099a2dd95SBruce Richardson 	 */
27199a2dd95SBruce Richardson 	uint32_t shaper_shared_n_max;
27299a2dd95SBruce Richardson 
27399a2dd95SBruce Richardson 	/** Maximum number of nodes that can share the same shared shaper.
27499a2dd95SBruce Richardson 	 * Only valid when shared shapers are supported.
27599a2dd95SBruce Richardson 	 */
27699a2dd95SBruce Richardson 	uint32_t shaper_shared_n_nodes_per_shaper_max;
27799a2dd95SBruce Richardson 
27899a2dd95SBruce Richardson 	/** Maximum number of shared shapers a node can be part of. This
27999a2dd95SBruce Richardson 	 * parameter indicates that there is at least one node that can be
28099a2dd95SBruce Richardson 	 * configured with this many shared shapers, which might not be true for
28199a2dd95SBruce Richardson 	 * all the nodes. Only valid when shared shapers are supported, in which
28299a2dd95SBruce Richardson 	 * case it ranges from 1 to *shaper_shared_n_max*.
28399a2dd95SBruce Richardson 	 */
28499a2dd95SBruce Richardson 	uint32_t shaper_shared_n_shapers_per_node_max;
28599a2dd95SBruce Richardson 
28699a2dd95SBruce Richardson 	/** Maximum number of shared shapers that can be configured with dual
28799a2dd95SBruce Richardson 	 * rate shaping. The value of zero indicates that dual rate shaping
28899a2dd95SBruce Richardson 	 * support is not available for shared shapers.
28999a2dd95SBruce Richardson 	 */
29099a2dd95SBruce Richardson 	uint32_t shaper_shared_dual_rate_n_max;
29199a2dd95SBruce Richardson 
29299a2dd95SBruce Richardson 	/** Minimum committed/peak rate (bytes per second) for any shared
29399a2dd95SBruce Richardson 	 * shaper. Only valid when shared shapers are supported.
29499a2dd95SBruce Richardson 	 */
29599a2dd95SBruce Richardson 	uint64_t shaper_shared_rate_min;
29699a2dd95SBruce Richardson 
29799a2dd95SBruce Richardson 	/** Maximum committed/peak rate (bytes per second) for any shared
29899a2dd95SBruce Richardson 	 * shaper. Only valid when shared shapers are supported.
29999a2dd95SBruce Richardson 	 */
30099a2dd95SBruce Richardson 	uint64_t shaper_shared_rate_max;
30199a2dd95SBruce Richardson 
30299a2dd95SBruce Richardson 	/** Shaper shared packet mode supported. When non-zero, this parameter
30399a2dd95SBruce Richardson 	 * indicates a shared shaper can be configured with packet mode.
30499a2dd95SBruce Richardson 	 * When shared shaper is configured in packet mode, committed/peak rate
30599a2dd95SBruce Richardson 	 * provided is interpreted in packets per second.
30699a2dd95SBruce Richardson 	 */
30799a2dd95SBruce Richardson 	int shaper_shared_packet_mode_supported;
30899a2dd95SBruce Richardson 
30999a2dd95SBruce Richardson 	/** Shaper shared byte mode supported. When non-zero, this parameter
31099a2dd95SBruce Richardson 	 * indicates that a shared shaper can be configured with byte mode.
31199a2dd95SBruce Richardson 	 * When shared shaper is configured in byte mode, committed/peak rate
31299a2dd95SBruce Richardson 	 * provided is interpreted in bytes per second.
31399a2dd95SBruce Richardson 	 */
31499a2dd95SBruce Richardson 	int shaper_shared_byte_mode_supported;
31599a2dd95SBruce Richardson 
31699a2dd95SBruce Richardson 
31799a2dd95SBruce Richardson 	/** Minimum value allowed for packet length adjustment for any private
31899a2dd95SBruce Richardson 	 * or shared shaper.
31999a2dd95SBruce Richardson 	 */
32099a2dd95SBruce Richardson 	int shaper_pkt_length_adjust_min;
32199a2dd95SBruce Richardson 
32299a2dd95SBruce Richardson 	/** Maximum value allowed for packet length adjustment for any private
32399a2dd95SBruce Richardson 	 * or shared shaper.
32499a2dd95SBruce Richardson 	 */
32599a2dd95SBruce Richardson 	int shaper_pkt_length_adjust_max;
32699a2dd95SBruce Richardson 
32799a2dd95SBruce Richardson 	/** Maximum number of children nodes. This parameter indicates that
32899a2dd95SBruce Richardson 	 * there is at least one non-leaf node that can be configured with this
32999a2dd95SBruce Richardson 	 * many children nodes, which might not be true for all the non-leaf
33099a2dd95SBruce Richardson 	 * nodes.
33199a2dd95SBruce Richardson 	 */
33299a2dd95SBruce Richardson 	uint32_t sched_n_children_max;
33399a2dd95SBruce Richardson 
33499a2dd95SBruce Richardson 	/** Maximum number of supported priority levels. This parameter
33599a2dd95SBruce Richardson 	 * indicates that there is at least one non-leaf node that can be
33699a2dd95SBruce Richardson 	 * configured with this many priority levels for managing its children
33799a2dd95SBruce Richardson 	 * nodes, which might not be true for all the non-leaf nodes. The value
33899a2dd95SBruce Richardson 	 * of zero is invalid. The value of 1 indicates that only priority 0 is
33999a2dd95SBruce Richardson 	 * supported, which essentially means that Strict Priority (SP)
34099a2dd95SBruce Richardson 	 * algorithm is not supported.
34199a2dd95SBruce Richardson 	 */
34299a2dd95SBruce Richardson 	uint32_t sched_sp_n_priorities_max;
34399a2dd95SBruce Richardson 
34499a2dd95SBruce Richardson 	/** Maximum number of sibling nodes that can have the same priority at
34599a2dd95SBruce Richardson 	 * any given time, i.e. maximum size of the WFQ sibling node group. This
34699a2dd95SBruce Richardson 	 * parameter indicates there is at least one non-leaf node that meets
34799a2dd95SBruce Richardson 	 * this condition, which might not be true for all the non-leaf nodes.
34899a2dd95SBruce Richardson 	 * The value of zero is invalid. The value of 1 indicates that WFQ
34999a2dd95SBruce Richardson 	 * algorithm is not supported. The maximum value is
35099a2dd95SBruce Richardson 	 * *sched_n_children_max*.
35199a2dd95SBruce Richardson 	 */
35299a2dd95SBruce Richardson 	uint32_t sched_wfq_n_children_per_group_max;
35399a2dd95SBruce Richardson 
35499a2dd95SBruce Richardson 	/** Maximum number of priority levels that can have more than one child
35599a2dd95SBruce Richardson 	 * node at any given time, i.e. maximum number of WFQ sibling node
35699a2dd95SBruce Richardson 	 * groups that have two or more members. This parameter indicates there
35799a2dd95SBruce Richardson 	 * is at least one non-leaf node that meets this condition, which might
35899a2dd95SBruce Richardson 	 * not be true for all the non-leaf nodes. The value of zero states that
35999a2dd95SBruce Richardson 	 * WFQ algorithm is not supported. The value of 1 indicates that
36099a2dd95SBruce Richardson 	 * (*sched_sp_n_priorities_max* - 1) priority levels have at most one
36199a2dd95SBruce Richardson 	 * child node, so there can be only one priority level with two or
36299a2dd95SBruce Richardson 	 * more sibling nodes making up a WFQ group. The maximum value is:
36399a2dd95SBruce Richardson 	 * min(floor(*sched_n_children_max* / 2), *sched_sp_n_priorities_max*).
36499a2dd95SBruce Richardson 	 */
36599a2dd95SBruce Richardson 	uint32_t sched_wfq_n_groups_max;
36699a2dd95SBruce Richardson 
36799a2dd95SBruce Richardson 	/** Maximum WFQ weight. The value of 1 indicates that all sibling nodes
36899a2dd95SBruce Richardson 	 * with same priority have the same WFQ weight, so WFQ is reduced to FQ.
36999a2dd95SBruce Richardson 	 */
37099a2dd95SBruce Richardson 	uint32_t sched_wfq_weight_max;
37199a2dd95SBruce Richardson 
37299a2dd95SBruce Richardson 	/** WFQ packet mode supported. When non-zero, this parameter indicates
37399a2dd95SBruce Richardson 	 * that there is at least one non-leaf node that supports packet mode
37499a2dd95SBruce Richardson 	 * for WFQ among its children. WFQ weights will be applied against
37599a2dd95SBruce Richardson 	 * packet count for scheduling children when a non-leaf node
37699a2dd95SBruce Richardson 	 * is configured appropriately.
37799a2dd95SBruce Richardson 	 */
37899a2dd95SBruce Richardson 	int sched_wfq_packet_mode_supported;
37999a2dd95SBruce Richardson 
38099a2dd95SBruce Richardson 	/** WFQ byte mode supported. When non-zero, this parameter indicates
38199a2dd95SBruce Richardson 	 * that there is at least one non-leaf node that supports byte mode
38299a2dd95SBruce Richardson 	 * for WFQ among its children. WFQ weights will be applied against
38399a2dd95SBruce Richardson 	 * bytes for scheduling children when a non-leaf node is configured
38499a2dd95SBruce Richardson 	 * appropriately.
38599a2dd95SBruce Richardson 	 */
38699a2dd95SBruce Richardson 	int sched_wfq_byte_mode_supported;
38799a2dd95SBruce Richardson 
38899a2dd95SBruce Richardson 	/** WRED packet mode support. When non-zero, this parameter indicates
38999a2dd95SBruce Richardson 	 * that there is at least one leaf node that supports the WRED packet
39099a2dd95SBruce Richardson 	 * mode, which might not be true for all the leaf nodes. In packet
39199a2dd95SBruce Richardson 	 * mode, the WRED thresholds specify the queue length in packets, as
39299a2dd95SBruce Richardson 	 * opposed to bytes.
39399a2dd95SBruce Richardson 	 */
39499a2dd95SBruce Richardson 	int cman_wred_packet_mode_supported;
39599a2dd95SBruce Richardson 
39699a2dd95SBruce Richardson 	/** WRED byte mode support. When non-zero, this parameter indicates that
39799a2dd95SBruce Richardson 	 * there is at least one leaf node that supports the WRED byte mode,
39899a2dd95SBruce Richardson 	 * which might not be true for all the leaf nodes. In byte mode, the
39999a2dd95SBruce Richardson 	 * WRED thresholds specify the queue length in bytes, as opposed to
40099a2dd95SBruce Richardson 	 * packets.
40199a2dd95SBruce Richardson 	 */
40299a2dd95SBruce Richardson 	int cman_wred_byte_mode_supported;
40399a2dd95SBruce Richardson 
40499a2dd95SBruce Richardson 	/** Head drop algorithm support. When non-zero, this parameter
40599a2dd95SBruce Richardson 	 * indicates that there is at least one leaf node that supports the head
40699a2dd95SBruce Richardson 	 * drop algorithm, which might not be true for all the leaf nodes.
40799a2dd95SBruce Richardson 	 */
40899a2dd95SBruce Richardson 	int cman_head_drop_supported;
40999a2dd95SBruce Richardson 
41099a2dd95SBruce Richardson 	/** Maximum number of WRED contexts, either private or shared. In case
41199a2dd95SBruce Richardson 	 * the implementation does not share any resources between private and
41299a2dd95SBruce Richardson 	 * shared WRED contexts, it is typically equal to the sum of
41399a2dd95SBruce Richardson 	 * *cman_wred_context_private_n_max* and
41499a2dd95SBruce Richardson 	 * *cman_wred_context_shared_n_max*. The value of zero indicates that
41599a2dd95SBruce Richardson 	 * WRED is not supported.
41699a2dd95SBruce Richardson 	 */
41799a2dd95SBruce Richardson 	uint32_t cman_wred_context_n_max;
41899a2dd95SBruce Richardson 
41999a2dd95SBruce Richardson 	/** Maximum number of private WRED contexts. Indicates the maximum
42099a2dd95SBruce Richardson 	 * number of leaf nodes that can concurrently have their private WRED
42199a2dd95SBruce Richardson 	 * context enabled. The value of zero indicates that private WRED
42299a2dd95SBruce Richardson 	 * contexts are not supported.
42399a2dd95SBruce Richardson 	 */
42499a2dd95SBruce Richardson 	uint32_t cman_wred_context_private_n_max;
42599a2dd95SBruce Richardson 
42699a2dd95SBruce Richardson 	/** Maximum number of shared WRED contexts. The value of zero
42799a2dd95SBruce Richardson 	 * indicates that shared WRED contexts are not supported.
42899a2dd95SBruce Richardson 	 */
42999a2dd95SBruce Richardson 	uint32_t cman_wred_context_shared_n_max;
43099a2dd95SBruce Richardson 
43199a2dd95SBruce Richardson 	/** Maximum number of leaf nodes that can share the same WRED context.
43299a2dd95SBruce Richardson 	 * Only valid when shared WRED contexts are supported.
43399a2dd95SBruce Richardson 	 */
43499a2dd95SBruce Richardson 	uint32_t cman_wred_context_shared_n_nodes_per_context_max;
43599a2dd95SBruce Richardson 
43699a2dd95SBruce Richardson 	/** Maximum number of shared WRED contexts a leaf node can be part of.
43799a2dd95SBruce Richardson 	 * This parameter indicates that there is at least one leaf node that
43899a2dd95SBruce Richardson 	 * can be configured with this many shared WRED contexts, which might
43999a2dd95SBruce Richardson 	 * not be true for all the leaf nodes. Only valid when shared WRED
44099a2dd95SBruce Richardson 	 * contexts are supported, in which case it ranges from 1 to
44199a2dd95SBruce Richardson 	 * *cman_wred_context_shared_n_max*.
44299a2dd95SBruce Richardson 	 */
44399a2dd95SBruce Richardson 	uint32_t cman_wred_context_shared_n_contexts_per_node_max;
44499a2dd95SBruce Richardson 
44599a2dd95SBruce Richardson 	/** Support for VLAN DEI packet marking (per color). */
44699a2dd95SBruce Richardson 	int mark_vlan_dei_supported[RTE_COLORS];
44799a2dd95SBruce Richardson 
44899a2dd95SBruce Richardson 	/** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */
44999a2dd95SBruce Richardson 	int mark_ip_ecn_tcp_supported[RTE_COLORS];
45099a2dd95SBruce Richardson 
45199a2dd95SBruce Richardson 	/** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */
45299a2dd95SBruce Richardson 	int mark_ip_ecn_sctp_supported[RTE_COLORS];
45399a2dd95SBruce Richardson 
45499a2dd95SBruce Richardson 	/** Support for IPv4/IPv6 DSCP packet marking (per color). */
45599a2dd95SBruce Richardson 	int mark_ip_dscp_supported[RTE_COLORS];
45699a2dd95SBruce Richardson 
45799a2dd95SBruce Richardson 	/** Set of supported dynamic update operations.
45899a2dd95SBruce Richardson 	 * @see enum rte_tm_dynamic_update_type
45999a2dd95SBruce Richardson 	 */
46099a2dd95SBruce Richardson 	uint64_t dynamic_update_mask;
46199a2dd95SBruce Richardson 
46299a2dd95SBruce Richardson 	/** Set of supported statistics counter types.
46399a2dd95SBruce Richardson 	 * @see enum rte_tm_stats_type
46499a2dd95SBruce Richardson 	 */
46599a2dd95SBruce Richardson 	uint64_t stats_mask;
46699a2dd95SBruce Richardson };
46799a2dd95SBruce Richardson 
46899a2dd95SBruce Richardson /**
46999a2dd95SBruce Richardson  * Traffic manager level capabilities
47099a2dd95SBruce Richardson  */
47199a2dd95SBruce Richardson struct rte_tm_level_capabilities {
47299a2dd95SBruce Richardson 	/** Maximum number of nodes for the current hierarchy level. */
47399a2dd95SBruce Richardson 	uint32_t n_nodes_max;
47499a2dd95SBruce Richardson 
47599a2dd95SBruce Richardson 	/** Maximum number of non-leaf nodes for the current hierarchy level.
47699a2dd95SBruce Richardson 	 * The value of 0 indicates that current level only supports leaf
47799a2dd95SBruce Richardson 	 * nodes. The maximum value is *n_nodes_max*.
47899a2dd95SBruce Richardson 	 */
47999a2dd95SBruce Richardson 	uint32_t n_nodes_nonleaf_max;
48099a2dd95SBruce Richardson 
48199a2dd95SBruce Richardson 	/** Maximum number of leaf nodes for the current hierarchy level. The
48299a2dd95SBruce Richardson 	 * value of 0 indicates that current level only supports non-leaf
48399a2dd95SBruce Richardson 	 * nodes. The maximum value is *n_nodes_max*.
48499a2dd95SBruce Richardson 	 */
48599a2dd95SBruce Richardson 	uint32_t n_nodes_leaf_max;
48699a2dd95SBruce Richardson 
48799a2dd95SBruce Richardson 	/** When non-zero, this flag indicates that all the non-leaf nodes on
48899a2dd95SBruce Richardson 	 * this level have identical capability set. Valid only when
48999a2dd95SBruce Richardson 	 * *n_nodes_nonleaf_max* is non-zero.
49099a2dd95SBruce Richardson 	 */
49199a2dd95SBruce Richardson 	int non_leaf_nodes_identical;
49299a2dd95SBruce Richardson 
49399a2dd95SBruce Richardson 	/** When non-zero, this flag indicates that all the leaf nodes on this
49499a2dd95SBruce Richardson 	 * level have identical capability set. Valid only when
49599a2dd95SBruce Richardson 	 * *n_nodes_leaf_max* is non-zero.
49699a2dd95SBruce Richardson 	 */
49799a2dd95SBruce Richardson 	int leaf_nodes_identical;
49899a2dd95SBruce Richardson 
49999a2dd95SBruce Richardson 	union {
50099a2dd95SBruce Richardson 		/** Items valid only for the non-leaf nodes on this level. */
50199a2dd95SBruce Richardson 		struct {
50299a2dd95SBruce Richardson 			/** Private shaper support. When non-zero, it indicates
50399a2dd95SBruce Richardson 			 * there is at least one non-leaf node on this level
50499a2dd95SBruce Richardson 			 * with private shaper support, which may not be the
50599a2dd95SBruce Richardson 			 * case for all the non-leaf nodes on this level.
50699a2dd95SBruce Richardson 			 */
50799a2dd95SBruce Richardson 			int shaper_private_supported;
50899a2dd95SBruce Richardson 
50999a2dd95SBruce Richardson 			/** Dual rate support for private shaper. Valid only
51099a2dd95SBruce Richardson 			 * when private shaper is supported for the non-leaf
51199a2dd95SBruce Richardson 			 * nodes on the current level. When non-zero, it
51299a2dd95SBruce Richardson 			 * indicates there is at least one non-leaf node on this
51399a2dd95SBruce Richardson 			 * level with dual rate private shaper support, which
51499a2dd95SBruce Richardson 			 * may not be the case for all the non-leaf nodes on
51599a2dd95SBruce Richardson 			 * this level.
51699a2dd95SBruce Richardson 			 */
51799a2dd95SBruce Richardson 			int shaper_private_dual_rate_supported;
51899a2dd95SBruce Richardson 
51999a2dd95SBruce Richardson 			/** Minimum committed/peak rate (bytes per second) for
52099a2dd95SBruce Richardson 			 * private shapers of the non-leaf nodes of this level.
52199a2dd95SBruce Richardson 			 * Valid only when private shaper is supported on this
52299a2dd95SBruce Richardson 			 * level.
52399a2dd95SBruce Richardson 			 */
52499a2dd95SBruce Richardson 			uint64_t shaper_private_rate_min;
52599a2dd95SBruce Richardson 
52699a2dd95SBruce Richardson 			/** Maximum committed/peak rate (bytes per second) for
52799a2dd95SBruce Richardson 			 * private shapers of the non-leaf nodes on this level.
52899a2dd95SBruce Richardson 			 * Valid only when private shaper is supported on this
52999a2dd95SBruce Richardson 			 * level.
53099a2dd95SBruce Richardson 			 */
53199a2dd95SBruce Richardson 			uint64_t shaper_private_rate_max;
53299a2dd95SBruce Richardson 
53399a2dd95SBruce Richardson 			/** Shaper private packet mode supported. When non-zero,
53499a2dd95SBruce Richardson 			 * this parameter indicates there is at least one
53599a2dd95SBruce Richardson 			 * non-leaf node at this level that can be configured
53699a2dd95SBruce Richardson 			 * with packet mode in its private shaper. When private
53799a2dd95SBruce Richardson 			 * shaper is configured in packet mode, committed/peak
53899a2dd95SBruce Richardson 			 * rate provided is interpreted in packets per second.
53999a2dd95SBruce Richardson 			 */
54099a2dd95SBruce Richardson 			int shaper_private_packet_mode_supported;
54199a2dd95SBruce Richardson 
54299a2dd95SBruce Richardson 			/** Shaper private byte mode supported. When non-zero,
54399a2dd95SBruce Richardson 			 * this parameter indicates there is at least one
54499a2dd95SBruce Richardson 			 * non-leaf node at this level that can be configured
54599a2dd95SBruce Richardson 			 * with byte mode in its private shaper. When private
54699a2dd95SBruce Richardson 			 * shaper is configured in byte mode, committed/peak
54799a2dd95SBruce Richardson 			 * rate provided is interpreted in bytes per second.
54899a2dd95SBruce Richardson 			 */
54999a2dd95SBruce Richardson 			int shaper_private_byte_mode_supported;
55099a2dd95SBruce Richardson 
55199a2dd95SBruce Richardson 			/** Maximum number of shared shapers that any non-leaf
55299a2dd95SBruce Richardson 			 * node on this level can be part of. The value of zero
55399a2dd95SBruce Richardson 			 * indicates that shared shapers are not supported by
55499a2dd95SBruce Richardson 			 * the non-leaf nodes on this level. When non-zero, it
55599a2dd95SBruce Richardson 			 * indicates there is at least one non-leaf node on this
55699a2dd95SBruce Richardson 			 * level that meets this condition, which may not be the
55799a2dd95SBruce Richardson 			 * case for all the non-leaf nodes on this level.
55899a2dd95SBruce Richardson 			 */
55999a2dd95SBruce Richardson 			uint32_t shaper_shared_n_max;
56099a2dd95SBruce Richardson 
56199a2dd95SBruce Richardson 			/** Shaper shared packet mode supported. When non-zero,
56299a2dd95SBruce Richardson 			 * this parameter indicates that there is at least one
56399a2dd95SBruce Richardson 			 * non-leaf node on this level that can be part of
56499a2dd95SBruce Richardson 			 * shared shapers which work in packet mode.
56599a2dd95SBruce Richardson 			 */
56699a2dd95SBruce Richardson 			int shaper_shared_packet_mode_supported;
56799a2dd95SBruce Richardson 
56899a2dd95SBruce Richardson 			/** Shaper shared byte mode supported. When non-zero,
56999a2dd95SBruce Richardson 			 * this parameter indicates that there is at least one
57099a2dd95SBruce Richardson 			 * non-leaf node on this level that can be part of
57199a2dd95SBruce Richardson 			 * shared shapers which work in byte mode.
57299a2dd95SBruce Richardson 			 */
57399a2dd95SBruce Richardson 			int shaper_shared_byte_mode_supported;
57499a2dd95SBruce Richardson 
57599a2dd95SBruce Richardson 			/** Maximum number of children nodes. This parameter
57699a2dd95SBruce Richardson 			 * indicates that there is at least one non-leaf node on
57799a2dd95SBruce Richardson 			 * this level that can be configured with this many
57899a2dd95SBruce Richardson 			 * children nodes, which might not be true for all the
57999a2dd95SBruce Richardson 			 * non-leaf nodes on this level.
58099a2dd95SBruce Richardson 			 */
58199a2dd95SBruce Richardson 			uint32_t sched_n_children_max;
58299a2dd95SBruce Richardson 
58399a2dd95SBruce Richardson 			/** Maximum number of supported priority levels. This
58499a2dd95SBruce Richardson 			 * parameter indicates that there is at least one
58599a2dd95SBruce Richardson 			 * non-leaf node on this level that can be configured
58699a2dd95SBruce Richardson 			 * with this many priority levels for managing its
58799a2dd95SBruce Richardson 			 * children nodes, which might not be true for all the
58899a2dd95SBruce Richardson 			 * non-leaf nodes on this level. The value of zero is
58999a2dd95SBruce Richardson 			 * invalid. The value of 1 indicates that only priority
59099a2dd95SBruce Richardson 			 * 0 is supported, which essentially means that Strict
59199a2dd95SBruce Richardson 			 * Priority (SP) algorithm is not supported on this
59299a2dd95SBruce Richardson 			 * level.
59399a2dd95SBruce Richardson 			 */
59499a2dd95SBruce Richardson 			uint32_t sched_sp_n_priorities_max;
59599a2dd95SBruce Richardson 
59699a2dd95SBruce Richardson 			/** Maximum number of sibling nodes that can have the
59799a2dd95SBruce Richardson 			 * same priority at any given time, i.e. maximum size of
59899a2dd95SBruce Richardson 			 * the WFQ sibling node group. This parameter indicates
59999a2dd95SBruce Richardson 			 * there is at least one non-leaf node on this level
60099a2dd95SBruce Richardson 			 * that meets this condition, which may not be true for
60199a2dd95SBruce Richardson 			 * all the non-leaf nodes on this level. The value of
60299a2dd95SBruce Richardson 			 * zero is invalid. The value of 1 indicates that WFQ
60399a2dd95SBruce Richardson 			 * algorithm is not supported on this level. The maximum
60499a2dd95SBruce Richardson 			 * value is *sched_n_children_max*.
60599a2dd95SBruce Richardson 			 */
60699a2dd95SBruce Richardson 			uint32_t sched_wfq_n_children_per_group_max;
60799a2dd95SBruce Richardson 
60899a2dd95SBruce Richardson 			/** Maximum number of priority levels that can have
60999a2dd95SBruce Richardson 			 * more than one child node at any given time, i.e.
61099a2dd95SBruce Richardson 			 * maximum number of WFQ sibling node groups that
61199a2dd95SBruce Richardson 			 * have two or more members. This parameter indicates
61299a2dd95SBruce Richardson 			 * there is at least one non-leaf node on this level
61399a2dd95SBruce Richardson 			 * that meets this condition, which might not be true
61499a2dd95SBruce Richardson 			 * for all the non-leaf nodes. The value of zero states
61599a2dd95SBruce Richardson 			 * that WFQ algorithm is not supported on this level.
61699a2dd95SBruce Richardson 			 * The value of 1 indicates that
61799a2dd95SBruce Richardson 			 * (*sched_sp_n_priorities_max* - 1) priority levels on
61899a2dd95SBruce Richardson 			 * this level have at most one child node, so there can
61999a2dd95SBruce Richardson 			 * be only one priority level with two or more sibling
62099a2dd95SBruce Richardson 			 * nodes making up a WFQ group on this level. The
62199a2dd95SBruce Richardson 			 * maximum value is:
62299a2dd95SBruce Richardson 			 * min(floor(*sched_n_children_max* / 2),
62399a2dd95SBruce Richardson 			 * *sched_sp_n_priorities_max*).
62499a2dd95SBruce Richardson 			 */
62599a2dd95SBruce Richardson 			uint32_t sched_wfq_n_groups_max;
62699a2dd95SBruce Richardson 
62799a2dd95SBruce Richardson 			/** Maximum WFQ weight. The value of 1 indicates that
62899a2dd95SBruce Richardson 			 * all sibling nodes on this level with same priority
62999a2dd95SBruce Richardson 			 * have the same WFQ weight, so on this level WFQ is
63099a2dd95SBruce Richardson 			 * reduced to FQ.
63199a2dd95SBruce Richardson 			 */
63299a2dd95SBruce Richardson 			uint32_t sched_wfq_weight_max;
63399a2dd95SBruce Richardson 
63499a2dd95SBruce Richardson 			/** WFQ packet mode supported. When non-zero, this
63599a2dd95SBruce Richardson 			 * parameter indicates that there is at least one
63699a2dd95SBruce Richardson 			 * non-leaf node at this level that supports packet
63799a2dd95SBruce Richardson 			 * mode for WFQ among its children. WFQ weights will
63899a2dd95SBruce Richardson 			 * be applied against packet count for scheduling
63999a2dd95SBruce Richardson 			 * children when a non-leaf node is configured
64099a2dd95SBruce Richardson 			 * appropriately.
64199a2dd95SBruce Richardson 			 */
64299a2dd95SBruce Richardson 			int sched_wfq_packet_mode_supported;
64399a2dd95SBruce Richardson 
64499a2dd95SBruce Richardson 			/** WFQ byte mode supported. When non-zero, this
64599a2dd95SBruce Richardson 			 * parameter indicates that there is at least one
64699a2dd95SBruce Richardson 			 * non-leaf node at this level that supports byte
64799a2dd95SBruce Richardson 			 * mode for WFQ among its children. WFQ weights will
64899a2dd95SBruce Richardson 			 * be applied against bytes for scheduling children
64999a2dd95SBruce Richardson 			 * when a non-leaf node is configured appropriately.
65099a2dd95SBruce Richardson 			 */
65199a2dd95SBruce Richardson 			int sched_wfq_byte_mode_supported;
65299a2dd95SBruce Richardson 
65399a2dd95SBruce Richardson 			/** Mask of statistics counter types supported by the
65499a2dd95SBruce Richardson 			 * non-leaf nodes on this level. Every supported
65599a2dd95SBruce Richardson 			 * statistics counter type is supported by at least one
65699a2dd95SBruce Richardson 			 * non-leaf node on this level, which may not be true
65799a2dd95SBruce Richardson 			 * for all the non-leaf nodes on this level.
65899a2dd95SBruce Richardson 			 * @see enum rte_tm_stats_type
65999a2dd95SBruce Richardson 			 */
66099a2dd95SBruce Richardson 			uint64_t stats_mask;
66199a2dd95SBruce Richardson 		} nonleaf;
66299a2dd95SBruce Richardson 
66399a2dd95SBruce Richardson 		/** Items valid only for the leaf nodes on this level. */
66499a2dd95SBruce Richardson 		struct {
66599a2dd95SBruce Richardson 			/** Private shaper support. When non-zero, it indicates
66699a2dd95SBruce Richardson 			 * there is at least one leaf node on this level with
66799a2dd95SBruce Richardson 			 * private shaper support, which may not be the case for
66899a2dd95SBruce Richardson 			 * all the leaf nodes on this level.
66999a2dd95SBruce Richardson 			 */
67099a2dd95SBruce Richardson 			int shaper_private_supported;
67199a2dd95SBruce Richardson 
67299a2dd95SBruce Richardson 			/** Dual rate support for private shaper. Valid only
67399a2dd95SBruce Richardson 			 * when private shaper is supported for the leaf nodes
67499a2dd95SBruce Richardson 			 * on this level. When non-zero, it indicates there is
67599a2dd95SBruce Richardson 			 * at least one leaf node on this level with dual rate
67699a2dd95SBruce Richardson 			 * private shaper support, which may not be the case for
67799a2dd95SBruce Richardson 			 * all the leaf nodes on this level.
67899a2dd95SBruce Richardson 			 */
67999a2dd95SBruce Richardson 			int shaper_private_dual_rate_supported;
68099a2dd95SBruce Richardson 
68199a2dd95SBruce Richardson 			/** Minimum committed/peak rate (bytes per second) for
68299a2dd95SBruce Richardson 			 * private shapers of the leaf nodes of this level.
68399a2dd95SBruce Richardson 			 * Valid only when private shaper is supported for the
68499a2dd95SBruce Richardson 			 * leaf nodes on this level.
68599a2dd95SBruce Richardson 			 */
68699a2dd95SBruce Richardson 			uint64_t shaper_private_rate_min;
68799a2dd95SBruce Richardson 
68899a2dd95SBruce Richardson 			/** Maximum committed/peak rate (bytes per second) for
68999a2dd95SBruce Richardson 			 * private shapers of the leaf nodes on this level.
69099a2dd95SBruce Richardson 			 * Valid only when private shaper is supported for the
69199a2dd95SBruce Richardson 			 * leaf nodes on this level.
69299a2dd95SBruce Richardson 			 */
69399a2dd95SBruce Richardson 			uint64_t shaper_private_rate_max;
69499a2dd95SBruce Richardson 
69599a2dd95SBruce Richardson 			/** Shaper private packet mode supported. When non-zero,
69699a2dd95SBruce Richardson 			 * this parameter indicates there is at least one leaf
69799a2dd95SBruce Richardson 			 * node at this level that can be configured with
69899a2dd95SBruce Richardson 			 * packet mode in its private shaper. When private
69999a2dd95SBruce Richardson 			 * shaper is configured in packet mode, committed/peak
70099a2dd95SBruce Richardson 			 * rate provided is interpreted in packets per second.
70199a2dd95SBruce Richardson 			 */
70299a2dd95SBruce Richardson 			int shaper_private_packet_mode_supported;
70399a2dd95SBruce Richardson 
70499a2dd95SBruce Richardson 			/** Shaper private byte mode supported. When non-zero,
70599a2dd95SBruce Richardson 			 * this parameter indicates there is at least one leaf
70699a2dd95SBruce Richardson 			 * node at this level that can be configured with
70799a2dd95SBruce Richardson 			 * byte mode in its private shaper. When private shaper
70899a2dd95SBruce Richardson 			 * is configured in byte mode, committed/peak rate
70999a2dd95SBruce Richardson 			 * provided is interpreted in bytes per second.
71099a2dd95SBruce Richardson 			 */
71199a2dd95SBruce Richardson 			int shaper_private_byte_mode_supported;
71299a2dd95SBruce Richardson 
71399a2dd95SBruce Richardson 			/** Maximum number of shared shapers that any leaf node
71499a2dd95SBruce Richardson 			 * on this level can be part of. The value of zero
71599a2dd95SBruce Richardson 			 * indicates that shared shapers are not supported by
71699a2dd95SBruce Richardson 			 * the leaf nodes on this level. When non-zero, it
71799a2dd95SBruce Richardson 			 * indicates there is at least one leaf node on this
71899a2dd95SBruce Richardson 			 * level that meets this condition, which may not be the
71999a2dd95SBruce Richardson 			 * case for all the leaf nodes on this level.
72099a2dd95SBruce Richardson 			 */
72199a2dd95SBruce Richardson 			uint32_t shaper_shared_n_max;
72299a2dd95SBruce Richardson 
72399a2dd95SBruce Richardson 			/** Shaper shared packet mode supported. When non-zero,
72499a2dd95SBruce Richardson 			 * this parameter indicates that there is at least one
72599a2dd95SBruce Richardson 			 * leaf node on this level that can be part of
72699a2dd95SBruce Richardson 			 * shared shapers which work in packet mode.
72799a2dd95SBruce Richardson 			 */
72899a2dd95SBruce Richardson 			int shaper_shared_packet_mode_supported;
72999a2dd95SBruce Richardson 
73099a2dd95SBruce Richardson 			/** Shaper shared byte mode supported. When non-zero,
73199a2dd95SBruce Richardson 			 * this parameter indicates that there is at least one
73299a2dd95SBruce Richardson 			 * leaf node on this level that can be part of
73399a2dd95SBruce Richardson 			 * shared shapers which work in byte mode.
73499a2dd95SBruce Richardson 			 */
73599a2dd95SBruce Richardson 			int shaper_shared_byte_mode_supported;
73699a2dd95SBruce Richardson 
73799a2dd95SBruce Richardson 			/** WRED packet mode support. When non-zero, this
73899a2dd95SBruce Richardson 			 * parameter indicates that there is at least one leaf
73999a2dd95SBruce Richardson 			 * node on this level that supports the WRED packet
74099a2dd95SBruce Richardson 			 * mode, which might not be true for all the leaf
74199a2dd95SBruce Richardson 			 * nodes. In packet mode, the WRED thresholds specify
74299a2dd95SBruce Richardson 			 * the queue length in packets, as opposed to bytes.
74399a2dd95SBruce Richardson 			 */
74499a2dd95SBruce Richardson 			int cman_wred_packet_mode_supported;
74599a2dd95SBruce Richardson 
74699a2dd95SBruce Richardson 			/** WRED byte mode support. When non-zero, this
74799a2dd95SBruce Richardson 			 * parameter indicates that there is at least one leaf
74899a2dd95SBruce Richardson 			 * node on this level that supports the WRED byte mode,
74999a2dd95SBruce Richardson 			 * which might not be true for all the leaf nodes. In
75099a2dd95SBruce Richardson 			 * byte mode, the WRED thresholds specify the queue
75199a2dd95SBruce Richardson 			 * length in bytes, as opposed to packets.
75299a2dd95SBruce Richardson 			 */
75399a2dd95SBruce Richardson 			int cman_wred_byte_mode_supported;
75499a2dd95SBruce Richardson 
75599a2dd95SBruce Richardson 			/** Head drop algorithm support. When non-zero, this
75699a2dd95SBruce Richardson 			 * parameter indicates that there is at least one leaf
75799a2dd95SBruce Richardson 			 * node on this level that supports the head drop
75899a2dd95SBruce Richardson 			 * algorithm, which might not be true for all the leaf
75999a2dd95SBruce Richardson 			 * nodes on this level.
76099a2dd95SBruce Richardson 			 */
76199a2dd95SBruce Richardson 			int cman_head_drop_supported;
76299a2dd95SBruce Richardson 
76399a2dd95SBruce Richardson 			/** Private WRED context support. When non-zero, it
76499a2dd95SBruce Richardson 			 * indicates there is at least one node on this level
76599a2dd95SBruce Richardson 			 * with private WRED context support, which may not be
76699a2dd95SBruce Richardson 			 * true for all the leaf nodes on this level.
76799a2dd95SBruce Richardson 			 */
76899a2dd95SBruce Richardson 			int cman_wred_context_private_supported;
76999a2dd95SBruce Richardson 
77099a2dd95SBruce Richardson 			/** Maximum number of shared WRED contexts that any
77199a2dd95SBruce Richardson 			 * leaf node on this level can be part of. The value of
77299a2dd95SBruce Richardson 			 * zero indicates that shared WRED contexts are not
77399a2dd95SBruce Richardson 			 * supported by the leaf nodes on this level. When
77499a2dd95SBruce Richardson 			 * non-zero, it indicates there is at least one leaf
77599a2dd95SBruce Richardson 			 * node on this level that meets this condition, which
77699a2dd95SBruce Richardson 			 * may not be the case for all the leaf nodes on this
77799a2dd95SBruce Richardson 			 * level.
77899a2dd95SBruce Richardson 			 */
77999a2dd95SBruce Richardson 			uint32_t cman_wred_context_shared_n_max;
78099a2dd95SBruce Richardson 
78199a2dd95SBruce Richardson 			/** Mask of statistics counter types supported by the
78299a2dd95SBruce Richardson 			 * leaf nodes on this level. Every supported statistics
78399a2dd95SBruce Richardson 			 * counter type is supported by at least one leaf node
78499a2dd95SBruce Richardson 			 * on this level, which may not be true for all the leaf
78599a2dd95SBruce Richardson 			 * nodes on this level.
78699a2dd95SBruce Richardson 			 * @see enum rte_tm_stats_type
78799a2dd95SBruce Richardson 			 */
78899a2dd95SBruce Richardson 			uint64_t stats_mask;
78999a2dd95SBruce Richardson 		} leaf;
79099a2dd95SBruce Richardson 	};
79199a2dd95SBruce Richardson };
79299a2dd95SBruce Richardson 
79399a2dd95SBruce Richardson /**
79499a2dd95SBruce Richardson  * Traffic manager node capabilities
79599a2dd95SBruce Richardson  */
79699a2dd95SBruce Richardson struct rte_tm_node_capabilities {
79799a2dd95SBruce Richardson 	/** Private shaper support for the current node. */
79899a2dd95SBruce Richardson 	int shaper_private_supported;
79999a2dd95SBruce Richardson 
80099a2dd95SBruce Richardson 	/** Dual rate shaping support for private shaper of current node.
80199a2dd95SBruce Richardson 	 * Valid only when private shaper is supported by the current node.
80299a2dd95SBruce Richardson 	 */
80399a2dd95SBruce Richardson 	int shaper_private_dual_rate_supported;
80499a2dd95SBruce Richardson 
80599a2dd95SBruce Richardson 	/** Minimum committed/peak rate (bytes per second) for private
80699a2dd95SBruce Richardson 	 * shaper of current node. Valid only when private shaper is supported
80799a2dd95SBruce Richardson 	 * by the current node.
80899a2dd95SBruce Richardson 	 */
80999a2dd95SBruce Richardson 	uint64_t shaper_private_rate_min;
81099a2dd95SBruce Richardson 
81199a2dd95SBruce Richardson 	/** Maximum committed/peak rate (bytes per second) for private
81299a2dd95SBruce Richardson 	 * shaper of current node. Valid only when private shaper is supported
81399a2dd95SBruce Richardson 	 * by the current node.
81499a2dd95SBruce Richardson 	 */
81599a2dd95SBruce Richardson 	uint64_t shaper_private_rate_max;
81699a2dd95SBruce Richardson 
81799a2dd95SBruce Richardson 	/** Shaper private packet mode supported. When non-zero, this parameter
81899a2dd95SBruce Richardson 	 * indicates private shaper of current node can be configured with
81999a2dd95SBruce Richardson 	 * packet mode. When configured in packet mode, committed/peak rate
82099a2dd95SBruce Richardson 	 * provided is interpreted in packets per second.
82199a2dd95SBruce Richardson 	 */
82299a2dd95SBruce Richardson 	int shaper_private_packet_mode_supported;
82399a2dd95SBruce Richardson 
82499a2dd95SBruce Richardson 	/** Shaper private byte mode supported. When non-zero, this parameter
82599a2dd95SBruce Richardson 	 * indicates private shaper of current node can be configured with
82699a2dd95SBruce Richardson 	 * byte mode. When configured in byte mode, committed/peak rate
82799a2dd95SBruce Richardson 	 * provided is interpreted in bytes per second.
82899a2dd95SBruce Richardson 	 */
82999a2dd95SBruce Richardson 	int shaper_private_byte_mode_supported;
83099a2dd95SBruce Richardson 
83199a2dd95SBruce Richardson 	/** Maximum number of shared shapers the current node can be part of.
83299a2dd95SBruce Richardson 	 * The value of zero indicates that shared shapers are not supported by
83399a2dd95SBruce Richardson 	 * the current node.
83499a2dd95SBruce Richardson 	 */
83599a2dd95SBruce Richardson 	uint32_t shaper_shared_n_max;
83699a2dd95SBruce Richardson 
83799a2dd95SBruce Richardson 	/** Shaper shared packet mode supported. When non-zero,
83899a2dd95SBruce Richardson 	 * this parameter indicates that current node can be part of
83999a2dd95SBruce Richardson 	 * shared shapers which work in packet mode.
84099a2dd95SBruce Richardson 	 */
84199a2dd95SBruce Richardson 	int shaper_shared_packet_mode_supported;
84299a2dd95SBruce Richardson 
84399a2dd95SBruce Richardson 	/** Shaper shared byte mode supported. When non-zero,
84499a2dd95SBruce Richardson 	 * this parameter indicates that current node can be part of
84599a2dd95SBruce Richardson 	 * shared shapers which work in byte mode.
84699a2dd95SBruce Richardson 	 */
84799a2dd95SBruce Richardson 	int shaper_shared_byte_mode_supported;
84899a2dd95SBruce Richardson 
84999a2dd95SBruce Richardson 	union {
85099a2dd95SBruce Richardson 		/** Items valid only for non-leaf nodes. */
85199a2dd95SBruce Richardson 		struct {
85299a2dd95SBruce Richardson 			/** Maximum number of children nodes. */
85399a2dd95SBruce Richardson 			uint32_t sched_n_children_max;
85499a2dd95SBruce Richardson 
85599a2dd95SBruce Richardson 			/** Maximum number of supported priority levels. The
85699a2dd95SBruce Richardson 			 * value of zero is invalid. The value of 1 indicates
85799a2dd95SBruce Richardson 			 * that only priority 0 is supported, which essentially
85899a2dd95SBruce Richardson 			 * means that Strict Priority (SP) algorithm is not
85999a2dd95SBruce Richardson 			 * supported.
86099a2dd95SBruce Richardson 			 */
86199a2dd95SBruce Richardson 			uint32_t sched_sp_n_priorities_max;
86299a2dd95SBruce Richardson 
86399a2dd95SBruce Richardson 			/** Maximum number of sibling nodes that can have the
86499a2dd95SBruce Richardson 			 * same priority at any given time, i.e. maximum size
86599a2dd95SBruce Richardson 			 * of the WFQ sibling node group. The value of zero
86699a2dd95SBruce Richardson 			 * is invalid. The value of 1 indicates that WFQ
86799a2dd95SBruce Richardson 			 * algorithm is not supported. The maximum value is
86899a2dd95SBruce Richardson 			 * *sched_n_children_max*.
86999a2dd95SBruce Richardson 			 */
87099a2dd95SBruce Richardson 			uint32_t sched_wfq_n_children_per_group_max;
87199a2dd95SBruce Richardson 
87299a2dd95SBruce Richardson 			/** Maximum number of priority levels that can have
87399a2dd95SBruce Richardson 			 * more than one child node at any given time, i.e.
87499a2dd95SBruce Richardson 			 * maximum number of WFQ sibling node groups that have
87599a2dd95SBruce Richardson 			 * two or more members. The value of zero states that
87699a2dd95SBruce Richardson 			 * WFQ algorithm is not supported. The value of 1
87799a2dd95SBruce Richardson 			 * indicates that (*sched_sp_n_priorities_max* - 1)
87899a2dd95SBruce Richardson 			 * priority levels have at most one child node, so there
87999a2dd95SBruce Richardson 			 * can be only one priority level with two or more
88099a2dd95SBruce Richardson 			 * sibling nodes making up a WFQ group. The maximum
88199a2dd95SBruce Richardson 			 * value is: min(floor(*sched_n_children_max* / 2),
88299a2dd95SBruce Richardson 			 * *sched_sp_n_priorities_max*).
88399a2dd95SBruce Richardson 			 */
88499a2dd95SBruce Richardson 			uint32_t sched_wfq_n_groups_max;
88599a2dd95SBruce Richardson 
88699a2dd95SBruce Richardson 			/** Maximum WFQ weight. The value of 1 indicates that
88799a2dd95SBruce Richardson 			 * all sibling nodes with same priority have the same
88899a2dd95SBruce Richardson 			 * WFQ weight, so WFQ is reduced to FQ.
88999a2dd95SBruce Richardson 			 */
89099a2dd95SBruce Richardson 			uint32_t sched_wfq_weight_max;
89199a2dd95SBruce Richardson 
89299a2dd95SBruce Richardson 			/** WFQ packet mode supported. When non-zero, this
89399a2dd95SBruce Richardson 			 * parameter indicates that current node supports packet
89499a2dd95SBruce Richardson 			 * mode for WFQ among its children. WFQ weights will be
89599a2dd95SBruce Richardson 			 * applied against packet count for scheduling children
89699a2dd95SBruce Richardson 			 * when configured appropriately.
89799a2dd95SBruce Richardson 			 */
89899a2dd95SBruce Richardson 			int sched_wfq_packet_mode_supported;
89999a2dd95SBruce Richardson 
90099a2dd95SBruce Richardson 			/** WFQ byte mode supported. When non-zero, this
90199a2dd95SBruce Richardson 			 * parameter indicates that current node supports byte
90299a2dd95SBruce Richardson 			 * mode for WFQ among its children. WFQ weights will be
90399a2dd95SBruce Richardson 			 * applied against  bytes for scheduling children when
90499a2dd95SBruce Richardson 			 * configured appropriately.
90599a2dd95SBruce Richardson 			 */
90699a2dd95SBruce Richardson 			int sched_wfq_byte_mode_supported;
90799a2dd95SBruce Richardson 
90899a2dd95SBruce Richardson 		} nonleaf;
90999a2dd95SBruce Richardson 
91099a2dd95SBruce Richardson 		/** Items valid only for leaf nodes. */
91199a2dd95SBruce Richardson 		struct {
91299a2dd95SBruce Richardson 			/** WRED packet mode support for current node. */
91399a2dd95SBruce Richardson 			int cman_wred_packet_mode_supported;
91499a2dd95SBruce Richardson 
91599a2dd95SBruce Richardson 			/** WRED byte mode support for current node. */
91699a2dd95SBruce Richardson 			int cman_wred_byte_mode_supported;
91799a2dd95SBruce Richardson 
91899a2dd95SBruce Richardson 			/** Head drop algorithm support for current node. */
91999a2dd95SBruce Richardson 			int cman_head_drop_supported;
92099a2dd95SBruce Richardson 
92199a2dd95SBruce Richardson 			/** Private WRED context support for current node. */
92299a2dd95SBruce Richardson 			int cman_wred_context_private_supported;
92399a2dd95SBruce Richardson 
92499a2dd95SBruce Richardson 			/** Maximum number of shared WRED contexts the current
92599a2dd95SBruce Richardson 			 * node can be part of. The value of zero indicates that
92699a2dd95SBruce Richardson 			 * shared WRED contexts are not supported by the current
92799a2dd95SBruce Richardson 			 * node.
92899a2dd95SBruce Richardson 			 */
92999a2dd95SBruce Richardson 			uint32_t cman_wred_context_shared_n_max;
93099a2dd95SBruce Richardson 		} leaf;
93199a2dd95SBruce Richardson 	};
93299a2dd95SBruce Richardson 
93399a2dd95SBruce Richardson 	/** Mask of statistics counter types supported by the current node.
93499a2dd95SBruce Richardson 	 * @see enum rte_tm_stats_type
93599a2dd95SBruce Richardson 	 */
93699a2dd95SBruce Richardson 	uint64_t stats_mask;
93799a2dd95SBruce Richardson };
93899a2dd95SBruce Richardson 
93999a2dd95SBruce Richardson /**
94099a2dd95SBruce Richardson  * Congestion management (CMAN) mode
94199a2dd95SBruce Richardson  *
94299a2dd95SBruce Richardson  * This is used for controlling the admission of packets into a packet queue or
94399a2dd95SBruce Richardson  * group of packet queues on congestion. On request of writing a new packet
94499a2dd95SBruce Richardson  * into the current queue while the queue is full, the *tail drop* algorithm
94599a2dd95SBruce Richardson  * drops the new packet while leaving the queue unmodified, as opposed to *head
94699a2dd95SBruce Richardson  * drop* algorithm, which drops the packet at the head of the queue (the oldest
94799a2dd95SBruce Richardson  * packet waiting in the queue) and admits the new packet at the tail of the
94899a2dd95SBruce Richardson  * queue.
94999a2dd95SBruce Richardson  *
95099a2dd95SBruce Richardson  * The *Random Early Detection (RED)* algorithm works by proactively dropping
95199a2dd95SBruce Richardson  * more and more input packets as the queue occupancy builds up. When the queue
95299a2dd95SBruce Richardson  * is full or almost full, RED effectively works as *tail drop*. The *Weighted
95399a2dd95SBruce Richardson  * RED* algorithm uses a separate set of RED thresholds for each packet color.
95499a2dd95SBruce Richardson  */
95599a2dd95SBruce Richardson enum rte_tm_cman_mode {
95699a2dd95SBruce Richardson 	RTE_TM_CMAN_TAIL_DROP = 0, /**< Tail drop */
95799a2dd95SBruce Richardson 	RTE_TM_CMAN_HEAD_DROP, /**< Head drop */
95899a2dd95SBruce Richardson 	RTE_TM_CMAN_WRED, /**< Weighted Random Early Detection (WRED) */
95999a2dd95SBruce Richardson };
96099a2dd95SBruce Richardson 
96199a2dd95SBruce Richardson /**
96299a2dd95SBruce Richardson  * Random Early Detection (RED) profile
96399a2dd95SBruce Richardson  */
96499a2dd95SBruce Richardson struct rte_tm_red_params {
96599a2dd95SBruce Richardson 	/** Minimum queue threshold */
96699a2dd95SBruce Richardson 	uint64_t min_th;
96799a2dd95SBruce Richardson 
96899a2dd95SBruce Richardson 	/** Maximum queue threshold */
96999a2dd95SBruce Richardson 	uint64_t max_th;
97099a2dd95SBruce Richardson 
97199a2dd95SBruce Richardson 	/** Inverse of packet marking probability maximum value (maxp), i.e.
97299a2dd95SBruce Richardson 	 * maxp_inv = 1 / maxp
97399a2dd95SBruce Richardson 	 */
97499a2dd95SBruce Richardson 	uint16_t maxp_inv;
97599a2dd95SBruce Richardson 
97699a2dd95SBruce Richardson 	/** Negated log2 of queue weight (wq), i.e. wq = 1 / (2 ^ wq_log2) */
97799a2dd95SBruce Richardson 	uint16_t wq_log2;
97899a2dd95SBruce Richardson };
97999a2dd95SBruce Richardson 
98099a2dd95SBruce Richardson /**
98199a2dd95SBruce Richardson  * Weighted RED (WRED) profile
98299a2dd95SBruce Richardson  *
98399a2dd95SBruce Richardson  * Multiple WRED contexts can share the same WRED profile. Each leaf node with
98499a2dd95SBruce Richardson  * WRED enabled as its congestion management mode has zero or one private WRED
98599a2dd95SBruce Richardson  * context (only one leaf node using it) and/or zero, one or several shared
98699a2dd95SBruce Richardson  * WRED contexts (multiple leaf nodes use the same WRED context). A private
98799a2dd95SBruce Richardson  * WRED context is used to perform congestion management for a single leaf
98899a2dd95SBruce Richardson  * node, while a shared WRED context is used to perform congestion management
98999a2dd95SBruce Richardson  * for a group of leaf nodes.
99099a2dd95SBruce Richardson  *
99199a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::cman_wred_packet_mode_supported
99299a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::cman_wred_byte_mode_supported
99399a2dd95SBruce Richardson  */
99499a2dd95SBruce Richardson struct rte_tm_wred_params {
99599a2dd95SBruce Richardson 	/** One set of RED parameters per packet color */
99699a2dd95SBruce Richardson 	struct rte_tm_red_params red_params[RTE_COLORS];
99799a2dd95SBruce Richardson 
99899a2dd95SBruce Richardson 	/** When non-zero, the *min_th* and *max_th* thresholds are specified
99999a2dd95SBruce Richardson 	 * in packets (WRED packet mode). When zero, the *min_th* and *max_th*
100099a2dd95SBruce Richardson 	 * thresholds are specified in bytes (WRED byte mode)
100199a2dd95SBruce Richardson 	 */
100299a2dd95SBruce Richardson 	int packet_mode;
100399a2dd95SBruce Richardson };
100499a2dd95SBruce Richardson 
100599a2dd95SBruce Richardson /**
100699a2dd95SBruce Richardson  * Token bucket
100799a2dd95SBruce Richardson  */
100899a2dd95SBruce Richardson struct rte_tm_token_bucket {
100999a2dd95SBruce Richardson 	/** Token bucket rate (bytes per second or packets per second) */
101099a2dd95SBruce Richardson 	uint64_t rate;
101199a2dd95SBruce Richardson 
101299a2dd95SBruce Richardson 	/** Token bucket size (bytes or packets), a.k.a. max burst size */
101399a2dd95SBruce Richardson 	uint64_t size;
101499a2dd95SBruce Richardson };
101599a2dd95SBruce Richardson 
101699a2dd95SBruce Richardson /**
101799a2dd95SBruce Richardson  * Shaper (rate limiter) profile
101899a2dd95SBruce Richardson  *
101999a2dd95SBruce Richardson  * Multiple shaper instances can share the same shaper profile. Each node has
102099a2dd95SBruce Richardson  * zero or one private shaper (only one node using it) and/or zero, one or
102199a2dd95SBruce Richardson  * several shared shapers (multiple nodes use the same shaper instance).
102299a2dd95SBruce Richardson  * A private shaper is used to perform traffic shaping for a single node, while
102399a2dd95SBruce Richardson  * a shared shaper is used to perform traffic shaping for a group of nodes.
102499a2dd95SBruce Richardson  *
102599a2dd95SBruce Richardson  * Single rate shapers use a single token bucket. A single rate shaper can be
102699a2dd95SBruce Richardson  * configured by setting the rate of the committed bucket to zero, which
102799a2dd95SBruce Richardson  * effectively disables this bucket. The peak bucket is used to limit the rate
102899a2dd95SBruce Richardson  * and the burst size for the current shaper.
102999a2dd95SBruce Richardson  *
103099a2dd95SBruce Richardson  * Dual rate shapers use both the committed and the peak token buckets. The
103199a2dd95SBruce Richardson  * rate of the peak bucket has to be bigger than zero, as well as greater than
103299a2dd95SBruce Richardson  * or equal to the rate of the committed bucket.
103399a2dd95SBruce Richardson  *
103499a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::shaper_private_packet_mode_supported
103599a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::shaper_private_byte_mode_supported
103699a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::shaper_shared_packet_mode_supported
103799a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::shaper_shared_byte_mode_supported
103899a2dd95SBruce Richardson  */
103999a2dd95SBruce Richardson struct rte_tm_shaper_params {
104099a2dd95SBruce Richardson 	/** Committed token bucket */
104199a2dd95SBruce Richardson 	struct rte_tm_token_bucket committed;
104299a2dd95SBruce Richardson 
104399a2dd95SBruce Richardson 	/** Peak token bucket */
104499a2dd95SBruce Richardson 	struct rte_tm_token_bucket peak;
104599a2dd95SBruce Richardson 
104699a2dd95SBruce Richardson 	/** Signed value to be added to the length of each packet for the
104799a2dd95SBruce Richardson 	 * purpose of shaping. Can be used to correct the packet length with
104899a2dd95SBruce Richardson 	 * the framing overhead bytes that are also consumed on the wire (e.g.
104999a2dd95SBruce Richardson 	 * RTE_TM_ETH_FRAMING_OVERHEAD_FCS).
105099a2dd95SBruce Richardson 	 * This field is ignored when the profile enables packet mode.
105199a2dd95SBruce Richardson 	 */
105299a2dd95SBruce Richardson 	int32_t pkt_length_adjust;
105399a2dd95SBruce Richardson 
105499a2dd95SBruce Richardson 	/** When zero, the byte mode is enabled for the current profile, so the
105599a2dd95SBruce Richardson 	 * *rate* and *size* fields in both the committed and peak token buckets
105699a2dd95SBruce Richardson 	 * are specified in bytes per second and bytes, respectively.
105799a2dd95SBruce Richardson 	 * When non-zero, the packet mode is enabled for the current profile,
105899a2dd95SBruce Richardson 	 * so the *rate* and *size* fields in both the committed and peak token
105999a2dd95SBruce Richardson 	 * buckets are specified in packets per second and packets,
106099a2dd95SBruce Richardson 	 * respectively.
106199a2dd95SBruce Richardson 	 */
106299a2dd95SBruce Richardson 	int packet_mode;
106399a2dd95SBruce Richardson };
106499a2dd95SBruce Richardson 
106599a2dd95SBruce Richardson /**
106699a2dd95SBruce Richardson  * Node parameters
106799a2dd95SBruce Richardson  *
106899a2dd95SBruce Richardson  * Each non-leaf node has multiple inputs (its children nodes) and single output
106999a2dd95SBruce Richardson  * (which is input to its parent node). It arbitrates its inputs using Strict
107099a2dd95SBruce Richardson  * Priority (SP) and Weighted Fair Queuing (WFQ) algorithms to schedule input
107199a2dd95SBruce Richardson  * packets to its output while observing its shaping (rate limiting)
107299a2dd95SBruce Richardson  * constraints.
107399a2dd95SBruce Richardson  *
107499a2dd95SBruce Richardson  * Algorithms such as Weighted Round Robin (WRR), Byte-level WRR, Deficit WRR
107599a2dd95SBruce Richardson  * (DWRR), etc. are considered approximations of the WFQ ideal and are
107699a2dd95SBruce Richardson  * assimilated to WFQ, although an associated implementation-dependent trade-off
107799a2dd95SBruce Richardson  * on accuracy, performance and resource usage might exist.
107899a2dd95SBruce Richardson  *
107999a2dd95SBruce Richardson  * Children nodes with different priorities are scheduled using the SP algorithm
108099a2dd95SBruce Richardson  * based on their priority, with zero (0) as the highest priority. Children with
108199a2dd95SBruce Richardson  * the same priority are scheduled using the WFQ algorithm according to their
108299a2dd95SBruce Richardson  * weights. The WFQ weight of a given child node is relative to the sum of the
108399a2dd95SBruce Richardson  * weights of all its sibling nodes that have the same priority, with one (1) as
108499a2dd95SBruce Richardson  * the lowest weight. For each SP priority, the WFQ weight mode can be set as
108599a2dd95SBruce Richardson  * either byte-based or packet-based.
108699a2dd95SBruce Richardson  *
108709fd4227SAndrew Rybchenko  * Each leaf node sits on top of a Tx queue of the current Ethernet port. Hence,
108899a2dd95SBruce Richardson  * the leaf nodes are predefined, with their node IDs set to 0 .. (N-1), where N
108909fd4227SAndrew Rybchenko  * is the number of Tx queues configured for the current Ethernet port. The
109099a2dd95SBruce Richardson  * non-leaf nodes have their IDs generated by the application.
109199a2dd95SBruce Richardson  */
109299a2dd95SBruce Richardson struct rte_tm_node_params {
109399a2dd95SBruce Richardson 	/** Shaper profile for the private shaper. The absence of the private
109499a2dd95SBruce Richardson 	 * shaper for the current node is indicated by setting this parameter
109599a2dd95SBruce Richardson 	 * to RTE_TM_SHAPER_PROFILE_ID_NONE.
109699a2dd95SBruce Richardson 	 */
109799a2dd95SBruce Richardson 	uint32_t shaper_profile_id;
109899a2dd95SBruce Richardson 
109999a2dd95SBruce Richardson 	/** User allocated array of valid shared shaper IDs. */
110099a2dd95SBruce Richardson 	uint32_t *shared_shaper_id;
110199a2dd95SBruce Richardson 
110299a2dd95SBruce Richardson 	/** Number of shared shaper IDs in the *shared_shaper_id* array. */
110399a2dd95SBruce Richardson 	uint32_t n_shared_shapers;
110499a2dd95SBruce Richardson 
110599a2dd95SBruce Richardson 	union {
110699a2dd95SBruce Richardson 		/** Parameters only valid for non-leaf nodes. */
110799a2dd95SBruce Richardson 		struct {
110899a2dd95SBruce Richardson 			/** WFQ weight mode for each SP priority. When NULL, it
110999a2dd95SBruce Richardson 			 * indicates that WFQ is to be used for all priorities.
111099a2dd95SBruce Richardson 			 * When non-NULL, it points to a pre-allocated array of
111199a2dd95SBruce Richardson 			 * *n_sp_priorities* values, with non-zero value for
111299a2dd95SBruce Richardson 			 * byte-mode and zero for packet-mode.
111399a2dd95SBruce Richardson 			 * @see struct rte_tm_node_capabilities::sched_wfq_packet_mode_supported
111499a2dd95SBruce Richardson 			 * @see struct rte_tm_node_capabilities::sched_wfq_byte_mode_supported
111599a2dd95SBruce Richardson 			 */
111699a2dd95SBruce Richardson 			int *wfq_weight_mode;
111799a2dd95SBruce Richardson 
111899a2dd95SBruce Richardson 			/** Number of SP priorities. */
111999a2dd95SBruce Richardson 			uint32_t n_sp_priorities;
112099a2dd95SBruce Richardson 		} nonleaf;
112199a2dd95SBruce Richardson 
112299a2dd95SBruce Richardson 		/** Parameters only valid for leaf nodes. */
112399a2dd95SBruce Richardson 		struct {
112499a2dd95SBruce Richardson 			/** Congestion management mode */
112599a2dd95SBruce Richardson 			enum rte_tm_cman_mode cman;
112699a2dd95SBruce Richardson 
112799a2dd95SBruce Richardson 			/** WRED parameters (only valid when *cman* is set to
112899a2dd95SBruce Richardson 			 * WRED).
112999a2dd95SBruce Richardson 			 */
113099a2dd95SBruce Richardson 			struct {
113199a2dd95SBruce Richardson 				/** WRED profile for private WRED context. The
113299a2dd95SBruce Richardson 				 * absence of a private WRED context for the
113399a2dd95SBruce Richardson 				 * current leaf node is indicated by value
113499a2dd95SBruce Richardson 				 * RTE_TM_WRED_PROFILE_ID_NONE.
113599a2dd95SBruce Richardson 				 */
113699a2dd95SBruce Richardson 				uint32_t wred_profile_id;
113799a2dd95SBruce Richardson 
113899a2dd95SBruce Richardson 				/** User allocated array of shared WRED context
113999a2dd95SBruce Richardson 				 * IDs. When set to NULL, it indicates that the
114099a2dd95SBruce Richardson 				 * current leaf node should not currently be
114199a2dd95SBruce Richardson 				 * part of any shared WRED contexts.
114299a2dd95SBruce Richardson 				 */
114399a2dd95SBruce Richardson 				uint32_t *shared_wred_context_id;
114499a2dd95SBruce Richardson 
114599a2dd95SBruce Richardson 				/** Number of elements in the
114699a2dd95SBruce Richardson 				 * *shared_wred_context_id* array. Only valid
114799a2dd95SBruce Richardson 				 * when *shared_wred_context_id* is non-NULL,
114899a2dd95SBruce Richardson 				 * in which case it should be non-zero.
114999a2dd95SBruce Richardson 				 */
115099a2dd95SBruce Richardson 				uint32_t n_shared_wred_contexts;
115199a2dd95SBruce Richardson 			} wred;
115299a2dd95SBruce Richardson 		} leaf;
115399a2dd95SBruce Richardson 	};
115499a2dd95SBruce Richardson 
115599a2dd95SBruce Richardson 	/** Mask of statistics counter types to be enabled for this node. This
115699a2dd95SBruce Richardson 	 * needs to be a subset of the statistics counter types available for
115799a2dd95SBruce Richardson 	 * the current node. Any statistics counter type not included in this
115899a2dd95SBruce Richardson 	 * set is to be disabled for the current node.
115999a2dd95SBruce Richardson 	 * @see enum rte_tm_stats_type
116099a2dd95SBruce Richardson 	 */
116199a2dd95SBruce Richardson 	uint64_t stats_mask;
116299a2dd95SBruce Richardson };
116399a2dd95SBruce Richardson 
116499a2dd95SBruce Richardson /**
116599a2dd95SBruce Richardson  * Verbose error types.
116699a2dd95SBruce Richardson  *
116799a2dd95SBruce Richardson  * Most of them provide the type of the object referenced by struct
116899a2dd95SBruce Richardson  * rte_tm_error::cause.
116999a2dd95SBruce Richardson  */
117099a2dd95SBruce Richardson enum rte_tm_error_type {
117199a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NONE, /**< No error. */
117299a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
117399a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_CAPABILITIES,
117499a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_LEVEL_ID,
117599a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_WRED_PROFILE,
117699a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN,
117799a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW,
117899a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_WRED_PROFILE_RED,
117999a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_WRED_PROFILE_ID,
118099a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID,
118199a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
118299a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE,
118399a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE,
118499a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
118599a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
118699a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN,
118799a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PACKET_MODE,
118899a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
118999a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID,
119099a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID,
119199a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PRIORITY,
119299a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_WEIGHT,
119399a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS,
119499a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID,
119599a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID,
119699a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS,
119799a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE,
119899a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES,
119999a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN,
120099a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID,
120199a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID,
120299a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS,
120399a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
120499a2dd95SBruce Richardson 	RTE_TM_ERROR_TYPE_NODE_ID,
120599a2dd95SBruce Richardson };
120699a2dd95SBruce Richardson 
120799a2dd95SBruce Richardson /**
120899a2dd95SBruce Richardson  * Verbose error structure definition.
120999a2dd95SBruce Richardson  *
121099a2dd95SBruce Richardson  * This object is normally allocated by applications and set by PMDs, the
121199a2dd95SBruce Richardson  * message points to a constant string which does not need to be freed by
121299a2dd95SBruce Richardson  * the application, however its pointer can be considered valid only as long
121399a2dd95SBruce Richardson  * as its associated DPDK port remains configured. Closing the underlying
121499a2dd95SBruce Richardson  * device or unloading the PMD invalidates it.
121599a2dd95SBruce Richardson  *
121699a2dd95SBruce Richardson  * Both cause and message may be NULL regardless of the error type.
121799a2dd95SBruce Richardson  */
121899a2dd95SBruce Richardson struct rte_tm_error {
121999a2dd95SBruce Richardson 	enum rte_tm_error_type type; /**< Cause field and error type. */
122099a2dd95SBruce Richardson 	const void *cause; /**< Object responsible for the error. */
122199a2dd95SBruce Richardson 	const char *message; /**< Human-readable error message. */
122299a2dd95SBruce Richardson };
122399a2dd95SBruce Richardson 
122499a2dd95SBruce Richardson /**
122599a2dd95SBruce Richardson  * Traffic manager get number of leaf nodes
122699a2dd95SBruce Richardson  *
122709fd4227SAndrew Rybchenko  * Each leaf node sits on top of a Tx queue of the current Ethernet port.
122899a2dd95SBruce Richardson  * Therefore, the set of leaf nodes is predefined, their number is always equal
122909fd4227SAndrew Rybchenko  * to N (where N is the number of Tx queues configured for the current port)
123099a2dd95SBruce Richardson  * and their IDs are 0 .. (N-1).
123199a2dd95SBruce Richardson  *
123299a2dd95SBruce Richardson  * @param[in] port_id
123399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
123499a2dd95SBruce Richardson  * @param[out] n_leaf_nodes
123599a2dd95SBruce Richardson  *   Number of leaf nodes for the current port.
123699a2dd95SBruce Richardson  * @param[out] error
123799a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
123899a2dd95SBruce Richardson  * @return
123999a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
124099a2dd95SBruce Richardson  */
124199a2dd95SBruce Richardson int
124299a2dd95SBruce Richardson rte_tm_get_number_of_leaf_nodes(uint16_t port_id,
124399a2dd95SBruce Richardson 	uint32_t *n_leaf_nodes,
124499a2dd95SBruce Richardson 	struct rte_tm_error *error);
124599a2dd95SBruce Richardson 
124699a2dd95SBruce Richardson /**
124799a2dd95SBruce Richardson  * Traffic manager node ID validate and type (i.e. leaf or non-leaf) get
124899a2dd95SBruce Richardson  *
124999a2dd95SBruce Richardson  * The leaf nodes have predefined IDs in the range of 0 .. (N-1), where N is
125009fd4227SAndrew Rybchenko  * the number of Tx queues of the current Ethernet port. The non-leaf nodes
125199a2dd95SBruce Richardson  * have their IDs generated by the application outside of the above range,
125299a2dd95SBruce Richardson  * which is reserved for leaf nodes.
125399a2dd95SBruce Richardson  *
125499a2dd95SBruce Richardson  * @param[in] port_id
125599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
125699a2dd95SBruce Richardson  * @param[in] node_id
125799a2dd95SBruce Richardson  *   Node ID value. Needs to be valid.
125899a2dd95SBruce Richardson  * @param[out] is_leaf
125999a2dd95SBruce Richardson  *   Set to non-zero value when node is leaf and to zero otherwise (non-leaf).
126099a2dd95SBruce Richardson  * @param[out] error
126199a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
126299a2dd95SBruce Richardson  * @return
126399a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
126499a2dd95SBruce Richardson  */
126599a2dd95SBruce Richardson int
126699a2dd95SBruce Richardson rte_tm_node_type_get(uint16_t port_id,
126799a2dd95SBruce Richardson 	uint32_t node_id,
126899a2dd95SBruce Richardson 	int *is_leaf,
126999a2dd95SBruce Richardson 	struct rte_tm_error *error);
127099a2dd95SBruce Richardson 
127199a2dd95SBruce Richardson /**
127299a2dd95SBruce Richardson  * Traffic manager capabilities get
127399a2dd95SBruce Richardson  *
127499a2dd95SBruce Richardson  * @param[in] port_id
127599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
127699a2dd95SBruce Richardson  * @param[out] cap
127799a2dd95SBruce Richardson  *   Traffic manager capabilities. Needs to be pre-allocated and valid.
127899a2dd95SBruce Richardson  * @param[out] error
127999a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
128099a2dd95SBruce Richardson  * @return
128199a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
128299a2dd95SBruce Richardson  */
128399a2dd95SBruce Richardson int
128499a2dd95SBruce Richardson rte_tm_capabilities_get(uint16_t port_id,
128599a2dd95SBruce Richardson 	struct rte_tm_capabilities *cap,
128699a2dd95SBruce Richardson 	struct rte_tm_error *error);
128799a2dd95SBruce Richardson 
128899a2dd95SBruce Richardson /**
128999a2dd95SBruce Richardson  * Traffic manager level capabilities get
129099a2dd95SBruce Richardson  *
129199a2dd95SBruce Richardson  * @param[in] port_id
129299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
129399a2dd95SBruce Richardson  * @param[in] level_id
129499a2dd95SBruce Richardson  *   The hierarchy level identifier. The value of 0 identifies the level of the
129599a2dd95SBruce Richardson  *   root node.
129699a2dd95SBruce Richardson  * @param[out] cap
129799a2dd95SBruce Richardson  *   Traffic manager level capabilities. Needs to be pre-allocated and valid.
129899a2dd95SBruce Richardson  * @param[out] error
129999a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
130099a2dd95SBruce Richardson  * @return
130199a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
130299a2dd95SBruce Richardson  */
130399a2dd95SBruce Richardson int
130499a2dd95SBruce Richardson rte_tm_level_capabilities_get(uint16_t port_id,
130599a2dd95SBruce Richardson 	uint32_t level_id,
130699a2dd95SBruce Richardson 	struct rte_tm_level_capabilities *cap,
130799a2dd95SBruce Richardson 	struct rte_tm_error *error);
130899a2dd95SBruce Richardson 
130999a2dd95SBruce Richardson /**
131099a2dd95SBruce Richardson  * Traffic manager node capabilities get
131199a2dd95SBruce Richardson  *
131299a2dd95SBruce Richardson  * @param[in] port_id
131399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
131499a2dd95SBruce Richardson  * @param[in] node_id
131599a2dd95SBruce Richardson  *   Node ID. Needs to be valid.
131699a2dd95SBruce Richardson  * @param[out] cap
131799a2dd95SBruce Richardson  *   Traffic manager node capabilities. Needs to be pre-allocated and valid.
131899a2dd95SBruce Richardson  * @param[out] error
131999a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
132099a2dd95SBruce Richardson  * @return
132199a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
132299a2dd95SBruce Richardson  */
132399a2dd95SBruce Richardson int
132499a2dd95SBruce Richardson rte_tm_node_capabilities_get(uint16_t port_id,
132599a2dd95SBruce Richardson 	uint32_t node_id,
132699a2dd95SBruce Richardson 	struct rte_tm_node_capabilities *cap,
132799a2dd95SBruce Richardson 	struct rte_tm_error *error);
132899a2dd95SBruce Richardson 
132999a2dd95SBruce Richardson /**
133099a2dd95SBruce Richardson  * Traffic manager WRED profile add
133199a2dd95SBruce Richardson  *
133299a2dd95SBruce Richardson  * Create a new WRED profile with ID set to *wred_profile_id*. The new profile
133399a2dd95SBruce Richardson  * is used to create one or several WRED contexts.
133499a2dd95SBruce Richardson  *
133599a2dd95SBruce Richardson  * @param[in] port_id
133699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
133799a2dd95SBruce Richardson  * @param[in] wred_profile_id
133899a2dd95SBruce Richardson  *   WRED profile ID for the new profile. Needs to be unused.
133999a2dd95SBruce Richardson  * @param[in] profile
134099a2dd95SBruce Richardson  *   WRED profile parameters. Needs to be pre-allocated and valid.
134199a2dd95SBruce Richardson  * @param[out] error
134299a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
134399a2dd95SBruce Richardson  * @return
134499a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
134599a2dd95SBruce Richardson  *
134699a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::cman_wred_context_n_max
134799a2dd95SBruce Richardson  */
134899a2dd95SBruce Richardson int
134999a2dd95SBruce Richardson rte_tm_wred_profile_add(uint16_t port_id,
135099a2dd95SBruce Richardson 	uint32_t wred_profile_id,
13515d963566SBruce Richardson 	const struct rte_tm_wred_params *profile,
135299a2dd95SBruce Richardson 	struct rte_tm_error *error);
135399a2dd95SBruce Richardson 
135499a2dd95SBruce Richardson /**
135599a2dd95SBruce Richardson  * Traffic manager WRED profile delete
135699a2dd95SBruce Richardson  *
135799a2dd95SBruce Richardson  * Delete an existing WRED profile. This operation fails when there is
135899a2dd95SBruce Richardson  * currently at least one user (i.e. WRED context) of this WRED profile.
135999a2dd95SBruce Richardson  *
136099a2dd95SBruce Richardson  * @param[in] port_id
136199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
136299a2dd95SBruce Richardson  * @param[in] wred_profile_id
136399a2dd95SBruce Richardson  *   WRED profile ID. Needs to be the valid.
136499a2dd95SBruce Richardson  * @param[out] error
136599a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
136699a2dd95SBruce Richardson  * @return
136799a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
136899a2dd95SBruce Richardson  *
136999a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::cman_wred_context_n_max
137099a2dd95SBruce Richardson  */
137199a2dd95SBruce Richardson int
137299a2dd95SBruce Richardson rte_tm_wred_profile_delete(uint16_t port_id,
137399a2dd95SBruce Richardson 	uint32_t wred_profile_id,
137499a2dd95SBruce Richardson 	struct rte_tm_error *error);
137599a2dd95SBruce Richardson 
137699a2dd95SBruce Richardson /**
137799a2dd95SBruce Richardson  * Traffic manager shared WRED context add or update
137899a2dd95SBruce Richardson  *
137999a2dd95SBruce Richardson  * When *shared_wred_context_id* is invalid, a new WRED context with this ID is
138099a2dd95SBruce Richardson  * created by using the WRED profile identified by *wred_profile_id*.
138199a2dd95SBruce Richardson  *
138299a2dd95SBruce Richardson  * When *shared_wred_context_id* is valid, this WRED context is no longer using
138399a2dd95SBruce Richardson  * the profile previously assigned to it and is updated to use the profile
138499a2dd95SBruce Richardson  * identified by *wred_profile_id*.
138599a2dd95SBruce Richardson  *
138699a2dd95SBruce Richardson  * A valid shared WRED context can be assigned to several hierarchy leaf nodes
138799a2dd95SBruce Richardson  * configured to use WRED as the congestion management mode.
138899a2dd95SBruce Richardson  *
138999a2dd95SBruce Richardson  * @param[in] port_id
139099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
139199a2dd95SBruce Richardson  * @param[in] shared_wred_context_id
139299a2dd95SBruce Richardson  *   Shared WRED context ID
139399a2dd95SBruce Richardson  * @param[in] wred_profile_id
139499a2dd95SBruce Richardson  *   WRED profile ID. Needs to be the valid.
139599a2dd95SBruce Richardson  * @param[out] error
139699a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
139799a2dd95SBruce Richardson  * @return
139899a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
139999a2dd95SBruce Richardson  *
140099a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
140199a2dd95SBruce Richardson  */
140299a2dd95SBruce Richardson int
140399a2dd95SBruce Richardson rte_tm_shared_wred_context_add_update(uint16_t port_id,
140499a2dd95SBruce Richardson 	uint32_t shared_wred_context_id,
140599a2dd95SBruce Richardson 	uint32_t wred_profile_id,
140699a2dd95SBruce Richardson 	struct rte_tm_error *error);
140799a2dd95SBruce Richardson 
140899a2dd95SBruce Richardson /**
140999a2dd95SBruce Richardson  * Traffic manager shared WRED context delete
141099a2dd95SBruce Richardson  *
141199a2dd95SBruce Richardson  * Delete an existing shared WRED context. This operation fails when there is
141299a2dd95SBruce Richardson  * currently at least one user (i.e. hierarchy leaf node) of this shared WRED
141399a2dd95SBruce Richardson  * context.
141499a2dd95SBruce Richardson  *
141599a2dd95SBruce Richardson  * @param[in] port_id
141699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
141799a2dd95SBruce Richardson  * @param[in] shared_wred_context_id
141899a2dd95SBruce Richardson  *   Shared WRED context ID. Needs to be the valid.
141999a2dd95SBruce Richardson  * @param[out] error
142099a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
142199a2dd95SBruce Richardson  * @return
142299a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
142399a2dd95SBruce Richardson  *
142499a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
142599a2dd95SBruce Richardson  */
142699a2dd95SBruce Richardson int
142799a2dd95SBruce Richardson rte_tm_shared_wred_context_delete(uint16_t port_id,
142899a2dd95SBruce Richardson 	uint32_t shared_wred_context_id,
142999a2dd95SBruce Richardson 	struct rte_tm_error *error);
143099a2dd95SBruce Richardson 
143199a2dd95SBruce Richardson /**
143299a2dd95SBruce Richardson  * Traffic manager shaper profile add
143399a2dd95SBruce Richardson  *
143499a2dd95SBruce Richardson  * Create a new shaper profile with ID set to *shaper_profile_id*. The new
143599a2dd95SBruce Richardson  * shaper profile is used to create one or several shapers.
143699a2dd95SBruce Richardson  *
143799a2dd95SBruce Richardson  * @param[in] port_id
143899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
143999a2dd95SBruce Richardson  * @param[in] shaper_profile_id
144099a2dd95SBruce Richardson  *   Shaper profile ID for the new profile. Needs to be unused.
144199a2dd95SBruce Richardson  * @param[in] profile
144299a2dd95SBruce Richardson  *   Shaper profile parameters. Needs to be pre-allocated and valid.
144399a2dd95SBruce Richardson  * @param[out] error
144499a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
144599a2dd95SBruce Richardson  * @return
144699a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
144799a2dd95SBruce Richardson  *
144899a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::shaper_n_max
144999a2dd95SBruce Richardson  */
145099a2dd95SBruce Richardson int
145199a2dd95SBruce Richardson rte_tm_shaper_profile_add(uint16_t port_id,
145299a2dd95SBruce Richardson 	uint32_t shaper_profile_id,
145339533238SBruce Richardson 	const struct rte_tm_shaper_params *profile,
145499a2dd95SBruce Richardson 	struct rte_tm_error *error);
145599a2dd95SBruce Richardson 
145699a2dd95SBruce Richardson /**
145799a2dd95SBruce Richardson  * Traffic manager shaper profile delete
145899a2dd95SBruce Richardson  *
145999a2dd95SBruce Richardson  * Delete an existing shaper profile. This operation fails when there is
146099a2dd95SBruce Richardson  * currently at least one user (i.e. shaper) of this shaper profile.
146199a2dd95SBruce Richardson  *
146299a2dd95SBruce Richardson  * @param[in] port_id
146399a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
146499a2dd95SBruce Richardson  * @param[in] shaper_profile_id
146599a2dd95SBruce Richardson  *   Shaper profile ID. Needs to be the valid.
146699a2dd95SBruce Richardson  * @param[out] error
146799a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
146899a2dd95SBruce Richardson  * @return
146999a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
147099a2dd95SBruce Richardson  *
147199a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::shaper_n_max
147299a2dd95SBruce Richardson  */
147399a2dd95SBruce Richardson int
147499a2dd95SBruce Richardson rte_tm_shaper_profile_delete(uint16_t port_id,
147599a2dd95SBruce Richardson 	uint32_t shaper_profile_id,
147699a2dd95SBruce Richardson 	struct rte_tm_error *error);
147799a2dd95SBruce Richardson 
147899a2dd95SBruce Richardson /**
147999a2dd95SBruce Richardson  * Traffic manager shared shaper add or update
148099a2dd95SBruce Richardson  *
148199a2dd95SBruce Richardson  * When *shared_shaper_id* is not a valid shared shaper ID, a new shared shaper
148299a2dd95SBruce Richardson  * with this ID is created using the shaper profile identified by
148399a2dd95SBruce Richardson  * *shaper_profile_id*.
148499a2dd95SBruce Richardson  *
148599a2dd95SBruce Richardson  * When *shared_shaper_id* is a valid shared shaper ID, this shared shaper is
148699a2dd95SBruce Richardson  * no longer using the shaper profile previously assigned to it and is updated
148799a2dd95SBruce Richardson  * to use the shaper profile identified by *shaper_profile_id*.
148899a2dd95SBruce Richardson  *
148999a2dd95SBruce Richardson  * @param[in] port_id
149099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
149199a2dd95SBruce Richardson  * @param[in] shared_shaper_id
149299a2dd95SBruce Richardson  *   Shared shaper ID
149399a2dd95SBruce Richardson  * @param[in] shaper_profile_id
149499a2dd95SBruce Richardson  *   Shaper profile ID. Needs to be the valid.
149599a2dd95SBruce Richardson  * @param[out] error
149699a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
149799a2dd95SBruce Richardson  * @return
149899a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
149999a2dd95SBruce Richardson  *
150099a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::shaper_shared_n_max
150199a2dd95SBruce Richardson  */
150299a2dd95SBruce Richardson int
150399a2dd95SBruce Richardson rte_tm_shared_shaper_add_update(uint16_t port_id,
150499a2dd95SBruce Richardson 	uint32_t shared_shaper_id,
150599a2dd95SBruce Richardson 	uint32_t shaper_profile_id,
150699a2dd95SBruce Richardson 	struct rte_tm_error *error);
150799a2dd95SBruce Richardson 
150899a2dd95SBruce Richardson /**
150999a2dd95SBruce Richardson  * Traffic manager shared shaper delete
151099a2dd95SBruce Richardson  *
151199a2dd95SBruce Richardson  * Delete an existing shared shaper. This operation fails when there is
151299a2dd95SBruce Richardson  * currently at least one user (i.e. hierarchy node) of this shared shaper.
151399a2dd95SBruce Richardson  *
151499a2dd95SBruce Richardson  * @param[in] port_id
151599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
151699a2dd95SBruce Richardson  * @param[in] shared_shaper_id
151799a2dd95SBruce Richardson  *   Shared shaper ID. Needs to be the valid.
151899a2dd95SBruce Richardson  * @param[out] error
151999a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
152099a2dd95SBruce Richardson  * @return
152199a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
152299a2dd95SBruce Richardson  *
152399a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::shaper_shared_n_max
152499a2dd95SBruce Richardson  */
152599a2dd95SBruce Richardson int
152699a2dd95SBruce Richardson rte_tm_shared_shaper_delete(uint16_t port_id,
152799a2dd95SBruce Richardson 	uint32_t shared_shaper_id,
152899a2dd95SBruce Richardson 	struct rte_tm_error *error);
152999a2dd95SBruce Richardson 
153099a2dd95SBruce Richardson /**
153199a2dd95SBruce Richardson  * Traffic manager node add
153299a2dd95SBruce Richardson  *
153399a2dd95SBruce Richardson  * Create new node and connect it as child of an existing node. The new node is
153499a2dd95SBruce Richardson  * further identified by *node_id*, which needs to be unused by any of the
153599a2dd95SBruce Richardson  * existing nodes. The parent node is identified by *parent_node_id*, which
153699a2dd95SBruce Richardson  * needs to be the valid ID of an existing non-leaf node. The parent node is
153799a2dd95SBruce Richardson  * going to use the provided SP *priority* and WFQ *weight* to schedule its new
153899a2dd95SBruce Richardson  * child node.
153999a2dd95SBruce Richardson  *
154099a2dd95SBruce Richardson  * This function has to be called for both leaf and non-leaf nodes. In the case
154199a2dd95SBruce Richardson  * of leaf nodes (i.e. *node_id* is within the range of 0 .. (N-1), with N as
154209fd4227SAndrew Rybchenko  * the number of configured Tx queues of the current port), the leaf node is
154399a2dd95SBruce Richardson  * configured rather than created (as the set of leaf nodes is predefined) and
154499a2dd95SBruce Richardson  * it is also connected as child of an existing node.
154599a2dd95SBruce Richardson  *
154699a2dd95SBruce Richardson  * The first node that is added becomes the root node and all the nodes that
154799a2dd95SBruce Richardson  * are subsequently added have to be added as descendants of the root node. The
154899a2dd95SBruce Richardson  * parent of the root node has to be specified as RTE_TM_NODE_ID_NULL and there
154999a2dd95SBruce Richardson  * can only be one node with this parent ID (i.e. the root node). Further
155099a2dd95SBruce Richardson  * restrictions for root node: needs to be non-leaf, its private shaper profile
155199a2dd95SBruce Richardson  * needs to be valid and single rate, cannot use any shared shapers.
155299a2dd95SBruce Richardson  *
155399a2dd95SBruce Richardson  * When called before rte_tm_hierarchy_commit() invocation, this function is
155499a2dd95SBruce Richardson  * typically used to define the initial start-up hierarchy for the port.
155599a2dd95SBruce Richardson  * Provided that dynamic hierarchy updates are supported by the current port (as
155699a2dd95SBruce Richardson  * advertised in the port capability set), this function can be also called
155799a2dd95SBruce Richardson  * after the rte_tm_hierarchy_commit() invocation.
155899a2dd95SBruce Richardson  *
155999a2dd95SBruce Richardson  * @param[in] port_id
156099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
156199a2dd95SBruce Richardson  * @param[in] node_id
156299a2dd95SBruce Richardson  *   Node ID. Needs to be unused by any of the existing nodes.
156399a2dd95SBruce Richardson  * @param[in] parent_node_id
156499a2dd95SBruce Richardson  *   Parent node ID. Needs to be the valid.
156599a2dd95SBruce Richardson  * @param[in] priority
156699a2dd95SBruce Richardson  *   Node priority. The highest node priority is zero. Used by the SP algorithm
156799a2dd95SBruce Richardson  *   running on the parent of the current node for scheduling this child node.
156899a2dd95SBruce Richardson  * @param[in] weight
156999a2dd95SBruce Richardson  *   Node weight. The node weight is relative to the weight sum of all siblings
157099a2dd95SBruce Richardson  *   that have the same priority. The lowest weight is one. Used by the WFQ
157199a2dd95SBruce Richardson  *   algorithm running on the parent of the current node for scheduling this
157299a2dd95SBruce Richardson  *   child node.
157399a2dd95SBruce Richardson  * @param[in] level_id
157499a2dd95SBruce Richardson  *   Level ID that should be met by this node. The hierarchy level of the
157599a2dd95SBruce Richardson  *   current node is already fully specified through its parent node (i.e. the
157699a2dd95SBruce Richardson  *   level of this node is equal to the level of its parent node plus one),
157799a2dd95SBruce Richardson  *   therefore the reason for providing this parameter is to enable the
157899a2dd95SBruce Richardson  *   application to perform step-by-step checking of the node level during
157999a2dd95SBruce Richardson  *   successive invocations of this function. When not desired, this check can
158099a2dd95SBruce Richardson  *   be disabled by assigning value RTE_TM_NODE_LEVEL_ID_ANY to this parameter.
158199a2dd95SBruce Richardson  * @param[in] params
158299a2dd95SBruce Richardson  *   Node parameters. Needs to be pre-allocated and valid.
158399a2dd95SBruce Richardson  * @param[out] error
158499a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
158599a2dd95SBruce Richardson  * @return
158699a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
158799a2dd95SBruce Richardson  *
158899a2dd95SBruce Richardson  * @see rte_tm_hierarchy_commit()
158999a2dd95SBruce Richardson  * @see RTE_TM_UPDATE_NODE_ADD_DELETE
159099a2dd95SBruce Richardson  * @see RTE_TM_NODE_LEVEL_ID_ANY
159199a2dd95SBruce Richardson  * @see struct rte_tm_capabilities
159299a2dd95SBruce Richardson  */
159399a2dd95SBruce Richardson int
159499a2dd95SBruce Richardson rte_tm_node_add(uint16_t port_id,
159599a2dd95SBruce Richardson 	uint32_t node_id,
159699a2dd95SBruce Richardson 	uint32_t parent_node_id,
159799a2dd95SBruce Richardson 	uint32_t priority,
159899a2dd95SBruce Richardson 	uint32_t weight,
159999a2dd95SBruce Richardson 	uint32_t level_id,
16005d49af62SBruce Richardson 	const struct rte_tm_node_params *params,
160199a2dd95SBruce Richardson 	struct rte_tm_error *error);
160299a2dd95SBruce Richardson 
160399a2dd95SBruce Richardson /**
1604*25a2a0dcSBruce Richardson  * Return information about a traffic management node
1605*25a2a0dcSBruce Richardson  *
1606*25a2a0dcSBruce Richardson  * Return information about a hierarchy node, using the same format of parameters
1607*25a2a0dcSBruce Richardson  * as was passed to the rte_rm_node_add() function.
1608*25a2a0dcSBruce Richardson  * Each of the "out" parameters pointers (except error) may be passed as NULL if the
1609*25a2a0dcSBruce Richardson  * information is not needed by the caller. For example, to one may check if a node id
1610*25a2a0dcSBruce Richardson  * is in use by:
1611*25a2a0dcSBruce Richardson  *
1612*25a2a0dcSBruce Richardson  *  struct rte_tm_error error;
1613*25a2a0dcSBruce Richardson  *  int ret = rte_tm_node_query(port, node_id, NULL, NULL, NULL, NULL, NULL, &error);
1614*25a2a0dcSBruce Richardson  *  if (ret == ENOENT) ...
1615*25a2a0dcSBruce Richardson  *
1616*25a2a0dcSBruce Richardson  * @param[in] port_id
1617*25a2a0dcSBruce Richardson  *   The port identifier of the Ethernet device.
1618*25a2a0dcSBruce Richardson  * @param[in] node_id
1619*25a2a0dcSBruce Richardson  *   Node ID. Should be a valid node id.
1620*25a2a0dcSBruce Richardson  * @param[out] parent_node_id
1621*25a2a0dcSBruce Richardson  *   Parent node ID.
1622*25a2a0dcSBruce Richardson  * @param[out] priority
1623*25a2a0dcSBruce Richardson  *   Node priority. The highest node priority is zero. Used by the SP algorithm
1624*25a2a0dcSBruce Richardson  *   running on the parent of the current node for scheduling this child node.
1625*25a2a0dcSBruce Richardson  * @param[out] weight
1626*25a2a0dcSBruce Richardson  *   Node weight. The node weight is relative to the weight sum of all siblings
1627*25a2a0dcSBruce Richardson  *   that have the same priority. The lowest weight is one. Used by the WFQ
1628*25a2a0dcSBruce Richardson  *   algorithm running on the parent of the current node for scheduling this
1629*25a2a0dcSBruce Richardson  *   child node.
1630*25a2a0dcSBruce Richardson  * @param[out] level_id
1631*25a2a0dcSBruce Richardson  *   The node level in the scheduler hierarchy.
1632*25a2a0dcSBruce Richardson  * @param[out] params
1633*25a2a0dcSBruce Richardson  *   Node parameters, as would be used when creating the node.
1634*25a2a0dcSBruce Richardson  * @param[out] error
1635*25a2a0dcSBruce Richardson  *   Error details. Filled in only on error. Must not be NULL.
1636*25a2a0dcSBruce Richardson  * @return
1637*25a2a0dcSBruce Richardson  *   0 on success, non-zero error code otherwise.
1638*25a2a0dcSBruce Richardson  *   -EINVAL - port or node id value is invalid
1639*25a2a0dcSBruce Richardson  *   -ENOENT - no node exists with the provided id on the provided port
1640*25a2a0dcSBruce Richardson  */
1641*25a2a0dcSBruce Richardson __rte_experimental
1642*25a2a0dcSBruce Richardson int
1643*25a2a0dcSBruce Richardson rte_tm_node_query(uint16_t port_id,
1644*25a2a0dcSBruce Richardson 	uint32_t node_id,
1645*25a2a0dcSBruce Richardson 	uint32_t *parent_node_id,
1646*25a2a0dcSBruce Richardson 	uint32_t *priority,
1647*25a2a0dcSBruce Richardson 	uint32_t *weight,
1648*25a2a0dcSBruce Richardson 	uint32_t *level_id,
1649*25a2a0dcSBruce Richardson 	struct rte_tm_node_params *params,
1650*25a2a0dcSBruce Richardson 	struct rte_tm_error *error);
1651*25a2a0dcSBruce Richardson 
1652*25a2a0dcSBruce Richardson /**
165399a2dd95SBruce Richardson  * Traffic manager node delete
165499a2dd95SBruce Richardson  *
165599a2dd95SBruce Richardson  * Delete an existing node. This operation fails when this node currently has
165699a2dd95SBruce Richardson  * at least one user (i.e. child node).
165799a2dd95SBruce Richardson  *
165899a2dd95SBruce Richardson  * When called before rte_tm_hierarchy_commit() invocation, this function is
165999a2dd95SBruce Richardson  * typically used to define the initial start-up hierarchy for the port.
166099a2dd95SBruce Richardson  * Provided that dynamic hierarchy updates are supported by the current port (as
166199a2dd95SBruce Richardson  * advertised in the port capability set), this function can be also called
166299a2dd95SBruce Richardson  * after the rte_tm_hierarchy_commit() invocation.
166399a2dd95SBruce Richardson  *
166499a2dd95SBruce Richardson  * @param[in] port_id
166599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
166699a2dd95SBruce Richardson  * @param[in] node_id
166799a2dd95SBruce Richardson  *   Node ID. Needs to be valid.
166899a2dd95SBruce Richardson  * @param[out] error
166999a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
167099a2dd95SBruce Richardson  * @return
167199a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
167299a2dd95SBruce Richardson  *
167399a2dd95SBruce Richardson  * @see RTE_TM_UPDATE_NODE_ADD_DELETE
167499a2dd95SBruce Richardson  */
167599a2dd95SBruce Richardson int
167699a2dd95SBruce Richardson rte_tm_node_delete(uint16_t port_id,
167799a2dd95SBruce Richardson 	uint32_t node_id,
167899a2dd95SBruce Richardson 	struct rte_tm_error *error);
167999a2dd95SBruce Richardson 
168099a2dd95SBruce Richardson /**
168199a2dd95SBruce Richardson  * Traffic manager node suspend
168299a2dd95SBruce Richardson  *
168399a2dd95SBruce Richardson  * Suspend an existing node. While the node is in suspended state, no packet is
168499a2dd95SBruce Richardson  * scheduled from this node and its descendants. The node exits the suspended
168599a2dd95SBruce Richardson  * state through the node resume operation.
168699a2dd95SBruce Richardson  *
168799a2dd95SBruce Richardson  * @param[in] port_id
168899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
168999a2dd95SBruce Richardson  * @param[in] node_id
169099a2dd95SBruce Richardson  *   Node ID. Needs to be valid.
169199a2dd95SBruce Richardson  * @param[out] error
169299a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
169399a2dd95SBruce Richardson  * @return
169499a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
169599a2dd95SBruce Richardson  *
169699a2dd95SBruce Richardson  * @see rte_tm_node_resume()
169799a2dd95SBruce Richardson  * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
169899a2dd95SBruce Richardson  */
169999a2dd95SBruce Richardson int
170099a2dd95SBruce Richardson rte_tm_node_suspend(uint16_t port_id,
170199a2dd95SBruce Richardson 	uint32_t node_id,
170299a2dd95SBruce Richardson 	struct rte_tm_error *error);
170399a2dd95SBruce Richardson 
170499a2dd95SBruce Richardson /**
170599a2dd95SBruce Richardson  * Traffic manager node resume
170699a2dd95SBruce Richardson  *
170799a2dd95SBruce Richardson  * Resume an existing node that is currently in suspended state. The node
170899a2dd95SBruce Richardson  * entered the suspended state as result of a previous node suspend operation.
170999a2dd95SBruce Richardson  *
171099a2dd95SBruce Richardson  * @param[in] port_id
171199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
171299a2dd95SBruce Richardson  * @param[in] node_id
171399a2dd95SBruce Richardson  *   Node ID. Needs to be valid.
171499a2dd95SBruce Richardson  * @param[out] error
171599a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
171699a2dd95SBruce Richardson  * @return
171799a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
171899a2dd95SBruce Richardson  *
171999a2dd95SBruce Richardson  * @see rte_tm_node_suspend()
172099a2dd95SBruce Richardson  * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
172199a2dd95SBruce Richardson  */
172299a2dd95SBruce Richardson int
172399a2dd95SBruce Richardson rte_tm_node_resume(uint16_t port_id,
172499a2dd95SBruce Richardson 	uint32_t node_id,
172599a2dd95SBruce Richardson 	struct rte_tm_error *error);
172699a2dd95SBruce Richardson 
172799a2dd95SBruce Richardson /**
172899a2dd95SBruce Richardson  * Traffic manager hierarchy commit
172999a2dd95SBruce Richardson  *
173099a2dd95SBruce Richardson  * This function is called during the port initialization phase (before the
173199a2dd95SBruce Richardson  * Ethernet port is started) to freeze the start-up hierarchy.
173299a2dd95SBruce Richardson  *
173399a2dd95SBruce Richardson  * This function typically performs the following steps:
173499a2dd95SBruce Richardson  *    a) It validates the start-up hierarchy that was previously defined for the
173599a2dd95SBruce Richardson  *       current port through successive rte_tm_node_add() invocations;
173699a2dd95SBruce Richardson  *    b) Assuming successful validation, it performs all the necessary port
173799a2dd95SBruce Richardson  *       specific configuration operations to install the specified hierarchy on
173899a2dd95SBruce Richardson  *       the current port, with immediate effect once the port is started.
173999a2dd95SBruce Richardson  *
174099a2dd95SBruce Richardson  * This function fails when the currently configured hierarchy is not supported
174199a2dd95SBruce Richardson  * by the Ethernet port, in which case the user can abort or try out another
174299a2dd95SBruce Richardson  * hierarchy configuration (e.g. a hierarchy with less leaf nodes), which can be
174399a2dd95SBruce Richardson  * build from scratch (when *clear_on_fail* is enabled) or by modifying the
174499a2dd95SBruce Richardson  * existing hierarchy configuration (when *clear_on_fail* is disabled).
174599a2dd95SBruce Richardson  *
174699a2dd95SBruce Richardson  * Note that this function can still fail due to other causes (e.g. not enough
174799a2dd95SBruce Richardson  * memory available in the system, etc), even though the specified hierarchy is
174899a2dd95SBruce Richardson  * supported in principle by the current port.
174999a2dd95SBruce Richardson  *
175099a2dd95SBruce Richardson  * @param[in] port_id
175199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
175299a2dd95SBruce Richardson  * @param[in] clear_on_fail
175399a2dd95SBruce Richardson  *   On function call failure, hierarchy is cleared when this parameter is
175499a2dd95SBruce Richardson  *   non-zero and preserved when this parameter is equal to zero.
175599a2dd95SBruce Richardson  * @param[out] error
175699a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
175799a2dd95SBruce Richardson  * @return
175899a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
175999a2dd95SBruce Richardson  *
176099a2dd95SBruce Richardson  * @see rte_tm_node_add()
176199a2dd95SBruce Richardson  * @see rte_tm_node_delete()
176299a2dd95SBruce Richardson  */
176399a2dd95SBruce Richardson int
176499a2dd95SBruce Richardson rte_tm_hierarchy_commit(uint16_t port_id,
176599a2dd95SBruce Richardson 	int clear_on_fail,
176699a2dd95SBruce Richardson 	struct rte_tm_error *error);
176799a2dd95SBruce Richardson 
176899a2dd95SBruce Richardson /**
176999a2dd95SBruce Richardson  * Traffic manager node parent update
177099a2dd95SBruce Richardson  *
177199a2dd95SBruce Richardson  * This function may be used to move a node and its children to a different
177299a2dd95SBruce Richardson  * parent.  Additionally, if the new parent is the same as the current parent,
177399a2dd95SBruce Richardson  * this function will update the priority/weight of an existing node.
177499a2dd95SBruce Richardson  *
177599a2dd95SBruce Richardson  * Restriction for root node: its parent cannot be changed.
177699a2dd95SBruce Richardson  *
177799a2dd95SBruce Richardson  * This function can only be called after the rte_tm_hierarchy_commit()
177899a2dd95SBruce Richardson  * invocation. Its success depends on the port support for this operation, as
177999a2dd95SBruce Richardson  * advertised through the port capability set.
178099a2dd95SBruce Richardson  *
178199a2dd95SBruce Richardson  * @param[in] port_id
178299a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
178399a2dd95SBruce Richardson  * @param[in] node_id
178499a2dd95SBruce Richardson  *   Node ID. Needs to be valid.
178599a2dd95SBruce Richardson  * @param[in] parent_node_id
178699a2dd95SBruce Richardson  *   Node ID for the new parent. Needs to be valid.
178799a2dd95SBruce Richardson  * @param[in] priority
178899a2dd95SBruce Richardson  *   Node priority. The highest node priority is zero. Used by the SP algorithm
178999a2dd95SBruce Richardson  *   running on the parent of the current node for scheduling this child node.
179099a2dd95SBruce Richardson  * @param[in] weight
179199a2dd95SBruce Richardson  *   Node weight. The node weight is relative to the weight sum of all siblings
179299a2dd95SBruce Richardson  *   that have the same priority. The lowest weight is zero. Used by the WFQ
179399a2dd95SBruce Richardson  *   algorithm running on the parent of the current node for scheduling this
179499a2dd95SBruce Richardson  *   child node.
179599a2dd95SBruce Richardson  * @param[out] error
179699a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
179799a2dd95SBruce Richardson  * @return
179899a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
179999a2dd95SBruce Richardson  *
180099a2dd95SBruce Richardson  * @see RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL
180199a2dd95SBruce Richardson  * @see RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL
180299a2dd95SBruce Richardson  */
180399a2dd95SBruce Richardson int
180499a2dd95SBruce Richardson rte_tm_node_parent_update(uint16_t port_id,
180599a2dd95SBruce Richardson 	uint32_t node_id,
180699a2dd95SBruce Richardson 	uint32_t parent_node_id,
180799a2dd95SBruce Richardson 	uint32_t priority,
180899a2dd95SBruce Richardson 	uint32_t weight,
180999a2dd95SBruce Richardson 	struct rte_tm_error *error);
181099a2dd95SBruce Richardson 
181199a2dd95SBruce Richardson /**
181299a2dd95SBruce Richardson  * Traffic manager node private shaper update
181399a2dd95SBruce Richardson  *
181499a2dd95SBruce Richardson  * Restriction for the root node: its private shaper profile needs to be valid
181599a2dd95SBruce Richardson  * and single rate.
181699a2dd95SBruce Richardson  *
181799a2dd95SBruce Richardson  * @param[in] port_id
181899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
181999a2dd95SBruce Richardson  * @param[in] node_id
182099a2dd95SBruce Richardson  *   Node ID. Needs to be valid.
182199a2dd95SBruce Richardson  * @param[in] shaper_profile_id
182299a2dd95SBruce Richardson  *   Shaper profile ID for the private shaper of the current node. Needs to be
182399a2dd95SBruce Richardson  *   either valid shaper profile ID or RTE_TM_SHAPER_PROFILE_ID_NONE, with
182499a2dd95SBruce Richardson  *   the latter disabling the private shaper of the current node.
182599a2dd95SBruce Richardson  * @param[out] error
182699a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
182799a2dd95SBruce Richardson  * @return
182899a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
182999a2dd95SBruce Richardson  *
183099a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::shaper_private_n_max
183199a2dd95SBruce Richardson  */
183299a2dd95SBruce Richardson int
183399a2dd95SBruce Richardson rte_tm_node_shaper_update(uint16_t port_id,
183499a2dd95SBruce Richardson 	uint32_t node_id,
183599a2dd95SBruce Richardson 	uint32_t shaper_profile_id,
183699a2dd95SBruce Richardson 	struct rte_tm_error *error);
183799a2dd95SBruce Richardson 
183899a2dd95SBruce Richardson /**
183999a2dd95SBruce Richardson  * Traffic manager node shared shapers update
184099a2dd95SBruce Richardson  *
184199a2dd95SBruce Richardson  * Restriction for root node: cannot use any shared rate shapers.
184299a2dd95SBruce Richardson  *
184399a2dd95SBruce Richardson  * @param[in] port_id
184499a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
184599a2dd95SBruce Richardson  * @param[in] node_id
184699a2dd95SBruce Richardson  *   Node ID. Needs to be valid.
184799a2dd95SBruce Richardson  * @param[in] shared_shaper_id
184899a2dd95SBruce Richardson  *   Shared shaper ID. Needs to be valid.
184999a2dd95SBruce Richardson  * @param[in] add
185099a2dd95SBruce Richardson  *   Set to non-zero value to add this shared shaper to current node or to zero
185199a2dd95SBruce Richardson  *   to delete this shared shaper from current node.
185299a2dd95SBruce Richardson  * @param[out] error
185399a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
185499a2dd95SBruce Richardson  * @return
185599a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
185699a2dd95SBruce Richardson  *
185799a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::shaper_shared_n_max
185899a2dd95SBruce Richardson  */
185999a2dd95SBruce Richardson int
186099a2dd95SBruce Richardson rte_tm_node_shared_shaper_update(uint16_t port_id,
186199a2dd95SBruce Richardson 	uint32_t node_id,
186299a2dd95SBruce Richardson 	uint32_t shared_shaper_id,
186399a2dd95SBruce Richardson 	int add,
186499a2dd95SBruce Richardson 	struct rte_tm_error *error);
186599a2dd95SBruce Richardson 
186699a2dd95SBruce Richardson /**
186799a2dd95SBruce Richardson  * Traffic manager node enabled statistics counters update
186899a2dd95SBruce Richardson  *
186999a2dd95SBruce Richardson  * @param[in] port_id
187099a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
187199a2dd95SBruce Richardson  * @param[in] node_id
187299a2dd95SBruce Richardson  *   Node ID. Needs to be valid.
187399a2dd95SBruce Richardson  * @param[in] stats_mask
187499a2dd95SBruce Richardson  *   Mask of statistics counter types to be enabled for the current node. This
187599a2dd95SBruce Richardson  *   needs to be a subset of the statistics counter types available for the
187699a2dd95SBruce Richardson  *   current node. Any statistics counter type not included in this set is to
187799a2dd95SBruce Richardson  *   be disabled for the current node.
187899a2dd95SBruce Richardson  * @param[out] error
187999a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
188099a2dd95SBruce Richardson  * @return
188199a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
188299a2dd95SBruce Richardson  *
188399a2dd95SBruce Richardson  * @see enum rte_tm_stats_type
188499a2dd95SBruce Richardson  * @see RTE_TM_UPDATE_NODE_STATS
188599a2dd95SBruce Richardson  */
188699a2dd95SBruce Richardson int
188799a2dd95SBruce Richardson rte_tm_node_stats_update(uint16_t port_id,
188899a2dd95SBruce Richardson 	uint32_t node_id,
188999a2dd95SBruce Richardson 	uint64_t stats_mask,
189099a2dd95SBruce Richardson 	struct rte_tm_error *error);
189199a2dd95SBruce Richardson 
189299a2dd95SBruce Richardson /**
189399a2dd95SBruce Richardson  * Traffic manager node WFQ weight mode update
189499a2dd95SBruce Richardson  *
189599a2dd95SBruce Richardson  * @param[in] port_id
189699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
189799a2dd95SBruce Richardson  * @param[in] node_id
189899a2dd95SBruce Richardson  *   Node ID. Needs to be valid non-leaf node ID.
189999a2dd95SBruce Richardson  * @param[in] wfq_weight_mode
190099a2dd95SBruce Richardson  *   WFQ weight mode for each SP priority. When NULL, it indicates that WFQ is
190199a2dd95SBruce Richardson  *   to be used for all priorities. When non-NULL, it points to a pre-allocated
190299a2dd95SBruce Richardson  *   array of *n_sp_priorities* values, with non-zero value for byte-mode and
190399a2dd95SBruce Richardson  *   zero for packet-mode.
190499a2dd95SBruce Richardson  * @param[in] n_sp_priorities
190599a2dd95SBruce Richardson  *   Number of SP priorities.
190699a2dd95SBruce Richardson  * @param[out] error
190799a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
190899a2dd95SBruce Richardson  * @return
190999a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
191099a2dd95SBruce Richardson  *
191199a2dd95SBruce Richardson  * @see RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE
191299a2dd95SBruce Richardson  * @see RTE_TM_UPDATE_NODE_N_SP_PRIORITIES
191399a2dd95SBruce Richardson  */
191499a2dd95SBruce Richardson int
191599a2dd95SBruce Richardson rte_tm_node_wfq_weight_mode_update(uint16_t port_id,
191699a2dd95SBruce Richardson 	uint32_t node_id,
191799a2dd95SBruce Richardson 	int *wfq_weight_mode,
191899a2dd95SBruce Richardson 	uint32_t n_sp_priorities,
191999a2dd95SBruce Richardson 	struct rte_tm_error *error);
192099a2dd95SBruce Richardson 
192199a2dd95SBruce Richardson /**
192299a2dd95SBruce Richardson  * Traffic manager node congestion management mode update
192399a2dd95SBruce Richardson  *
192499a2dd95SBruce Richardson  * @param[in] port_id
192599a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
192699a2dd95SBruce Richardson  * @param[in] node_id
192799a2dd95SBruce Richardson  *   Node ID. Needs to be valid leaf node ID.
192899a2dd95SBruce Richardson  * @param[in] cman
192999a2dd95SBruce Richardson  *   Congestion management mode.
193099a2dd95SBruce Richardson  * @param[out] error
193199a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
193299a2dd95SBruce Richardson  * @return
193399a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
193499a2dd95SBruce Richardson  *
193599a2dd95SBruce Richardson  * @see RTE_TM_UPDATE_NODE_CMAN
193699a2dd95SBruce Richardson  */
193799a2dd95SBruce Richardson int
193899a2dd95SBruce Richardson rte_tm_node_cman_update(uint16_t port_id,
193999a2dd95SBruce Richardson 	uint32_t node_id,
194099a2dd95SBruce Richardson 	enum rte_tm_cman_mode cman,
194199a2dd95SBruce Richardson 	struct rte_tm_error *error);
194299a2dd95SBruce Richardson 
194399a2dd95SBruce Richardson /**
194499a2dd95SBruce Richardson  * Traffic manager node private WRED context update
194599a2dd95SBruce Richardson  *
194699a2dd95SBruce Richardson  * @param[in] port_id
194799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
194899a2dd95SBruce Richardson  * @param[in] node_id
194999a2dd95SBruce Richardson  *   Node ID. Needs to be valid leaf node ID.
195099a2dd95SBruce Richardson  * @param[in] wred_profile_id
195199a2dd95SBruce Richardson  *   WRED profile ID for the private WRED context of the current node. Needs to
195299a2dd95SBruce Richardson  *   be either valid WRED profile ID or RTE_TM_WRED_PROFILE_ID_NONE, with the
195399a2dd95SBruce Richardson  *   latter disabling the private WRED context of the current node.
195499a2dd95SBruce Richardson  * @param[out] error
195599a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
195699a2dd95SBruce Richardson  * @return
195799a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
195899a2dd95SBruce Richardson  *
195999a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::cman_wred_context_private_n_max
196099a2dd95SBruce Richardson  */
196199a2dd95SBruce Richardson int
196299a2dd95SBruce Richardson rte_tm_node_wred_context_update(uint16_t port_id,
196399a2dd95SBruce Richardson 	uint32_t node_id,
196499a2dd95SBruce Richardson 	uint32_t wred_profile_id,
196599a2dd95SBruce Richardson 	struct rte_tm_error *error);
196699a2dd95SBruce Richardson 
196799a2dd95SBruce Richardson /**
196899a2dd95SBruce Richardson  * Traffic manager node shared WRED context update
196999a2dd95SBruce Richardson  *
197099a2dd95SBruce Richardson  * @param[in] port_id
197199a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
197299a2dd95SBruce Richardson  * @param[in] node_id
197399a2dd95SBruce Richardson  *   Node ID. Needs to be valid leaf node ID.
197499a2dd95SBruce Richardson  * @param[in] shared_wred_context_id
197599a2dd95SBruce Richardson  *   Shared WRED context ID. Needs to be valid.
197699a2dd95SBruce Richardson  * @param[in] add
197799a2dd95SBruce Richardson  *   Set to non-zero value to add this shared WRED context to current node or
197899a2dd95SBruce Richardson  *   to zero to delete this shared WRED context from current node.
197999a2dd95SBruce Richardson  * @param[out] error
198099a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
198199a2dd95SBruce Richardson  * @return
198299a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
198399a2dd95SBruce Richardson  *
198499a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
198599a2dd95SBruce Richardson  */
198699a2dd95SBruce Richardson int
198799a2dd95SBruce Richardson rte_tm_node_shared_wred_context_update(uint16_t port_id,
198899a2dd95SBruce Richardson 	uint32_t node_id,
198999a2dd95SBruce Richardson 	uint32_t shared_wred_context_id,
199099a2dd95SBruce Richardson 	int add,
199199a2dd95SBruce Richardson 	struct rte_tm_error *error);
199299a2dd95SBruce Richardson 
199399a2dd95SBruce Richardson /**
199499a2dd95SBruce Richardson  * Traffic manager node statistics counters read
199599a2dd95SBruce Richardson  *
199699a2dd95SBruce Richardson  * @param[in] port_id
199799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
199899a2dd95SBruce Richardson  * @param[in] node_id
199999a2dd95SBruce Richardson  *   Node ID. Needs to be valid.
200099a2dd95SBruce Richardson  * @param[out] stats
200199a2dd95SBruce Richardson  *   When non-NULL, it contains the current value for the statistics counters
200299a2dd95SBruce Richardson  *   enabled for the current node.
200399a2dd95SBruce Richardson  * @param[out] stats_mask
200499a2dd95SBruce Richardson  *   When non-NULL, it contains the mask of statistics counter types that are
200599a2dd95SBruce Richardson  *   currently enabled for this node, indicating which of the counters
200699a2dd95SBruce Richardson  *   retrieved with the *stats* structure are valid.
200799a2dd95SBruce Richardson  * @param[in] clear
200899a2dd95SBruce Richardson  *   When this parameter has a non-zero value, the statistics counters are
200999a2dd95SBruce Richardson  *   cleared (i.e. set to zero) immediately after they have been read,
201099a2dd95SBruce Richardson  *   otherwise the statistics counters are left untouched.
201199a2dd95SBruce Richardson  * @param[out] error
201299a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
201399a2dd95SBruce Richardson  * @return
201499a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
201599a2dd95SBruce Richardson  *
201699a2dd95SBruce Richardson  * @see enum rte_tm_stats_type
201799a2dd95SBruce Richardson  */
201899a2dd95SBruce Richardson int
201999a2dd95SBruce Richardson rte_tm_node_stats_read(uint16_t port_id,
202099a2dd95SBruce Richardson 	uint32_t node_id,
202199a2dd95SBruce Richardson 	struct rte_tm_node_stats *stats,
202299a2dd95SBruce Richardson 	uint64_t *stats_mask,
202399a2dd95SBruce Richardson 	int clear,
202499a2dd95SBruce Richardson 	struct rte_tm_error *error);
202599a2dd95SBruce Richardson 
202699a2dd95SBruce Richardson /**
202799a2dd95SBruce Richardson  * Traffic manager packet marking - VLAN DEI (IEEE 802.1Q)
202899a2dd95SBruce Richardson  *
202999a2dd95SBruce Richardson  * IEEE 802.1p maps the traffic class to the VLAN Priority Code Point (PCP)
203099a2dd95SBruce Richardson  * field (3 bits), while IEEE 802.1q maps the drop priority to the VLAN Drop
203199a2dd95SBruce Richardson  * Eligible Indicator (DEI) field (1 bit), which was previously named Canonical
203299a2dd95SBruce Richardson  * Format Indicator (CFI).
203399a2dd95SBruce Richardson  *
203499a2dd95SBruce Richardson  * All VLAN frames of a given color get their DEI bit set if marking is enabled
203599a2dd95SBruce Richardson  * for this color; otherwise, their DEI bit is left as is (either set or not).
203699a2dd95SBruce Richardson  *
203799a2dd95SBruce Richardson  * @param[in] port_id
203899a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
203999a2dd95SBruce Richardson  * @param[in] mark_green
204099a2dd95SBruce Richardson  *   Set to non-zero value to enable marking of green packets and to zero to
204199a2dd95SBruce Richardson  *   disable it.
204299a2dd95SBruce Richardson  * @param[in] mark_yellow
204399a2dd95SBruce Richardson  *   Set to non-zero value to enable marking of yellow packets and to zero to
204499a2dd95SBruce Richardson  *   disable it.
204599a2dd95SBruce Richardson  * @param[in] mark_red
204699a2dd95SBruce Richardson  *   Set to non-zero value to enable marking of red packets and to zero to
204799a2dd95SBruce Richardson  *   disable it.
204899a2dd95SBruce Richardson  * @param[out] error
204999a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
205099a2dd95SBruce Richardson  * @return
205199a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
205299a2dd95SBruce Richardson  *
205399a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::mark_vlan_dei_supported
205499a2dd95SBruce Richardson  */
205599a2dd95SBruce Richardson int
205699a2dd95SBruce Richardson rte_tm_mark_vlan_dei(uint16_t port_id,
205799a2dd95SBruce Richardson 	int mark_green,
205899a2dd95SBruce Richardson 	int mark_yellow,
205999a2dd95SBruce Richardson 	int mark_red,
206099a2dd95SBruce Richardson 	struct rte_tm_error *error);
206199a2dd95SBruce Richardson 
206299a2dd95SBruce Richardson /**
206399a2dd95SBruce Richardson  * Traffic manager packet marking - IPv4 / IPv6 ECN (IETF RFC 3168)
206499a2dd95SBruce Richardson  *
206599a2dd95SBruce Richardson  * IETF RFCs 2474 and 3168 reorganize the IPv4 Type of Service (TOS) field
206699a2dd95SBruce Richardson  * (8 bits) and the IPv6 Traffic Class (TC) field (8 bits) into Differentiated
206799a2dd95SBruce Richardson  * Services Codepoint (DSCP) field (6 bits) and Explicit Congestion
206899a2dd95SBruce Richardson  * Notification (ECN) field (2 bits). The DSCP field is typically used to
206999a2dd95SBruce Richardson  * encode the traffic class and/or drop priority (RFC 2597), while the ECN
207099a2dd95SBruce Richardson  * field is used by RFC 3168 to implement a congestion notification mechanism
207199a2dd95SBruce Richardson  * to be leveraged by transport layer protocols such as TCP and SCTP that have
207299a2dd95SBruce Richardson  * congestion control mechanisms.
207399a2dd95SBruce Richardson  *
207499a2dd95SBruce Richardson  * When congestion is experienced, as alternative to dropping the packet,
207599a2dd95SBruce Richardson  * routers can change the ECN field of input packets from 2'b01 or 2'b10
207699a2dd95SBruce Richardson  * (values indicating that source endpoint is ECN-capable) to 2'b11 (meaning
207799a2dd95SBruce Richardson  * that congestion is experienced). The destination endpoint can use the
207899a2dd95SBruce Richardson  * ECN-Echo (ECE) TCP flag to relay the congestion indication back to the
207999a2dd95SBruce Richardson  * source endpoint, which acknowledges it back to the destination endpoint with
208099a2dd95SBruce Richardson  * the Congestion Window Reduced (CWR) TCP flag.
208199a2dd95SBruce Richardson  *
208299a2dd95SBruce Richardson  * All IPv4/IPv6 packets of a given color with ECN set to 2’b01 or 2’b10
208399a2dd95SBruce Richardson  * carrying TCP or SCTP have their ECN set to 2’b11 if the marking feature is
208499a2dd95SBruce Richardson  * enabled for the current color, otherwise the ECN field is left as is.
208599a2dd95SBruce Richardson  *
208699a2dd95SBruce Richardson  * @param[in] port_id
208799a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
208899a2dd95SBruce Richardson  * @param[in] mark_green
208999a2dd95SBruce Richardson  *   Set to non-zero value to enable marking of green packets and to zero to
209099a2dd95SBruce Richardson  *   disable it.
209199a2dd95SBruce Richardson  * @param[in] mark_yellow
209299a2dd95SBruce Richardson  *   Set to non-zero value to enable marking of yellow packets and to zero to
209399a2dd95SBruce Richardson  *   disable it.
209499a2dd95SBruce Richardson  * @param[in] mark_red
209599a2dd95SBruce Richardson  *   Set to non-zero value to enable marking of red packets and to zero to
209699a2dd95SBruce Richardson  *   disable it.
209799a2dd95SBruce Richardson  * @param[out] error
209899a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
209999a2dd95SBruce Richardson  * @return
210099a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
210199a2dd95SBruce Richardson  *
210299a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::mark_ip_ecn_tcp_supported
210399a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::mark_ip_ecn_sctp_supported
210499a2dd95SBruce Richardson  */
210599a2dd95SBruce Richardson int
210699a2dd95SBruce Richardson rte_tm_mark_ip_ecn(uint16_t port_id,
210799a2dd95SBruce Richardson 	int mark_green,
210899a2dd95SBruce Richardson 	int mark_yellow,
210999a2dd95SBruce Richardson 	int mark_red,
211099a2dd95SBruce Richardson 	struct rte_tm_error *error);
211199a2dd95SBruce Richardson 
211299a2dd95SBruce Richardson /**
211399a2dd95SBruce Richardson  * Traffic manager packet marking - IPv4 / IPv6 DSCP (IETF RFC 2597)
211499a2dd95SBruce Richardson  *
211599a2dd95SBruce Richardson  * IETF RFC 2597 maps the traffic class and the drop priority to the IPv4/IPv6
211699a2dd95SBruce Richardson  * Differentiated Services Codepoint (DSCP) field (6 bits). Here are the DSCP
211799a2dd95SBruce Richardson  * values proposed by this RFC:
211899a2dd95SBruce Richardson  *
211999a2dd95SBruce Richardson  * <pre>                   Class 1    Class 2    Class 3    Class 4   </pre>
212099a2dd95SBruce Richardson  * <pre>                 +----------+----------+----------+----------+</pre>
212199a2dd95SBruce Richardson  * <pre>Low Drop Prec    |  001010  |  010010  |  011010  |  100010  |</pre>
212299a2dd95SBruce Richardson  * <pre>Medium Drop Prec |  001100  |  010100  |  011100  |  100100  |</pre>
212399a2dd95SBruce Richardson  * <pre>High Drop Prec   |  001110  |  010110  |  011110  |  100110  |</pre>
212499a2dd95SBruce Richardson  * <pre>                 +----------+----------+----------+----------+</pre>
212599a2dd95SBruce Richardson  *
212699a2dd95SBruce Richardson  * There are 4 traffic classes (classes 1 .. 4) encoded by DSCP bits 1 and 2,
212799a2dd95SBruce Richardson  * as well as 3 drop priorities (low/medium/high) encoded by DSCP bits 3 and 4.
212899a2dd95SBruce Richardson  *
212999a2dd95SBruce Richardson  * All IPv4/IPv6 packets have their color marked into DSCP bits 3 and 4 as
213099a2dd95SBruce Richardson  * follows: green mapped to Low Drop Precedence (2’b01), yellow to Medium
213199a2dd95SBruce Richardson  * (2’b10) and red to High (2’b11). Marking needs to be explicitly enabled
213299a2dd95SBruce Richardson  * for each color; when not enabled for a given color, the DSCP field of all
213399a2dd95SBruce Richardson  * packets with that color is left as is.
213499a2dd95SBruce Richardson  *
213599a2dd95SBruce Richardson  * @param[in] port_id
213699a2dd95SBruce Richardson  *   The port identifier of the Ethernet device.
213799a2dd95SBruce Richardson  * @param[in] mark_green
213899a2dd95SBruce Richardson  *   Set to non-zero value to enable marking of green packets and to zero to
213999a2dd95SBruce Richardson  *   disable it.
214099a2dd95SBruce Richardson  * @param[in] mark_yellow
214199a2dd95SBruce Richardson  *   Set to non-zero value to enable marking of yellow packets and to zero to
214299a2dd95SBruce Richardson  *   disable it.
214399a2dd95SBruce Richardson  * @param[in] mark_red
214499a2dd95SBruce Richardson  *   Set to non-zero value to enable marking of red packets and to zero to
214599a2dd95SBruce Richardson  *   disable it.
214699a2dd95SBruce Richardson  * @param[out] error
214799a2dd95SBruce Richardson  *   Error details. Filled in only on error, when not NULL.
214899a2dd95SBruce Richardson  * @return
214999a2dd95SBruce Richardson  *   0 on success, non-zero error code otherwise.
215099a2dd95SBruce Richardson  *
215199a2dd95SBruce Richardson  * @see struct rte_tm_capabilities::mark_ip_dscp_supported
215299a2dd95SBruce Richardson  */
215399a2dd95SBruce Richardson int
215499a2dd95SBruce Richardson rte_tm_mark_ip_dscp(uint16_t port_id,
215599a2dd95SBruce Richardson 	int mark_green,
215699a2dd95SBruce Richardson 	int mark_yellow,
215799a2dd95SBruce Richardson 	int mark_red,
215899a2dd95SBruce Richardson 	struct rte_tm_error *error);
215999a2dd95SBruce Richardson 
216099a2dd95SBruce Richardson #ifdef __cplusplus
216199a2dd95SBruce Richardson }
216299a2dd95SBruce Richardson #endif
216399a2dd95SBruce Richardson 
216499a2dd95SBruce Richardson #endif /* __INCLUDE_RTE_TM_H__ */
2165