priv->ctrl_flows = 0;
rte_spinlock_init(&priv->flow_list_lock);
TAILQ_INIT(&priv->flow_meters);
- TAILQ_INIT(&priv->flow_meter_profiles);
+ priv->mtr_profile_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_PTR);
+ if (!priv->mtr_profile_tbl)
+ goto error;
/* Hint libmlx5 to use PMD allocator for data plane resources */
mlx5_glue->dv_set_context_attr(sh->ctx,
MLX5DV_CTX_ATTR_BUF_ALLOCATORS,
mlx5_vlan_vmwa_exit(priv->vmwa_context);
if (eth_dev && priv->drop_queue.hrxq)
mlx5_drop_action_destroy(eth_dev);
+ if (priv->mtr_profile_tbl)
+ mlx5_l3t_destroy(priv->mtr_profile_tbl);
if (own_domain_id)
claim_zero(rte_eth_switch_domain_free(priv->domain_id));
mlx5_cache_list_destroy(&priv->hrxqs);
static struct mlx5_flow_meter_profile *
mlx5_flow_meter_profile_find(struct mlx5_priv *priv, uint32_t meter_profile_id)
{
- struct mlx5_mtr_profiles *fmps = &priv->flow_meter_profiles;
struct mlx5_flow_meter_profile *fmp;
+ union mlx5_l3t_data data;
+ int32_t ret;
- TAILQ_FOREACH(fmp, fmps, next)
- if (meter_profile_id == fmp->id)
- return fmp;
- return NULL;
+ if (mlx5_l3t_get_entry(priv->mtr_profile_tbl,
+ meter_profile_id, &data) || !data.ptr)
+ return NULL;
+ fmp = data.ptr;
+ /* Remove reference taken by the mlx5_l3t_get_entry. */
+ ret = mlx5_l3t_clear_entry(priv->mtr_profile_tbl,
+ meter_profile_id);
+ if (!ret || ret == -1)
+ return NULL;
+ return fmp;
}
/**
struct rte_mtr_error *error)
{
struct mlx5_priv *priv = dev->data->dev_private;
- struct mlx5_mtr_profiles *fmps = &priv->flow_meter_profiles;
struct mlx5_flow_meter_profile *fmp;
+ union mlx5_l3t_data data;
int ret;
if (!priv->mtr_en)
ret = mlx5_flow_meter_param_fill(fmp, priv, error);
if (ret)
goto error;
- /* Add to list. */
- TAILQ_INSERT_TAIL(fmps, fmp, next);
+ data.ptr = fmp;
+ ret = mlx5_l3t_set_entry(priv->mtr_profile_tbl,
+ meter_profile_id, &data);
+ if (ret)
+ return -rte_mtr_error_set(error, ENOTSUP,
+ RTE_MTR_ERROR_TYPE_UNSPECIFIED,
+ NULL, "Meter profile insert fail.");
return 0;
error:
mlx5_free(fmp);
return -rte_mtr_error_set(error, EBUSY,
RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
NULL, "Meter profile is in use.");
- /* Remove from list. */
- TAILQ_REMOVE(&priv->flow_meter_profiles, fmp, next);
+ if (mlx5_l3t_clear_entry(priv->mtr_profile_tbl, meter_profile_id))
+ return -rte_mtr_error_set(error, EBUSY,
+ RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
+ NULL, "Meter profile remove fail.");
mlx5_free(fmp);
return 0;
}
{
struct mlx5_priv *priv = dev->data->dev_private;
struct mlx5_legacy_flow_meters *fms = &priv->flow_meters;
- struct mlx5_mtr_profiles *fmps = &priv->flow_meter_profiles;
struct mlx5_flow_meter_profile *fmp;
struct mlx5_legacy_flow_meter *legacy_fm;
struct mlx5_flow_meter_info *fm;
mlx5_l3t_destroy(priv->sh->mtrmng->policy_idx_tbl);
priv->sh->mtrmng->policy_idx_tbl = NULL;
}
- TAILQ_FOREACH_SAFE(fmp, fmps, next, tmp) {
- /* Check unused. */
- MLX5_ASSERT(!fmp->ref_cnt);
- /* Remove from list. */
- TAILQ_REMOVE(&priv->flow_meter_profiles, fmp, next);
- mlx5_free(fmp);
+ if (priv->mtr_profile_tbl) {
+ MLX5_L3T_FOREACH(priv->mtr_profile_tbl, i, entry) {
+ fmp = entry;
+ if (mlx5_flow_meter_profile_delete(dev, fmp->id,
+ error))
+ return -rte_mtr_error_set(error, EINVAL,
+ RTE_MTR_ERROR_TYPE_METER_POLICY_ID,
+ NULL, "Fail to destroy "
+ "meter profile.");
+ }
+ mlx5_l3t_destroy(priv->mtr_profile_tbl);
+ priv->mtr_profile_tbl = NULL;
}
/* Delete default policy table. */
mlx5_flow_destroy_def_policy(dev);