Commit 74b6ba0d authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: mv88e6xxx: extract single FDB dump

Move out the code which dumps a single FDB to its own function.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2fb5ef09
...@@ -1895,42 +1895,24 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid, ...@@ -1895,42 +1895,24 @@ static int _mv88e6xxx_atu_getnext(struct dsa_switch *ds, u16 fid,
return 0; return 0;
} }
int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, static int _mv88e6xxx_port_fdb_dump_one(struct dsa_switch *ds, u16 fid, u16 vid,
int port,
struct switchdev_obj_port_fdb *fdb, struct switchdev_obj_port_fdb *fdb,
int (*cb)(struct switchdev_obj *obj)) int (*cb)(struct switchdev_obj *obj))
{ {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
struct mv88e6xxx_vtu_stu_entry vlan = {
.vid = GLOBAL_VTU_VID_MASK, /* all ones */
};
int err;
mutex_lock(&ps->smi_mutex);
err = _mv88e6xxx_vtu_vid_write(ds, vlan.vid);
if (err)
goto unlock;
do {
struct mv88e6xxx_atu_entry addr = { struct mv88e6xxx_atu_entry addr = {
.mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, .mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
}; };
int err;
err = _mv88e6xxx_vtu_getnext(ds, &vlan);
if (err)
goto unlock;
if (!vlan.valid)
break;
err = _mv88e6xxx_atu_mac_write(ds, addr.mac); err = _mv88e6xxx_atu_mac_write(ds, addr.mac);
if (err) if (err)
goto unlock; return err;
do { do {
err = _mv88e6xxx_atu_getnext(ds, vlan.fid, &addr); err = _mv88e6xxx_atu_getnext(ds, fid, &addr);
if (err) if (err)
goto unlock; break;
if (addr.state == GLOBAL_ATU_DATA_STATE_UNUSED) if (addr.state == GLOBAL_ATU_DATA_STATE_UNUSED)
break; break;
...@@ -1941,17 +1923,48 @@ int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, ...@@ -1941,17 +1923,48 @@ int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
GLOBAL_ATU_DATA_STATE_MC_STATIC : GLOBAL_ATU_DATA_STATE_MC_STATIC :
GLOBAL_ATU_DATA_STATE_UC_STATIC); GLOBAL_ATU_DATA_STATE_UC_STATIC);
fdb->vid = vlan.vid; fdb->vid = vid;
ether_addr_copy(fdb->addr, addr.mac); ether_addr_copy(fdb->addr, addr.mac);
fdb->ndm_state = is_static ? NUD_NOARP : fdb->ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE;
NUD_REACHABLE;
err = cb(&fdb->obj); err = cb(&fdb->obj);
if (err) if (err)
goto unlock; break;
} }
} while (!is_broadcast_ether_addr(addr.mac)); } 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))
{
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
struct mv88e6xxx_vtu_stu_entry vlan = {
.vid = GLOBAL_VTU_VID_MASK, /* all ones */
};
int err;
mutex_lock(&ps->smi_mutex);
/* Dump VLANs' Filtering Information Databases */
err = _mv88e6xxx_vtu_vid_write(ds, vlan.vid);
if (err)
goto unlock;
do {
err = _mv88e6xxx_vtu_getnext(ds, &vlan);
if (err)
break;
if (!vlan.valid)
break;
err = _mv88e6xxx_port_fdb_dump_one(ds, vlan.fid, vlan.vid, port,
fdb, cb);
if (err)
break;
} while (vlan.vid < GLOBAL_VTU_VID_MASK); } while (vlan.vid < GLOBAL_VTU_VID_MASK);
unlock: unlock:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment