Skip to contentSkip to conversation

ethdev: mtr: enhance input color table features

RFC PATCH In review [email protected] 8 participants 30 messages Aug 20, 2021 – May 19, 2022

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ethdev: mtr: enhance input color table features

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

---
 lib/ethdev/rte_mtr.h | 130 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 116 insertions(+), 14 deletions(-)
lib/ethdev/rte_mtr.h +116 -14
index dc246dd7af..311e8754de 100644
@@ -213,6 +213,16 @@ struct rte_mtr_meter_policy_params {
 	const struct rte_flow_action *actions[RTE_COLORS];
 };
 
+/**
+ * Input color table
+ */
+enum rte_mtr_input_color_tbl {
+	/** DSCP based input color table */
+	RTE_MTR_INPUT_COLOR_TBL_DSCP,
+	/** VLAN based input color table */
+	RTE_MTR_INPUT_COLOR_TBL_VLAN,
+};
+
 /**
  * Parameters for each traffic metering & policing object
  *
@@ -233,20 +243,44 @@ struct rte_mtr_params {
 	 */
 	int use_prev_mtr_color;
 
-	/** Meter input color. When non-NULL: it points to a pre-allocated and
-	 * pre-populated table with exactly 64 elements providing the input
-	 * color for each value of the IPv4/IPv6 Differentiated Services Code
-	 * Point (DSCP) input packet field. When NULL: it is equivalent to
-	 * setting this parameter to an all-green populated table (i.e. table
-	 * with all the 64 elements set to green color). The color blind mode
-	 * is configured by setting *use_prev_mtr_color* to 0 and *dscp_table*
-	 * to either NULL or to an all-green populated table. When
-	 * *use_prev_mtr_color* is non-zero value or when *dscp_table* contains
-	 * at least one yellow or red color element, then the color aware mode
-	 * is configured.
-	 */
-	enum rte_color *dscp_table;
-
+	RTE_STD_C11
+	union {
+		/** Meter input color based on DSCP.
+		 * Valid when rte_mtr_input_color_tbl::tbl_selector is
+		 * set to RTE_MTR_INPUT_COLOR_TBL_DSCP.
+		 * When non-NULL: it points to a pre-allocated and pre-populated
+		 * table with exactly 64 elements providing the input color for
+		 * each value of the IPv4/IPv6 Differentiated Services Code
+		 * Point (DSCP) input packet field. When NULL:
+		 * it is equivalent to setting this parameter to an all-green
+		 * populated table (i.e. table with
+		 * all the 64 elements set to green color). The color blind mode
+		 * is configured by setting *use_prev_mtr_color* to 0 and
+		 * *dscp_table* to either NULL or to an all-green
+		 * populated table. When *use_prev_mtr_color* is non-zero value
+		 * or when *dscp_table* contains at least one yellow or
+		 * red color element, then the color aware mode is configured.
+		 * @see struct rte_mtr_capabilities::input_color_dscp_supported
+		 */
+		enum rte_color *dscp_table;
+		/** Meter input color based on VLAN.
+		 * Valid when rte_mtr_input_color_tbl::tbl_selector is
+		 * set to RTE_MTR_INPUT_COLOR_TBL_VLAN.
+		 * When non-NULL: it points to a pre-allocated and pre-populated
+		 * table with exactly 16 elements providing the input color for
+		 * each value of the DEI(1bit), PCP(3 bits) input packet field.
+		 * When NULL: it is equivalent to setting this parameter to an
+		 * all-green populated table (i.e. table with
+		 * all the 16 elements set to green color). The color blind mode
+		 * is configured by setting *use_prev_mtr_color* to 0 and
+		 * *vlan_table* to either NULL or to an all-green
+		 * populated table. When *use_prev_mtr_color* is non-zero value
+		 * or when *vlan_table* contains at least one yellow or
+		 * red color element, then the color aware mode is configured.
+		 * @see struct rte_mtr_capabilities::input_color_vlan_supported
+		 */
+		enum rte_color *vlan_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
 	 * *meter_profile_id* is set to NONE.
@@ -261,6 +295,25 @@ struct rte_mtr_params {
 
 	/** Meter policy ID. */
 	uint32_t meter_policy_id;
+
+	/** Select the input color table
+	 * @see struct rte_mtr_params::dscp_table
+	 * @see struct rte_mtr_capabilities::input_color_dscp_supported
+	 * @see struct rte_mtr_params::vlan_table
+	 * @see struct rte_mtr_capabilities::input_color_vlan_supported
+	 */
+	enum rte_mtr_input_color_tbl tbl_selector;
+	/** Fallback input color for the meter,
+	 *  when *use_prev_mtr_color* set to zero value and
+	 *  when packet is not based on selected *tbl_selector*.
+	 *  @see struct rte_mtr_capabilities::input_color_fallback_supported
+	 */
+	enum rte_color fallback_input_color;
+	/** Input color table based on inner field of selected
+	 *  of *tbl_selector*.
+	 *  @see struct rte_mtr_capabilities::input_color_inner_supported
+	 */
+	int input_color_inner_enable;
 };
 
 /**
@@ -417,6 +470,31 @@ struct rte_mtr_capabilities {
 	 * @see enum rte_mtr_stats_type
 	 */
 	uint64_t stats_mask;
+
+	/** Input color based on DSCP.
+	 * When non-zero, it indicates that driver supports input color table
+	 * based on DSCP.
+	 */
+	int input_color_dscp_supported;
+	/** Input color based on VLAN.
+	 * When non-zero, it indicates that driver supports input color table
+	 * based on VLAN.
+	 */
+	int input_color_vlan_supported;
+	/** Input color fallback support.
+	 * When non-zero, it indicates that driver supports input color
+	 * fallback.
+	 */
+	int input_color_fallback_supported;
+	/** Input color based on inner packet field.
+	 * When non-zero, it indicates that driver supports input color
+	 * based on inner field.
+	 */
+	int input_color_inner_supported;
+	 /** When non-zero, it indicates that driver supports separate
+	  * input color table for given ethdev port.
+	  */
+	int seperate_input_color_table_per_port;
 };
 
 /**
@@ -832,6 +910,30 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
+/**
+ * MTR object VLAN table update
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[in] vlan_table
+ *   When non-NULL: it points to a pre-allocated and pre-populated table with
+ *   exactly 16 elements providing the input color for each value of the
+ *   each value of the DEI(1bit), PCP(3 bits) input packet field.
+ *   When NULL: it is equivalent to setting this parameter to an "all-green"
+ *   populated table (i.e. table with all the 16 elements set to green color).
+ * @param[out] error
+ *   Error details. Filled in only on error, when not NULL.
+ * @return
+ *   0 on success, non-zero error code otherwise.
+ */
+__rte_experimental
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id,
+	uint32_t mtr_id,
+	enum rte_color *vlan_table,
+	struct rte_mtr_error *error);
 /**
  * MTR object enabled statistics counters update
  *

--
2.33.0

#1 lore raw

Ping

Quoted 189 lines · On Fri, Aug 20, 2021 at 1:56 PM <[email protected]> wrote:

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

---
 lib/ethdev/rte_mtr.h | 130 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 116 insertions(+), 14 deletions(-)
lib/ethdev/rte_mtr.h +116 -15
index dc246dd7af..311e8754de 100644
@@ -213,6 +213,16 @@ struct rte_mtr_meter_policy_params {
        const struct rte_flow_action *actions[RTE_COLORS];
 };
 
+/**
+ * Input color table
+ */
+enum rte_mtr_input_color_tbl {
+       /** DSCP based input color table */
+       RTE_MTR_INPUT_COLOR_TBL_DSCP,
+       /** VLAN based input color table */
+       RTE_MTR_INPUT_COLOR_TBL_VLAN,
+};
+
 /**
  * Parameters for each traffic metering & policing object
  *
@@ -233,20 +243,44 @@ struct rte_mtr_params {
         */
        int use_prev_mtr_color;
 
-       /** Meter input color. When non-NULL: it points to a pre-allocated and
-        * pre-populated table with exactly 64 elements providing the input
-        * color for each value of the IPv4/IPv6 Differentiated Services Code
-        * Point (DSCP) input packet field. When NULL: it is equivalent to
-        * setting this parameter to an all-green populated table (i.e. table
-        * with all the 64 elements set to green color). The color blind mode
-        * is configured by setting *use_prev_mtr_color* to 0 and *dscp_table*
-        * to either NULL or to an all-green populated table. When
-        * *use_prev_mtr_color* is non-zero value or when *dscp_table* contains
-        * at least one yellow or red color element, then the color aware mode
-        * is configured.
-        */
-       enum rte_color *dscp_table;
-
+       RTE_STD_C11
+       union {
+               /** Meter input color based on DSCP.
+                * Valid when rte_mtr_input_color_tbl::tbl_selector is
+                * set to RTE_MTR_INPUT_COLOR_TBL_DSCP.
+                * When non-NULL: it points to a pre-allocated and pre-populated
+                * table with exactly 64 elements providing the input color for
+                * each value of the IPv4/IPv6 Differentiated Services Code
+                * Point (DSCP) input packet field. When NULL:
+                * it is equivalent to setting this parameter to an all-green
+                * populated table (i.e. table with
+                * all the 64 elements set to green color). The color blind mode
+                * is configured by setting *use_prev_mtr_color* to 0 and
+                * *dscp_table* to either NULL or to an all-green
+                * populated table. When *use_prev_mtr_color* is non-zero value
+                * or when *dscp_table* contains at least one yellow or
+                * red color element, then the color aware mode is configured.
+                * @see struct rte_mtr_capabilities::input_color_dscp_supported
+                */
+               enum rte_color *dscp_table;
+               /** Meter input color based on VLAN.
+                * Valid when rte_mtr_input_color_tbl::tbl_selector is
+                * set to RTE_MTR_INPUT_COLOR_TBL_VLAN.
+                * When non-NULL: it points to a pre-allocated and pre-populated
+                * table with exactly 16 elements providing the input color for
+                * each value of the DEI(1bit), PCP(3 bits) input packet field.
+                * When NULL: it is equivalent to setting this parameter to an
+                * all-green populated table (i.e. table with
+                * all the 16 elements set to green color). The color blind mode
+                * is configured by setting *use_prev_mtr_color* to 0 and
+                * *vlan_table* to either NULL or to an all-green
+                * populated table. When *use_prev_mtr_color* is non-zero value
+                * or when *vlan_table* contains at least one yellow or
+                * red color element, then the color aware mode is configured.
+                * @see struct rte_mtr_capabilities::input_color_vlan_supported
+                */
+               enum rte_color *vlan_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
         * *meter_profile_id* is set to NONE.
@@ -261,6 +295,25 @@ struct rte_mtr_params {
 
        /** Meter policy ID. */
        uint32_t meter_policy_id;
+
+       /** Select the input color table
+        * @see struct rte_mtr_params::dscp_table
+        * @see struct rte_mtr_capabilities::input_color_dscp_supported
+        * @see struct rte_mtr_params::vlan_table
+        * @see struct rte_mtr_capabilities::input_color_vlan_supported
+        */
+       enum rte_mtr_input_color_tbl tbl_selector;
+       /** Fallback input color for the meter,
+        *  when *use_prev_mtr_color* set to zero value and
+        *  when packet is not based on selected *tbl_selector*.
+        *  @see struct rte_mtr_capabilities::input_color_fallback_supported
+        */
+       enum rte_color fallback_input_color;
+       /** Input color table based on inner field of selected
+        *  of *tbl_selector*.
+        *  @see struct rte_mtr_capabilities::input_color_inner_supported
+        */
+       int input_color_inner_enable;
 };
 
 /**
@@ -417,6 +470,31 @@ struct rte_mtr_capabilities {
         * @see enum rte_mtr_stats_type
         */
        uint64_t stats_mask;
+
+       /** Input color based on DSCP.
+        * When non-zero, it indicates that driver supports input color table
+        * based on DSCP.
+        */
+       int input_color_dscp_supported;
+       /** Input color based on VLAN.
+        * When non-zero, it indicates that driver supports input color table
+        * based on VLAN.
+        */
+       int input_color_vlan_supported;
+       /** Input color fallback support.
+        * When non-zero, it indicates that driver supports input color
+        * fallback.
+        */
+       int input_color_fallback_supported;
+       /** Input color based on inner packet field.
+        * When non-zero, it indicates that driver supports input color
+        * based on inner field.
+        */
+       int input_color_inner_supported;
+        /** When non-zero, it indicates that driver supports separate
+         * input color table for given ethdev port.
+         */
+       int seperate_input_color_table_per_port;
 };
 
 /**
@@ -832,6 +910,30 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
        enum rte_color *dscp_table,
        struct rte_mtr_error *error);
 
+/**
+ * MTR object VLAN table update
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[in] vlan_table
+ *   When non-NULL: it points to a pre-allocated and pre-populated table with
+ *   exactly 16 elements providing the input color for each value of the
+ *   each value of the DEI(1bit), PCP(3 bits) input packet field.
+ *   When NULL: it is equivalent to setting this parameter to an "all-green"
+ *   populated table (i.e. table with all the 16 elements set to green color).
+ * @param[out] error
+ *   Error details. Filled in only on error, when not NULL.
+ * @return
+ *   0 on success, non-zero error code otherwise.
+ */
+__rte_experimental
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id,
+       uint32_t mtr_id,
+       enum rte_color *vlan_table,
+       struct rte_mtr_error *error);
 /**
  * MTR object enabled statistics counters update
  *
--

2.33.0

#2 lore raw
Quoted 17 lines · Jerin Jacob

Ping

Quoted 13 lines · On Fri, Aug 20, 2021 at 1:56 PM <[email protected]> wrote:

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

Hi Cristian,

Reminder of this set, can you please review it?

#3 lore raw
In reply to [email protected]

Hi Jerin,

Quoted 219 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Friday, August 20, 2021 9:24 AM
To: Dumitrescu, Cristian <[email protected]>; Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Singh, Jasvinder <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Jerin Jacob <[email protected]>
Subject: [dpdk-dev] [RFC PATCH] ethdev: mtr: enhance input color table features

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

---
 lib/ethdev/rte_mtr.h | 130
++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 116 insertions(+), 14 deletions(-)
lib/ethdev/rte_mtr.h +10 -1
index dc246dd7af..311e8754de 100644
@@ -213,6 +213,16 @@ struct rte_mtr_meter_policy_params {
 	const struct rte_flow_action *actions[RTE_COLORS];
 };
 
+/**
+ * Input color table
+ */
+enum rte_mtr_input_color_tbl {
+	/** DSCP based input color table */
+	RTE_MTR_INPUT_COLOR_TBL_DSCP,
+	/** VLAN based input color table */
+	RTE_MTR_INPUT_COLOR_TBL_VLAN,
+};
+
 /**
  * Parameters for each traffic metering & policing object
  *
@@ -233,20 +243,44 @@ struct rte_mtr_params {
 	 */
 	int use_prev_mtr_color;
 
-	/** Meter input color. When non-NULL: it points to a pre-allocated

and

lib/ethdev/rte_mtr.h +0 -6
-	 * pre-populated table with exactly 64 elements providing the input
-	 * color for each value of the IPv4/IPv6 Differentiated Services Code
-	 * Point (DSCP) input packet field. When NULL: it is equivalent to
-	 * setting this parameter to an all-green populated table (i.e. table
-	 * with all the 64 elements set to green color). The color blind mode
-	 * is configured by setting *use_prev_mtr_color* to 0 and

*dscp_table*

lib/ethdev/rte_mtr.h +0 -2
-	 * to either NULL or to an all-green populated table. When
-	 * *use_prev_mtr_color* is non-zero value or when *dscp_table*

contains

lib/ethdev/rte_mtr.h +0 -1
-	 * at least one yellow or red color element, then the color aware

mode

lib/ethdev/rte_mtr.h +6 -4
-	 * is configured.
-	 */
-	enum rte_color *dscp_table;
-
+	RTE_STD_C11
+	union {
+		/** Meter input color based on DSCP.
+		 * Valid when rte_mtr_input_color_tbl::tbl_selector is
+		 * set to RTE_MTR_INPUT_COLOR_TBL_DSCP.
+		 * When non-NULL: it points to a pre-allocated and pre-

populated

lib/ethdev/rte_mtr.h +6 -0
+		 * table with exactly 64 elements providing the input color for
+		 * each value of the IPv4/IPv6 Differentiated Services Code
+		 * Point (DSCP) input packet field. When NULL:
+		 * it is equivalent to setting this parameter to an all-green
+		 * populated table (i.e. table with
+		 * all the 64 elements set to green color). The color blind

mode

lib/ethdev/rte_mtr.h +3 -0
+		 * is configured by setting *use_prev_mtr_color* to 0 and
+		 * *dscp_table* to either NULL or to an all-green
+		 * populated table. When *use_prev_mtr_color* is non-zero

value

lib/ethdev/rte_mtr.h +2 -0
+		 * or when *dscp_table* contains at least one yellow or
+		 * red color element, then the color aware mode is

configured.

lib/ethdev/rte_mtr.h +1 -0
+		 * @see struct

rte_mtr_capabilities::input_color_dscp_supported

lib/ethdev/rte_mtr.h +6 -0
+		 */
+		enum rte_color *dscp_table;
+		/** Meter input color based on VLAN.
+		 * Valid when rte_mtr_input_color_tbl::tbl_selector is
+		 * set to RTE_MTR_INPUT_COLOR_TBL_VLAN.
+		 * When non-NULL: it points to a pre-allocated and pre-

populated

lib/ethdev/rte_mtr.h +5 -0
+		 * table with exactly 16 elements providing the input color for
+		 * each value of the DEI(1bit), PCP(3 bits) input packet field.
+		 * When NULL: it is equivalent to setting this parameter to an
+		 * all-green populated table (i.e. table with
+		 * all the 16 elements set to green color). The color blind

mode

lib/ethdev/rte_mtr.h +3 -0
+		 * is configured by setting *use_prev_mtr_color* to 0 and
+		 * *vlan_table* to either NULL or to an all-green
+		 * populated table. When *use_prev_mtr_color* is non-zero

value

lib/ethdev/rte_mtr.h +2 -0
+		 * or when *vlan_table* contains at least one yellow or
+		 * red color element, then the color aware mode is

configured.

lib/ethdev/rte_mtr.h +1 -0
+		 * @see struct

rte_mtr_capabilities::input_color_vlan_supported

lib/ethdev/rte_mtr.h +3 -0
+		 */
+		enum rte_color *vlan_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

lib/ethdev/rte_mtr.h +53 -0
 	 * *meter_profile_id* is set to NONE.
@@ -261,6 +295,25 @@ struct rte_mtr_params {
 
 	/** Meter policy ID. */
 	uint32_t meter_policy_id;
+
+	/** Select the input color table
+	 * @see struct rte_mtr_params::dscp_table
+	 * @see struct rte_mtr_capabilities::input_color_dscp_supported
+	 * @see struct rte_mtr_params::vlan_table
+	 * @see struct rte_mtr_capabilities::input_color_vlan_supported
+	 */
+	enum rte_mtr_input_color_tbl tbl_selector;
+	/** Fallback input color for the meter,
+	 *  when *use_prev_mtr_color* set to zero value and
+	 *  when packet is not based on selected *tbl_selector*.
+	 *  @see struct rte_mtr_capabilities::input_color_fallback_supported
+	 */
+	enum rte_color fallback_input_color;
+	/** Input color table based on inner field of selected
+	 *  of *tbl_selector*.
+	 *  @see struct rte_mtr_capabilities::input_color_inner_supported
+	 */
+	int input_color_inner_enable;
 };
 
 /**
@@ -417,6 +470,31 @@ struct rte_mtr_capabilities {
 	 * @see enum rte_mtr_stats_type
 	 */
 	uint64_t stats_mask;
+
+	/** Input color based on DSCP.
+	 * When non-zero, it indicates that driver supports input color table
+	 * based on DSCP.
+	 */
+	int input_color_dscp_supported;
+	/** Input color based on VLAN.
+	 * When non-zero, it indicates that driver supports input color table
+	 * based on VLAN.
+	 */
+	int input_color_vlan_supported;
+	/** Input color fallback support.
+	 * When non-zero, it indicates that driver supports input color
+	 * fallback.
+	 */
+	int input_color_fallback_supported;
+	/** Input color based on inner packet field.
+	 * When non-zero, it indicates that driver supports input color
+	 * based on inner field.
+	 */
+	int input_color_inner_supported;
+	 /** When non-zero, it indicates that driver supports separate
+	  * input color table for given ethdev port.
+	  */
+	int seperate_input_color_table_per_port;
 };
 
 /**
@@ -832,6 +910,30 @@ rte_mtr_meter_dscp_table_update(uint16_t
 port_id,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
+/**
+ * MTR object VLAN table update
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[in] vlan_table
+ *   When non-NULL: it points to a pre-allocated and pre-populated table

with

+ *   exactly 16 elements providing the input color for each value of the
+ *   each value of the DEI(1bit), PCP(3 bits) input packet field.
+ *   When NULL: it is equivalent to setting this parameter to an "all-green"
+ *   populated table (i.e. table with all the 16 elements set to green color).

+ * @param[out] error
+ * Error details. Filled in only on error, when not NULL.
+ * @return
+ * 0 on success, non-zero error code otherwise.
+ */

