net/mlx5: fix LAG representor probing on PF1 PCI
[dpdk.git] / drivers / net / mlx5 / mlx5.c
index 7e83d09..35f91e9 100644 (file)
@@ -708,6 +708,60 @@ mlx5_flow_aso_ct_mng_init(struct mlx5_dev_ctx_shared *sh)
        return 0;
 }
 
+/*
+ * Close and release all the resources of the
+ * ASO connection tracking management structure.
+ *
+ * @param[in] sh
+ *   Pointer to mlx5_dev_ctx_shared object to free.
+ */
+static void
+mlx5_flow_aso_ct_mng_close(struct mlx5_dev_ctx_shared *sh)
+{
+       struct mlx5_aso_ct_pools_mng *mng = sh->ct_mng;
+       struct mlx5_aso_ct_pool *ct_pool;
+       struct mlx5_aso_ct_action *ct;
+       uint32_t idx;
+       uint32_t val;
+       uint32_t cnt;
+       int i;
+
+       mlx5_aso_queue_uninit(sh, ASO_OPC_MOD_CONNECTION_TRACKING);
+       idx = mng->next;
+       while (idx--) {
+               cnt = 0;
+               ct_pool = mng->pools[idx];
+               for (i = 0; i < MLX5_ASO_CT_ACTIONS_PER_POOL; i++) {
+                       ct = &ct_pool->actions[i];
+                       val = __atomic_fetch_sub(&ct->refcnt, 1,
+                                                __ATOMIC_RELAXED);
+                       MLX5_ASSERT(val == 1);
+                       if (val > 1)
+                               cnt++;
+#ifdef HAVE_MLX5_DR_ACTION_ASO_CT
+                       if (ct->dr_action_orig)
+                               claim_zero(mlx5_glue->destroy_flow_action
+                                                       (ct->dr_action_orig));
+                       if (ct->dr_action_rply)
+                               claim_zero(mlx5_glue->destroy_flow_action
+                                                       (ct->dr_action_rply));
+#endif
+               }
+               claim_zero(mlx5_devx_cmd_destroy(ct_pool->devx_obj));
+               if (cnt) {
+                       DRV_LOG(DEBUG, "%u ASO CT objects are being used in the pool %u",
+                               cnt, i);
+               }
+               mlx5_free(ct_pool);
+               /* in case of failure. */
+               mng->next--;
+       }
+       mlx5_free(mng->pools);
+       mlx5_free(mng);
+       /* Management structure must be cleared to 0s during allocation. */
+       sh->ct_mng = NULL;
+}
+
 /**
  * Initialize the flow resources' indexed mempool.
  *
@@ -1510,6 +1564,8 @@ mlx5_dev_close(struct rte_eth_dev *dev)
        if (priv->mreg_cp_tbl)
                mlx5_hlist_destroy(priv->mreg_cp_tbl);
        mlx5_mprq_free_mp(dev);
+       if (priv->sh->ct_mng)
+               mlx5_flow_aso_ct_mng_close(priv->sh);
        mlx5_os_free_shared_dr(priv);
        if (priv->rss_conf.rss_key != NULL)
                mlx5_free(priv->rss_conf.rss_key);
@@ -2386,7 +2442,7 @@ static struct mlx5_pci_driver mlx5_driver = {
 };
 
 /* Initialize driver log type. */
-RTE_LOG_REGISTER(mlx5_logtype, pmd.net.mlx5, NOTICE)
+RTE_LOG_REGISTER_DEFAULT(mlx5_logtype, NOTICE)
 
 /**
  * Driver initialization routine.