26d207ca6ab75f3e6af4d06001668f1090855f4c
[openwrt/staging/hauke.git] / target / linux / generic / backport-5.15 / 705-11-v6.0-net-dsa-mt7530-rework-mt7530_hw_vlan_-add-del.patch
1 From e26be16262e1fc1e9f1798c12762663bd9c265c6 Mon Sep 17 00:00:00 2001
2 From: Frank Wunderlich <frank-w@public-files.de>
3 Date: Fri, 10 Jun 2022 19:05:37 +0200
4 Subject: [PATCH 11/13] net: dsa: mt7530: rework mt7530_hw_vlan_{add,del}
5
6 Rework vlan_add/vlan_del functions in preparation for dynamic cpu port.
7
8 Currently BIT(MT7530_CPU_PORT) is added to new_members, even though
9 mt7530_port_vlan_add() will be called on the CPU port too.
10
11 Let DSA core decide when to call port_vlan_add for the CPU port, rather
12 than doing it implicitly.
13
14 We can do autonomous forwarding in a certain VLAN, but not add br0 to that
15 VLAN and avoid flooding the CPU with those packets, if software knows it
16 doesn't need to process them.
17
18 Suggested-by: Vladimir Oltean <olteanv@gmail.com>
19 Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
20 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
21 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
22 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
23 ---
24 drivers/net/dsa/mt7530.c | 30 ++++++++++++------------------
25 1 file changed, 12 insertions(+), 18 deletions(-)
26
27 --- a/drivers/net/dsa/mt7530.c
28 +++ b/drivers/net/dsa/mt7530.c
29 @@ -1536,11 +1536,11 @@ static void
30 mt7530_hw_vlan_add(struct mt7530_priv *priv,
31 struct mt7530_hw_vlan_entry *entry)
32 {
33 + struct dsa_port *dp = dsa_to_port(priv->ds, entry->port);
34 u8 new_members;
35 u32 val;
36
37 - new_members = entry->old_members | BIT(entry->port) |
38 - BIT(MT7530_CPU_PORT);
39 + new_members = entry->old_members | BIT(entry->port);
40
41 /* Validate the entry with independent learning, create egress tag per
42 * VLAN and joining the port as one of the port members.
43 @@ -1551,22 +1551,20 @@ mt7530_hw_vlan_add(struct mt7530_priv *p
44
45 /* Decide whether adding tag or not for those outgoing packets from the
46 * port inside the VLAN.
47 - */
48 - val = entry->untagged ? MT7530_VLAN_EGRESS_UNTAG :
49 - MT7530_VLAN_EGRESS_TAG;
50 - mt7530_rmw(priv, MT7530_VAWD2,
51 - ETAG_CTRL_P_MASK(entry->port),
52 - ETAG_CTRL_P(entry->port, val));
53 -
54 - /* CPU port is always taken as a tagged port for serving more than one
55 + * CPU port is always taken as a tagged port for serving more than one
56 * VLANs across and also being applied with egress type stack mode for
57 * that VLAN tags would be appended after hardware special tag used as
58 * DSA tag.
59 */
60 + if (dsa_port_is_cpu(dp))
61 + val = MT7530_VLAN_EGRESS_STACK;
62 + else if (entry->untagged)
63 + val = MT7530_VLAN_EGRESS_UNTAG;
64 + else
65 + val = MT7530_VLAN_EGRESS_TAG;
66 mt7530_rmw(priv, MT7530_VAWD2,
67 - ETAG_CTRL_P_MASK(MT7530_CPU_PORT),
68 - ETAG_CTRL_P(MT7530_CPU_PORT,
69 - MT7530_VLAN_EGRESS_STACK));
70 + ETAG_CTRL_P_MASK(entry->port),
71 + ETAG_CTRL_P(entry->port, val));
72 }
73
74 static void
75 @@ -1585,11 +1583,7 @@ mt7530_hw_vlan_del(struct mt7530_priv *p
76 return;
77 }
78
79 - /* If certain member apart from CPU port is still alive in the VLAN,
80 - * the entry would be kept valid. Otherwise, the entry is got to be
81 - * disabled.
82 - */
83 - if (new_members && new_members != BIT(MT7530_CPU_PORT)) {
84 + if (new_members) {
85 val = IVL_MAC | VTAG_EN | PORT_MEM(new_members) |
86 VLAN_VALID;
87 mt7530_write(priv, MT7530_VAWD1, val);