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}
6 Rework vlan_add/vlan_del functions in preparation for dynamic cpu port.
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.
11 Let DSA core decide when to call port_vlan_add for the CPU port, rather
12 than doing it implicitly.
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.
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>
24 drivers/net/dsa/mt7530.c | 30 ++++++++++++------------------
25 1 file changed, 12 insertions(+), 18 deletions(-)
27 --- a/drivers/net/dsa/mt7530.c
28 +++ b/drivers/net/dsa/mt7530.c
29 @@ -1522,11 +1522,11 @@ static void
30 mt7530_hw_vlan_add(struct mt7530_priv *priv,
31 struct mt7530_hw_vlan_entry *entry)
33 + struct dsa_port *dp = dsa_to_port(priv->ds, entry->port);
37 - new_members = entry->old_members | BIT(entry->port) |
38 - BIT(MT7530_CPU_PORT);
39 + new_members = entry->old_members | BIT(entry->port);
41 /* Validate the entry with independent learning, create egress tag per
42 * VLAN and joining the port as one of the port members.
43 @@ -1537,22 +1537,20 @@ mt7530_hw_vlan_add(struct mt7530_priv *p
45 /* Decide whether adding tag or not for those outgoing packets from the
46 * port inside the VLAN.
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));
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
60 + if (dsa_port_is_cpu(dp))
61 + val = MT7530_VLAN_EGRESS_STACK;
62 + else if (entry->untagged)
63 + val = MT7530_VLAN_EGRESS_UNTAG;
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));
75 @@ -1571,11 +1569,7 @@ mt7530_hw_vlan_del(struct mt7530_priv *p
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
83 - if (new_members && new_members != BIT(MT7530_CPU_PORT)) {
85 val = IVL_MAC | VTAG_EN | PORT_MEM(new_members) |
87 mt7530_write(priv, MT7530_VAWD1, val);