net: dsa: mt7530: set CPU port to fallback mode
Subsystems (5)
PATCH 1/1 net: dsa: mt7530: set CPU port to fallback mode
Currently, setting a bridge's self PVID to other value and deleting the default VID 1 renders untagged ports of that VLAN unable to talk to the CPU port:
bridge vlan add dev br0 vid 2 pvid untagged self bridge vlan del dev br0 vid 1 self
bridge vlan add dev sw0p0 vid 2 pvid untagged bridge vlan del dev sw0p0 vid 1
# br0 cannot send untagged frames out of sw0p0 anymore
That is because the CPU port is set to security mode and its PVID is still 1, and untagged frames are dropped due to VLAN member violation.
Set the CPU port to fallback mode so untagged frames can pass through.
--- drivers/net/dsa/mt7530.c | 11 ++++++++--- drivers/net/dsa/mt7530.h | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/net/dsa/mt7530.c +8 -3
@@ -810,10 +810,15 @@ mt7530_port_set_vlan_aware(struct dsa_switch *ds, int port) PCR_MATRIX_MASK, PCR_MATRIX(MT7530_ALL_MEMBERS));/* Trapped into security mode allows packet forwarding through VLAN -* table lookup. +* table lookup. CPU port is set to fallback mode to let untagged +* frames pass through. */ -mt7530_rmw (priv,MT7530_PCR_P (port),PCR_PORT_VLAN_MASK , -MT7530_PORT_SECURITY_MODE ); +if (dsa_is_cpu_port (ds, port)) +mt7530_rmw (priv,MT7530_PCR_P (port),PCR_PORT_VLAN_MASK , +MT7530_PORT_FALLBACK_MODE ); +else +mt7530_rmw (priv,MT7530_PCR_P (port),PCR_PORT_VLAN_MASK , +MT7530_PORT_SECURITY_MODE );/* Set the port as a user port which is to be able to recognize VID * from incoming packets before fetching entry within the VLAN table.
drivers/net/dsa/mt7530.h +6 -0
@@ -152,6 +152,12 @@ enum mt7530_port_mode {/* Port Matrix Mode: Frames are forwarded by the PCR_MATRIX members. */ MT7530_PORT_MATRIX_MODE =PORT_VLAN (0 ), +/* Fallback Mode: Forward received frames with ingress ports that do +* not belong to the VLAN member. Frames whose VID is not listed on +* the VLAN table are forwarded by the PCR_MATRIX members. +*/ + MT7530_PORT_FALLBACK_MODE = PORT_VLAN(1), +/* Security Mode: Discard any frame due to ingress membership * violation or VID missed on the VLAN table. */
Signature · 1 line
2.26.2
Quoted 10 lines · DENG Qingfang
Currently, setting a bridge's self PVID to other value and deleting the default VID 1 renders untagged ports of that VLAN unable to talk to the CPU port:
bridge vlan add dev br0 vid 2 pvid untagged self bridge vlan del dev br0 vid 1 self
bridge vlan add dev sw0p0 vid 2 pvid untagged bridge vlan del dev sw0p0 vid 1
# br0 cannot send untagged frames out of sw0p0 anymore
Quoted 4 lines
That is because the CPU port is set to security mode and its PVID is still 1, and untagged frames are dropped due to VLAN member violation.
Set the CPU port to fallback mode so untagged frames can pass through.
How about if the bridge has vlan_filtering=1? The use case you present seems to be valid to me, that is, you may create a VLAN just for the user ports and not have the CPU port be part of it at all.
Quoted 49 lines
Fixes 83163f7dca56 ("net: dsa: mediatek: add VLAN support for MT7530")Signed-off-by DENG Qingfang <[email protected]>--- drivers/net/dsa/mt7530.c | 11 ++++++++--- drivers/net/dsa/mt7530.h | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-)drivers/net/dsa/mt7530.c +8
-3@@ -810,10 +810,15 @@ mt7530_port_set_vlan_aware(struct dsa_switch *ds, int port) PCR_MATRIX_MASK, PCR_MATRIX(MT7530_ALL_MEMBERS));/* Trapped into security mode allows packet forwarding through VLAN -* table lookup. +* table lookup. CPU port is set to fallback mode to let untagged +* frames pass through. */ -mt7530_rmw (priv,MT7530_PCR_P (port),PCR_PORT_VLAN_MASK , -MT7530_PORT_SECURITY_MODE ); +if (dsa_is_cpu_port (ds, port)) +mt7530_rmw (priv,MT7530_PCR_P (port),PCR_PORT_VLAN_MASK , +MT7530_PORT_FALLBACK_MODE ); +else +mt7530_rmw (priv,MT7530_PCR_P (port),PCR_PORT_VLAN_MASK , +MT7530_PORT_SECURITY_MODE );/* Set the port as a user port which is to be able to recognize VID * from incoming packets before fetching entry within the VLAN table. drivers/net/dsa/mt7530.h +6
-0@@ -152,6 +152,12 @@ enum mt7530_port_mode {/* Port Matrix Mode: Frames are forwarded by the PCR_MATRIX members. */ MT7530_PORT_MATRIX_MODE =PORT_VLAN (0 ), +/* Fallback Mode: Forward received frames with ingress ports that do +* not belong to the VLAN member. Frames whose VID is not listed on +* the VLAN table are forwarded by the PCR_MATRIX members. +*/ + MT7530_PORT_FALLBACK_MODE = PORT_VLAN(1), +/* Security Mode: Discard any frame due to ingress membership * violation or VID missed on the VLAN table. */
Signature · 1 line
Florian
Hi Florian
Quoted 14 lines · Florian Fainelli
Quoted 10 lines · DENG Qingfang
Currently, setting a bridge's self PVID to other value and deleting the default VID 1 renders untagged ports of that VLAN unable to talk to the CPU port:
bridge vlan add dev br0 vid 2 pvid untagged self bridge vlan del dev br0 vid 1 self
bridge vlan add dev sw0p0 vid 2 pvid untagged bridge vlan del dev sw0p0 vid 1
# br0 cannot send untagged frames out of sw0p0 anymore
Quoted 8 lines
Quoted 4 lines
That is because the CPU port is set to security mode and its PVID is still 1, and untagged frames are dropped due to VLAN member violation.
Set the CPU port to fallback mode so untagged frames can pass through.
How about if the bridge has vlan_filtering=1? The use case you present seems to be valid to me, that is, you may create a VLAN just for the user ports and not have the CPU port be part of it at all.
I forgot to mention that this is ONLY for vlan_filtering=1 bridge vlan simply won't do anything if VLAN filtering is disabled.
Quoted 53 lines
Quoted 40 lines
Fixes 83163f7dca56 ("net: dsa: mediatek: add VLAN support for MT7530")Signed-off-by DENG Qingfang <[email protected]>--- drivers/net/dsa/mt7530.c | 11 ++++++++--- drivers/net/dsa/mt7530.h | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-)drivers/net/dsa/mt7530.c +8
-3@@ -810,10 +810,15 @@ mt7530_port_set_vlan_aware(struct dsa_switch *ds, int port) PCR_MATRIX_MASK, PCR_MATRIX(MT7530_ALL_MEMBERS));/* Trapped into security mode allows packet forwarding through VLAN -* table lookup. +* table lookup. CPU port is set to fallback mode to let untagged +* frames pass through. */ -mt7530_rmw (priv,MT7530_PCR_P (port),PCR_PORT_VLAN_MASK , -MT7530_PORT_SECURITY_MODE ); +if (dsa_is_cpu_port (ds, port)) +mt7530_rmw (priv,MT7530_PCR_P (port),PCR_PORT_VLAN_MASK , +MT7530_PORT_FALLBACK_MODE ); +else +mt7530_rmw (priv,MT7530_PCR_P (port),PCR_PORT_VLAN_MASK , +MT7530_PORT_SECURITY_MODE );/* Set the port as a user port which is to be able to recognize VID * from incoming packets before fetching entry within the VLAN table. drivers/net/dsa/mt7530.h +0
-0@@ -152,6 +152,12 @@ enum mt7530_port_mode {/* Port Matrix Mode: Frames are forwarded by the PCR_MATRIX members. */ MT7530_PORT_MATRIX_MODE = PORT_VLAN(0),drivers/net/dsa/mt7530.h enum mt7530_port_mode { · line 163
Quoted 10 lines
drivers/net/dsa/mt7530.h +6
-0+/* Fallback Mode: Forward received frames with ingress ports that do +* not belong to the VLAN member. Frames whose VID is not listed on +* the VLAN table are forwarded by the PCR_MATRIX members. +*/ + MT7530_PORT_FALLBACK_MODE = PORT_VLAN(1), +/* Security Mode: Discard any frame due to ingress membership * violation or VID missed on the VLAN table. */ --
Florian
Quoted 20 lines · DENG Qingfang
Hi Florian
Quoted 17 lines · Florian Fainelli
Quoted 13 lines · DENG Qingfang
Currently, setting a bridge's self PVID to other value and deleting the default VID 1 renders untagged ports of that VLAN unable to talk to the CPU port:
bridge vlan add dev br0 vid 2 pvid untagged self bridge vlan del dev br0 vid 1 self
bridge vlan add dev sw0p0 vid 2 pvid untagged bridge vlan del dev sw0p0 vid 1
# br0 cannot send untagged frames out of sw0p0 anymoreThat is because the CPU port is set to security mode and its PVID is still 1, and untagged frames are dropped due to VLAN member violation.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Set the CPU port to fallback mode so untagged frames can pass through.
How about if the bridge has vlan_filtering=1? The use case you present seems to be valid to me, that is, you may create a VLAN just for the user ports and not have the CPU port be part of it at all.
I forgot to mention that this is ONLY for vlan_filtering=1
bridge vlansimply won't do anything if VLAN filtering is disabled.
It depends now as of this patch:
and sorry I misunderstood your use case, you are changing the default VLAN for the CPU port through the bridge's master device and you still want it to be in the same VLAN membership as sw0p0, so yes that looks correct.
Signature · 1 line
Florian
Vladimir Oltean
maintainerQuoted 14 lines · Florian Fainelli
Quoted 10 lines · DENG Qingfang
Currently, setting a bridge's self PVID to other value and deleting the default VID 1 renders untagged ports of that VLAN unable to talk to the CPU port:
bridge vlan add dev br0 vid 2 pvid untagged self bridge vlan del dev br0 vid 1 self
bridge vlan add dev sw0p0 vid 2 pvid untagged bridge vlan del dev sw0p0 vid 1
# br0 cannot send untagged frames out of sw0p0 anymore
Quoted 9 lines
Quoted 4 lines
That is because the CPU port is set to security mode and its PVID is still 1, and untagged frames are dropped due to VLAN member violation.
Set the CPU port to fallback mode so untagged frames can pass through.
How about if the bridge has vlan_filtering=1? The use case you present seems to be valid to me, that is, you may create a VLAN just for the user ports and not have the CPU port be part of it at all.
What Qingfang is doing is in effect (but not by intention) removing the front panel port sw0p0 from the membership list of the CPU port's pvid. What you seem to be thinking of (VLAN of which the CPU is not a member of) does not seem to be supported in DSA at the moment.
As a fix, there's nothing wrong with the patch actually, I don't even know how it would work otherwise. DSA doesn't change the pvid of the CPU port when the pvid of a slave changes, because 4 slave ports could have 4 different pvids and the CPU port pvid would keep changing. Fallback mode should only apply on ingress from CPU, so there's no danger really.
Thanks,
-Vladimir
Florian Fainelli
Reviewed-byQuoted 25 lines · Vladimir Oltean
Quoted 14 lines · Florian Fainelli
Quoted 10 lines · DENG Qingfang
Currently, setting a bridge's self PVID to other value and deleting the default VID 1 renders untagged ports of that VLAN unable to talk to the CPU port:
bridge vlan add dev br0 vid 2 pvid untagged self bridge vlan del dev br0 vid 1 self
bridge vlan add dev sw0p0 vid 2 pvid untagged bridge vlan del dev sw0p0 vid 1
# br0 cannot send untagged frames out of sw0p0 anymoreQuoted 9 lines
Quoted 4 lines
That is because the CPU port is set to security mode and its PVID is still 1, and untagged frames are dropped due to VLAN member violation.
Set the CPU port to fallback mode so untagged frames can pass through.
How about if the bridge has vlan_filtering=1? The use case you present seems to be valid to me, that is, you may create a VLAN just for the user ports and not have the CPU port be part of it at all.
Quoted 4 lines
What Qingfang is doing is in effect (but not by intention) removing the front panel port sw0p0 from the membership list of the CPU port's pvid. What you seem to be thinking of (VLAN of which the CPU is not a member of) does not seem to be supported in DSA at the moment.
Indeed and I replied to Qingfang already that I had misunderstood his patch originally.
Quoted 7 lines
As a fix, there's nothing wrong with the patch actually, I don't even know how it would work otherwise. DSA doesn't change the pvid of the CPU port when the pvid of a slave changes, because 4 slave ports could have 4 different pvids and the CPU port pvid would keep changing. Fallback mode should only apply on ingress from CPU, so there's no danger really.
Agreed.
Signature · 1 line
Florian
From: DENG Qingfang <[email protected]>
Date: Wed, 13 May 2020 23:37:17 +0800
Quoted 10 lines
Currently, setting a bridge's self PVID to other value and deleting the default VID 1 renders untagged ports of that VLAN unable to talk to the CPU port:
bridge vlan add dev br0 vid 2 pvid untagged self bridge vlan del dev br0 vid 1 self
bridge vlan add dev sw0p0 vid 2 pvid untagged bridge vlan del dev sw0p0 vid 1
# br0 cannot send untagged frames out of sw0p0 anymore
Quoted 7 lines
That is because the CPU port is set to security mode and its PVID is still 1, and untagged frames are dropped due to VLAN member violation.
Set the CPU port to fallback mode so untagged frames can pass through.
Fixes 83163f7dca56 ("net: dsa: mediatek: add VLAN support for MT7530")Signed-off-by DENG Qingfang <[email protected]>
Applied to net-next, thanks.