net: dsa: mv88e6xxx: complete ATU state definitions
Marvell has different values for the state of a MAC address, depending on its multicast bit. This patch completes the definitions for these states. At the same time, use 0 which is intuitive enough and simplifies the code a bit, instead of the UC or MC unused value. Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
c21815f1c1
Коммит
d8291a956a
|
@ -1497,7 +1497,7 @@ static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
|
|||
fid = vlan.fid;
|
||||
}
|
||||
|
||||
entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
|
||||
entry.state = 0;
|
||||
ether_addr_copy(entry.mac, addr);
|
||||
eth_addr_dec(entry.mac);
|
||||
|
||||
|
@ -1506,17 +1506,16 @@ static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
|
|||
return err;
|
||||
|
||||
/* Initialize a fresh ATU entry if it isn't found */
|
||||
if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
|
||||
!ether_addr_equal(entry.mac, addr)) {
|
||||
if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
|
||||
memset(&entry, 0, sizeof(entry));
|
||||
ether_addr_copy(entry.mac, addr);
|
||||
}
|
||||
|
||||
/* Purge the ATU entry only if no port is using it anymore */
|
||||
if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
|
||||
if (!state) {
|
||||
entry.portvec &= ~BIT(port);
|
||||
if (!entry.portvec)
|
||||
entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
|
||||
entry.state = 0;
|
||||
} else {
|
||||
entry.portvec |= BIT(port);
|
||||
entry.state = state;
|
||||
|
@ -1732,8 +1731,7 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
|
|||
int err;
|
||||
|
||||
mv88e6xxx_reg_lock(chip);
|
||||
err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
|
||||
MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
|
||||
err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
|
||||
mv88e6xxx_reg_unlock(chip);
|
||||
|
||||
return err;
|
||||
|
@ -1747,7 +1745,7 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
|
|||
bool is_static;
|
||||
int err;
|
||||
|
||||
addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
|
||||
addr.state = 0;
|
||||
eth_broadcast_addr(addr.mac);
|
||||
|
||||
do {
|
||||
|
@ -1755,7 +1753,7 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
|
||||
if (!addr.state)
|
||||
break;
|
||||
|
||||
if (addr.trunk || (addr.portvec & BIT(port)) == 0)
|
||||
|
@ -4690,8 +4688,7 @@ static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
|
|||
int err;
|
||||
|
||||
mv88e6xxx_reg_lock(chip);
|
||||
err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
|
||||
MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
|
||||
err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
|
||||
mv88e6xxx_reg_unlock(chip);
|
||||
|
||||
return err;
|
||||
|
|
|
@ -128,19 +128,36 @@
|
|||
#define MV88E6XXX_G1_ATU_OP_FULL_VIOLATION BIT(4)
|
||||
|
||||
/* Offset 0x0C: ATU Data Register */
|
||||
#define MV88E6XXX_G1_ATU_DATA 0x0c
|
||||
#define MV88E6XXX_G1_ATU_DATA_TRUNK 0x8000
|
||||
#define MV88E6XXX_G1_ATU_DATA_TRUNK_ID_MASK 0x00f0
|
||||
#define MV88E6XXX_G1_ATU_DATA_PORT_VECTOR_MASK 0x3ff0
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MASK 0x000f
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UNUSED 0x0000
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_MGMT 0x000d
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC 0x000e
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_PRIO_OVER 0x000f
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_NONE_RATE 0x0005
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC 0x0007
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_MGMT 0x000e
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_PRIO_OVER 0x000f
|
||||
#define MV88E6XXX_G1_ATU_DATA 0x0c
|
||||
#define MV88E6XXX_G1_ATU_DATA_TRUNK 0x8000
|
||||
#define MV88E6XXX_G1_ATU_DATA_TRUNK_ID_MASK 0x00f0
|
||||
#define MV88E6XXX_G1_ATU_DATA_PORT_VECTOR_MASK 0x3ff0
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MASK 0x000f
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_UNUSED 0x0000
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_1_OLDEST 0x0001
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_2 0x0002
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_3 0x0003
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_4 0x0004
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_5 0x0005
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_6 0x0006
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_7_NEWEST 0x0007
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY 0x0008
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY_PO 0x0009
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_AVB_NRL 0x000a
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_AVB_NRL_PO 0x000b
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_DA_MGMT 0x000c
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_DA_MGMT_PO 0x000d
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC 0x000e
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_PO 0x000f
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_UNUSED 0x0000
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY 0x0004
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_AVB_NRL 0x0005
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_DA_MGMT 0x0006
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC 0x0007
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY_PO 0x000c
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_AVB_NRL_PO 0x000d
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_DA_MGMT_PO 0x000e
|
||||
#define MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_PO 0x000f
|
||||
|
||||
/* Offset 0x0D: ATU MAC Address Register Bytes 0 & 1
|
||||
* Offset 0x0E: ATU MAC Address Register Bytes 2 & 3
|
||||
|
|
|
@ -135,7 +135,7 @@ static int mv88e6xxx_g1_atu_data_read(struct mv88e6xxx_chip *chip,
|
|||
return err;
|
||||
|
||||
entry->state = val & 0xf;
|
||||
if (entry->state != MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
|
||||
if (entry->state) {
|
||||
entry->trunk = !!(val & MV88E6XXX_G1_ATU_DATA_TRUNK);
|
||||
entry->portvec = (val >> 4) & mv88e6xxx_port_mask(chip);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ static int mv88e6xxx_g1_atu_data_write(struct mv88e6xxx_chip *chip,
|
|||
{
|
||||
u16 data = entry->state & 0xf;
|
||||
|
||||
if (entry->state != MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
|
||||
if (entry->state) {
|
||||
if (entry->trunk)
|
||||
data |= MV88E6XXX_G1_ATU_DATA_TRUNK;
|
||||
|
||||
|
@ -209,7 +209,7 @@ int mv88e6xxx_g1_atu_getnext(struct mv88e6xxx_chip *chip, u16 fid,
|
|||
return err;
|
||||
|
||||
/* Write the MAC address to iterate from only once */
|
||||
if (entry->state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
|
||||
if (!entry->state) {
|
||||
err = mv88e6xxx_g1_atu_mac_write(chip, entry);
|
||||
if (err)
|
||||
return err;
|
||||
|
|
Загрузка…
Ссылка в новой задаче