net: dsa: b53: Restore VLAN entries upon (re)configuration
authorFlorian Fainelli <f.fainelli@gmail.com>
Mon, 30 Mar 2020 21:38:47 +0000 (14:38 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 31 Mar 2020 02:55:42 +0000 (19:55 -0700)
The first time b53_configure_vlan() is called we have not configured any
VLAN entries yet, since that happens later when interfaces get brought
up. When b53_configure_vlan() is called again from suspend/resume we
need to restore all VLAN entries though.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/b53/b53_common.c

index 39ae4ed87d1d944a3ea862e5918018a4ddbe46ff..5cb678e8b9cdaf967183ff6cc1835bc4e292d2da 100644 (file)
@@ -681,7 +681,9 @@ int b53_configure_vlan(struct dsa_switch *ds)
 {
        struct b53_device *dev = ds->priv;
        struct b53_vlan vl = { 0 };
+       struct b53_vlan *v;
        int i, def_vid;
+       u16 vid;
 
        def_vid = b53_default_pvid(dev);
 
@@ -699,6 +701,19 @@ int b53_configure_vlan(struct dsa_switch *ds)
                b53_write16(dev, B53_VLAN_PAGE,
                            B53_VLAN_PORT_DEF_TAG(i), def_vid);
 
+       /* Upon initial call we have not set-up any VLANs, but upon
+        * system resume, we need to restore all VLAN entries.
+        */
+       for (vid = def_vid; vid < dev->num_vlans; vid++) {
+               v = &dev->vlans[vid];
+
+               if (!v->members)
+                       continue;
+
+               b53_set_vlan_entry(dev, vid, v);
+               b53_fast_age_vlan(dev, vid);
+       }
+
        return 0;
 }
 EXPORT_SYMBOL(b53_configure_vlan);