@@ -1663,115 +1663,24 @@ static int init_root_ns(struct mlx5_flow_steering *steering)
1663
1663
return - ENOMEM ;
1664
1664
}
1665
1665
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 )
1668
1667
{
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 ;
1673
1671
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 );
1681
1675
}
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 );
1695
1676
}
1696
1677
1697
- static void cleanup_root_ns (struct mlx5_flow_steering * steering )
1678
+ static void cleanup_root_ns (struct mlx5_flow_root_namespace * root_ns )
1698
1679
{
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
-
1705
1680
if (!root_ns )
1706
1681
return ;
1707
1682
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 );
1775
1684
}
1776
1685
1777
1686
void mlx5_cleanup_fs (struct mlx5_core_dev * dev )
@@ -1781,10 +1690,10 @@ void mlx5_cleanup_fs(struct mlx5_core_dev *dev)
1781
1690
if (MLX5_CAP_GEN (dev , port_type ) != MLX5_CAP_PORT_TYPE_ETH )
1782
1691
return ;
1783
1692
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 );
1788
1697
mlx5_cleanup_fc_stats (dev );
1789
1698
kfree (steering );
1790
1699
}
@@ -1800,7 +1709,8 @@ static int init_fdb_root_ns(struct mlx5_flow_steering *steering)
1800
1709
/* Create single prio */
1801
1710
prio = fs_create_prio (& steering -> fdb_root_ns -> ns , 0 , 1 );
1802
1711
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 ;
1804
1714
return PTR_ERR (prio );
1805
1715
} else {
1806
1716
return 0 ;
0 commit comments