@@ -1363,12 +1363,13 @@ void mlx5_destroy_flow_group(struct mlx5_flow_group *fg)
1363
1363
struct mlx5_flow_namespace * mlx5_get_flow_namespace (struct mlx5_core_dev * dev ,
1364
1364
enum mlx5_flow_namespace_type type )
1365
1365
{
1366
- struct mlx5_flow_root_namespace * root_ns = dev -> priv .root_ns ;
1366
+ struct mlx5_flow_steering * steering = dev -> priv .steering ;
1367
+ struct mlx5_flow_root_namespace * root_ns ;
1367
1368
int prio ;
1368
1369
struct fs_prio * fs_prio ;
1369
1370
struct mlx5_flow_namespace * ns ;
1370
1371
1371
- if (!root_ns )
1372
+ if (!steering )
1372
1373
return NULL ;
1373
1374
1374
1375
switch (type ) {
@@ -1380,24 +1381,28 @@ struct mlx5_flow_namespace *mlx5_get_flow_namespace(struct mlx5_core_dev *dev,
1380
1381
prio = type ;
1381
1382
break ;
1382
1383
case MLX5_FLOW_NAMESPACE_FDB :
1383
- if (dev -> priv . fdb_root_ns )
1384
- return & dev -> priv . fdb_root_ns -> ns ;
1384
+ if (steering -> fdb_root_ns )
1385
+ return & steering -> fdb_root_ns -> ns ;
1385
1386
else
1386
1387
return NULL ;
1387
1388
case MLX5_FLOW_NAMESPACE_ESW_EGRESS :
1388
- if (dev -> priv . esw_egress_root_ns )
1389
- return & dev -> priv . esw_egress_root_ns -> ns ;
1389
+ if (steering -> esw_egress_root_ns )
1390
+ return & steering -> esw_egress_root_ns -> ns ;
1390
1391
else
1391
1392
return NULL ;
1392
1393
case MLX5_FLOW_NAMESPACE_ESW_INGRESS :
1393
- if (dev -> priv . esw_ingress_root_ns )
1394
- return & dev -> priv . esw_ingress_root_ns -> ns ;
1394
+ if (steering -> esw_ingress_root_ns )
1395
+ return & steering -> esw_ingress_root_ns -> ns ;
1395
1396
else
1396
1397
return NULL ;
1397
1398
default :
1398
1399
return NULL ;
1399
1400
}
1400
1401
1402
+ root_ns = steering -> root_ns ;
1403
+ if (!root_ns )
1404
+ return NULL ;
1405
+
1401
1406
fs_prio = find_prio (& root_ns -> ns , prio );
1402
1407
if (!fs_prio )
1403
1408
return NULL ;
@@ -1483,13 +1488,13 @@ static bool has_required_caps(struct mlx5_core_dev *dev, struct node_caps *caps)
1483
1488
return true;
1484
1489
}
1485
1490
1486
- static int init_root_tree_recursive (struct mlx5_core_dev * dev ,
1491
+ static int init_root_tree_recursive (struct mlx5_flow_steering * steering ,
1487
1492
struct init_tree_node * init_node ,
1488
1493
struct fs_node * fs_parent_node ,
1489
1494
struct init_tree_node * init_parent_node ,
1490
1495
int prio )
1491
1496
{
1492
- int max_ft_level = MLX5_CAP_FLOWTABLE (dev ,
1497
+ int max_ft_level = MLX5_CAP_FLOWTABLE (steering -> dev ,
1493
1498
flow_table_properties_nic_receive .
1494
1499
max_ft_level );
1495
1500
struct mlx5_flow_namespace * fs_ns ;
@@ -1500,7 +1505,7 @@ static int init_root_tree_recursive(struct mlx5_core_dev *dev,
1500
1505
1501
1506
if (init_node -> type == FS_TYPE_PRIO ) {
1502
1507
if ((init_node -> min_ft_level > max_ft_level ) ||
1503
- !has_required_caps (dev , & init_node -> caps ))
1508
+ !has_required_caps (steering -> dev , & init_node -> caps ))
1504
1509
return 0 ;
1505
1510
1506
1511
fs_get_obj (fs_ns , fs_parent_node );
@@ -1521,7 +1526,7 @@ static int init_root_tree_recursive(struct mlx5_core_dev *dev,
1521
1526
}
1522
1527
prio = 0 ;
1523
1528
for (i = 0 ; i < init_node -> ar_size ; i ++ ) {
1524
- err = init_root_tree_recursive (dev , & init_node -> children [i ],
1529
+ err = init_root_tree_recursive (steering , & init_node -> children [i ],
1525
1530
base , init_node , prio );
1526
1531
if (err )
1527
1532
return err ;
@@ -1534,7 +1539,7 @@ static int init_root_tree_recursive(struct mlx5_core_dev *dev,
1534
1539
return 0 ;
1535
1540
}
1536
1541
1537
- static int init_root_tree (struct mlx5_core_dev * dev ,
1542
+ static int init_root_tree (struct mlx5_flow_steering * steering ,
1538
1543
struct init_tree_node * init_node ,
1539
1544
struct fs_node * fs_parent_node )
1540
1545
{
@@ -1544,7 +1549,7 @@ static int init_root_tree(struct mlx5_core_dev *dev,
1544
1549
1545
1550
fs_get_obj (fs_ns , fs_parent_node );
1546
1551
for (i = 0 ; i < init_node -> ar_size ; i ++ ) {
1547
- err = init_root_tree_recursive (dev , & init_node -> children [i ],
1552
+ err = init_root_tree_recursive (steering , & init_node -> children [i ],
1548
1553
& fs_ns -> node ,
1549
1554
init_node , i );
1550
1555
if (err )
@@ -1553,7 +1558,7 @@ static int init_root_tree(struct mlx5_core_dev *dev,
1553
1558
return 0 ;
1554
1559
}
1555
1560
1556
- static struct mlx5_flow_root_namespace * create_root_ns (struct mlx5_core_dev * dev ,
1561
+ static struct mlx5_flow_root_namespace * create_root_ns (struct mlx5_flow_steering * steering ,
1557
1562
enum fs_flow_table_type
1558
1563
table_type )
1559
1564
{
@@ -1565,7 +1570,7 @@ static struct mlx5_flow_root_namespace *create_root_ns(struct mlx5_core_dev *dev
1565
1570
if (!root_ns )
1566
1571
return NULL ;
1567
1572
1568
- root_ns -> dev = dev ;
1573
+ root_ns -> dev = steering -> dev ;
1569
1574
root_ns -> table_type = table_type ;
1570
1575
1571
1576
ns = & root_ns -> ns ;
@@ -1620,46 +1625,45 @@ static void set_prio_attrs(struct mlx5_flow_root_namespace *root_ns)
1620
1625
#define ANCHOR_PRIO 0
1621
1626
#define ANCHOR_SIZE 1
1622
1627
#define ANCHOR_LEVEL 0
1623
- static int create_anchor_flow_table (struct mlx5_core_dev
1624
- * dev )
1628
+ static int create_anchor_flow_table (struct mlx5_flow_steering * steering )
1625
1629
{
1626
1630
struct mlx5_flow_namespace * ns = NULL ;
1627
1631
struct mlx5_flow_table * ft ;
1628
1632
1629
- ns = mlx5_get_flow_namespace (dev , MLX5_FLOW_NAMESPACE_ANCHOR );
1633
+ ns = mlx5_get_flow_namespace (steering -> dev , MLX5_FLOW_NAMESPACE_ANCHOR );
1630
1634
if (!ns )
1631
1635
return - EINVAL ;
1632
1636
ft = mlx5_create_flow_table (ns , ANCHOR_PRIO , ANCHOR_SIZE , ANCHOR_LEVEL );
1633
1637
if (IS_ERR (ft )) {
1634
- mlx5_core_err (dev , "Failed to create last anchor flow table" );
1638
+ mlx5_core_err (steering -> dev , "Failed to create last anchor flow table" );
1635
1639
return PTR_ERR (ft );
1636
1640
}
1637
1641
return 0 ;
1638
1642
}
1639
1643
1640
- static int init_root_ns (struct mlx5_core_dev * dev )
1644
+ static int init_root_ns (struct mlx5_flow_steering * steering )
1641
1645
{
1642
1646
1643
- dev -> priv . root_ns = create_root_ns (dev , FS_FT_NIC_RX );
1644
- if (IS_ERR_OR_NULL (dev -> priv . root_ns ))
1647
+ steering -> root_ns = create_root_ns (steering , FS_FT_NIC_RX );
1648
+ if (IS_ERR_OR_NULL (steering -> root_ns ))
1645
1649
goto cleanup ;
1646
1650
1647
- if (init_root_tree (dev , & root_fs , & dev -> priv . root_ns -> ns .node ))
1651
+ if (init_root_tree (steering , & root_fs , & steering -> root_ns -> ns .node ))
1648
1652
goto cleanup ;
1649
1653
1650
- set_prio_attrs (dev -> priv . root_ns );
1654
+ set_prio_attrs (steering -> root_ns );
1651
1655
1652
- if (create_anchor_flow_table (dev ))
1656
+ if (create_anchor_flow_table (steering ))
1653
1657
goto cleanup ;
1654
1658
1655
1659
return 0 ;
1656
1660
1657
1661
cleanup :
1658
- mlx5_cleanup_fs (dev );
1662
+ mlx5_cleanup_fs (steering -> dev );
1659
1663
return - ENOMEM ;
1660
1664
}
1661
1665
1662
- static void cleanup_single_prio_root_ns (struct mlx5_core_dev * dev ,
1666
+ static void cleanup_single_prio_root_ns (struct mlx5_flow_steering * steering ,
1663
1667
struct mlx5_flow_root_namespace * root_ns )
1664
1668
{
1665
1669
struct fs_node * prio ;
@@ -1672,11 +1676,11 @@ static void cleanup_single_prio_root_ns(struct mlx5_core_dev *dev,
1672
1676
struct fs_node ,
1673
1677
list );
1674
1678
if (tree_remove_node (prio ))
1675
- mlx5_core_warn (dev ,
1679
+ mlx5_core_warn (steering -> dev ,
1676
1680
"Flow steering priority wasn't destroyed, refcount > 1\n" );
1677
1681
}
1678
1682
if (tree_remove_node (& root_ns -> ns .node ))
1679
- mlx5_core_warn (dev ,
1683
+ mlx5_core_warn (steering -> dev ,
1680
1684
"Flow steering namespace wasn't destroyed, refcount > 1\n" );
1681
1685
root_ns = NULL ;
1682
1686
}
@@ -1690,12 +1694,12 @@ static void destroy_flow_tables(struct fs_prio *prio)
1690
1694
mlx5_destroy_flow_table (iter );
1691
1695
}
1692
1696
1693
- static void cleanup_root_ns (struct mlx5_core_dev * dev )
1697
+ static void cleanup_root_ns (struct mlx5_flow_steering * steering )
1694
1698
{
1695
- struct mlx5_flow_root_namespace * root_ns = dev -> priv . root_ns ;
1699
+ struct mlx5_flow_root_namespace * root_ns = steering -> root_ns ;
1696
1700
struct fs_prio * iter_prio ;
1697
1701
1698
- if (!MLX5_CAP_GEN (dev , nic_flow_table ))
1702
+ if (!MLX5_CAP_GEN (steering -> dev , nic_flow_table ))
1699
1703
return ;
1700
1704
1701
1705
if (!root_ns )
@@ -1720,7 +1724,7 @@ static void cleanup_root_ns(struct mlx5_core_dev *dev)
1720
1724
fs_get_obj (obj_iter_prio2 , iter_prio2 );
1721
1725
destroy_flow_tables (obj_iter_prio2 );
1722
1726
if (tree_remove_node (iter_prio2 )) {
1723
- mlx5_core_warn (dev ,
1727
+ mlx5_core_warn (steering -> dev ,
1724
1728
"Priority %d wasn't destroyed, refcount > 1\n" ,
1725
1729
obj_iter_prio2 -> prio );
1726
1730
return ;
@@ -1737,7 +1741,7 @@ static void cleanup_root_ns(struct mlx5_core_dev *dev)
1737
1741
struct fs_node ,
1738
1742
list );
1739
1743
if (tree_remove_node (iter_ns )) {
1740
- mlx5_core_warn (dev ,
1744
+ mlx5_core_warn (steering -> dev ,
1741
1745
"Namespace wasn't destroyed, refcount > 1\n" );
1742
1746
return ;
1743
1747
}
@@ -1754,78 +1758,83 @@ static void cleanup_root_ns(struct mlx5_core_dev *dev)
1754
1758
1755
1759
fs_get_obj (obj_prio_node , prio_node );
1756
1760
if (tree_remove_node (prio_node )) {
1757
- mlx5_core_warn (dev ,
1761
+ mlx5_core_warn (steering -> dev ,
1758
1762
"Priority %d wasn't destroyed, refcount > 1\n" ,
1759
1763
obj_prio_node -> prio );
1760
1764
return ;
1761
1765
}
1762
1766
}
1763
1767
1764
1768
if (tree_remove_node (& root_ns -> ns .node )) {
1765
- mlx5_core_warn (dev ,
1769
+ mlx5_core_warn (steering -> dev ,
1766
1770
"root namespace wasn't destroyed, refcount > 1\n" );
1767
1771
return ;
1768
1772
}
1769
1773
1770
- dev -> priv . root_ns = NULL ;
1774
+ steering -> root_ns = NULL ;
1771
1775
}
1772
1776
1773
1777
void mlx5_cleanup_fs (struct mlx5_core_dev * dev )
1774
1778
{
1779
+ struct mlx5_flow_steering * steering = dev -> priv .steering ;
1780
+
1775
1781
if (MLX5_CAP_GEN (dev , port_type ) != MLX5_CAP_PORT_TYPE_ETH )
1776
1782
return ;
1777
1783
1778
- cleanup_root_ns (dev );
1779
- cleanup_single_prio_root_ns (dev , dev -> priv . fdb_root_ns );
1780
- cleanup_single_prio_root_ns (dev , dev -> priv . esw_egress_root_ns );
1781
- cleanup_single_prio_root_ns (dev , dev -> priv . esw_ingress_root_ns );
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 );
1782
1788
mlx5_cleanup_fc_stats (dev );
1789
+ kfree (steering );
1783
1790
}
1784
1791
1785
- static int init_fdb_root_ns (struct mlx5_core_dev * dev )
1792
+ static int init_fdb_root_ns (struct mlx5_flow_steering * steering )
1786
1793
{
1787
1794
struct fs_prio * prio ;
1788
1795
1789
- dev -> priv . fdb_root_ns = create_root_ns (dev , FS_FT_FDB );
1790
- if (!dev -> priv . fdb_root_ns )
1796
+ steering -> fdb_root_ns = create_root_ns (steering , FS_FT_FDB );
1797
+ if (!steering -> fdb_root_ns )
1791
1798
return - ENOMEM ;
1792
1799
1793
1800
/* Create single prio */
1794
- prio = fs_create_prio (& dev -> priv . fdb_root_ns -> ns , 0 , 1 );
1801
+ prio = fs_create_prio (& steering -> fdb_root_ns -> ns , 0 , 1 );
1795
1802
if (IS_ERR (prio )) {
1796
- cleanup_single_prio_root_ns (dev , dev -> priv . fdb_root_ns );
1803
+ cleanup_single_prio_root_ns (steering , steering -> fdb_root_ns );
1797
1804
return PTR_ERR (prio );
1798
1805
} else {
1799
1806
return 0 ;
1800
1807
}
1801
1808
}
1802
1809
1803
- static int init_egress_acl_root_ns (struct mlx5_core_dev * dev )
1810
+ static int init_ingress_acl_root_ns (struct mlx5_flow_steering * steering )
1804
1811
{
1805
1812
struct fs_prio * prio ;
1806
1813
1807
- dev -> priv . esw_egress_root_ns = create_root_ns (dev , FS_FT_ESW_EGRESS_ACL );
1808
- if (!dev -> priv . esw_egress_root_ns )
1814
+ steering -> esw_egress_root_ns = create_root_ns (steering , FS_FT_ESW_EGRESS_ACL );
1815
+ if (!steering -> esw_egress_root_ns )
1809
1816
return - ENOMEM ;
1810
1817
1811
1818
/* create 1 prio*/
1812
- prio = fs_create_prio (& dev -> priv .esw_egress_root_ns -> ns , 0 , MLX5_TOTAL_VPORTS (dev ));
1819
+ prio = fs_create_prio (& steering -> esw_egress_root_ns -> ns , 0 ,
1820
+ MLX5_TOTAL_VPORTS (steering -> dev ));
1813
1821
if (IS_ERR (prio ))
1814
1822
return PTR_ERR (prio );
1815
1823
else
1816
1824
return 0 ;
1817
1825
}
1818
1826
1819
- static int init_ingress_acl_root_ns (struct mlx5_core_dev * dev )
1827
+ static int init_egress_acl_root_ns (struct mlx5_flow_steering * steering )
1820
1828
{
1821
1829
struct fs_prio * prio ;
1822
1830
1823
- dev -> priv . esw_ingress_root_ns = create_root_ns (dev , FS_FT_ESW_INGRESS_ACL );
1824
- if (!dev -> priv . esw_ingress_root_ns )
1831
+ steering -> esw_ingress_root_ns = create_root_ns (steering , FS_FT_ESW_INGRESS_ACL );
1832
+ if (!steering -> esw_ingress_root_ns )
1825
1833
return - ENOMEM ;
1826
1834
1827
1835
/* create 1 prio*/
1828
- prio = fs_create_prio (& dev -> priv .esw_ingress_root_ns -> ns , 0 , MLX5_TOTAL_VPORTS (dev ));
1836
+ prio = fs_create_prio (& steering -> esw_ingress_root_ns -> ns , 0 ,
1837
+ MLX5_TOTAL_VPORTS (steering -> dev ));
1829
1838
if (IS_ERR (prio ))
1830
1839
return PTR_ERR (prio );
1831
1840
else
@@ -1834,6 +1843,7 @@ static int init_ingress_acl_root_ns(struct mlx5_core_dev *dev)
1834
1843
1835
1844
int mlx5_init_fs (struct mlx5_core_dev * dev )
1836
1845
{
1846
+ struct mlx5_flow_steering * steering ;
1837
1847
int err = 0 ;
1838
1848
1839
1849
if (MLX5_CAP_GEN (dev , port_type ) != MLX5_CAP_PORT_TYPE_ETH )
@@ -1843,26 +1853,32 @@ int mlx5_init_fs(struct mlx5_core_dev *dev)
1843
1853
if (err )
1844
1854
return err ;
1845
1855
1856
+ steering = kzalloc (sizeof (* steering ), GFP_KERNEL );
1857
+ if (!steering )
1858
+ return - ENOMEM ;
1859
+ steering -> dev = dev ;
1860
+ dev -> priv .steering = steering ;
1861
+
1846
1862
if (MLX5_CAP_GEN (dev , nic_flow_table ) &&
1847
1863
MLX5_CAP_FLOWTABLE_NIC_RX (dev , ft_support )) {
1848
- err = init_root_ns (dev );
1864
+ err = init_root_ns (steering );
1849
1865
if (err )
1850
1866
goto err ;
1851
1867
}
1852
1868
1853
1869
if (MLX5_CAP_GEN (dev , eswitch_flow_table )) {
1854
1870
if (MLX5_CAP_ESW_FLOWTABLE_FDB (dev , ft_support )) {
1855
- err = init_fdb_root_ns (dev );
1871
+ err = init_fdb_root_ns (steering );
1856
1872
if (err )
1857
1873
goto err ;
1858
1874
}
1859
1875
if (MLX5_CAP_ESW_EGRESS_ACL (dev , ft_support )) {
1860
- err = init_egress_acl_root_ns (dev );
1876
+ err = init_egress_acl_root_ns (steering );
1861
1877
if (err )
1862
1878
goto err ;
1863
1879
}
1864
1880
if (MLX5_CAP_ESW_INGRESS_ACL (dev , ft_support )) {
1865
- err = init_ingress_acl_root_ns (dev );
1881
+ err = init_ingress_acl_root_ns (steering );
1866
1882
if (err )
1867
1883
goto err ;
1868
1884
}
0 commit comments