[v5,4/7] ethdev: add meter color mark flow action
Checks
Commit Message
Create a new Flow API action: METER_MARK.
It Meters a packet stream and marks its packets with colors.
The marking is done on a metadata, not on a packet field.
Unlike the METER action, it performs no policing at all.
A user has the flexibility to create any policies with the help of
the METER_COLOR item later, only meter profile is mandatory here.
Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
---
doc/guides/prog_guide/rte_flow.rst | 25 ++++++++++++
doc/guides/rel_notes/release_22_11.rst | 1 +
lib/ethdev/rte_flow.c | 1 +
lib/ethdev/rte_flow.h | 56 ++++++++++++++++++++++++++
4 files changed, 83 insertions(+)
@@ -3411,6 +3411,31 @@ This action is meant to use the same structure as `Action: PORT_REPRESENTOR`_.
See also `Item: REPRESENTED_PORT`_.
+Action: ``METER_MARK``
+^^^^^^^^^^^^^^^^^^^^^^
+
+Meters a packet stream and marks its packets with colors.
+
+Unlike the ``METER`` action, policing is optional and may be
+performed later with the help of the ``METER_COLOR`` item.
+The profile and/or policy objects have to be created
+using the rte_mtr_profile_add()/rte_mtr_policy_add() API.
+Pointers to these objects are used as action parameters
+and need to be retrieved using the rte_mtr_profile_get() API
+and rte_mtr_policy_get() API respectively.
+
+.. _table_rte_flow_action_meter_mark:
+
+.. table:: METER_MARK
+
+ +------------------+----------------------+
+ | Field | Value |
+ +==================+======================+
+ | ``profile`` | Meter profile object |
+ +------------------+----------------------+
+ | ``policy`` | Meter policy object |
+ +------------------+----------------------+
+
Negative types
~~~~~~~~~~~~~~
@@ -60,6 +60,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 get a pointer to profile/policy by their ID.
+ * Added METER_MARK action for Metering with lockless profile/policy access.
* **Updated Wangxun ngbe driver.**
@@ -260,6 +260,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {
MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)),
MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct rte_flow_action_ethdev)),
MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct rte_flow_action_ethdev)),
+ MK_FLOW_ACTION(METER_MARK, sizeof(struct rte_flow_action_meter_mark)),
};
int
@@ -2903,6 +2903,14 @@ enum rte_flow_action_type {
* @see struct rte_flow_action_ethdev
*/
RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
+
+ /**
+ * Traffic metering and marking (MTR).
+ *
+ * @see struct rte_flow_action_meter_mark
+ * See file rte_mtr.h for MTR profile object configuration.
+ */
+ RTE_FLOW_ACTION_TYPE_METER_MARK,
};
/**
@@ -3774,6 +3782,54 @@ struct rte_flow_action_modify_field {
uint32_t width; /**< Number of bits to use from a source field. */
};
+/**
+ * RTE_FLOW_ACTION_TYPE_METER_MARK
+ *
+ * Traffic metering and marking (MTR).
+ *
+ * Meters a packet stream and marks its packets either
+ * green, yellow, or red according to the specified profile.
+ * The policy is optional and may be specified for defining
+ * subsequent actions based on a color assigned by MTR.
+ * Alternatively, the METER_COLOR item may be used for this.
+ */
+struct rte_flow_action_meter_mark {
+
+ /**< Profile config retrieved with rte_mtr_profile_get(). */
+ struct rte_flow_meter_profile *profile;
+ /**< Policy config retrieved with rte_mtr_policy_get(). */
+ struct rte_flow_meter_policy *policy;
+ /** Metering mode: 0 - Color-Blind, 1 - Color-Aware. */
+ int color_mode;
+ /** Initial Color applied to packets in Color-Aware mode. */
+ enum rte_color init_color;
+ /** Metering state: 0 - Disabled, 1 - Enabled. */
+ int state;
+};
+
+/**
+ * RTE_FLOW_ACTION_TYPE_METER_MARK
+ *
+ * Wrapper structure for the context update interface.
+ *
+ */
+struct rte_flow_update_meter_mark {
+ /** New meter_mark parameters to be updated. */
+ struct rte_flow_action_meter_mark meter_mark;
+ /** The profile will be updated. */
+ uint32_t profile_valid:1;
+ /** The policy will be updated. */
+ uint32_t policy_valid:1;
+ /** The color mode will be updated. */
+ uint32_t color_mode_valid:1;
+ /** The initial color will be updated. */
+ uint32_t init_color_valid:1;
+ /** The meter state will be updated. */
+ uint32_t state_valid:1;
+ /** Reserved bits for the future usage. */
+ uint32_t reserved:27;
+};
+
/* Mbuf dynamic field offset for metadata. */
extern int32_t rte_flow_dynf_metadata_offs;