| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From d7a0b1f7652f9f6b7ba0c9d8ad8edd6b8c0c1511 Mon Sep 17 00:00:00 2001 |
| 2 | From: Florian Fainelli <f.fainelli@gmail.com> |
| 3 | Date: Mon, 30 Mar 2020 14:38:47 -0700 |
| 4 | Subject: [PATCH] net: dsa: b53: Restore VLAN entries upon (re)configuration |
| 5 | |
| 6 | The first time b53_configure_vlan() is called we have not configured any |
| 7 | VLAN entries yet, since that happens later when interfaces get brought |
| 8 | up. When b53_configure_vlan() is called again from suspend/resume we |
| 9 | need to restore all VLAN entries though. |
| 10 | |
| 11 | Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> |
| 12 | Signed-off-by: David S. Miller <davem@davemloft.net> |
| 13 | --- |
| 14 | drivers/net/dsa/b53/b53_common.c | 15 +++++++++++++++ |
| 15 | 1 file changed, 15 insertions(+) |
| 16 | |
| 17 | --- a/drivers/net/dsa/b53/b53_common.c |
| 18 | +++ b/drivers/net/dsa/b53/b53_common.c |
| 19 | @@ -696,7 +696,9 @@ int b53_configure_vlan(struct dsa_switch |
| 20 | { |
| 21 | struct b53_device *dev = ds->priv; |
| 22 | struct b53_vlan vl = { 0 }; |
| 23 | + struct b53_vlan *v; |
| 24 | int i, def_vid; |
| 25 | + u16 vid; |
| 26 | |
| 27 | def_vid = b53_default_pvid(dev); |
| 28 | |
| 29 | @@ -717,6 +719,19 @@ int b53_configure_vlan(struct dsa_switch |
| 30 | if (!is5325(dev) && !is5365(dev)) |
| 31 | b53_set_jumbo(dev, dev->enable_jumbo, false); |
| 32 | |
| 33 | + /* Upon initial call we have not set-up any VLANs, but upon |
| 34 | + * system resume, we need to restore all VLAN entries. |
| 35 | + */ |
| 36 | + for (vid = def_vid; vid < dev->num_vlans; vid++) { |
| 37 | + v = &dev->vlans[vid]; |
| 38 | + |
| 39 | + if (!v->members) |
| 40 | + continue; |
| 41 | + |
| 42 | + b53_set_vlan_entry(dev, vid, v); |
| 43 | + b53_fast_age_vlan(dev, vid); |
| 44 | + } |
| 45 | + |
| 46 | return 0; |
| 47 | } |
| 48 | EXPORT_SYMBOL(b53_configure_vlan); |