705-11-v6.0-net-dsa-mt7530-rework-mt7530_hw_vlan_-add-del.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. From e26be16262e1fc1e9f1798c12762663bd9c265c6 Mon Sep 17 00:00:00 2001
  2. From: Frank Wunderlich <[email protected]>
  3. Date: Fri, 10 Jun 2022 19:05:37 +0200
  4. Subject: [PATCH 11/13] net: dsa: mt7530: rework mt7530_hw_vlan_{add,del}
  5. Rework vlan_add/vlan_del functions in preparation for dynamic cpu port.
  6. Currently BIT(MT7530_CPU_PORT) is added to new_members, even though
  7. mt7530_port_vlan_add() will be called on the CPU port too.
  8. Let DSA core decide when to call port_vlan_add for the CPU port, rather
  9. than doing it implicitly.
  10. We can do autonomous forwarding in a certain VLAN, but not add br0 to that
  11. VLAN and avoid flooding the CPU with those packets, if software knows it
  12. doesn't need to process them.
  13. Suggested-by: Vladimir Oltean <[email protected]>
  14. Signed-off-by: Frank Wunderlich <[email protected]>
  15. Reviewed-by: Vladimir Oltean <[email protected]>
  16. Reviewed-by: Florian Fainelli <[email protected]>
  17. Signed-off-by: Jakub Kicinski <[email protected]>
  18. ---
  19. drivers/net/dsa/mt7530.c | 30 ++++++++++++------------------
  20. 1 file changed, 12 insertions(+), 18 deletions(-)
  21. --- a/drivers/net/dsa/mt7530.c
  22. +++ b/drivers/net/dsa/mt7530.c
  23. @@ -1589,11 +1589,11 @@ static void
  24. mt7530_hw_vlan_add(struct mt7530_priv *priv,
  25. struct mt7530_hw_vlan_entry *entry)
  26. {
  27. + struct dsa_port *dp = dsa_to_port(priv->ds, entry->port);
  28. u8 new_members;
  29. u32 val;
  30. - new_members = entry->old_members | BIT(entry->port) |
  31. - BIT(MT7530_CPU_PORT);
  32. + new_members = entry->old_members | BIT(entry->port);
  33. /* Validate the entry with independent learning, create egress tag per
  34. * VLAN and joining the port as one of the port members.
  35. @@ -1604,22 +1604,20 @@ mt7530_hw_vlan_add(struct mt7530_priv *p
  36. /* Decide whether adding tag or not for those outgoing packets from the
  37. * port inside the VLAN.
  38. - */
  39. - val = entry->untagged ? MT7530_VLAN_EGRESS_UNTAG :
  40. - MT7530_VLAN_EGRESS_TAG;
  41. - mt7530_rmw(priv, MT7530_VAWD2,
  42. - ETAG_CTRL_P_MASK(entry->port),
  43. - ETAG_CTRL_P(entry->port, val));
  44. -
  45. - /* CPU port is always taken as a tagged port for serving more than one
  46. + * CPU port is always taken as a tagged port for serving more than one
  47. * VLANs across and also being applied with egress type stack mode for
  48. * that VLAN tags would be appended after hardware special tag used as
  49. * DSA tag.
  50. */
  51. + if (dsa_port_is_cpu(dp))
  52. + val = MT7530_VLAN_EGRESS_STACK;
  53. + else if (entry->untagged)
  54. + val = MT7530_VLAN_EGRESS_UNTAG;
  55. + else
  56. + val = MT7530_VLAN_EGRESS_TAG;
  57. mt7530_rmw(priv, MT7530_VAWD2,
  58. - ETAG_CTRL_P_MASK(MT7530_CPU_PORT),
  59. - ETAG_CTRL_P(MT7530_CPU_PORT,
  60. - MT7530_VLAN_EGRESS_STACK));
  61. + ETAG_CTRL_P_MASK(entry->port),
  62. + ETAG_CTRL_P(entry->port, val));
  63. }
  64. static void
  65. @@ -1638,11 +1636,7 @@ mt7530_hw_vlan_del(struct mt7530_priv *p
  66. return;
  67. }
  68. - /* If certain member apart from CPU port is still alive in the VLAN,
  69. - * the entry would be kept valid. Otherwise, the entry is got to be
  70. - * disabled.
  71. - */
  72. - if (new_members && new_members != BIT(MT7530_CPU_PORT)) {
  73. + if (new_members) {
  74. val = IVL_MAC | VTAG_EN | PORT_MEM(new_members) |
  75. VLAN_VALID;
  76. mt7530_write(priv, MT7530_VAWD1, val);