patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] [18.11] net/mlx5: fix selection between encap and decap
@ 2020-12-08 12:03 Viacheslav Ovsiienko
  0 siblings, 0 replies; only message in thread
From: Viacheslav Ovsiienko @ 2020-12-08 12:03 UTC (permalink / raw)
  To: stable; +Cc: ktraynor, orika, Ori Kam

From: Ori Kam <orika@mellanox.com>

From: Ori Kam <orika@mellanox.com>

The current raw_encap function selects if to decap or encap
based on the egress/ingress attribute. This concepts doesn't work
in case of FDB since all flows are considered ingress.

To solve this issue we moved to check the encap size.
if the encap size is larger then eth + ipv4 it means we are
trying to encap.

Fixes: 8ba9eee4ce32 ("net/mlx5: add raw data encap/decap to Direct Verbs")
Cc: stable@dpdk.org

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 17a298e..3363f90 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -37,6 +37,8 @@
 
 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
 
+#define MLX5_ENCAPSULATION_DECISION_SIZE (sizeof(struct ether_hdr) + \
+					  sizeof(struct ipv4_hdr))
 /**
  * Validate VLAN item.
  *
@@ -302,6 +304,8 @@
 				  const struct rte_flow_attr *attr,
 				  struct rte_flow_error *error)
 {
+	const struct rte_flow_action_raw_decap *decap = action->conf;
+
 	if (action_flags & MLX5_FLOW_ACTION_DROP)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ACTION, NULL,
@@ -317,22 +321,16 @@
 					  "can only have a single decap"
 					  " action in a flow");
 	/* decap action is valid on egress only if it is followed by encap */
-	if (attr->egress) {
-		for (; action->type != RTE_FLOW_ACTION_TYPE_END &&
-		       action->type != RTE_FLOW_ACTION_TYPE_RAW_ENCAP;
-		       action++) {
-		}
-		if (action->type != RTE_FLOW_ACTION_TYPE_RAW_ENCAP)
-			return rte_flow_error_set
-					(error, ENOTSUP,
-					 RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
-					 NULL, "decap action not supported"
-					 " for egress");
+	if (attr->egress && decap &&
+	    decap->size > MLX5_ENCAPSULATION_DECISION_SIZE) {
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
+					  NULL, "decap action not supported"
+					  " for egress");
 	}
 	return 0;
 }
 
-
 /**
  * Find existing encap/decap resource or create and register a new one.
  *
@@ -749,9 +747,9 @@
 	encap_data = (const struct rte_flow_action_raw_encap *)action->conf;
 	res.size = encap_data->size;
 	memcpy(res.buf, encap_data->data, res.size);
-	res.reformat_type = attr->egress ?
-		MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL :
-		MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2;
+	res.reformat_type = res.size < MLX5_ENCAPSULATION_DECISION_SIZE ?
+		MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L3_TUNNEL_TO_L2 :
+		MLX5DV_FLOW_ACTION_PACKET_REFORMAT_TYPE_L2_TO_L3_TUNNEL;
 	res.ft_type = attr->egress ? MLX5DV_FLOW_TABLE_TYPE_NIC_TX :
 				     MLX5DV_FLOW_TABLE_TYPE_NIC_RX;
 	if (flow_dv_encap_decap_resource_register(dev, &res, dev_flow, error))
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-08 12:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 12:03 [dpdk-stable] [PATCH] [18.11] net/mlx5: fix selection between encap and decap Viacheslav Ovsiienko

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git