741-v5.14-0003-net-dsa-b53-Create-default-VLAN-entry-explicitly.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From 64a81b24487f0d2fba0f033029eec2abc7d82cee Mon Sep 17 00:00:00 2001
  2. From: Florian Fainelli <[email protected]>
  3. Date: Mon, 21 Jun 2021 15:10:55 -0700
  4. Subject: [PATCH] net: dsa: b53: Create default VLAN entry explicitly
  5. In case CONFIG_VLAN_8021Q is not set, there will be no call down to the
  6. b53 driver to ensure that the default PVID VLAN entry will be configured
  7. with the appropriate untagged attribute towards the CPU port. We were
  8. implicitly relying on dsa_slave_vlan_rx_add_vid() to do that for us,
  9. instead make it explicit.
  10. Reported-by: Vladimir Oltean <[email protected]>
  11. Signed-off-by: Florian Fainelli <[email protected]>
  12. Reviewed-by: Vladimir Oltean <[email protected]>
  13. Signed-off-by: David S. Miller <[email protected]>
  14. ---
  15. drivers/net/dsa/b53/b53_common.c | 27 +++++++++++++++++++--------
  16. 1 file changed, 19 insertions(+), 8 deletions(-)
  17. --- a/drivers/net/dsa/b53/b53_common.c
  18. +++ b/drivers/net/dsa/b53/b53_common.c
  19. @@ -693,6 +693,13 @@ static u16 b53_default_pvid(struct b53_d
  20. return 0;
  21. }
  22. +static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port)
  23. +{
  24. + struct b53_device *dev = ds->priv;
  25. +
  26. + return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port);
  27. +}
  28. +
  29. int b53_configure_vlan(struct dsa_switch *ds)
  30. {
  31. struct b53_device *dev = ds->priv;
  32. @@ -713,9 +720,20 @@ int b53_configure_vlan(struct dsa_switch
  33. b53_enable_vlan(dev, -1, dev->vlan_enabled, ds->vlan_filtering);
  34. - b53_for_each_port(dev, i)
  35. + /* Create an untagged VLAN entry for the default PVID in case
  36. + * CONFIG_VLAN_8021Q is disabled and there are no calls to
  37. + * dsa_slave_vlan_rx_add_vid() to create the default VLAN
  38. + * entry. Do this only when the tagging protocol is not
  39. + * DSA_TAG_PROTO_NONE
  40. + */
  41. + b53_for_each_port(dev, i) {
  42. + v = &dev->vlans[def_vid];
  43. + v->members |= BIT(i);
  44. + if (!b53_vlan_port_needs_forced_tagged(ds, i))
  45. + v->untag = v->members;
  46. b53_write16(dev, B53_VLAN_PAGE,
  47. B53_VLAN_PORT_DEF_TAG(i), def_vid);
  48. + }
  49. /* Upon initial call we have not set-up any VLANs, but upon
  50. * system resume, we need to restore all VLAN entries.
  51. @@ -1429,13 +1447,6 @@ int b53_vlan_prepare(struct dsa_switch *
  52. }
  53. EXPORT_SYMBOL(b53_vlan_prepare);
  54. -static bool b53_vlan_port_needs_forced_tagged(struct dsa_switch *ds, int port)
  55. -{
  56. - struct b53_device *dev = ds->priv;
  57. -
  58. - return dev->tag_protocol == DSA_TAG_PROTO_NONE && dsa_is_cpu_port(ds, port);
  59. -}
  60. -
  61. void b53_vlan_add(struct dsa_switch *ds, int port,
  62. const struct switchdev_obj_port_vlan *vlan)
  63. {