789-STABLE-03-net-dsa-mt7530-fix-handling-of-all-link-local-frames.patch 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. From 86c0c154a759f2af9612a04bdf29110f02dce956 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <[email protected]>
  3. Date: Thu, 14 Mar 2024 12:33:42 +0300
  4. Subject: [PATCH 3/3] net: dsa: mt7530: fix handling of all link-local frames
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. [ Upstream commit 69ddba9d170bdaee1dc0eb4ced38d7e4bb7b92af ]
  9. Currently, the MT753X switches treat frames with :01-0D and :0F MAC DAs as
  10. regular multicast frames, therefore flooding them to user ports.
  11. On page 205, section "8.6.3 Frame filtering" of the active standard, IEEE
  12. Std 802.1Q™-2022, it is stated that frames with 01:80:C2:00:00:00-0F as MAC
  13. DA must only be propagated to C-VLAN and MAC Bridge components. That means
  14. VLAN-aware and VLAN-unaware bridges. On the switch designs with CPU ports,
  15. these frames are supposed to be processed by the CPU (software). So we make
  16. the switch only forward them to the CPU port. And if received from a CPU
  17. port, forward to a single port. The software is responsible of making the
  18. switch conform to the latter by setting a single port as destination port
  19. on the special tag.
  20. This switch intellectual property cannot conform to this part of the
  21. standard fully. Whilst the REV_UN frame tag covers the remaining :04-0D and
  22. :0F MAC DAs, it also includes :22-FF which the scope of propagation is not
  23. supposed to be restricted for these MAC DAs.
  24. Set frames with :01-03 MAC DAs to be trapped to the CPU port(s). Add a
  25. comment for the remaining MAC DAs.
  26. Note that the ingress port must have a PVID assigned to it for the switch
  27. to forward untagged frames. A PVID is set by default on VLAN-aware and
  28. VLAN-unaware ports. However, when the network interface that pertains to
  29. the ingress port is attached to a vlan_filtering enabled bridge, the user
  30. can remove the PVID assignment from it which would prevent the link-local
  31. frames from being trapped to the CPU port. I am yet to see a way to forward
  32. link-local frames while preventing other untagged frames from being
  33. forwarded too.
  34. Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
  35. Signed-off-by: Arınç ÜNAL <[email protected]>
  36. Signed-off-by: Paolo Abeni <[email protected]>
  37. Signed-off-by: Sasha Levin <[email protected]>
  38. ---
  39. drivers/net/dsa/mt7530.c | 37 +++++++++++++++++++++++++++++++++----
  40. drivers/net/dsa/mt7530.h | 13 +++++++++++++
  41. 2 files changed, 46 insertions(+), 4 deletions(-)
  42. --- a/drivers/net/dsa/mt7530.c
  43. +++ b/drivers/net/dsa/mt7530.c
  44. @@ -998,6 +998,21 @@ unlock_exit:
  45. mutex_unlock(&priv->reg_mutex);
  46. }
  47. +/* On page 205, section "8.6.3 Frame filtering" of the active standard, IEEE Std
  48. + * 802.1Q™-2022, it is stated that frames with 01:80:C2:00:00:00-0F as MAC DA
  49. + * must only be propagated to C-VLAN and MAC Bridge components. That means
  50. + * VLAN-aware and VLAN-unaware bridges. On the switch designs with CPU ports,
  51. + * these frames are supposed to be processed by the CPU (software). So we make
  52. + * the switch only forward them to the CPU port. And if received from a CPU
  53. + * port, forward to a single port. The software is responsible of making the
  54. + * switch conform to the latter by setting a single port as destination port on
  55. + * the special tag.
  56. + *
  57. + * This switch intellectual property cannot conform to this part of the standard
  58. + * fully. Whilst the REV_UN frame tag covers the remaining :04-0D and :0F MAC
  59. + * DAs, it also includes :22-FF which the scope of propagation is not supposed
  60. + * to be restricted for these MAC DAs.
  61. + */
  62. static void
  63. mt753x_trap_frames(struct mt7530_priv *priv)
  64. {
  65. @@ -1012,13 +1027,27 @@ mt753x_trap_frames(struct mt7530_priv *p
  66. MT753X_BPDU_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
  67. MT753X_BPDU_CPU_ONLY);
  68. - /* Trap LLDP frames with :0E MAC DA to the CPU port(s) and egress them
  69. - * VLAN-untagged.
  70. + /* Trap frames with :01 and :02 MAC DAs to the CPU port(s) and egress
  71. + * them VLAN-untagged.
  72. + */
  73. + mt7530_rmw(priv, MT753X_RGAC1, MT753X_R02_EG_TAG_MASK |
  74. + MT753X_R02_PORT_FW_MASK | MT753X_R01_EG_TAG_MASK |
  75. + MT753X_R01_PORT_FW_MASK,
  76. + MT753X_R02_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
  77. + MT753X_R02_PORT_FW(MT753X_BPDU_CPU_ONLY) |
  78. + MT753X_R01_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
  79. + MT753X_BPDU_CPU_ONLY);
  80. +
  81. + /* Trap frames with :03 and :0E MAC DAs to the CPU port(s) and egress
  82. + * them VLAN-untagged.
  83. */
  84. mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_EG_TAG_MASK |
  85. - MT753X_R0E_PORT_FW_MASK,
  86. + MT753X_R0E_PORT_FW_MASK | MT753X_R03_EG_TAG_MASK |
  87. + MT753X_R03_PORT_FW_MASK,
  88. MT753X_R0E_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
  89. - MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY));
  90. + MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY) |
  91. + MT753X_R03_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
  92. + MT753X_BPDU_CPU_ONLY);
  93. }
  94. static int
  95. --- a/drivers/net/dsa/mt7530.h
  96. +++ b/drivers/net/dsa/mt7530.h
  97. @@ -71,12 +71,25 @@ enum mt753x_id {
  98. #define MT753X_BPDU_EG_TAG(x) FIELD_PREP(MT753X_BPDU_EG_TAG_MASK, x)
  99. #define MT753X_BPDU_PORT_FW_MASK GENMASK(2, 0)
  100. +/* Register for :01 and :02 MAC DA frame control */
  101. +#define MT753X_RGAC1 0x28
  102. +#define MT753X_R02_EG_TAG_MASK GENMASK(24, 22)
  103. +#define MT753X_R02_EG_TAG(x) FIELD_PREP(MT753X_R02_EG_TAG_MASK, x)
  104. +#define MT753X_R02_PORT_FW_MASK GENMASK(18, 16)
  105. +#define MT753X_R02_PORT_FW(x) FIELD_PREP(MT753X_R02_PORT_FW_MASK, x)
  106. +#define MT753X_R01_EG_TAG_MASK GENMASK(8, 6)
  107. +#define MT753X_R01_EG_TAG(x) FIELD_PREP(MT753X_R01_EG_TAG_MASK, x)
  108. +#define MT753X_R01_PORT_FW_MASK GENMASK(2, 0)
  109. +
  110. /* Register for :03 and :0E MAC DA frame control */
  111. #define MT753X_RGAC2 0x2c
  112. #define MT753X_R0E_EG_TAG_MASK GENMASK(24, 22)
  113. #define MT753X_R0E_EG_TAG(x) FIELD_PREP(MT753X_R0E_EG_TAG_MASK, x)
  114. #define MT753X_R0E_PORT_FW_MASK GENMASK(18, 16)
  115. #define MT753X_R0E_PORT_FW(x) FIELD_PREP(MT753X_R0E_PORT_FW_MASK, x)
  116. +#define MT753X_R03_EG_TAG_MASK GENMASK(8, 6)
  117. +#define MT753X_R03_EG_TAG(x) FIELD_PREP(MT753X_R03_EG_TAG_MASK, x)
  118. +#define MT753X_R03_PORT_FW_MASK GENMASK(2, 0)
  119. enum mt753x_bpdu_port_fw {
  120. MT753X_BPDU_FOLLOW_MFC,