From: Shun Hao Date: Fri, 2 Jul 2021 09:14:44 +0000 (+0300) Subject: net/mlx5: fix meter policy ID table container X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=efcce4dcdc7e4e16bb139b388c1855d937996a16;p=dpdk.git net/mlx5: fix meter policy ID table container The meter policy handlers are managed by user IDs and the driver used l3 table in order to map the user ID to the internal driver handler of the policy. The l3 table was wrongly saved in the shared device structure which manages all the switch domain ports what made the user IDs shared between different ethdev ports. Move the policy l3 table to be per port by saving it in the port private structure. Fixes: afb4aa4f122 ("net/mlx5: support meter policy operations") Cc: stable@dpdk.org Signed-off-by: Shun Hao Acked-by: Matan Azrad --- diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index d0faa45944..abd573e8ed 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -600,8 +600,6 @@ mlx5_aso_flow_mtrs_mng_init(struct mlx5_dev_ctx_shared *sh) if (sh->meter_aso_en) { rte_spinlock_init(&sh->mtrmng->pools_mng.mtrsl); LIST_INIT(&sh->mtrmng->pools_mng.meters); - sh->mtrmng->policy_idx_tbl = - mlx5_l3t_create(MLX5_L3T_TYPE_DWORD); } sh->mtrmng->def_policy_id = MLX5_INVALID_POLICY_ID; } diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 0226327bc3..6eae7b6fd7 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -870,8 +870,6 @@ struct mlx5_flow_mtr_mng { /* Default policy id. */ uint32_t def_policy_ref_cnt; /** def_policy meter use count. */ - struct mlx5_l3t_tbl *policy_idx_tbl; - /* Policy index lookup table. */ struct mlx5_flow_tbl_resource *drop_tbl[MLX5_MTR_DOMAIN_MAX]; /* Meter drop table. */ struct mlx5_flow_dv_matcher * @@ -1375,6 +1373,7 @@ struct mlx5_priv { uint8_t mtr_color_reg; /* Meter color match REG_C. */ struct mlx5_legacy_flow_meters flow_meters; /* MTR list. */ struct mlx5_l3t_tbl *mtr_profile_tbl; /* Meter index lookup table. */ + struct mlx5_l3t_tbl *policy_idx_tbl; /* Policy index lookup table. */ struct mlx5_l3t_tbl *mtr_idx_tbl; /* Meter index lookup table. */ uint8_t skip_default_rss_reta; /* Skip configuration of default reta. */ uint8_t fdb_def_rule; /* Whether fdb jump to table 1 is configured. */ diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index 87c5782956..6f962a8d52 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -512,11 +512,9 @@ mlx5_flow_meter_policy_find(struct rte_eth_dev *dev, struct mlx5_flow_meter_sub_policy *sub_policy = NULL; union mlx5_l3t_data data; - if (policy_id > MLX5_MAX_SUB_POLICY_TBL_NUM || - !priv->sh->mtrmng->policy_idx_tbl) + if (policy_id > MLX5_MAX_SUB_POLICY_TBL_NUM || !priv->policy_idx_tbl) return NULL; - if (mlx5_l3t_get_entry(priv->sh->mtrmng->policy_idx_tbl, - policy_id, &data) || + if (mlx5_l3t_get_entry(priv->policy_idx_tbl, policy_id, &data) || !data.dword) return NULL; if (policy_idx) @@ -524,8 +522,7 @@ mlx5_flow_meter_policy_find(struct rte_eth_dev *dev, sub_policy = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], data.dword); /* Remove reference taken by the mlx5_l3t_get_entry. */ - mlx5_l3t_clear_entry(priv->sh->mtrmng->policy_idx_tbl, - policy_id); + mlx5_l3t_clear_entry(priv->policy_idx_tbl, policy_id); if (sub_policy) if (sub_policy->main_policy_id) return sub_policy->main_policy; @@ -605,9 +602,8 @@ __mlx5_flow_meter_policy_delete(struct rte_eth_dev *dev, } } } - if (priv->sh->mtrmng->policy_idx_tbl && clear_l3t) { - if (mlx5_l3t_clear_entry(priv->sh->mtrmng->policy_idx_tbl, - policy_id)) { + if (priv->policy_idx_tbl && clear_l3t) { + if (mlx5_l3t_clear_entry(priv->policy_idx_tbl, policy_id)) { rte_spinlock_unlock(&mtr_policy->sl); return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY_ID, NULL, @@ -770,14 +766,12 @@ mlx5_flow_meter_policy_add(struct rte_eth_dev *dev, goto policy_add_err; } data.dword = policy_idx; - if (!priv->sh->mtrmng->policy_idx_tbl) { - priv->sh->mtrmng->policy_idx_tbl = - mlx5_l3t_create(MLX5_L3T_TYPE_DWORD); - if (!priv->sh->mtrmng->policy_idx_tbl) + if (!priv->policy_idx_tbl) { + priv->policy_idx_tbl = mlx5_l3t_create(MLX5_L3T_TYPE_DWORD); + if (!priv->policy_idx_tbl) goto policy_add_err; } - if (mlx5_l3t_set_entry(priv->sh->mtrmng->policy_idx_tbl, - policy_id, &data)) + if (mlx5_l3t_set_entry(priv->policy_idx_tbl, policy_id, &data)) goto policy_add_err; return 0; policy_add_err: @@ -1840,9 +1834,8 @@ mlx5_flow_meter_rxq_flush(struct rte_eth_dev *dev) if (!priv->mtr_en) return; - if (priv->sh->mtrmng->policy_idx_tbl && priv->sh->refcnt == 1) { - MLX5_L3T_FOREACH(priv->sh->mtrmng->policy_idx_tbl, - i, entry) { + if (priv->policy_idx_tbl) { + MLX5_L3T_FOREACH(priv->policy_idx_tbl, i, entry) { policy_idx = *(uint32_t *)entry; sub_policy = mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], @@ -1908,9 +1901,8 @@ mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error) NULL, "MTR object meter profile invalid."); } } - if (priv->sh->mtrmng->policy_idx_tbl && priv->sh->refcnt == 1) { - MLX5_L3T_FOREACH(priv->sh->mtrmng->policy_idx_tbl, - i, entry) { + if (priv->policy_idx_tbl) { + MLX5_L3T_FOREACH(priv->policy_idx_tbl, i, entry) { policy_idx = *(uint32_t *)entry; sub_policy = mlx5_ipool_get (priv->sh->ipool[MLX5_IPOOL_MTR_POLICY], @@ -1931,8 +1923,8 @@ mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error) "meter policy invalid."); mlx5_free(sub_policy->main_policy); } - mlx5_l3t_destroy(priv->sh->mtrmng->policy_idx_tbl); - priv->sh->mtrmng->policy_idx_tbl = NULL; + mlx5_l3t_destroy(priv->policy_idx_tbl); + priv->policy_idx_tbl = NULL; } if (priv->mtr_profile_tbl) { MLX5_L3T_FOREACH(priv->mtr_profile_tbl, i, entry) {