[dpdk-dev] [PATCH v6 5/6] net/mlx5: add NVGRE decap action to Direct Verbs

Dekel Peled dekelp at mellanox.com
Thu Oct 25 22:08:27 CEST 2018


This patch implements the NVGRE decap action in DV flow for MLX5 PMD.

Signed-off-by: Dekel Peled <dekelp at mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.h    |  4 ++++
 drivers/net/mlx5/mlx5_flow_dv.c | 23 +++++++++++++++--------
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 05527eb..2d73a05 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -95,6 +95,7 @@
 #define MLX5_FLOW_ACTION_VXLAN_ENCAP (1u << 22)
 #define MLX5_FLOW_ACTION_VXLAN_DECAP (1u << 23)
 #define MLX5_FLOW_ACTION_NVGRE_ENCAP (1u << 24)
+#define MLX5_FLOW_ACTION_NVGRE_DECAP (1u << 25)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)
@@ -102,6 +103,9 @@
 #define MLX5_FLOW_ENCAP_ACTIONS	\
 	(MLX5_FLOW_ACTION_VXLAN_ENCAP | MLX5_FLOW_ACTION_NVGRE_ENCAP)
 
+#define MLX5_FLOW_DECAP_ACTIONS	\
+	(MLX5_FLOW_ACTION_VXLAN_DECAP | MLX5_FLOW_ACTION_NVGRE_DECAP)
+
 #ifndef IPPROTO_MPLS
 #define IPPROTO_MPLS 137
 #endif
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index bdaec19..d7d0c6b 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -131,8 +131,7 @@
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 					  "can't drop and encap in same flow");
-	if (action_flags & (MLX5_FLOW_ENCAP_ACTIONS |
-			    MLX5_FLOW_ACTION_VXLAN_DECAP))
+	if (action_flags & (MLX5_FLOW_ENCAP_ACTIONS | MLX5_FLOW_DECAP_ACTIONS))
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 					  "can only have a single encap or"
@@ -148,7 +147,7 @@
 
 /**
  * Validate the L2 decap action.
- * Used for VXLAN decap action.
+ * Used for VXLAN and NVGRE decap actions.
  *
  * @param[in] action_flags
  *   Holds the actions detected until now.
@@ -172,8 +171,7 @@
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 					  "can't drop and decap in same flow");
-	if (action_flags & (MLX5_FLOW_ENCAP_ACTIONS |
-			    MLX5_FLOW_ACTION_VXLAN_DECAP))
+	if (action_flags & (MLX5_FLOW_ENCAP_ACTIONS | MLX5_FLOW_DECAP_ACTIONS))
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 					  "can only have a single encap or"
@@ -443,7 +441,7 @@
 
 /**
  * Convert L2 decap action to DV specification.
- * Used for VXLAN decap action.
+ * Used for VXLAN and NVGRE decap actions.
  *
  * @param[in] dev
  *   Pointer to rte_eth_dev structure.
@@ -732,12 +730,17 @@
 			++actions_n;
 			break;
 		case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP:
+		case RTE_FLOW_ACTION_TYPE_NVGRE_DECAP:
 			ret = flow_dv_validate_action_l2_decap(action_flags,
 							       actions, attr,
 							       error);
 			if (ret < 0)
 				return ret;
-			action_flags |= MLX5_FLOW_ACTION_VXLAN_DECAP;
+			action_flags |= actions->type ==
+					RTE_FLOW_ACTION_TYPE_VXLAN_DECAP ?
+					MLX5_FLOW_ACTION_VXLAN_DECAP :
+					MLX5_FLOW_ACTION_NVGRE_DECAP;
+
 			++actions_n;
 			break;
 		default:
@@ -1531,6 +1534,7 @@
 		actions_n++;
 		break;
 	case RTE_FLOW_ACTION_TYPE_VXLAN_DECAP:
+	case RTE_FLOW_ACTION_TYPE_NVGRE_DECAP:
 		dev_flow->dv.actions[actions_n].type =
 			MLX5DV_FLOW_ACTION_IBV_FLOW_ACTION;
 		dev_flow->dv.actions[actions_n].action =
@@ -1540,7 +1544,10 @@
 			return -rte_errno;
 		dev_flow->dv.verbs_action =
 			dev_flow->dv.actions[actions_n].action;
-		flow->actions |= MLX5_FLOW_ACTION_VXLAN_DECAP;
+		flow->actions |= action->type ==
+				 RTE_FLOW_ACTION_TYPE_VXLAN_DECAP ?
+				 MLX5_FLOW_ACTION_VXLAN_DECAP :
+				 MLX5_FLOW_ACTION_NVGRE_DECAP;
 		actions_n++;
 		break;
 	default:
-- 
1.8.3.1



More information about the dev mailing list