generic: 6.1, 6.6: mt7530: import accepted patches
[openwrt/openwrt.git] / target / linux / generic / backport-6.6 / 790-34-v6.10-net-dsa-mt7530-fix-mirroring-frames-received-on-loca.patch
1 From d4097ddef078a113643a6dcde01e99741f852adb Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
3 Date: Sat, 13 Apr 2024 16:01:39 +0300
4 Subject: [PATCH 2/5] net: dsa: mt7530: fix mirroring frames received on local
5 port
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 This switch intellectual property provides a bit on the ARL global control
11 register which controls allowing mirroring frames which are received on the
12 local port (monitor port). This bit is unset after reset.
13
14 This ability must be enabled to fully support the port mirroring feature on
15 this switch intellectual property.
16
17 Therefore, this patch fixes the traffic not being reflected on a port,
18 which would be configured like below:
19
20 tc qdisc add dev swp0 clsact
21
22 tc filter add dev swp0 ingress matchall skip_sw \
23 action mirred egress mirror dev swp0
24
25 As a side note, this configuration provides the hairpinning feature for a
26 single port.
27
28 Fixes: 37feab6076aa ("net: dsa: mt7530: add support for port mirroring")
29 Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
30 Signed-off-by: David S. Miller <davem@davemloft.net>
31 ---
32 drivers/net/dsa/mt7530.c | 6 ++++++
33 drivers/net/dsa/mt7530.h | 4 ++++
34 2 files changed, 10 insertions(+)
35
36 --- a/drivers/net/dsa/mt7530.c
37 +++ b/drivers/net/dsa/mt7530.c
38 @@ -2480,6 +2480,9 @@ mt7530_setup(struct dsa_switch *ds)
39 PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
40 }
41
42 + /* Allow mirroring frames received on the local port (monitor port). */
43 + mt7530_set(priv, MT753X_AGC, LOCAL_EN);
44 +
45 /* Setup VLAN ID 0 for VLAN-unaware bridges */
46 ret = mt7530_setup_vlan0(priv);
47 if (ret)
48 @@ -2591,6 +2594,9 @@ mt7531_setup_common(struct dsa_switch *d
49 PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
50 }
51
52 + /* Allow mirroring frames received on the local port (monitor port). */
53 + mt7530_set(priv, MT753X_AGC, LOCAL_EN);
54 +
55 /* Flush the FDB table */
56 ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
57 if (ret < 0)
58 --- a/drivers/net/dsa/mt7530.h
59 +++ b/drivers/net/dsa/mt7530.h
60 @@ -32,6 +32,10 @@ enum mt753x_id {
61 #define SYSC_REG_RSTCTRL 0x34
62 #define RESET_MCM BIT(2)
63
64 +/* Register for ARL global control */
65 +#define MT753X_AGC 0xc
66 +#define LOCAL_EN BIT(7)
67 +
68 /* Registers to mac forward control for unknown frames */
69 #define MT7530_MFC 0x10
70 #define BC_FFP(x) (((x) & 0xff) << 24)