diff mbox series

[v2,1/4] ethdev: add packet mode in meter profile structure

Message ID 20210408035849.1755493-2-lizh@nvidia.com (mailing list archive)
State Superseded
Delegated to: Ferruh Yigit
Headers show
Series Support PPS(packet per second) on meter | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Li Zhang April 8, 2021, 3:58 a.m. UTC
Currently meter algorithms only supports rate is bytes per second(BPS).
Add packet_mode flag in meter profile parameters data structure.
So that it can meter traffic by packet per second.

When packet_mode is 0, the profile rates and bucket sizes are
specified in bytes per second and bytes
when packet_mode is not 0, the profile rates and bucket sizes are
specified in packets and packets per second.

The below structure will be extended:
rte_mtr_meter_profile
rte_mtr_capabilities

Signed-off-by: Li Zhang <lizh@nvidia.com>
---
 doc/guides/rel_notes/release_21_05.rst |  7 ++
 lib/librte_ethdev/rte_mtr.h            | 90 ++++++++++++++++++++++----
 2 files changed, 86 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst
index 3c76148b11..c9c15794ad 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -119,6 +119,13 @@  New Features
   * Added command to display Rx queue used descriptor count.
     ``show port (port_id) rxq (queue_id) desc used count``
 
+* **Added support for meter PPS profile.**
+
+  Currently meter algorithms only supports bytes per second(BPS).
+  Add packet_mode in the meter profile parameters data structures
+  to support packet per second (PPS) mode.
+  So that it can meter traffic by packet per second.
+  Packet_mode must be 0 when it is bytes mode.
 
 Removed Items
 -------------
diff --git a/lib/librte_ethdev/rte_mtr.h b/lib/librte_ethdev/rte_mtr.h
index e1dc59eb06..890b4ac344 100644
--- a/lib/librte_ethdev/rte_mtr.h
+++ b/lib/librte_ethdev/rte_mtr.h
@@ -133,46 +133,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;
 };
 
 /**
@@ -333,6 +358,48 @@  struct rte_mtr_capabilities {
 	 */
 	int color_aware_trtcm_rfc4115_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
 	 */
@@ -350,6 +417,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,