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: [email protected]
Suggested-by: Matan Azrad <[email protected]>
Signed-off-by: Bing Zhao <[email protected]>
---
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