diff mbox series

[v5] ethdev: mtr: support protocol based input color selection

Message ID 20220501144637.3757757-1-jerinj@marvell.com (mailing list archive)
State Accepted
Delegated to: Andrew Rybchenko
Headers show
Series [v5] ethdev: mtr: support protocol based input color selection | expand

Checks

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

Commit Message

Jerin Jacob Kollanukkaran May 1, 2022, 2:46 p.m. UTC
From: Jerin Jacob <jerinj@marvell.com>

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.

Suggested-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---

v5..v4:

- Improved the Doxgen comments as per
http://patches.dpdk.org/project/dpdk/patch/20220421180241.514767-1-jerinj@marvell.com/
- 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/20220301085824.1041009-1-skori@marvell.com/
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/20210820082401.3778736-1-jerinj@marvell.com/
 
.../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(-)

Comments

Ray Kinsella May 4, 2022, 8:52 a.m. UTC | #1
jerinj@marvell.com writes:

> From: Jerin Jacob <jerinj@marvell.com>
>
> 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.
>
> Suggested-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> ---
>
> v5..v4:
>
> - Improved the Doxgen comments as per
> http://patches.dpdk.org/project/dpdk/patch/20220421180241.514767-1-jerinj@marvell.com/
> - 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/20220301085824.1041009-1-skori@marvell.com/
> 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/20210820082401.3778736-1-jerinj@marvell.com/
>  
> .../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: Ray Kinsella <mdr@ashroe.eu>
Dumitrescu, Cristian May 5, 2022, 10:56 a.m. UTC | #2
> -----Original Message-----
> From: jerinj@marvell.com <jerinj@marvell.com>
> Sent: Sunday, May 1, 2022 3:47 PM
> To: dev@dpdk.org; Dumitrescu, Cristian <cristian.dumitrescu@intel.com>;
> Thomas Monjalon <thomas@monjalon.net>; Ferruh Yigit
> <ferruh.yigit@xilinx.com>; Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru>; Ray Kinsella <mdr@ashroe.eu>
> Cc: ajit.khaparde@broadcom.com; aboyer@pensando.io; Xing, Beilei
> <beilei.xing@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>;
> chas3@att.com; Xia, Chenbo <chenbo.xia@intel.com>; Loftus, Ciara
> <ciara.loftus@intel.com>; dsinghrawat@marvell.com;
> ed.czeck@atomicrules.com; evgenys@amazon.com; grive@u256.net;
> g.singh@nxp.com; zhouguoyang@huawei.com; Wang, Haiyue
> <haiyue.wang@intel.com>; hkalra@marvell.com; heinrich.kuhn@corigine.com;
> hemant.agrawal@nxp.com; hyonkim@cisco.com; igorch@amazon.com;
> irusskikh@marvell.com; jgrajcia@cisco.com; Singh, Jasvinder
> <jasvinder.singh@intel.com>; jianwang@trustnetic.com;
> jiawenwu@trustnetic.com; Wu, Jingjing <jingjing.wu@intel.com>; Daley, John
> <johndale@cisco.com>; john.miller@atomicrules.com; linville@tuxdriver.com;
> Wiles, Keith <keith.wiles@intel.com>; kirankumark@marvell.com;
> oulijun@huawei.com; lironh@marvell.com; longli@microsoft.com;
> mw@semihalf.com; spinler@cesnet.cz; matan@nvidia.com; Peters, Matt
> <matt.peters@windriver.com>; maxime.coquelin@redhat.com;
> mk@semihalf.com; humin29@huawei.com; pnalla@marvell.com;
> ndabilpuram@marvell.com; Yang, Qiming <qiming.yang@intel.com>; Zhang,
> Qi Z <qi.z.zhang@intel.com>; radhac@marvell.com;
> rahul.lakkireddy@chelsio.com; rmody@marvell.com; Xu, Rosen
> <rosen.xu@intel.com>; sachin.saxena@oss.nxp.com; skoteshwar@marvell.com;
> shshaikh@marvell.com; shaibran@amazon.com; Shepard Siegel
> <shepard.siegel@atomicrules.com>; asomalap@amd.com;
> somnath.kotur@broadcom.com; sthemmin@microsoft.com; Webster, Steven
> <steven.webster@windriver.com>; skori@marvell.com;
> mtetsuyah@gmail.com; vburru@marvell.com; viacheslavo@nvidia.com; Wang,
> Xiao W <xiao.w.wang@intel.com>; cloud.wangxiaoyun@huawei.com;
> yisen.zhuang@huawei.com; Wang, Yong <yongwang@vmware.com>;
> xuanziyang2@huawei.com; Jerin Jacob <jerinj@marvell.com>
> Subject: [dpdk-dev] [PATCH v5] ethdev: mtr: support protocol based input color
> selection
> 
> From: Jerin Jacob <jerinj@marvell.com>
> 
> 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.
> 
> Suggested-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> ---
> 

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Thanks very much, Jerin!
Andrew Rybchenko May 12, 2022, 7:36 a.m. UTC | #3
Hi Jerin,

