Commit 27997978 authored by Chris Mi's avatar Chris Mi Committed by Saeed Mahameed

net/mlx5e: CT, Use xarray to manage fte ids

IDR is deprecated. Use xarray instead.
Signed-off-by: default avatarChris Mi <cmi@nvidia.com>
Reviewed-by: default avatarOz Shlomo <ozsh@nvidia.com>
Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent bcd6740c
...@@ -46,7 +46,7 @@ struct mlx5_tc_ct_priv { ...@@ -46,7 +46,7 @@ struct mlx5_tc_ct_priv {
struct mlx5_core_dev *dev; struct mlx5_core_dev *dev;
const struct net_device *netdev; const struct net_device *netdev;
struct mod_hdr_tbl *mod_hdr_tbl; struct mod_hdr_tbl *mod_hdr_tbl;
struct idr fte_ids; struct xarray fte_ids;
struct xarray tuple_ids; struct xarray tuple_ids;
struct rhashtable zone_ht; struct rhashtable zone_ht;
struct rhashtable ct_tuples_ht; struct rhashtable ct_tuples_ht;
...@@ -1773,12 +1773,12 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv, ...@@ -1773,12 +1773,12 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,
} }
ct_flow->ft = ft; ct_flow->ft = ft;
err = idr_alloc_u32(&ct_priv->fte_ids, ct_flow, &fte_id, err = xa_alloc(&ct_priv->fte_ids, &fte_id, ct_flow,
MLX5_FTE_ID_MAX, GFP_KERNEL); XA_LIMIT(1, MLX5_FTE_ID_MAX), GFP_KERNEL);
if (err) { if (err) {
netdev_warn(priv->netdev, netdev_warn(priv->netdev,
"Failed to allocate fte id, err: %d\n", err); "Failed to allocate fte id, err: %d\n", err);
goto err_idr; goto err_xarray;
} }
ct_flow->fte_id = fte_id; ct_flow->fte_id = fte_id;
...@@ -1914,8 +1914,8 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv, ...@@ -1914,8 +1914,8 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,
err_alloc_post: err_alloc_post:
kfree(ct_flow->pre_ct_attr); kfree(ct_flow->pre_ct_attr);
err_alloc_pre: err_alloc_pre:
idr_remove(&ct_priv->fte_ids, fte_id); xa_erase(&ct_priv->fte_ids, fte_id);
err_idr: err_xarray:
mlx5_tc_ct_del_ft_cb(ct_priv, ft); mlx5_tc_ct_del_ft_cb(ct_priv, ft);
err_ft: err_ft:
kvfree(post_ct_spec); kvfree(post_ct_spec);
...@@ -2033,7 +2033,7 @@ __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv, ...@@ -2033,7 +2033,7 @@ __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv,
mlx5_tc_rule_delete(priv, ct_flow->post_ct_rule, mlx5_tc_rule_delete(priv, ct_flow->post_ct_rule,
ct_flow->post_ct_attr); ct_flow->post_ct_attr);
mlx5_chains_put_chain_mapping(ct_priv->chains, ct_flow->chain_mapping); mlx5_chains_put_chain_mapping(ct_priv->chains, ct_flow->chain_mapping);
idr_remove(&ct_priv->fte_ids, ct_flow->fte_id); xa_erase(&ct_priv->fte_ids, ct_flow->fte_id);
mlx5_tc_ct_del_ft_cb(ct_priv, ct_flow->ft); mlx5_tc_ct_del_ft_cb(ct_priv, ct_flow->ft);
} }
...@@ -2203,7 +2203,7 @@ mlx5_tc_ct_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains, ...@@ -2203,7 +2203,7 @@ mlx5_tc_ct_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains,
goto err_post_ct_tbl; goto err_post_ct_tbl;
} }
idr_init(&ct_priv->fte_ids); xa_init_flags(&ct_priv->fte_ids, XA_FLAGS_ALLOC1);
mutex_init(&ct_priv->control_lock); mutex_init(&ct_priv->control_lock);
rhashtable_init(&ct_priv->zone_ht, &zone_params); rhashtable_init(&ct_priv->zone_ht, &zone_params);
rhashtable_init(&ct_priv->ct_tuples_ht, &tuples_ht_params); rhashtable_init(&ct_priv->ct_tuples_ht, &tuples_ht_params);
...@@ -2247,7 +2247,7 @@ mlx5_tc_ct_clean(struct mlx5_tc_ct_priv *ct_priv) ...@@ -2247,7 +2247,7 @@ mlx5_tc_ct_clean(struct mlx5_tc_ct_priv *ct_priv)
rhashtable_destroy(&ct_priv->ct_tuples_nat_ht); rhashtable_destroy(&ct_priv->ct_tuples_nat_ht);
rhashtable_destroy(&ct_priv->zone_ht); rhashtable_destroy(&ct_priv->zone_ht);
mutex_destroy(&ct_priv->control_lock); mutex_destroy(&ct_priv->control_lock);
idr_destroy(&ct_priv->fte_ids); xa_destroy(&ct_priv->fte_ids);
kfree(ct_priv); kfree(ct_priv);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment