diff mbox series

[03/10] common/mlx5: update regex DevX commands

Message ID 20211022154600.2180938-3-fkelly@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series [01/10] common/mlx5: update PRM definitions for regex availability | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Francis Kelly Oct. 22, 2021, 3:45 p.m. UTC
From: Ady Agbarih <adypodoman@gmail.com>

This patch modifies the SET_REGEXP_PARAMS devx command as follows:
  Remove DB setup devx command. The command is no longer needed
    in DPDK, it will always be invoked by the regex-daemon.
  Add new devx command, for programming rof rules for a specific
    engine. The command takes as an input an mkey of the rof.
    It also introduces a new field_select bit.

Signed-off-by: Ady Agbarih <adypodoman@gmail.com>
---
 drivers/common/mlx5/mlx5_prm.h       | 13 ++++++++-----
 drivers/regex/mlx5/mlx5_regex.c      |  9 +++------
 drivers/regex/mlx5/mlx5_regex.h      |  4 ++--
 drivers/regex/mlx5/mlx5_regex_devx.c | 15 ++++++++-------
 drivers/regex/mlx5/mlx5_rxp.c        | 27 ---------------------------
 5 files changed, 21 insertions(+), 47 deletions(-)

Comments

Ori Kam Oct. 24, 2021, 1:39 p.m. UTC | #1
Hi Francis,

> -----Original Message-----
> From: Francis Kelly <fkelly@nvidia.com>
> Sent: Friday, October 22, 2021 6:46 PM
> Subject: [PATCH 03/10] common/mlx5: update regex DevX commands
> 
> From: Ady Agbarih <adypodoman@gmail.com>
> 
> This patch modifies the SET_REGEXP_PARAMS devx command as follows:
>   Remove DB setup devx command. The command is no longer needed
>     in DPDK, it will always be invoked by the regex-daemon.
>   Add new devx command, for programming rof rules for a specific
>     engine. The command takes as an input an mkey of the rof.
>     It also introduces a new field_select bit.
> 
> Signed-off-by: Ady Agbarih <adypodoman@gmail.com>
> ---

Acked-by: Ori Kam <orika@nvidia.com>
Best,
Ori
diff mbox series

Patch

diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h
index 8b0f2f1a89..fb75f2da4d 100644
--- a/drivers/common/mlx5/mlx5_prm.h
+++ b/drivers/common/mlx5/mlx5_prm.h
@@ -3710,17 +3710,20 @@  struct mlx5_ifc_parse_graph_flex_out_bits {
 };
 
 struct regexp_params_field_select_bits {
-	u8 reserved_at_0[0x1e];
+	u8 reserved_at_0[0x1d];
+	u8 rof_mkey[0x1];
 	u8 stop_engine[0x1];
-	u8 db_umem_id[0x1];
+	u8 reserved_at_1f[0x1];
 };
 
 struct mlx5_ifc_regexp_params_bits {
 	u8 reserved_at_0[0x1f];
 	u8 stop_engine[0x1];
-	u8 db_umem_id[0x20];
-	u8 db_umem_offset[0x40];
-	u8 reserved_at_80[0x100];
+	u8 reserved_at_20[0x60];
+	u8 rof_mkey[0x20];
+	u8 rof_size[0x20];
+	u8 rof_mkey_va[0x40];
+	u8 reserved_at_100[0x80];
 };
 
 struct mlx5_ifc_set_regexp_params_in_bits {
diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index b7175ff8e9..4be36e40c5 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -55,12 +55,9 @@  mlx5_regex_stop(struct rte_regexdev *dev __rte_unused)
 	rte_free(priv->qps);
 	priv->qps = NULL;
 
-	for (i = 0; i < (priv->nb_engines + MLX5_RXP_EM_COUNT); i++) {
-		if (priv->db[i].umem.umem)
-			mlx5_glue->devx_umem_dereg(priv->db[i].umem.umem);
-		rte_free(priv->db[i].ptr);
-		priv->db[i].ptr = NULL;
-	}
+	for (i = 0; i < priv->nb_engines; i++)
+		/* Stop engine. */
+		mlx5_devx_regex_database_stop(priv->ctx, i);
 
 	return 0;
 }
diff --git a/drivers/regex/mlx5/mlx5_regex.h b/drivers/regex/mlx5/mlx5_regex.h
index 329768980d..c9586ae714 100644
--- a/drivers/regex/mlx5/mlx5_regex.h
+++ b/drivers/regex/mlx5/mlx5_regex.h
@@ -119,8 +119,8 @@  int mlx5_devx_regex_register_read(struct ibv_context *ctx, int engine_id,
 				  uint32_t addr, uint32_t *data);
 int mlx5_devx_regex_database_stop(void *ctx, uint8_t engine);
 int mlx5_devx_regex_database_resume(void *ctx, uint8_t engine);
