aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2017-05-01 14:05:13 -0400
committerDavid S. Miller <davem@davemloft.net>2017-05-01 15:03:09 -0400
commitb486d7c95cc8336aa91813a156f9385439bde2fc (patch)
tree92a1d3a7a915d9f7b94a1290564cd6c56d7afd6e
parent332aa5ccc82005de9441c1b65ca546488c7f8730 (diff)
net: dsa: mv88e6xxx: move VTU flush
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>
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c28
-rw-r--r--drivers/net/dsa/mv88e6xxx/global1.h1
-rw-r--r--drivers/net/dsa/mv88e6xxx/global1_vtu.c13
3 files changed, 26 insertions, 16 deletions
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index bf0350432337..d244c2283138 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1263,17 +1263,6 @@ static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1263 netdev_err(ds->ports[port].netdev, "failed to flush ATU\n"); 1263 netdev_err(ds->ports[port].netdev, "failed to flush ATU\n");
1264} 1264}
1265 1265
1266static int _mv88e6xxx_vtu_stu_flush(struct mv88e6xxx_chip *chip)
1267{
1268 int ret;
1269
1270 ret = mv88e6xxx_g1_vtu_op_wait(chip);
1271 if (ret < 0)
1272 return ret;
1273
1274 return mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_FLUSH_ALL);
1275}
1276
1277static int _mv88e6xxx_vtu_stu_data_read(struct mv88e6xxx_chip *chip, 1266static int _mv88e6xxx_vtu_stu_data_read(struct mv88e6xxx_chip *chip,
1278 struct mv88e6xxx_vtu_entry *entry, 1267 struct mv88e6xxx_vtu_entry *entry,
1279 unsigned int nibble_offset) 1268 unsigned int nibble_offset)
@@ -1412,6 +1401,14 @@ static int _mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1412 return 0; 1401 return 0;
1413} 1402}
1414 1403
1404static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1405{
1406 if (!chip->info->max_vid)
1407 return 0;
1408
1409 return mv88e6xxx_g1_vtu_flush(chip);
1410}
1411
1415static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port, 1412static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
1416 struct switchdev_obj_port_vlan *vlan, 1413 struct switchdev_obj_port_vlan *vlan,
1417 int (*cb)(struct switchdev_obj *obj)) 1414 int (*cb)(struct switchdev_obj *obj))
@@ -2599,11 +2596,6 @@ static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
2599 if (err) 2596 if (err)
2600 return err; 2597 return err;
2601 2598
2602 /* Clear all the VTU and STU entries */
2603 err = _mv88e6xxx_vtu_stu_flush(chip);
2604 if (err < 0)
2605 return err;
2606
2607 /* Configure the IP ToS mapping registers. */ 2599 /* Configure the IP ToS mapping registers. */
2608 err = mv88e6xxx_g1_write(chip, GLOBAL_IP_PRI_0, 0x0000); 2600 err = mv88e6xxx_g1_write(chip, GLOBAL_IP_PRI_0, 0x0000);
2609 if (err) 2601 if (err)
@@ -2684,6 +2676,10 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
2684 goto unlock; 2676 goto unlock;
2685 } 2677 }
2686 2678
2679 err = mv88e6xxx_vtu_setup(chip);
2680 if (err)
2681 goto unlock;
2682
2687 err = mv88e6xxx_pvt_setup(chip); 2683 err = mv88e6xxx_pvt_setup(chip);
2688 if (err) 2684 if (err)
2689 goto unlock; 2685 goto unlock;
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
index c153d07d2065..ed40e5557bbc 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -52,5 +52,6 @@ int mv88e6xxx_g1_atu_remove(struct mv88e6xxx_chip *chip, u16 fid, int port,
52 52
53int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip); 53int mv88e6xxx_g1_vtu_op_wait(struct mv88e6xxx_chip *chip);
54int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op); 54int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op);
55int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip);
55 56
56#endif /* _MV88E6XXX_GLOBAL1_H */ 57#endif /* _MV88E6XXX_GLOBAL1_H */
diff --git a/drivers/net/dsa/mv88e6xxx/global1_vtu.c b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
index 20dfdcbda238..c41ca28da084 100644
--- a/drivers/net/dsa/mv88e6xxx/global1_vtu.c
+++ b/drivers/net/dsa/mv88e6xxx/global1_vtu.c
@@ -31,3 +31,16 @@ int mv88e6xxx_g1_vtu_op(struct mv88e6xxx_chip *chip, u16 op)
31 31
32 return mv88e6xxx_g1_vtu_op_wait(chip); 32 return mv88e6xxx_g1_vtu_op_wait(chip);
33} 33}
34
35/* VLAN Translation Unit Operations */
36
37int mv88e6xxx_g1_vtu_flush(struct mv88e6xxx_chip *chip)
38{
39 int err;
40
41 err = mv88e6xxx_g1_vtu_op_wait(chip);
42 if (err)
43 return err;
44
45 return mv88e6xxx_g1_vtu_op(chip, GLOBAL_VTU_OP_FLUSH_ALL);
46}