DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] net/mlx5: fix incorrect layer choose with decap
@ 2020-02-19 14:26 Suanming Mou
  2020-02-19 14:26 ` [dpdk-dev] [PATCH 1/2] net/mlx5: fix wrong layer validation with decapsulation Suanming Mou
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Suanming Mou @ 2020-02-19 14:26 UTC (permalink / raw)
  To: viacheslavo, matan; +Cc: dev, rasland

For header modify actions after decapsulation action, the header modify
actions should be applied to the inner layers.

Currently, it always treats the outermost layers as the corresponding
layer even though with decapsulation action.

Add the layer validation with decapsulation for the header modify action
and fix the incorrect layers chosen in header modify action with
decapsulation action.

Suanming Mou (2):
  net/mlx5: fix wrong layer validation with decapsulation
  net/mlx5: fix header modifiy choose wrong layer type

 drivers/net/mlx5/mlx5_flow_dv.c | 104 +++++++++++++++++++++++++++++++++-------
 1 file changed, 87 insertions(+), 17 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH 1/2] net/mlx5: fix wrong layer validation with decapsulation
  2020-02-19 14:26 [dpdk-dev] [PATCH 0/2] net/mlx5: fix incorrect layer choose with decap Suanming Mou
@ 2020-02-19 14:26 ` Suanming Mou
  2020-02-19 15:31   ` Matan Azrad
  2020-02-19 14:26 ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix header modifiy choose wrong layer type Suanming Mou
  2020-02-20 11:26 ` [dpdk-dev] [PATCH 0/2] net/mlx5: fix incorrect layer choose with decap Raslan Darawsheh
  2 siblings, 1 reply; 6+ messages in thread
From: Suanming Mou @ 2020-02-19 14:26 UTC (permalink / raw)
  To: viacheslavo, matan; +Cc: dev, rasland, stable

Currently, the flow validate function only validate the outermost layer
with the header modify actions. If there is decapsulation action before
the header modify action, the validation should choose the inner layer
for validation.

