patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] net/mlx5: fix tunnel offload validation
@ 2021-11-03  8:55 Gregory Etelson
  2021-11-10  8:45 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Gregory Etelson @ 2021-11-03  8:55 UTC (permalink / raw)
  To: dev, getelson; +Cc: matan, rasland, stable, Viacheslav Ovsiienko

Tunnel offload API allows application to restore packet to
its original form if chain of flows missed after DECAP action.

MLX5 PMD provides tunnel offload support only if DV API was enabled.

The patch verifies DV availability before processing with
tunnel offload tasks.

Cc: stable@dpdk.org

Fixes: 4ec6360de37d ("net/mlx5: implement tunnel offload")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c    | 54 +++++++++++++++------------------
 drivers/net/mlx5/mlx5_flow_dv.c |  5 +++
 2 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 2385a0b550..2ce424dd1b 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -9343,33 +9343,37 @@ int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh)
 	return err;
 }
 
-static inline bool
+static inline int
 mlx5_flow_tunnel_validate(struct rte_eth_dev *dev,
 			  struct rte_flow_tunnel *tunnel,
-			  const char *err_msg)
+			  struct rte_flow_error *error)
 {
-	err_msg = NULL;
-	if (!is_tunnel_offload_active(dev)) {
-		err_msg = "tunnel offload was not activated";
-		goto out;
-	} else if (!tunnel) {
-		err_msg = "no application tunnel";
-		goto out;
-	}
+	struct mlx5_priv *priv = dev->data->dev_private;
 
+	if (!priv->config.dv_flow_en)
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL,
+					  "flow DV interface is off");
+	if (!is_tunnel_offload_active(dev))
+		return rte_flow_error_set(error, ENOTSUP,
+					  RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL,
+					  "tunnel offload was not activated");
+	if (!tunnel)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL,
+					  "no application tunnel");
 	switch (tunnel->type) {
 	default:
-		err_msg = "unsupported tunnel type";
-		goto out;
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL,
+					  "unsupported tunnel type");
 	case RTE_FLOW_ITEM_TYPE_VXLAN:
 	case RTE_FLOW_ITEM_TYPE_GRE:
 	case RTE_FLOW_ITEM_TYPE_NVGRE:
 	case RTE_FLOW_ITEM_TYPE_GENEVE:
 		break;
 	}
-
-out:
-	return !err_msg;
+	return 0;
 }
 
 static int
@@ -9379,15 +9383,11 @@ mlx5_flow_tunnel_decap_set(struct rte_eth_dev *dev,
 		    uint32_t *num_of_actions,
 		    struct rte_flow_error *error)
 {
-	int ret;
 	struct mlx5_flow_tunnel *tunnel;
-	const char *err_msg = NULL;
-	bool verdict = mlx5_flow_tunnel_validate(dev, app_tunnel, err_msg);
+	int ret = mlx5_flow_tunnel_validate(dev, app_tunnel, error);
 
-	if (!verdict)
-		return rte_flow_error_set(error, EINVAL,
-					  RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL,
-					  err_msg);
+	if (ret)
+		return ret;
 	ret = mlx5_get_flow_tunnel(dev, app_tunnel, &tunnel);
 	if (ret < 0) {
 		return rte_flow_error_set(error, ret,
@@ -9406,15 +9406,11 @@ mlx5_flow_tunnel_match(struct rte_eth_dev *dev,
 		       uint32_t *num_of_items,
 		       struct rte_flow_error *error)
 {
-	int ret;
 	struct mlx5_flow_tunnel *tunnel;
-	const char *err_msg = NULL;
-	bool verdict = mlx5_flow_tunnel_validate(dev, app_tunnel, err_msg);
+	int ret = mlx5_flow_tunnel_validate(dev, app_tunnel, error);
 
-	if (!verdict)
-		return rte_flow_error_set(error, EINVAL,
-					  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
-					  err_msg);
+	if (ret)
+		return ret;
 	ret = mlx5_get_flow_tunnel(dev, app_tunnel, &tunnel);
 	if (ret < 0) {
 		return rte_flow_error_set(error, ret,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 8962d26c75..21d686f3f0 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -6789,6 +6789,11 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
 	tunnel = is_tunnel_offload_active(dev) ?
 		 mlx5_get_tof(items, actions, &tof_rule_type) : NULL;
 	if (tunnel) {
+		if (!priv->config.dv_flow_en)
+			return rte_flow_error_set
+				(error, ENOTSUP,
+				 RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				 NULL, "tunnel offload requires DV flow interface");
 		if (priv->representor)
 			return rte_flow_error_set
 				(error, ENOTSUP,
-- 
2.33.1


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

* Re: [dpdk-stable] [PATCH] net/mlx5: fix tunnel offload validation
  2021-11-03  8:55 [dpdk-stable] [PATCH] net/mlx5: fix tunnel offload validation Gregory Etelson
@ 2021-11-10  8:45 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2021-11-10  8:45 UTC (permalink / raw)
  To: Gregory Etelson, dev; +Cc: Matan Azrad, stable, Slava Ovsiienko

Hi,

> -----Original Message-----
> From: Gregory Etelson <getelson@nvidia.com>
> Sent: Wednesday, November 3, 2021 10:56 AM
> To: dev@dpdk.org; Gregory Etelson <getelson@nvidia.com>
> Cc: Matan Azrad <matan@nvidia.com>; Raslan Darawsheh
> <rasland@nvidia.com>; stable@dpdk.org; Slava Ovsiienko
> <viacheslavo@nvidia.com>
> Subject: [PATCH] net/mlx5: fix tunnel offload validation
> 
> Tunnel offload API allows application to restore packet to
> its original form if chain of flows missed after DECAP action.
> 
> MLX5 PMD provides tunnel offload support only if DV API was enabled.
> 
> The patch verifies DV availability before processing with
> tunnel offload tasks.
> 
> Cc: stable@dpdk.org
> 
> Fixes: 4ec6360de37d ("net/mlx5: implement tunnel offload")
> 
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2021-11-10  8:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03  8:55 [dpdk-stable] [PATCH] net/mlx5: fix tunnel offload validation Gregory Etelson
2021-11-10  8:45 ` Raslan Darawsheh

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://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/ http://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