ethdev: add packet mode in meter profile structure
[dpdk.git] / lib / librte_ethdev / rte_mtr.h
index c4819b2..ceb5dcb 100644 (file)
@@ -1,35 +1,7 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright 2017 Intel Corporation
- *   Copyright 2017 NXP
- *   Copyright 2017 Cavium
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above copyright
- *       notice, this list of conditions and the following disclaimer in
- *       the documentation and/or other materials provided with the
- *       distribution.
- *     * Neither the name of Intel Corporation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2017 Intel Corporation
+ * Copyright 2017 NXP
+ * Copyright 2017 Cavium
  */
 
 #ifndef __INCLUDE_RTE_MTR_H__
 #include <stdint.h>
 #include <rte_compat.h>
 #include <rte_common.h>
+#include <rte_meter.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/**
- * Color
- */
-enum rte_mtr_color {
-       RTE_MTR_GREEN = 0, /**< Green */
-       RTE_MTR_YELLOW, /**< Yellow */
-       RTE_MTR_RED, /**< Red */
-       RTE_MTR_COLORS /**< Number of colors. */
-};
-
 /**
  * Statistics counter type
  */
@@ -125,10 +88,10 @@ enum rte_mtr_stats_type {
  */
 struct rte_mtr_stats {
        /** Number of packets passed by the policer (per color). */
-       uint64_t n_pkts[RTE_MTR_COLORS];
+       uint64_t n_pkts[RTE_COLORS];
 
        /** Number of bytes passed by the policer (per color). */
-       uint64_t n_bytes[RTE_MTR_COLORS];
+       uint64_t n_bytes[RTE_COLORS];
 
        /** Number of packets dropped by the policer. */
        uint64_t n_pkts_dropped;
@@ -169,46 +132,71 @@ struct rte_mtr_meter_profile {
        union {
                /** Items only valid when *alg* is set to srTCM - RFC 2697. */
                struct {
-                       /** Committed Information Rate (CIR) (bytes/second). */
+                       /**
+                        * Committed Information Rate (CIR)
+                        * (bytes per second or packets per second).
+                        */
                        uint64_t cir;
 
-                       /** Committed Burst Size (CBS) (bytes). */
+                       /** Committed Burst Size (CBS) (bytes or packets). */
                        uint64_t cbs;
 
-                       /** Excess Burst Size (EBS) (bytes). */
+                       /** Excess Burst Size (EBS) (bytes or packets). */
                        uint64_t ebs;
                } srtcm_rfc2697;
 
                /** Items only valid when *alg* is set to trTCM - RFC 2698. */
                struct {
-                       /** Committed Information Rate (CIR) (bytes/second). */
+                       /**
+                        * Committed Information Rate (CIR)
+                        * (bytes per second or packets per second).
+                        */
                        uint64_t cir;
 
-                       /** Peak Information Rate (PIR) (bytes/second). */
+                       /**
+                        * Peak Information Rate (PIR)
+                        * (bytes per second or packets per second).
+                        */
                        uint64_t pir;
 
-                       /** Committed Burst Size (CBS) (byes). */
+                       /** Committed Burst Size (CBS) (bytes or packets). */
                        uint64_t cbs;
 
-                       /** Peak Burst Size (PBS) (bytes). */
+                       /** Peak Burst Size (PBS) (bytes or packets). */
                        uint64_t pbs;
                } trtcm_rfc2698;
 
                /** Items only valid when *alg* is set to trTCM - RFC 4115. */
                struct {
-                       /** Committed Information Rate (CIR) (bytes/second). */
+                       /**
+                        * Committed Information Rate (CIR)
+                        * (bytes per second or packets per second).
+                        */
                        uint64_t cir;
 
-                       /** Excess Information Rate (EIR) (bytes/second). */
+                       /**
+                        * Excess Information Rate (EIR)
+                        * (bytes per second or packets per second).
+                        */
                        uint64_t eir;
 
-                       /** Committed Burst Size (CBS) (byes). */
+                       /** Committed Burst Size (CBS) (bytes or packets). */
                        uint64_t cbs;
 
-                       /** Excess Burst Size (EBS) (bytes). */
+                       /** Excess Burst Size (EBS) (bytes or packets). */
                        uint64_t ebs;
                } trtcm_rfc4115;
        };
+
+       /**
+        * When zero, the byte mode is enabled for the current profile, so the
+        * *rate* and *size* fields are specified in bytes per second
+        * and bytes, respectively.
+        * When non-zero, the packet mode is enabled for the current profile,
+        * so the *rate* and *size* fields are specified in packets per second
+        * and packets, respectively.
+        */
+       int packet_mode;
 };
 
 /**
@@ -260,7 +248,7 @@ struct rte_mtr_params {
         * at least one yellow or red color element, then the color aware mode
         * is configured.
         */
-       enum rte_mtr_color *dscp_table;
+       enum rte_color *dscp_table;
 
        /** Non-zero to enable the meter, zero to disable the meter at the time
         * of MTR object creation. Ignored when the meter profile indicated by
@@ -270,7 +258,7 @@ struct rte_mtr_params {
        int meter_enable;
 
        /** Policer actions (per meter output color). */
-       enum rte_mtr_policer_action action[RTE_MTR_COLORS];
+       enum rte_mtr_policer_action action[RTE_COLORS];
 
        /** Set of stats counters to be enabled.
         * @see enum rte_mtr_stats_type
@@ -391,6 +379,48 @@ struct rte_mtr_capabilities {
         */
        int policer_action_drop_supported;
 
+       /**
+        * srTCM rfc2697 byte mode supported.
+        * When non-zero, it indicates that byte mode is supported for
+        * the srTCM RFC 2697 metering algorithm.
+        */
+       int srtcm_rfc2697_byte_mode_supported;
+
+       /**
+        * srTCM rfc2697 packet mode supported.
+        * When non-zero, it indicates that packet mode is supported for
+        * the srTCM RFC 2697 metering algorithm.
+        */
+       int srtcm_rfc2697_packet_mode_supported;
+
+       /**
+        * trTCM rfc2698 byte mode supported.
+        * When non-zero, it indicates that byte mode is supported for
+        * the trTCM RFC 2698 metering algorithm.
+        */
+       int trtcm_rfc2698_byte_mode_supported;
+
+       /**
+        * trTCM rfc2698 packet mode supported.
+        * When non-zero, it indicates that packet mode is supported for
+        * the trTCM RFC 2698 metering algorithm.
+        */
+       int trtcm_rfc2698_packet_mode_supported;
+
+       /**
+        * trTCM rfc4115 byte mode supported.
+        * When non-zero, it indicates that byte mode is supported for
+        * the trTCM RFC 4115 metering algorithm.
+        */
+       int trtcm_rfc4115_byte_mode_supported;
+
+       /**
+        * trTCM rfc4115 packet mode supported.
+        * When non-zero, it indicates that packet mode is supported for
+        * the trTCM RFC 4115 metering algorithm.
+        */
+       int trtcm_rfc4115_packet_mode_supported;
+
        /** Set of supported statistics counter types.
         * @see enum rte_mtr_stats_type
         */
@@ -408,6 +438,7 @@ enum rte_mtr_error_type {
        RTE_MTR_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
        RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
        RTE_MTR_ERROR_TYPE_METER_PROFILE,
+       RTE_MTR_ERROR_TYPE_METER_PROFILE_PACKET_MODE,
        RTE_MTR_ERROR_TYPE_MTR_ID,
        RTE_MTR_ERROR_TYPE_MTR_PARAMS,
        RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN,
@@ -447,7 +478,8 @@ struct rte_mtr_error {
  * @return
  *   0 on success, non-zero error code otherwise.
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_capabilities_get(uint16_t port_id,
        struct rte_mtr_capabilities *cap,
        struct rte_mtr_error *error);
@@ -470,7 +502,8 @@ rte_mtr_capabilities_get(uint16_t port_id,
  * @return
  *   0 on success, non-zero error code otherwise.
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_meter_profile_add(uint16_t port_id,
        uint32_t meter_profile_id,
        struct rte_mtr_meter_profile *profile,
@@ -491,7 +524,8 @@ rte_mtr_meter_profile_add(uint16_t port_id,
  * @return
  *   0 on success, non-zero error code otherwise.
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_meter_profile_delete(uint16_t port_id,
        uint32_t meter_profile_id,
        struct rte_mtr_error *error);
@@ -519,7 +553,8 @@ rte_mtr_meter_profile_delete(uint16_t port_id,
  *
  * @see enum rte_flow_action_type::RTE_FLOW_ACTION_TYPE_METER
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_create(uint16_t port_id,
        uint32_t mtr_id,
        struct rte_mtr_params *params,
@@ -542,7 +577,8 @@ rte_mtr_create(uint16_t port_id,
  * @return
  *   0 on success, non-zero error code otherwise.
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_destroy(uint16_t port_id,
        uint32_t mtr_id,
        struct rte_mtr_error *error);
@@ -569,7 +605,8 @@ rte_mtr_destroy(uint16_t port_id,
  * @return
  *   0 on success, non-zero error code otherwise.
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_meter_disable(uint16_t port_id,
        uint32_t mtr_id,
        struct rte_mtr_error *error);
@@ -590,7 +627,8 @@ rte_mtr_meter_disable(uint16_t port_id,
  * @return
  *   0 on success, non-zero error code otherwise.
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_meter_enable(uint16_t port_id,
        uint32_t mtr_id,
        struct rte_mtr_error *error);
@@ -609,7 +647,8 @@ rte_mtr_meter_enable(uint16_t port_id,
  * @return
  *   0 on success, non-zero error code otherwise.
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_meter_profile_update(uint16_t port_id,
        uint32_t mtr_id,
        uint32_t meter_profile_id,
@@ -633,10 +672,11 @@ rte_mtr_meter_profile_update(uint16_t port_id,
  * @return
  *   0 on success, non-zero error code otherwise.
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_meter_dscp_table_update(uint16_t port_id,
        uint32_t mtr_id,
-       enum rte_mtr_color *dscp_table,
+       enum rte_color *dscp_table,
        struct rte_mtr_error *error);
 
 /**
@@ -659,7 +699,8 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
  * @return
  *   0 on success, non-zero error code otherwise.
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_policer_actions_update(uint16_t port_id,
        uint32_t mtr_id,
        uint32_t action_mask,
@@ -684,7 +725,8 @@ rte_mtr_policer_actions_update(uint16_t port_id,
  *
  * @see enum rte_mtr_stats_type
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_stats_update(uint16_t port_id,
        uint32_t mtr_id,
        uint64_t stats_mask,
@@ -715,7 +757,8 @@ rte_mtr_stats_update(uint16_t port_id,
  *
  * @see enum rte_mtr_stats_type
  */
-int __rte_experimental
+__rte_experimental
+int
 rte_mtr_stats_read(uint16_t port_id,
        uint32_t mtr_id,
        struct rte_mtr_stats *stats,