Skip to content

Commit 0b6d642

Browse files
vladimirolteanPaolo Abeni
authored andcommitted
net: dsa: mt7530: don't change PVC_EG_TAG when CPU port becomes VLAN-aware
Frank reports that in a mt7530 setup where some ports are standalone and some are in a VLAN-aware bridge, 8021q uppers of the standalone ports lose their VLAN tag on xmit, as seen by the link partner. This seems to occur because once the other ports join the VLAN-aware bridge, mt7530_port_vlan_filtering() also calls mt7530_port_set_vlan_aware(ds, cpu_dp->index), and this affects the way that the switch processes the traffic of the standalone port. Relevant is the PVC_EG_TAG bit. The MT7530 documentation says about it: EG_TAG: Incoming Port Egress Tag VLAN Attribution 0: disabled (system default) 1: consistent (keep the original ingress tag attribute) My interpretation is that this setting applies on the ingress port, and "disabled" is basically the normal behavior, where the egress tag format of the packet (tagged or untagged) is decided by the VLAN table (MT7530_VLAN_EGRESS_UNTAG or MT7530_VLAN_EGRESS_TAG). But there is also an option of overriding the system default behavior, and for the egress tagging format of packets to be decided not by the VLAN table, but simply by copying the ingress tag format (if ingress was tagged, egress is tagged; if ingress was untagged, egress is untagged; aka "consistent). This is useful in 2 scenarios: - VLAN-unaware bridge ports will always encounter a miss in the VLAN table. They should forward a packet as-is, though. So we use "consistent" there. See commit e045124 ("net: dsa: mt7530: fix tagged frames pass-through in VLAN-unaware mode"). - Traffic injected from the CPU port. The operating system is in god mode; if it wants a packet to exit as VLAN-tagged, it sends it as VLAN-tagged. Otherwise it sends it as VLAN-untagged*. *This is true only if we don't consider the bridge TX forwarding offload feature, which mt7530 doesn't support. So for now, make the CPU port always stay in "consistent" mode to allow software VLANs to be forwarded to their egress ports with the VLAN tag intact, and not stripped. Link: https://lore.kernel.org/netdev/trinity-e6294d28-636c-4c40-bb8b-b523521b00be-1674233135062@3c-app-gmx-bs36/ Fixes: e045124 ("net: dsa: mt7530: fix tagged frames pass-through in VLAN-unaware mode") Reported-by: Frank Wunderlich <[email protected]> Tested-by: Frank Wunderlich <[email protected]> Signed-off-by: Vladimir Oltean <[email protected]> Tested-by: Arınç ÜNAL <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 811d581 commit 0b6d642

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

drivers/net/dsa/mt7530.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,14 +1309,26 @@ mt7530_port_set_vlan_aware(struct dsa_switch *ds, int port)
13091309
if (!priv->ports[port].pvid)
13101310
mt7530_rmw(priv, MT7530_PVC_P(port), ACC_FRM_MASK,
13111311
MT7530_VLAN_ACC_TAGGED);
1312-
}
13131312

1314-
/* Set the port as a user port which is to be able to recognize VID
1315-
* from incoming packets before fetching entry within the VLAN table.
1316-
*/
1317-
mt7530_rmw(priv, MT7530_PVC_P(port), VLAN_ATTR_MASK | PVC_EG_TAG_MASK,
1318-
VLAN_ATTR(MT7530_VLAN_USER) |
1319-
PVC_EG_TAG(MT7530_VLAN_EG_DISABLED));
1313+
/* Set the port as a user port which is to be able to recognize
1314+
* VID from incoming packets before fetching entry within the
1315+
* VLAN table.
1316+
*/
1317+
mt7530_rmw(priv, MT7530_PVC_P(port),
1318+
VLAN_ATTR_MASK | PVC_EG_TAG_MASK,
1319+
VLAN_ATTR(MT7530_VLAN_USER) |
1320+
PVC_EG_TAG(MT7530_VLAN_EG_DISABLED));
1321+
} else {
1322+
/* Also set CPU ports to the "user" VLAN port attribute, to
1323+
* allow VLAN classification, but keep the EG_TAG attribute as
1324+
* "consistent" (i.o.w. don't change its value) for packets
1325+
* received by the switch from the CPU, so that tagged packets
1326+
* are forwarded to user ports as tagged, and untagged as
1327+
* untagged.
1328+
*/
1329+
mt7530_rmw(priv, MT7530_PVC_P(port), VLAN_ATTR_MASK,
1330+
VLAN_ATTR(MT7530_VLAN_USER));
1331+
}
13201332
}
13211333

13221334
static void

0 commit comments

Comments
 (0)