diff mbox series

[3/3] common/mlx5: move to formal ASO action API

Message ID c1aaa4a92d9f8402b7ebd70920b72ec508976827.1605689124.git.dekelp@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers show
Series ASO age action fixes | expand

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-testing warning Testing issues
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/checkpatch success coding style OK

Commit Message

Dekel Peled Nov. 18, 2020, 8:59 a.m. UTC
Existing code uses the previous API offered by rdma-core in order
to create ASO Flow Hit action.

A general API is now formally released, to create ASO action of any type.
This patch moves the MLX5 PMD code to use the formal API.

Signed-off-by: Dekel Peled <dekelp@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/common/mlx5/linux/meson.build |  4 +--
 drivers/common/mlx5/linux/mlx5_glue.c | 38 ++++++++++++++++-----------
 drivers/common/mlx5/linux/mlx5_glue.h |  6 ++---
 drivers/net/mlx5/linux/mlx5_os.c      |  4 +--
 drivers/net/mlx5/mlx5_flow_dv.c       | 11 +++++---
 5 files changed, 36 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 87f7bfda51..63b78e4bce 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -181,8 +181,8 @@  has_sym_args = [
 	[ 'HAVE_MLX5_DR_CREATE_ACTION_DEST_ARRAY', 'infiniband/mlx5dv.h',
 	'mlx5dv_dr_action_create_dest_array'],
 	[ 'HAVE_DEVLINK', 'linux/devlink.h', 'DEVLINK_GENL_NAME' ],
-        [ 'HAVE_MLX5DV_DR_ACTION_FLOW_HIT', 'infiniband/mlx5dv.h',
-        'mlx5dv_dr_action_create_flow_hit'],
+        [ 'HAVE_MLX5_DR_CREATE_ACTION_ASO', 'infiniband/mlx5dv.h',
+        'mlx5dv_dr_action_create_aso' ],
 ]
 config = configuration_data()
 foreach arg:has_sym_args
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index cc6670c5bd..8146c79287 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c
@@ -811,6 +811,27 @@  mlx5_glue_dv_modify_flow_action_meter(void *action,
 #endif
 }
 
+static void *
+mlx5_glue_dv_create_flow_action_aso(struct mlx5dv_dr_domain *domain,
+				    void *aso_obj,
+				    uint32_t offset,
+				    uint32_t flags,
+				    uint8_t return_reg_c)
+{
+#if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_ASO)
+	return mlx5dv_dr_action_create_aso(domain, aso_obj, offset,
+					   flags, return_reg_c);
+#else
+	(void)domain;
+	(void)aso_obj;
+	(void)offset;
+	(void)flags;
+	(void)return_reg_c;
+	errno = ENOTSUP;
+	return NULL;
+#endif
+}
+
 static void *
 mlx5_glue_dr_create_flow_action_default_miss(void)
 {
@@ -1281,21 +1302,6 @@  mlx5_glue_dv_free_pp(struct mlx5dv_pp *pp)
 #endif
 }
 
-static void *
-mlx5_glue_dr_action_create_flow_hit(struct mlx5dv_devx_obj *devx_obj,
-				    uint32_t offset, uint8_t reg_c_index)
-{
-#ifdef HAVE_MLX5DV_DR_ACTION_FLOW_HIT
-	return mlx5dv_dr_action_create_flow_hit(devx_obj, offset, reg_c_index);
-#else
-	(void)(devx_obj);
-	(void)(offset);
-	(void)(reg_c_index);
-	errno = ENOTSUP;
-	return NULL;
-#endif
-}
-
 __rte_cache_aligned
 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
 	.version = MLX5_GLUE_VERSION,
@@ -1379,6 +1385,7 @@  const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
 	.dv_create_flow_action_tag =  mlx5_glue_dv_create_flow_action_tag,
 	.dv_create_flow_action_meter = mlx5_glue_dv_create_flow_action_meter,
 	.dv_modify_flow_action_meter = mlx5_glue_dv_modify_flow_action_meter,
+	.dv_create_flow_action_aso = mlx5_glue_dv_create_flow_action_aso,
 	.dr_create_flow_action_default_miss =
 		mlx5_glue_dr_create_flow_action_default_miss,
 	.dv_destroy_flow = mlx5_glue_dv_destroy_flow,
@@ -1415,5 +1422,4 @@  const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
 	.dv_free_var = mlx5_glue_dv_free_var,
 	.dv_alloc_pp = mlx5_glue_dv_alloc_pp,
 	.dv_free_pp = mlx5_glue_dv_free_pp,
-	.dr_action_create_flow_hit = mlx5_glue_dr_action_create_flow_hit,
 };
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index c5d7853ea9..8be446a902 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h
@@ -344,9 +344,9 @@  struct mlx5_glue {
 			(void *domain,
 			 size_t num_dest,
 			 struct mlx5dv_dr_action_dest_attr *dests[]);
-	void *(*dr_action_create_flow_hit)(struct mlx5dv_devx_obj *devx_obj,
-					   uint32_t offset,
-					   uint8_t reg_c_index);
+	void *(*dv_create_flow_action_aso)
+			(struct mlx5dv_dr_domain *domain, void *aso_obj,
+			 uint32_t offset, uint32_t flags, uint8_t return_reg_c);
 };
 
 extern const struct mlx5_glue *mlx5_glue;
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 468ef3356f..2dfed4b16f 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -1200,7 +1200,7 @@  mlx5_dev_spawn(struct rte_device *dpdk_dev,
 			}
 		}
 #endif
-#ifdef HAVE_MLX5DV_DR_ACTION_FLOW_HIT
+#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO
 		if (config->hca_attr.flow_hit_aso &&
 		    priv->mtr_color_reg == REG_C_3) {
 			sh->flow_hit_aso_en = 1;
@@ -1211,7 +1211,7 @@  mlx5_dev_spawn(struct rte_device *dpdk_dev,
 			}
 			DRV_LOG(DEBUG, "Flow Hit ASO is supported.");
 		}
-#endif /* HAVE_MLX5DV_DR_ACTION_FLOW_HIT */
+#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */
 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE)
 		if (config->hca_attr.log_max_ft_sampler_num > 0  &&
 		    config->dv_flow_en) {
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index ae8967ec58..b3e71fc564 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -9491,10 +9491,13 @@  flow_dv_aso_age_alloc(struct rte_eth_dev *dev, struct rte_flow_error *error)
 					   "for ASO flow hit");
 			return 0; /* 0 is an error. */
 		}
-		age_free->dr_action = mlx5_glue->dr_action_create_flow_hit
-						(pool->flow_hit_aso_obj->obj,
-						 age_free->offset,
-						 (reg_c - REG_C_0));
+#ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO
+		age_free->dr_action = mlx5_glue->dv_create_flow_action_aso
+				(priv->sh->rx_domain,
+				 pool->flow_hit_aso_obj->obj, age_free->offset,
+				 MLX5DV_DR_ACTION_FLAGS_ASO_FIRST_HIT_SET,
+				 (reg_c - REG_C_0));
+#endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */
 		if (!age_free->dr_action) {
 			rte_errno = errno;
 			rte_spinlock_lock(&mng->free_sl);