All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bing Zhao <bingz@nvidia.com>
To: <dev@dpdk.org>
Cc: Dariusz Sosnowski <dsosnowski@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
	Suanming Mou <suanmingm@nvidia.com>,
	Matan Azrad <matan@nvidia.com>, Li Zhang <lizh@nvidia.com>,
	Shun Hao <shunh@nvidia.com>, Michael Baum <michaelba@nvidia.com>,
	<stable@dpdk.org>
Subject: [PATCH] net/mlx5: destroy DR domains after ASO close
Date: Wed, 11 Nov 2026 15:34:52 +0200	[thread overview]
Message-ID: <20261111133456.49554-1-bingz@nvidia.com> (raw)

ASO age, meter and connection tracking actions are created in the
shared DR domains and released only when the ASO management is
closed. That close runs in mlx5_free_shared_dev_ctx(), while the
domains are destroyed earlier in mlx5_os_free_shared_dr(). Freeing
a domain-bound action after the domain is gone crashes on close.

The domains belong to the shared context, as the ASO managers do.
Destroy them in mlx5_free_shared_dev_ctx() after the ASO managers.
One port close then cannot drop them while another port still uses
the shared context.

Fixes: f935ed4b645a ("net/mlx5: support flow hit action for aging")
Fixes: c99b4f8bc2f1 ("net/mlx5: support ASO meter action")
Fixes: ce12974cce72 ("net/mlx5: fix ASO CT object release")
Cc: stable@dpdk.org

Suggested-by: Matan Azrad <matan@nvidia.com>
Signed-off-by: Bing Zhao <bingz@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_os.c   | 51 ++++++++++++++++--------------
 drivers/net/mlx5/mlx5.c            |  6 ++++
 drivers/net/mlx5/mlx5.h            |  1 +
 drivers/net/mlx5/windows/mlx5_os.c | 13 ++++++++
 4 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 4c35737292..fb4a5a6fa2 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -689,18 +689,7 @@ mlx5_alloc_shared_dr(struct rte_eth_dev *eth_dev)
 	return 0;
 error:
 	/* Rollback the created objects. */
-	if (sh->rx_domain) {
-		mlx5_glue->dr_destroy_domain(sh->rx_domain);
-		sh->rx_domain = NULL;
-	}
-	if (sh->tx_domain) {
-		mlx5_glue->dr_destroy_domain(sh->tx_domain);
-		sh->tx_domain = NULL;
-	}
-	if (sh->fdb_domain) {
-		mlx5_glue->dr_destroy_domain(sh->fdb_domain);
-		sh->fdb_domain = NULL;
-	}
+	mlx5_os_free_shared_domains(sh);
 	if (sh->dr_drop_action) {
 		mlx5_glue->destroy_flow_action(sh->dr_drop_action);
 		sh->dr_drop_action = NULL;
@@ -774,6 +763,32 @@ mlx5_destroy_send_to_kernel_action(struct mlx5_dev_ctx_shared *sh)
 }
 #endif /* HAVE_MLX5DV_DR */
 
+/**
+ * Destroy the shared DR domains.
+ *
+ * The domains are per shared context. ASO steering actions are created in
+ * them, so callers must release those actions before calling this.
+ *
+ * @param[in] sh
+ *   Pointer to the shared device context.
+ */
+void
+mlx5_os_free_shared_domains(struct mlx5_dev_ctx_shared *sh)
+{
+	if (sh->rx_domain != NULL) {
+		claim_zero(mlx5_glue->dr_destroy_domain(sh->rx_domain));
+		sh->rx_domain = NULL;
+	}
+	if (sh->tx_domain != NULL) {
+		claim_zero(mlx5_glue->dr_destroy_domain(sh->tx_domain));
+		sh->tx_domain = NULL;
+	}
+	if (sh->fdb_domain != NULL) {
+		claim_zero(mlx5_glue->dr_destroy_domain(sh->fdb_domain));
+		sh->fdb_domain = NULL;
+	}
+}
+
 /**
  * Destroy DR related data within private structure.
  *
@@ -801,19 +816,7 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv)
 	MLX5_ASSERT(LIST_EMPTY(&sh->shared_rxqs));
 #ifdef HAVE_MLX5DV_DR
 	mlx5_destroy_send_to_kernel_action(sh);
-	if (sh->rx_domain) {
-		mlx5_glue->dr_destroy_domain(sh->rx_domain);
-		sh->rx_domain = NULL;
-	}
-	if (sh->tx_domain) {
-		mlx5_glue->dr_destroy_domain(sh->tx_domain);
-		sh->tx_domain = NULL;
-	}
 #ifdef HAVE_MLX5DV_DR_ESWITCH
-	if (sh->fdb_domain) {
-		mlx5_glue->dr_destroy_domain(sh->fdb_domain);
-		sh->fdb_domain = NULL;
-	}
 	if (sh->dr_drop_action) {
 		mlx5_glue->destroy_flow_action(sh->dr_drop_action);
 		sh->dr_drop_action = NULL;
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index e2dbd2977b..4168d62039 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -2130,6 +2130,12 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
 	}
 	if (sh->mtrmng)
 		mlx5_aso_flow_mtrs_mng_close(sh);
+	/*
+	 * DR domains belong to the shared context, as the ASO managers do.
+	 * ASO steering actions are created in these domains, so destroy the
+	 * domains only after those actions are released.
+	 */
+	mlx5_os_free_shared_domains(sh);
 	mlx5_flow_ipool_destroy(sh);
 	mlx5_os_dev_shared_handler_uninstall(sh);
 	mlx5_rxtx_uars_release(sh);
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 7923125c5c..9b6d7a0403 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -2644,6 +2644,7 @@ uint32_t mlx5_flow_mtr_max_get(struct mlx5_priv *priv);
 struct rte_pci_driver;
 int mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh);
 void mlx5_os_free_shared_dr(struct mlx5_priv *priv);
+void mlx5_os_free_shared_domains(struct mlx5_dev_ctx_shared *sh);
 int mlx5_os_net_probe(struct mlx5_common_device *cdev,
 		      struct mlx5_kvargs_ctrl *mkvlist);
 void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh);
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index cc60f07e17..1117cee1de 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -310,6 +310,19 @@ mlx5_os_free_shared_dr(struct mlx5_priv *priv)
 	mlx5_free_table_hash_list(priv);
 }
 
+/**
+ * Destroy shared DR domains.
+ * Windows has no DR domains.
+ *
+ * @param[in] sh
+ *   Pointer to the shared device context.
+ */
+void
+mlx5_os_free_shared_domains(struct mlx5_dev_ctx_shared *sh)
+{
+	RTE_SET_USED(sh);
+}
+
 /**
  * Set the completion channel file descriptor interrupt as non-blocking.
  * Currently it has no support under Windows.
-- 
2.43.0


                 reply	other threads:[~2026-11-11 13:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261111133456.49554-1-bingz@nvidia.com \
    --to=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=lizh@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=michaelba@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=shunh@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.