net/mlx5: release connection tracking management

When freeing the IB shared context during stopping a device, the
ASO connection tracking management structure should also be cleaned
up.

All the DR actions created should be destroyed. The structures need
to be freed and ASO CT QP should be released. In the meanwhile, the
allocated and registered memory region for query should also be
deregistered and then freed.

Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
This commit is contained in:
Bing Zhao 2021-05-05 15:23:19 +03:00 committed by Raslan Darawsheh
parent 2db75e8b1d
commit 0af8a2298a
2 changed files with 60 additions and 0 deletions

View 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);

View File

@ -372,6 +372,10 @@ mlx5_aso_queue_uninit(struct mlx5_dev_ctx_shared *sh,
case ASO_OPC_MOD_POLICER:
sq = &sh->mtrmng->pools_mng.sq;
break;
case ASO_OPC_MOD_CONNECTION_TRACKING:
mlx5_aso_dereg_mr(sh, &sh->ct_mng->aso_sq.mr);
sq = &sh->ct_mng->aso_sq;
break;
default:
DRV_LOG(ERR, "Unknown ASO operation mode");
return;