[4/4] ethdev: add meter color mark flow action

Message ID 20220518043459.1281590-5-akozyrev@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Andrew Rybchenko
Headers
Series ethdev: separate metering and marking from policing |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail Compilation issues
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build fail github build: failed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS

Commit Message

Alexander Kozyrev May 18, 2022, 4:34 a.m. UTC
  Create a new Flow API action: METER_MARK.
It Meters an IP packet stream and marks its packets with colors.
Unlike the METER action, it performs no policing at all.
An user has the flexibility to create any policies with the help of
the METER_COLOR item later, only meter profile is required now.

Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
---
 doc/guides/prog_guide/rte_flow.rst     | 26 +++++++++++++++++++
 doc/guides/rel_notes/release_22_07.rst |  1 +
 lib/ethdev/rte_flow.h                  | 36 ++++++++++++++++++++++++++
 3 files changed, 63 insertions(+)
  

Patch

diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst
index 1877d4b9b5..f5a2150f86 100644
--- a/doc/guides/prog_guide/rte_flow.rst
+++ b/doc/guides/prog_guide/rte_flow.rst
@@ -3411,6 +3411,32 @@  This action is meant to use the same structure as `Action: PORT_REPRESENTOR`_.
 
 See also `Item: REPRESENTED_PORT`_.
 
+Action: ``METER_MARK``
+^^^^^^^^^^^^^^^^^^^^^^
+
+Meters an IP packet stream and marks its packets with colors.
+
+Applies a stage of metering only. Unlike the ``METER`` action,
+no policing is performed and the ``METER_COLOR`` item may be used later.
+The profle object has to be created using the rte_mtr_profile_create() API.
+The ID of the profile object may be specified as an action parameter.
+Or PMD-specific profile configuration may be used to save the time to calculate
+the profile configuration via rte_mtr_profile_calculate() API.
+
+.. _table_rte_flow_action_meter_mark:
+
+.. table:: METER_MARK
+
+   +------------------+----------------------+
+   | Field            | Value                |
+   +==================+======================+
+   | ``mode``         | Meter profile mode   |
+   +------------------+----------------------+
+   | ``profile_id``   | Meter profile ID     |
+   +------------------+----------------------+
+   | ``profile_cfg``  | Meter profile config |
+   +------------------+----------------------+
+
 Negative types
 ~~~~~~~~~~~~~~
 
diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst
index 5f19223663..591ac7cfba 100644
--- a/doc/guides/rel_notes/release_22_07.rst
+++ b/doc/guides/rel_notes/release_22_07.rst
@@ -65,6 +65,7 @@  New Features
   * Added METER_COLOR item to match Color Marker set by a Meter.
   * Added ability to set Color Marker via modify_field Flow API.
   * Added Meter API to calculate a profile configuration values.
+  * Added METER_MARK action to perform Meter color marking only.
 
 * **Updated Intel iavf driver.**
 
diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
index 817df34ed0..ac3a3b338f 100644
--- a/lib/ethdev/rte_flow.h
+++ b/lib/ethdev/rte_flow.h
@@ -2906,6 +2906,15 @@  enum rte_flow_action_type {
 	 * @see struct rte_flow_action_ethdev
 	 */
 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+	/**
+	 * Traffic metering and marking (MTR).
+	 * the entity represented by the given ethdev.
+	 *
+	 * @see struct rte_flow_action_meter_mark
+	 * See file rte_mtr.h for MTR profile object configuration.
+	 */
+	RTE_FLOW_ACTION_TYPE_METER_MARK,
 };
 
 /**
@@ -3775,6 +3784,33 @@  struct rte_flow_action_modify_field {
 	uint32_t width; /**< Number of bits to use from a source field. */
 };
 
+/**
+ * Meter profile mode for METER_MARK action.
+ */
+enum rte_flow_meter_profile_mode {
+	RTE_FLOW_METER_PROFILE_ID = 0, /**< Use profile ID. */
+	RTE_FLOW_METER_PROFILE_CFG,    /**< Use profile config. */
+};
+
+/**
+ * RTE_FLOW_ACTION_TYPE_METER_MARK
+ *
+ * Traffic metering and marking (MTR).
+ *
+ * Meters an IP packet stream and marks its packets either
+ * green, yellow, or red according to the specified profile.
+ */
+struct rte_flow_action_meter_mark {
+	enum rte_flow_meter_profile_mode mode; /** Meter profile mode. */
+	RTE_STD_C11
+	union {
+		/**< Profile ID create with rte_mtr_profile_create(). */
+		uint32_t profile_id;
+		/**< Profile config calculated with rte_mtr_profile_calculate(). */
+		void *profile_cfg;
+	};
+};
+
 /* Mbuf dynamic field offset for metadata. */
 extern int32_t rte_flow_dynf_metadata_offs;