lib/ethdev/rte_mtr.h +6 -1
+__rte_experimental
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id,
+	uint32_t mtr_id,
+	enum rte_color *vlan_table,
+	struct rte_mtr_error *error);
 /**
  * MTR object enabled statistics counters update
  *
--
Quoted 1 line

2.33.0

Allowing the configuration of the packet input color based on multiple protocols as opposed to just IP DSCP field makes sense to me.

A few questions/suggestions:

1. How do we decide which field/protocol takes precedence to define the packet input color? You are enabling 2 possible options so far, i.e. VLAN tag PCP field and IP DSCP field, which one is to be set for the current meter object? Using the capabilities to decide is confusing, as a specific meter object might be able to support multiple or even all the possible options (e.g. the meter object is fine with either IP DSCP or VLAN PCP). Therefore, we need a clear mechanism to unequivocally pick one; I think the user must explicitly define which input color methodology is to be used by explicitly setting a field (to be added) in the meter object parameter structure.

2. What if the defined input color methodology is not applicable to the current input packet? For example, the user selects VLAN PCP, but some or all of the input packets do not contain any VLAN labels?

3. How do we manage the many packet fields that could be used as the key for the input color: outer IP DSCP, inner IP DSCP, VLAN 1st label, VLAN 2nd label, MPLS QoS, etc?
- Approach A: Use an enumeration, like you propose, and we can add more in the future. Not ideal.
- Approach B: Point to a protocol-agnostic packet field by defining the offset and mask of a 64-bit field. Advantage: we don't need to change the API every time we add a new option.

4. I suggest we use a unified input color table as opposed to one per protocol, i.e. rename the struct rte_mtr_params::dscp_table to color_in_table. The size of this table could be implicitly defined by the packet field type (in case of enum) or the field mask (in case of protocol-agnostic field offset and mask), as described above.

Regards,
Cristian

#4 lore raw
Quoted 2 lines · Cristian

Hi Jerin,

Hi Cristian,

Quoted 26 lines
Quoted 26 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Friday, August 20, 2021 9:24 AM
To: Dumitrescu, Cristian <[email protected]>; Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Singh, Jasvinder <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Jerin Jacob <[email protected]>
Subject: [dpdk-dev] [RFC PATCH] ethdev: mtr: enhance input color table features

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

Quoted 6 lines
Quoted 3 lines

2.33.0

Allowing the configuration of the packet input color based on multiple protocols as opposed to just IP DSCP field makes sense to me.

Apologies for the delay in response. This was missed the 21.11 timeframe so I don't bother replying. Reviving back.

Quoted 3 lines

A few questions/suggestions:

1. How do we decide which field/protocol takes precedence to define the packet input color? You are enabling 2 possible options so far, i.e. VLAN tag PCP field and IP DSCP field, which one is to be set for the current meter object? Using the capabilities to decide is confusing, as a specific meter object might be able to support multiple or even all the possible options (e.g. the meter object is fine with either IP DSCP or VLAN PCP). Therefore, we need a clear mechanism to unequivocally pick one; I think the user must explicitly define which input color methodology is to be used by explicitly setting a field (to be added) in the meter object parameter structure.

Currently, in our HW, Each meter object needs to tell which pre-color scheme it is going to use(IP DSCP or VLAN PCP). This is OK in the overall scheme of things as the meter object is connected to rte_flow. So,
rte_flow pattern can decide the steering to meter. Having said that, it is possible to have array for input color as you suggested. If choose that, path, We need to add capability tell implementation supports only one input color per meter object. Let me know if this is OK.

Quoted 2 lines

2. What if the defined input color methodology is not applicable to the current input packet? For example, the user selects VLAN PCP, but some or all of the input packets do not contain any VLAN labels?

it picks the rte_mtr_params::fallback_input_color

Quoted 4 lines

3. How do we manage the many packet fields that could be used as the key for the input color: outer IP DSCP, inner IP DSCP, VLAN 1st label, VLAN 2nd label, MPLS QoS, etc?
- Approach A: Use an enumeration, like you propose, and we can add more in the future. Not ideal.
- Approach B: Point to a protocol-agnostic packet field by defining the offset and mask of a 64-bit field. Advantage: we don't need to change the API every time we add a new option.

No strong opinion on doing Approach B. I think, it may be overkill for application and implementation to express. No strong opinion, If you have a strong opinion on that, I will change that to v1. Let me know.

Quoted 2 lines

4. I suggest we use a unified input color table as opposed to one per protocol, i.e. rename the struct rte_mtr_params::dscp_table to color_in_table. The size of this table could be implicitly defined by the packet field type (in case of enum) or the field mask (in case of protocol-agnostic field offset and mask), as described above.

Will do that. I thought not to do that just because, I don't want to remove the existing dscp_table symbol.
Make sense to enable your suggestion.

Let me know your views on Questions 1 and 3. I will send the next version based on that.

Quoted 3 lines

Regards,
Cristian

#5 lore raw
Quoted 6 lines · Jerin Jacob
Quoted 2 lines · Cristian

Hi Jerin,

Hi Cristian,

Could you share your feedback so that I can send the v1?

Quoted 83 lines
Quoted 28 lines
Quoted 28 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Friday, August 20, 2021 9:24 AM
To: Dumitrescu, Cristian <[email protected]>; Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Singh, Jasvinder <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Jerin Jacob <[email protected]>
Subject: [dpdk-dev] [RFC PATCH] ethdev: mtr: enhance input color table features

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

Quoted 6 lines
Quoted 3 lines

2.33.0

Allowing the configuration of the packet input color based on multiple protocols as opposed to just IP DSCP field makes sense to me.

Apologies for the delay in response. This was missed the 21.11 timeframe so I don't bother replying. Reviving back.

Quoted 3 lines

A few questions/suggestions:

1. How do we decide which field/protocol takes precedence to define the packet input color? You are enabling 2 possible options so far, i.e. VLAN tag PCP field and IP DSCP field, which one is to be set for the current meter object? Using the capabilities to decide is confusing, as a specific meter object might be able to support multiple or even all the possible options (e.g. the meter object is fine with either IP DSCP or VLAN PCP). Therefore, we need a clear mechanism to unequivocally pick one; I think the user must explicitly define which input color methodology is to be used by explicitly setting a field (to be added) in the meter object parameter structure.

Currently, in our HW, Each meter object needs to tell which pre-color scheme it is going to use(IP DSCP or VLAN PCP). This is OK in the overall scheme of things as the meter object is connected to rte_flow. So,
rte_flow pattern can decide the steering to meter. Having said that, it is possible to have array for input color as you suggested. If choose that, path, We need to add capability tell implementation supports only one input color per meter object. Let me know if this is OK.

Quoted 2 lines

2. What if the defined input color methodology is not applicable to the current input packet? For example, the user selects VLAN PCP, but some or all of the input packets do not contain any VLAN labels?

it picks the rte_mtr_params::fallback_input_color

Quoted 4 lines

3. How do we manage the many packet fields that could be used as the key for the input color: outer IP DSCP, inner IP DSCP, VLAN 1st label, VLAN 2nd label, MPLS QoS, etc?
- Approach A: Use an enumeration, like you propose, and we can add more in the future. Not ideal.
- Approach B: Point to a protocol-agnostic packet field by defining the offset and mask of a 64-bit field. Advantage: we don't need to change the API every time we add a new option.

No strong opinion on doing Approach B. I think, it may be overkill for application and implementation to express. No strong opinion, If you have a strong opinion on that, I will change that to v1. Let me know.

Quoted 2 lines

4. I suggest we use a unified input color table as opposed to one per protocol, i.e. rename the struct rte_mtr_params::dscp_table to color_in_table. The size of this table could be implicitly defined by the packet field type (in case of enum) or the field mask (in case of protocol-agnostic field offset and mask), as described above.

Will do that. I thought not to do that just because, I don't want to remove the existing dscp_table symbol.
Make sense to enable your suggestion.

Let me know your views on Questions 1 and 3. I will send the next version based on that.

Quoted 3 lines

Regards,
Cristian

#6 lore raw

HI Jerin,

Sorry for my delay. I am currently in vacation until the beginning on January 2022, so my response is slower than usual.

Quoted 73 lines

-----Original Message-----
From: Jerin Jacob <[email protected]>
Sent: Tuesday, December 7, 2021 9:55 AM
To: Dumitrescu, Cristian <[email protected]>
Cc: [email protected]; Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Singh, Jasvinder <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [RFC PATCH] ethdev: mtr: enhance input color table features

Quoted 6 lines · Jerin Jacob
Quoted 2 lines · Cristian

Hi Jerin,

Hi Cristian,

Could you share your feedback so that I can send the v1?

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Friday, August 20, 2021 9:24 AM
To: Dumitrescu, Cristian <[email protected]>; Thomas

Monjalon

Quoted 1 line
Quoted 1 line
Quoted 1 line

<[email protected]>; Yigit, Ferruh <[email protected]>;

Andrew

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Rybchenko <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Singh, Jasvinder <[email protected]>; [email protected]; [email protected]; [email protected];

[email protected];

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Jerin Jacob <[email protected]>
Subject: [dpdk-dev] [RFC PATCH] ethdev: mtr: enhance input color

table

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

features

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

2.33.0

Allowing the configuration of the packet input color based on multiple

protocols as opposed to just IP DSCP field makes sense to me.

Quoted 8 lines
Quoted 1 line

Apologies for the delay in response. This was missed the 21.11 timeframe so I don't bother replying. Reviving back.

Quoted 3 lines

A few questions/suggestions:

1. How do we decide which field/protocol takes precedence to define the

Quoted 19 lines

packet input color? You are enabling 2 possible options so far, i.e. VLAN tag PCP field and IP DSCP field, which one is to be set for the current meter object? Using the capabilities to decide is confusing, as a specific meter object might be able to support multiple or even all the possible options (e.g. the meter object is fine with either IP DSCP or VLAN PCP). Therefore, we need a clear mechanism to unequivocally pick one; I think the user must explicitly define which input color methodology is to be used by explicitly setting a field (to be added) in the meter object parameter structure.

Quoted 11 lines

Currently, in our HW, Each meter object needs to tell which pre-color scheme it is going to use(IP DSCP or VLAN PCP). This is OK in the overall scheme of things as the meter object is connected to rte_flow. So,
rte_flow pattern can decide the steering to meter. Having said that, it is possible to have array for input color as you suggested. If choose that, path, We need to add capability tell implementation supports only one input color per meter object. Let me know if this is OK.

Thanks for the explanation of the capabilities you are trying to enable in the API. Based on this, I am reconsidering some of my previous input. Here are my current thoughts:

a) Each meter object can be configured with multiple methods to determine the input color: IP DSCP and VLAN PCP are just two of them, others are possible (as also listed by you). I think the problem we are trying to solve here is: in case multiple such methods are enabled for a given meter object AND more than one enabled method is applicable for a particular input packet at run-time (e.g. the packet is an IP packet, but it also contains at least one VLAN label, and both IP DSCP and the VLAN PCP methods are enabled for the meter object), how do we decide which method is to be applied? So, IMO we need to define a priority scheme that always picks a single method:

- a unique priority for each method;

- a default method to be used when none of the enabled methods is applicable to the input packet.

b) The default method must be usable even when the input packet type is unknown to the HW (unsupported), e.g. we should still be able to decide the input color of a packet that is not an IP packet, such as ARP, and it does not contain any VLAN labels. For this, I suggest we add a field ins struct rte_mtr_params called default_input_color of type enum rte_color:

	struct rte_mtr_params {
		enum rte_color default_input_color; /* Input color to be set for the input packet when none of the enabled input color methods is applicable to the current input packet. Ignored when this method is set to the color blind method. */
	};

c) In terms of methods and their priority, I propose to start with the following options, each of which referring to a set of methods, with a clear way to select a unique method. This is the minimal set needed to support the HW capabilities that you mention, this set can be extended as needed in the future:

enum rte_mtr_input_color_method {
RTE_MTR_INPUT_COLOR_METHOD_COLOR_BLIND, /* The input color is always green. The default_input_color is ignored for this method. */
RTE_ MTR_INPUT_COLOR_METHOD_IP_DSCP, /* If the input packet is IPv4 or IPv6, its input color is detected by the DSCP field indexing into the dscp_table. Otherwise, the default_input_color is applied. */
RTE_ MTR_INPUT_COLOR_METHOD_OUTER_VLAN_PCP, /* If the input packet has at least one VLAN label, its input color is detected by the outermost VLAN PCP indexing into the vlan_table. Otherwise, the default_input_color is applied. */
RTE_ MTR_INPUT_COLOR_METHOD_OUTER_VLAN_PCP_IP_DSCP, /* If the input packet has at least one VLAN label, its input color is detected by the outermost VLAN PCP indexing into the vlan_table. Otherwise, if the packet is IPv4 or IPv6, its input color is detected by the DSCP field indexing into the dscp_table. Otherwise, the default_input_color is applied. */ RTE_ MTR_INPUT_COLOR_METHOD_INNER_VLAN_PCP, /* If the input packet has at least one VLAN label, its input color is detected by the innermost VLAN PCP indexing into the vlan_table. Otherwise, the default_input_color is applied. */
RTE_ MTR_INPUT_COLOR_METHOD_INNER_VLAN_PCP_IP_DSCP, /* If the input packet has at least one VLAN label, its input color is detected by the innermost VLAN PCP indexing into the vlan_table. Otherwise, if the packet is IPv4 or IPv6, its input color is detected by the DSCP field indexing into the dscp_table. Otherwise, the default_input_color is applied. */
};

struct rte_mtr_params {
enum rte_mtr_input_color_method input_color_method;
};

d) The above point means that all the protocol dependent tables are independent of each other, so they can all exist at the same time, so we cannot put all of them into a union or a single unified input color translation table. In case any of these tables is enabled/required by the input color scheme, but it is set to NULL, it must automatically resolve to an "all-green" table (as it is already the case for the existing dscp_table).

	struct rte_mtr_params {
		enum rte_color *ip_dscp_table; /* Used when the IP DSCP input color method is selected for the current input packet. If set to NULL, it defaults to 64 elements of RTE_COLOR_GREEN. */
		enum rte_color *vlan_table; /* Used when the outermost/innermost VLAN PCP input color method is selected for the current input packet. If set to NULL, it defaults to all elements being RTE_COLOR_GREEN. */
	};

So many details to address in order to avoid any loopholes in this API, but I think this scheme is implementable and robust enough. What do you think?

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

2. What if the defined input color methodology is not applicable to the

current input packet? For example, the user selects VLAN PCP, but some or all of the input packets do not contain any VLAN labels?

Quoted 3 lines

it picks the rte_mtr_params::fallback_input_color

We likely need a more complex scheme, see above ;)

Quoted 14 lines
Quoted 2 lines
Quoted 2 lines

3. How do we manage the many packet fields that could be used as the

key for the input color: outer IP DSCP, inner IP DSCP, VLAN 1st label, VLAN 2nd label, MPLS QoS, etc?

Quoted 1 line
Quoted 1 line

- Approach A: Use an enumeration, like you propose, and we can add

more in the future. Not ideal.

Quoted 1 line
Quoted 1 line

- Approach B: Point to a protocol-agnostic packet field by defining the

offset and mask of a 64-bit field. Advantage: we don't need to change the API every time we add a new option.

Quoted 5 lines

No strong opinion on doing Approach B. I think, it may be overkill for application and implementation to express. No strong opinion, If you have a strong opinion on that, I will change that to v1. Let me know.

I would love to have a protocol agnostic scheme, but I am OK to start with a simple scheme for now (if you can call the above scheme as being simple ;) )and revisit later on if needed.

Quoted 15 lines
Quoted 3 lines
Quoted 3 lines

4. I suggest we use a unified input color table as opposed to one per

protocol, i.e. rename the struct rte_mtr_params::dscp_table to color_in_table. The size of this table could be implicitly defined by the packet field type (in case of enum) or the field mask (in case of protocol-agnostic field offset and mask), as described above.

Quoted 8 lines

Will do that. I thought not to do that just because, I don't want to remove the existing dscp_table symbol.
Make sense to enable your suggestion.

Let me know your views on Questions 1 and 3. I will send the next version based on that.

Based on the above comments, I no longer thing a unified such table would work.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Regards,
Cristian

Regards,
Cristian

#7 lore raw
Quoted 2 lines · Cristian

HI Jerin,

Hi Chistian,

Quoted 2 lines

Sorry for my delay. I am currently in vacation until the beginning on January 2022, so my response is slower than usual.

I was too on vacation.

Quoted 30 lines

Thanks for the explanation of the capabilities you are trying to enable in the API. Based on this, I am reconsidering some of my previous input. Here are my current thoughts:

a) Each meter object can be configured with multiple methods to determine the input color: IP DSCP and VLAN PCP are just two of them, others are possible (as also listed by you). I think the problem we are trying to solve here is: in case multiple such methods are enabled for a given meter object AND more than one enabled method is applicable for a particular input packet at run-time (e.g. the packet is an IP packet, but it also contains at least one VLAN label, and both IP DSCP and the VLAN PCP methods are enabled for the meter object), how do we decide which method is to be applied? So, IMO we need to define a priority scheme that always picks a single method:

- a unique priority for each method;

- a default method to be used when none of the enabled methods is applicable to the input packet.

