#include "mlx5_regex.h"
#include "mlx5_regex_utils.h"
-#include "mlx5_rxp_csrs.h"
#include "mlx5_rxp.h"
#define MLX5_REGEX_NUM_WQE_PER_PAGE (4096/64)
regex_ctrl_create_cq(struct mlx5_regex_priv *priv, struct mlx5_regex_cq *cq)
{
struct mlx5_devx_cq_attr attr = {
- .uar_page_id = priv->uar->page_id,
+ .uar_page_id = mlx5_os_get_devx_uar_page_id(priv->uar.obj),
};
int ret;
cq->ci = 0;
- ret = mlx5_devx_cq_create(priv->ctx, &cq->cq_obj, cq->log_nb_desc,
+ ret = mlx5_devx_cq_create(priv->cdev->ctx, &cq->cq_obj, cq->log_nb_desc,
&attr, SOCKET_ID_ANY);
if (ret) {
DRV_LOG(ERR, "Can't create CQ object.");
#ifdef HAVE_IBV_FLOW_DV_SUPPORT
struct mlx5_devx_qp_attr attr = {
.cqn = qp->cq.cq_obj.cq->id,
- .uar_index = priv->uar->page_id,
- .ts_format = mlx5_ts_format_conv(priv->qp_ts_format),
+ .uar_index = mlx5_os_get_devx_uar_page_id(priv->uar.obj),
+ .pd = priv->cdev->pdn,
+ .ts_format = mlx5_ts_format_conv
+ (priv->cdev->config.hca_attr.qp_ts_format),
.user_index = q_ind,
};
struct mlx5_regex_hw_qp *qp_obj = &qp->qps[q_ind];
- uint32_t pd_num = 0;
int ret;
qp_obj->log_nb_desc = log_nb_desc;
qp_obj->qpn = q_ind;
qp_obj->ci = 0;
qp_obj->pi = 0;
- ret = regex_get_pdn(priv->pd, &pd_num);
- if (ret)
- return ret;
- attr.pd = pd_num;
- attr.rq_size = 0;
- attr.sq_size = RTE_BIT32(MLX5_REGEX_WQE_LOG_NUM(priv->has_umr,
+ attr.num_of_receive_wqes = 0;
+ attr.num_of_send_wqbbs = RTE_BIT32(MLX5_REGEX_WQE_LOG_NUM(priv->has_umr,
log_nb_desc));
attr.mmo = priv->mmo_regex_qp_cap;
- ret = mlx5_devx_qp_create(priv->ctx, &qp_obj->qp_obj,
- MLX5_REGEX_WQE_LOG_NUM(priv->has_umr, log_nb_desc),
- &attr, SOCKET_ID_ANY);
+ ret = mlx5_devx_qp_create(priv->cdev->ctx, &qp_obj->qp_obj,
+ attr.num_of_send_wqbbs * MLX5_WQE_SIZE, &attr,
+ SOCKET_ID_ANY);
if (ret) {
DRV_LOG(ERR, "Can't create QP object.");
rte_errno = ENOMEM;
uint16_t log_desc;
qp = &priv->qps[qp_ind];
+ if (qp->jobs) {
+ DRV_LOG(ERR, "Attempting to setup QP a second time.");
+ rte_errno = EINVAL;
+ return -rte_errno;
+ }
+
qp->flags = cfg->qp_conf_flags;
log_desc = rte_log2_u32(cfg->nb_desc);
/*
nb_sq_config++;
}
- /* Save pointer of global generation number to check memory event. */
- qp->mr_ctrl.dev_gen_ptr = &priv->mr_scache.dev_gen;
- ret = mlx5_mr_btree_init(&qp->mr_ctrl.cache_bh, MLX5_MR_BTREE_CACHE_N,
- rte_socket_id());
+ ret = mlx5_mr_ctrl_init(&qp->mr_ctrl, &priv->cdev->mr_scache.dev_gen,
+ rte_socket_id());
if (ret) {
DRV_LOG(ERR, "Error setting up mr btree");
goto err_btree;
rte_free(qp->qps);
return ret;
}
+
+void
+mlx5_regex_clean_ctrl(struct rte_regexdev *dev)
+{
+ struct mlx5_regex_priv *priv = dev->data->dev_private;
+ struct mlx5_regex_qp *qp;
+ int qp_ind;
+ int i;
+
+ if (!priv->qps)
+ return;
+ for (qp_ind = 0; qp_ind < priv->nb_queues; qp_ind++) {
+ qp = &priv->qps[qp_ind];
+ /* Check if mlx5_regex_qp_setup() was called for this QP */
+ if (!qp->jobs)
+ continue;
+ mlx5_regexdev_teardown_fastpath(priv, qp_ind);
+ mlx5_mr_btree_free(&qp->mr_ctrl.cache_bh);
+ for (i = 0; i < qp->nb_obj; i++)
+ regex_ctrl_destroy_hw_qp(qp, i);
+ regex_ctrl_destroy_cq(&qp->cq);
+ }
+}