From fd44e8288fbbfd58e4b8a1ba454526fffd85a436 Mon Sep 17 00:00:00 2001
From: Salem Sol <salems@nvidia.com>
Date: Wed, 7 Apr 2021 14:49:38 +0300
Subject: [PATCH] net/mlx5: support NVGRE encap action in sampling

Add support for NVGRE encap as a sample action
and validate it.

Signed-off-by: Salem Sol <salems@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 doc/guides/nics/mlx5.rst               | 2 +-
 doc/guides/rel_notes/release_21_05.rst | 2 +-
 drivers/net/mlx5/mlx5_flow_dv.c        | 2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index f3bb464bd0..aa1ddbc95d 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -377,7 +377,7 @@ Limitations
   - For NIC Rx flow, supports ``MARK``, ``COUNT``, ``QUEUE``, ``RSS`` in the
     sample actions list.
   - For E-Switch mirroring flow, supports ``RAW ENCAP``, ``Port ID``,
-    ``VXLAN ENCAP`` in the sample actions list.
+    ``VXLAN ENCAP``, ``NVGRE ENCAP`` in the sample actions list.
 
 - Modify Field flow:
 
diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst
index 24ea62e874..ba773defb4 100644
--- a/doc/guides/rel_notes/release_21_05.rst
+++ b/doc/guides/rel_notes/release_21_05.rst
@@ -117,7 +117,7 @@ New Features
 
   Updated the Mellanox mlx5 driver with new features and improvements, including:
 
-  * Added support for VXLAN encap as a sample action.
+  * Added support for VXLAN and NVGRE encap as sample actions.
 
 * **Updated NXP DPAA driver.**
 
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index f6030910b0..51c95f19e8 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -5259,6 +5259,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags,
 			++actions_n;
 			break;
 		case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
+		case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
 			ret = flow_dv_validate_action_l2_encap(dev,
 							       sub_action_flags,
 							       act, attr,
@@ -10431,6 +10432,7 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev,
 			break;
 		}
 		case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
+		case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
 		case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
 			/* Save the encap resource before sample */
 			pre_rix = dev_flow->handle->dvh.rix_encap_decap;
-- 
2.39.5