[07/20] common/mlx5: add rxp database set cmd

Message ID 1593941027-86651-8-git-send-email-orika@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series add Mellanox RegEx PMD |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ori Kam July 5, 2020, 9:23 a.m. UTC
  This commit adds the database set command for the RXP engine.

Signed-off-by: Ori Kam <orika@mellanox.com>
---
 drivers/common/mlx5/mlx5_devx_cmds.c            | 104 ++++++++++++++++++++++++
 drivers/common/mlx5/mlx5_devx_cmds.h            |   8 +-
 drivers/common/mlx5/rte_common_mlx5_version.map |   3 +
 3 files changed, 114 insertions(+), 1 deletion(-)
  

Comments

Slava Ovsiienko July 8, 2020, 7:32 a.m. UTC | #1
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

> -----Original Message-----
> From: Ori Kam <orika@mellanox.com>
> Sent: Sunday, July 5, 2020 12:24
> To: jerinj@marvell.com; xiang.w.wang@intel.com; Matan Azrad
> <matan@mellanox.com>; Slava Ovsiienko <viacheslavo@mellanox.com>;
> Shahaf Shuler <shahafs@mellanox.com>; Ray Kinsella <mdr@ashroe.eu>;
> Neil Horman <nhorman@tuxdriver.com>
> Cc: guyk@marvell.com; dev@dpdk.org; pbhagavatula@marvell.com;
> hemant.agrawal@nxp.com; Opher Reviv <opher@mellanox.com>; Alex
> Rosenbaum <alexr@mellanox.com>; dovrat@marvell.com;
> pkapoor@marvell.com; nipun.gupta@nxp.com;
> bruce.richardson@intel.com; yang.a.hong@intel.com;
> harry.chang@intel.com; gu.jian1@zte.com.cn;
> shanjiangh@chinatelecom.cn; zhangy.yun@chinatelecom.cn;
> lixingfu@huachentel.com; wushuai@inspur.com; yuyingxia@yxlink.com;
> fanchenggang@sunyainfo.com; davidfgao@tencent.com;
> liuzhong1@chinaunicom.cn; zhaoyong11@huawei.com; oc@yunify.com;
> jim@netgate.com; hongjun.ni@intel.com; deri@ntop.org;
> fc@napatech.com; arthur.su@lionic.com; Thomas Monjalon
> <thomas@monjalon.net>; Ori Kam <orika@mellanox.com>; Raslan
> Darawsheh <rasland@mellanox.com>
> Subject: [PATCH 07/20] common/mlx5: add rxp database set cmd
> 
> This commit adds the database set command for the RXP engine.
> 
> Signed-off-by: Ori Kam <orika@mellanox.com>
> ---
>  drivers/common/mlx5/mlx5_devx_cmds.c            | 104
> ++++++++++++++++++++++++
>  drivers/common/mlx5/mlx5_devx_cmds.h            |   8 +-
>  drivers/common/mlx5/rte_common_mlx5_version.map |   3 +
>  3 files changed, 114 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c
> b/drivers/common/mlx5/mlx5_devx_cmds.c
> index 74df035..f8760e6 100644
> --- a/drivers/common/mlx5/mlx5_devx_cmds.c
> +++ b/drivers/common/mlx5/mlx5_devx_cmds.c
> @@ -1616,3 +1616,107 @@ struct mlx5_devx_obj *
>  					invalid_buffer);
>  	return ret;
>  }
> +
> +/**
> + * Issue the RXP stop database command.
> + *
> + * @param[in] ctx
> + *   Context returned from mlx5 open_device() glue function.
> + * @param[in] engine
> + *   The engine to stop.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +int
> +mlx5_devx_regex_database_stop(void *ctx, uint8_t engine) {
> +	uint32_t out[DEVX_ST_SZ_DW(set_regexp_params_out)] = {};
> +	uint32_t in[DEVX_ST_SZ_DW(set_regexp_params_in)] = {};
> +	int ret;
> +
> +	DEVX_SET(set_regexp_params_in, in, opcode,
> MLX5_CMD_SET_REGEX_PARAMS);
> +	DEVX_SET(set_regexp_params_in, in, engine_id, engine);
> +	DEVX_SET(set_regexp_params_in, in, regexp_params.stop_engine,
> 1);
> +	DEVX_SET(set_regexp_params_in, in, field_select.stop_engine, 1);
> +	ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
> +					  sizeof(out));
> +	if (ret) {
> +		DRV_LOG(ERR, "Database stop failed %d", ret);
> +		rte_errno = errno;
> +		return -errno;
> +	}
> +	return 0;
> +}
> +
> +/**
> + * Issue the RXP resume database command.
> + *
> + * @param[in] ctx
> + *   Context returned from mlx5 open_device() glue function.
> + * @param[in] engine
> + *   The engine to start.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +int
> +mlx5_devx_regex_database_resume(void *ctx, uint8_t engine) {
> +	uint32_t out[DEVX_ST_SZ_DW(set_regexp_params_out)] = {};
> +	uint32_t in[DEVX_ST_SZ_DW(set_regexp_params_in)] = {};
> +	int ret;
> +
> +	DEVX_SET(set_regexp_params_in, in, opcode,
> MLX5_CMD_SET_REGEX_PARAMS);
> +	DEVX_SET(set_regexp_params_in, in, engine_id, engine);
> +	DEVX_SET(set_regexp_params_in, in, regexp_params.stop_engine,
> 0);
> +	DEVX_SET(set_regexp_params_in, in, field_select.stop_engine, 1);
> +	ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
> +					  sizeof(out));
> +	if (ret) {
> +		DRV_LOG(ERR, "Database start failed %d", ret);
> +		rte_errno = errno;
> +		return -errno;
> +	}
> +	return 0;
> +}
> +
> +/**
> + * Issue the RXP program database command.
> + *
> + * @param[in] ctx
> + *   Context returned from mlx5 open_device() glue function.
> + * @param[in] engine
> + *   The engine to program.
> + * @param[in] umem_id
> + *   The umem id to use.
> + * @param[in] umem_offset
> + *   The offset in the umem to start copying from.
> + *
> + * @return
> + *   0 on success, a negative errno value otherwise and rte_errno is set.
> + */
> +int
> +mlx5_devx_regex_database_program(void *ctx, uint8_t engine, uint32_t
> umem_id,
> +				 uint64_t umem_offset)
> +{
> +	uint32_t out[DEVX_ST_SZ_DW(set_regexp_params_out)] = {};
> +	uint32_t in[DEVX_ST_SZ_DW(set_regexp_params_in)] = {};
> +	int ret;
> +
> +	DEVX_SET(set_regexp_params_in, in, opcode,
> MLX5_CMD_SET_REGEX_PARAMS);
> +	DEVX_SET(set_regexp_params_in, in, engine_id, engine);
> +	DEVX_SET(set_regexp_params_in, in, regexp_params.db_umem_id,
> umem_id);
> +	DEVX_SET64(set_regexp_params_in, in,
> regexp_params.db_umem_offset,
> +		   umem_offset);
> +	DEVX_SET(set_regexp_params_in, in, field_select.db_umem_id, 1);
> +	ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
> +					  sizeof(out));
> +	if (ret) {
> +		DRV_LOG(ERR, "Database program failed %d", ret);
> +		rte_errno = errno;
> +		return -errno;
> +	}
> +	return 0;
> +}
> +
> diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h
> b/drivers/common/mlx5/mlx5_devx_cmds.h
> index bb14ca5..655e31f 100644
> --- a/drivers/common/mlx5/mlx5_devx_cmds.h
> +++ b/drivers/common/mlx5/mlx5_devx_cmds.h
> @@ -401,5 +401,11 @@ int mlx5_devx_cmd_modify_rqt(struct
> mlx5_devx_obj *rqt,  __rte_internal  int
> mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj
> *couners_obj,
>  				  struct mlx5_devx_virtio_q_couners_attr
> *attr);
> -
> +__rte_internal
> +int mlx5_devx_regex_database_stop(void *ctx, uint8_t engine);
> +__rte_internal int mlx5_devx_regex_database_resume(void *ctx, uint8_t
> +engine); __rte_internal int mlx5_devx_regex_database_program(void *ctx,
> +uint8_t engine,
> +				     uint32_t umem_id, uint64_t
> umem_offset);
>  #endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
> diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map
> b/drivers/common/mlx5/rte_common_mlx5_version.map
> index ae57ebd..6054d39 100644
> --- a/drivers/common/mlx5/rte_common_mlx5_version.map
> +++ b/drivers/common/mlx5/rte_common_mlx5_version.map
> @@ -35,6 +35,9 @@ INTERNAL {
>  	mlx5_devx_cmd_query_virtio_q_counters;
>  	mlx5_devx_cmd_query_virtq;
>  	mlx5_devx_get_out_command_status;
> +	mlx5_devx_regex_database_program;
> +	mlx5_devx_regex_database_resume;
> +	mlx5_devx_regex_database_stop;
> 
>  	mlx5_get_ifname_sysfs;
>  	mlx5_get_dbr;
> --
> 1.8.3.1
  

Patch

diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c
index 74df035..f8760e6 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.c
+++ b/drivers/common/mlx5/mlx5_devx_cmds.c
@@ -1616,3 +1616,107 @@  struct mlx5_devx_obj *
 					invalid_buffer);
 	return ret;
 }
