From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 74FBDA04B5;
	Wed, 28 Oct 2020 00:24:33 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id A346F2C1A;
	Wed, 28 Oct 2020 00:24:09 +0100 (CET)
Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])
 by dpdk.org (Postfix) with ESMTP id 1CDAB2BF9
 for <dev@dpdk.org>; Wed, 28 Oct 2020 00:24:00 +0100 (CET)
Received: from Internal Mail-Server by MTLPINE1 (envelope-from
 ophirmu@nvidia.com) with SMTP; 28 Oct 2020 01:23:53 +0200
Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100])
 by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09RNNrrE026642;
 Wed, 28 Oct 2020 01:23:53 +0200
From: Ophir Munk <ophirmu@nvidia.com>
To: dev@dpdk.org, Raslan Darawsheh <rasland@nvidia.com>
Cc: Ophir Munk <ophirmu@nvidia.com>, Matan Azrad <matan@nvidia.com>,
 Tal Shnaiderman <talshn@nvidia.com>,
 Thomas Monjalon <thomas@monjalon.net>, stable@dpdk.org
Date: Tue, 27 Oct 2020 23:22:25 +0000
Message-Id: <20201027232335.31427-3-ophirmu@nvidia.com>
X-Mailer: git-send-email 2.8.4
In-Reply-To: <20201027232335.31427-1-ophirmu@nvidia.com>
References: <20201027232335.31427-1-ophirmu@nvidia.com>
Subject: [dpdk-dev] [PATCH v1 02/72] net/mlx5: fix flow sample definitions
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Flow sampling is dependent on rdma-core support. The definitions which
enable sampling code are HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE and
HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY. This commit expands these
definitions to more functions which use sampling logic and structs:
flow_dv_sample_resource_register, flow_dv_dest_array_resource_register,
flow_dv_sample_resource_release, flow_dv_dest_array_resource_release.
Hence any system without the required rdma-core support will not compile
or execute redundant sampling code.

Fixes: eb7368b0109a ("net/mlx5: update translate function for sample action")
Fixes: e8a1d23ae9a8 ("net/mlx5: update translate function for mirror")
Cc: stable@dpdk.org

Signed-off-by: Ophir Munk <ophirmu@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index dafe07f..2560559 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -8629,6 +8629,7 @@ flow_dv_sample_resource_register(struct rte_eth_dev *dev,
 			 void **sample_dv_actions,
 			 struct rte_flow_error *error)
 {
+#ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
 	struct mlx5_flow_dv_sample_resource *cache_resource;
 	struct mlx5dv_dr_flow_sampler_attr sampler_attr;
 	struct mlx5_priv *priv = dev->data->dev_private;
@@ -8746,6 +8747,17 @@ flow_dv_sample_resource_register(struct rte_eth_dev *dev,
 				dev_flow->handle->dvh.rix_sample);
 	dev_flow->handle->dvh.rix_sample = 0;
 	return -rte_errno;
+#else
+	RTE_SET_USED(dev);
+	RTE_SET_USED(attr);
+	RTE_SET_USED(resource);
+	RTE_SET_USED(dev_flow);
+	RTE_SET_USED(sample_dv_actions);
+	RTE_SET_USED(error);
+	DRV_LOG(ERR, "Sample resource registration is not supported.");
+	rte_errno = ENOTSUP;
+	return -ENOTSUP;
+#endif /* HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE */
 }
 
 /**
@@ -8772,6 +8784,7 @@ flow_dv_dest_array_resource_register(struct rte_eth_dev *dev,
 			 struct mlx5_flow *dev_flow,
 			 struct rte_flow_error *error)
 {
+#ifdef HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY
 	struct mlx5_flow_dv_dest_array_resource *cache_resource;
 	struct mlx5dv_dr_action_dest_attr *dest_attr[MLX5_MAX_DEST_NUM] = { 0 };
 	struct mlx5dv_dr_action_dest_reformat dest_reformat[MLX5_MAX_DEST_NUM];
@@ -8894,6 +8907,16 @@ flow_dv_dest_array_resource_register(struct rte_eth_dev *dev,
 				dev_flow->handle->dvh.rix_dest_array);
 	dev_flow->handle->dvh.rix_dest_array = 0;
 	return -rte_errno;
+#else
+	RTE_SET_USED(dev);
+	RTE_SET_USED(attr);
+	RTE_SET_USED(resource);
+	RTE_SET_USED(dev_flow);
+	RTE_SET_USED(error);
+	DRV_LOG(ERR, "Dest array resource registration is not supported.");
+	rte_errno = ENOTSUP;
+	return -ENOTSUP;
+#endif /* HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY */
 }
 
 /**
@@ -10758,6 +10781,7 @@ static int
 flow_dv_sample_resource_release(struct rte_eth_dev *dev,
 				     struct mlx5_flow_handle *handle)
 {
+#ifdef HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE
 	struct mlx5_priv *priv = dev->data->dev_private;
 	uint32_t idx = handle->dvh.rix_sample;
 	struct mlx5_flow_dv_sample_resource *cache_resource;
@@ -10807,6 +10831,12 @@ flow_dv_sample_resource_release(struct rte_eth_dev *dev,
 		return 0;
 	}
 	return 1;
+#else
+	RTE_SET_USED(dev);
+	RTE_SET_USED(handle);
+	DRV_LOG(ERR, "Sample resource release is not supported.");
+	return 0;
+#endif /* HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE */
 }
 
 /**
@@ -10824,6 +10854,7 @@ static int
 flow_dv_dest_array_resource_release(struct rte_eth_dev *dev,
 				     struct mlx5_flow_handle *handle)
 {
+#ifdef HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_flow_dv_dest_array_resource *cache_resource;
 	struct mlx5_flow_sub_actions_idx *mdest_act_res;
@@ -10875,6 +10906,12 @@ flow_dv_dest_array_resource_release(struct rte_eth_dev *dev,
 		return 0;
 	}
 	return 1;
+#else
+	RTE_SET_USED(dev);
+	RTE_SET_USED(handle);
+	DRV_LOG(ERR, "Dest array resource release is not supported.");
+	return 0;
+#endif /* ifdef HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY */
 }
 
 /**
-- 
2.8.4