Skip to content

Commit 69ddba9

Browse files
arinc9Paolo Abeni
authored andcommitted
net: dsa: mt7530: fix handling of all link-local frames
Currently, the MT753X switches treat frames with :01-0D and :0F MAC DAs as regular multicast frames, therefore flooding them to user ports. On page 205, section "8.6.3 Frame filtering" of the active standard, IEEE Std 802.1Q™-2022, it is stated that frames with 01:80:C2:00:00:00-0F as MAC DA must only be propagated to C-VLAN and MAC Bridge components. That means VLAN-aware and VLAN-unaware bridges. On the switch designs with CPU ports, these frames are supposed to be processed by the CPU (software). So we make the switch only forward them to the CPU port. And if received from a CPU port, forward to a single port. The software is responsible of making the switch conform to the latter by setting a single port as destination port on the special tag. This switch intellectual property cannot conform to this part of the standard fully. Whilst the REV_UN frame tag covers the remaining :04-0D and :0F MAC DAs, it also includes :22-FF which the scope of propagation is not supposed to be restricted for these MAC DAs. Set frames with :01-03 MAC DAs to be trapped to the CPU port(s). Add a comment for the remaining MAC DAs. Note that the ingress port must have a PVID assigned to it for the switch to forward untagged frames. A PVID is set by default on VLAN-aware and VLAN-unaware ports. However, when the network interface that pertains to the ingress port is attached to a vlan_filtering enabled bridge, the user can remove the PVID assignment from it which would prevent the link-local frames from being trapped to the CPU port. I am yet to see a way to forward link-local frames while preventing other untagged frames from being forwarded too. Fixes: b8f126a ("net-next: dsa: add dsa support for Mediatek MT7530 switch") Signed-off-by: Arınç ÜNAL <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent e8bf353 commit 69ddba9

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

drivers/net/dsa/mt7530.c

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,21 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface)
950950
mutex_unlock(&priv->reg_mutex);
951951
}
952952

953+
/* On page 205, section "8.6.3 Frame filtering" of the active standard, IEEE Std
954+
* 802.1Q™-2022, it is stated that frames with 01:80:C2:00:00:00-0F as MAC DA
955+
* must only be propagated to C-VLAN and MAC Bridge components. That means
956+
* VLAN-aware and VLAN-unaware bridges. On the switch designs with CPU ports,
957+
* these frames are supposed to be processed by the CPU (software). So we make
958+
* the switch only forward them to the CPU port. And if received from a CPU
959+
* port, forward to a single port. The software is responsible of making the
960+
* switch conform to the latter by setting a single port as destination port on
961+
* the special tag.
962+
*
963+
* This switch intellectual property cannot conform to this part of the standard
964+
* fully. Whilst the REV_UN frame tag covers the remaining :04-0D and :0F MAC
965+
* DAs, it also includes :22-FF which the scope of propagation is not supposed
966+
* to be restricted for these MAC DAs.
967+
*/
953968
static void
954969
mt753x_trap_frames(struct mt7530_priv *priv)
955970
{
@@ -964,13 +979,27 @@ mt753x_trap_frames(struct mt7530_priv *priv)
964979
MT753X_BPDU_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
965980
MT753X_BPDU_CPU_ONLY);
966981

967-
/* Trap LLDP frames with :0E MAC DA to the CPU port(s) and egress them
968-
* VLAN-untagged.
982+
/* Trap frames with :01 and :02 MAC DAs to the CPU port(s) and egress
983+
* them VLAN-untagged.
984+
*/
985+
mt7530_rmw(priv, MT753X_RGAC1, MT753X_R02_EG_TAG_MASK |
986+
MT753X_R02_PORT_FW_MASK | MT753X_R01_EG_TAG_MASK |
987+
MT753X_R01_PORT_FW_MASK,
988+
MT753X_R02_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
989+
MT753X_R02_PORT_FW(MT753X_BPDU_CPU_ONLY) |
990+
MT753X_R01_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
991+
MT753X_BPDU_CPU_ONLY);
992+
993+
/* Trap frames with :03 and :0E MAC DAs to the CPU port(s) and egress
994+
* them VLAN-untagged.
969995
*/
970996
mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_EG_TAG_MASK |
971-
MT753X_R0E_PORT_FW_MASK,
997+
MT753X_R0E_PORT_FW_MASK | MT753X_R03_EG_TAG_MASK |
998+
MT753X_R03_PORT_FW_MASK,
972999
MT753X_R0E_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
973-
MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY));
1000+
MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY) |
1001+
MT753X_R03_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
1002+
MT753X_BPDU_CPU_ONLY);
9741003
}
9751004

9761005
static void

drivers/net/dsa/mt7530.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,25 @@ enum mt753x_id {
7373
#define MT753X_BPDU_EG_TAG(x) FIELD_PREP(MT753X_BPDU_EG_TAG_MASK, x)
7474
#define MT753X_BPDU_PORT_FW_MASK GENMASK(2, 0)
7575

76+
/* Register for :01 and :02 MAC DA frame control */
77+
#define MT753X_RGAC1 0x28
78+
#define MT753X_R02_EG_TAG_MASK GENMASK(24, 22)
79+
#define MT753X_R02_EG_TAG(x) FIELD_PREP(MT753X_R02_EG_TAG_MASK, x)
80+
#define MT753X_R02_PORT_FW_MASK GENMASK(18, 16)
81+
#define MT753X_R02_PORT_FW(x) FIELD_PREP(MT753X_R02_PORT_FW_MASK, x)
82+
#define MT753X_R01_EG_TAG_MASK GENMASK(8, 6)
83+
#define MT753X_R01_EG_TAG(x) FIELD_PREP(MT753X_R01_EG_TAG_MASK, x)
84+
#define MT753X_R01_PORT_FW_MASK GENMASK(2, 0)
85+
7686
/* Register for :03 and :0E MAC DA frame control */
7787
#define MT753X_RGAC2 0x2c
7888
#define MT753X_R0E_EG_TAG_MASK GENMASK(24, 22)
7989
#define MT753X_R0E_EG_TAG(x) FIELD_PREP(MT753X_R0E_EG_TAG_MASK, x)
8090
#define MT753X_R0E_PORT_FW_MASK GENMASK(18, 16)
8191
#define MT753X_R0E_PORT_FW(x) FIELD_PREP(MT753X_R0E_PORT_FW_MASK, x)
92+
#define MT753X_R03_EG_TAG_MASK GENMASK(8, 6)
93+
#define MT753X_R03_EG_TAG(x) FIELD_PREP(MT753X_R03_EG_TAG_MASK, x)
94+
#define MT753X_R03_PORT_FW_MASK GENMASK(2, 0)
8295

8396
enum mt753x_bpdu_port_fw {
8497
MT753X_BPDU_FOLLOW_MFC,

0 commit comments

Comments
 (0)