Skip to content

Commit f33475b

Browse files
viviendavem330
authored andcommitted
net: dsa: mv88e6xxx: implement port_fdb_dump
Implement the port_fdb_dump DSA operation. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b0e1a69 commit f33475b

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

drivers/net/dsa/mv88e6171.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ struct dsa_switch_driver mv88e6171_switch_driver = {
123123
.port_fdb_add = mv88e6xxx_port_fdb_add,
124124
.port_fdb_del = mv88e6xxx_port_fdb_del,
125125
.port_fdb_getnext = mv88e6xxx_port_fdb_getnext,
126+
.port_fdb_dump = mv88e6xxx_port_fdb_dump,
126127
};
127128

128129
MODULE_ALIAS("platform:mv88e6171");

drivers/net/dsa/mv88e6352.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ struct dsa_switch_driver mv88e6352_switch_driver = {
350350
.port_fdb_add = mv88e6xxx_port_fdb_add,
351351
.port_fdb_del = mv88e6xxx_port_fdb_del,
352352
.port_fdb_getnext = mv88e6xxx_port_fdb_getnext,
353+
.port_fdb_dump = mv88e6xxx_port_fdb_dump,
353354
};
354355

355356
MODULE_ALIAS("platform:mv88e6172");

drivers/net/dsa/mv88e6xxx.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,71 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid,
17991799
return 0;
18001800
}
18011801

1802+
int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
1803+
struct switchdev_obj_port_fdb *fdb,
1804+
int (*cb)(struct switchdev_obj *obj))
1805+
{
1806+
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
1807+
struct mv88e6xxx_vtu_stu_entry vlan = {
1808+
.vid = GLOBAL_VTU_VID_MASK, /* all ones */
1809+
};
1810+
int err;
1811+
1812+
mutex_lock(&ps->smi_mutex);
1813+
1814+
err = _mv88e6xxx_vtu_vid_write(ds, vlan.vid);
1815+
if (err)
1816+
goto unlock;
1817+
1818+
do {
1819+
struct mv88e6xxx_atu_entry addr = {
1820+
.mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1821+
};
1822+
1823+
err = _mv88e6xxx_vtu_getnext(ds, &vlan);
1824+
if (err)
1825+
goto unlock;
1826+
1827+
if (!vlan.valid)
1828+
break;
1829+
1830+
err = _mv88e6xxx_atu_mac_write(ds, addr.mac);
1831+
if (err)
1832+
goto unlock;
1833+
1834+
do {
1835+
err = _mv88e6xxx_atu_getnext(ds, vlan.fid, &addr);
1836+
if (err)
1837+
goto unlock;
1838+
1839+
if (addr.state == GLOBAL_ATU_DATA_STATE_UNUSED)
1840+
break;
1841+
1842+
if (!addr.trunk && addr.portv_trunkid & BIT(port)) {
1843+
bool is_static = addr.state ==
1844+
(is_multicast_ether_addr(addr.mac) ?
1845+
GLOBAL_ATU_DATA_STATE_MC_STATIC :
1846+
GLOBAL_ATU_DATA_STATE_UC_STATIC);
1847+
1848+
fdb->vid = vlan.vid;
1849+
ether_addr_copy(fdb->addr, addr.mac);
1850+
fdb->ndm_state = is_static ? NUD_NOARP :
1851+
NUD_REACHABLE;
1852+
1853+
err = cb(&fdb->obj);
1854+
if (err)
1855+
goto unlock;
1856+
}
1857+
} while (!is_broadcast_ether_addr(addr.mac));
1858+
1859+
} while (vlan.vid < GLOBAL_VTU_VID_MASK);
1860+
1861+
unlock:
1862+
mutex_unlock(&ps->smi_mutex);
1863+
1864+
return err;
1865+
}
1866+
18021867
/* get next entry for port */
18031868
int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
18041869
unsigned char *addr, u16 *vid, bool *is_static)

drivers/net/dsa/mv88e6xxx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
476476
const struct switchdev_obj_port_fdb *fdb);
477477
int mv88e6xxx_port_fdb_getnext(struct dsa_switch *ds, int port,
478478
unsigned char *addr, u16 *vid, bool *is_static);
479+
int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
480+
struct switchdev_obj_port_fdb *fdb,
481+
int (*cb)(struct switchdev_obj *obj));
479482
int mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int page, int reg);
480483
int mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page,
481484
int reg, int val);

0 commit comments

Comments
 (0)