From: Francis Kelly <fkelly@nvidia.com>
To: <tmonjalon@nvidia.com>, Ori Kam <orika@nvidia.com>
Cc: <jamhunter@nvidia.com>, <aagbarih@nvidia.com>, <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 02/10] regex/mlx5: add cleanup code
Date: Fri, 22 Oct 2021 15:45:52 +0000 [thread overview]
Message-ID: <20211022154600.2180938-2-fkelly@nvidia.com> (raw)
In-Reply-To: <20211022154600.2180938-1-fkelly@nvidia.com>
From: Ori Kam <orika@nvidia.com>
When stopping the device we should release all
data allocated.
This commit add this cleanup logic.
Signed-off-by: Ori Kam <orika@nvidia.com>
---
drivers/regex/mlx5/mlx5_regex.c | 14 ++++++++++++++
drivers/regex/mlx5/mlx5_regex.h | 1 +
drivers/regex/mlx5/mlx5_regex_control.c | 20 ++++++++++++++++++++
drivers/regex/mlx5/mlx5_rxp.c | 4 ++--
4 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/drivers/regex/mlx5/mlx5_regex.c b/drivers/regex/mlx5/mlx5_regex.c
index 2124fd15f0..b7175ff8e9 100644
--- a/drivers/regex/mlx5/mlx5_regex.c
+++ b/drivers/regex/mlx5/mlx5_regex.c
@@ -48,6 +48,20 @@ mlx5_regex_start(struct rte_regexdev *dev __rte_unused)
int
mlx5_regex_stop(struct rte_regexdev *dev __rte_unused)
{
+ struct mlx5_regex_priv *priv = dev->data->dev_private;
+ uint32_t i;
+
+ mlx5_regex_clean_ctrl(dev);
+ rte_free(priv->qps);
+ priv->qps = NULL;
+
+ for (i = 0; i < (priv->nb_engines + MLX5_RXP_EM_COUNT); i++) {
+ if (priv->db[i].umem.umem)
+ mlx5_glue->devx_umem_dereg(priv->db[i].umem.umem);
+ rte_free(priv->db[i].ptr);
+ priv->db[i].ptr = NULL;
+ }
+
return 0;
}
diff --git a/drivers/regex/mlx5/mlx5_regex.h b/drivers/regex/mlx5/mlx5_regex.h
index 2242d250a3..329768980d 100644
--- a/drivers/regex/mlx5/mlx5_regex.h
+++ b/drivers/regex/mlx5/mlx5_regex.h
@@ -125,6 +125,7 @@ int mlx5_devx_regex_database_program(void *ctx, uint8_t engine,
/* mlx5_regex_control.c */
int mlx5_regex_qp_setup(struct rte_regexdev *dev, uint16_t qp_ind,
const struct rte_regexdev_qp_conf *cfg);
+void mlx5_regex_clean_ctrl(struct rte_regexdev *dev);
/* mlx5_regex_fastpath.c */
int mlx5_regexdev_setup_fastpath(struct mlx5_regex_priv *priv, uint32_t qp_id);
diff --git a/drivers/regex/mlx5/mlx5_regex_control.c b/drivers/regex/mlx5/mlx5_regex_control.c
index 572ecc6d86..1783df923c 100644
--- a/drivers/regex/mlx5/mlx5_regex_control.c
+++ b/drivers/regex/mlx5/mlx5_regex_control.c
@@ -271,3 +271,23 @@ mlx5_regex_qp_setup(struct rte_regexdev *dev, uint16_t qp_ind,
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];
+ 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);
+ }
+}
diff --git a/drivers/regex/mlx5/mlx5_rxp.c b/drivers/regex/mlx5/mlx5_rxp.c
index 380037e24c..5afdcb35cc 100644
--- a/drivers/regex/mlx5/mlx5_rxp.c
+++ b/drivers/regex/mlx5/mlx5_rxp.c
@@ -776,10 +776,10 @@ rxp_db_setup(struct mlx5_regex_priv *priv)
return 0;
tidyup_error:
for (i = 0; i < (priv->nb_engines + MLX5_RXP_EM_COUNT); i++) {
- if (priv->db[i].ptr)
- rte_free(priv->db[i].ptr);
if (priv->db[i].umem.umem)
mlx5_glue->devx_umem_dereg(priv->db[i].umem.umem);
+ rte_free(priv->db[i].ptr);
+ priv->db[i].ptr = NULL;
}
return -ret;
}
--
2.25.1
next prev parent reply other threads:[~2021-10-22 15:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-22 15:45 [dpdk-dev] [PATCH 01/10] common/mlx5: update PRM definitions for regex availability Francis Kelly
2021-10-22 15:45 ` Francis Kelly [this message]
2021-10-22 15:45 ` [dpdk-dev] [PATCH 03/10] common/mlx5: update regex DevX commands Francis Kelly
2021-10-24 13:39 ` Ori Kam
2021-10-22 15:45 ` [dpdk-dev] [PATCH 04/10] regex/mlx5: remove regexp register read/write Francis Kelly
2021-10-24 13:40 ` Ori Kam
2021-10-22 15:45 ` [dpdk-dev] [PATCH 05/10] regex/mlx5: move RXP to CrSpace Francis Kelly
2021-10-24 13:41 ` Ori Kam
2021-10-22 15:45 ` [dpdk-dev] [PATCH 06/10] regex/mlx5: remove start/stop engine API Francis Kelly
2021-10-22 15:45 ` [dpdk-dev] [PATCH 07/10] regex/mlx5: removed redundant rxp csr file Francis Kelly
2021-10-24 13:42 ` Ori Kam
2021-10-22 15:45 ` [dpdk-dev] [PATCH 08/10] regex/mlx5: fix uninitialized QP destroy Francis Kelly
2021-10-24 13:42 ` Ori Kam
2021-10-22 15:45 ` [dpdk-dev] [PATCH 09/10] regex/mlx5: prevent QP double setup Francis Kelly
2021-10-24 13:43 ` Ori Kam
2021-10-22 15:46 ` [dpdk-dev] [PATCH 10/10] doc: updated release notes and mlx5 file Francis Kelly
2021-10-24 13:43 ` Ori Kam
2021-11-03 22:13 ` Thomas Monjalon
2021-10-24 13:38 ` [dpdk-dev] [PATCH 01/10] common/mlx5: update PRM definitions for regex availability Ori Kam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211022154600.2180938-2-fkelly@nvidia.com \
--to=fkelly@nvidia.com \
--cc=aagbarih@nvidia.com \
--cc=dev@dpdk.org \
--cc=jamhunter@nvidia.com \
--cc=orika@nvidia.com \
--cc=tmonjalon@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).