+
+/**
+ * Issue the RXP stop database command.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ * @param[in] engine
+ *   The engine to stop.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_regex_database_stop(void *ctx, uint8_t engine)
+{
+	uint32_t out[DEVX_ST_SZ_DW(set_regexp_params_out)] = {};
+	uint32_t in[DEVX_ST_SZ_DW(set_regexp_params_in)] = {};
+	int ret;
+
+	DEVX_SET(set_regexp_params_in, in, opcode, MLX5_CMD_SET_REGEX_PARAMS);
+	DEVX_SET(set_regexp_params_in, in, engine_id, engine);
+	DEVX_SET(set_regexp_params_in, in, regexp_params.stop_engine, 1);
+	DEVX_SET(set_regexp_params_in, in, field_select.stop_engine, 1);
+	ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
+					  sizeof(out));
+	if (ret) {
+		DRV_LOG(ERR, "Database stop failed %d", ret);
+		rte_errno = errno;
+		return -errno;
+	}
+	return 0;
+}
+
+/**
+ * Issue the RXP resume database command.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ * @param[in] engine
+ *   The engine to start.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_regex_database_resume(void *ctx, uint8_t engine)
+{
+	uint32_t out[DEVX_ST_SZ_DW(set_regexp_params_out)] = {};
+	uint32_t in[DEVX_ST_SZ_DW(set_regexp_params_in)] = {};
+	int ret;
+
+	DEVX_SET(set_regexp_params_in, in, opcode, MLX5_CMD_SET_REGEX_PARAMS);
+	DEVX_SET(set_regexp_params_in, in, engine_id, engine);
+	DEVX_SET(set_regexp_params_in, in, regexp_params.stop_engine, 0);
+	DEVX_SET(set_regexp_params_in, in, field_select.stop_engine, 1);
+	ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
+					  sizeof(out));
+	if (ret) {
+		DRV_LOG(ERR, "Database start failed %d", ret);
+		rte_errno = errno;
+		return -errno;
+	}
+	return 0;
+}
+
+/**
+ * Issue the RXP program database command.
+ *
+ * @param[in] ctx
+ *   Context returned from mlx5 open_device() glue function.
+ * @param[in] engine
+ *   The engine to program.
+ * @param[in] umem_id
+ *   The umem id to use.
+ * @param[in] umem_offset
+ *   The offset in the umem to start copying from.
+ *
+ * @return
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
+ */
+int
+mlx5_devx_regex_database_program(void *ctx, uint8_t engine, uint32_t umem_id,
+				 uint64_t umem_offset)
+{
+	uint32_t out[DEVX_ST_SZ_DW(set_regexp_params_out)] = {};
+	uint32_t in[DEVX_ST_SZ_DW(set_regexp_params_in)] = {};
+	int ret;
+
+	DEVX_SET(set_regexp_params_in, in, opcode, MLX5_CMD_SET_REGEX_PARAMS);
+	DEVX_SET(set_regexp_params_in, in, engine_id, engine);
+	DEVX_SET(set_regexp_params_in, in, regexp_params.db_umem_id, umem_id);
+	DEVX_SET64(set_regexp_params_in, in, regexp_params.db_umem_offset,
+		   umem_offset);
+	DEVX_SET(set_regexp_params_in, in, field_select.db_umem_id, 1);
+	ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
+					  sizeof(out));
+	if (ret) {
+		DRV_LOG(ERR, "Database program failed %d", ret);
+		rte_errno = errno;
+		return -errno;
+	}
+	return 0;
+}
+
diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h
index bb14ca5..655e31f 100644
--- a/drivers/common/mlx5/mlx5_devx_cmds.h
+++ b/drivers/common/mlx5/mlx5_devx_cmds.h
@@ -401,5 +401,11 @@  int mlx5_devx_cmd_modify_rqt(struct mlx5_devx_obj *rqt,
 __rte_internal
 int mlx5_devx_cmd_query_virtio_q_counters(struct mlx5_devx_obj *couners_obj,
 				  struct mlx5_devx_virtio_q_couners_attr *attr);
-
+__rte_internal
+int mlx5_devx_regex_database_stop(void *ctx, uint8_t engine);
+__rte_internal
+int mlx5_devx_regex_database_resume(void *ctx, uint8_t engine);
+__rte_internal
+int mlx5_devx_regex_database_program(void *ctx, uint8_t engine,
+				     uint32_t umem_id, uint64_t umem_offset);
 #endif /* RTE_PMD_MLX5_DEVX_CMDS_H_ */
diff --git a/drivers/common/mlx5/rte_common_mlx5_version.map b/drivers/common/mlx5/rte_common_mlx5_version.map
index ae57ebd..6054d39 100644
--- a/drivers/common/mlx5/rte_common_mlx5_version.map
+++ b/drivers/common/mlx5/rte_common_mlx5_version.map
@@ -35,6 +35,9 @@  INTERNAL {
 	mlx5_devx_cmd_query_virtio_q_counters;
 	mlx5_devx_cmd_query_virtq;
 	mlx5_devx_get_out_command_status;
+	mlx5_devx_regex_database_program;
+	mlx5_devx_regex_database_resume;
+	mlx5_devx_regex_database_stop;
 
 	mlx5_get_ifname_sysfs;
 	mlx5_get_dbr;