common/mlx5: update regex DevX commands
authorAdy Agbarih <adypodoman@gmail.com>
Fri, 22 Oct 2021 15:45:53 +0000 (15:45 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 3 Nov 2021 22:14:29 +0000 (23:14 +0100)
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>
drivers/common/mlx5/mlx5_prm.h
drivers/regex/mlx5/mlx5_regex.c
drivers/regex/mlx5/mlx5_regex.h
drivers/regex/mlx5/mlx5_regex_devx.c
drivers/regex/mlx5/mlx5_rxp.c

index 8b0f2f1..fb75f2d 100644 (file)
@@ -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 {
index 856e08d..4e5e47f 100644 (file)
@@ -53,12 +53,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->cdev->ctx, i);
 
        return 0;
 }
index e4d1742..16d8693 100644 (file)
@@ -94,8 +94,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,
index f66d7aa..d851576 100644 (file)
@@ -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;
        }
index 995e02f..2898294 100644 (file)
@@ -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 @@ parse_error:
        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->cdev->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->cdev->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)
 {