b) The default method must be usable even when the input packet type is unknown to the HW (unsupported), e.g. we should still be able to decide the input color of a packet that is not an IP packet, such as ARP, and it does not contain any VLAN labels. For this, I suggest we add a field ins struct rte_mtr_params called default_input_color of type enum rte_color:

        struct rte_mtr_params {
                enum rte_color default_input_color; /* Input color to be set for the input packet when none of the enabled input color methods is applicable to the current input packet. Ignored when this method is set to the color blind method. */
        };

c) In terms of methods and their priority, I propose to start with the following options, each of which referring to a set of methods, with a clear way to select a unique method. This is the minimal set needed to support the HW capabilities that you mention, this set can be extended as needed in the future:

enum rte_mtr_input_color_method {
RTE_MTR_INPUT_COLOR_METHOD_COLOR_BLIND, /* The input color is always green. The default_input_color is ignored for this method. */
RTE_ MTR_INPUT_COLOR_METHOD_IP_DSCP, /* If the input packet is IPv4 or IPv6, its input color is detected by the DSCP field indexing into the dscp_table. Otherwise, the default_input_color is applied. */
RTE_ MTR_INPUT_COLOR_METHOD_OUTER_VLAN_PCP, /* If the input packet has at least one VLAN label, its input color is detected by the outermost VLAN PCP indexing into the vlan_table. Otherwise, the default_input_color is applied. */
RTE_ MTR_INPUT_COLOR_METHOD_OUTER_VLAN_PCP_IP_DSCP, /* If the input packet has at least one VLAN label, its input color is detected by the outermost VLAN PCP indexing into the vlan_table. Otherwise, if the packet is IPv4 or IPv6, its input color is detected by the DSCP field indexing into the dscp_table. Otherwise, the default_input_color is applied. */ RTE_ MTR_INPUT_COLOR_METHOD_INNER_VLAN_PCP, /* If the input packet has at least one VLAN label, its input color is detected by the innermost VLAN PCP indexing into the vlan_table. Otherwise, the default_input_color is applied. */
RTE_ MTR_INPUT_COLOR_METHOD_INNER_VLAN_PCP_IP_DSCP, /* If the input packet has at least one VLAN label, its input color is detected by the innermost VLAN PCP indexing into the vlan_table. Otherwise, if the packet is IPv4 or IPv6, its input color is detected by the DSCP field indexing into the dscp_table. Otherwise, the default_input_color is applied. */
};

struct rte_mtr_params {
enum rte_mtr_input_color_method input_color_method;
};

Quoted 8 lines

d) The above point means that all the protocol dependent tables are independent of each other, so they can all exist at the same time, so we cannot put all of them into a union or a single unified input color translation table. In case any of these tables is enabled/required by the input color scheme, but it is set to NULL, it must automatically resolve to an "all-green" table (as it is already the case for the existing dscp_table).

struct rte_mtr_params {
enum rte_color *ip_dscp_table; /* Used when the IP DSCP input color method is selected for the current input packet. If set to NULL, it defaults to 64 elements of RTE_COLOR_GREEN. */ enum rte_color *vlan_table; /* Used when the outermost/innermost VLAN PCP input color method is selected for the current input packet. If set to NULL, it defaults to all elements being RTE_COLOR_GREEN. */
};

So many details to address in order to avoid any loopholes in this API, but I think this scheme is implementable and robust enough. What do you think?

Sounds good. I will next version based on your suggestion.

Quoted 55 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

2. What if the defined input color methodology is not applicable to the

current input packet? For example, the user selects VLAN PCP, but some or all of the input packets do not contain any VLAN labels?

Quoted 3 lines

it picks the rte_mtr_params::fallback_input_color

We likely need a more complex scheme, see above ;)

Quoted 14 lines
Quoted 2 lines
Quoted 2 lines

3. How do we manage the many packet fields that could be used as the

key for the input color: outer IP DSCP, inner IP DSCP, VLAN 1st label, VLAN 2nd label, MPLS QoS, etc?

Quoted 1 line
Quoted 1 line

- Approach A: Use an enumeration, like you propose, and we can add

more in the future. Not ideal.

Quoted 1 line
Quoted 1 line

- Approach B: Point to a protocol-agnostic packet field by defining the

offset and mask of a 64-bit field. Advantage: we don't need to change the API every time we add a new option.

Quoted 5 lines

No strong opinion on doing Approach B. I think, it may be overkill for application and implementation to express. No strong opinion, If you have a strong opinion on that, I will change that to v1. Let me know.

I would love to have a protocol agnostic scheme, but I am OK to start with a simple scheme for now (if you can call the above scheme as being simple ;) )and revisit later on if needed.

Quoted 15 lines
Quoted 3 lines
Quoted 3 lines

4. I suggest we use a unified input color table as opposed to one per

protocol, i.e. rename the struct rte_mtr_params::dscp_table to color_in_table. The size of this table could be implicitly defined by the packet field type (in case of enum) or the field mask (in case of protocol-agnostic field offset and mask), as described above.

Quoted 8 lines

Will do that. I thought not to do that just because, I don't want to remove the existing dscp_table symbol.
Make sense to enable your suggestion.

Let me know your views on Questions 1 and 3. I will send the next version based on that.

Based on the above comments, I no longer thing a unified such table would work.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Regards,
Cristian

Regards,
Cristian

#8 lore raw

PATCH 1/1 ethdev: mtr: support input color selection

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port

---

v1..RFC:

Address the review comments by Cristian at
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

- Moved to v22.07 release
- Updated rte_mtr_input_color_method to support all VLAN, DSCP, Inner cases
- Added input_color_method
- Removed union between vlan_table and dscp_table
- Kept VLAN instead of PCP as HW coloring based on DEI(1bit), PCP(3 bits)

What is missing:
- 22.07 release notes update
- Testpmd and driver updates(Waiting for the review comments v1 API spec)

 .../traffic_metering_and_policing.rst         |  27 +++
 lib/ethdev/rte_mtr.h                          | 162 +++++++++++++++++-
 lib/ethdev/version.map                        |   3 +
 3 files changed, 190 insertions(+), 2 deletions(-)
doc/guides/prog_guide/traffic_metering_and_policing.rst +27 -0
index ceb5a96488..97d27c92e3 100644
@@ -21,6 +21,7 @@ The main features are:
 * Policer actions (per meter output color): recolor, drop
 * Statistics (per policer output color)
 * Chaining multiple meter objects
+* Packet content based input color selection
 
 Configuration steps
 -------------------
@@ -105,3 +106,29 @@ traffic meter and policing library.
    * Adding one (or multiple) actions of the type ``RTE_FLOW_ACTION_TYPE_METER``
      to the list of meter actions (``struct rte_mtr_meter_policy_params::actions``)
      specified per color as show in :numref:`figure_rte_mtr_chaining`.
+
+Packet content based input color selection
+------------------------------------------
+
+The API supports selecting the input color based on the packet content.
+Following is the API usage model for the same.
+
+#. Probe the input color selection device capabilities using following
+   parameter using ``rte_mtr_capabilities_get()`` API
+   ``struct rte_mtr_capabilities::rte_mtr_input_color_method`` and
+   ``struct rte_mtr_capabilitie::seperate_input_color_table_per_port``
+#. When creating the meter object using ``rte_mtr_create()``, configure
+   relevant input color selection parameters such as
+
+   * Select the input color method ``struct rte_mtr_params::input_color_method``
+
+   * Fill the tables ``struct rte_mtr_params::dscp_table``,
+     ``struct rte_mtr_params::dscp_table`` based on input color selected
+
+   * Update the ``struct rte_mtr_params::default_input_color`` to determine
+     the default input color in case the input packet does not match
+     the input color method
+
+   * If needed, update the input color table at runtime using
+     ``rte_mtr_meter_vlan_table_update()`` and ``rte_mtr_meter_dscp_table_update()``
+     APIs.
lib/ethdev/rte_mtr.h +160 -2

200 lines not on this page · raw message

lib/ethdev/version.map +3 -0
index d5cc56a560..430c620490 100644
@@ -264,6 +264,9 @@ EXPERIMENTAL {
 	rte_eth_ip_reassembly_capability_get;
 	rte_eth_ip_reassembly_conf_get;
 	rte_eth_ip_reassembly_conf_set;
+
+	# added in 22.07
+	rte_mtr_meter_vlan_table_update;
 };
 
 INTERNAL {

--
2.35.1

#9 lore raw

PATCH v2 1/1 ethdev: mtr: support input color selection

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port

---
v2..v1:

- Fix seperate typo

v1..RFC:

Address the review comments by Cristian at
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

- Moved to v22.07 release
- Updated rte_mtr_input_color_method to support all VLAN, DSCP, Inner cases
- Added input_color_method
- Removed union between vlan_table and dscp_table
- Kept VLAN instead of PCP as HW coloring based on DEI(1bit), PCP(3 bits)

What is missing:
- 22.07 release notes update
- Testpmd and driver updates(Waiting for the review comments v1 API spec)

 .../traffic_metering_and_policing.rst         |  27 +++
 lib/ethdev/rte_mtr.h                          | 162 +++++++++++++++++-
 lib/ethdev/version.map                        |   3 +
 3 files changed, 190 insertions(+), 2 deletions(-)
doc/guides/prog_guide/traffic_metering_and_policing.rst +27 -0
index ceb5a96488..db8113f635 100644
@@ -21,6 +21,7 @@ The main features are:
 * Policer actions (per meter output color): recolor, drop
 * Statistics (per policer output color)
 * Chaining multiple meter objects
+* Packet content based input color selection
 
 Configuration steps
 -------------------
@@ -105,3 +106,29 @@ traffic meter and policing library.
    * Adding one (or multiple) actions of the type ``RTE_FLOW_ACTION_TYPE_METER``
      to the list of meter actions (``struct rte_mtr_meter_policy_params::actions``)
      specified per color as show in :numref:`figure_rte_mtr_chaining`.
+
+Packet content based input color selection
+------------------------------------------
+
+The API supports selecting the input color based on the packet content.
+Following is the API usage model for the same.
+
+#. Probe the input color selection device capabilities using following
+   parameter using ``rte_mtr_capabilities_get()`` API
+   ``struct rte_mtr_capabilities::rte_mtr_input_color_method`` and
+   ``struct rte_mtr_capabilitie::separate_input_color_table_per_port``
+#. When creating the meter object using ``rte_mtr_create()``, configure
+   relevant input color selection parameters such as
+
+   * Select the input color method ``struct rte_mtr_params::input_color_method``
+
+   * Fill the tables ``struct rte_mtr_params::dscp_table``,
+     ``struct rte_mtr_params::dscp_table`` based on input color selected
+
+   * Update the ``struct rte_mtr_params::default_input_color`` to determine
+     the default input color in case the input packet does not match
+     the input color method
+
+   * If needed, update the input color table at runtime using
+     ``rte_mtr_meter_vlan_table_update()`` and ``rte_mtr_meter_dscp_table_update()``
+     APIs.
lib/ethdev/rte_mtr.h +160 -2

200 lines not on this page · raw message

lib/ethdev/version.map +3 -0
index d5cc56a560..430c620490 100644
@@ -264,6 +264,9 @@ EXPERIMENTAL {
 	rte_eth_ip_reassembly_capability_get;
 	rte_eth_ip_reassembly_conf_get;
 	rte_eth_ip_reassembly_conf_set;
+
+	# added in 22.07
+	rte_mtr_meter_vlan_table_update;
 };
 
 INTERNAL {
Signature · 1 line
2.35.1
#10 lore raw

PATCH v3 1/1 ethdev: mtr: support input color selection

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port

---
v3..v2:
- Fix input color flags as a bitmask
- Add definitions for newly added API

v2..v1:

- Fix seperate typo

v1..RFC:

Address the review comments by Cristian at
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

- Moved to v22.07 release
- Updated rte_mtr_input_color_method to support all VLAN, DSCP, Inner cases
- Added input_color_method
- Removed union between vlan_table and dscp_table
- Kept VLAN instead of PCP as HW coloring based on DEI(1bit), PCP(3 bits)

What is missing:
- 22.07 release notes update

 .../traffic_metering_and_policing.rst         |  28 +++
 lib/ethdev/rte_mtr.c                          |  12 ++
 lib/ethdev/rte_mtr.h                          | 164 +++++++++++++++++-
 lib/ethdev/rte_mtr_driver.h                   |   9 +
 lib/ethdev/version.map                        |   3 +
 5 files changed, 214 insertions(+), 2 deletions(-)
doc/guides/prog_guide/traffic_metering_and_policing.rst +28 -0
index ceb5a96488..59ebd361ba 100644
@@ -21,6 +21,7 @@ The main features are:
 * Policer actions (per meter output color): recolor, drop
 * Statistics (per policer output color)
 * Chaining multiple meter objects
+* Packet content based input color selection
 
 Configuration steps
 -------------------
@@ -105,3 +106,30 @@ traffic meter and policing library.
    * Adding one (or multiple) actions of the type ``RTE_FLOW_ACTION_TYPE_METER``
      to the list of meter actions (``struct rte_mtr_meter_policy_params::actions``)
      specified per color as show in :numref:`figure_rte_mtr_chaining`.
+
+Packet content based input color selection
+------------------------------------------
+
+The API supports selecting the input color based on the packet content.
+Following is the API usage model for the same.
+
+#. Probe the input color selection device capabilities using following
+   parameter using ``rte_mtr_capabilities_get()`` API
+   ``struct rte_mtr_capabilities::methods_mask`` and
+   ``struct rte_mtr_capabilitie::separate_input_color_table_per_port``
+
+#. When creating the meter object using ``rte_mtr_create()``, configure
+   relevant input color selection parameters such as
+
+   * Select the input color method ``struct rte_mtr_params::input_color_method``
+
+   * Fill the tables ``struct rte_mtr_params::dscp_table``,
+     ``struct rte_mtr_params::dscp_table`` based on input color selected
+
+   * Update the ``struct rte_mtr_params::default_input_color`` to determine
+     the default input color in case the input packet does not match
+     the input color method
+
+   * If needed, update the input color table at runtime using
+     ``rte_mtr_meter_vlan_table_update()`` and ``rte_mtr_meter_dscp_table_update()``
+     APIs.
lib/ethdev/rte_mtr.c +12 -0
index e49fcf271c..a0cb91e0b1 100644
@@ -207,6 +207,18 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
 		mtr_id, dscp_table, error);
 }
 
