doc: add Meson coding style to contributors guide
[dpdk.git] / lib / librte_ethdev / rte_tm.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation.
3  * Copyright(c) 2017 Cavium.
4  * Copyright(c) 2017 NXP.
5  */
6
7 #ifndef __INCLUDE_RTE_TM_H__
8 #define __INCLUDE_RTE_TM_H__
9
10 /**
11  * @file
12  * RTE Generic Traffic Manager API
13  *
14  * This interface provides the ability to configure the traffic manager in a
15  * generic way. It includes features such as: hierarchical scheduling,
16  * traffic shaping, congestion management, packet marking, etc.
17  *
18  * @warning
19  * @b EXPERIMENTAL:
20  * All functions in this file may be changed or removed without prior notice.
21  */
22
23 #include <stdint.h>
24
25 #include <rte_common.h>
26 #include <rte_meter.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /**
33  * Ethernet framing overhead.
34  *
35  * Overhead fields per Ethernet frame:
36  * 1. Preamble:                                            7 bytes;
37  * 2. Start of Frame Delimiter (SFD):                      1 byte;
38  * 3. Inter-Frame Gap (IFG):                              12 bytes.
39  *
40  * One of the typical values for the *pkt_length_adjust* field of the shaper
41  * profile.
42  *
43  * @see struct rte_tm_shaper_params
44  */
45 #define RTE_TM_ETH_FRAMING_OVERHEAD                  20
46
47 /**
48  * Ethernet framing overhead including the Frame Check Sequence (FCS) field.
49  * Useful when FCS is generated and added at the end of the Ethernet frame on
50  * TX side without any SW intervention.
51  *
52  * One of the typical values for the pkt_length_adjust field of the shaper
53  * profile.
54  *
55  * @see struct rte_tm_shaper_params
56  */
57 #define RTE_TM_ETH_FRAMING_OVERHEAD_FCS              24
58
59 /**
60  * Invalid WRED profile ID.
61  *
62  * @see struct rte_tm_node_params
63  * @see rte_tm_node_add()
64  * @see rte_tm_node_wred_context_update()
65  */
66 #define RTE_TM_WRED_PROFILE_ID_NONE                  UINT32_MAX
67
68 /**
69  *Invalid shaper profile ID.
70  *
71  * @see struct rte_tm_node_params
72  * @see rte_tm_node_add()
73  * @see rte_tm_node_shaper_update()
74  */
75 #define RTE_TM_SHAPER_PROFILE_ID_NONE                UINT32_MAX
76
77 /**
78  * Node ID for the parent of the root node.
79  *
80  * @see rte_tm_node_add()
81  */
82 #define RTE_TM_NODE_ID_NULL                          UINT32_MAX
83
84 /**
85  * Node level ID used to disable level ID checking.
86  *
87  * @see rte_tm_node_add()
88  */
89 #define RTE_TM_NODE_LEVEL_ID_ANY                     UINT32_MAX
90
91 /**
92  * Node statistics counter type
93  */
94 enum rte_tm_stats_type {
95         /** Number of packets scheduled from current node. */
96         RTE_TM_STATS_N_PKTS = 1 << 0,
97
98         /** Number of bytes scheduled from current node. */
99         RTE_TM_STATS_N_BYTES = 1 << 1,
100
101         /** Number of green packets dropped by current leaf node.  */
102         RTE_TM_STATS_N_PKTS_GREEN_DROPPED = 1 << 2,
103
104         /** Number of yellow packets dropped by current leaf node.  */
105         RTE_TM_STATS_N_PKTS_YELLOW_DROPPED = 1 << 3,
106
107         /** Number of red packets dropped by current leaf node.  */
108         RTE_TM_STATS_N_PKTS_RED_DROPPED = 1 << 4,
109
110         /** Number of green bytes dropped by current leaf node.  */
111         RTE_TM_STATS_N_BYTES_GREEN_DROPPED = 1 << 5,
112
113         /** Number of yellow bytes dropped by current leaf node.  */
114         RTE_TM_STATS_N_BYTES_YELLOW_DROPPED = 1 << 6,
115
116         /** Number of red bytes dropped by current leaf node.  */
117         RTE_TM_STATS_N_BYTES_RED_DROPPED = 1 << 7,
118
119         /** Number of packets currently waiting in the packet queue of current
120          * leaf node.
121          */
122         RTE_TM_STATS_N_PKTS_QUEUED = 1 << 8,
123
124         /** Number of bytes currently waiting in the packet queue of current
125          * leaf node.
126          */
127         RTE_TM_STATS_N_BYTES_QUEUED = 1 << 9,
128 };
129
130 /**
131  * Node statistics counters
132  */
133 struct rte_tm_node_stats {
134         /** Number of packets scheduled from current node. */
135         uint64_t n_pkts;
136
137         /** Number of bytes scheduled from current node. */
138         uint64_t n_bytes;
139
140         /** Statistics counters for leaf nodes only. */
141         struct {
142                 /** Number of packets dropped by current leaf node per each
143                  * color.
144                  */
145                 uint64_t n_pkts_dropped[RTE_COLORS];
146
147                 /** Number of bytes dropped by current leaf node per each
148                  * color.
149                  */
150                 uint64_t n_bytes_dropped[RTE_COLORS];
151
152                 /** Number of packets currently waiting in the packet queue of
153                  * current leaf node.
154                  */
155                 uint64_t n_pkts_queued;
156
157                 /** Number of bytes currently waiting in the packet queue of
158                  * current leaf node.
159                  */
160                 uint64_t n_bytes_queued;
161         } leaf;
162 };
163
164 /**
165  * Traffic manager dynamic updates
166  */
167 enum rte_tm_dynamic_update_type {
168         /** Dynamic parent node update. The new parent node is located on same
169          * hierarchy level as the former parent node. Consequently, the node
170          * whose parent is changed preserves its hierarchy level.
171          */
172         RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL = 1 << 0,
173
174         /** Dynamic parent node update. The new parent node is located on
175          * different hierarchy level than the former parent node. Consequently,
176          * the node whose parent is changed also changes its hierarchy level.
177          */
178         RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL = 1 << 1,
179
180         /** Dynamic node add/delete. */
181         RTE_TM_UPDATE_NODE_ADD_DELETE = 1 << 2,
182
183         /** Suspend/resume nodes. */
184         RTE_TM_UPDATE_NODE_SUSPEND_RESUME = 1 << 3,
185
186         /** Dynamic switch between byte-based and packet-based WFQ weights. */
187         RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE = 1 << 4,
188
189         /** Dynamic update on number of SP priorities. */
190         RTE_TM_UPDATE_NODE_N_SP_PRIORITIES = 1 << 5,
191
192         /** Dynamic update of congestion management mode for leaf nodes. */
193         RTE_TM_UPDATE_NODE_CMAN = 1 << 6,
194
195         /** Dynamic update of the set of enabled stats counter types. */
196         RTE_TM_UPDATE_NODE_STATS = 1 << 7,
197 };
198
199 /**
200  * Traffic manager capabilities
201  */
202 struct rte_tm_capabilities {
203         /** Maximum number of nodes. */
204         uint32_t n_nodes_max;
205
206         /** Maximum number of levels (i.e. number of nodes connecting the root
207          * node with any leaf node, including the root and the leaf).
208          */
209         uint32_t n_levels_max;
210
211         /** When non-zero, this flag indicates that all the non-leaf nodes
212          * (with the exception of the root node) have identical capability set.
213          */
214         int non_leaf_nodes_identical;
215
216         /** When non-zero, this flag indicates that all the leaf nodes have
217          * identical capability set.
218          */
219         int leaf_nodes_identical;
220
221         /** Maximum number of shapers, either private or shared. In case the
222          * implementation does not share any resources between private and
223          * shared shapers, it is typically equal to the sum of
224          * *shaper_private_n_max* and *shaper_shared_n_max*. The
225          * value of zero indicates that traffic shaping is not supported.
226          */
227         uint32_t shaper_n_max;
228
229         /** Maximum number of private shapers. Indicates the maximum number of
230          * nodes that can concurrently have their private shaper enabled. The
231          * value of zero indicates that private shapers are not supported.
232          */
233         uint32_t shaper_private_n_max;
234
235         /** Maximum number of private shapers that support dual rate shaping.
236          * Indicates the maximum number of nodes that can concurrently have
237          * their private shaper enabled with dual rate support. Only valid when
238          * private shapers are supported. The value of zero indicates that dual
239          * rate shaping is not available for private shapers. The maximum value
240          * is *shaper_private_n_max*.
241          */
242         int shaper_private_dual_rate_n_max;
243
244         /** Minimum committed/peak rate (bytes per second) for any private
245          * shaper. Valid only when private shapers are supported.
246          */
247         uint64_t shaper_private_rate_min;
248
249         /** Maximum committed/peak rate (bytes per second) for any private
250          * shaper. Valid only when private shapers are supported.
251          */
252         uint64_t shaper_private_rate_max;
253
254         /** Shaper private packet mode supported. When non-zero, this parameter
255          * indicates that there is at least one node that can be configured
256          * with packet mode in its private shaper. When shaper is configured
257          * in packet mode, committed/peak rate provided is interpreted
258          * in packets per second.
259          */
260         int shaper_private_packet_mode_supported;
261
262         /** Shaper private byte mode supported. When non-zero, this parameter
263          * indicates that there is at least one node that can be configured
264          * with byte mode in its private shaper. When shaper is configured
265          * in byte mode, committed/peak rate provided is interpreted in
266          * bytes per second.
267          */
268         int shaper_private_byte_mode_supported;
269
270
271         /** Maximum number of shared shapers. The value of zero indicates that
272          * shared shapers are not supported.
273          */
274         uint32_t shaper_shared_n_max;
275
276         /** Maximum number of nodes that can share the same shared shaper.
277          * Only valid when shared shapers are supported.
278          */
279         uint32_t shaper_shared_n_nodes_per_shaper_max;
280
281         /** Maximum number of shared shapers a node can be part of. This
282          * parameter indicates that there is at least one node that can be
283          * configured with this many shared shapers, which might not be true for
284          * all the nodes. Only valid when shared shapers are supported, in which
285          * case it ranges from 1 to *shaper_shared_n_max*.
286          */
287         uint32_t shaper_shared_n_shapers_per_node_max;
288
289         /** Maximum number of shared shapers that can be configured with dual
290          * rate shaping. The value of zero indicates that dual rate shaping
291          * support is not available for shared shapers.
292          */
293         uint32_t shaper_shared_dual_rate_n_max;
294
295         /** Minimum committed/peak rate (bytes per second) for any shared
296          * shaper. Only valid when shared shapers are supported.
297          */
298         uint64_t shaper_shared_rate_min;
299
300         /** Maximum committed/peak rate (bytes per second) for any shared
301          * shaper. Only valid when shared shapers are supported.
302          */
303         uint64_t shaper_shared_rate_max;
304
305         /** Shaper shared packet mode supported. When non-zero, this parameter
306          * indicates a shared shaper can be configured with packet mode.
307          * When shared shaper is configured in packet mode, committed/peak rate
308          * provided is interpreted in packets per second.
309          */
310         int shaper_shared_packet_mode_supported;
311
312         /** Shaper shared byte mode supported. When non-zero, this parameter
313          * indicates that a shared shaper can be configured with byte mode.
314          * When shared shaper is configured in byte mode, committed/peak rate
315          * provided is interpreted in bytes per second.
316          */
317         int shaper_shared_byte_mode_supported;
318
319
320         /** Minimum value allowed for packet length adjustment for any private
321          * or shared shaper.
322          */
323         int shaper_pkt_length_adjust_min;
324
325         /** Maximum value allowed for packet length adjustment for any private
326          * or shared shaper.
327          */
328         int shaper_pkt_length_adjust_max;
329
330         /** Maximum number of children nodes. This parameter indicates that
331          * there is at least one non-leaf node that can be configured with this
332          * many children nodes, which might not be true for all the non-leaf
333          * nodes.
334          */
335         uint32_t sched_n_children_max;
336
337         /** Maximum number of supported priority levels. This parameter
338          * indicates that there is at least one non-leaf node that can be
339          * configured with this many priority levels for managing its children
340          * nodes, which might not be true for all the non-leaf nodes. The value
341          * of zero is invalid. The value of 1 indicates that only priority 0 is
342          * supported, which essentially means that Strict Priority (SP)
343          * algorithm is not supported.
344          */
345         uint32_t sched_sp_n_priorities_max;
346
347         /** Maximum number of sibling nodes that can have the same priority at
348          * any given time, i.e. maximum size of the WFQ sibling node group. This
349          * parameter indicates there is at least one non-leaf node that meets
350          * this condition, which might not be true for all the non-leaf nodes.
351          * The value of zero is invalid. The value of 1 indicates that WFQ
352          * algorithm is not supported. The maximum value is
353          * *sched_n_children_max*.
354          */
355         uint32_t sched_wfq_n_children_per_group_max;
356
357         /** Maximum number of priority levels that can have more than one child
358          * node at any given time, i.e. maximum number of WFQ sibling node
359          * groups that have two or more members. This parameter indicates there
360          * is at least one non-leaf node that meets this condition, which might
361          * not be true for all the non-leaf nodes. The value of zero states that
362          * WFQ algorithm is not supported. The value of 1 indicates that
363          * (*sched_sp_n_priorities_max* - 1) priority levels have at most one
364          * child node, so there can be only one priority level with two or
365          * more sibling nodes making up a WFQ group. The maximum value is:
366          * min(floor(*sched_n_children_max* / 2), *sched_sp_n_priorities_max*).
367          */
368         uint32_t sched_wfq_n_groups_max;
369
370         /** Maximum WFQ weight. The value of 1 indicates that all sibling nodes
371          * with same priority have the same WFQ weight, so WFQ is reduced to FQ.
372          */
373         uint32_t sched_wfq_weight_max;
374
375         /** WFQ packet mode supported. When non-zero, this parameter indicates
376          * that there is at least one non-leaf node that supports packet mode
377          * for WFQ among its children. WFQ weights will be applied against
378          * packet count for scheduling children when a non-leaf node
379          * is configured appropriately.
380          */
381         int sched_wfq_packet_mode_supported;
382
383         /** WFQ byte mode supported. When non-zero, this parameter indicates
384          * that there is at least one non-leaf node that supports byte mode
385          * for WFQ among its children. WFQ weights will be applied against
386          * bytes for scheduling children when a non-leaf node is configured
387          * appropriately.
388          */
389         int sched_wfq_byte_mode_supported;
390
391         /** WRED packet mode support. When non-zero, this parameter indicates
392          * that there is at least one leaf node that supports the WRED packet
393          * mode, which might not be true for all the leaf nodes. In packet
394          * mode, the WRED thresholds specify the queue length in packets, as
395          * opposed to bytes.
396          */
397         int cman_wred_packet_mode_supported;
398
399         /** WRED byte mode support. When non-zero, this parameter indicates that
400          * there is at least one leaf node that supports the WRED byte mode,
401          * which might not be true for all the leaf nodes. In byte mode, the
402          * WRED thresholds specify the queue length in bytes, as opposed to
403          * packets.
404          */
405         int cman_wred_byte_mode_supported;
406
407         /** Head drop algorithm support. When non-zero, this parameter
408          * indicates that there is at least one leaf node that supports the head
409          * drop algorithm, which might not be true for all the leaf nodes.
410          */
411         int cman_head_drop_supported;
412
413         /** Maximum number of WRED contexts, either private or shared. In case
414          * the implementation does not share any resources between private and
415          * shared WRED contexts, it is typically equal to the sum of
416          * *cman_wred_context_private_n_max* and
417          * *cman_wred_context_shared_n_max*. The value of zero indicates that
418          * WRED is not supported.
419          */
420         uint32_t cman_wred_context_n_max;
421
422         /** Maximum number of private WRED contexts. Indicates the maximum
423          * number of leaf nodes that can concurrently have their private WRED
424          * context enabled. The value of zero indicates that private WRED
425          * contexts are not supported.
426          */
427         uint32_t cman_wred_context_private_n_max;
428
429         /** Maximum number of shared WRED contexts. The value of zero
430          * indicates that shared WRED contexts are not supported.
431          */
432         uint32_t cman_wred_context_shared_n_max;
433
434         /** Maximum number of leaf nodes that can share the same WRED context.
435          * Only valid when shared WRED contexts are supported.
436          */
437         uint32_t cman_wred_context_shared_n_nodes_per_context_max;
438
439         /** Maximum number of shared WRED contexts a leaf node can be part of.
440          * This parameter indicates that there is at least one leaf node that
441          * can be configured with this many shared WRED contexts, which might
442          * not be true for all the leaf nodes. Only valid when shared WRED
443          * contexts are supported, in which case it ranges from 1 to
444          * *cman_wred_context_shared_n_max*.
445          */
446         uint32_t cman_wred_context_shared_n_contexts_per_node_max;
447
448         /** Support for VLAN DEI packet marking (per color). */
449         int mark_vlan_dei_supported[RTE_COLORS];
450
451         /** Support for IPv4/IPv6 ECN marking of TCP packets (per color). */
452         int mark_ip_ecn_tcp_supported[RTE_COLORS];
453
454         /** Support for IPv4/IPv6 ECN marking of SCTP packets (per color). */
455         int mark_ip_ecn_sctp_supported[RTE_COLORS];
456
457         /** Support for IPv4/IPv6 DSCP packet marking (per color). */
458         int mark_ip_dscp_supported[RTE_COLORS];
459
460         /** Set of supported dynamic update operations.
461          * @see enum rte_tm_dynamic_update_type
462          */
463         uint64_t dynamic_update_mask;
464
465         /** Set of supported statistics counter types.
466          * @see enum rte_tm_stats_type
467          */
468         uint64_t stats_mask;
469 };
470
471 /**
472  * Traffic manager level capabilities
473  */
474 struct rte_tm_level_capabilities {
475         /** Maximum number of nodes for the current hierarchy level. */
476         uint32_t n_nodes_max;
477
478         /** Maximum number of non-leaf nodes for the current hierarchy level.
479          * The value of 0 indicates that current level only supports leaf
480          * nodes. The maximum value is *n_nodes_max*.
481          */
482         uint32_t n_nodes_nonleaf_max;
483
484         /** Maximum number of leaf nodes for the current hierarchy level. The
485          * value of 0 indicates that current level only supports non-leaf
486          * nodes. The maximum value is *n_nodes_max*.
487          */
488         uint32_t n_nodes_leaf_max;
489
490         /** When non-zero, this flag indicates that all the non-leaf nodes on
491          * this level have identical capability set. Valid only when
492          * *n_nodes_nonleaf_max* is non-zero.
493          */
494         int non_leaf_nodes_identical;
495
496         /** When non-zero, this flag indicates that all the leaf nodes on this
497          * level have identical capability set. Valid only when
498          * *n_nodes_leaf_max* is non-zero.
499          */
500         int leaf_nodes_identical;
501
502         RTE_STD_C11
503         union {
504                 /** Items valid only for the non-leaf nodes on this level. */
505                 struct {
506                         /** Private shaper support. When non-zero, it indicates
507                          * there is at least one non-leaf node on this level
508                          * with private shaper support, which may not be the
509                          * case for all the non-leaf nodes on this level.
510                          */
511                         int shaper_private_supported;
512
513                         /** Dual rate support for private shaper. Valid only
514                          * when private shaper is supported for the non-leaf
515                          * nodes on the current level. When non-zero, it
516                          * indicates there is at least one non-leaf node on this
517                          * level with dual rate private shaper support, which
518                          * may not be the case for all the non-leaf nodes on
519                          * this level.
520                          */
521                         int shaper_private_dual_rate_supported;
522
523                         /** Minimum committed/peak rate (bytes per second) for
524                          * private shapers of the non-leaf nodes of this level.
525                          * Valid only when private shaper is supported on this
526                          * level.
527                          */
528                         uint64_t shaper_private_rate_min;
529
530                         /** Maximum committed/peak rate (bytes per second) for
531                          * private shapers of the non-leaf nodes on this level.
532                          * Valid only when private shaper is supported on this
533                          * level.
534                          */
535                         uint64_t shaper_private_rate_max;
536
537                         /** Shaper private packet mode supported. When non-zero,
538                          * this parameter indicates there is at least one
539                          * non-leaf node at this level that can be configured
540                          * with packet mode in its private shaper. When private
541                          * shaper is configured in packet mode, committed/peak
542                          * rate provided is interpreted in packets per second.
543                          */
544                         int shaper_private_packet_mode_supported;
545
546                         /** Shaper private byte mode supported. When non-zero,
547                          * this parameter indicates there is at least one
548                          * non-leaf node at this level that can be configured
549                          * with byte mode in its private shaper. When private
550                          * shaper is configured in byte mode, committed/peak
551                          * rate provided is interpreted in bytes per second.
552                          */
553                         int shaper_private_byte_mode_supported;
554
555                         /** Maximum number of shared shapers that any non-leaf
556                          * node on this level can be part of. The value of zero
557                          * indicates that shared shapers are not supported by
558                          * the non-leaf nodes on this level. When non-zero, it
559                          * indicates there is at least one non-leaf node on this
560                          * level that meets this condition, which may not be the
561                          * case for all the non-leaf nodes on this level.
562                          */
563                         uint32_t shaper_shared_n_max;
564
565                         /** Shaper shared packet mode supported. When non-zero,
566                          * this parameter indicates that there is at least one
567                          * non-leaf node on this level that can be part of
568                          * shared shapers which work in packet mode.
569                          */
570                         int shaper_shared_packet_mode_supported;
571
572                         /** Shaper shared byte mode supported. When non-zero,
573                          * this parameter indicates that there is at least one
574                          * non-leaf node on this level that can be part of
575                          * shared shapers which work in byte mode.
576                          */
577                         int shaper_shared_byte_mode_supported;
578
579                         /** Maximum number of children nodes. This parameter
580                          * indicates that there is at least one non-leaf node on
581                          * this level that can be configured with this many
582                          * children nodes, which might not be true for all the
583                          * non-leaf nodes on this level.
584                          */
585                         uint32_t sched_n_children_max;
586
587                         /** Maximum number of supported priority levels. This
588                          * parameter indicates that there is at least one
589                          * non-leaf node on this level that can be configured
590                          * with this many priority levels for managing its
591                          * children nodes, which might not be true for all the
592                          * non-leaf nodes on this level. The value of zero is
593                          * invalid. The value of 1 indicates that only priority
594                          * 0 is supported, which essentially means that Strict
595                          * Priority (SP) algorithm is not supported on this
596                          * level.
597                          */
598                         uint32_t sched_sp_n_priorities_max;
599
600                         /** Maximum number of sibling nodes that can have the
601                          * same priority at any given time, i.e. maximum size of
602                          * the WFQ sibling node group. This parameter indicates
603                          * there is at least one non-leaf node on this level
604                          * that meets this condition, which may not be true for
605                          * all the non-leaf nodes on this level. The value of
606                          * zero is invalid. The value of 1 indicates that WFQ
607                          * algorithm is not supported on this level. The maximum
608                          * value is *sched_n_children_max*.
609                          */
610                         uint32_t sched_wfq_n_children_per_group_max;
611
612                         /** Maximum number of priority levels that can have
613                          * more than one child node at any given time, i.e.
614                          * maximum number of WFQ sibling node groups that
615                          * have two or more members. This parameter indicates
616                          * there is at least one non-leaf node on this level
617                          * that meets this condition, which might not be true
618                          * for all the non-leaf nodes. The value of zero states
619                          * that WFQ algorithm is not supported on this level.
620                          * The value of 1 indicates that
621                          * (*sched_sp_n_priorities_max* - 1) priority levels on
622                          * this level have at most one child node, so there can
623                          * be only one priority level with two or more sibling
624                          * nodes making up a WFQ group on this level. The
625                          * maximum value is:
626                          * min(floor(*sched_n_children_max* / 2),
627                          * *sched_sp_n_priorities_max*).
628                          */
629                         uint32_t sched_wfq_n_groups_max;
630
631                         /** Maximum WFQ weight. The value of 1 indicates that
632                          * all sibling nodes on this level with same priority
633                          * have the same WFQ weight, so on this level WFQ is
634                          * reduced to FQ.
635                          */
636                         uint32_t sched_wfq_weight_max;
637
638                         /** WFQ packet mode supported. When non-zero, this
639                          * parameter indicates that there is at least one
640                          * non-leaf node at this level that supports packet
641                          * mode for WFQ among its children. WFQ weights will
642                          * be applied against packet count for scheduling
643                          * children when a non-leaf node is configured
644                          * appropriately.
645                          */
646                         int sched_wfq_packet_mode_supported;
647
648                         /** WFQ byte mode supported. When non-zero, this
649                          * parameter indicates that there is at least one
650                          * non-leaf node at this level that supports byte
651                          * mode for WFQ among its children. WFQ weights will
652                          * be applied against bytes for scheduling children
653                          * when a non-leaf node is configured appropriately.
654                          */
655                         int sched_wfq_byte_mode_supported;
656
657                         /** Mask of statistics counter types supported by the
658                          * non-leaf nodes on this level. Every supported
659                          * statistics counter type is supported by at least one
660                          * non-leaf node on this level, which may not be true
661                          * for all the non-leaf nodes on this level.
662                          * @see enum rte_tm_stats_type
663                          */
664                         uint64_t stats_mask;
665                 } nonleaf;
666
667                 /** Items valid only for the leaf nodes on this level. */
668                 struct {
669                         /** Private shaper support. When non-zero, it indicates
670                          * there is at least one leaf node on this level with
671                          * private shaper support, which may not be the case for
672                          * all the leaf nodes on this level.
673                          */
674                         int shaper_private_supported;
675
676                         /** Dual rate support for private shaper. Valid only
677                          * when private shaper is supported for the leaf nodes
678                          * on this level. When non-zero, it indicates there is
679                          * at least one leaf node on this level with dual rate
680                          * private shaper support, which may not be the case for
681                          * all the leaf nodes on this level.
682                          */
683                         int shaper_private_dual_rate_supported;
684
685                         /** Minimum committed/peak rate (bytes per second) for
686                          * private shapers of the leaf nodes of this level.
687                          * Valid only when private shaper is supported for the
688                          * leaf nodes on this level.
689                          */
690                         uint64_t shaper_private_rate_min;
691
692                         /** Maximum committed/peak rate (bytes per second) for
693                          * private shapers of the leaf nodes on this level.
694                          * Valid only when private shaper is supported for the
695                          * leaf nodes on this level.
696                          */
697                         uint64_t shaper_private_rate_max;
698
699                         /** Shaper private packet mode supported. When non-zero,
700                          * this parameter indicates there is at least one leaf
701                          * node at this level that can be configured with
702                          * packet mode in its private shaper. When private
703                          * shaper is configured in packet mode, committed/peak
704                          * rate provided is interpreted in packets per second.
705                          */
706                         int shaper_private_packet_mode_supported;
707
708                         /** Shaper private byte mode supported. When non-zero,
709                          * this parameter indicates there is at least one leaf
710                          * node at this level that can be configured with
711                          * byte mode in its private shaper. When private shaper
712                          * is configured in byte mode, committed/peak rate
713                          * provided is interpreted in bytes per second.
714                          */
715                         int shaper_private_byte_mode_supported;
716
717                         /** Maximum number of shared shapers that any leaf node
718                          * on this level can be part of. The value of zero
719                          * indicates that shared shapers are not supported by
720                          * the leaf nodes on this level. When non-zero, it
721                          * indicates there is at least one leaf node on this
722                          * level that meets this condition, which may not be the
723                          * case for all the leaf nodes on this level.
724                          */
725                         uint32_t shaper_shared_n_max;
726
727                         /** Shaper shared packet mode supported. When non-zero,
728                          * this parameter indicates that there is at least one
729                          * leaf node on this level that can be part of
730                          * shared shapers which work in packet mode.
731                          */
732                         int shaper_shared_packet_mode_supported;
733
734                         /** Shaper shared byte mode supported. When non-zero,
735                          * this parameter indicates that there is at least one
736                          * leaf node on this level that can be part of
737                          * shared shapers which work in byte mode.
738                          */
739                         int shaper_shared_byte_mode_supported;
740
741                         /** WRED packet mode support. When non-zero, this
742                          * parameter indicates that there is at least one leaf
743                          * node on this level that supports the WRED packet
744                          * mode, which might not be true for all the leaf
745                          * nodes. In packet mode, the WRED thresholds specify
746                          * the queue length in packets, as opposed to bytes.
747                          */
748                         int cman_wred_packet_mode_supported;
749
750                         /** WRED byte mode support. When non-zero, this
751                          * parameter indicates that there is at least one leaf
752                          * node on this level that supports the WRED byte mode,
753                          * which might not be true for all the leaf nodes. In
754                          * byte mode, the WRED thresholds specify the queue
755                          * length in bytes, as opposed to packets.
756                          */
757                         int cman_wred_byte_mode_supported;
758
759                         /** Head drop algorithm support. When non-zero, this
760                          * parameter indicates that there is at least one leaf
761                          * node on this level that supports the head drop
762                          * algorithm, which might not be true for all the leaf
763                          * nodes on this level.
764                          */
765                         int cman_head_drop_supported;
766
767                         /** Private WRED context support. When non-zero, it
768                          * indicates there is at least one node on this level
769                          * with private WRED context support, which may not be
770                          * true for all the leaf nodes on this level.
771                          */
772                         int cman_wred_context_private_supported;
773
774                         /** Maximum number of shared WRED contexts that any
775                          * leaf node on this level can be part of. The value of
776                          * zero indicates that shared WRED contexts are not
777                          * supported by the leaf nodes on this level. When
778                          * non-zero, it indicates there is at least one leaf
779                          * node on this level that meets this condition, which
780                          * may not be the case for all the leaf nodes on this
781                          * level.
782                          */
783                         uint32_t cman_wred_context_shared_n_max;
784
785                         /** Mask of statistics counter types supported by the
786                          * leaf nodes on this level. Every supported statistics
787                          * counter type is supported by at least one leaf node
788                          * on this level, which may not be true for all the leaf
789                          * nodes on this level.
790                          * @see enum rte_tm_stats_type
791                          */
792                         uint64_t stats_mask;
793                 } leaf;
794         };
795 };
796
797 /**
798  * Traffic manager node capabilities
799  */
800 struct rte_tm_node_capabilities {
801         /** Private shaper support for the current node. */
802         int shaper_private_supported;
803
804         /** Dual rate shaping support for private shaper of current node.
805          * Valid only when private shaper is supported by the current node.
806          */
807         int shaper_private_dual_rate_supported;
808
809         /** Minimum committed/peak rate (bytes per second) for private
810          * shaper of current node. Valid only when private shaper is supported
811          * by the current node.
812          */
813         uint64_t shaper_private_rate_min;
814
815         /** Maximum committed/peak rate (bytes per second) for private
816          * shaper of current node. Valid only when private shaper is supported
817          * by the current node.
818          */
819         uint64_t shaper_private_rate_max;
820
821         /** Shaper private packet mode supported. When non-zero, this parameter
822          * indicates private shaper of current node can be configured with
823          * packet mode. When configured in packet mode, committed/peak rate
824          * provided is interpreted in packets per second.
825          */
826         int shaper_private_packet_mode_supported;
827
828         /** Shaper private byte mode supported. When non-zero, this parameter
829          * indicates private shaper of current node can be configured with
830          * byte mode. When configured in byte mode, committed/peak rate
831          * provided is interpreted in bytes per second.
832          */
833         int shaper_private_byte_mode_supported;
834
835         /** Maximum number of shared shapers the current node can be part of.
836          * The value of zero indicates that shared shapers are not supported by
837          * the current node.
838          */
839         uint32_t shaper_shared_n_max;
840
841         /** Shaper shared packet mode supported. When non-zero,
842          * this parameter indicates that current node can be part of
843          * shared shapers which work in packet mode.
844          */
845         int shaper_shared_packet_mode_supported;
846
847         /** Shaper shared byte mode supported. When non-zero,
848          * this parameter indicates that current node can be part of
849          * shared shapers which work in byte mode.
850          */
851         int shaper_shared_byte_mode_supported;
852
853         RTE_STD_C11
854         union {
855                 /** Items valid only for non-leaf nodes. */
856                 struct {
857                         /** Maximum number of children nodes. */
858                         uint32_t sched_n_children_max;
859
860                         /** Maximum number of supported priority levels. The
861                          * value of zero is invalid. The value of 1 indicates
862                          * that only priority 0 is supported, which essentially
863                          * means that Strict Priority (SP) algorithm is not
864                          * supported.
865                          */
866                         uint32_t sched_sp_n_priorities_max;
867
868                         /** Maximum number of sibling nodes that can have the
869                          * same priority at any given time, i.e. maximum size
870                          * of the WFQ sibling node group. The value of zero
871                          * is invalid. The value of 1 indicates that WFQ
872                          * algorithm is not supported. The maximum value is
873                          * *sched_n_children_max*.
874                          */
875                         uint32_t sched_wfq_n_children_per_group_max;
876
877                         /** Maximum number of priority levels that can have
878                          * more than one child node at any given time, i.e.
879                          * maximum number of WFQ sibling node groups that have
880                          * two or more members. The value of zero states that
881                          * WFQ algorithm is not supported. The value of 1
882                          * indicates that (*sched_sp_n_priorities_max* - 1)
883                          * priority levels have at most one child node, so there
884                          * can be only one priority level with two or more
885                          * sibling nodes making up a WFQ group. The maximum
886                          * value is: min(floor(*sched_n_children_max* / 2),
887                          * *sched_sp_n_priorities_max*).
888                          */
889                         uint32_t sched_wfq_n_groups_max;
890
891                         /** Maximum WFQ weight. The value of 1 indicates that
892                          * all sibling nodes with same priority have the same
893                          * WFQ weight, so WFQ is reduced to FQ.
894                          */
895                         uint32_t sched_wfq_weight_max;
896
897                         /** WFQ packet mode supported. When non-zero, this
898                          * parameter indicates that current node supports packet
899                          * mode for WFQ among its children. WFQ weights will be
900                          * applied against packet count for scheduling children
901                          * when configured appropriately.
902                          */
903                         int sched_wfq_packet_mode_supported;
904
905                         /** WFQ byte mode supported. When non-zero, this
906                          * parameter indicates that current node supports byte
907                          * mode for WFQ among its children. WFQ weights will be
908                          * applied against  bytes for scheduling children when
909                          * configured appropriately.
910                          */
911                         int sched_wfq_byte_mode_supported;
912
913                 } nonleaf;
914
915                 /** Items valid only for leaf nodes. */
916                 struct {
917                         /** WRED packet mode support for current node. */
918                         int cman_wred_packet_mode_supported;
919
920                         /** WRED byte mode support for current node. */
921                         int cman_wred_byte_mode_supported;
922
923                         /** Head drop algorithm support for current node. */
924                         int cman_head_drop_supported;
925
926                         /** Private WRED context support for current node. */
927                         int cman_wred_context_private_supported;
928
929                         /** Maximum number of shared WRED contexts the current
930                          * node can be part of. The value of zero indicates that
931                          * shared WRED contexts are not supported by the current
932                          * node.
933                          */
934                         uint32_t cman_wred_context_shared_n_max;
935                 } leaf;
936         };
937
938         /** Mask of statistics counter types supported by the current node.
939          * @see enum rte_tm_stats_type
940          */
941         uint64_t stats_mask;
942 };
943
944 /**
945  * Congestion management (CMAN) mode
946  *
947  * This is used for controlling the admission of packets into a packet queue or
948  * group of packet queues on congestion. On request of writing a new packet
949  * into the current queue while the queue is full, the *tail drop* algorithm
950  * drops the new packet while leaving the queue unmodified, as opposed to *head
951  * drop* algorithm, which drops the packet at the head of the queue (the oldest
952  * packet waiting in the queue) and admits the new packet at the tail of the
953  * queue.
954  *
955  * The *Random Early Detection (RED)* algorithm works by proactively dropping
956  * more and more input packets as the queue occupancy builds up. When the queue
957  * is full or almost full, RED effectively works as *tail drop*. The *Weighted
958  * RED* algorithm uses a separate set of RED thresholds for each packet color.
959  */
960 enum rte_tm_cman_mode {
961         RTE_TM_CMAN_TAIL_DROP = 0, /**< Tail drop */
962         RTE_TM_CMAN_HEAD_DROP, /**< Head drop */
963         RTE_TM_CMAN_WRED, /**< Weighted Random Early Detection (WRED) */
964 };
965
966 /**
967  * Random Early Detection (RED) profile
968  */
969 struct rte_tm_red_params {
970         /** Minimum queue threshold */
971         uint64_t min_th;
972
973         /** Maximum queue threshold */
974         uint64_t max_th;
975
976         /** Inverse of packet marking probability maximum value (maxp), i.e.
977          * maxp_inv = 1 / maxp
978          */
979         uint16_t maxp_inv;
980
981         /** Negated log2 of queue weight (wq), i.e. wq = 1 / (2 ^ wq_log2) */
982         uint16_t wq_log2;
983 };
984
985 /**
986  * Weighted RED (WRED) profile
987  *
988  * Multiple WRED contexts can share the same WRED profile. Each leaf node with
989  * WRED enabled as its congestion management mode has zero or one private WRED
990  * context (only one leaf node using it) and/or zero, one or several shared
991  * WRED contexts (multiple leaf nodes use the same WRED context). A private
992  * WRED context is used to perform congestion management for a single leaf
993  * node, while a shared WRED context is used to perform congestion management
994  * for a group of leaf nodes.
995  *
996  * @see struct rte_tm_capabilities::cman_wred_packet_mode_supported
997  * @see struct rte_tm_capabilities::cman_wred_byte_mode_supported
998  */
999 struct rte_tm_wred_params {
1000         /** One set of RED parameters per packet color */
1001         struct rte_tm_red_params red_params[RTE_COLORS];
1002
1003         /** When non-zero, the *min_th* and *max_th* thresholds are specified
1004          * in packets (WRED packet mode). When zero, the *min_th* and *max_th*
1005          * thresholds are specified in bytes (WRED byte mode)
1006          */
1007         int packet_mode;
1008 };
1009
1010 /**
1011  * Token bucket
1012  */
1013 struct rte_tm_token_bucket {
1014         /** Token bucket rate (bytes per second or packets per second) */
1015         uint64_t rate;
1016
1017         /** Token bucket size (bytes or packets), a.k.a. max burst size */
1018         uint64_t size;
1019 };
1020
1021 /**
1022  * Shaper (rate limiter) profile
1023  *
1024  * Multiple shaper instances can share the same shaper profile. Each node has
1025  * zero or one private shaper (only one node using it) and/or zero, one or
1026  * several shared shapers (multiple nodes use the same shaper instance).
1027  * A private shaper is used to perform traffic shaping for a single node, while
1028  * a shared shaper is used to perform traffic shaping for a group of nodes.
1029  *
1030  * Single rate shapers use a single token bucket. A single rate shaper can be
1031  * configured by setting the rate of the committed bucket to zero, which
1032  * effectively disables this bucket. The peak bucket is used to limit the rate
1033  * and the burst size for the current shaper.
1034  *
1035  * Dual rate shapers use both the committed and the peak token buckets. The
1036  * rate of the peak bucket has to be bigger than zero, as well as greater than
1037  * or equal to the rate of the committed bucket.
1038  *
1039  * @see struct rte_tm_capabilities::shaper_private_packet_mode_supported
1040  * @see struct rte_tm_capabilities::shaper_private_byte_mode_supported
1041  * @see struct rte_tm_capabilities::shaper_shared_packet_mode_supported
1042  * @see struct rte_tm_capabilities::shaper_shared_byte_mode_supported
1043  */
1044 struct rte_tm_shaper_params {
1045         /** Committed token bucket */
1046         struct rte_tm_token_bucket committed;
1047
1048         /** Peak token bucket */
1049         struct rte_tm_token_bucket peak;
1050
1051         /** Signed value to be added to the length of each packet for the
1052          * purpose of shaping. Can be used to correct the packet length with
1053          * the framing overhead bytes that are also consumed on the wire (e.g.
1054          * RTE_TM_ETH_FRAMING_OVERHEAD_FCS).
1055          * This field is ignored when the profile enables packet mode.
1056          */
1057         int32_t pkt_length_adjust;
1058
1059         /** When zero, the byte mode is enabled for the current profile, so the
1060          * *rate* and *size* fields in both the committed and peak token buckets
1061          * are specified in bytes per second and bytes, respectively.
1062          * When non-zero, the packet mode is enabled for the current profile,
1063          * so the *rate* and *size* fields in both the committed and peak token
1064          * buckets are specified in packets per second and packets,
1065          * respectively.
1066          */
1067         int packet_mode;
1068 };
1069
1070 /**
1071  * Node parameters
1072  *
1073  * Each non-leaf node has multiple inputs (its children nodes) and single output
1074  * (which is input to its parent node). It arbitrates its inputs using Strict
1075  * Priority (SP) and Weighted Fair Queuing (WFQ) algorithms to schedule input
1076  * packets to its output while observing its shaping (rate limiting)
1077  * constraints.
1078  *
1079  * Algorithms such as Weighted Round Robin (WRR), Byte-level WRR, Deficit WRR
1080  * (DWRR), etc. are considered approximations of the WFQ ideal and are
1081  * assimilated to WFQ, although an associated implementation-dependent trade-off
1082  * on accuracy, performance and resource usage might exist.
1083  *
1084  * Children nodes with different priorities are scheduled using the SP algorithm
1085  * based on their priority, with zero (0) as the highest priority. Children with
1086  * the same priority are scheduled using the WFQ algorithm according to their
1087  * weights. The WFQ weight of a given child node is relative to the sum of the
1088  * weights of all its sibling nodes that have the same priority, with one (1) as
1089  * the lowest weight. For each SP priority, the WFQ weight mode can be set as
1090  * either byte-based or packet-based.
1091  *
1092  * Each leaf node sits on top of a TX queue of the current Ethernet port. Hence,
1093  * the leaf nodes are predefined, with their node IDs set to 0 .. (N-1), where N
1094  * is the number of TX queues configured for the current Ethernet port. The
1095  * non-leaf nodes have their IDs generated by the application.
1096  */
1097 struct rte_tm_node_params {
1098         /** Shaper profile for the private shaper. The absence of the private
1099          * shaper for the current node is indicated by setting this parameter
1100          * to RTE_TM_SHAPER_PROFILE_ID_NONE.
1101          */
1102         uint32_t shaper_profile_id;
1103
1104         /** User allocated array of valid shared shaper IDs. */
1105         uint32_t *shared_shaper_id;
1106
1107         /** Number of shared shaper IDs in the *shared_shaper_id* array. */
1108         uint32_t n_shared_shapers;
1109
1110         RTE_STD_C11
1111         union {
1112                 /** Parameters only valid for non-leaf nodes. */
1113                 struct {
1114                         /** WFQ weight mode for each SP priority. When NULL, it
1115                          * indicates that WFQ is to be used for all priorities.
1116                          * When non-NULL, it points to a pre-allocated array of
1117                          * *n_sp_priorities* values, with non-zero value for
1118                          * byte-mode and zero for packet-mode.
1119                          * @see struct rte_tm_node_capabilities::sched_wfq_packet_mode_supported
1120                          * @see struct rte_tm_node_capabilities::sched_wfq_byte_mode_supported
1121                          */
1122                         int *wfq_weight_mode;
1123
1124                         /** Number of SP priorities. */
1125                         uint32_t n_sp_priorities;
1126                 } nonleaf;
1127
1128                 /** Parameters only valid for leaf nodes. */
1129                 struct {
1130                         /** Congestion management mode */
1131                         enum rte_tm_cman_mode cman;
1132
1133                         /** WRED parameters (only valid when *cman* is set to
1134                          * WRED).
1135                          */
1136                         struct {
1137                                 /** WRED profile for private WRED context. The
1138                                  * absence of a private WRED context for the
1139                                  * current leaf node is indicated by value
1140                                  * RTE_TM_WRED_PROFILE_ID_NONE.
1141                                  */
1142                                 uint32_t wred_profile_id;
1143
1144                                 /** User allocated array of shared WRED context
1145                                  * IDs. When set to NULL, it indicates that the
1146                                  * current leaf node should not currently be
1147                                  * part of any shared WRED contexts.
1148                                  */
1149                                 uint32_t *shared_wred_context_id;
1150
1151                                 /** Number of elements in the
1152                                  * *shared_wred_context_id* array. Only valid
1153                                  * when *shared_wred_context_id* is non-NULL,
1154                                  * in which case it should be non-zero.
1155                                  */
1156                                 uint32_t n_shared_wred_contexts;
1157                         } wred;
1158                 } leaf;
1159         };
1160
1161         /** Mask of statistics counter types to be enabled for this node. This
1162          * needs to be a subset of the statistics counter types available for
1163          * the current node. Any statistics counter type not included in this
1164          * set is to be disabled for the current node.
1165          * @see enum rte_tm_stats_type
1166          */
1167         uint64_t stats_mask;
1168 };
1169
1170 /**
1171  * Verbose error types.
1172  *
1173  * Most of them provide the type of the object referenced by struct
1174  * rte_tm_error::cause.
1175  */
1176 enum rte_tm_error_type {
1177         RTE_TM_ERROR_TYPE_NONE, /**< No error. */
1178         RTE_TM_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
1179         RTE_TM_ERROR_TYPE_CAPABILITIES,
1180         RTE_TM_ERROR_TYPE_LEVEL_ID,
1181         RTE_TM_ERROR_TYPE_WRED_PROFILE,
1182         RTE_TM_ERROR_TYPE_WRED_PROFILE_GREEN,
1183         RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW,
1184         RTE_TM_ERROR_TYPE_WRED_PROFILE_RED,
1185         RTE_TM_ERROR_TYPE_WRED_PROFILE_ID,
1186         RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID,
1187         RTE_TM_ERROR_TYPE_SHAPER_PROFILE,
1188         RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE,
1189         RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE,
1190         RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
1191         RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
1192         RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN,
1193         RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PACKET_MODE,
1194         RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
1195         RTE_TM_ERROR_TYPE_SHARED_SHAPER_ID,
1196         RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID,
1197         RTE_TM_ERROR_TYPE_NODE_PRIORITY,
1198         RTE_TM_ERROR_TYPE_NODE_WEIGHT,
1199         RTE_TM_ERROR_TYPE_NODE_PARAMS,
1200         RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID,
1201         RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID,
1202         RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS,
1203         RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE,
1204         RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES,
1205         RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN,
1206         RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID,
1207         RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID,
1208         RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS,
1209         RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
1210         RTE_TM_ERROR_TYPE_NODE_ID,
1211 };
1212
1213 /**
1214  * Verbose error structure definition.
1215  *
1216  * This object is normally allocated by applications and set by PMDs, the
1217  * message points to a constant string which does not need to be freed by
1218  * the application, however its pointer can be considered valid only as long
1219  * as its associated DPDK port remains configured. Closing the underlying
1220  * device or unloading the PMD invalidates it.
1221  *
1222  * Both cause and message may be NULL regardless of the error type.
1223  */
1224 struct rte_tm_error {
1225         enum rte_tm_error_type type; /**< Cause field and error type. */
1226         const void *cause; /**< Object responsible for the error. */
1227         const char *message; /**< Human-readable error message. */
1228 };
1229
1230 /**
1231  * Traffic manager get number of leaf nodes
1232  *
1233  * Each leaf node sits on on top of a TX queue of the current Ethernet port.
1234  * Therefore, the set of leaf nodes is predefined, their number is always equal
1235  * to N (where N is the number of TX queues configured for the current port)
1236  * and their IDs are 0 .. (N-1).
1237  *
1238  * @param[in] port_id
1239  *   The port identifier of the Ethernet device.
1240  * @param[out] n_leaf_nodes
1241  *   Number of leaf nodes for the current port.
1242  * @param[out] error
1243  *   Error details. Filled in only on error, when not NULL.
1244  * @return
1245  *   0 on success, non-zero error code otherwise.
1246  */
1247 __rte_experimental
1248 int
1249 rte_tm_get_number_of_leaf_nodes(uint16_t port_id,
1250         uint32_t *n_leaf_nodes,
1251         struct rte_tm_error *error);
1252
1253 /**
1254  * Traffic manager node ID validate and type (i.e. leaf or non-leaf) get
1255  *
1256  * The leaf nodes have predefined IDs in the range of 0 .. (N-1), where N is
1257  * the number of TX queues of the current Ethernet port. The non-leaf nodes
1258  * have their IDs generated by the application outside of the above range,
1259  * which is reserved for leaf nodes.
1260  *
1261  * @param[in] port_id
1262  *   The port identifier of the Ethernet device.
1263  * @param[in] node_id
1264  *   Node ID value. Needs to be valid.
1265  * @param[out] is_leaf
1266  *   Set to non-zero value when node is leaf and to zero otherwise (non-leaf).
1267  * @param[out] error
1268  *   Error details. Filled in only on error, when not NULL.
1269  * @return
1270  *   0 on success, non-zero error code otherwise.
1271  */
1272 __rte_experimental
1273 int
1274 rte_tm_node_type_get(uint16_t port_id,
1275         uint32_t node_id,
1276         int *is_leaf,
1277         struct rte_tm_error *error);
1278
1279 /**
1280  * Traffic manager capabilities get
1281  *
1282  * @param[in] port_id
1283  *   The port identifier of the Ethernet device.
1284  * @param[out] cap
1285  *   Traffic manager capabilities. Needs to be pre-allocated and valid.
1286  * @param[out] error
1287  *   Error details. Filled in only on error, when not NULL.
1288  * @return
1289  *   0 on success, non-zero error code otherwise.
1290  */
1291 __rte_experimental
1292 int
1293 rte_tm_capabilities_get(uint16_t port_id,
1294         struct rte_tm_capabilities *cap,
1295         struct rte_tm_error *error);
1296
1297 /**
1298  * Traffic manager level capabilities get
1299  *
1300  * @param[in] port_id
1301  *   The port identifier of the Ethernet device.
1302  * @param[in] level_id
1303  *   The hierarchy level identifier. The value of 0 identifies the level of the
1304  *   root node.
1305  * @param[out] cap
1306  *   Traffic manager level capabilities. Needs to be pre-allocated and valid.
1307  * @param[out] error
1308  *   Error details. Filled in only on error, when not NULL.
1309  * @return
1310  *   0 on success, non-zero error code otherwise.
1311  */
1312 __rte_experimental
1313 int
1314 rte_tm_level_capabilities_get(uint16_t port_id,
1315         uint32_t level_id,
1316         struct rte_tm_level_capabilities *cap,
1317         struct rte_tm_error *error);
1318
1319 /**
1320  * Traffic manager node capabilities get
1321  *
1322  * @param[in] port_id
1323  *   The port identifier of the Ethernet device.
1324  * @param[in] node_id
1325  *   Node ID. Needs to be valid.
1326  * @param[out] cap
1327  *   Traffic manager node capabilities. Needs to be pre-allocated and valid.
1328  * @param[out] error
1329  *   Error details. Filled in only on error, when not NULL.
1330  * @return
1331  *   0 on success, non-zero error code otherwise.
1332  */
1333 __rte_experimental
1334 int
1335 rte_tm_node_capabilities_get(uint16_t port_id,
1336         uint32_t node_id,
1337         struct rte_tm_node_capabilities *cap,
1338         struct rte_tm_error *error);
1339
1340 /**
1341  * Traffic manager WRED profile add
1342  *
1343  * Create a new WRED profile with ID set to *wred_profile_id*. The new profile
1344  * is used to create one or several WRED contexts.
1345  *
1346  * @param[in] port_id
1347  *   The port identifier of the Ethernet device.
1348  * @param[in] wred_profile_id
1349  *   WRED profile ID for the new profile. Needs to be unused.
1350  * @param[in] profile
1351  *   WRED profile parameters. Needs to be pre-allocated and valid.
1352  * @param[out] error
1353  *   Error details. Filled in only on error, when not NULL.
1354  * @return
1355  *   0 on success, non-zero error code otherwise.
1356  *
1357  * @see struct rte_tm_capabilities::cman_wred_context_n_max
1358  */
1359 __rte_experimental
1360 int
1361 rte_tm_wred_profile_add(uint16_t port_id,
1362         uint32_t wred_profile_id,
1363         struct rte_tm_wred_params *profile,
1364         struct rte_tm_error *error);
1365
1366 /**
1367  * Traffic manager WRED profile delete
1368  *
1369  * Delete an existing WRED profile. This operation fails when there is
1370  * currently at least one user (i.e. WRED context) of this WRED profile.
1371  *
1372  * @param[in] port_id
1373  *   The port identifier of the Ethernet device.
1374  * @param[in] wred_profile_id
1375  *   WRED profile ID. Needs to be the valid.
1376  * @param[out] error
1377  *   Error details. Filled in only on error, when not NULL.
1378  * @return
1379  *   0 on success, non-zero error code otherwise.
1380  *
1381  * @see struct rte_tm_capabilities::cman_wred_context_n_max
1382  */
1383 __rte_experimental
1384 int
1385 rte_tm_wred_profile_delete(uint16_t port_id,
1386         uint32_t wred_profile_id,
1387         struct rte_tm_error *error);
1388
1389 /**
1390  * Traffic manager shared WRED context add or update
1391  *
1392  * When *shared_wred_context_id* is invalid, a new WRED context with this ID is
1393  * created by using the WRED profile identified by *wred_profile_id*.
1394  *
1395  * When *shared_wred_context_id* is valid, this WRED context is no longer using
1396  * the profile previously assigned to it and is updated to use the profile
1397  * identified by *wred_profile_id*.
1398  *
1399  * A valid shared WRED context can be assigned to several hierarchy leaf nodes
1400  * configured to use WRED as the congestion management mode.
1401  *
1402  * @param[in] port_id
1403  *   The port identifier of the Ethernet device.
1404  * @param[in] shared_wred_context_id
1405  *   Shared WRED context ID
1406  * @param[in] wred_profile_id
1407  *   WRED profile ID. Needs to be the valid.
1408  * @param[out] error
1409  *   Error details. Filled in only on error, when not NULL.
1410  * @return
1411  *   0 on success, non-zero error code otherwise.
1412  *
1413  * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1414  */
1415 __rte_experimental
1416 int
1417 rte_tm_shared_wred_context_add_update(uint16_t port_id,
1418         uint32_t shared_wred_context_id,
1419         uint32_t wred_profile_id,
1420         struct rte_tm_error *error);
1421
1422 /**
1423  * Traffic manager shared WRED context delete
1424  *
1425  * Delete an existing shared WRED context. This operation fails when there is
1426  * currently at least one user (i.e. hierarchy leaf node) of this shared WRED
1427  * context.
1428  *
1429  * @param[in] port_id
1430  *   The port identifier of the Ethernet device.
1431  * @param[in] shared_wred_context_id
1432  *   Shared WRED context ID. Needs to be the valid.
1433  * @param[out] error
1434  *   Error details. Filled in only on error, when not NULL.
1435  * @return
1436  *   0 on success, non-zero error code otherwise.
1437  *
1438  * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1439  */
1440 __rte_experimental
1441 int
1442 rte_tm_shared_wred_context_delete(uint16_t port_id,
1443         uint32_t shared_wred_context_id,
1444         struct rte_tm_error *error);
1445
1446 /**
1447  * Traffic manager shaper profile add
1448  *
1449  * Create a new shaper profile with ID set to *shaper_profile_id*. The new
1450  * shaper profile is used to create one or several shapers.
1451  *
1452  * @param[in] port_id
1453  *   The port identifier of the Ethernet device.
1454  * @param[in] shaper_profile_id
1455  *   Shaper profile ID for the new profile. Needs to be unused.
1456  * @param[in] profile
1457  *   Shaper profile parameters. Needs to be pre-allocated and valid.
1458  * @param[out] error
1459  *   Error details. Filled in only on error, when not NULL.
1460  * @return
1461  *   0 on success, non-zero error code otherwise.
1462  *
1463  * @see struct rte_tm_capabilities::shaper_n_max
1464  */
1465 __rte_experimental
1466 int
1467 rte_tm_shaper_profile_add(uint16_t port_id,
1468         uint32_t shaper_profile_id,
1469         struct rte_tm_shaper_params *profile,
1470         struct rte_tm_error *error);
1471
1472 /**
1473  * Traffic manager shaper profile delete
1474  *
1475  * Delete an existing shaper profile. This operation fails when there is
1476  * currently at least one user (i.e. shaper) of this shaper profile.
1477  *
1478  * @param[in] port_id
1479  *   The port identifier of the Ethernet device.
1480  * @param[in] shaper_profile_id
1481  *   Shaper profile ID. Needs to be the valid.
1482  * @param[out] error
1483  *   Error details. Filled in only on error, when not NULL.
1484  * @return
1485  *   0 on success, non-zero error code otherwise.
1486  *
1487  * @see struct rte_tm_capabilities::shaper_n_max
1488  */
1489 __rte_experimental
1490 int
1491 rte_tm_shaper_profile_delete(uint16_t port_id,
1492         uint32_t shaper_profile_id,
1493         struct rte_tm_error *error);
1494
1495 /**
1496  * Traffic manager shared shaper add or update
1497  *
1498  * When *shared_shaper_id* is not a valid shared shaper ID, a new shared shaper
1499  * with this ID is created using the shaper profile identified by
1500  * *shaper_profile_id*.
1501  *
1502  * When *shared_shaper_id* is a valid shared shaper ID, this shared shaper is
1503  * no longer using the shaper profile previously assigned to it and is updated
1504  * to use the shaper profile identified by *shaper_profile_id*.
1505  *
1506  * @param[in] port_id
1507  *   The port identifier of the Ethernet device.
1508  * @param[in] shared_shaper_id
1509  *   Shared shaper ID
1510  * @param[in] shaper_profile_id
1511  *   Shaper profile ID. Needs to be the valid.
1512  * @param[out] error
1513  *   Error details. Filled in only on error, when not NULL.
1514  * @return
1515  *   0 on success, non-zero error code otherwise.
1516  *
1517  * @see struct rte_tm_capabilities::shaper_shared_n_max
1518  */
1519 __rte_experimental
1520 int
1521 rte_tm_shared_shaper_add_update(uint16_t port_id,
1522         uint32_t shared_shaper_id,
1523         uint32_t shaper_profile_id,
1524         struct rte_tm_error *error);
1525
1526 /**
1527  * Traffic manager shared shaper delete
1528  *
1529  * Delete an existing shared shaper. This operation fails when there is
1530  * currently at least one user (i.e. hierarchy node) of this shared shaper.
1531  *
1532  * @param[in] port_id
1533  *   The port identifier of the Ethernet device.
1534  * @param[in] shared_shaper_id
1535  *   Shared shaper ID. Needs to be the valid.
1536  * @param[out] error
1537  *   Error details. Filled in only on error, when not NULL.
1538  * @return
1539  *   0 on success, non-zero error code otherwise.
1540  *
1541  * @see struct rte_tm_capabilities::shaper_shared_n_max
1542  */
1543 __rte_experimental
1544 int
1545 rte_tm_shared_shaper_delete(uint16_t port_id,
1546         uint32_t shared_shaper_id,
1547         struct rte_tm_error *error);
1548
1549 /**
1550  * Traffic manager node add
1551  *
1552  * Create new node and connect it as child of an existing node. The new node is
1553  * further identified by *node_id*, which needs to be unused by any of the
1554  * existing nodes. The parent node is identified by *parent_node_id*, which
1555  * needs to be the valid ID of an existing non-leaf node. The parent node is
1556  * going to use the provided SP *priority* and WFQ *weight* to schedule its new
1557  * child node.
1558  *
1559  * This function has to be called for both leaf and non-leaf nodes. In the case
1560  * of leaf nodes (i.e. *node_id* is within the range of 0 .. (N-1), with N as
1561  * the number of configured TX queues of the current port), the leaf node is
1562  * configured rather than created (as the set of leaf nodes is predefined) and
1563  * it is also connected as child of an existing node.
1564  *
1565  * The first node that is added becomes the root node and all the nodes that
1566  * are subsequently added have to be added as descendants of the root node. The
1567  * parent of the root node has to be specified as RTE_TM_NODE_ID_NULL and there
1568  * can only be one node with this parent ID (i.e. the root node). Further
1569  * restrictions for root node: needs to be non-leaf, its private shaper profile
1570  * needs to be valid and single rate, cannot use any shared shapers.
1571  *
1572  * When called before rte_tm_hierarchy_commit() invocation, this function is
1573  * typically used to define the initial start-up hierarchy for the port.
1574  * Provided that dynamic hierarchy updates are supported by the current port (as
1575  * advertised in the port capability set), this function can be also called
1576  * after the rte_tm_hierarchy_commit() invocation.
1577  *
1578  * @param[in] port_id
1579  *   The port identifier of the Ethernet device.
1580  * @param[in] node_id
1581  *   Node ID. Needs to be unused by any of the existing nodes.
1582  * @param[in] parent_node_id
1583  *   Parent node ID. Needs to be the valid.
1584  * @param[in] priority
1585  *   Node priority. The highest node priority is zero. Used by the SP algorithm
1586  *   running on the parent of the current node for scheduling this child node.
1587  * @param[in] weight
1588  *   Node weight. The node weight is relative to the weight sum of all siblings
1589  *   that have the same priority. The lowest weight is one. Used by the WFQ
1590  *   algorithm running on the parent of the current node for scheduling this
1591  *   child node.
1592  * @param[in] level_id
1593  *   Level ID that should be met by this node. The hierarchy level of the
1594  *   current node is already fully specified through its parent node (i.e. the
1595  *   level of this node is equal to the level of its parent node plus one),
1596  *   therefore the reason for providing this parameter is to enable the
1597  *   application to perform step-by-step checking of the node level during
1598  *   successive invocations of this function. When not desired, this check can
1599  *   be disabled by assigning value RTE_TM_NODE_LEVEL_ID_ANY to this parameter.
1600  * @param[in] params
1601  *   Node parameters. Needs to be pre-allocated and valid.
1602  * @param[out] error
1603  *   Error details. Filled in only on error, when not NULL.
1604  * @return
1605  *   0 on success, non-zero error code otherwise.
1606  *
1607  * @see rte_tm_hierarchy_commit()
1608  * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1609  * @see RTE_TM_NODE_LEVEL_ID_ANY
1610  * @see struct rte_tm_capabilities
1611  */
1612 __rte_experimental
1613 int
1614 rte_tm_node_add(uint16_t port_id,
1615         uint32_t node_id,
1616         uint32_t parent_node_id,
1617         uint32_t priority,
1618         uint32_t weight,
1619         uint32_t level_id,
1620         struct rte_tm_node_params *params,
1621         struct rte_tm_error *error);
1622
1623 /**
1624  * Traffic manager node delete
1625  *
1626  * Delete an existing node. This operation fails when this node currently has
1627  * at least one user (i.e. child node).
1628  *
1629  * When called before rte_tm_hierarchy_commit() invocation, this function is
1630  * typically used to define the initial start-up hierarchy for the port.
1631  * Provided that dynamic hierarchy updates are supported by the current port (as
1632  * advertised in the port capability set), this function can be also called
1633  * after the rte_tm_hierarchy_commit() invocation.
1634  *
1635  * @param[in] port_id
1636  *   The port identifier of the Ethernet device.
1637  * @param[in] node_id
1638  *   Node ID. Needs to be valid.
1639  * @param[out] error
1640  *   Error details. Filled in only on error, when not NULL.
1641  * @return
1642  *   0 on success, non-zero error code otherwise.
1643  *
1644  * @see RTE_TM_UPDATE_NODE_ADD_DELETE
1645  */
1646 __rte_experimental
1647 int
1648 rte_tm_node_delete(uint16_t port_id,
1649         uint32_t node_id,
1650         struct rte_tm_error *error);
1651
1652 /**
1653  * Traffic manager node suspend
1654  *
1655  * Suspend an existing node. While the node is in suspended state, no packet is
1656  * scheduled from this node and its descendants. The node exits the suspended
1657  * state through the node resume operation.
1658  *
1659  * @param[in] port_id
1660  *   The port identifier of the Ethernet device.
1661  * @param[in] node_id
1662  *   Node ID. Needs to be valid.
1663  * @param[out] error
1664  *   Error details. Filled in only on error, when not NULL.
1665  * @return
1666  *   0 on success, non-zero error code otherwise.
1667  *
1668  * @see rte_tm_node_resume()
1669  * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1670  */
1671 __rte_experimental
1672 int
1673 rte_tm_node_suspend(uint16_t port_id,
1674         uint32_t node_id,
1675         struct rte_tm_error *error);
1676
1677 /**
1678  * Traffic manager node resume
1679  *
1680  * Resume an existing node that is currently in suspended state. The node
1681  * entered the suspended state as result of a previous node suspend operation.
1682  *
1683  * @param[in] port_id
1684  *   The port identifier of the Ethernet device.
1685  * @param[in] node_id
1686  *   Node ID. Needs to be valid.
1687  * @param[out] error
1688  *   Error details. Filled in only on error, when not NULL.
1689  * @return
1690  *   0 on success, non-zero error code otherwise.
1691  *
1692  * @see rte_tm_node_suspend()
1693  * @see RTE_TM_UPDATE_NODE_SUSPEND_RESUME
1694  */
1695 __rte_experimental
1696 int
1697 rte_tm_node_resume(uint16_t port_id,
1698         uint32_t node_id,
1699         struct rte_tm_error *error);
1700
1701 /**
1702  * Traffic manager hierarchy commit
1703  *
1704  * This function is called during the port initialization phase (before the
1705  * Ethernet port is started) to freeze the start-up hierarchy.
1706  *
1707  * This function typically performs the following steps:
1708  *    a) It validates the start-up hierarchy that was previously defined for the
1709  *       current port through successive rte_tm_node_add() invocations;
1710  *    b) Assuming successful validation, it performs all the necessary port
1711  *       specific configuration operations to install the specified hierarchy on
1712  *       the current port, with immediate effect once the port is started.
1713  *
1714  * This function fails when the currently configured hierarchy is not supported
1715  * by the Ethernet port, in which case the user can abort or try out another
1716  * hierarchy configuration (e.g. a hierarchy with less leaf nodes), which can be
1717  * build from scratch (when *clear_on_fail* is enabled) or by modifying the
1718  * existing hierarchy configuration (when *clear_on_fail* is disabled).
1719  *
1720  * Note that this function can still fail due to other causes (e.g. not enough
1721  * memory available in the system, etc), even though the specified hierarchy is
1722  * supported in principle by the current port.
1723  *
1724  * @param[in] port_id
1725  *   The port identifier of the Ethernet device.
1726  * @param[in] clear_on_fail
1727  *   On function call failure, hierarchy is cleared when this parameter is
1728  *   non-zero and preserved when this parameter is equal to zero.
1729  * @param[out] error
1730  *   Error details. Filled in only on error, when not NULL.
1731  * @return
1732  *   0 on success, non-zero error code otherwise.
1733  *
1734  * @see rte_tm_node_add()
1735  * @see rte_tm_node_delete()
1736  */
1737 __rte_experimental
1738 int
1739 rte_tm_hierarchy_commit(uint16_t port_id,
1740         int clear_on_fail,
1741         struct rte_tm_error *error);
1742
1743 /**
1744  * Traffic manager node parent update
1745  *
1746  * This function may be used to move a node and its children to a different
1747  * parent.  Additionally, if the new parent is the same as the current parent,
1748  * this function will update the priority/weight of an existing node.
1749  *
1750  * Restriction for root node: its parent cannot be changed.
1751  *
1752  * This function can only be called after the rte_tm_hierarchy_commit()
1753  * invocation. Its success depends on the port support for this operation, as
1754  * advertised through the port capability set.
1755  *
1756  * @param[in] port_id
1757  *   The port identifier of the Ethernet device.
1758  * @param[in] node_id
1759  *   Node ID. Needs to be valid.
1760  * @param[in] parent_node_id
1761  *   Node ID for the new parent. Needs to be valid.
1762  * @param[in] priority
1763  *   Node priority. The highest node priority is zero. Used by the SP algorithm
1764  *   running on the parent of the current node for scheduling this child node.
1765  * @param[in] weight
1766  *   Node weight. The node weight is relative to the weight sum of all siblings
1767  *   that have the same priority. The lowest weight is zero. Used by the WFQ
1768  *   algorithm running on the parent of the current node for scheduling this
1769  *   child node.
1770  * @param[out] error
1771  *   Error details. Filled in only on error, when not NULL.
1772  * @return
1773  *   0 on success, non-zero error code otherwise.
1774  *
1775  * @see RTE_TM_UPDATE_NODE_PARENT_KEEP_LEVEL
1776  * @see RTE_TM_UPDATE_NODE_PARENT_CHANGE_LEVEL
1777  */
1778 __rte_experimental
1779 int
1780 rte_tm_node_parent_update(uint16_t port_id,
1781         uint32_t node_id,
1782         uint32_t parent_node_id,
1783         uint32_t priority,
1784         uint32_t weight,
1785         struct rte_tm_error *error);
1786
1787 /**
1788  * Traffic manager node private shaper update
1789  *
1790  * Restriction for the root node: its private shaper profile needs to be valid
1791  * and single rate.
1792  *
1793  * @param[in] port_id
1794  *   The port identifier of the Ethernet device.
1795  * @param[in] node_id
1796  *   Node ID. Needs to be valid.
1797  * @param[in] shaper_profile_id
1798  *   Shaper profile ID for the private shaper of the current node. Needs to be
1799  *   either valid shaper profile ID or RTE_TM_SHAPER_PROFILE_ID_NONE, with
1800  *   the latter disabling the private shaper of the current node.
1801  * @param[out] error
1802  *   Error details. Filled in only on error, when not NULL.
1803  * @return
1804  *   0 on success, non-zero error code otherwise.
1805  *
1806  * @see struct rte_tm_capabilities::shaper_private_n_max
1807  */
1808 __rte_experimental
1809 int
1810 rte_tm_node_shaper_update(uint16_t port_id,
1811         uint32_t node_id,
1812         uint32_t shaper_profile_id,
1813         struct rte_tm_error *error);
1814
1815 /**
1816  * Traffic manager node shared shapers update
1817  *
1818  * Restriction for root node: cannot use any shared rate shapers.
1819  *
1820  * @param[in] port_id
1821  *   The port identifier of the Ethernet device.
1822  * @param[in] node_id
1823  *   Node ID. Needs to be valid.
1824  * @param[in] shared_shaper_id
1825  *   Shared shaper ID. Needs to be valid.
1826  * @param[in] add
1827  *   Set to non-zero value to add this shared shaper to current node or to zero
1828  *   to delete this shared shaper from current node.
1829  * @param[out] error
1830  *   Error details. Filled in only on error, when not NULL.
1831  * @return
1832  *   0 on success, non-zero error code otherwise.
1833  *
1834  * @see struct rte_tm_capabilities::shaper_shared_n_max
1835  */
1836 __rte_experimental
1837 int
1838 rte_tm_node_shared_shaper_update(uint16_t port_id,
1839         uint32_t node_id,
1840         uint32_t shared_shaper_id,
1841         int add,
1842         struct rte_tm_error *error);
1843
1844 /**
1845  * Traffic manager node enabled statistics counters update
1846  *
1847  * @param[in] port_id
1848  *   The port identifier of the Ethernet device.
1849  * @param[in] node_id
1850  *   Node ID. Needs to be valid.
1851  * @param[in] stats_mask
1852  *   Mask of statistics counter types to be enabled for the current node. This
1853  *   needs to be a subset of the statistics counter types available for the
1854  *   current node. Any statistics counter type not included in this set is to
1855  *   be disabled for the current node.
1856  * @param[out] error
1857  *   Error details. Filled in only on error, when not NULL.
1858  * @return
1859  *   0 on success, non-zero error code otherwise.
1860  *
1861  * @see enum rte_tm_stats_type
1862  * @see RTE_TM_UPDATE_NODE_STATS
1863  */
1864 __rte_experimental
1865 int
1866 rte_tm_node_stats_update(uint16_t port_id,
1867         uint32_t node_id,
1868         uint64_t stats_mask,
1869         struct rte_tm_error *error);
1870
1871 /**
1872  * Traffic manager node WFQ weight mode update
1873  *
1874  * @param[in] port_id
1875  *   The port identifier of the Ethernet device.
1876  * @param[in] node_id
1877  *   Node ID. Needs to be valid non-leaf node ID.
1878  * @param[in] wfq_weight_mode
1879  *   WFQ weight mode for each SP priority. When NULL, it indicates that WFQ is
1880  *   to be used for all priorities. When non-NULL, it points to a pre-allocated
1881  *   array of *n_sp_priorities* values, with non-zero value for byte-mode and
1882  *   zero for packet-mode.
1883  * @param[in] n_sp_priorities
1884  *   Number of SP priorities.
1885  * @param[out] error
1886  *   Error details. Filled in only on error, when not NULL.
1887  * @return
1888  *   0 on success, non-zero error code otherwise.
1889  *
1890  * @see RTE_TM_UPDATE_NODE_WFQ_WEIGHT_MODE
1891  * @see RTE_TM_UPDATE_NODE_N_SP_PRIORITIES
1892  */
1893 __rte_experimental
1894 int
1895 rte_tm_node_wfq_weight_mode_update(uint16_t port_id,
1896         uint32_t node_id,
1897         int *wfq_weight_mode,
1898         uint32_t n_sp_priorities,
1899         struct rte_tm_error *error);
1900
1901 /**
1902  * Traffic manager node congestion management mode update
1903  *
1904  * @param[in] port_id
1905  *   The port identifier of the Ethernet device.
1906  * @param[in] node_id
1907  *   Node ID. Needs to be valid leaf node ID.
1908  * @param[in] cman
1909  *   Congestion management mode.
1910  * @param[out] error
1911  *   Error details. Filled in only on error, when not NULL.
1912  * @return
1913  *   0 on success, non-zero error code otherwise.
1914  *
1915  * @see RTE_TM_UPDATE_NODE_CMAN
1916  */
1917 __rte_experimental
1918 int
1919 rte_tm_node_cman_update(uint16_t port_id,
1920         uint32_t node_id,
1921         enum rte_tm_cman_mode cman,
1922         struct rte_tm_error *error);
1923
1924 /**
1925  * Traffic manager node private WRED context update
1926  *
1927  * @param[in] port_id
1928  *   The port identifier of the Ethernet device.
1929  * @param[in] node_id
1930  *   Node ID. Needs to be valid leaf node ID.
1931  * @param[in] wred_profile_id
1932  *   WRED profile ID for the private WRED context of the current node. Needs to
1933  *   be either valid WRED profile ID or RTE_TM_WRED_PROFILE_ID_NONE, with the
1934  *   latter disabling the private WRED context of the current node.
1935  * @param[out] error
1936  *   Error details. Filled in only on error, when not NULL.
1937  * @return
1938  *   0 on success, non-zero error code otherwise.
1939   *
1940  * @see struct rte_tm_capabilities::cman_wred_context_private_n_max
1941 */
1942 __rte_experimental
1943 int
1944 rte_tm_node_wred_context_update(uint16_t port_id,
1945         uint32_t node_id,
1946         uint32_t wred_profile_id,
1947         struct rte_tm_error *error);
1948
1949 /**
1950  * Traffic manager node shared WRED context update
1951  *
1952  * @param[in] port_id
1953  *   The port identifier of the Ethernet device.
1954  * @param[in] node_id
1955  *   Node ID. Needs to be valid leaf node ID.
1956  * @param[in] shared_wred_context_id
1957  *   Shared WRED context ID. Needs to be valid.
1958  * @param[in] add
1959  *   Set to non-zero value to add this shared WRED context to current node or
1960  *   to zero to delete this shared WRED context from current node.
1961  * @param[out] error
1962  *   Error details. Filled in only on error, when not NULL.
1963  * @return
1964  *   0 on success, non-zero error code otherwise.
1965  *
1966  * @see struct rte_tm_capabilities::cman_wred_context_shared_n_max
1967  */
1968 __rte_experimental
1969 int
1970 rte_tm_node_shared_wred_context_update(uint16_t port_id,
1971         uint32_t node_id,
1972         uint32_t shared_wred_context_id,
1973         int add,
1974         struct rte_tm_error *error);
1975
1976 /**
1977  * Traffic manager node statistics counters read
1978  *
1979  * @param[in] port_id
1980  *   The port identifier of the Ethernet device.
1981  * @param[in] node_id
1982  *   Node ID. Needs to be valid.
1983  * @param[out] stats
1984  *   When non-NULL, it contains the current value for the statistics counters
1985  *   enabled for the current node.
1986  * @param[out] stats_mask
1987  *   When non-NULL, it contains the mask of statistics counter types that are
1988  *   currently enabled for this node, indicating which of the counters
1989  *   retrieved with the *stats* structure are valid.
1990  * @param[in] clear
1991  *   When this parameter has a non-zero value, the statistics counters are
1992  *   cleared (i.e. set to zero) immediately after they have been read,
1993  *   otherwise the statistics counters are left untouched.
1994  * @param[out] error
1995  *   Error details. Filled in only on error, when not NULL.
1996  * @return
1997  *   0 on success, non-zero error code otherwise.
1998  *
1999  * @see enum rte_tm_stats_type
2000  */
2001 __rte_experimental
2002 int
2003 rte_tm_node_stats_read(uint16_t port_id,
2004         uint32_t node_id,
2005         struct rte_tm_node_stats *stats,
2006         uint64_t *stats_mask,
2007         int clear,
2008         struct rte_tm_error *error);
2009
2010 /**
2011  * Traffic manager packet marking - VLAN DEI (IEEE 802.1Q)
2012  *
2013  * IEEE 802.1p maps the traffic class to the VLAN Priority Code Point (PCP)
2014  * field (3 bits), while IEEE 802.1q maps the drop priority to the VLAN Drop
2015  * Eligible Indicator (DEI) field (1 bit), which was previously named Canonical
2016  * Format Indicator (CFI).
2017  *
2018  * All VLAN frames of a given color get their DEI bit set if marking is enabled
2019  * for this color; otherwise, their DEI bit is left as is (either set or not).
2020  *
2021  * @param[in] port_id
2022  *   The port identifier of the Ethernet device.
2023  * @param[in] mark_green
2024  *   Set to non-zero value to enable marking of green packets and to zero to
2025  *   disable it.
2026  * @param[in] mark_yellow
2027  *   Set to non-zero value to enable marking of yellow packets and to zero to
2028  *   disable it.
2029  * @param[in] mark_red
2030  *   Set to non-zero value to enable marking of red packets and to zero to
2031  *   disable it.
2032  * @param[out] error
2033  *   Error details. Filled in only on error, when not NULL.
2034  * @return
2035  *   0 on success, non-zero error code otherwise.
2036  *
2037  * @see struct rte_tm_capabilities::mark_vlan_dei_supported
2038  */
2039 __rte_experimental
2040 int
2041 rte_tm_mark_vlan_dei(uint16_t port_id,
2042         int mark_green,
2043         int mark_yellow,
2044         int mark_red,
2045         struct rte_tm_error *error);
2046
2047 /**
2048  * Traffic manager packet marking - IPv4 / IPv6 ECN (IETF RFC 3168)
2049  *
2050  * IETF RFCs 2474 and 3168 reorganize the IPv4 Type of Service (TOS) field
2051  * (8 bits) and the IPv6 Traffic Class (TC) field (8 bits) into Differentiated
2052  * Services Codepoint (DSCP) field (6 bits) and Explicit Congestion
2053  * Notification (ECN) field (2 bits). The DSCP field is typically used to
2054  * encode the traffic class and/or drop priority (RFC 2597), while the ECN
2055  * field is used by RFC 3168 to implement a congestion notification mechanism
2056  * to be leveraged by transport layer protocols such as TCP and SCTP that have
2057  * congestion control mechanisms.
2058  *
2059  * When congestion is experienced, as alternative to dropping the packet,
2060  * routers can change the ECN field of input packets from 2'b01 or 2'b10
2061  * (values indicating that source endpoint is ECN-capable) to 2'b11 (meaning
2062  * that congestion is experienced). The destination endpoint can use the
2063  * ECN-Echo (ECE) TCP flag to relay the congestion indication back to the
2064  * source endpoint, which acknowledges it back to the destination endpoint with
2065  * the Congestion Window Reduced (CWR) TCP flag.
2066  *
2067  * All IPv4/IPv6 packets of a given color with ECN set to 2’b01 or 2’b10
2068  * carrying TCP or SCTP have their ECN set to 2’b11 if the marking feature is
2069  * enabled for the current color, otherwise the ECN field is left as is.
2070  *
2071  * @param[in] port_id
2072  *   The port identifier of the Ethernet device.
2073  * @param[in] mark_green
2074  *   Set to non-zero value to enable marking of green packets and to zero to
2075  *   disable it.
2076  * @param[in] mark_yellow
2077  *   Set to non-zero value to enable marking of yellow packets and to zero to
2078  *   disable it.
2079  * @param[in] mark_red
2080  *   Set to non-zero value to enable marking of red packets and to zero to
2081  *   disable it.
2082  * @param[out] error
2083  *   Error details. Filled in only on error, when not NULL.
2084  * @return
2085  *   0 on success, non-zero error code otherwise.
2086  *
2087  * @see struct rte_tm_capabilities::mark_ip_ecn_tcp_supported
2088  * @see struct rte_tm_capabilities::mark_ip_ecn_sctp_supported
2089  */
2090 __rte_experimental
2091 int
2092 rte_tm_mark_ip_ecn(uint16_t port_id,
2093         int mark_green,
2094         int mark_yellow,
2095         int mark_red,
2096         struct rte_tm_error *error);
2097
2098 /**
2099  * Traffic manager packet marking - IPv4 / IPv6 DSCP (IETF RFC 2597)
2100  *
2101  * IETF RFC 2597 maps the traffic class and the drop priority to the IPv4/IPv6
2102  * Differentiated Services Codepoint (DSCP) field (6 bits). Here are the DSCP
2103  * values proposed by this RFC:
2104  *
2105  * <pre>                   Class 1    Class 2    Class 3    Class 4   </pre>
2106  * <pre>                 +----------+----------+----------+----------+</pre>
2107  * <pre>Low Drop Prec    |  001010  |  010010  |  011010  |  100010  |</pre>
2108  * <pre>Medium Drop Prec |  001100  |  010100  |  011100  |  100100  |</pre>
2109  * <pre>High Drop Prec   |  001110  |  010110  |  011110  |  100110  |</pre>
2110  * <pre>                 +----------+----------+----------+----------+</pre>
2111  *
2112  * There are 4 traffic classes (classes 1 .. 4) encoded by DSCP bits 1 and 2,
2113  * as well as 3 drop priorities (low/medium/high) encoded by DSCP bits 3 and 4.
2114  *
2115  * All IPv4/IPv6 packets have their color marked into DSCP bits 3 and 4 as
2116  * follows: green mapped to Low Drop Precedence (2’b01), yellow to Medium
2117  * (2’b10) and red to High (2’b11). Marking needs to be explicitly enabled
2118  * for each color; when not enabled for a given color, the DSCP field of all
2119  * packets with that color is left as is.
2120  *
2121  * @param[in] port_id
2122  *   The port identifier of the Ethernet device.
2123  * @param[in] mark_green
2124  *   Set to non-zero value to enable marking of green packets and to zero to
2125  *   disable it.
2126  * @param[in] mark_yellow
2127  *   Set to non-zero value to enable marking of yellow packets and to zero to
2128  *   disable it.
2129  * @param[in] mark_red
2130  *   Set to non-zero value to enable marking of red packets and to zero to
2131  *   disable it.
2132  * @param[out] error
2133  *   Error details. Filled in only on error, when not NULL.
2134  * @return
2135  *   0 on success, non-zero error code otherwise.
2136  *
2137  * @see struct rte_tm_capabilities::mark_ip_dscp_supported
2138  */
2139 __rte_experimental
2140 int
2141 rte_tm_mark_ip_dscp(uint16_t port_id,
2142         int mark_green,
2143         int mark_yellow,
2144         int mark_red,
2145         struct rte_tm_error *error);
2146
2147 #ifdef __cplusplus
2148 }
2149 #endif
2150
2151 #endif /* __INCLUDE_RTE_TM_H__ */