-int mlx5_devx_regex_database_program(void *ctx, uint8_t engine,
-				     uint32_t umem_id, uint64_t umem_offset);
+int mlx5_devx_regex_rules_program(void *ctx, uint8_t engine, uint32_t rof_mkey,
+				uint32_t rof_size, uint64_t db_mkey_offset);
 
 /* mlx5_regex_control.c */
 int mlx5_regex_qp_setup(struct rte_regexdev *dev, uint16_t qp_ind,
diff --git a/drivers/regex/mlx5/mlx5_regex_devx.c b/drivers/regex/mlx5/mlx5_regex_devx.c
index f66d7aa08b..d8515768c3 100644
--- a/drivers/regex/mlx5/mlx5_regex_devx.c
+++ b/drivers/regex/mlx5/mlx5_regex_devx.c
@@ -103,8 +103,8 @@  mlx5_devx_regex_database_resume(void *ctx, uint8_t engine)
 }
 
 int
-mlx5_devx_regex_database_program(void *ctx, uint8_t engine, uint32_t umem_id,
-				 uint64_t umem_offset)
+mlx5_devx_regex_rules_program(void *ctx, uint8_t engine, uint32_t rof_mkey,
+				uint32_t rof_size, uint64_t rof_mkey_va)
 {
 	uint32_t out[MLX5_ST_SZ_DW(set_regexp_params_out)] = {0};
 	uint32_t in[MLX5_ST_SZ_DW(set_regexp_params_in)] = {0};
@@ -112,14 +112,15 @@  mlx5_devx_regex_database_program(void *ctx, uint8_t engine, uint32_t umem_id,
 
 	MLX5_SET(set_regexp_params_in, in, opcode, MLX5_CMD_SET_REGEX_PARAMS);
 	MLX5_SET(set_regexp_params_in, in, engine_id, engine);
-	MLX5_SET(set_regexp_params_in, in, regexp_params.db_umem_id, umem_id);
-	MLX5_SET64(set_regexp_params_in, in, regexp_params.db_umem_offset,
-		   umem_offset);
-	MLX5_SET(set_regexp_params_in, in, field_select.db_umem_id, 1);
+	MLX5_SET(set_regexp_params_in, in, regexp_params.rof_mkey, rof_mkey);
+	MLX5_SET(set_regexp_params_in, in, regexp_params.rof_size, rof_size);
+	MLX5_SET64(set_regexp_params_in, in, regexp_params.rof_mkey_va,
+		   rof_mkey_va);
+	MLX5_SET(set_regexp_params_in, in, field_select.rof_mkey, 1);
 	ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
 					  sizeof(out));
 	if (ret) {
-		DRV_LOG(ERR, "Database program failed %d", ret);
+		DRV_LOG(ERR, "Rules program failed %d", ret);
 		rte_errno = errno;
 		return -errno;
 	}
diff --git a/drivers/regex/mlx5/mlx5_rxp.c b/drivers/regex/mlx5/mlx5_rxp.c
index 5afdcb35cc..79f063a127 100644
--- a/drivers/regex/mlx5/mlx5_rxp.c
+++ b/drivers/regex/mlx5/mlx5_rxp.c
@@ -33,8 +33,6 @@  rxp_poll_csr_for_value(struct ibv_context *ctx, uint32_t *value,
 		       uint32_t address, uint32_t expected_value,
 		       uint32_t expected_mask, uint32_t timeout_ms, uint8_t id);
 static int
-mlnx_set_database(struct mlx5_regex_priv *priv, uint8_t id, uint8_t db_to_use);
-static int
 mlnx_resume_database(struct mlx5_regex_priv *priv, uint8_t id);
 static int
 mlnx_update_database(struct mlx5_regex_priv *priv, uint8_t id);
@@ -488,11 +486,6 @@  rxp_program_rof(struct mlx5_regex_priv *priv, const char *buf, uint32_t len,
 		}
 
 	}
-	ret = mlnx_set_database(priv, id, db_free);
-	if (ret < 0) {
-		DRV_LOG(ERR, "Failed to register db memory!");
-		goto parse_error;
-	}
 	rte_free(tmp);
 	return 0;
 parse_error:
@@ -500,26 +493,6 @@  rxp_program_rof(struct mlx5_regex_priv *priv, const char *buf, uint32_t len,
 	return ret;
 }
 
-static int
-mlnx_set_database(struct mlx5_regex_priv *priv, uint8_t id, uint8_t db_to_use)
-{
-	int ret;
-	uint32_t umem_id;
-
-	ret = mlx5_devx_regex_database_stop(priv->ctx, id);
-	if (ret < 0) {
-		DRV_LOG(ERR, "stop engine failed!");
-		return ret;
-	}
-	umem_id = mlx5_os_get_umem_id(priv->db[db_to_use].umem.umem);
-	ret = mlx5_devx_regex_database_program(priv->ctx, id, umem_id, 0);
-	if (ret < 0) {
-		DRV_LOG(ERR, "program db failed!");
-		return ret;
-	}
-	return 0;
-}
-
 static int
 mlnx_resume_database(struct mlx5_regex_priv *priv, uint8_t id)
 {