On 5/1/22 17:46, jerinj@marvell.com wrote:
> From: Jerin Jacob <jerinj@marvell.com>
> 
> 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.
> 
> Suggested-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>

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.
Jerin Jacob May 12, 2022, 11:03 a.m. UTC | #4
On Thu, May 12, 2022 at 1:06 PM Andrew Rybchenko
<andrew.rybchenko@oktetlabs.ru> wrote:
>
> Hi Jerin,

Hi Andrew,

>
> On 5/1/22 17:46, jerinj@marvell.com wrote:
> > From: Jerin Jacob <jerinj@marvell.com>
> >
> > 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.
> >
> > Suggested-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> > Signed-off-by: Jerin Jacob <jerinj@marvell.com>
>
> 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/20220301090056.1042866-3-skori@marvell.com/
https://patches.dpdk.org/project/dpdk/patch/20220301090056.1042866-2-skori@marvell.com/

>
> Thanks,
> Andrew.
Andrew Rybchenko May 19, 2022, 7:05 a.m. UTC | #5
On 5/12/22 14:03, Jerin Jacob wrote:
> On Thu, May 12, 2022 at 1:06 PM Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru> wrote:
>>
>> Hi Jerin,
> 
> Hi Andrew,
> 
>>
>> On 5/1/22 17:46, jerinj@marvell.com wrote:
>>> From: Jerin Jacob <jerinj@marvell.com>
>>>
>>> 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.
>>>
>>> Suggested-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
>>> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
>>
>> 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/20220301090056.1042866-3-skori@marvell.com/
> https://patches.dpdk.org/project/dpdk/patch/20220301090056.1042866-2-skori@marvell.com/
> 
>>
>> Thanks,
>> Andrew.

Applied, thanks.
diff mbox series

Patch

diff --git a/doc/guides/prog_guide/traffic_metering_and_policing.rst b/doc/guides/prog_guide/traffic_metering_and_policing.rst
index ceb5a96488..d1958a023d 100644
--- a/doc/guides/prog_guide/traffic_metering_and_policing.rst
+++ b/doc/guides/prog_guide/traffic_metering_and_policing.rst
@@ -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.
diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst
index 88d6e96cc1..74ecc3f53d 100644
--- a/doc/guides/rel_notes/release_22_07.rst
+++ b/doc/guides/rel_notes/release_22_07.rst
@@ -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
 ------------
