1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
8 #include <rte_regexdev.h>
10 #include <infiniband/verbs.h>
11 #include <infiniband/mlx5dv.h>
13 #include <mlx5_common.h>
14 #include <mlx5_common_mr.h>
15 #include <mlx5_common_devx.h>
18 #include "mlx5_regex_utils.h"
20 struct mlx5_regex_hw_qp {
21 uint16_t log_nb_desc; /* Log 2 number of desc for this object. */
22 struct mlx5_devx_qp qp_obj; /* The QP DevX object. */
28 struct mlx5_regex_cq {
29 uint32_t log_nb_desc; /* Log 2 number of desc for this object. */
30 struct mlx5_devx_cq cq_obj; /* The CQ DevX object. */
34 struct mlx5_regex_qp {
35 uint32_t flags; /* QP user flags. */
36 uint32_t nb_desc; /* Total number of desc for this qp. */
37 struct mlx5_regex_hw_qp *qps; /* Pointer to qp array. */
38 uint16_t nb_obj; /* Number of qp objects. */
39 struct mlx5_regex_cq cq; /* CQ struct. */
41 struct mlx5_regex_job *jobs;
42 struct ibv_mr *metadata;
43 struct ibv_mr *outputs;
44 struct ibv_mr *imkey_addr; /* Indirect mkey array region. */
46 struct mlx5_mr_ctrl mr_ctrl;
49 struct mlx5_regex_priv {
50 TAILQ_ENTRY(mlx5_regex_priv) next;
51 struct mlx5_common_device *cdev; /* Backend mlx5 device. */
52 struct rte_regexdev *regexdev; /* Pointer to the RegEx dev. */
53 uint16_t nb_queues; /* Number of queues. */
54 struct mlx5_regex_qp *qps; /* Pointer to the qp array. */
55 uint16_t nb_max_matches; /* Max number of matches. */
56 enum mlx5_rxp_program_mode prog_mode;
57 uint32_t nb_engines; /* Number of RegEx engines. */
58 struct mlx5dv_devx_uar *uar; /* UAR object. */
59 uint8_t is_bf2; /* The device is BF2 device. */
60 uint8_t has_umr; /* The device supports UMR. */
61 uint32_t mmo_regex_qp_cap:1;
62 uint32_t mmo_regex_sq_cap:1;
66 int mlx5_regex_start(struct rte_regexdev *dev);
67 int mlx5_regex_stop(struct rte_regexdev *dev);
68 int mlx5_regex_close(struct rte_regexdev *dev);
71 int mlx5_regex_info_get(struct rte_regexdev *dev,
72 struct rte_regexdev_info *info);
73 int mlx5_regex_configure(struct rte_regexdev *dev,
74 const struct rte_regexdev_config *cfg);
75 int mlx5_regex_rules_db_import(struct rte_regexdev *dev,
76 const char *rule_db, uint32_t rule_db_len);
78 /* mlx5_regex_devx.c */
79 int mlx5_devx_regex_database_stop(void *ctx, uint8_t engine);
80 int mlx5_devx_regex_database_resume(void *ctx, uint8_t engine);
81 int mlx5_devx_regex_rules_program(void *ctx, uint8_t engine, uint32_t rof_mkey,
82 uint32_t rof_size, uint64_t db_mkey_offset);
84 /* mlx5_regex_control.c */
85 int mlx5_regex_qp_setup(struct rte_regexdev *dev, uint16_t qp_ind,
86 const struct rte_regexdev_qp_conf *cfg);
87 void mlx5_regex_clean_ctrl(struct rte_regexdev *dev);
89 /* mlx5_regex_fastpath.c */
90 int mlx5_regexdev_setup_fastpath(struct mlx5_regex_priv *priv, uint32_t qp_id);
91 void mlx5_regexdev_teardown_fastpath(struct mlx5_regex_priv *priv,
93 uint16_t mlx5_regexdev_enqueue(struct rte_regexdev *dev, uint16_t qp_id,
94 struct rte_regex_ops **ops, uint16_t nb_ops);
95 uint16_t mlx5_regexdev_dequeue(struct rte_regexdev *dev, uint16_t qp_id,
96 struct rte_regex_ops **ops, uint16_t nb_ops);
97 uint16_t mlx5_regexdev_enqueue_gga(struct rte_regexdev *dev, uint16_t qp_id,
98 struct rte_regex_ops **ops, uint16_t nb_ops);
99 #endif /* MLX5_REGEX_H */