generic: mt7530: set CPU port to fallback mode
[openwrt/staging/jow.git] / target / linux / generic / backport-5.4 / 751-v5.8-net-dsa-mt7530-set-CPU-port-to-fallback-mode.patch
1 From 38152ea37d8bdaffa22603e0a5b5b86cfa8714c9 Mon Sep 17 00:00:00 2001
2 From: DENG Qingfang <dqfext@gmail.com>
3 Date: Wed, 13 May 2020 23:37:17 +0800
4 Subject: net: dsa: mt7530: set CPU port to fallback mode
5
6 Currently, setting a bridge's self PVID to other value and deleting
7 the default VID 1 renders untagged ports of that VLAN unable to talk to
8 the CPU port:
9
10 bridge vlan add dev br0 vid 2 pvid untagged self
11 bridge vlan del dev br0 vid 1 self
12 bridge vlan add dev sw0p0 vid 2 pvid untagged
13 bridge vlan del dev sw0p0 vid 1
14 # br0 cannot send untagged frames out of sw0p0 anymore
15
16 That is because the CPU port is set to security mode and its PVID is
17 still 1, and untagged frames are dropped due to VLAN member violation.
18
19 Set the CPU port to fallback mode so untagged frames can pass through.
20
21 Fixes: 83163f7dca56 ("net: dsa: mediatek: add VLAN support for MT7530")
22 Signed-off-by: DENG Qingfang <dqfext@gmail.com>
23 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
24 Signed-off-by: David S. Miller <davem@davemloft.net>
25 ---
26 drivers/net/dsa/mt7530.c | 11 ++++++++---
27 drivers/net/dsa/mt7530.h | 6 ++++++
28 2 files changed, 14 insertions(+), 3 deletions(-)
29
30 --- a/drivers/net/dsa/mt7530.c
31 +++ b/drivers/net/dsa/mt7530.c
32 @@ -821,10 +821,15 @@ mt7530_port_set_vlan_aware(struct dsa_sw
33 PCR_MATRIX_MASK, PCR_MATRIX(MT7530_ALL_MEMBERS));
34
35 /* Trapped into security mode allows packet forwarding through VLAN
36 - * table lookup.
37 + * table lookup. CPU port is set to fallback mode to let untagged
38 + * frames pass through.
39 */
40 - mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK,
41 - MT7530_PORT_SECURITY_MODE);
42 + if (dsa_is_cpu_port(ds, port))
43 + mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK,
44 + MT7530_PORT_FALLBACK_MODE);
45 + else
46 + mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK,
47 + MT7530_PORT_SECURITY_MODE);
48
49 /* Set the port as a user port which is to be able to recognize VID
50 * from incoming packets before fetching entry within the VLAN table.
51 --- a/drivers/net/dsa/mt7530.h
52 +++ b/drivers/net/dsa/mt7530.h
53 @@ -152,6 +152,12 @@ enum mt7530_port_mode {
54 /* Port Matrix Mode: Frames are forwarded by the PCR_MATRIX members. */
55 MT7530_PORT_MATRIX_MODE = PORT_VLAN(0),
56
57 + /* Fallback Mode: Forward received frames with ingress ports that do
58 + * not belong to the VLAN member. Frames whose VID is not listed on
59 + * the VLAN table are forwarded by the PCR_MATRIX members.
60 + */
61 + MT7530_PORT_FALLBACK_MODE = PORT_VLAN(1),
62 +
63 /* Security Mode: Discard any frame due to ingress membership
64 * violation or VID missed on the VLAN table.
65 */