diff --git a/lib/ethdev/rte_mtr.c b/lib/ethdev/rte_mtr.c
index e49fcf271c..441ea1dca9 100644
--- a/lib/ethdev/rte_mtr.c
+++ b/lib/ethdev/rte_mtr.c
@@ -207,6 +207,56 @@  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 input color protocol on MTR object */
+int
+rte_mtr_color_in_protocol_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_set)(dev,
+		mtr_id, proto, priority, error);
+}
+
+/** Get input color protocols of MTR object */
+int
+rte_mtr_color_in_protocol_get(uint16_t port_id,
+	uint32_t mtr_id,
+	uint64_t *proto_mask,
+	struct rte_mtr_error *error)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	return RTE_MTR_FUNC(port_id, in_proto_get)(dev,
+		mtr_id, proto_mask, error);
+}
+
+/** Get input color protocol priority of MTR object */
+int
+rte_mtr_color_in_protocol_priority_get(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_get)(dev,
+		mtr_id, proto, priority, error);
+}
+
 /** MTR object enabled stats update */
 int
 rte_mtr_stats_update(uint16_t port_id,
diff --git a/lib/ethdev/rte_mtr.h b/lib/ethdev/rte_mtr.h
index 40df0888c8..008bc84f0d 100644
--- a/lib/ethdev/rte_mtr.h
+++ b/lib/ethdev/rte_mtr.h
@@ -213,6 +213,51 @@  struct rte_mtr_meter_policy_params {
 	const struct rte_flow_action *actions[RTE_COLORS];
 };
 
+/**
+ * Input color protocol method
+ *
+ * More than one of the 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_set()
+ *
+ */
+enum rte_mtr_color_in_protocol {
+	/**
+	 * 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.
+	 *
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN = RTE_BIT64(0),
+	/**
+	 * Enable the detection of the packet input color based on the innermost
+	 * VLAN header fields DEI (1 bit) and PCP (3 bits).
+	 * These fields are used as index into the VLAN table.
+	 *
+	 * @see struct rte_mtr_params::vlan_table
+	 */
+	RTE_MTR_COLOR_IN_PROTO_INNER_VLAN = RTE_BIT64(1),
+	/**
+	 * Enable the detection of the packet input color based on the outermost
+	 * IP DSCP field. These fields are used as index into the DSCP table.
+	 *
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_COLOR_IN_PROTO_OUTER_IP = RTE_BIT64(2),
+	/**
+	 * Enable the detection of the packet input color based on the innermost
+	 * IP DSCP field. These fields are used as index into the DSCP table.
+	 *
+	 * @see struct rte_mtr_params::dscp_table
+	 */
+	RTE_MTR_COLOR_IN_PROTO_INNER_IP = RTE_BIT64(3),
+};
+
 /**
  * Parameters for each traffic metering & policing object
  *
@@ -233,20 +278,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_IP,
+	 * RTE_MTR_COLOR_IN_PROTO_INNER_IP
+	 *
+	 * 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_IP
+	 * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_IP
+	 * @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 +344,12 @@  struct rte_mtr_params {
 
 	/** Meter policy ID. @see rte_mtr_meter_policy_add() */
 	uint32_t meter_policy_id;
+
+	/** 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 +506,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 +931,103 @@  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 input color protocol for a given MTR object
+ *
+ * More than one of the 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.
+ *
+ * @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.
+ * @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.
+ */
+__rte_experimental
+int
+rte_mtr_color_in_protocol_set(uint16_t port_id, uint32_t mtr_id,
+	enum rte_mtr_color_in_protocol proto, uint32_t priority,
+	struct rte_mtr_error *error);
+
+/**
+ * Get the input color protocol for a given MTR object
+ *
+ * @param[in] port_id
+ *   The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ *   MTR object ID. Needs to be valid.
+ * @param[out] proto_mask
+ *   Selected input color protocols as bit mask.
+ * @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_color_in_protocol_get(uint16_t port_id, uint32_t mtr_id,
+	uint64_t *proto_mask,
+	struct rte_mtr_error *error);
+
+/**
+ * Get the priority associated with input color protocol for a given MTR object
+ *
+ * @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.
+ * @param[out] priority
+ *   Input color protocol priority associated with proto.
+ * @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_color_in_protocol_priority_get(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
  *
diff --git a/lib/ethdev/rte_mtr_driver.h b/lib/ethdev/rte_mtr_driver.h
index ee8c6ef7ad..f7dca9a54c 100644
--- a/lib/ethdev/rte_mtr_driver.h
+++ b/lib/ethdev/rte_mtr_driver.h
@@ -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;
 
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index 20391ab29e..daca7851f2 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -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 {