[v3,2/4] net/mlx5: add Direct Verbs encap and decap defs

Message ID 1539113137-4914-3-git-send-email-dekelp@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Shahaf Shuler
Headers
Series add support of Direct Verbs encap and decap actions |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Dekel Peled Oct. 9, 2018, 7:25 p.m. UTC
  This patch adds the required definitions for DV encap/decap actions.
It also adds usage of the new actions definition in validation
function of existing drop operation.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 8 ++++++++
 drivers/net/mlx5/mlx5_flow.h | 6 ++++++
 2 files changed, 14 insertions(+)
  

Comments

Yongseok Koh Oct. 10, 2018, 12:40 a.m. UTC | #1
On Tue, Oct 09, 2018 at 10:25:35PM +0300, Dekel Peled wrote:
> This patch adds the required definitions for DV encap/decap actions.
> It also adds usage of the new actions definition in validation
> function of existing drop operation.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---

I've acked it in v2. So, please put my acked-by tag when you submit a new
version.

Acked-by: Yongseok Koh <yskoh@mellanox.com>

Thanks

>  drivers/net/mlx5/mlx5_flow.c | 8 ++++++++
>  drivers/net/mlx5/mlx5_flow.h | 6 ++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 1087f67..b452e11 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -766,6 +766,14 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
>  					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
>  					  "can't have 2 fate actions in"
>  					  " same flow");
> +	if (action_flags & (MLX5_FLOW_ACTION_TUNNEL_DECAP |
> +			    MLX5_FLOW_ACTION_TUNNEL_DECAP_L3 |
> +			    MLX5_FLOW_ACTION_TUNNEL_ENCAP |
> +			    MLX5_FLOW_ACTION_TUNNEL_ENCAP_L3))
> +		return rte_flow_error_set(error, EINVAL,
> +					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
> +					  "can't encap or decap and drop in"
> +					  " same flow");
>  	if (attr->egress)
>  		return rte_flow_error_set(error, ENOTSUP,
>  					  RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
> diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
> index 690c597..01c73a2 100644
> --- a/drivers/net/mlx5/mlx5_flow.h
> +++ b/drivers/net/mlx5/mlx5_flow.h
> @@ -82,6 +82,10 @@
>  #define MLX5_FLOW_ACTION_OF_SET_VLAN_VID (1u << 9)
>  #define MLX5_FLOW_ACTION_OF_SET_VLAN_PCP (1u << 10)
>  #define MLX5_FLOW_ACTION_JUMP (1u << 11)
> +#define MLX5_FLOW_ACTION_TUNNEL_ENCAP (1u << 12)
> +#define MLX5_FLOW_ACTION_TUNNEL_DECAP (1u << 13)
> +#define MLX5_FLOW_ACTION_TUNNEL_ENCAP_L3 (1u << 14)
> +#define MLX5_FLOW_ACTION_TUNNEL_DECAP_L3 (1u << 15)
>  
>  #define MLX5_FLOW_FATE_ACTIONS \
>  	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)
> @@ -172,6 +176,8 @@ struct mlx5_flow_dv {
>  #ifdef HAVE_IBV_FLOW_DV_SUPPORT
>  	struct mlx5dv_flow_action_attr actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];
>  	/**< Action list. */
> +	struct ibv_flow_action *encap_verb; /**< Verbs object of encap. */
> +	struct ibv_flow_action *decap_verb; /**< Verbs object of decap. */
>  #endif
>  	int actions_n; /**< number of actions. */
>  };
> -- 
> 1.8.3.1
>
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 1087f67..b452e11 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -766,6 +766,14 @@  uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
 					  "can't have 2 fate actions in"
 					  " same flow");
+	if (action_flags & (MLX5_FLOW_ACTION_TUNNEL_DECAP |
+			    MLX5_FLOW_ACTION_TUNNEL_DECAP_L3 |
+			    MLX5_FLOW_ACTION_TUNNEL_ENCAP |
+			    MLX5_FLOW_ACTION_TUNNEL_ENCAP_L3))
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
+					  "can't encap or decap and drop in"
+					  " same flow");
 	if (attr->egress)
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 690c597..01c73a2 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -82,6 +82,10 @@ 
 #define MLX5_FLOW_ACTION_OF_SET_VLAN_VID (1u << 9)
 #define MLX5_FLOW_ACTION_OF_SET_VLAN_PCP (1u << 10)
 #define MLX5_FLOW_ACTION_JUMP (1u << 11)
+#define MLX5_FLOW_ACTION_TUNNEL_ENCAP (1u << 12)
+#define MLX5_FLOW_ACTION_TUNNEL_DECAP (1u << 13)
+#define MLX5_FLOW_ACTION_TUNNEL_ENCAP_L3 (1u << 14)
+#define MLX5_FLOW_ACTION_TUNNEL_DECAP_L3 (1u << 15)
 
 #define MLX5_FLOW_FATE_ACTIONS \
 	(MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | MLX5_FLOW_ACTION_RSS)
@@ -172,6 +176,8 @@  struct mlx5_flow_dv {
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
 	struct mlx5dv_flow_action_attr actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];
 	/**< Action list. */
+	struct ibv_flow_action *encap_verb; /**< Verbs object of encap. */
+	struct ibv_flow_action *decap_verb; /**< Verbs object of decap. */
 #endif
 	int actions_n; /**< number of actions. */
 };