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