Add decapsulation check when validate with the header modify actions.
Choose the inner layer once there is decapsulation action.

Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs")
Cc: stable@dpdk.org

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 1c01269..410c555 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -3096,10 +3096,14 @@ struct field_modify_info modify_tcp[] = {
 				    struct rte_flow_error *error)
 {
 	int ret = 0;
+	uint64_t layer;
 
 	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
 	if (!ret) {
-		if (!(item_flags & MLX5_FLOW_LAYER_L3_IPV4))
+		layer = (action_flags & MLX5_FLOW_ACTION_DECAP) ?
+				 MLX5_FLOW_LAYER_INNER_L3_IPV4 :
+				 MLX5_FLOW_LAYER_OUTER_L3_IPV4;
+		if (!(item_flags & layer))
 			return rte_flow_error_set(error, EINVAL,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
 						  NULL,
@@ -3130,10 +3134,14 @@ struct field_modify_info modify_tcp[] = {
 				    struct rte_flow_error *error)
 {
 	int ret = 0;
+	uint64_t layer;
 
 	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
 	if (!ret) {
-		if (!(item_flags & MLX5_FLOW_LAYER_L3_IPV6))
+		layer = (action_flags & MLX5_FLOW_ACTION_DECAP) ?
+				 MLX5_FLOW_LAYER_INNER_L3_IPV6 :
+				 MLX5_FLOW_LAYER_OUTER_L3_IPV6;
+		if (!(item_flags & layer))
 			return rte_flow_error_set(error, EINVAL,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
 						  NULL,
@@ -3164,10 +3172,14 @@ struct field_modify_info modify_tcp[] = {
 				  struct rte_flow_error *error)
 {
 	int ret = 0;
+	uint64_t layer;
 
 	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
 	if (!ret) {
-		if (!(item_flags & MLX5_FLOW_LAYER_L4))
+		layer = (action_flags & MLX5_FLOW_ACTION_DECAP) ?
+				 MLX5_FLOW_LAYER_INNER_L4 :
+				 MLX5_FLOW_LAYER_OUTER_L4;
+		if (!(item_flags & layer))
 			return rte_flow_error_set(error, EINVAL,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
 						  NULL, "no transport layer "
@@ -3199,10 +3211,14 @@ struct field_modify_info modify_tcp[] = {
 				       struct rte_flow_error *error)
 {
 	int ret = 0;
+	uint64_t layer;
 
 	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
 	if (!ret) {
-		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+		layer = (action_flags & MLX5_FLOW_ACTION_DECAP) ?
+				 MLX5_FLOW_LAYER_INNER_L4_TCP :
+				 MLX5_FLOW_LAYER_OUTER_L4_TCP;
+		if (!(item_flags & layer))
 			return rte_flow_error_set(error, EINVAL,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
 						  NULL, "no TCP item in"
@@ -3244,10 +3260,14 @@ struct field_modify_info modify_tcp[] = {
 				       struct rte_flow_error *error)
 {
 	int ret = 0;
+	uint64_t layer;
 
 	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
 	if (!ret) {
-		if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L4_TCP))
+		layer = (action_flags & MLX5_FLOW_ACTION_DECAP) ?
+				 MLX5_FLOW_LAYER_INNER_L4_TCP :
+				 MLX5_FLOW_LAYER_OUTER_L4_TCP;
+		if (!(item_flags & layer))
 			return rte_flow_error_set(error, EINVAL,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
 						  NULL, "no TCP item in"
@@ -3288,10 +3308,14 @@ struct field_modify_info modify_tcp[] = {
 				   struct rte_flow_error *error)
 {
 	int ret = 0;
+	uint64_t layer;
 
 	ret = flow_dv_validate_action_modify_hdr(action_flags, action, error);
 	if (!ret) {
-		if (!(item_flags & MLX5_FLOW_LAYER_L3))
+		layer = (action_flags & MLX5_FLOW_ACTION_DECAP) ?
+				 MLX5_FLOW_LAYER_INNER_L3 :
+				 MLX5_FLOW_LAYER_OUTER_L3;
+		if (!(item_flags & layer))
 			return rte_flow_error_set(error, EINVAL,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
 						  NULL,
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH 2/2] net/mlx5: fix header modifiy choose wrong layer type
  2020-02-19 14:26 [dpdk-dev] [PATCH 0/2] net/mlx5: fix incorrect layer choose with decap Suanming Mou
  2020-02-19 14:26 ` [dpdk-dev] [PATCH 1/2] net/mlx5: fix wrong layer validation with decapsulation Suanming Mou
@ 2020-02-19 14:26 ` Suanming Mou
  2020-02-19 15:31   ` Matan Azrad
  2020-02-20 11:26 ` [dpdk-dev] [PATCH 0/2] net/mlx5: fix incorrect layer choose with decap Raslan Darawsheh
  2 siblings, 1 reply; 6+ messages in thread
From: Suanming Mou @ 2020-02-19 14:26 UTC (permalink / raw)
  To: viacheslavo, matan; +Cc: dev, rasland, stable

Currently, for header modify actions after tunnel decapsulation, the
header modify actions will still select the old outermost layer type.
It will cause header modify actions get the wrong layer type.

Add the tunnel decap flag to indicate the layer type to get for header
modify actions.

Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs")
Cc: stable@dpdk.org

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 68 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 57 insertions(+), 11 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 410c555..d038f7b 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -85,19 +85,55 @@
  *   Pointer to item specification.
  * @param[out] attr
  *   Pointer to flow attributes structure.
+ * @param[in] tunnel_decap
+ *   Whether action is after tunnel decapsulation.
  */
 static void
-flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr *attr)
+flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr *attr,
+		  bool tunnel_decap)
 {
 	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
+		uint8_t next_protocol = 0xff;
+
 		switch (item->type) {
+		case RTE_FLOW_ITEM_TYPE_GRE:
+		case RTE_FLOW_ITEM_TYPE_NVGRE:
+		case RTE_FLOW_ITEM_TYPE_VXLAN:
+		case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
+		case RTE_FLOW_ITEM_TYPE_GENEVE:
+		case RTE_FLOW_ITEM_TYPE_MPLS:
+			if (tunnel_decap)
+				attr->attr = 0;
+			break;
 		case RTE_FLOW_ITEM_TYPE_IPV4:
 			if (!attr->ipv6)
 				attr->ipv4 = 1;
+			if (item->mask != NULL &&
+			    ((const struct rte_flow_item_ipv4 *)
+			    item->mask)->hdr.next_proto_id)
+				next_protocol =
+				    ((const struct rte_flow_item_ipv4 *)
+				      (item->spec))->hdr.next_proto_id &
+				    ((const struct rte_flow_item_ipv4 *)
+				      (item->mask))->hdr.next_proto_id;
+			if ((next_protocol == IPPROTO_IPIP ||
+			    next_protocol == IPPROTO_IPV6) && tunnel_decap)
+				attr->attr = 0;
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			if (!attr->ipv4)
 				attr->ipv6 = 1;
+			if (item->mask != NULL &&
+			    ((const struct rte_flow_item_ipv6 *)
+			    item->mask)->hdr.proto)
+				next_protocol =
+				    ((const struct rte_flow_item_ipv6 *)
+				      (item->spec))->hdr.proto &
+				    ((const struct rte_flow_item_ipv6 *)
+				      (item->mask))->hdr.proto;
+			if ((next_protocol == IPPROTO_IPIP ||
+			    next_protocol == IPPROTO_IPV6) && tunnel_decap)
+				attr->attr = 0;
 			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
 			if (!attr->tcp)
@@ -604,6 +640,8 @@ struct field_modify_info modify_tcp[] = {
  *   Pointer to rte_flow_item objects list.
  * @param[in] attr
  *   Pointer to flow attributes structure.
+ * @param[in] tunnel_decap
+ *   Whether action is after tunnel decapsulation.
  * @param[out] error
  *   Pointer to the error structure.
  *
@@ -615,7 +653,7 @@ struct field_modify_info modify_tcp[] = {
 			(struct mlx5_flow_dv_modify_hdr_resource *resource,
 			 const struct rte_flow_action *action,
 			 const struct rte_flow_item *items,
-			 union flow_dv_attr *attr,
+			 union flow_dv_attr *attr, bool tunnel_decap,
 			 struct rte_flow_error *error)
 {
 	const struct rte_flow_action_set_tp *conf =
@@ -628,7 +666,7 @@ struct field_modify_info modify_tcp[] = {
 	struct field_modify_info *field;
 
 	if (!attr->valid)
-		flow_dv_attr_init(items, attr);
+		flow_dv_attr_init(items, attr, tunnel_decap);
 	if (attr->udp) {
 		memset(&udp, 0, sizeof(udp));
 		memset(&udp_mask, 0, sizeof(udp_mask));
@@ -678,6 +716,8 @@ struct field_modify_info modify_tcp[] = {
  *   Pointer to rte_flow_item objects list.
  * @param[in] attr
  *   Pointer to flow attributes structure.
+ * @param[in] tunnel_decap
+ *   Whether action is after tunnel decapsulation.
  * @param[out] error
  *   Pointer to the error structure.
  *
@@ -689,7 +729,7 @@ struct field_modify_info modify_tcp[] = {
 			(struct mlx5_flow_dv_modify_hdr_resource *resource,
 			 const struct rte_flow_action *action,
 			 const struct rte_flow_item *items,
-			 union flow_dv_attr *attr,
+			 union flow_dv_attr *attr, bool tunnel_decap,
 			 struct rte_flow_error *error)
 {
 	const struct rte_flow_action_set_ttl *conf =
@@ -702,7 +742,7 @@ struct field_modify_info modify_tcp[] = {
 	struct field_modify_info *field;
 
 	if (!attr->valid)
-		flow_dv_attr_init(items, attr);
+		flow_dv_attr_init(items, attr, tunnel_decap);
 	if (attr->ipv4) {
 		memset(&ipv4, 0, sizeof(ipv4));
 		memset(&ipv4_mask, 0, sizeof(ipv4_mask));
@@ -738,6 +778,8 @@ struct field_modify_info modify_tcp[] = {
  *   Pointer to rte_flow_item objects list.
  * @param[in] attr
  *   Pointer to flow attributes structure.
+ * @param[in] tunnel_decap
+ *   Whether action is after tunnel decapsulation.
  * @param[out] error
  *   Pointer to the error structure.
  *
@@ -748,7 +790,7 @@ struct field_modify_info modify_tcp[] = {
 flow_dv_convert_action_modify_dec_ttl
 			(struct mlx5_flow_dv_modify_hdr_resource *resource,
 			 const struct rte_flow_item *items,
-			 union flow_dv_attr *attr,
+			 union flow_dv_attr *attr, bool tunnel_decap,
 			 struct rte_flow_error *error)
 {
 	struct rte_flow_item item;
@@ -759,7 +801,7 @@ struct field_modify_info modify_tcp[] = {
 	struct field_modify_info *field;
 
 	if (!attr->valid)
-		flow_dv_attr_init(items, attr);
+		flow_dv_attr_init(items, attr, tunnel_decap);
 	if (attr->ipv4) {
 		memset(&ipv4, 0, sizeof(ipv4));
 		memset(&ipv4_mask, 0, sizeof(ipv4_mask));
@@ -7463,7 +7505,8 @@ struct field_modify_info modify_tcp[] = {
 		case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
 			if (flow_dv_convert_action_modify_tp
 					(mhdr_res, actions, items,
-					 &flow_attr, error))
+					 &flow_attr, !!(action_flags &
+					 MLX5_FLOW_ACTION_DECAP), error))
 				return -rte_errno;
 			action_flags |= actions->type ==
 					RTE_FLOW_ACTION_TYPE_SET_TP_SRC ?
@@ -7472,14 +7515,17 @@ struct field_modify_info modify_tcp[] = {
 			break;
 		case RTE_FLOW_ACTION_TYPE_DEC_TTL:
 			if (flow_dv_convert_action_modify_dec_ttl
-					(mhdr_res, items, &flow_attr, error))
+					(mhdr_res, items, &flow_attr,
+					 !!(action_flags &
+					 MLX5_FLOW_ACTION_DECAP), error))
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_DEC_TTL;
 			break;
 		case RTE_FLOW_ACTION_TYPE_SET_TTL:
 			if (flow_dv_convert_action_modify_ttl
-					(mhdr_res, actions, items,
-					 &flow_attr, error))
+					(mhdr_res, actions, items, &flow_attr,
+					 !!(action_flags &
+					 MLX5_FLOW_ACTION_DECAP), error))
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
 			break;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] net/mlx5: fix wrong layer validation with decapsulation
  2020-02-19 14:26 ` [dpdk-dev] [PATCH 1/2] net/mlx5: fix wrong layer validation with decapsulation Suanming Mou
@ 2020-02-19 15:31   ` Matan Azrad
  0 siblings, 0 replies; 6+ messages in thread
From: Matan Azrad @ 2020-02-19 15:31 UTC (permalink / raw)
  To: Suanming Mou, Slava Ovsiienko; +Cc: dev, Raslan Darawsheh, stable



From: Suanming Mou
> Currently, the flow validate function only validate the outermost layer with
> the header modify actions. If there is decapsulation action before the header
> modify action, the validation should choose the inner layer for validation.
> 
> Add decapsulation check when validate with the header modify actions.
> Choose the inner layer once there is decapsulation action.
> 
> Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] net/mlx5: fix header modifiy choose wrong layer type
  2020-02-19 14:26 ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix header modifiy choose wrong layer type Suanming Mou
@ 2020-02-19 15:31   ` Matan Azrad
  0 siblings, 0 replies; 6+ messages in thread
From: Matan Azrad @ 2020-02-19 15:31 UTC (permalink / raw)
  To: Suanming Mou, Slava Ovsiienko; +Cc: dev, Raslan Darawsheh, stable



From: Suanming Mou
> Currently, for header modify actions after tunnel decapsulation, the header
> modify actions will still select the old outermost layer type.
> It will cause header modify actions get the wrong layer type.
> 
> Add the tunnel decap flag to indicate the layer type to get for header modify
> actions.
> 
> Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH 0/2] net/mlx5: fix incorrect layer choose with decap
  2020-02-19 14:26 [dpdk-dev] [PATCH 0/2] net/mlx5: fix incorrect layer choose with decap Suanming Mou
  2020-02-19 14:26 ` [dpdk-dev] [PATCH 1/2] net/mlx5: fix wrong layer validation with decapsulation Suanming Mou
  2020-02-19 14:26 ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix header modifiy choose wrong layer type Suanming Mou
@ 2020-02-20 11:26 ` Raslan Darawsheh
  2 siblings, 0 replies; 6+ messages in thread
From: Raslan Darawsheh @ 2020-02-20 11:26 UTC (permalink / raw)
  To: Suanming Mou, Slava Ovsiienko, Matan Azrad; +Cc: dev

Hi,

> -----Original Message-----
> From: Suanming Mou <suanmingm@mellanox.com>
> Sent: Wednesday, February 19, 2020 4:26 PM
> To: Slava Ovsiienko <viacheslavo@mellanox.com>; Matan Azrad
> <matan@mellanox.com>
> Cc: dev@dpdk.org; Raslan Darawsheh <rasland@mellanox.com>
> Subject: [PATCH 0/2] net/mlx5: fix incorrect layer choose with decap
> 
> For header modify actions after decapsulation action, the header modify
> actions should be applied to the inner layers.
> 
> Currently, it always treats the outermost layers as the corresponding
> layer even though with decapsulation action.
> 
> Add the layer validation with decapsulation for the header modify action
> and fix the incorrect layers chosen in header modify action with
> decapsulation action.
> 
> Suanming Mou (2):
>   net/mlx5: fix wrong layer validation with decapsulation
>   net/mlx5: fix header modifiy choose wrong layer type
> 
>  drivers/net/mlx5/mlx5_flow_dv.c | 104
> +++++++++++++++++++++++++++++++++-------
>  1 file changed, 87 insertions(+), 17 deletions(-)
> 
> --
> 1.8.3.1


Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-02-20 11:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 14:26 [dpdk-dev] [PATCH 0/2] net/mlx5: fix incorrect layer choose with decap Suanming Mou
2020-02-19 14:26 ` [dpdk-dev] [PATCH 1/2] net/mlx5: fix wrong layer validation with decapsulation Suanming Mou
2020-02-19 15:31   ` Matan Azrad
2020-02-19 14:26 ` [dpdk-dev] [PATCH 2/2] net/mlx5: fix header modifiy choose wrong layer type Suanming Mou
2020-02-19 15:31   ` Matan Azrad
2020-02-20 11:26 ` [dpdk-dev] [PATCH 0/2] net/mlx5: fix incorrect layer choose with decap Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).