History

net/mlx5e: CT: Use own workqueue instead of mlx5e priv

Allocate a ct priv workqueue instead of using mlx5e priv one so flushing will only be of related CT entries. Also move flushing of the workqueue before rhashtable destroy otherwise entries won't be valid.

Roi Dayan committed 4 years ago

Commit 6c4e8fa1 parent 1afbd1e1 file · +12 −8Browse files

Unified · Split

drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c+12−8
@@ -76,6 +76,7 @@ struct mlx5_tc_ct_priv { · 75 unmodified lines
76 struct mlx5_ct_fs *fs;76 struct mlx5_ct_fs *fs;
77 struct mlx5_ct_fs_ops *fs_ops;77 struct mlx5_ct_fs_ops *fs_ops;
78 spinlock_t ht_lock; /* protects ft entries */78 spinlock_t ht_lock; /* protects ft entries */
79 struct workqueue_struct *wq;
79 80
80 struct mlx5_tc_ct_debugfs debugfs;81 struct mlx5_tc_ct_debugfs debugfs;
81};82};
@@ -941,14 +942,11 @@ static void mlx5_tc_ct_entry_del_work(struct work_struct *work) · 859 unmodified lines
941static void942static void
942__mlx5_tc_ct_entry_put(struct mlx5_ct_entry *entry)943__mlx5_tc_ct_entry_put(struct mlx5_ct_entry *entry)
943{944{
944 struct mlx5e_priv *priv;
945
946 if (!refcount_dec_and_test(&entry->refcnt))945 if (!refcount_dec_and_test(&entry->refcnt))
947 return;946 return;
948 947
949 priv = netdev_priv(entry->ct_priv->netdev);
950 INIT_WORK(&entry->work, mlx5_tc_ct_entry_del_work);948 INIT_WORK(&entry->work, mlx5_tc_ct_entry_del_work);
951 queue_work(priv->wq, &entry->work);949 queue_work(entry->ct_priv->wq, &entry->work);
952}950}
953 951
954static struct mlx5_ct_counter *952static struct mlx5_ct_counter *
@@ -1759,19 +1757,16 @@ mlx5_tc_ct_flush_ft_entry(void *ptr, void *arg) · 804 unmodified lines
1759static void1757static void
1760mlx5_tc_ct_del_ft_cb(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_ft *ft)1758mlx5_tc_ct_del_ft_cb(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_ft *ft)
1761{1759{
1762 struct mlx5e_priv *priv;
1763
1764 if (!refcount_dec_and_test(&ft->refcount))1760 if (!refcount_dec_and_test(&ft->refcount))
1765 return;1761 return;
1766 1762
1763 flush_workqueue(ct_priv->wq);
1767 nf_flow_table_offload_del_cb(ft->nf_ft,1764 nf_flow_table_offload_del_cb(ft->nf_ft,
1768 mlx5_tc_ct_block_flow_offload, ft);1765 mlx5_tc_ct_block_flow_offload, ft);
1769 rhashtable_remove_fast(&ct_priv->zone_ht, &ft->node, zone_params);1766 rhashtable_remove_fast(&ct_priv->zone_ht, &ft->node, zone_params);
1770 rhashtable_free_and_destroy(&ft->ct_entries_ht,1767 rhashtable_free_and_destroy(&ft->ct_entries_ht,
1771 mlx5_tc_ct_flush_ft_entry,1768 mlx5_tc_ct_flush_ft_entry,
1772 ct_priv);1769 ct_priv);
1773 priv = netdev_priv(ct_priv->netdev);
1774 flush_workqueue(priv->wq);
1775 mlx5_tc_ct_free_pre_ct_tables(ft);1770 mlx5_tc_ct_free_pre_ct_tables(ft);
1776 mapping_remove(ct_priv->zone_mapping, ft->zone_restore_id);1771 mapping_remove(ct_priv->zone_mapping, ft->zone_restore_id);
1777 kfree(ft);1772 kfree(ft);
@@ -2176,6 +2171,12 @@ mlx5_tc_ct_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains, · 398 unmodified lines
2176 if (rhashtable_init(&ct_priv->ct_tuples_nat_ht, &tuples_nat_ht_params))2171 if (rhashtable_init(&ct_priv->ct_tuples_nat_ht, &tuples_nat_ht_params))
2177 goto err_ct_tuples_nat_ht;2172 goto err_ct_tuples_nat_ht;
2178 2173
2174 ct_priv->wq = alloc_ordered_workqueue("mlx5e_ct_priv_wq", 0);
2175 if (!ct_priv->wq) {
2176 err = -ENOMEM;
2177 goto err_wq;
2178 }
2179
2179 err = mlx5_tc_ct_fs_init(ct_priv);2180 err = mlx5_tc_ct_fs_init(ct_priv);
2180 if (err)2181 if (err)
2181 goto err_init_fs;2182 goto err_init_fs;
@@ -2184,6 +2185,8 @@ mlx5_tc_ct_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains, · 2 unmodified lines
2184 return ct_priv;2185 return ct_priv;
2185 2186
2186err_init_fs:2187err_init_fs:
2188 destroy_workqueue(ct_priv->wq);
2189err_wq:
2187 rhashtable_destroy(&ct_priv->ct_tuples_nat_ht);2190 rhashtable_destroy(&ct_priv->ct_tuples_nat_ht);
2188err_ct_tuples_nat_ht:2191err_ct_tuples_nat_ht:
2189 rhashtable_destroy(&ct_priv->ct_tuples_ht);2192 rhashtable_destroy(&ct_priv->ct_tuples_ht);
@@ -2213,6 +2216,7 @@ mlx5_tc_ct_clean(struct mlx5_tc_ct_priv *ct_priv) · 23 unmodified lines
2213 if (!ct_priv)2216 if (!ct_priv)
2214 return;2217 return;
2215 2218
2219 destroy_workqueue(ct_priv->wq);
2216 mlx5_ct_tc_remove_dbgfs(ct_priv);2220 mlx5_ct_tc_remove_dbgfs(ct_priv);
2217 chains = ct_priv->chains;2221 chains = ct_priv->chains;
2218 2222