+/** MTR object meter VLAN table update */
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id,
+	uint32_t mtr_id,
+	enum rte_color *vlan_table,
+	struct rte_mtr_error *error)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	return RTE_MTR_FUNC(port_id, meter_vlan_table_update)(dev,
+		mtr_id, vlan_table, error);
+}
+
 /** MTR object enabled stats update */
 int
 rte_mtr_stats_update(uint16_t port_id,
lib/ethdev/rte_mtr.h +162 -2

202 lines not on this page · raw message

lib/ethdev/rte_mtr_driver.h +9 -0
index ee8c6ef7ad..37ab79666b 100644
@@ -97,6 +97,12 @@ typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
+/** @internal MTR object meter VLAN table update. */
+typedef int (*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev,
+	uint32_t mtr_id,
+	enum rte_color *vlan_table,
+	struct rte_mtr_error *error);
+
 /** @internal MTR object enabled stats update. */
 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
 	uint32_t mtr_id,
@@ -139,6 +145,9 @@ struct rte_mtr_ops {
 	/** MTR object meter DSCP table update */
 	rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
 
+	/** MTR object meter VLAN table update */
+	rte_mtr_meter_vlan_table_update_t meter_vlan_table_update;
+
 	/** MTR object enabled stats update */
 	rte_mtr_stats_update_t stats_update;
 
lib/ethdev/version.map +3 -0
index 20391ab29e..77915c0ddc 100644
@@ -279,6 +279,9 @@ EXPERIMENTAL {
 	rte_flow_async_action_handle_create;
 	rte_flow_async_action_handle_destroy;
 	rte_flow_async_action_handle_update;
+
+	# added in 22.07
+	rte_mtr_meter_vlan_table_update;
 };
 
 INTERNAL {
Signature · 1 line
2.25.1
#11 lore raw

RE: [EXT] [PATCH v3 1/1] ethdev: mtr: support input color selection

Corresponding driver implementation is available at http://patches.dpdk.org/project/dpdk/patch/[email protected]/.
Also CLI is added to testpmd for below API and available at http://patches.dpdk.org/project/dpdk/patch/[email protected]/

Quoted 413 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Tuesday, March 1, 2022 2:28 PM
To: Cristian Dumitrescu <[email protected]>; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>
Subject: [EXT] [PATCH v3 1/1] ethdev: mtr: support input color selection

External Email

----------------------------------------------------------------------
From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port

---
v3..v2:
- Fix input color flags as a bitmask
- Add definitions for newly added API

v2..v1:

- Fix seperate typo

v1..RFC:

Address the review comments by Cristian at
https://urldefense.proofpoint.com/v2/url?u=https-
3A__patches.dpdk.org_project_dpdk_patch_20210820082401.3778736-2D1- 2Djerinj- 40marvell.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=dXeXaAMkP5 COgn1zxHMyaF1_d9IIuq6vHQO6NrIPjaE&m=bvYbz6aP4xuLPRt2TIk1o99kWXj u-rRDvz3qXnCVbz_TER0zcRDqjQxJSm3SnLXM&s=mVeBbQWjsvJLRm-dcB4h- KmAj3tGi4WT0E9IvsuNT2g&e=

- Moved to v22.07 release
- Updated rte_mtr_input_color_method to support all VLAN, DSCP, Inner cases
- Added input_color_method
- Removed union between vlan_table and dscp_table
- Kept VLAN instead of PCP as HW coloring based on DEI(1bit), PCP(3 bits)

What is missing:
- 22.07 release notes update

 .../traffic_metering_and_policing.rst         |  28 +++
 lib/ethdev/rte_mtr.c                          |  12 ++
 lib/ethdev/rte_mtr.h                          | 164 +++++++++++++++++-
 lib/ethdev/rte_mtr_driver.h                   |   9 +
 lib/ethdev/version.map                        |   3 +
 5 files changed, 214 insertions(+), 2 deletions(-)
doc/guides/prog_guide/traffic_metering_and_policing.rst +1 -0
index ceb5a96488..59ebd361ba 100644
@@ -21,6 +21,7 @@ The main features are:
 * Policer actions (per meter output color): recolor, drop
 * Statistics (per policer output color)
 * Chaining multiple meter objects
+* Packet content based input color selection
 
 Configuration steps
 -------------------
@@ -105,3 +106,30 @@ traffic meter and policing library.
    * Adding one (or multiple) actions of the type

``RTE_FLOW_ACTION_TYPE_METER``
to the list of meter actions (``struct
rte_mtr_meter_policy_params::actions``)
specified per color as show in :numref:figure_rte_mtr_chaining.

doc/guides/prog_guide/traffic_metering_and_policing.rst +28 -0
+
+Packet content based input color selection
+------------------------------------------
+
+The API supports selecting the input color based on the packet content.
+Following is the API usage model for the same.
+
+#. Probe the input color selection device capabilities using following
+   parameter using ``rte_mtr_capabilities_get()`` API
+   ``struct rte_mtr_capabilities::methods_mask`` and
+   ``struct rte_mtr_capabilitie::separate_input_color_table_per_port``
+
+#. When creating the meter object using ``rte_mtr_create()``, configure
+   relevant input color selection parameters such as
+
+   * Select the input color method ``struct
+ rte_mtr_params::input_color_method``
+
+   * Fill the tables ``struct rte_mtr_params::dscp_table``,
+     ``struct rte_mtr_params::dscp_table`` based on input color
+ selected
+
+   * Update the ``struct rte_mtr_params::default_input_color`` to determine
+     the default input color in case the input packet does not match
+     the input color method
+
+   * If needed, update the input color table at runtime using
+     ``rte_mtr_meter_vlan_table_update()`` and

``rte_mtr_meter_dscp_table_update()``

doc/guides/prog_guide/traffic_metering_and_policing.rst +1 -0
+     APIs.
lib/ethdev/rte_mtr.c index renamed from lib/ethdev/rte_mtr.c +0 -0

e49fcf271c..a0cb91e0b1 100644

lib/ethdev/rte_mtr.c +11 -0
@@ -207,6 +207,18 @@ rte_mtr_meter_dscp_table_update(uint16_t
 port_id,
 		mtr_id, dscp_table, error);
 }
 
+/** MTR object meter VLAN table update */ int
+rte_mtr_meter_vlan_table_update(uint16_t port_id,
+	uint32_t mtr_id,
+	enum rte_color *vlan_table,
+	struct rte_mtr_error *error)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	return RTE_MTR_FUNC(port_id, meter_vlan_table_update)(dev,
+		mtr_id, vlan_table, error);
+}
+
 /** MTR object enabled stats update */
 int
 rte_mtr_stats_update(uint16_t port_id,
lib/ethdev/rte_mtr.h index renamed from lib/ethdev/rte_mtr.h +0 -0

40df0888c8..7f9abebb41 100644

lib/ethdev/rte_mtr.h +73 -1
@@ -213,6 +213,80 @@ struct rte_mtr_meter_policy_params {
 	const struct rte_flow_action *actions[RTE_COLORS];  };
 
+/**
+ * Input color method
+ */
+enum rte_mtr_input_color_method {
+	/**
+	 * The input color is always green.
+	 * The default_input_color is ignored for this method.
+	 * @see struct rte_mtr_params::default_input_color
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_COLOR_BLIND  = RTE_BIT64(0),
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the outermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_VLAN = RTE_BIT64(1),
+	/**
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the outermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_DSCP = RTE_BIT64(2),
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the outermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the outermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP = RTE_BIT64(3),
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN = RTE_BIT64(4),
+	/**
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the innermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP = RTE_BIT64(5),
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the innermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP =
 RTE_BIT64(6), };
+
 /**
  * Parameters for each traffic metering & policing object
  *
@@ -233,7 +307,15 @@ struct rte_mtr_params {
 	 */
 	int use_prev_mtr_color;
 
-	/** Meter input color. When non-NULL: it points to a pre-allocated

and

lib/ethdev/rte_mtr.h +9 -1
+	/** Meter input color based on IP DSCP field.
+	 *
+	 * Valid when input_color_method set to any of the following
+	 * RTE_MTR_INPUT_COLOR_METHOD_DSCP,
+	 * RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP,
+	 * RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP,
+	 * RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP
+	 *
+	 * When non-NULL: it points to a pre-allocated and
 	 * pre-populated table with exactly 64 elements providing the input
 	 * color for each value of the IPv4/IPv6 Differentiated Services Code
 	 * Point (DSCP) input packet field. When NULL: it is equivalent to @@
-244,9 +326,39 @@ struct rte_mtr_params {
 	 * *use_prev_mtr_color* is non-zero value or when *dscp_table*

contains
* at least one yellow or red color element, then the color aware
mode

lib/ethdev/rte_mtr.h +1 -0
 	 * is configured.
+	 * @see enum

rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_DSCP

lib/ethdev/rte_mtr.h +1 -0
+	 * @see enum

rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_VLAN_DS CP

lib/ethdev/rte_mtr.h +1 -0
+	 * @see enum

rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_INNER_D SCP

lib/ethdev/rte_mtr.h +1 -0
+	 * @see enum

rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_INNER_VL AN_DSCP

lib/ethdev/rte_mtr.h +21 -1
+	 * @see struct rte_mtr_params::input_color_method
 	 */
 	enum rte_color *dscp_table;
-
+	/** Meter input color based on VLAN DEI(1bit), PCP(3 bits) fields.
+	 *
+	 * Valid when input_color_method set to any of the following
+	 * RTE_MTR_INPUT_COLOR_METHOD_VLAN,
+	 * RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP,
+	 * RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN,
+	 * RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP
+	 *
+	 * When non-NULL: it points to a pre-allocated and pre-populated
+	 * table with exactly 16 elements providing the input color for
+	 * each value of the DEI(1bit), PCP(3 bits) input packet field.
+	 * When NULL: it is equivalent to setting this parameter to an
+	 * all-green populated table (i.e. table with
+	 * all the 16 elements set to green color). The color blind mode
+	 * is configured by setting *use_prev_mtr_color* to 0 and
+	 * *vlan_table* to either NULL or to an all-green
+	 * populated table. When *use_prev_mtr_color* is non-zero value
+	 * or when *vlan_table* contains at least one yellow or
+	 * red color element, then the color aware mode is configured.
+	 * @see enum

rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_VLAN

lib/ethdev/rte_mtr.h +1 -0
+	 * @see enum

rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_VLAN_DS CP

lib/ethdev/rte_mtr.h +1 -0
+	 * @see enum

rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_INNER_VL AN

lib/ethdev/rte_mtr.h +1 -0
+	 * @see enum

rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_INNER_VL AN_DSCP

lib/ethdev/rte_mtr.h +3 -0
+	 * @see struct rte_mtr_params::input_color_method
+	 */
+	enum rte_color *vlan_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

lib/ethdev/rte_mtr.h +11 -0
 	 * *meter_profile_id* is set to NONE.
@@ -261,6 +373,20 @@ struct rte_mtr_params {
 
 	/** Meter policy ID. @see rte_mtr_meter_policy_add() */
 	uint32_t meter_policy_id;
+
+	/** Input color method to select.
+	 * @see struct rte_mtr_params::dscp_table
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	enum rte_mtr_input_color_method input_color_method;
+
+	/** Input color to be set for the input packet when none of the
+	 * enabled input color methods is applicable to the input packet.
+	 * Ignored when this method is set to the
+	 * enum

rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_COLOR_B LIND

lib/ethdev/rte_mtr.h +22 -0
+	 * method.
+	 */
+	enum rte_color default_input_color;
 };
 
 /**
@@ -417,6 +543,16 @@ struct rte_mtr_capabilities {
 	 * @see enum rte_mtr_stats_type
 	 */
 	uint64_t stats_mask;
+
+	/** Set of supported input color methods.
+	 * @see enum rte_mtr_input_color_method
+	 */
+	uint64_t methods_mask;
+
+	/** When non-zero, it indicates that driver supports separate
+	 * input color table for given ethdev port.
+	 */
+	int separate_input_color_table_per_port;
 };
 
 /**
@@ -832,6 +968,30 @@ rte_mtr_meter_dscp_table_update(uint16_t
 port_id,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
+/**
+ * MTR object VLAN table update
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[in] vlan_table
+ *   When non-NULL: it points to a pre-allocated and pre-populated table

with

+ *   exactly 16 elements providing the input color for each value of the
+ *   each value of the DEI(1bit), PCP(3 bits) input packet field.
+ *   When NULL: it is equivalent to setting this parameter to an "all-green"
+ *   populated table (i.e. table with all the 16 elements set to green color).

+ * @param[out] error
+ * Error details. Filled in only on error, when not NULL.
+ * @return
+ * 0 on success, non-zero error code otherwise.
+ */

lib/ethdev/rte_mtr.h +6 -0
+__rte_experimental
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id,
+	uint32_t mtr_id,
+	enum rte_color *vlan_table,
+	struct rte_mtr_error *error);
 /**
  * MTR object enabled statistics counters update
  *
lib/ethdev/rte_mtr_driver.h index renamed from lib/ethdev/rte_mtr_driver.h +0 -0

ee8c6ef7ad..37ab79666b 100644

lib/ethdev/rte_mtr_driver.h +6 -0
@@ -97,6 +97,12 @@ typedef int
 (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
+/** @internal MTR object meter VLAN table update. */ typedef int
+(*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev,
+	uint32_t mtr_id,
+	enum rte_color *vlan_table,
+	struct rte_mtr_error *error);
+
 /** @internal MTR object enabled stats update. */  typedef int
 (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
lib/ethdev/rte_mtr_driver.h +3 -0
 	uint32_t mtr_id,
@@ -139,6 +145,9 @@ struct rte_mtr_ops {
 	/** MTR object meter DSCP table update */
 	rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
 
+	/** MTR object meter VLAN table update */
+	rte_mtr_meter_vlan_table_update_t meter_vlan_table_update;
+
 	/** MTR object enabled stats update */
 	rte_mtr_stats_update_t stats_update;
 
lib/ethdev/version.map index renamed from lib/ethdev/version.map +0 -0

20391ab29e..77915c0ddc 100644

lib/ethdev/version.map +3 -1
@@ -279,6 +279,9 @@ EXPERIMENTAL {
 	rte_flow_async_action_handle_create;
 	rte_flow_async_action_handle_destroy;
 	rte_flow_async_action_handle_update;
+
+	# added in 22.07
+	rte_mtr_meter_vlan_table_update;
 };
 
 INTERNAL {
--

2.25.1

#12 lore raw

RE: [PATCH v3 1/1] ethdev: mtr: support input color selection

In reply to [email protected]

HI Jerin,

Thanks for your patch! I think we are making great progress, here are a few more comments:

<snip>

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 219

Quoted 4 lines
lib/ethdev/rte_mtr.h +4 -0
+/**
+ * Input color method
+ */
+enum rte_mtr_input_color_method {

We should clean up the names of these methods a bit: we should not mix header names (VLAN, IP) with header field names (DSCP, PCP), in the sense that to me METHOD_VLAN_DSCP should be replaced with either:
* METHOD_OUTER_VLAN_IP :shorter name, as only the headers are mentioned (my preference, but I am OK with both)
* METHOD_OUTER_VLAN_PCP_IP_DSCP: longer name, as both the headers and the header fields are mentioned

Please put a blank line in between these methods to better readability.

I see some issues in the list of methods below, I am trying to do my best to catch them all:

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 225

Quoted 6 lines
lib/ethdev/rte_mtr.h +6 -0
+	/**
+	 * The input color is always green.
+	 * The default_input_color is ignored for this method.
+	 * @see struct rte_mtr_params::default_input_color
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_COLOR_BLIND  = RTE_BIT64(0),

OK.

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 234

Quoted 9 lines
lib/ethdev/rte_mtr.h +9 -0
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the outermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_VLAN = RTE_BIT64(1),

OK.
Does your HW use PCP+DEI , or just PCP?

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 243

Quoted 9 lines
lib/ethdev/rte_mtr.h +9 -0
+	/**
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the outermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_DSCP = RTE_BIT64(2),

OK.
Please change name to METHOD_IP.
Description: Change the "outermost DSCP" to "the DSCP field of the outermost IP header". I would move this up on the second position (to follow immediately after the color blind method).

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 256

Quoted 13 lines
lib/ethdev/rte_mtr.h +13 -0
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the outermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the outermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP = RTE_BIT64(3),

OK.
Please change name to METHOD_VLAN_IP.
This should follow immediately after the METHOD_VLAN.
Description: please use "Otherwise" before "if the input packet is IP"; please replace "outermost DSCP" as above. Is your HW using DEI + PCP or just PCP?

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 265

Quoted 9 lines
lib/ethdev/rte_mtr.h +9 -0
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN = RTE_BIT64(4),

OK.
Is your HW using DEI + PCP or just PCP?

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 274

Quoted 9 lines
lib/ethdev/rte_mtr.h +9 -0
+	/**
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the innermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP = RTE_BIT64(5),

This is very confusing to me, I don't get what this one is about: The "inner" word in the name suggests that inner VLAN is attempted first, then IP DSCP (if no VLAN is present), but the description only talks about IP.

Quoted 13 lines
lib/ethdev/rte_mtr.h +13 -0
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the innermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP =
Quoted 1 line

RTE_BIT64(6),

OK.
Description fixes: Use "otherwise" before "if IP"; replace innermost DSCP with "DSCP field of the outermost IP header".

<snip>

Regards,
Cristian

#13 lore raw

RE: [PATCH v3 1/1] ethdev: mtr: support input color selection

Hi Jerin and folks, any update on this one? Thanks, Cristian

Quoted 144 lines

-----Original Message-----
From: Dumitrescu, Cristian <[email protected]>
Sent: Tuesday, March 1, 2022 5:48 PM
To: [email protected]; Thomas Monjalon <[email protected]>; Yigit, Ferruh <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>
Cc: [email protected]; Jerin Jacob <[email protected]>
Subject: RE: [PATCH v3 1/1] ethdev: mtr: support input color selection

HI Jerin,

Thanks for your patch! I think we are making great progress, here are a few more comments:

<snip>

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 219

Quoted 4 lines
lib/ethdev/rte_mtr.h +4 -0
+/**
+ * Input color method
+ */
+enum rte_mtr_input_color_method {

We should clean up the names of these methods a bit: we should not mix header names (VLAN, IP) with header field names (DSCP, PCP), in the sense that to me METHOD_VLAN_DSCP should be replaced with either:
* METHOD_OUTER_VLAN_IP :shorter name, as only the headers are mentioned (my preference, but I am OK with both)
* METHOD_OUTER_VLAN_PCP_IP_DSCP: longer name, as both the headers and the header fields are mentioned

Please put a blank line in between these methods to better readability.

I see some issues in the list of methods below, I am trying to do my best to catch them all:

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 225

Quoted 6 lines
lib/ethdev/rte_mtr.h +6 -0
+	/**
+	 * The input color is always green.
+	 * The default_input_color is ignored for this method.
+	 * @see struct rte_mtr_params::default_input_color
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_COLOR_BLIND  = RTE_BIT64(0),

OK.

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 234

Quoted 9 lines
lib/ethdev/rte_mtr.h +9 -0
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the outermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_VLAN = RTE_BIT64(1),

OK.
Does your HW use PCP+DEI , or just PCP?

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 243

Quoted 9 lines
lib/ethdev/rte_mtr.h +9 -0
+	/**
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the outermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_DSCP = RTE_BIT64(2),

OK.
Please change name to METHOD_IP.
Description: Change the "outermost DSCP" to "the DSCP field of the outermost IP header".
I would move this up on the second position (to follow immediately after the color blind method).

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 256

Quoted 13 lines
lib/ethdev/rte_mtr.h +13 -0
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the outermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the outermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP = RTE_BIT64(3),

OK.
Please change name to METHOD_VLAN_IP.
This should follow immediately after the METHOD_VLAN.
Description: please use "Otherwise" before "if the input packet is IP"; please replace "outermost DSCP" as above.
Is your HW using DEI + PCP or just PCP?

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 265

Quoted 9 lines
lib/ethdev/rte_mtr.h +9 -0
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN = RTE_BIT64(4),

OK.
Is your HW using DEI + PCP or just PCP?

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 274

Quoted 9 lines
lib/ethdev/rte_mtr.h +9 -0
+	/**
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the innermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP = RTE_BIT64(5),

This is very confusing to me, I don't get what this one is about: The "inner" word in the name suggests that inner VLAN is attempted first, then IP DSCP (if no VLAN is present), but the description only talks about IP.

Quoted 13 lines
lib/ethdev/rte_mtr.h +13 -0
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the innermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the default_input_color is applied.
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP =
Quoted 1 line

RTE_BIT64(6),

OK.
Description fixes: Use "otherwise" before "if IP"; replace innermost DSCP with "DSCP field of the outermost IP header".

<snip>

Regards,
Cristian

#14 lore raw

Re: [PATCH v3 1/1] ethdev: mtr: support input color selection

In reply to Dumitrescu, Cristian

0 0 0 0

0 0 0 0

Quoted 2 lines · Cristian

HI Jerin,

Hi Cristian,

Quoted 5 lines

Thanks for your patch! I think we are making great progress, here are a few more comments:

<snip>

Quoted 7 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 219

Quoted 4 lines
lib/ethdev/rte_mtr.h +4 -0
+/**
+ * Input color method
+ */
+enum rte_mtr_input_color_method {

We should clean up the names of these methods a bit: we should not mix header names (VLAN, IP) with header field names (DSCP, PCP), in the sense that to me METHOD_VLAN_DSCP should be replaced with either:
* METHOD_OUTER_VLAN_IP :shorter name, as only the headers are mentioned (my preference, but I am OK with both)

OK, We will keep VLAN and IP. By default OUTER is implicit in other DPDK API spec,i.e if not mentioned, it is outer. Hence I removed the outer. I can add outer explicit if you think in that way. See last comment.

Quoted 5 lines

* METHOD_OUTER_VLAN_PCP_IP_DSCP: longer name, as both the headers and the header fields are mentioned

Please put a blank line in between these methods to better readability.

I see some issues in the list of methods below, I am trying to do my best to catch them all:

Thanks. Sorry for the delay in reply.

Quoted 20 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 225

Quoted 7 lines
lib/ethdev/rte_mtr.h +6 -0
+     /**
+      * The input color is always green.
+      * The default_input_color is ignored for this method.
+      * @see struct rte_mtr_params::default_input_color
+      */
+     RTE_MTR_INPUT_COLOR_METHOD_COLOR_BLIND  = RTE_BIT64(0),

OK.

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 234

Quoted 9 lines
lib/ethdev/rte_mtr.h +9 -0
+     /**
+      * If the input packet has at least one VLAN label, its input color is
+      * detected by the outermost VLAN DEI(1bit), PCP(3 bits)
+      * indexing into the struct rte_mtr_params::vlan_table.
+      * Otherwise, the default_input_color is applied.
+      * @see struct rte_mtr_params::default_input_color
+      * @see struct rte_mtr_params::vlan_table
+      */
+     RTE_MTR_INPUT_COLOR_METHOD_VLAN = RTE_BIT64(1),
Quoted 2 lines

OK.
Does your HW use PCP+DEI , or just PCP?

PCP + DEI

Quoted 11 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 243

Quoted 10 lines
lib/ethdev/rte_mtr.h +9 -0
+     /**
+      * If the input packet is IPv4 or IPv6, its input color is detected by
+      * the outermost DSCP field indexing into the
+      * struct rte_mtr_params::dscp_table.
+      * Otherwise, the default_input_color is applied.
+      * @see struct rte_mtr_params::default_input_color
+      * @see struct rte_mtr_params::dscp_table
+      */
+     RTE_MTR_INPUT_COLOR_METHOD_DSCP = RTE_BIT64(2),
Quoted 3 lines

OK.
Please change name to METHOD_IP.
Description: Change the "outermost DSCP" to "the DSCP field of the outermost IP header".

OK

Quoted 1 line

I would move this up on the second position (to follow immediately after the color blind method).

Please check the summary below.

Quoted 15 lines
Quoted 4 lines
lib/ethdev/rte_mtr.h +3 -0
+     /**
+      * If the input packet has at least one VLAN label, its input color is
+      * detected by the outermost VLAN DEI(1bit), PCP(3 bits)

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 256

Quoted 10 lines
lib/ethdev/rte_mtr.h +10 -0
+      * indexing into the struct rte_mtr_params::vlan_table.
+      * If the input packet is IPv4 or IPv6, its input color is detected by
+      * the outermost DSCP field indexing into the
+      * struct rte_mtr_params::dscp_table.
+      * Otherwise, the default_input_color is applied.
+      * @see struct rte_mtr_params::default_input_color
+      * @see struct rte_mtr_params::vlan_table
+      * @see struct rte_mtr_params::dscp_table
+      */
+     RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP = RTE_BIT64(3),
Quoted 2 lines

OK.
Please change name to METHOD_VLAN_IP.

OK

Quoted 1 line

This should follow immediately after the METHOD_VLAN.

OK

Quoted 1 line

Description: please use "Otherwise" before "if the input packet is IP"; please replace "outermost DSCP" as above.

OK

Quoted 1 line

Is your HW using DEI + PCP or just PCP?

OK

Quoted 11 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 265

Quoted 10 lines
lib/ethdev/rte_mtr.h +9 -0
+     /**
+      * If the input packet has at least one VLAN label, its input color is
+      * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+      * indexing into the struct rte_mtr_params::vlan_table.
+      * Otherwise, the default_input_color is applied.
+      * @see struct rte_mtr_params::default_input_color
+      * @see struct rte_mtr_params::vlan_table
+      */
+     RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN = RTE_BIT64(4),
Quoted 2 lines

OK.
Is your HW using DEI + PCP or just PCP?

DEI + PCP

Quoted 11 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 274

Quoted 10 lines
lib/ethdev/rte_mtr.h +9 -0
+     /**
+      * If the input packet is IPv4 or IPv6, its input color is detected by
+      * the innermost DSCP field indexing into the
+      * struct rte_mtr_params::dscp_table.
+      * Otherwise, the default_input_color is applied.
+      * @see struct rte_mtr_params::default_input_color
+      * @see struct rte_mtr_params::dscp_table
+      */
+     RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP = RTE_BIT64(5),
Quoted 1 line

This is very confusing to me, I don't get what this one is about: The "inner" word in the name suggests that inner VLAN is attempted first, then IP DSCP (if no VLAN is present), but the description only talks about IP.

This case attempts only inner IP DSCP. VLAN does not matter.

Quoted 16 lines
Quoted 14 lines
lib/ethdev/rte_mtr.h +13 -0
+     /**
+      * If the input packet has at least one VLAN label, its input color is
+      * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+      * indexing into the struct rte_mtr_params::vlan_table.
+      * If the input packet is IPv4 or IPv6, its input color is detected by
+      * the innermost DSCP field indexing into the
+      * struct rte_mtr_params::dscp_table.
+      * Otherwise, the default_input_color is applied.
+      * @see struct rte_mtr_params::default_input_color
+      * @see struct rte_mtr_params::vlan_table
+      * @see struct rte_mtr_params::dscp_table
+      */
+     RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP =
Quoted 1 line

RTE_BIT64(6),

Quoted 2 lines

OK.
Description fixes: Use "otherwise" before "if IP"; replace innermost DSCP with "DSCP field of the outermost IP header".

OK.

To summarize we have 4 attributes, Please find below the truth table
1) Outer VLAN
2) Outer IP
3) Inner VLAN
4) Inner IP

Inner IP -Inner VLAN- Outer IP-Outer VLAN
0 0 0 0
- Not valid case
0 0 0 1
- RTE_MTR_INPUT_COLOR_METHOD_OUTER_VLAN
0 0 1 0
- RTE_MTR_INPUT_COLOR_METHOD_OUTER_IP
0 0 1 1
- RTE_MTR_INPUT_COLOR_METHOD_OUTER_VLAN_OUTER_IP - If found outer VLAN then vlan else outer IP
0 1 0 0
- RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN
0 1 0 1
- RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_OUTER_VLAN - If found inner VLAN else outer VLAN
0 1 1 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_OUTER_IP
0 1 1 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_OUTER_IP_OUTER_VLAN - If found
inner vlan then inner vlan else outer IP else outer VLAN
1 0 0 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP
1 0 0 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_OUTER_VLAN
1 0 1 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_OUTER_IP
1 0 1 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_OUTER_IP_OUTER_VLAN
1 1 0 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN
1 1 0 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN_OUTER_VLAN
1 1 1 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN_OUTER_IP
1 1 1 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN_OUTER_IP_OUTER_VLAN

Is this above enumeration fine, If not, Please suggest.

In Interms of name,
a) We could omit explicit OUTER to reduce the length as suggestion.
b) or change IIP, OIP, IVLAN, OVLAN kind of scheme to reduce the name.

Let me know the names and enumeration you prefer, I will change accordingly in the next version?

Quoted 5 lines

<snip>

Regards,
Cristian

#15 lore raw

RE: [PATCH v3 1/1] ethdev: mtr: support input color selection

Quoted 50 lines

To summarize we have 4 attributes, Please find below the truth table
1) Outer VLAN
2) Outer IP
3) Inner VLAN
4) Inner IP

