Commit 90b6dbdf authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: dsa: mv88e6xxx: Create helper for FIDs in use

Refactor the code in mv88e6xxx_atu_new() which builds a bitmaps of
FIDs in use into a helper function. This will be reused by the devlink
code when dumping the ATU.
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9dd43aa2
...@@ -1466,21 +1466,21 @@ static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip, ...@@ -1466,21 +1466,21 @@ static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
return chip->info->ops->vtu_loadpurge(chip, entry); return chip->info->ops->vtu_loadpurge(chip, entry);
} }
static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap)
{ {
DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
struct mv88e6xxx_vtu_entry vlan; struct mv88e6xxx_vtu_entry vlan;
int i, err; int i, err;
u16 fid;
bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
/* Set every FID bit used by the (un)bridged ports */ /* Set every FID bit used by the (un)bridged ports */
for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
err = mv88e6xxx_port_get_fid(chip, i, fid); err = mv88e6xxx_port_get_fid(chip, i, &fid);
if (err) if (err)
return err; return err;
set_bit(*fid, fid_bitmap); set_bit(fid, fid_bitmap);
} }
/* Set every FID bit used by the VLAN entries */ /* Set every FID bit used by the VLAN entries */
...@@ -1498,6 +1498,18 @@ static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) ...@@ -1498,6 +1498,18 @@ static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
set_bit(vlan.fid, fid_bitmap); set_bit(vlan.fid, fid_bitmap);
} while (vlan.vid < chip->info->max_vid); } while (vlan.vid < chip->info->max_vid);
return 0;
}
static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
{
DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
int err;
err = mv88e6xxx_fid_map(chip, fid_bitmap);
if (err)
return err;
/* The reset value 0x000 is used to indicate that multiple address /* The reset value 0x000 is used to indicate that multiple address
* databases are not needed. Return the next positive available. * databases are not needed. Return the next positive available.
*/ */
......
...@@ -689,4 +689,6 @@ static inline void mv88e6xxx_reg_unlock(struct mv88e6xxx_chip *chip) ...@@ -689,4 +689,6 @@ static inline void mv88e6xxx_reg_unlock(struct mv88e6xxx_chip *chip)
mutex_unlock(&chip->reg_lock); mutex_unlock(&chip->reg_lock);
} }
int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *bitmap);
#endif /* _MV88E6XXX_CHIP_H */ #endif /* _MV88E6XXX_CHIP_H */
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