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