net: dsa: mv88e6xxx: extract single FDB dump
Move out the code which dumps a single FDB to its own function. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
2fb5ef09de
Коммит
74b6ba0d76
|
@ -1895,6 +1895,47 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int _mv88e6xxx_port_fdb_dump_one(struct dsa_switch *ds, u16 fid, u16 vid,
|
||||
int port,
|
||||
struct switchdev_obj_port_fdb *fdb,
|
||||
int (*cb)(struct switchdev_obj *obj))
|
||||
{
|
||||
struct mv88e6xxx_atu_entry addr = {
|
||||
.mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
|
||||
};
|
||||
int err;
|
||||
|
||||
err = _mv88e6xxx_atu_mac_write(ds, addr.mac);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
do {
|
||||
err = _mv88e6xxx_atu_getnext(ds, fid, &addr);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
if (addr.state == GLOBAL_ATU_DATA_STATE_UNUSED)
|
||||
break;
|
||||
|
||||
if (!addr.trunk && addr.portv_trunkid & BIT(port)) {
|
||||
bool is_static = addr.state ==
|
||||
(is_multicast_ether_addr(addr.mac) ?
|
||||
GLOBAL_ATU_DATA_STATE_MC_STATIC :
|
||||
GLOBAL_ATU_DATA_STATE_UC_STATIC);
|
||||
|
||||
fdb->vid = vid;
|
||||
ether_addr_copy(fdb->addr, addr.mac);
|
||||
fdb->ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE;
|
||||
|
||||
err = cb(&fdb->obj);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
} while (!is_broadcast_ether_addr(addr.mac));
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
|
||||
struct switchdev_obj_port_fdb *fdb,
|
||||
int (*cb)(struct switchdev_obj *obj))
|
||||
|
@ -1907,51 +1948,23 @@ int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
|
|||
|
||||
mutex_lock(&ps->smi_mutex);
|
||||
|
||||
/* Dump VLANs' Filtering Information Databases */
|
||||
err = _mv88e6xxx_vtu_vid_write(ds, vlan.vid);
|
||||
if (err)
|
||||
goto unlock;
|
||||
|
||||
do {
|
||||
struct mv88e6xxx_atu_entry addr = {
|
||||
.mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
|
||||
};
|
||||
|
||||
err = _mv88e6xxx_vtu_getnext(ds, &vlan);
|
||||
if (err)
|
||||
goto unlock;
|
||||
break;
|
||||
|
||||
if (!vlan.valid)
|
||||
break;
|
||||
|
||||
err = _mv88e6xxx_atu_mac_write(ds, addr.mac);
|
||||
err = _mv88e6xxx_port_fdb_dump_one(ds, vlan.fid, vlan.vid, port,
|
||||
fdb, cb);
|
||||
if (err)
|
||||
goto unlock;
|
||||
|
||||
do {
|
||||
err = _mv88e6xxx_atu_getnext(ds, vlan.fid, &addr);
|
||||
if (err)
|
||||
goto unlock;
|
||||
|
||||
if (addr.state == GLOBAL_ATU_DATA_STATE_UNUSED)
|
||||
break;
|
||||
|
||||
if (!addr.trunk && addr.portv_trunkid & BIT(port)) {
|
||||
bool is_static = addr.state ==
|
||||
(is_multicast_ether_addr(addr.mac) ?
|
||||
GLOBAL_ATU_DATA_STATE_MC_STATIC :
|
||||
GLOBAL_ATU_DATA_STATE_UC_STATIC);
|
||||
|
||||
fdb->vid = vlan.vid;
|
||||
ether_addr_copy(fdb->addr, addr.mac);
|
||||
fdb->ndm_state = is_static ? NUD_NOARP :
|
||||
NUD_REACHABLE;
|
||||
|
||||
err = cb(&fdb->obj);
|
||||
if (err)
|
||||
goto unlock;
|
||||
}
|
||||
} while (!is_broadcast_ether_addr(addr.mac));
|
||||
|
||||
break;
|
||||
} while (vlan.vid < GLOBAL_VTU_VID_MASK);
|
||||
|
||||
unlock:
|
||||
|
|
Загрузка…
Ссылка в новой задаче