Skip to content

Commit 0da2d66

Browse files
Maor Gottliebdavem330
authored andcommitted
net/mlx5: Properly remove all steering objects
Instead of explicitly cleaning up the well known parts of the steering tree, we use the generic tree structure to traverse for cleanup. No functional changes. Signed-off-by: Maor Gottlieb <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fba53f7 commit 0da2d66

File tree

1 file changed

+15
-105
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+15
-105
lines changed

drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

Lines changed: 15 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,115 +1663,24 @@ static int init_root_ns(struct mlx5_flow_steering *steering)
16631663
return -ENOMEM;
16641664
}
16651665

1666-
static void cleanup_single_prio_root_ns(struct mlx5_flow_steering *steering,
1667-
struct mlx5_flow_root_namespace *root_ns)
1666+
static void clean_tree(struct fs_node *node)
16681667
{
1669-
struct fs_node *prio;
1670-
1671-
if (!root_ns)
1672-
return;
1668+
if (node) {
1669+
struct fs_node *iter;
1670+
struct fs_node *temp;
16731671

1674-
if (!list_empty(&root_ns->ns.node.children)) {
1675-
prio = list_first_entry(&root_ns->ns.node.children,
1676-
struct fs_node,
1677-
list);
1678-
if (tree_remove_node(prio))
1679-
mlx5_core_warn(steering->dev,
1680-
"Flow steering priority wasn't destroyed, refcount > 1\n");
1672+
list_for_each_entry_safe(iter, temp, &node->children, list)
1673+
clean_tree(iter);
1674+
tree_remove_node(node);
16811675
}
1682-
if (tree_remove_node(&root_ns->ns.node))
1683-
mlx5_core_warn(steering->dev,
1684-
"Flow steering namespace wasn't destroyed, refcount > 1\n");
1685-
root_ns = NULL;
1686-
}
1687-
1688-
static void destroy_flow_tables(struct fs_prio *prio)
1689-
{
1690-
struct mlx5_flow_table *iter;
1691-
struct mlx5_flow_table *tmp;
1692-
1693-
fs_for_each_ft_safe(iter, tmp, prio)
1694-
mlx5_destroy_flow_table(iter);
16951676
}
16961677

1697-
static void cleanup_root_ns(struct mlx5_flow_steering *steering)
1678+
static void cleanup_root_ns(struct mlx5_flow_root_namespace *root_ns)
16981679
{
1699-
struct mlx5_flow_root_namespace *root_ns = steering->root_ns;
1700-
struct fs_prio *iter_prio;
1701-
1702-
if (!MLX5_CAP_GEN(steering->dev, nic_flow_table))
1703-
return;
1704-
17051680
if (!root_ns)
17061681
return;
17071682

1708-
/* stage 1 */
1709-
fs_for_each_prio(iter_prio, &root_ns->ns) {
1710-
struct fs_node *node;
1711-
struct mlx5_flow_namespace *iter_ns;
1712-
1713-
fs_for_each_ns_or_ft(node, iter_prio) {
1714-
if (node->type == FS_TYPE_FLOW_TABLE)
1715-
continue;
1716-
fs_get_obj(iter_ns, node);
1717-
while (!list_empty(&iter_ns->node.children)) {
1718-
struct fs_prio *obj_iter_prio2;
1719-
struct fs_node *iter_prio2 =
1720-
list_first_entry(&iter_ns->node.children,
1721-
struct fs_node,
1722-
list);
1723-
1724-
fs_get_obj(obj_iter_prio2, iter_prio2);
1725-
destroy_flow_tables(obj_iter_prio2);
1726-
if (tree_remove_node(iter_prio2)) {
1727-
mlx5_core_warn(steering->dev,
1728-
"Priority %d wasn't destroyed, refcount > 1\n",
1729-
obj_iter_prio2->prio);
1730-
return;
1731-
}
1732-
}
1733-
}
1734-
}
1735-
1736-
/* stage 2 */
1737-
fs_for_each_prio(iter_prio, &root_ns->ns) {
1738-
while (!list_empty(&iter_prio->node.children)) {
1739-
struct fs_node *iter_ns =
1740-
list_first_entry(&iter_prio->node.children,
1741-
struct fs_node,
1742-
list);
1743-
if (tree_remove_node(iter_ns)) {
1744-
mlx5_core_warn(steering->dev,
1745-
"Namespace wasn't destroyed, refcount > 1\n");
1746-
return;
1747-
}
1748-
}
1749-
}
1750-
1751-
/* stage 3 */
1752-
while (!list_empty(&root_ns->ns.node.children)) {
1753-
struct fs_prio *obj_prio_node;
1754-
struct fs_node *prio_node =
1755-
list_first_entry(&root_ns->ns.node.children,
1756-
struct fs_node,
1757-
list);
1758-
1759-
fs_get_obj(obj_prio_node, prio_node);
1760-
if (tree_remove_node(prio_node)) {
1761-
mlx5_core_warn(steering->dev,
1762-
"Priority %d wasn't destroyed, refcount > 1\n",
1763-
obj_prio_node->prio);
1764-
return;
1765-
}
1766-
}
1767-
1768-
if (tree_remove_node(&root_ns->ns.node)) {
1769-
mlx5_core_warn(steering->dev,
1770-
"root namespace wasn't destroyed, refcount > 1\n");
1771-
return;
1772-
}
1773-
1774-
steering->root_ns = NULL;
1683+
clean_tree(&root_ns->ns.node);
17751684
}
17761685

17771686
void mlx5_cleanup_fs(struct mlx5_core_dev *dev)
@@ -1781,10 +1690,10 @@ void mlx5_cleanup_fs(struct mlx5_core_dev *dev)
17811690
if (MLX5_CAP_GEN(dev, port_type) != MLX5_CAP_PORT_TYPE_ETH)
17821691
return;
17831692

1784-
cleanup_root_ns(steering);
1785-
cleanup_single_prio_root_ns(steering, steering->esw_egress_root_ns);
1786-
cleanup_single_prio_root_ns(steering, steering->esw_ingress_root_ns);
1787-
cleanup_single_prio_root_ns(steering, steering->fdb_root_ns);
1693+
cleanup_root_ns(steering->root_ns);
1694+
cleanup_root_ns(steering->esw_egress_root_ns);
1695+
cleanup_root_ns(steering->esw_ingress_root_ns);
1696+
cleanup_root_ns(steering->fdb_root_ns);
17881697
mlx5_cleanup_fc_stats(dev);
17891698
kfree(steering);
17901699
}
@@ -1800,7 +1709,8 @@ static int init_fdb_root_ns(struct mlx5_flow_steering *steering)
18001709
/* Create single prio */
18011710
prio = fs_create_prio(&steering->fdb_root_ns->ns, 0, 1);
18021711
if (IS_ERR(prio)) {
1803-
cleanup_single_prio_root_ns(steering, steering->fdb_root_ns);
1712+
cleanup_root_ns(steering->fdb_root_ns);
1713+
steering->fdb_root_ns = NULL;
18041714
return PTR_ERR(prio);
18051715
} else {
18061716
return 0;

0 commit comments

Comments
 (0)