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