net: dsa: mv88e6xxx: enable ATU Learn2All
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Sat, 11 Mar 2017 21:12:51 +0000 (16:12 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Mar 2017 06:54:05 +0000 (23:54 -0700)
The ATU Learn2All feature allows newly learnt addresses to be spanned on
ports marked as "Message Port", currently all DSA ports.

This commit enables this feature which is necessary and quite convenient
for multi-chip switch fabrics.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/global1.h
drivers/net/dsa/mv88e6xxx/global1_atu.c

index 5c1b5825fe6c4f957778178bf3944c752773dd53..1ee0c05f624e8ffd1217f9ea619e4d704e63b2a0 100644 (file)
@@ -1308,6 +1308,12 @@ static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
 
 static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
 {
+       int err;
+
+       err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
+       if (err)
+               return err;
+
        return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
 }
 
@@ -2756,15 +2762,6 @@ static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
        if (err < 0)
                return err;
 
-       /* Set the default address aging time to 5 minutes, and
-        * enable address learn messages to be sent to all message
-        * ports.
-        */
-       err = mv88e6xxx_g1_write(chip, GLOBAL_ATU_CONTROL,
-                                GLOBAL_ATU_CONTROL_LEARN2ALL);
-       if (err)
-               return err;
-
        /* Clear all ATU entries */
        err = _mv88e6xxx_atu_flush(chip, 0, true);
        if (err)
index b8d0fb519babd8dba6aa2b4f72511caadcd7065a..18322d05225af278d8fc362b8b1e1e9c7333602d 100644 (file)
@@ -38,6 +38,7 @@ int mv88e6095_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port);
 int mv88e6390_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port);
 int mv88e6390_g1_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip);
 
+int mv88e6xxx_g1_atu_set_learn2all(struct mv88e6xxx_chip *chip, bool learn2all);
 int mv88e6xxx_g1_atu_set_age_time(struct mv88e6xxx_chip *chip,
                                  unsigned int msecs);
 
index 4d0ada9efc6ddada9260ead1f657567aa3851d4b..843a21e05f7ba8ef56572fb3d7d86c9a3c003c7b 100644 (file)
 
 /* Offset 0x0A: ATU Control Register */
 
+int mv88e6xxx_g1_atu_set_learn2all(struct mv88e6xxx_chip *chip, bool learn2all)
+{
+       u16 val;
+       int err;
+
+       err = mv88e6xxx_g1_read(chip, GLOBAL_ATU_CONTROL, &val);
+       if (err)
+               return err;
+
+       if (learn2all)
+               val |= GLOBAL_ATU_CONTROL_LEARN2ALL;
+       else
+               val &= ~GLOBAL_ATU_CONTROL_LEARN2ALL;
+
+       return mv88e6xxx_g1_write(chip, GLOBAL_ATU_CONTROL, val);
+}
+
 int mv88e6xxx_g1_atu_set_age_time(struct mv88e6xxx_chip *chip,
                                  unsigned int msecs)
 {