Inner IP -Inner VLAN- Outer IP-Outer VLAN
0 0 0 0
- Not valid case
0 0 0 1
- RTE_MTR_INPUT_COLOR_METHOD_OUTER_VLAN
0 0 1 0
- RTE_MTR_INPUT_COLOR_METHOD_OUTER_IP
0 0 1 1
- RTE_MTR_INPUT_COLOR_METHOD_OUTER_VLAN_OUTER_IP - If found outer VLAN
then vlan else outer IP
0 1 0 0
- RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN
0 1 0 1
- RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_OUTER_VLAN - If found inner
VLAN else outer VLAN
0 1 1 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_OUTER_IP
0 1 1 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_OUTER_IP_OUTER_VLAN -
If found
inner vlan then inner vlan else outer IP else outer VLAN
1 0 0 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP
1 0 0 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_OUTER_VLAN
1 0 1 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_OUTER_IP
1 0 1 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_OUTER_IP_OUTER_VLAN
1 1 0 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN
1 1 0 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN_OUTER_VLAN
1 1 1 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN_OUTER_IP
1 1 1 1 -

RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN_OUTER_IP_OUTE R_VLAN

Quoted 9 lines

Is this above enumeration fine, If not, Please suggest.

In Interms of name,
a) We could omit explicit OUTER to reduce the length as suggestion.
b) or change IIP, OIP, IVLAN, OVLAN kind of scheme to reduce the name.

Let me know the names and enumeration you prefer, I will change accordingly in the next version?

Hi Jerin,

The above table looks confusing to me, I suggest we have a meeting next week to go over it and then report back to the list?

Regards,
Cristian

#16 lore raw

Re: [PATCH v3 1/1] ethdev: mtr: support input color selection

Quoted 57 lines · Cristian
Quoted 57 lines

To summarize we have 4 attributes, Please find below the truth table
1) Outer VLAN
2) Outer IP
3) Inner VLAN
4) Inner IP

Inner IP -Inner VLAN- Outer IP-Outer VLAN
0 0 0 0
- Not valid case
0 0 0 1
- RTE_MTR_INPUT_COLOR_METHOD_OUTER_VLAN
0 0 1 0
- RTE_MTR_INPUT_COLOR_METHOD_OUTER_IP
0 0 1 1
- RTE_MTR_INPUT_COLOR_METHOD_OUTER_VLAN_OUTER_IP - If found outer VLAN
then vlan else outer IP
0 1 0 0
- RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN
0 1 0 1
- RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_OUTER_VLAN - If found inner
VLAN else outer VLAN
0 1 1 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_OUTER_IP
0 1 1 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_OUTER_IP_OUTER_VLAN -
If found
inner vlan then inner vlan else outer IP else outer VLAN
1 0 0 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP
1 0 0 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_OUTER_VLAN
1 0 1 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_OUTER_IP
1 0 1 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_OUTER_IP_OUTER_VLAN
1 1 0 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN
1 1 0 1 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN_OUTER_VLAN
1 1 1 0 -
RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN_OUTER_IP
1 1 1 1 -

RTE_MTR_INPUT_COLOR_METHOD_INNER_IP_INNER_VLAN_OUTER_IP_OUTE R_VLAN

Is this above enumeration fine, If not, Please suggest.

In Interms of name,
a) We could omit explicit OUTER to reduce the length as suggestion.
b) or change IIP, OIP, IVLAN, OVLAN kind of scheme to reduce the name.

Quoted 7 lines
Quoted 3 lines

Let me know the names and enumeration you prefer, I will change accordingly in the next version?

Hi Jerin,

The above table looks confusing to me, I suggest we have a meeting next week to go over it and then report back to the list?

Scheduled a meeting at 11th April - 6:30 IST

Agenda:
To discuss https://patches.dpdk.org/project/dpdk/patch/[email protected]/
patch

Let me know, If time needs to change to include any interested participants.

Hi there,

Jerin Jacob is inviting you to a scheduled Zoom meeting.

Topic: Jerin Jacob Kollanukkaran's Personal Meeting Room

Join Zoom Meeting:
https://marvell.zoom.us/j/9901077677?pwd=T2lTTGMwYlc1YTQzMnR4eGRWQXR6QT09

    Password: 339888

Or Telephone:
Dial(for higher quality, dial a number based on your current location):
US: +1 301 715 8592 or +1 312 626 6799 or +1 346 248 7799
or +1 646 558 8656 or +1 669 900 6833 or +1 253 215 8782 or 888 788 0099 (Toll Free) or 833 548 0276 (Toll Free) or 833 548 0282 (Toll Free) or 877 853 5247 (Toll Free)

    Meeting ID: 990 107 7677
    Password: 358309
    International numbers available: https://marvell.zoom.us/u/adpcCpMHYt

Or a Video Conference Room:
From Touchpad: Tap Join Zoom button. When prompted, enter 990 107 7677
Password: 358309

For China locations, from Touchpad: Dial* then 990 107 7677

    Password: 358309
Quoted 3 lines

Regards,
Cristian

#17 lore raw

RE: [PATCH v3 1/1] ethdev: mtr: support input color selection

Hi folks,

Thanks to the community colleagues that participated to the call earlier today. Apologies for not CC-ing all the 9 attendants, as I don't have the email address for all of them.

We had a good meeting, I think we agreed on a good solution that will also simplify the API proposal.

Recap on the problem statement:
1. How do we decide on the input color for the current packet in a deterministic (implementation independent) way?
2. Multiple choices possible for a given packet: The same packet might contain multiple headers that can provide the input color. Examples: VLAN (the PCP and DEI fields), IP (DSCP field), others. Some headers of same type may show up in the same packet (e.g. outer/inner header).
3. Some of the possible choices might not be available for a given packet: Different packets may contain different headers.

Proposed solution:
1. Configure which protocols to enable. Example: we might want to consider Outer VLAN and Outer IP, but disable Inner VLAN and inner IP.
2. Configure on the priority of each of the enabled protocols (0 = highest priority). Example: If the current packet has an Outer VLAN header, but not an Outer IP header, then we get the input color from the Outer VLAN header; same, if there is an Outer IP header, but no Outer VLAN header, we get the priority from the Outer IP header. But what if the packet has both an Outer VLAN and an Outer IP header? In this case we need to consider the priority and pick the input color from the highest priority header.
3. Configure the default input color. What happens if the packet does not have an Outer VLAN header, nor an Outer IP header? Then the default input color is picked.

API guideline:

enum rte_mtr_color_in_protocol {
	RTE_MTR_COLOR_IN_OUTER_VLAN,
	RTE_MTR_COLOR_IN_INNER_VLAN,
	RTE_MTR_COLOR_IN_OUTER_IP,
	RTE_MTR_COLOR_IN_INNER_IP,
	//more to add as needed. Per Ori's comment, we can add a reunion of the two protocols as well when needed, e.g. RTE_MTR_COLOR_IN_OUTER_VLAN_OUTER_IP that has a (4+6)-bit index (PCI, DEI, DSCP).
}

int
rte_mtr_color_in_protocol_priority_set(enum rte_mtr_color_in_protocol proto, uint32_t priority); //0 is highest priority

Regards,
Cristian

#18 lore raw

RE: [PATCH v3 1/1] ethdev: mtr: support input color selection

Adding some missing guys, that I know about.

Ori

Quoted 54 lines

-----Original Message-----
From: Dumitrescu, Cristian <[email protected]>
Sent: Monday, April 11, 2022 5:46 PM
To: [email protected]; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>
Cc: Jerin Jacob <[email protected]>; Jerin Jacob <[email protected]>; [email protected]; Ori Kam <[email protected]>
Subject: RE: [PATCH v3 1/1] ethdev: mtr: support input color selection

Hi folks,

Thanks to the community colleagues that participated to the call earlier today. Apologies for not CC-ing all the 9 attendants, as I don't have the email address for all of them.

We had a good meeting, I think we agreed on a good solution that will also simplify the API proposal.

Recap on the problem statement:
1. How do we decide on the input color for the current packet in a deterministic (implementation independent) way?
2. Multiple choices possible for a given packet: The same packet might contain multiple headers that can provide the input color. Examples: VLAN (the PCP and DEI fields), IP (DSCP field), others. Some headers of same type may show up in the same packet (e.g. outer/inner header).
3. Some of the possible choices might not be available for a given packet: Different packets may contain different headers.

Proposed solution:
1. Configure which protocols to enable. Example: we might want to consider Outer VLAN and Outer IP, but disable Inner VLAN and inner IP.
2. Configure on the priority of each of the enabled protocols (0 = highest priority). Example: If the current packet has an Outer VLAN header, but not an Outer IP header, then we get the input color from the Outer VLAN header; same, if there is an Outer IP header, but no Outer VLAN header, we get the priority from the Outer IP header. But what if the packet has both an Outer VLAN and an Outer IP header? In this case we need to consider the priority and pick the input color from the highest priority header.
3. Configure the default input color. What happens if the packet does not have an Outer VLAN header, nor an Outer IP header? Then the default input color is picked.

API guideline:

enum rte_mtr_color_in_protocol {
	RTE_MTR_COLOR_IN_OUTER_VLAN,
	RTE_MTR_COLOR_IN_INNER_VLAN,
	RTE_MTR_COLOR_IN_OUTER_IP,
	RTE_MTR_COLOR_IN_INNER_IP,
	//more to add as needed. Per Ori's comment, we can add a reunion of the two protocols as

well when needed, e.g. RTE_MTR_COLOR_IN_OUTER_VLAN_OUTER_IP that has a (4+6)-bit index (PCI, DEI, DSCP).
}

int
rte_mtr_color_in_protocol_priority_set(enum rte_mtr_color_in_protocol proto, uint32_t priority); //0 is highest priority

Regards,
Cristian

#19 lore raw

PATCH v4 1/1 ethdev: mtr: support protocol based input color selection

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

---
v4..v3:

- Aligned with community meeting call which is documented in
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
as last message. With following exception,
- Used RTE_MTR_COLOR_IN_*_DSCP instead of RTE_MTR_COLOR_IN_*_IP as there is already dscp_table and rte_mtr_meter_dscp_table_update() API. Changing above symbols break existing application for no good.
- Updated 22.07 release notes
- Remove testpmd changes from series to finalize the API spec first and then we can send testpmd changes.

v3..v2:

- Fix input color flags as a bitmask
- Add definitions for newly added API

v2..v1:
- Fix seperate typo

v1..RFC:

Address the review comments by Cristian at
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

- Moved to v22.07 release
- Updated rte_mtr_input_color_method to support all VLAN, DSCP, Inner cases
- Added input_color_method
- Removed union between vlan_table and dscp_table
- Kept VLAN instead of PCP as HW coloring based on DEI(1bit), PCP(3 bits)

 .../traffic_metering_and_policing.rst         |  33 ++++
 doc/guides/rel_notes/release_22_07.rst        |  10 +
 lib/ethdev/rte_mtr.c                          |  23 +++
 lib/ethdev/rte_mtr.h                          | 186 +++++++++++++++++-
 lib/ethdev/rte_mtr_driver.h                   |  19 ++
 lib/ethdev/version.map                        |   4 +
 6 files changed, 265 insertions(+), 10 deletions(-)
doc/guides/prog_guide/traffic_metering_and_policing.rst +33 -0
index ceb5a96488..75deabbaf1 100644
@@ -21,6 +21,7 @@ The main features are:
 * Policer actions (per meter output color): recolor, drop
 * Statistics (per policer output color)
 * Chaining multiple meter objects
+* Protocol based input color selection
 
 Configuration steps
 -------------------
@@ -105,3 +106,35 @@ traffic meter and policing library.
    * Adding one (or multiple) actions of the type ``RTE_FLOW_ACTION_TYPE_METER``
      to the list of meter actions (``struct rte_mtr_meter_policy_params::actions``)
      specified per color as show in :numref:`figure_rte_mtr_chaining`.
+
+Protocol based input color selection
+------------------------------------
+
+The API supports selecting the input color based on the packet content.
+Following is the API usage model for the same.
+
+#. Probe the protocol based input color selection device capabilities using
+   following parameter using ``rte_mtr_capabilities_get()`` API.
+
+   * ``struct rte_mtr_capabilities::input_color_proto_mask;``
+   * ``struct rte_mtr_capabilities::separate_input_color_table_per_port``
+
+#. When creating the meter object using ``rte_mtr_create()``, configure
+   relevant input color selection parameters such as
+
+   * Input color protocols with ``struct rte_mtr_params::input_color_proto_mask``
+
+   * If ``struct rte_mtr_params::input_color_proto_mask`` has multiple bits set then
+     ``rte_mtr_color_in_protocol_priority_set()`` shall be used to set the priority,
+     in the order, in which protocol to be used to find the input color.
+
+   * Fill the tables ``struct rte_mtr_params::dscp_table``,
+     ``struct rte_mtr_params::vlan_table`` based on input color selected.
+
+   * Update the ``struct rte_mtr_params::default_input_color`` to determine
+     the default input color in case the input packet does not match
+     the input color method.
+
+   * If needed, update the input color table at runtime using
+     ``rte_mtr_meter_vlan_table_update()`` and ``rte_mtr_meter_dscp_table_update()``
+     APIs.
doc/guides/rel_notes/release_22_07.rst +10 -0
index 42a5f2d990..746622f9b3 100644
@@ -55,6 +55,13 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added protocol based input color for meter.**
+
+  Added new APIs ``rte_mtr_color_in_protocol_priority_set()``,
+  ``rte_mtr_meter_vlan_table_update()`` and updated ``struct rte_mtr_params``
+  and ``struct rte_mtr_capabilities`` to support protocol based
+  input color for meter.
+
 
 Removed Items
 -------------
@@ -102,6 +109,9 @@ ABI Changes
 
 * No ABI change that would break compatibility with 21.11.
 
+* Experimental structures ``struct rte_mtr_params``
+  and ``struct rte_mtr_capabilities`` updated to support
+  protocol based input color for meter.
 
 Known Issues
 ------------
lib/ethdev/rte_mtr.c +23 -0
index e49fcf271c..a112fe65f5 100644
@@ -207,6 +207,29 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
 		mtr_id, dscp_table, error);
 }
 
+/** MTR object meter VLAN table update */
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
+				enum rte_color *vlan_table,
+				struct rte_mtr_error *error)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	return RTE_MTR_FUNC(port_id, meter_vlan_table_update)(dev,
+		mtr_id, vlan_table, error);
+}
+
+/** Set the priority for input color protocol on MTR object */
+int
+rte_mtr_color_in_protocol_priority_set(uint16_t port_id, uint32_t mtr_id,
+				       enum rte_mtr_color_in_protocol proto,
+				       uint32_t priority,
+				       struct rte_mtr_error *error)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	return RTE_MTR_FUNC(port_id, in_proto_prio_set)(dev,
+		mtr_id, proto, priority, error);
+}
+
 /** MTR object enabled stats update */
 int
 rte_mtr_stats_update(uint16_t port_id,
lib/ethdev/rte_mtr.h +176 -10

220 lines not on this page · raw message

lib/ethdev/rte_mtr_driver.h +19 -0
index ee8c6ef7ad..827952adc6 100644
@@ -97,6 +97,19 @@ typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
+/** @internal mtr object meter vlan table update. */
+typedef int (*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev,
+	uint32_t mtr_id,
+	enum rte_color *vlan_table,
+	struct rte_mtr_error *error);
+
+/** @internal Set the priority for input color protocol on MTR object. */
+typedef int (*rte_mtr_meter_color_in_proto_prio_set_t)(struct rte_eth_dev *dev,
+	uint32_t mtr_id,
+	enum rte_mtr_color_in_protocol proto,
+	uint32_t priority,
+	struct rte_mtr_error *error);
+
 /** @internal MTR object enabled stats update. */
 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
 	uint32_t mtr_id,
@@ -139,6 +152,12 @@ struct rte_mtr_ops {
 	/** MTR object meter DSCP table update */
 	rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
 
+	/** MTR object meter VLAN table update */
+	rte_mtr_meter_vlan_table_update_t meter_vlan_table_update;
+
+	/** Set the priority for input color protocol on MTR object. */
+	rte_mtr_meter_color_in_proto_prio_set_t in_proto_prio_set;
+
 	/** MTR object enabled stats update */
 	rte_mtr_stats_update_t stats_update;
 
lib/ethdev/version.map +4 -0
index 20391ab29e..cccbf6dee5 100644
@@ -279,6 +279,10 @@ EXPERIMENTAL {
 	rte_flow_async_action_handle_create;
 	rte_flow_async_action_handle_destroy;
 	rte_flow_async_action_handle_update;
+
+	# added in 22.07
+	rte_mtr_meter_vlan_table_update;
+	rte_mtr_color_in_protocol_priority_set;
 };
 
 INTERNAL {
Signature · 1 line
2.36.0
#20 lore raw

Re: [dpdk-dev] [PATCH v4] ethdev: mtr: support protocol based input color selection

Quoted 436 lines · [email protected] writes:

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

---
v4..v3:

- Aligned with community meeting call which is documented in
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
as last message. With following exception,
- Used RTE_MTR_COLOR_IN_*_DSCP instead of RTE_MTR_COLOR_IN_*_IP as there is already dscp_table and rte_mtr_meter_dscp_table_update() API. Changing above symbols break existing application for no good.
- Updated 22.07 release notes
- Remove testpmd changes from series to finalize the API spec first and then we can send testpmd changes.

v3..v2:

- Fix input color flags as a bitmask
- Add definitions for newly added API

v2..v1:
- Fix seperate typo

v1..RFC:

Address the review comments by Cristian at
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

- Moved to v22.07 release
- Updated rte_mtr_input_color_method to support all VLAN, DSCP, Inner cases
- Added input_color_method
- Removed union between vlan_table and dscp_table
- Kept VLAN instead of PCP as HW coloring based on DEI(1bit), PCP(3 bits)

 .../traffic_metering_and_policing.rst         |  33 ++++
 doc/guides/rel_notes/release_22_07.rst        |  10 +
 lib/ethdev/rte_mtr.c                          |  23 +++
 lib/ethdev/rte_mtr.h                          | 186 +++++++++++++++++-
 lib/ethdev/rte_mtr_driver.h                   |  19 ++
 lib/ethdev/version.map                        |   4 +
 6 files changed, 265 insertions(+), 10 deletions(-)
doc/guides/prog_guide/traffic_metering_and_policing.rst +33 -0
index ceb5a96488..75deabbaf1 100644
@@ -21,6 +21,7 @@ The main features are:
 * Policer actions (per meter output color): recolor, drop
 * Statistics (per policer output color)
 * Chaining multiple meter objects
+* Protocol based input color selection
 
 Configuration steps
 -------------------
@@ -105,3 +106,35 @@ traffic meter and policing library.
    * Adding one (or multiple) actions of the type ``RTE_FLOW_ACTION_TYPE_METER``
      to the list of meter actions (``struct rte_mtr_meter_policy_params::actions``)
      specified per color as show in :numref:`figure_rte_mtr_chaining`.
+
+Protocol based input color selection
+------------------------------------
+
+The API supports selecting the input color based on the packet content.
+Following is the API usage model for the same.
+
+#. Probe the protocol based input color selection device capabilities using
+   following parameter using ``rte_mtr_capabilities_get()`` API.
+
+   * ``struct rte_mtr_capabilities::input_color_proto_mask;``
+   * ``struct rte_mtr_capabilities::separate_input_color_table_per_port``
+
+#. When creating the meter object using ``rte_mtr_create()``, configure
+   relevant input color selection parameters such as
+
+   * Input color protocols with ``struct rte_mtr_params::input_color_proto_mask``
+
+   * If ``struct rte_mtr_params::input_color_proto_mask`` has multiple bits set then
+     ``rte_mtr_color_in_protocol_priority_set()`` shall be used to set the priority,
+     in the order, in which protocol to be used to find the input color.
+
+   * Fill the tables ``struct rte_mtr_params::dscp_table``,
+     ``struct rte_mtr_params::vlan_table`` based on input color selected.
+
+   * Update the ``struct rte_mtr_params::default_input_color`` to determine
+     the default input color in case the input packet does not match
+     the input color method.
+
+   * If needed, update the input color table at runtime using
+     ``rte_mtr_meter_vlan_table_update()`` and ``rte_mtr_meter_dscp_table_update()``
+     APIs.
doc/guides/rel_notes/release_22_07.rst +10 -0
index 42a5f2d990..746622f9b3 100644
@@ -55,6 +55,13 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added protocol based input color for meter.**
+
+  Added new APIs ``rte_mtr_color_in_protocol_priority_set()``,
+  ``rte_mtr_meter_vlan_table_update()`` and updated ``struct rte_mtr_params``
+  and ``struct rte_mtr_capabilities`` to support protocol based
+  input color for meter.
+
 
 Removed Items
 -------------
@@ -102,6 +109,9 @@ ABI Changes
 
 * No ABI change that would break compatibility with 21.11.
 
+* Experimental structures ``struct rte_mtr_params``
+  and ``struct rte_mtr_capabilities`` updated to support
+  protocol based input color for meter.
 
 Known Issues
 ------------
lib/ethdev/rte_mtr.c +23 -0
index e49fcf271c..a112fe65f5 100644
@@ -207,6 +207,29 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
 		mtr_id, dscp_table, error);
 }
 
+/** MTR object meter VLAN table update */
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
+				enum rte_color *vlan_table,
+				struct rte_mtr_error *error)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	return RTE_MTR_FUNC(port_id, meter_vlan_table_update)(dev,
+		mtr_id, vlan_table, error);
+}
+
+/** Set the priority for input color protocol on MTR object */
+int
+rte_mtr_color_in_protocol_priority_set(uint16_t port_id, uint32_t mtr_id,
+				       enum rte_mtr_color_in_protocol proto,
+				       uint32_t priority,
+				       struct rte_mtr_error *error)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	return RTE_MTR_FUNC(port_id, in_proto_prio_set)(dev,
+		mtr_id, proto, priority, error);
+}
+
 /** MTR object enabled stats update */
 int
 rte_mtr_stats_update(uint16_t port_id,
lib/ethdev/rte_mtr.h +176 -10
index 40df0888c8..76ffbcf724 100644
@@ -213,6 +213,52 @@ struct rte_mtr_meter_policy_params {
 	const struct rte_flow_action *actions[RTE_COLORS];
 };
 
+/**
+ * Input color protocol method
+ */
+enum rte_mtr_color_in_protocol {
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the outermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * Otherwise, the *default_input_color* is applied.
+	 *
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN = RTE_BIT64(0),
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * Otherwise, the *default_input_color* is applied.
+	 *
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_COLOR_IN_PROTO_INNER_VLAN = RTE_BIT64(1),
+	/**
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the outermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the *default_input_color* is applied.
+	 *
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_COLOR_IN_PROTO_OUTER_DSCP = RTE_BIT64(2),
+	/**
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the innermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the *default_input_color* is applied.
+	 *
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_COLOR_IN_PROTO_INNER_DSCP = RTE_BIT64(3),
+};
+
 /**
  * Parameters for each traffic metering & policing object
  *
@@ -233,20 +279,58 @@ struct rte_mtr_params {
 	 */
 	int use_prev_mtr_color;
 
-	/** Meter input color. When non-NULL: it points to a pre-allocated and
+	/** Meter input color based on IP DSCP protocol field.
+	 *
+	 * Valid when *input_color_proto_mask* set to any of the following
+	 * RTE_MTR_COLOR_IN_PROTO_OUTER_DSCP,
+	 * RTE_MTR_COLOR_IN_PROTO_INNER_DSCP
+	 *
+	 * When non-NULL: it points to a pre-allocated and
 	 * pre-populated table with exactly 64 elements providing the input
 	 * color for each value of the IPv4/IPv6 Differentiated Services Code
-	 * Point (DSCP) input packet field. When NULL: it is equivalent to
-	 * setting this parameter to an all-green populated table (i.e. table
-	 * with all the 64 elements set to green color). The color blind mode
-	 * is configured by setting *use_prev_mtr_color* to 0 and *dscp_table*
-	 * to either NULL or to an all-green populated table. When
-	 * *use_prev_mtr_color* is non-zero value or when *dscp_table* contains
-	 * at least one yellow or red color element, then the color aware mode
-	 * is configured.
+	 * Point (DSCP) input packet field.
+	 *
+	 * When NULL: it is equivalent to setting this parameter to an all-green
+	 * populated table (i.e. table with all the 64 elements set to green
+	 * color). The color blind mode is configured by setting
+	 * *use_prev_mtr_color* to 0 and *dscp_table* to either NULL or to an
+	 * all-green populated table.
+	 *
+	 * When *use_prev_mtr_color* is non-zero value or when *dscp_table*
+	 * contains at least one yellow or red color element, then the color
+	 * aware mode is configured.
+	 *
+	 * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_OUTER_DSCP
+	 * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_DSCP
+	 * @see struct rte_mtr_params::input_color_proto_mask
 	 */
 	enum rte_color *dscp_table;
-
+	/** Meter input color based on VLAN DEI(1bit), PCP(3 bits) protocol
+	 * fields.
+	 *
+	 * Valid when *input_color_proto_mask* set to any of the following
+	 * RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN,
+	 * RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
+	 *
+	 * When non-NULL: it points to a pre-allocated and pre-populated
+	 * table with exactly 16 elements providing the input color for
+	 * each value of the DEI(1bit), PCP(3 bits) input packet field.
+	 *
+	 * When NULL: it is equivalent to setting this parameter to an
+	 * all-green populated table (i.e. table with
+	 * all the 16 elements set to green color). The color blind mode
+	 * is configured by setting *use_prev_mtr_color* to 0 and
+	 * *vlan_table* to either NULL or to an all-green populated table.
+	 *
+	 * When *use_prev_mtr_color* is non-zero value
+	 * or when *vlan_table* contains at least one yellow or
+	 * red color element, then the color aware mode is configured.
+	 *
+	 * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN
+	 * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
+	 * @see struct rte_mtr_params::input_color_proto_mask
+	 */
+	enum rte_color *vlan_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
 	 * *meter_profile_id* is set to NONE.
@@ -261,6 +345,25 @@ struct rte_mtr_params {
 
 	/** Meter policy ID. @see rte_mtr_meter_policy_add() */
 	uint32_t meter_policy_id;
+
+	/** Set of input color protocols to be enabled.
+	 *
+	 * Set value to zero to configure as color blind mode.
+	 *
+	 * When multiple bits set then rte_mtr_color_in_protocol_priority_set()
+	 * shall be used to set the priority, in the order, in which protocol
+	 * to be used to find the inpput color.
+	 *
+	 * @see enum rte_mtr_color_in_protocol
+	 * @see rte_mtr_color_in_protocol_priority_set()
+	 */
+	uint64_t input_color_proto_mask;
+
+	/** Input color to be set for the input packet when none of the
+	 * enabled input color methods is applicable to the input packet.
+	 * Ignored when this when *input_color_proto_mask* set to zero.
+	 */
+	enum rte_color default_input_color;
 };
 
 /**
@@ -417,6 +520,16 @@ struct rte_mtr_capabilities {
 	 * @see enum rte_mtr_stats_type
 	 */
 	uint64_t stats_mask;
+
+	/** Set of supported input color protocol.
+	 * @see enum rte_mtr_color_in_protocol
+	 */
+	uint64_t input_color_proto_mask;
+
+	/** When non-zero, it indicates that driver supports separate
+	 * input color table for given ethdev port.
+	 */
+	int separate_input_color_table_per_port;
 };
 
 /**
@@ -832,6 +945,59 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
+/**
+ * MTR object VLAN table update
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[in] vlan_table
+ *   When non-NULL: it points to a pre-allocated and pre-populated table with
+ *   exactly 16 elements providing the input color for each value of the
+ *   each value of the DEI(1bit), PCP(3 bits) input packet field.
+ *   When NULL: it is equivalent to setting this parameter to an "all-green"
+ *   populated table (i.e. table with all the 16 elements set to green color).
+ * @param[out] error
+ *   Error details. Filled in only on error, when not NULL.
+ * @return
+ *   0 on success, non-zero error code otherwise.
+ */
+__rte_experimental
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
+				enum rte_color *vlan_table,
+				struct rte_mtr_error *error);
+/**
+ * Set the priority for input color protocol
+ *
+ * When multiple bits set in struct rte_mtr_params::input_color_proto_mask
+ * then this API shall be used to set the priority, in the order, in
+ * which protocol to be used to find the input color.
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[in] proto
+ *   Input color protocol to apply priority.
+ *   MTR object's *input_color_proto_mask* should be configured
+ *   with proto value.
+ * @param[in] priority
+ *   Input color protocol priority. Value zero indicates
+ *   the highest priority.
+ * @param[out] error
+ *   Error details. Filled in only on error, when not NULL.
+ * @return
+ *   0 on success, non-zero error code otherwise.
+ *
+ * @see rte_mtr_params::input_color_proto_mask
+ */
+__rte_experimental
+int
+rte_mtr_color_in_protocol_priority_set(uint16_t port_id, uint32_t mtr_id,
+	enum rte_mtr_color_in_protocol proto, uint32_t priority,
+	struct rte_mtr_error *error);
 /**
  * MTR object enabled statistics counters update
  *
lib/ethdev/rte_mtr_driver.h +19 -0
index ee8c6ef7ad..827952adc6 100644
@@ -97,6 +97,19 @@ typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
+/** @internal mtr object meter vlan table update. */
+typedef int (*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev,
+	uint32_t mtr_id,
+	enum rte_color *vlan_table,
+	struct rte_mtr_error *error);
+
+/** @internal Set the priority for input color protocol on MTR object. */
+typedef int (*rte_mtr_meter_color_in_proto_prio_set_t)(struct rte_eth_dev *dev,
+	uint32_t mtr_id,
+	enum rte_mtr_color_in_protocol proto,
+	uint32_t priority,
+	struct rte_mtr_error *error);
+
 /** @internal MTR object enabled stats update. */
 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
 	uint32_t mtr_id,
