@@ -1259,7 +1259,13 @@ static int _mv88e6xxx_vtu_stu_data_write(struct dsa_switch *ds,
1259
1259
return 0 ;
1260
1260
}
1261
1261
1262
- static int _mv88e6xxx_vtu_getnext (struct dsa_switch * ds , u16 vid ,
1262
+ static int _mv88e6xxx_vtu_vid_write (struct dsa_switch * ds , u16 vid )
1263
+ {
1264
+ return _mv88e6xxx_reg_write (ds , REG_GLOBAL , GLOBAL_VTU_VID ,
1265
+ vid & GLOBAL_VTU_VID_MASK );
1266
+ }
1267
+
1268
+ static int _mv88e6xxx_vtu_getnext (struct dsa_switch * ds ,
1263
1269
struct mv88e6xxx_vtu_stu_entry * entry )
1264
1270
{
1265
1271
struct mv88e6xxx_vtu_stu_entry next = { 0 };
@@ -1269,11 +1275,6 @@ static int _mv88e6xxx_vtu_getnext(struct dsa_switch *ds, u16 vid,
1269
1275
if (ret < 0 )
1270
1276
return ret ;
1271
1277
1272
- ret = _mv88e6xxx_reg_write (ds , REG_GLOBAL , GLOBAL_VTU_VID ,
1273
- vid & GLOBAL_VTU_VID_MASK );
1274
- if (ret < 0 )
1275
- return ret ;
1276
-
1277
1278
ret = _mv88e6xxx_vtu_cmd (ds , GLOBAL_VTU_OP_VTU_GET_NEXT );
1278
1279
if (ret < 0 )
1279
1280
return ret ;
@@ -1485,7 +1486,12 @@ int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, u16 vid,
1485
1486
int err ;
1486
1487
1487
1488
mutex_lock (& ps -> smi_mutex );
1488
- err = _mv88e6xxx_vtu_getnext (ds , vid - 1 , & vlan );
1489
+
1490
+ err = _mv88e6xxx_vtu_vid_write (ds , vid - 1 );
1491
+ if (err )
1492
+ goto unlock ;
1493
+
1494
+ err = _mv88e6xxx_vtu_getnext (ds , & vlan );
1489
1495
if (err )
1490
1496
goto unlock ;
1491
1497
@@ -1514,7 +1520,11 @@ int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, u16 vid)
1514
1520
1515
1521
mutex_lock (& ps -> smi_mutex );
1516
1522
1517
- err = _mv88e6xxx_vtu_getnext (ds , vid - 1 , & vlan );
1523
+ err = _mv88e6xxx_vtu_vid_write (ds , vid - 1 );
1524
+ if (err )
1525
+ goto unlock ;
1526
+
1527
+ err = _mv88e6xxx_vtu_getnext (ds , & vlan );
1518
1528
if (err )
1519
1529
goto unlock ;
1520
1530
@@ -1549,29 +1559,6 @@ int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, u16 vid)
1549
1559
return err ;
1550
1560
}
1551
1561
1552
- static int _mv88e6xxx_port_vtu_getnext (struct dsa_switch * ds , int port , u16 vid ,
1553
- struct mv88e6xxx_vtu_stu_entry * entry )
1554
- {
1555
- int err ;
1556
-
1557
- do {
1558
- if (vid == 4095 )
1559
- return - ENOENT ;
1560
-
1561
- err = _mv88e6xxx_vtu_getnext (ds , vid , entry );
1562
- if (err )
1563
- return err ;
1564
-
1565
- if (!entry -> valid )
1566
- return - ENOENT ;
1567
-
1568
- vid = entry -> vid ;
1569
- } while (entry -> data [port ] != GLOBAL_VTU_DATA_MEMBER_TAG_TAGGED &&
1570
- entry -> data [port ] != GLOBAL_VTU_DATA_MEMBER_TAG_UNTAGGED );
1571
-
1572
- return 0 ;
1573
- }
1574
-
1575
1562
int mv88e6xxx_vlan_getnext (struct dsa_switch * ds , u16 * vid ,
1576
1563
unsigned long * ports , unsigned long * untagged )
1577
1564
{
@@ -1584,7 +1571,12 @@ int mv88e6xxx_vlan_getnext(struct dsa_switch *ds, u16 *vid,
1584
1571
return - ENOENT ;
1585
1572
1586
1573
mutex_lock (& ps -> smi_mutex );
1587
- err = _mv88e6xxx_vtu_getnext (ds , * vid , & next );
1574
+ err = _mv88e6xxx_vtu_vid_write (ds , * vid );
1575
+ if (err )
1576
+ goto unlock ;
1577
+
1578
+ err = _mv88e6xxx_vtu_getnext (ds , & next );
1579
+ unlock :
1588
1580
mutex_unlock (& ps -> smi_mutex );
1589
1581
1590
1582
if (err )
@@ -1732,7 +1724,6 @@ int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
1732
1724
}
1733
1725
1734
1726
static int _mv88e6xxx_atu_getnext (struct dsa_switch * ds , u16 fid ,
1735
- const unsigned char * addr ,
1736
1727
struct mv88e6xxx_atu_entry * entry )
1737
1728
{
1738
1729
struct mv88e6xxx_atu_entry next = { 0 };
@@ -1744,10 +1735,6 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid,
1744
1735
if (ret < 0 )
1745
1736
return ret ;
1746
1737
1747
- ret = _mv88e6xxx_atu_mac_write (ds , addr );
1748
- if (ret < 0 )
1749
- return ret ;
1750
-
1751
1738
ret = _mv88e6xxx_reg_write (ds , REG_GLOBAL , GLOBAL_ATU_FID , fid );
1752
1739
if (ret < 0 )
1753
1740
return ret ;
@@ -1785,46 +1772,69 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid,
1785
1772
return 0 ;
1786
1773
}
1787
1774
1788
- /* get next entry for port */
1789
- int mv88e6xxx_port_fdb_getnext ( struct dsa_switch * ds , int port ,
1790
- unsigned char * addr , u16 * vid , bool * is_static )
1775
+ int mv88e6xxx_port_fdb_dump ( struct dsa_switch * ds , int port ,
1776
+ struct switchdev_obj_port_fdb * fdb ,
1777
+ int ( * cb )( struct switchdev_obj * obj ) )
1791
1778
{
1792
1779
struct mv88e6xxx_priv_state * ps = ds_to_priv (ds );
1793
- struct mv88e6xxx_atu_entry next ;
1794
- u16 fid = * vid ; /* We use one FID per VLAN */
1795
- int ret ;
1780
+ struct mv88e6xxx_vtu_stu_entry vlan = {
1781
+ .vid = GLOBAL_VTU_VID_MASK , /* all ones */
1782
+ };
1783
+ int err ;
1796
1784
1797
1785
mutex_lock (& ps -> smi_mutex );
1798
1786
1787
+ err = _mv88e6xxx_vtu_vid_write (ds , vlan .vid );
1788
+ if (err )
1789
+ goto unlock ;
1790
+
1799
1791
do {
1800
- if (is_broadcast_ether_addr (addr )) {
1801
- struct mv88e6xxx_vtu_stu_entry vtu ;
1792
+ struct mv88e6xxx_atu_entry addr = {
1793
+ .mac = { 0xff , 0xff , 0xff , 0xff , 0xff , 0xff },
1794
+ };
1802
1795
1803
- ret = _mv88e6xxx_port_vtu_getnext (ds , port , * vid , & vtu );
1804
- if (ret < 0 )
1805
- goto unlock ;
1796
+ err = _mv88e6xxx_vtu_getnext (ds , & vlan );
1797
+ if (err )
1798
+ goto unlock ;
1806
1799
1807
- * vid = vtu .vid ;
1808
- fid = vtu .fid ;
1809
- }
1800
+ if (!vlan .valid )
1801
+ break ;
1810
1802
1811
- ret = _mv88e6xxx_atu_getnext (ds , fid , addr , & next );
1812
- if (ret < 0 )
1803
+ err = _mv88e6xxx_atu_mac_write (ds , addr . mac );
1804
+ if (err )
1813
1805
goto unlock ;
1814
1806
1815
- ether_addr_copy (addr , next .mac );
1807
+ do {
1808
+ err = _mv88e6xxx_atu_getnext (ds , vlan .fid , & addr );
1809
+ if (err )
1810
+ goto unlock ;
1816
1811
1817
- if (next .state == GLOBAL_ATU_DATA_STATE_UNUSED )
1818
- continue ;
1819
- } while (next .trunk || (next .portv_trunkid & BIT (port )) == 0 );
1812
+ if (addr .state == GLOBAL_ATU_DATA_STATE_UNUSED )
1813
+ break ;
1814
+
1815
+ if (!addr .trunk && addr .portv_trunkid & BIT (port )) {
1816
+ bool is_static = addr .state ==
1817
+ (is_multicast_ether_addr (addr .mac ) ?
1818
+ GLOBAL_ATU_DATA_STATE_MC_STATIC :
1819
+ GLOBAL_ATU_DATA_STATE_UC_STATIC );
1820
+
1821
+ fdb -> vid = vlan .vid ;
1822
+ ether_addr_copy (fdb -> addr , addr .mac );
1823
+ fdb -> ndm_state = is_static ? NUD_NOARP :
1824
+ NUD_REACHABLE ;
1825
+
1826
+ err = cb (& fdb -> obj );
1827
+ if (err )
1828
+ goto unlock ;
1829
+ }
1830
+ } while (!is_broadcast_ether_addr (addr .mac ));
1831
+
1832
+ } while (vlan .vid < GLOBAL_VTU_VID_MASK );
1820
1833
1821
- * is_static = next .state == (is_multicast_ether_addr (addr ) ?
1822
- GLOBAL_ATU_DATA_STATE_MC_STATIC :
1823
- GLOBAL_ATU_DATA_STATE_UC_STATIC );
1824
1834
unlock :
1825
1835
mutex_unlock (& ps -> smi_mutex );
1826
1836
1827
- return ret ;
1837
+ return err ;
1828
1838
}
1829
1839
1830
1840
static void mv88e6xxx_bridge_work (struct work_struct * work )
0 commit comments