eventdev: fix doxygen comment
[dpdk.git] / lib / librte_ethdev / rte_mtr.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright 2017 Intel Corporation
5  *   Copyright 2017 NXP
6  *   Copyright 2017 Cavium
7  *
8  *   Redistribution and use in source and binary forms, with or without
9  *   modification, are permitted provided that the following conditions
10  *   are met:
11  *
12  *     * Redistributions of source code must retain the above copyright
13  *       notice, this list of conditions and the following disclaimer.
14  *     * Redistributions in binary form must reproduce the above copyright
15  *       notice, this list of conditions and the following disclaimer in
16  *       the documentation and/or other materials provided with the
17  *       distribution.
18  *     * Neither the name of Intel Corporation nor the names of its
19  *       contributors may be used to endorse or promote products derived
20  *       from this software without specific prior written permission.
21  *
22  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 #ifndef __INCLUDE_RTE_MTR_H__
36 #define __INCLUDE_RTE_MTR_H__
37
38 /**
39  * @file
40  * RTE Generic Traffic Metering and Policing API
41  *
42  * This interface provides the ability to configure the traffic metering and
43  * policing (MTR) in a generic way.
44  *
45  * The processing done for each input packet hitting a MTR object is:
46  *    A) Traffic metering: The packet is assigned a color (the meter output
47  *       color), based on the previous history of the flow reflected in the
48  *       current state of the MTR object, according to the specific traffic
49  *       metering algorithm. The traffic metering algorithm can typically work
50  *       in color aware mode, in which case the input packet already has an
51  *       initial color (the input color), or in color blind mode, which is
52  *       equivalent to considering all input packets initially colored as green.
53  *    B) Policing: There is a separate policer action configured for each meter
54  *       output color, which can:
55  *          a) Drop the packet.
56  *          b) Keep the same packet color: the policer output color matches the
57  *             meter output color (essentially a no-op action).
58  *          c) Recolor the packet: the policer output color is different than
59  *             the meter output color.
60  *       The policer output color is the output color of the packet, which is
61  *       set in the packet meta-data (i.e. struct rte_mbuf::sched::color).
62  *    C) Statistics: The set of counters maintained for each MTR object is
63  *       configurable and subject to the implementation support. This set
64  *       includes the number of packets and bytes dropped or passed for each
65  *       output color.
66  *
67  * Once successfully created, an MTR object is linked to one or several flows
68  * through the meter action of the flow API.
69  *    A) Whether an MTR object is private to a flow or potentially shared by
70  *       several flows has to be specified at creation time.
71  *    B) Several meter actions can be potentially registered for the same flow.
72  *
73  * @warning
74  * @b EXPERIMENTAL: this API may change without prior notice
75  */
76 #include <stdint.h>
77 #include <rte_compat.h>
78 #include <rte_common.h>
79 #include <rte_meter.h>
80
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84
85 /**
86  * Statistics counter type
87  */
88 enum rte_mtr_stats_type {
89         /** Number of packets passed as green by the policer. */
90         RTE_MTR_STATS_N_PKTS_GREEN = 1 << 0,
91
92         /** Number of packets passed as yellow by the policer. */
93         RTE_MTR_STATS_N_PKTS_YELLOW = 1 << 1,
94
95         /** Number of packets passed as red by the policer. */
96         RTE_MTR_STATS_N_PKTS_RED = 1 << 2,
97
98         /** Number of packets dropped by the policer. */
99         RTE_MTR_STATS_N_PKTS_DROPPED = 1 << 3,
100
101         /** Number of bytes passed as green by the policer. */
102         RTE_MTR_STATS_N_BYTES_GREEN = 1 << 4,
103
104         /** Number of bytes passed as yellow by the policer. */
105         RTE_MTR_STATS_N_BYTES_YELLOW = 1 << 5,
106
107         /** Number of bytes passed as red by the policer. */
108         RTE_MTR_STATS_N_BYTES_RED = 1 << 6,
109
110         /** Number of bytes dropped by the policer. */
111         RTE_MTR_STATS_N_BYTES_DROPPED = 1 << 7,
112 };
113
114 /**
115  * Statistics counters
116  */
117 struct rte_mtr_stats {
118         /** Number of packets passed by the policer (per color). */
119         uint64_t n_pkts[RTE_COLORS];
120
121         /** Number of bytes passed by the policer (per color). */
122         uint64_t n_bytes[RTE_COLORS];
123
124         /** Number of packets dropped by the policer. */
125         uint64_t n_pkts_dropped;
126
127         /** Number of bytes passed by the policer. */
128         uint64_t n_bytes_dropped;
129 };
130
131 /**
132  * Traffic metering algorithms
133  */
134 enum rte_mtr_algorithm {
135         /** No traffic metering performed, the output color is the same as the
136          * input color for every input packet. The meter of the MTR object is
137          * working in pass-through mode, having same effect as meter disable.
138          * @see rte_mtr_meter_disable()
139          */
140         RTE_MTR_NONE = 0,
141
142         /** Single Rate Three Color Marker (srTCM) - IETF RFC 2697. */
143         RTE_MTR_SRTCM_RFC2697,
144
145         /** Two Rate Three Color Marker (trTCM) - IETF RFC 2698. */
146         RTE_MTR_TRTCM_RFC2698,
147
148         /** Two Rate Three Color Marker (trTCM) - IETF RFC 4115. */
149         RTE_MTR_TRTCM_RFC4115,
150 };
151
152 /**
153  * Meter profile
154  */
155 struct rte_mtr_meter_profile {
156         /** Traffic metering algorithm. */
157         enum rte_mtr_algorithm alg;
158
159         RTE_STD_C11
160         union {
161                 /** Items only valid when *alg* is set to srTCM - RFC 2697. */
162                 struct {
163                         /** Committed Information Rate (CIR) (bytes/second). */
164                         uint64_t cir;
165
166                         /** Committed Burst Size (CBS) (bytes). */
167                         uint64_t cbs;
168
169                         /** Excess Burst Size (EBS) (bytes). */
170                         uint64_t ebs;
171                 } srtcm_rfc2697;
172
173                 /** Items only valid when *alg* is set to trTCM - RFC 2698. */
174                 struct {
175                         /** Committed Information Rate (CIR) (bytes/second). */
176                         uint64_t cir;
177
178                         /** Peak Information Rate (PIR) (bytes/second). */
179                         uint64_t pir;
180
181                         /** Committed Burst Size (CBS) (byes). */
182                         uint64_t cbs;
183
184                         /** Peak Burst Size (PBS) (bytes). */
185                         uint64_t pbs;
186                 } trtcm_rfc2698;
187
188                 /** Items only valid when *alg* is set to trTCM - RFC 4115. */
189                 struct {
190                         /** Committed Information Rate (CIR) (bytes/second). */
191                         uint64_t cir;
192
193                         /** Excess Information Rate (EIR) (bytes/second). */
194                         uint64_t eir;
195
196                         /** Committed Burst Size (CBS) (byes). */
197                         uint64_t cbs;
198
199                         /** Excess Burst Size (EBS) (bytes). */
200                         uint64_t ebs;
201                 } trtcm_rfc4115;
202         };
203 };
204
205 /**
206  * Policer actions
207  */
208 enum rte_mtr_policer_action {
209         /** Recolor the packet as green. */
210         MTR_POLICER_ACTION_COLOR_GREEN = 0,
211
212         /** Recolor the packet as yellow. */
213         MTR_POLICER_ACTION_COLOR_YELLOW,
214
215         /** Recolor the packet as red. */
216         MTR_POLICER_ACTION_COLOR_RED,
217
218         /** Drop the packet. */
219         MTR_POLICER_ACTION_DROP,
220 };
221
222 /**
223  * Parameters for each traffic metering & policing object
224  *
225  * @see enum rte_mtr_stats_type
226  */
227 struct rte_mtr_params {
228         /** Meter profile ID. */
229         uint32_t meter_profile_id;
230
231         /** Meter input color in case of MTR object chaining. When non-zero: if
232          * a previous MTR object is enabled in the same flow, then the color
233          * determined by the latest MTR object in the same flow is used as the
234          * input color by the current MTR object, otherwise the current MTR
235          * object uses the *dscp_table* to determine the input color. When zero:
236          * the color determined by any previous MTR object in same flow is
237          * ignored by the current MTR object, which uses the *dscp_table* to
238          * determine the input color.
239          */
240         int use_prev_mtr_color;
241
242         /** Meter input color. When non-NULL: it points to a pre-allocated and
243          * pre-populated table with exactly 64 elements providing the input
244          * color for each value of the IPv4/IPv6 Differentiated Services Code
245          * Point (DSCP) input packet field. When NULL: it is equivalent to
246          * setting this parameter to an all-green populated table (i.e. table
247          * with all the 64 elements set to green color). The color blind mode
248          * is configured by setting *use_prev_mtr_color* to 0 and *dscp_table*
249          * to either NULL or to an all-green populated table. When
250          * *use_prev_mtr_color* is non-zero value or when *dscp_table* contains
251          * at least one yellow or red color element, then the color aware mode
252          * is configured.
253          */
254         enum rte_color *dscp_table;
255
256         /** Non-zero to enable the meter, zero to disable the meter at the time
257          * of MTR object creation. Ignored when the meter profile indicated by
258          * *meter_profile_id* is set to NONE.
259          * @see rte_mtr_meter_disable()
260          */
261         int meter_enable;
262
263         /** Policer actions (per meter output color). */
264         enum rte_mtr_policer_action action[RTE_COLORS];
265
266         /** Set of stats counters to be enabled.
267          * @see enum rte_mtr_stats_type
268          */
269         uint64_t stats_mask;
270 };
271
272 /**
273  * MTR capabilities
274  */
275 struct rte_mtr_capabilities {
276         /** Maximum number of MTR objects. */
277         uint32_t n_max;
278
279         /** Maximum number of MTR objects that can be shared by multiple flows.
280          * The value of zero indicates that shared MTR objects are not
281          * supported. The maximum value is *n_max*.
282          */
283         uint32_t n_shared_max;
284
285         /** When non-zero, this flag indicates that all the MTR objects that
286          * cannot be shared by multiple flows have identical capability set.
287          */
288         int identical;
289
290         /** When non-zero, this flag indicates that all the MTR objects that
291          * can be shared by multiple flows have identical capability set.
292          */
293         int shared_identical;
294
295         /** Maximum number of flows that can share the same MTR object. The
296          * value of zero is invalid. The value of 1 means that shared MTR
297          * objects not supported.
298          */
299         uint32_t shared_n_flows_per_mtr_max;
300
301         /** Maximum number of MTR objects that can be part of the same flow. The
302          * value of zero is invalid. The value of 1 indicates that MTR object
303          * chaining is not supported. The maximum value is *n_max*.
304          */
305         uint32_t chaining_n_mtrs_per_flow_max;
306
307         /**
308          * When non-zero, it indicates that the packet color identified by one
309          * MTR object can be used as the packet input color by any subsequent
310          * MTR object from the same flow. When zero, it indicates that the color
311          * determined by one MTR object is always ignored by any subsequent MTR
312          * object from the same flow. Only valid when MTR chaining is supported,
313          * i.e. *chaining_n_mtrs_per_flow_max* is greater than 1. When non-zero,
314          * it also means that the color aware mode is supported by at least one
315          * metering algorithm.
316          */
317         int chaining_use_prev_mtr_color_supported;
318
319         /**
320          * When non-zero, it indicates that the packet color identified by one
321          * MTR object is always used as the packet input color by any subsequent
322          * MTR object that is part of the same flow. When zero, it indicates
323          * that whether the color determined by one MTR object is either ignored
324          * or used as the packet input color by any subsequent MTR object from
325          * the same flow is individually configurable for each MTR object. Only
326          * valid when *chaining_use_prev_mtr_color_supported* is non-zero.
327          */
328         int chaining_use_prev_mtr_color_enforced;
329
330         /** Maximum number of MTR objects that can have their meter configured
331          * to run the srTCM RFC 2697 algorithm. The value of 0 indicates this
332          * metering algorithm is not supported. The maximum value is *n_max*.
333          */
334         uint32_t meter_srtcm_rfc2697_n_max;
335
336         /** Maximum number of MTR objects that can have their meter configured
337          * to run the trTCM RFC 2698 algorithm. The value of 0 indicates this
338          * metering algorithm is not supported. The maximum value is *n_max*.
339          */
340         uint32_t meter_trtcm_rfc2698_n_max;
341
342         /** Maximum number of MTR objects that can have their meter configured
343          * to run the trTCM RFC 4115 algorithm. The value of 0 indicates this
344          * metering algorithm is not supported. The maximum value is *n_max*.
345          */
346         uint32_t meter_trtcm_rfc4115_n_max;
347
348         /** Maximum traffic rate that can be metered by a single MTR object. For
349          * srTCM RFC 2697, this is the maximum CIR rate. For trTCM RFC 2698,
350          * this is the maximum PIR rate. For trTCM RFC 4115, this is the maximum
351          * value for the sum of PIR and EIR rates.
352          */
353         uint64_t meter_rate_max;
354
355         /**
356          * When non-zero, it indicates that color aware mode is supported for
357          * the srTCM RFC 2697 metering algorithm.
358          */
359         int color_aware_srtcm_rfc2697_supported;
360
361         /**
362          * When non-zero, it indicates that color aware mode is supported for
363          * the trTCM RFC 2698 metering algorithm.
364          */
365         int color_aware_trtcm_rfc2698_supported;
366
367         /**
368          * When non-zero, it indicates that color aware mode is supported for
369          * the trTCM RFC 4115 metering algorithm.
370          */
371         int color_aware_trtcm_rfc4115_supported;
372
373         /** When non-zero, it indicates that the policer packet recolor actions
374          * are supported.
375          * @see enum rte_mtr_policer_action
376          */
377         int policer_action_recolor_supported;
378
379         /** When non-zero, it indicates that the policer packet drop action is
380          * supported.
381          * @see enum rte_mtr_policer_action
382          */
383         int policer_action_drop_supported;
384
385         /** Set of supported statistics counter types.
386          * @see enum rte_mtr_stats_type
387          */
388         uint64_t stats_mask;
389 };
390
391 /**
392  * Verbose error types.
393  *
394  * Most of them provide the type of the object referenced by struct
395  * rte_mtr_error::cause.
396  */
397 enum rte_mtr_error_type {
398         RTE_MTR_ERROR_TYPE_NONE, /**< No error. */
399         RTE_MTR_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
400         RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
401         RTE_MTR_ERROR_TYPE_METER_PROFILE,
402         RTE_MTR_ERROR_TYPE_MTR_ID,
403         RTE_MTR_ERROR_TYPE_MTR_PARAMS,
404         RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN,
405         RTE_MTR_ERROR_TYPE_POLICER_ACTION_YELLOW,
406         RTE_MTR_ERROR_TYPE_POLICER_ACTION_RED,
407         RTE_MTR_ERROR_TYPE_STATS_MASK,
408         RTE_MTR_ERROR_TYPE_STATS,
409         RTE_MTR_ERROR_TYPE_SHARED,
410 };
411
412 /**
413  * Verbose error structure definition.
414  *
415  * This object is normally allocated by applications and set by PMDs, the
416  * message points to a constant string which does not need to be freed by
417  * the application, however its pointer can be considered valid only as long
418  * as its associated DPDK port remains configured. Closing the underlying
419  * device or unloading the PMD invalidates it.
420  *
421  * Both cause and message may be NULL regardless of the error type.
422  */
423 struct rte_mtr_error {
424         enum rte_mtr_error_type type; /**< Cause field and error type. */
425         const void *cause; /**< Object responsible for the error. */
426         const char *message; /**< Human-readable error message. */
427 };
428
429 /**
430  * MTR capabilities get
431  *
432  * @param[in] port_id
433  *   The port identifier of the Ethernet device.
434  * @param[out] cap
435  *   MTR capabilities. Needs to be pre-allocated and valid.
436  * @param[out] error
437  *   Error details. Filled in only on error, when not NULL.
438  * @return
439  *   0 on success, non-zero error code otherwise.
440  */
441 __rte_experimental
442 int
443 rte_mtr_capabilities_get(uint16_t port_id,
444         struct rte_mtr_capabilities *cap,
445         struct rte_mtr_error *error);
446
447 /**
448  * Meter profile add
449  *
450  * Create a new meter profile with ID set to *meter_profile_id*. The new profile
451  * is used to create one or several MTR objects.
452  *
453  * @param[in] port_id
454  *   The port identifier of the Ethernet device.
455  * @param[in] meter_profile_id
456  *   ID for the new meter profile. Needs to be unused by any of the existing
457  *   meter profiles added for the current port.
458  * @param[in] profile
459  *   Meter profile parameters. Needs to be pre-allocated and valid.
460  * @param[out] error
461  *   Error details. Filled in only on error, when not NULL.
462  * @return
463  *   0 on success, non-zero error code otherwise.
464  */
465 __rte_experimental
466 int
467 rte_mtr_meter_profile_add(uint16_t port_id,
468         uint32_t meter_profile_id,
469         struct rte_mtr_meter_profile *profile,
470         struct rte_mtr_error *error);
471
472 /**
473  * Meter profile delete
474  *
475  * Delete an existing meter profile. This operation fails when there is
476  * currently at least one user (i.e. MTR object) of this profile.
477  *
478  * @param[in] port_id
479  *   The port identifier of the Ethernet device.
480  * @param[in] meter_profile_id
481  *   Meter profile ID. Needs to be the valid.
482  * @param[out] error
483  *   Error details. Filled in only on error, when not NULL.
484  * @return
485  *   0 on success, non-zero error code otherwise.
486  */
487 __rte_experimental
488 int
489 rte_mtr_meter_profile_delete(uint16_t port_id,
490         uint32_t meter_profile_id,
491         struct rte_mtr_error *error);
492
493 /**
494  * MTR object create
495  *
496  * Create a new MTR object for the current port. This object is run as part of
497  * associated flow action for traffic metering and policing.
498  *
499  * @param[in] port_id
500  *   The port identifier of the Ethernet device.
501  * @param[in] mtr_id
502  *   MTR object ID. Needs to be unused by any of the existing MTR objects.
503  *   created for the current port.
504  * @param[in] params
505  *   MTR object params. Needs to be pre-allocated and valid.
506  * @param[in] shared
507  *   Non-zero when this MTR object can be shared by multiple flows, zero when
508  *   this MTR object can be used by a single flow.
509  * @param[out] error
510  *   Error details. Filled in only on error, when not NULL.
511  * @return
512  *   0 on success, non-zero error code otherwise.
513  *
514  * @see enum rte_flow_action_type::RTE_FLOW_ACTION_TYPE_METER
515  */
516 __rte_experimental
517 int
518 rte_mtr_create(uint16_t port_id,
519         uint32_t mtr_id,
520         struct rte_mtr_params *params,
521         int shared,
522         struct rte_mtr_error *error);
523
524 /**
525  * MTR object destroy
526  *
527  * Delete an existing MTR object. This operation fails when there is currently
528  * at least one user (i.e. flow) of this MTR object.
529  *
530  * @param[in] port_id
531  *   The port identifier of the Ethernet device.
532  * @param[in] mtr_id
533  *   MTR object ID. Needs to be valid.
534  *   created for the current port.
535  * @param[out] error
536  *   Error details. Filled in only on error, when not NULL.
537  * @return
538  *   0 on success, non-zero error code otherwise.
539  */
540 __rte_experimental
541 int
542 rte_mtr_destroy(uint16_t port_id,
543         uint32_t mtr_id,
544         struct rte_mtr_error *error);
545
546 /**
547  * MTR object meter disable
548  *
549  * Disable the meter of an existing MTR object. In disabled state, the meter of
550  * the current MTR object works in pass-through mode, meaning that for each
551  * input packet the meter output color is always the same as the input color. In
552  * particular, when the meter of the current MTR object is configured in color
553  * blind mode, the input color is always green, so the meter output color is
554  * also always green. Note that the policer and the statistics of the current
555  * MTR object are working as usual while the meter is disabled. No action is
556  * taken and this function returns successfully when the meter of the current
557  * MTR object is already disabled.
558  *
559  * @param[in] port_id
560  *   The port identifier of the Ethernet device.
561  * @param[in] mtr_id
562  *   MTR object ID.
563  * @param[out] error
564  *   Error details. Filled in only on error, when not NULL.
565  * @return
566  *   0 on success, non-zero error code otherwise.
567  */
568 __rte_experimental
569 int
570 rte_mtr_meter_disable(uint16_t port_id,
571         uint32_t mtr_id,
572         struct rte_mtr_error *error);
573
574 /**
575  * MTR object meter enable
576  *
577  * Enable the meter of an existing MTR object. If the MTR object has its meter
578  * already enabled, then no action is taken and this function returns
579  * successfully.
580  *
581  * @param[in] port_id
582  *   The port identifier of the Ethernet device.
583  * @param[in] mtr_id
584  *   MTR object ID.
585  * @param[out] error
586  *   Error details. Filled in only on error, when not NULL.
587  * @return
588  *   0 on success, non-zero error code otherwise.
589  */
590 __rte_experimental
591 int
592 rte_mtr_meter_enable(uint16_t port_id,
593         uint32_t mtr_id,
594         struct rte_mtr_error *error);
595
596 /**
597  * MTR object meter profile update
598  *
599  * @param[in] port_id
600  *   The port identifier of the Ethernet device.
601  * @param[in] mtr_id
602  *   MTR object ID. Needs to be valid.
603  * @param[in] meter_profile_id
604  *   Meter profile ID for the current MTR object. Needs to be valid.
605  * @param[out] error
606  *   Error details. Filled in only on error, when not NULL.
607  * @return
608  *   0 on success, non-zero error code otherwise.
609  */
610 __rte_experimental
611 int
612 rte_mtr_meter_profile_update(uint16_t port_id,
613         uint32_t mtr_id,
614         uint32_t meter_profile_id,
615         struct rte_mtr_error *error);
616
617 /**
618  * MTR object DSCP table update
619  *
620  * @param[in] port_id
621  *   The port identifier of the Ethernet device.
622  * @param[in] mtr_id
623  *   MTR object ID. Needs to be valid.
624  * @param[in] dscp_table
625  *   When non-NULL: it points to a pre-allocated and pre-populated table with
626  *   exactly 64 elements providing the input color for each value of the
627  *   IPv4/IPv6 Differentiated Services Code Point (DSCP) input packet field.
628  *   When NULL: it is equivalent to setting this parameter to an “all-green”
629  *   populated table (i.e. table with all the 64 elements set to green color).
630  * @param[out] error
631  *   Error details. Filled in only on error, when not NULL.
632  * @return
633  *   0 on success, non-zero error code otherwise.
634  */
635 __rte_experimental
636 int
637 rte_mtr_meter_dscp_table_update(uint16_t port_id,
638         uint32_t mtr_id,
639         enum rte_color *dscp_table,
640         struct rte_mtr_error *error);
641
642 /**
643  * MTR object policer actions update
644  *
645  * @param[in] port_id
646  *   The port identifier of the Ethernet device.
647  * @param[in] mtr_id
648  *   MTR object ID. Needs to be valid.
649  * @param[in] action_mask
650  *   Bit mask indicating which policer actions need to be updated. One or more
651  *   policer actions can be updated in a single function invocation. To update
652  *   the policer action associated with color C, bit (1 << C) needs to be set in
653  *   *action_mask* and element at position C in the *actions* array needs to be
654  *   valid.
655  * @param[in] actions
656  *   Pre-allocated and pre-populated array of policer actions.
657  * @param[out] error
658  *   Error details. Filled in only on error, when not NULL.
659  * @return
660  *   0 on success, non-zero error code otherwise.
661  */
662 __rte_experimental
663 int
664 rte_mtr_policer_actions_update(uint16_t port_id,
665         uint32_t mtr_id,
666         uint32_t action_mask,
667         enum rte_mtr_policer_action *actions,
668         struct rte_mtr_error *error);
669
670 /**
671  * MTR object enabled statistics counters update
672  *
673  * @param[in] port_id
674  *   The port identifier of the Ethernet device.
675  * @param[in] mtr_id
676  *   MTR object ID. Needs to be valid.
677  * @param[in] stats_mask
678  *   Mask of statistics counter types to be enabled for the current MTR object.
679  *   Any statistics counter type not included in this set is to be disabled for
680  *   the current MTR object.
681  * @param[out] error
682  *   Error details. Filled in only on error, when not NULL.
683  * @return
684  *   0 on success, non-zero error code otherwise.
685  *
686  * @see enum rte_mtr_stats_type
687  */
688 __rte_experimental
689 int
690 rte_mtr_stats_update(uint16_t port_id,
691         uint32_t mtr_id,
692         uint64_t stats_mask,
693         struct rte_mtr_error *error);
694
695 /**
696  * MTR object statistics counters read
697  *
698  * @param[in] port_id
699  *   The port identifier of the Ethernet device.
700  * @param[in] mtr_id
701  *   MTR object ID. Needs to be valid.
702  * @param[out] stats
703  *   When non-NULL, it contains the current value for the statistics counters
704  *   enabled for the current MTR object.
705  * @param[out] stats_mask
706  *   When non-NULL, it contains the mask of statistics counter types that are
707  *   currently enabled for this MTR object, indicating which of the counters
708  *   retrieved with the *stats* structure are valid.
709  * @param[in] clear
710  *   When this parameter has a non-zero value, the statistics counters are
711  *   cleared (i.e. set to zero) immediately after they have been read,
712  *   otherwise the statistics counters are left untouched.
713  * @param[out] error
714  *   Error details. Filled in only on error, when not NULL.
715  * @return
716  *   0 on success, non-zero error code otherwise.
717  *
718  * @see enum rte_mtr_stats_type
719  */
720 __rte_experimental
721 int
722 rte_mtr_stats_read(uint16_t port_id,
723         uint32_t mtr_id,
724         struct rte_mtr_stats *stats,
725         uint64_t *stats_mask,
726         int clear,
727         struct rte_mtr_error *error);
728
729 #ifdef __cplusplus
730 }
731 #endif
732
733 #endif /* __INCLUDE_RTE_MTR_H__ */