@@ -139,6 +152,12 @@ struct rte_mtr_ops {
 	/** MTR object meter DSCP table update */
 	rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
 
+	/** MTR object meter VLAN table update */
+	rte_mtr_meter_vlan_table_update_t meter_vlan_table_update;
+
+	/** Set the priority for input color protocol on MTR object. */
+	rte_mtr_meter_color_in_proto_prio_set_t in_proto_prio_set;
+
 	/** MTR object enabled stats update */
 	rte_mtr_stats_update_t stats_update;
 
lib/ethdev/version.map +0 -0
index 20391ab29e..cccbf6dee5 100644

lib/ethdev/version.map EXPERIMENTAL { · line 283

Quoted 5 lines
lib/ethdev/version.map +2 -0
@@ -279,6 +279,10 @@ EXPERIMENTAL {
 	rte_flow_async_action_handle_create;
 	rte_flow_async_action_handle_destroy;
 	rte_flow_async_action_handle_update;
+
+	# added in 22.07

Symbols are not in alphabetical order.

Quoted 5 lines
lib/ethdev/version.map +2 -0
+	rte_mtr_meter_vlan_table_update;
+	rte_mtr_color_in_protocol_priority_set;
 };
 
 INTERNAL {
Signature · 1 line
Regards, Ray K
#21 lore raw

Re: [dpdk-dev] [PATCH v4] ethdev: mtr: support protocol based input color selection

Quoted 44 lines · Ray Kinsella
Quoted 40 lines · [email protected] writes:

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

---
v4..v3:

- Aligned with community meeting call which is documented in
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
as last message. With following exception,
- Used RTE_MTR_COLOR_IN_*_DSCP instead of RTE_MTR_COLOR_IN_*_IP as there is already dscp_table and rte_mtr_meter_dscp_table_update() API. Changing above symbols break existing application for no good.
- Updated 22.07 release notes
- Remove testpmd changes from series to finalize the API spec first and then we can send testpmd changes.

v3..v2:

- Fix input color flags as a bitmask
- Add definitions for newly added API

v2..v1:
- Fix seperate typo

v1..RFC:

Address the review comments by Cristian at
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

Quoted 12 lines

lib/ethdev/version.map EXPERIMENTAL { · line 283

Quoted 10 lines
lib/ethdev/version.map +2 -0
index 20391ab29e..cccbf6dee5 100644
@@ -279,6 +279,10 @@ EXPERIMENTAL {
      rte_flow_async_action_handle_create;
      rte_flow_async_action_handle_destroy;
      rte_flow_async_action_handle_update;
+
+     # added in 22.07

Symbols are not in alphabetical order.

Thanks. Will fix it in v5

Quoted 10 lines

lib/ethdev/version.map EXPERIMENTAL { · line 288

Quoted 6 lines
lib/ethdev/version.map +2 -0
+     rte_mtr_meter_vlan_table_update;
+     rte_mtr_color_in_protocol_priority_set;
 };
 
 INTERNAL {

--
Regards, Ray K

#22 lore raw

RE: [dpdk-dev] [PATCH v4] ethdev: mtr: support protocol based input color selection

In reply to [email protected]

Hi Jerin,

Thank you for implementing according to our agreement, I am happy to see that we are converging.

Here are some comments below:

<snip>

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 217

Quoted 10 lines
lib/ethdev/rte_mtr.h +2 -0
index 40df0888c8..76ffbcf724 100644
@@ -213,6 +213,52 @@ struct rte_mtr_meter_policy_params {
 	const struct rte_flow_action *actions[RTE_COLORS];
 };
 
+/**
+ * Input color protocol method

I suggest adding some more explanations here:
More than one method can be enabled for a given meter. Even if enabled, a method might not be applicable to each input packet, in case the associated protocol header is not present in the packet. The highest priority method that is both enabled for the meter and also applicable for the current input packet wins; if none is both enabled and applicable, the default input color is used. @see function rte_mtr_color_in_protocol_priority_set()

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 225

Quoted 8 lines
lib/ethdev/rte_mtr.h +8 -0
+ */
+enum rte_mtr_color_in_protocol {
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the outermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * Otherwise, the *default_input_color* is applied.
+	 *

The statement "Otherwise, the *default_input_color* is applied" is incorrect IMO and should be removed, as multiple methods might be enabled and also applicable to a specific input packet, in which case the highest priority method wins, as opposed to the default input color.

I suggest a simplification "Enable the detection of the packet input color based on the outermost VLAN header fields DEI (1 bit) and PCP (3 bits). These fields are used as index into the VLAN table"

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 238

Quoted 13 lines
lib/ethdev/rte_mtr.h +13 -0
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN = RTE_BIT64(0),
+	/**
+	 * If the input packet has at least one VLAN label, its input color is
+	 * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+	 * indexing into the struct rte_mtr_params::vlan_table.
+	 * Otherwise, the *default_input_color* is applied.
+	 *
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::vlan_table
+	 */

Same simplification suggested here.

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 248

Quoted 10 lines
lib/ethdev/rte_mtr.h +10 -0
+	RTE_MTR_COLOR_IN_PROTO_INNER_VLAN = RTE_BIT64(1),
+	/**
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the outermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the *default_input_color* is applied.
+	 *
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::dscp_table
+	 */

Same simplification suggested here.

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 249

Quoted 1 line
lib/ethdev/rte_mtr.h +1 -0
+	RTE_MTR_COLOR_IN_PROTO_OUTER_DSCP = RTE_BIT64(2),

I am OK to keep DSCP for the name of the table instead of renaming the table, as you suggested, but this method name should reflect the protocol, not the field: RTE_MTR_COLOR_IN_PROTO_OUTER_IP.

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 258

Quoted 9 lines
lib/ethdev/rte_mtr.h +9 -0
+	/**
+	 * If the input packet is IPv4 or IPv6, its input color is detected by
+	 * the innermost DSCP field indexing into the
+	 * struct rte_mtr_params::dscp_table.
+	 * Otherwise, the *default_input_color* is applied.
+	 *
+	 * @see struct rte_mtr_params::default_input_color
+	 * @see struct rte_mtr_params::dscp_table
+	 */

Same simplification suggested here.

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 259

Quoted 1 line
lib/ethdev/rte_mtr.h +1 -0
+	RTE_MTR_COLOR_IN_PROTO_INNER_DSCP = RTE_BIT64(3),

I am OK to keep DSCP for the name of the table instead of renaming the table, as you suggested, but this method name should reflect the protocol, not the field: RTE_MTR_COLOR_IN_PROTO_INNER_IP.

Quoted 87 lines
lib/ethdev/rte_mtr.h +8 -7
+
 /**
  * Parameters for each traffic metering & policing object
  *
@@ -233,20 +279,58 @@ struct rte_mtr_params {
 	 */
 	int use_prev_mtr_color;
 
-	/** Meter input color. When non-NULL: it points to a pre-allocated and
+	/** Meter input color based on IP DSCP protocol field.
+	 *
+	 * Valid when *input_color_proto_mask* set to any of the following
+	 * RTE_MTR_COLOR_IN_PROTO_OUTER_DSCP,
+	 * RTE_MTR_COLOR_IN_PROTO_INNER_DSCP
+	 *
+	 * When non-NULL: it points to a pre-allocated and
 	 * pre-populated table with exactly 64 elements providing the input
 	 * color for each value of the IPv4/IPv6 Differentiated Services Code
-	 * Point (DSCP) input packet field. When NULL: it is equivalent to
-	 * setting this parameter to an all-green populated table (i.e. table
-	 * with all the 64 elements set to green color). The color blind mode
-	 * is configured by setting *use_prev_mtr_color* to 0 and *dscp_table*
-	 * to either NULL or to an all-green populated table. When
-	 * *use_prev_mtr_color* is non-zero value or when *dscp_table*

contains

lib/ethdev/rte_mtr.h +9 -2
-	 * at least one yellow or red color element, then the color aware mode
-	 * is configured.
+	 * Point (DSCP) input packet field.
+	 *
+	 * When NULL: it is equivalent to setting this parameter to an all-green
+	 * populated table (i.e. table with all the 64 elements set to green
+	 * color). The color blind mode is configured by setting
+	 * *use_prev_mtr_color* to 0 and *dscp_table* to either NULL or to an
+	 * all-green populated table.
+	 *
+	 * When *use_prev_mtr_color* is non-zero value or when

*dscp_table*

lib/ethdev/rte_mtr.h +4 -0
+	 * contains at least one yellow or red color element, then the color
+	 * aware mode is configured.
+	 *
+	 * @see enum

rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_OUTER_DSCP

lib/ethdev/rte_mtr.h +1 -0
+	 * @see enum

rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_DSCP

lib/ethdev/rte_mtr.h +23 -1
+	 * @see struct rte_mtr_params::input_color_proto_mask
 	 */
 	enum rte_color *dscp_table;
-
+	/** Meter input color based on VLAN DEI(1bit), PCP(3 bits) protocol
+	 * fields.
+	 *
+	 * Valid when *input_color_proto_mask* set to any of the following
+	 * RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN,
+	 * RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
+	 *
+	 * When non-NULL: it points to a pre-allocated and pre-populated
+	 * table with exactly 16 elements providing the input color for
+	 * each value of the DEI(1bit), PCP(3 bits) input packet field.
+	 *
+	 * When NULL: it is equivalent to setting this parameter to an
+	 * all-green populated table (i.e. table with
+	 * all the 16 elements set to green color). The color blind mode
+	 * is configured by setting *use_prev_mtr_color* to 0 and
+	 * *vlan_table* to either NULL or to an all-green populated table.
+	 *
+	 * When *use_prev_mtr_color* is non-zero value
+	 * or when *vlan_table* contains at least one yellow or
+	 * red color element, then the color aware mode is configured.
+	 *
+	 * @see enum

rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN

lib/ethdev/rte_mtr.h +1 -0
+	 * @see enum

rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_VLAN

lib/ethdev/rte_mtr.h +3 -0
+	 * @see struct rte_mtr_params::input_color_proto_mask
+	 */
+	enum rte_color *vlan_table;
 	/** Non-zero to enable the meter, zero to disable the meter at the

time

lib/ethdev/rte_mtr.h +3 -0
 	 * of MTR object creation. Ignored when the meter profile indicated by
 	 * *meter_profile_id* is set to NONE.
@@ -261,6 +345,25 @@ struct rte_mtr_params {
 
 	/** Meter policy ID. @see rte_mtr_meter_policy_add() */
 	uint32_t meter_policy_id;
+
+	/** Set of input color protocols to be enabled.
+	 *

lib/ethdev/rte_mtr.h struct rte_mtr_params { · line 360

Quoted 10 lines
lib/ethdev/rte_mtr.h +10 -0
+	 * Set value to zero to configure as color blind mode.
+	 *
+	 * When multiple bits set then rte_mtr_color_in_protocol_priority_set()
+	 * shall be used to set the priority, in the order, in which protocol
+	 * to be used to find the inpput color.
+	 *
+	 * @see enum rte_mtr_color_in_protocol
+	 * @see rte_mtr_color_in_protocol_priority_set()
+	 */
+	uint64_t input_color_proto_mask;

We should not have this as an input parameter at all, please remove this field. This mask is implicitly created by the user by calling the rte_mtr_color_in_protocol_priority_set() API function. If this function is called for a given method, then that method is enabled with the given priority; when this function is not called for a given method, then that method is disabled.

Quoted 10 lines
lib/ethdev/rte_mtr.h +6 -0
+
+	/** Input color to be set for the input packet when none of the
+	 * enabled input color methods is applicable to the input packet.
+	 * Ignored when this when *input_color_proto_mask* set to zero.
+	 */
+	enum rte_color default_input_color;
 };
 
 /**

lib/ethdev/rte_mtr.h struct rte_mtr_capabilities { · line 527

Quoted 8 lines
lib/ethdev/rte_mtr.h +5 -0
@@ -417,6 +520,16 @@ struct rte_mtr_capabilities {
 	 * @see enum rte_mtr_stats_type
 	 */
 	uint64_t stats_mask;
+
+	/** Set of supported input color protocol.
+	 * @see enum rte_mtr_color_in_protocol
+	 */
+	uint64_t input_color_proto_mask;

Agree.

lib/ethdev/rte_mtr.h struct rte_mtr_capabilities { · line 532

Quoted 5 lines
lib/ethdev/rte_mtr.h +5 -0
+
+	/** When non-zero, it indicates that driver supports separate
+	 * input color table for given ethdev port.
+	 */
+	int separate_input_color_table_per_port;

The input color tables are actually configured per meter object, do we also need a "separate_input_color_table_per_meter" capability flag?

Quoted 26 lines
lib/ethdev/rte_mtr.h +19 -0
 };
 
 /**
@@ -832,6 +945,59 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
+/**
+ * MTR object VLAN table update
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[in] vlan_table
+ *   When non-NULL: it points to a pre-allocated and pre-populated table with
+ *   exactly 16 elements providing the input color for each value of the
+ *   each value of the DEI(1bit), PCP(3 bits) input packet field.
+ *   When NULL: it is equivalent to setting this parameter to an "all-green"
+ *   populated table (i.e. table with all the 16 elements set to green color).
+ * @param[out] error
+ *   Error details. Filled in only on error, when not NULL.
+ * @return
+ *   0 on success, non-zero error code otherwise.
+ */
+__rte_experimental

lib/ethdev/rte_mtr.h rte_mtr_meter_dscp_table_update(uint16_t port_id, · line 976

Quoted 10 lines
lib/ethdev/rte_mtr.h +10 -0
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
+				enum rte_color *vlan_table,
+				struct rte_mtr_error *error);
+/**
+ * Set the priority for input color protocol
+ *
+ * When multiple bits set in struct rte_mtr_params::input_color_proto_mask
+ * then this API shall be used to set the priority, in the order, in
+ * which protocol to be used to find the input color.

As stated above, we should remove struct rte_mtr_params::input_color_proto_mask, as it is build implicitly by calling this function.

I suggest reiterating the explanation from above:
More than one method can be enabled for a given meter. Even if enabled, a method might not be applicable to each input packet, in case the associated protocol header is not present in the packet. The highest priority method that is both enabled for the meter and also applicable for the current input packet wins; if none is both enabled and applicable, the default input color is used. @see function rte_mtr_color_in_protocol_priority_set()

lib/ethdev/rte_mtr.h rte_mtr_meter_dscp_table_update(uint16_t port_id, · line 988

Quoted 12 lines
lib/ethdev/rte_mtr.h +12 -0
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[in] proto
+ *   Input color protocol to apply priority.
+ *   MTR object's *input_color_proto_mask* should be configured
+ *   with proto value.
+ * @param[in] priority
+ *   Input color protocol priority. Value zero indicates
+ *   the highest priority.

Agree.

Quoted 5 lines
lib/ethdev/rte_mtr.h +5 -0
+ * @param[out] error
+ *   Error details. Filled in only on error, when not NULL.
+ * @return
+ *   0 on success, non-zero error code otherwise.
+ *

lib/ethdev/rte_mtr.h rte_mtr_meter_dscp_table_update(uint16_t port_id, · line 1003

Quoted 10 lines
lib/ethdev/rte_mtr.h +7 -0
+ * @see rte_mtr_params::input_color_proto_mask
+ */
+__rte_experimental
+int
+rte_mtr_color_in_protocol_priority_set(uint16_t port_id, uint32_t mtr_id,
+	enum rte_mtr_color_in_protocol proto, uint32_t priority,
+	struct rte_mtr_error *error);
 /**
  * MTR object enabled statistics counters update
  *

<snip>

Regards,
Cristian

#23 lore raw

Re: [dpdk-dev] [PATCH v4] ethdev: mtr: support protocol based input color selection

Quoted 2 lines · Cristian

Hi Jerin,

Hi Cristian

Quoted 2 lines

Thank you for implementing according to our agreement, I am happy to see that we are converging.

:-)

Quoted 13 lines

Here are some comments below:

<snip>

Quoted 8 lines
lib/ethdev/rte_mtr.h +0 -0
index 40df0888c8..76ffbcf724 100644
@@ -213,6 +213,52 @@ struct rte_mtr_meter_policy_params {
      const struct rte_flow_action *actions[RTE_COLORS];
 };
 
Quoted 5 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 217

Quoted 2 lines
lib/ethdev/rte_mtr.h +2 -0
+/**
+ * Input color protocol method

I suggest adding some more explanations here:
More than one method can be enabled for a given meter. Even if enabled, a method might not be applicable to each input packet, in case the associated protocol header is not present in the packet. The highest priority method that is both enabled for the meter and also applicable for the current input packet wins; if none is both enabled and applicable, the default input color is used. @see function rte_mtr_color_in_protocol_priority_set()

OK.

Quoted 10 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 225

Quoted 9 lines
lib/ethdev/rte_mtr.h +8 -0
+ */
+enum rte_mtr_color_in_protocol {
+     /**
+      * If the input packet has at least one VLAN label, its input color is
+      * detected by the outermost VLAN DEI(1bit), PCP(3 bits)
+      * indexing into the struct rte_mtr_params::vlan_table.
+      * Otherwise, the *default_input_color* is applied.
+      *
Quoted 3 lines

The statement "Otherwise, the *default_input_color* is applied" is incorrect IMO and should be removed, as multiple methods might be enabled and also applicable to a specific input packet, in which case the highest priority method wins, as opposed to the default input color.

I suggest a simplification "Enable the detection of the packet input color based on the outermost VLAN header fields DEI (1 bit) and PCP (3 bits). These fields are used as index into the VLAN table"

OK

Quoted 15 lines
Quoted 4 lines
lib/ethdev/rte_mtr.h +3 -0
+      * @see struct rte_mtr_params::default_input_color
+      * @see struct rte_mtr_params::vlan_table
+      */

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 238

Quoted 10 lines
lib/ethdev/rte_mtr.h +10 -0
+     RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN = RTE_BIT64(0),
+     /**
+      * If the input packet has at least one VLAN label, its input color is
+      * detected by the innermost VLAN DEI(1bit), PCP(3 bits)
+      * indexing into the struct rte_mtr_params::vlan_table.
+      * Otherwise, the *default_input_color* is applied.
+      *
+      * @see struct rte_mtr_params::default_input_color
+      * @see struct rte_mtr_params::vlan_table
+      */
Quoted 1 line

Same simplification suggested here.

OK

Quoted 12 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 248

Quoted 11 lines
lib/ethdev/rte_mtr.h +10 -0
+     RTE_MTR_COLOR_IN_PROTO_INNER_VLAN = RTE_BIT64(1),
+     /**
+      * If the input packet is IPv4 or IPv6, its input color is detected by
+      * the outermost DSCP field indexing into the
+      * struct rte_mtr_params::dscp_table.
+      * Otherwise, the *default_input_color* is applied.
+      *
+      * @see struct rte_mtr_params::default_input_color
+      * @see struct rte_mtr_params::dscp_table
+      */
Quoted 1 line

Same simplification suggested here.

OK

Quoted 4 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 249

Quoted 2 lines
lib/ethdev/rte_mtr.h +1 -0
+     RTE_MTR_COLOR_IN_PROTO_OUTER_DSCP = RTE_BIT64(2),

I am OK to keep DSCP for the name of the table instead of renaming the table, as you suggested, but this method name should reflect the protocol, not the field: RTE_MTR_COLOR_IN_PROTO_OUTER_IP.

OK

Quoted 11 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 258

Quoted 10 lines
lib/ethdev/rte_mtr.h +9 -0
+     /**
+      * If the input packet is IPv4 or IPv6, its input color is detected by
+      * the innermost DSCP field indexing into the
+      * struct rte_mtr_params::dscp_table.
+      * Otherwise, the *default_input_color* is applied.
+      *
+      * @see struct rte_mtr_params::default_input_color
+      * @see struct rte_mtr_params::dscp_table
+      */
Quoted 1 line

Same simplification suggested here.

OK

Quoted 4 lines

lib/ethdev/rte_mtr.h struct rte_mtr_meter_policy_params { · line 259

Quoted 2 lines
lib/ethdev/rte_mtr.h +1 -0
+     RTE_MTR_COLOR_IN_PROTO_INNER_DSCP = RTE_BIT64(3),

I am OK to keep DSCP for the name of the table instead of renaming the table, as you suggested, but this method name should reflect the protocol, not the field: RTE_MTR_COLOR_IN_PROTO_INNER_IP.

OK

Quoted 92 lines
Quoted 92 lines
lib/ethdev/rte_mtr.h +8 -7
+
 /**
  * Parameters for each traffic metering & policing object
  *
@@ -233,20 +279,58 @@ struct rte_mtr_params {
       */
      int use_prev_mtr_color;
 
-     /** Meter input color. When non-NULL: it points to a pre-allocated and
+     /** Meter input color based on IP DSCP protocol field.
+      *
+      * Valid when *input_color_proto_mask* set to any of the following
+      * RTE_MTR_COLOR_IN_PROTO_OUTER_DSCP,
+      * RTE_MTR_COLOR_IN_PROTO_INNER_DSCP
+      *
+      * When non-NULL: it points to a pre-allocated and
       * pre-populated table with exactly 64 elements providing the input
       * color for each value of the IPv4/IPv6 Differentiated Services Code
-      * Point (DSCP) input packet field. When NULL: it is equivalent to
-      * setting this parameter to an all-green populated table (i.e. table
-      * with all the 64 elements set to green color). The color blind mode
-      * is configured by setting *use_prev_mtr_color* to 0 and *dscp_table*
-      * to either NULL or to an all-green populated table. When
-      * *use_prev_mtr_color* is non-zero value or when *dscp_table*

contains

lib/ethdev/rte_mtr.h +9 -2
-      * at least one yellow or red color element, then the color aware mode
-      * is configured.
+      * Point (DSCP) input packet field.
+      *
+      * When NULL: it is equivalent to setting this parameter to an all-green
+      * populated table (i.e. table with all the 64 elements set to green
+      * color). The color blind mode is configured by setting
+      * *use_prev_mtr_color* to 0 and *dscp_table* to either NULL or to an
+      * all-green populated table.
+      *
+      * When *use_prev_mtr_color* is non-zero value or when

*dscp_table*

lib/ethdev/rte_mtr.h +4 -0
+      * contains at least one yellow or red color element, then the color
+      * aware mode is configured.
+      *
+      * @see enum

rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_OUTER_DSCP
+ * @see enum
rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_DSCP

lib/ethdev/rte_mtr.h +23 -1
+      * @see struct rte_mtr_params::input_color_proto_mask
       */
      enum rte_color *dscp_table;
-
+     /** Meter input color based on VLAN DEI(1bit), PCP(3 bits) protocol
+      * fields.
+      *
+      * Valid when *input_color_proto_mask* set to any of the following
+      * RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN,
+      * RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
+      *
+      * When non-NULL: it points to a pre-allocated and pre-populated
+      * table with exactly 16 elements providing the input color for
+      * each value of the DEI(1bit), PCP(3 bits) input packet field.
+      *
+      * When NULL: it is equivalent to setting this parameter to an
+      * all-green populated table (i.e. table with
+      * all the 16 elements set to green color). The color blind mode
+      * is configured by setting *use_prev_mtr_color* to 0 and
+      * *vlan_table* to either NULL or to an all-green populated table.
+      *
+      * When *use_prev_mtr_color* is non-zero value
+      * or when *vlan_table* contains at least one yellow or
+      * red color element, then the color aware mode is configured.
+      *
+      * @see enum

rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN
+ * @see enum
rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_VLAN

lib/ethdev/rte_mtr.h +3 -0
+      * @see struct rte_mtr_params::input_color_proto_mask
+      */
+     enum rte_color *vlan_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
* *meter_profile_id* is set to NONE.

lib/ethdev/rte_mtr.h +7 -0
@@ -261,6 +345,25 @@ struct rte_mtr_params {
 
      /** Meter policy ID. @see rte_mtr_meter_policy_add() */
      uint32_t meter_policy_id;
+
+     /** Set of input color protocols to be enabled.
+      *
+      * Set value to zero to configure as color blind mode.
+      *
+      * When multiple bits set then rte_mtr_color_in_protocol_priority_set()
+      * shall be used to set the priority, in the order, in which protocol
Quoted 8 lines

lib/ethdev/rte_mtr.h struct rte_mtr_params { · line 360

Quoted 6 lines
lib/ethdev/rte_mtr.h +6 -0
+      * to be used to find the inpput color.
+      *
+      * @see enum rte_mtr_color_in_protocol
+      * @see rte_mtr_color_in_protocol_priority_set()
+      */
+     uint64_t input_color_proto_mask;

We should not have this as an input parameter at all, please remove this field. This mask is implicitly created by the user by calling the rte_mtr_color_in_protocol_priority_set() API function. If this function is called for a given method, then that method is enabled with the given priority; when this function is not called for a given method, then that method is disabled.

OK. Since we had rte_mtr_color_in_protocol_priority_set(), I was thinking it is only setting "priority".

I will change to rte_mtr_color_in_protocol_set() and add API to _get() as well.

Quoted 22 lines
Quoted 11 lines
lib/ethdev/rte_mtr.h +6 -0
+
+     /** Input color to be set for the input packet when none of the
+      * enabled input color methods is applicable to the input packet.
+      * Ignored when this when *input_color_proto_mask* set to zero.
+      */
+     enum rte_color default_input_color;
 };
 
 /**

lib/ethdev/rte_mtr.h struct rte_mtr_capabilities { · line 527

Quoted 8 lines
lib/ethdev/rte_mtr.h +5 -0
@@ -417,6 +520,16 @@ struct rte_mtr_capabilities {
       * @see enum rte_mtr_stats_type
       */
      uint64_t stats_mask;
+
+     /** Set of supported input color protocol.
+      * @see enum rte_mtr_color_in_protocol
+      */
+     uint64_t input_color_proto_mask;

Agree.

Quoted 7 lines

lib/ethdev/rte_mtr.h struct rte_mtr_capabilities { · line 532

Quoted 5 lines
lib/ethdev/rte_mtr.h +5 -0
+
+     /** When non-zero, it indicates that driver supports separate
+      * input color table for given ethdev port.
+      */
+     int separate_input_color_table_per_port;

The input color tables are actually configured per meter object, do we also need a "separate_input_color_table_per_meter" capability flag?

Yes. We have a similar limitation.

Quoted 40 lines
Quoted 27 lines
lib/ethdev/rte_mtr.h +19 -0
 };
 
 /**
@@ -832,6 +945,59 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id,
      enum rte_color *dscp_table,
      struct rte_mtr_error *error);
 
+/**
+ * MTR object VLAN table update
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[in] vlan_table
+ *   When non-NULL: it points to a pre-allocated and pre-populated table with
+ *   exactly 16 elements providing the input color for each value of the
+ *   each value of the DEI(1bit), PCP(3 bits) input packet field.
+ *   When NULL: it is equivalent to setting this parameter to an "all-green"
+ *   populated table (i.e. table with all the 16 elements set to green color).
+ * @param[out] error
+ *   Error details. Filled in only on error, when not NULL.
+ * @return
+ *   0 on success, non-zero error code otherwise.
+ */
+__rte_experimental

lib/ethdev/rte_mtr.h rte_mtr_meter_dscp_table_update(uint16_t port_id, · line 976

Quoted 10 lines
lib/ethdev/rte_mtr.h +10 -0
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
+                             enum rte_color *vlan_table,
+                             struct rte_mtr_error *error);
+/**
+ * Set the priority for input color protocol
+ *
+ * When multiple bits set in struct rte_mtr_params::input_color_proto_mask
+ * then this API shall be used to set the priority, in the order, in
+ * which protocol to be used to find the input color.

As stated above, we should remove struct rte_mtr_params::input_color_proto_mask, as it is build implicitly by calling this function.

Quoted 2 lines

I suggest reiterating the explanation from above:
More than one method can be enabled for a given meter. Even if enabled, a method might not be applicable to each input packet, in case the associated protocol header is not present in the packet. The highest priority method that is both enabled for the meter and also applicable for the current input packet wins; if none is both enabled and applicable, the default input color is used. @see function rte_mtr_color_in_protocol_priority_set()

OK

Quoted 36 lines

lib/ethdev/rte_mtr.h rte_mtr_meter_dscp_table_update(uint16_t port_id, · line 988

Quoted 13 lines
lib/ethdev/rte_mtr.h +12 -0
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[in] proto
+ *   Input color protocol to apply priority.
+ *   MTR object's *input_color_proto_mask* should be configured
+ *   with proto value.
+ * @param[in] priority
+ *   Input color protocol priority. Value zero indicates
+ *   the highest priority.

Agree.

Quoted 5 lines
lib/ethdev/rte_mtr.h +5 -0
+ * @param[out] error
+ *   Error details. Filled in only on error, when not NULL.
+ * @return
+ *   0 on success, non-zero error code otherwise.
+ *

lib/ethdev/rte_mtr.h rte_mtr_meter_dscp_table_update(uint16_t port_id, · line 1003

Quoted 10 lines
lib/ethdev/rte_mtr.h +7 -0
+ * @see rte_mtr_params::input_color_proto_mask
+ */
+__rte_experimental
+int
+rte_mtr_color_in_protocol_priority_set(uint16_t port_id, uint32_t mtr_id,
+     enum rte_mtr_color_in_protocol proto, uint32_t priority,
+     struct rte_mtr_error *error);
 /**
  * MTR object enabled statistics counters update
  *

<snip>

Regards,
Cristian

#24 lore raw

PATCH v5 1/1 ethdev: mtr: support protocol based input color selection

In reply to [email protected]

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

---

v5..v4:

- Improved the Doxgen comments as per
http://patches.dpdk.org/project/dpdk/patch/[email protected]/
- Removed input_color_proto_mask
- Renamed rte_mtr_color_in_protocol_priority_set() to rte_mtr_color_in_protocol_set()
- Introduced rte_mtr_color_in_protocol_get(), rte_mtr_color_in_protocol_priority_get() for getting the configured input color protocol.

v4..v3:

- Aligned with community meeting call which is documented in
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
as last message. With following exception,
- Used RTE_MTR_COLOR_IN_*_DSCP instead of RTE_MTR_COLOR_IN_*_IP as there is already dscp_table and rte_mtr_meter_dscp_table_update() API. Changing above symbols break existing application for no good.
- Updated 22.07 release notes
- Remove testpmd changes from series to finalize the API spec first and then we can send testpmd changes.

v3..v2:

- Fix input color flags as a bitmask
- Add definitions for newly added API

v2..v1:
- Fix seperate typo

v1..RFC:

Address the review comments by Cristian at
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

.../traffic_metering_and_policing.rst | 35 +++

 doc/guides/rel_notes/release_22_07.rst        |  10 +
 lib/ethdev/rte_mtr.c                          |  50 ++++
 lib/ethdev/rte_mtr.h                          | 216 +++++++++++++++++-
 lib/ethdev/rte_mtr_driver.h                   |  38 +++
 lib/ethdev/version.map                        |   6 +
 6 files changed, 345 insertions(+), 10 deletions(-)
doc/guides/prog_guide/traffic_metering_and_policing.rst +35 -0
index ceb5a96488..d1958a023d 100644
@@ -21,6 +21,7 @@ The main features are:
 * Policer actions (per meter output color): recolor, drop
 * Statistics (per policer output color)
 * Chaining multiple meter objects
+* Protocol based input color selection
 
 Configuration steps
 -------------------
@@ -105,3 +106,37 @@ traffic meter and policing library.
    * Adding one (or multiple) actions of the type ``RTE_FLOW_ACTION_TYPE_METER``
      to the list of meter actions (``struct rte_mtr_meter_policy_params::actions``)
      specified per color as show in :numref:`figure_rte_mtr_chaining`.
+
+Protocol based input color selection
+------------------------------------
+
+The API supports selecting the input color based on the packet content.
+Following is the API usage model for the same.
+
+#. Probe the protocol based input color selection device capabilities using
+   the following parameters with ``rte_mtr_capabilities_get()`` API.
+
+   * ``struct rte_mtr_capabilities::input_color_proto_mask;``
+   * ``struct rte_mtr_capabilities::separate_input_color_table_per_port``
+
+#. When creating the meter object using ``rte_mtr_create()``, configure
+   relevant input color selection parameters such as
+
+   * Fill the tables ``struct rte_mtr_params::dscp_table``,
+     ``struct rte_mtr_params::vlan_table`` based on input color selected.
+
+   * Update the ``struct rte_mtr_params::default_input_color`` to determine
+     the default input color in case the input packet does not match
+     the input color method.
+
+#. Use the following APIs to configure the meter object
+
+   * Select the input protocol color with ``rte_mtr_color_in_protocol_set()`` API.
+
+   * If needed, update the input color table at runtime using
+     ``rte_mtr_meter_vlan_table_update()`` and ``rte_mtr_meter_dscp_table_update()``
+     APIs.
+
+   * Application can query the configured input color protocol and its associated
+     priority using ``rte_mtr_color_in_protocol_get()`` and
+     ``rte_mtr_color_in_protocol_priority_get()`` APIs.
doc/guides/rel_notes/release_22_07.rst +10 -0
index 88d6e96cc1..74ecc3f53d 100644
@@ -55,6 +55,13 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added protocol based input color selection for meter.**
+
+  Added new APIs ``rte_mtr_color_in_protocol_set()``, ``rte_mtr_color_in_protocol_get()``,
+  ``rte_mtr_color_in_protocol_priority_get()``,  ``rte_mtr_meter_vlan_table_update()``
+  and updated ``struct rte_mtr_params`` and ``struct rte_mtr_capabilities`` to
+  support protocol based input color selection for meter.
+
 * **Updated Intel iavf driver.**
 
   * Added Tx QoS queue rate limitation support.
@@ -112,6 +119,9 @@ ABI Changes
 
 * No ABI change that would break compatibility with 21.11.
 
+* Experimental structures ``struct rte_mtr_params``
+  and ``struct rte_mtr_capabilities`` updated to support
+  protocol based input color for meter.
 
 Known Issues
 ------------
lib/ethdev/rte_mtr.c +50 -0

56 lines not on this page · raw message

lib/ethdev/rte_mtr.h +206 -10

250 lines not on this page · raw message

lib/ethdev/rte_mtr_driver.h +38 -0
index ee8c6ef7ad..f7dca9a54c 100644
@@ -97,6 +97,32 @@ typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev,
 	enum rte_color *dscp_table,
 	struct rte_mtr_error *error);
 
+/** @internal mtr object meter vlan table update. */
+typedef int (*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev,
+	uint32_t mtr_id,
+	enum rte_color *vlan_table,
+	struct rte_mtr_error *error);
+
+/** @internal Set the input color protocol on MTR object. */
+typedef int (*rte_mtr_meter_color_in_proto_set_t)(struct rte_eth_dev *dev,
+	uint32_t mtr_id,
+	enum rte_mtr_color_in_protocol proto,
+	uint32_t priority,
+	struct rte_mtr_error *error);
+
+/** @internal Get the input color protocols of MTR object. */
+typedef int (*rte_mtr_meter_color_in_proto_get_t)(struct rte_eth_dev *dev,
+	uint32_t mtr_id,
+	uint64_t *proto_mask,
+	struct rte_mtr_error *error);
+
+/** @internal Get the input color protocol priority of MTR object. */
+typedef int (*rte_mtr_meter_color_in_proto_prio_get_t)(struct rte_eth_dev *dev,
+	uint32_t mtr_id,
+	enum rte_mtr_color_in_protocol proto,
+	uint32_t *priority,
+	struct rte_mtr_error *error);
+
 /** @internal MTR object enabled stats update. */
 typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
 	uint32_t mtr_id,
@@ -139,6 +165,18 @@ struct rte_mtr_ops {
 	/** MTR object meter DSCP table update */
 	rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
 
+	/** MTR object meter VLAN table update */
+	rte_mtr_meter_vlan_table_update_t meter_vlan_table_update;
+
+	/** Set the input color protocol on MTR object. */
+	rte_mtr_meter_color_in_proto_set_t in_proto_set;
+
+	/** Get the input color protocol of MTR object. */
+	rte_mtr_meter_color_in_proto_get_t in_proto_get;
+
+	/** Get the input color protocol priority of MTR object. */
+	rte_mtr_meter_color_in_proto_prio_get_t in_proto_prio_get;
+
 	/** MTR object enabled stats update */
 	rte_mtr_stats_update_t stats_update;
 
lib/ethdev/version.map +6 -0
index 20391ab29e..daca7851f2 100644
@@ -279,6 +279,12 @@ EXPERIMENTAL {
 	rte_flow_async_action_handle_create;
 	rte_flow_async_action_handle_destroy;
 	rte_flow_async_action_handle_update;
+
+	# added in 22.07
+	rte_mtr_color_in_protocol_get;
+	rte_mtr_color_in_protocol_priority_get;
+	rte_mtr_color_in_protocol_set;
+	rte_mtr_meter_vlan_table_update;
 };
 
 INTERNAL {
Signature · 1 line
2.36.0
Acked-by on v5 1/1
#25 lore raw

Re: [dpdk-dev] [PATCH v5] ethdev: mtr: support protocol based input color selection

Quoted 49 lines · [email protected] writes:

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

---

v5..v4:

- Improved the Doxgen comments as per
http://patches.dpdk.org/project/dpdk/patch/[email protected]/
- Removed input_color_proto_mask
- Renamed rte_mtr_color_in_protocol_priority_set() to rte_mtr_color_in_protocol_set()
- Introduced rte_mtr_color_in_protocol_get(), rte_mtr_color_in_protocol_priority_get() for getting the configured input color protocol.

v4..v3:

- Aligned with community meeting call which is documented in
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
as last message. With following exception,
- Used RTE_MTR_COLOR_IN_*_DSCP instead of RTE_MTR_COLOR_IN_*_IP as there is already dscp_table and rte_mtr_meter_dscp_table_update() API. Changing above symbols break existing application for no good.
- Updated 22.07 release notes
- Remove testpmd changes from series to finalize the API spec first and then we can send testpmd changes.

v3..v2:

- Fix input color flags as a bitmask
- Add definitions for newly added API

v2..v1:
- Fix seperate typo

v1..RFC:

Address the review comments by Cristian at
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

Quoted 8 lines

.../traffic_metering_and_policing.rst | 35 +++

 doc/guides/rel_notes/release_22_07.rst        |  10 +
 lib/ethdev/rte_mtr.c                          |  50 ++++
 lib/ethdev/rte_mtr.h                          | 216 +++++++++++++++++-
 lib/ethdev/rte_mtr_driver.h                   |  38 +++
 lib/ethdev/version.map                        |   6 +
 6 files changed, 345 insertions(+), 10 deletions(-)
Acked-by on v5 1/1
#26 lore raw

RE: [dpdk-dev] [PATCH v5] ethdev: mtr: support protocol based input color selection

In reply to [email protected]
Quoted 48 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Sunday, May 1, 2022 3:47 PM
To: [email protected]; Dumitrescu, Cristian <[email protected]>; Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; Ray Kinsella <[email protected]>
Cc: [email protected]; [email protected]; Xing, Beilei <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Xia, Chenbo <[email protected]>; Loftus, Ciara <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Wang, Haiyue <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Singh, Jasvinder <[email protected]>; [email protected]; [email protected]; Wu, Jingjing <[email protected]>; Daley, John <[email protected]>; [email protected]; [email protected]; Wiles, Keith <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Peters, Matt <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; [email protected]; [email protected]; [email protected]; Xu, Rosen <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Shepard Siegel <[email protected]>; [email protected]; [email protected]; [email protected]; Webster, Steven <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Wang, Xiao W <[email protected]>; [email protected]; [email protected]; Wang, Yong <[email protected]>; [email protected]; Jerin Jacob <[email protected]>
Subject: [dpdk-dev] [PATCH v5] ethdev: mtr: support protocol based input color selection

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

Quoted 8 lines

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

---

Thanks very much, Jerin!

#27 lore raw

Re: [dpdk-dev] [PATCH v5] ethdev: mtr: support protocol based input color selection

In reply to [email protected]

Hi Jerin,

Quoted 7 lines · On 5/1/22 17:46, [email protected] wrote:

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

Quoted 6 lines

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

the patch LGTM, but I have a couple of questions to clarify:

1. Will we have API usage patches in the release cycle (I guess testpmd)?

2. Will we have net driver patches which add support for new driver callbacks and advertise added capabilities?

Thanks,
Andrew.

#28 lore raw

Re: [dpdk-dev] [PATCH v5] ethdev: mtr: support protocol based input color selection

Quoted 2 lines · Andrew Rybchenko

Hi Jerin,

Hi Andrew,

Quoted 16 lines · On 5/1/22 17:46, [email protected] wrote:
Quoted 7 lines

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

Quoted 6 lines

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

Quoted 7 lines

the patch LGTM, but I have a couple of questions to clarify:

1. Will we have API usage patches in the release cycle (I guess testpmd)?

2. Will we have net driver patches which add support for new driver callbacks and advertise added capabilities?

Yes. Both will be there for this release. Most likely post rc1.

We have testpmd, cnxk driver changes for the v1 version of the spec[1]. We will update both for the latest spec version.(We just awaiting for spec to merge)

[1]
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

Quoted 3 lines

Thanks,
Andrew.

#29 lore raw

Re: [dpdk-dev] [PATCH v5] ethdev: mtr: support protocol based input color selection

Quoted 33 lines · Jerin Jacob
Quoted 2 lines · Andrew Rybchenko

Hi Jerin,

Hi Andrew,

Quoted 16 lines · On 5/1/22 17:46, [email protected] wrote:
Quoted 7 lines

From: Jerin Jacob <[email protected]>

Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field.

Quoted 6 lines

All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port.

Quoted 7 lines

the patch LGTM, but I have a couple of questions to clarify:

1. Will we have API usage patches in the release cycle (I guess testpmd)?

2. Will we have net driver patches which add support for new driver callbacks and advertise added capabilities?

Yes. Both will be there for this release. Most likely post rc1.

Quoted 11 lines

We have testpmd, cnxk driver changes for the v1 version of the spec[1]. We will update both for the latest spec version.(We just awaiting for spec to merge)

[1]
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
https://patches.dpdk.org/project/dpdk/patch/[email protected]/

Quoted 3 lines

Thanks,
Andrew.

Applied, thanks.