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