1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
9 #include <mlx5_devx_cmds.h>
12 #include "mlx5_regex.h"
13 #include "mlx5_regex_utils.h"
16 mlx5_devx_regex_register_write(struct ibv_context *ctx, int engine_id,
17 uint32_t addr, uint32_t data)
19 uint32_t out[MLX5_ST_SZ_DW(set_regexp_register_out)] = {0};
20 uint32_t in[MLX5_ST_SZ_DW(set_regexp_register_in)] = {0};
23 MLX5_SET(set_regexp_register_in, in, opcode,
24 MLX5_CMD_SET_REGEX_REGISTERS);
25 MLX5_SET(set_regexp_register_in, in, engine_id, engine_id);
26 MLX5_SET(set_regexp_register_in, in, register_address, addr);
27 MLX5_SET(set_regexp_register_in, in, register_data, data);
29 ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
32 DRV_LOG(ERR, "Set regexp register failed %d", ret);
40 mlx5_devx_regex_register_read(struct ibv_context *ctx, int engine_id,
41 uint32_t addr, uint32_t *data)
43 uint32_t out[MLX5_ST_SZ_DW(query_regexp_register_out)] = {0};
44 uint32_t in[MLX5_ST_SZ_DW(query_regexp_register_in)] = {0};
47 MLX5_SET(query_regexp_register_in, in, opcode,
48 MLX5_CMD_QUERY_REGEX_REGISTERS);
49 MLX5_SET(query_regexp_register_in, in, engine_id, engine_id);
50 MLX5_SET(query_regexp_register_in, in, register_address, addr);
52 ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
55 DRV_LOG(ERR, "Query regexp register failed %d", ret);
59 *data = MLX5_GET(query_regexp_register_out, out, register_data);
64 mlx5_devx_regex_database_stop(void *ctx, uint8_t engine)
66 uint32_t out[MLX5_ST_SZ_DW(set_regexp_params_out)] = {0};
67 uint32_t in[MLX5_ST_SZ_DW(set_regexp_params_in)] = {0};
70 MLX5_SET(set_regexp_params_in, in, opcode, MLX5_CMD_SET_REGEX_PARAMS);
71 MLX5_SET(set_regexp_params_in, in, engine_id, engine);
72 MLX5_SET(set_regexp_params_in, in, regexp_params.stop_engine, 1);
73 MLX5_SET(set_regexp_params_in, in, field_select.stop_engine, 1);
74 ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
77 DRV_LOG(ERR, "Database stop failed %d", ret);
85 mlx5_devx_regex_database_resume(void *ctx, uint8_t engine)
87 uint32_t out[MLX5_ST_SZ_DW(set_regexp_params_out)] = {0};
88 uint32_t in[MLX5_ST_SZ_DW(set_regexp_params_in)] = {0};
91 MLX5_SET(set_regexp_params_in, in, opcode, MLX5_CMD_SET_REGEX_PARAMS);
92 MLX5_SET(set_regexp_params_in, in, engine_id, engine);
93 MLX5_SET(set_regexp_params_in, in, regexp_params.stop_engine, 0);
94 MLX5_SET(set_regexp_params_in, in, field_select.stop_engine, 1);
95 ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
98 DRV_LOG(ERR, "Database start failed %d", ret);
106 mlx5_devx_regex_database_program(void *ctx, uint8_t engine, uint32_t umem_id,
107 uint64_t umem_offset)
109 uint32_t out[MLX5_ST_SZ_DW(set_regexp_params_out)] = {0};
110 uint32_t in[MLX5_ST_SZ_DW(set_regexp_params_in)] = {0};
113 MLX5_SET(set_regexp_params_in, in, opcode, MLX5_CMD_SET_REGEX_PARAMS);
114 MLX5_SET(set_regexp_params_in, in, engine_id, engine);
115 MLX5_SET(set_regexp_params_in, in, regexp_params.db_umem_id, umem_id);
116 MLX5_SET64(set_regexp_params_in, in, regexp_params.db_umem_offset,
118 MLX5_SET(set_regexp_params_in, in, field_select.db_umem_id, 1);
119 ret = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out,
122 DRV_LOG(ERR, "Database program failed %d", ret);