net: dsa: mv88e6xxx: move VTU flush
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Mon, 1 May 2017 18:05:13 +0000 (14:05 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 1 May 2017 19:03:09 +0000 (15:03 -0400)
Move the VTU flush operation to global1_vtu.c and call it from a
mv88e6xxx_vtu_setup helper, similarly to the ATU and PVT setup.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
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_vtu.c

index bf03504323374640a6057cabb05e83e60cefecac..d244c22831380a88f7e70de49f3c9373faf01142 100644 (file)
@@ -1263,17 +1263,6 @@ static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
                netdev_err(ds->ports[port].netdev, "failed to flush ATU\n");
 }
 
-static int _mv88e6xxx_vtu_stu_flush(struct mv88e6xxx_chip *chip)
-{
-       int ret;
-
-       ret = mv88e6xxx_g1_vtu_op_wait(chip);
-       if (ret < 0)
-               return ret;
-
-       return mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_FLUSH_ALL);
-}
-
 static int _mv88e6xxx_vtu_stu_data_read(struct mv88e6xxx_chip *chip,
                                        struct mv88e6xxx_vtu_entry *entry,
                                        unsigned int nibble_offset)
@@ -1412,6 +1401,14 @@ static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
        return 0;
 }
 
+static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
+{
+       if (!chip->info->max_vid)
+               return 0;
+
+       return mv88e6xxx_g1_vtu_flush(chip);
+}
+
 static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
                                    struct switchdev_obj_port_vlan *vlan,
                                    int (*cb)(struct switchdev_obj *obj))
@@ -2599,11 +2596,6 @@ static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
        if (err)
                return err;
 
-       /* Clear all the VTU and STU entries */
-       err = _mv88e6xxx_vtu_stu_flush(chip);
-       if (err < 0)
-               return err;
-
        /* Configure the IP ToS mapping registers. */
        err = mv88e6xxx_g1_write(chip, GLOBAL_IP_PRI_0, 0x0000);
        if (err)
@@ -2684,6 +2676,10 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
                        goto unlock;
        }
 
+       err = mv88e6xxx_vtu_setup(chip);
+       if (err)
+               goto unlock;
+
        err = mv88e6xxx_pvt_setup(chip);
        if (err)
                goto unlock;
index c153d07d2065e41f3d1bba7b5c12b101953a8981..ed40e5557bbc9af711bf3ab30437ebd0aa531eeb 100644 (file)
@@ -52,5 +52,6 @@ int mv88e6xxx_g1_atu_remove(struct mv88e6xxx_chip *chip, u16 fid, int port,
 
 int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip);
 int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op);
+int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip);
 
 #endif /* _MV88E6XXX_GLOBAL1_H */
index 20dfdcbda238d45436f2585a4a384b6bf217f66c..c41ca28da084e8228c8243ed14a77570c0d1849a 100644 (file)
@@ -31,3 +31,16 @@ int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op)
 
        return mv88e6xxx_g1_vtu_op_wait(chip);
 }
+
+/* VLAN Translation Unit Operations */
+
+int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip)
+{
+       int err;
+
+       err = mv88e6xxx_g1_vtu_op_wait(chip);
+       if (err)
+               return err;
+
+       return mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_FLUSH_ALL);
+}