/* mlx5_regex_fastpath.c */
int mlx5_regexdev_setup_fastpath(struct mlx5_regex_priv *priv, uint32_t qp_id);
+void mlx5_regexdev_teardown_fastpath(struct mlx5_regex_priv *priv,
+ uint32_t qp_id);
uint16_t mlx5_regexdev_enqueue(struct rte_regexdev *dev, uint16_t qp_id,
struct rte_regex_ops **ops, uint16_t nb_ops);
uint16_t mlx5_regexdev_dequeue(struct rte_regexdev *dev, uint16_t qp_id,
ret = regex_ctrl_create_cq(priv, &qp->cq);
if (ret) {
DRV_LOG(ERR, "Can't create cq.");
- goto error;
+ goto err_cq;
}
for (i = 0; i < qp->nb_obj; i++) {
ret = regex_ctrl_create_sq(priv, qp, i, log_desc);
if (ret) {
DRV_LOG(ERR, "Can't create sq.");
- goto error;
+ goto err_sq;
}
}
- mlx5_regexdev_setup_fastpath(priv, qp_ind);
+ ret = mlx5_regexdev_setup_fastpath(priv, qp_ind);
+ if (ret) {
+ DRV_LOG(ERR, "Fail to setup fastpath.");
+ goto err_fp;
+ }
return 0;
-error:
- regex_ctrl_destroy_cq(priv, &qp->cq);
+err_fp:
for (i = 0; i < qp->nb_obj; i++)
ret = regex_ctrl_destroy_sq(priv, qp, i);
- return -rte_errno;
-
+err_sq:
+ regex_ctrl_destroy_cq(priv, &qp->cq);
+err_cq:
+ rte_free(qp->sqs);
+ return ret;
}
if (!qp->jobs)
return -ENOMEM;
err = setup_buffers(qp, priv->pd);
- if (err)
+ if (err) {
+ rte_free(qp->jobs);
return err;
+ }
setup_sqs(qp);
return 0;
}
+
+static void
+free_buffers(struct mlx5_regex_qp *qp)
+{
+ if (qp->metadata) {
+ mlx5_glue->dereg_mr(qp->metadata);
+ rte_free(qp->metadata->addr);
+ }
+ if (qp->inputs) {
+ mlx5_glue->dereg_mr(qp->inputs);
+ rte_free(qp->inputs->addr);
+ }
+ if (qp->outputs) {
+ mlx5_glue->dereg_mr(qp->outputs);
+ rte_free(qp->outputs->addr);
+ }
+}
+
+void
+mlx5_regexdev_teardown_fastpath(struct mlx5_regex_priv *priv, uint32_t qp_id)
+{
+ struct mlx5_regex_qp *qp = &priv->qps[qp_id];
+
+ if (qp) {
+ free_buffers(qp);
+ if (qp->jobs)
+ rte_free(qp->jobs);
+ }
+}