forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generic: 6.1: sync mt7530 DSA driver with upstream
Backport lots upstream changes, many of them fixes, for the mt7530 DSA driver. Some of them may or may not find they way into Linux 6.1 stable, some certainly won't because they are fixes for backported commits which aren't even present in Linux 6.1 upstream. Apart from adding new patches, also remove mutated patch 723-net-mt7531-ensure-all-MACs-are-powered-down-before-r.patch which should never have been added for Linux 6.1 -- it was applied already upstream but coincidentally would fuzzy-apply in the wrong place as well (for MT7530 instead of MT7531). While that didn't really hurt anyone it is just unneeded. The other deleted patch 795-mt7530-register-OF-node-for-internal-MDIO-bus.patch has been replaced by an equivalent commit with a more complete patch description by upstream maintainer Arınç Ünal. The remaining differences compared to the upstream driver are: * C22/C45 MDIO ops aren't split Upstream did that, backporting it would require making changes to *all* DSA drivers * 'slave' -> 'user', 'master' -> 'conduit' language change in DSA * support for selecting preferred CPU port on MT7531 Also this would require too many DSA framework changes potentially affecting other devices. If we ever really use Linux 6.1 in a release (I hope not) we can still reconsider to make the effort to backport that. In addition to some minor bug fixes and style improvements the switch should now behave more conformant when it comes to link-local frames, and we will again be able to cleanly pick patches from upstream. MAINTAIERS NOTE: Three patches are already part of Linux stable and should be removed with the next minor kernel version bump: 789-STABLE-01-net-dsa-mt7530-prevent-possible-incorrect-XTAL-frequ.patch 789-STABLE-02-net-dsa-mt7530-fix-link-local-frames-that-ingress-vl.patch 789-STABLE-03-net-dsa-mt7530-fix-handling-of-all-link-local-frames.patch Signed-off-by: Daniel Golle <daniel@makrotopia.org>
- Loading branch information
Showing
52 changed files
with
3,340 additions
and
256 deletions.
There are no files selected for viewing
172 changes: 172 additions & 0 deletions
172
...ric/backport-6.1/789-STABLE-01-net-dsa-mt7530-prevent-possible-incorrect-XTAL-frequ.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
From be4512b9ac6fc53e1ca8daccbda84f643215c547 Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com> | ||
Date: Thu, 14 Mar 2024 12:28:35 +0300 | ||
Subject: [PATCH 1/3] net: dsa: mt7530: prevent possible incorrect XTAL | ||
frequency selection | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
|
||
[ Upstream commit f490c492e946d8ffbe65ad4efc66de3c5ede30a4 ] | ||
|
||
On MT7530, the HT_XTAL_FSEL field of the HWTRAP register stores a 2-bit | ||
value that represents the frequency of the crystal oscillator connected to | ||
the switch IC. The field is populated by the state of the ESW_P4_LED_0 and | ||
ESW_P4_LED_0 pins, which is done right after reset is deasserted. | ||
|
||
ESW_P4_LED_0 ESW_P3_LED_0 Frequency | ||
----------------------------------------- | ||
0 0 Reserved | ||
0 1 20MHz | ||
1 0 40MHz | ||
1 1 25MHz | ||
|
||
On MT7531, the XTAL25 bit of the STRAP register stores this. The LAN0LED0 | ||
pin is used to populate the bit. 25MHz when the pin is high, 40MHz when | ||
it's low. | ||
|
||
These pins are also used with LEDs, therefore, their state can be set to | ||
something other than the bootstrapping configuration. For example, a link | ||
may be established on port 3 before the DSA subdriver takes control of the | ||
switch which would set ESW_P3_LED_0 to high. | ||
|
||
Currently on mt7530_setup() and mt7531_setup(), 1000 - 1100 usec delay is | ||
described between reset assertion and deassertion. Some switch ICs in real | ||
life conditions cannot always have these pins set back to the bootstrapping | ||
configuration before reset deassertion in this amount of delay. This causes | ||
wrong crystal frequency to be selected which puts the switch in a | ||
nonfunctional state after reset deassertion. | ||
|
||
The tests below are conducted on an MT7530 with a 40MHz crystal oscillator | ||
by Justin Swartz. | ||
|
||
With a cable from an active peer connected to port 3 before reset, an | ||
incorrect crystal frequency (0b11 = 25MHz) is selected: | ||
|
||
[1] [3] [5] | ||
: : : | ||
_____________________________ __________________ | ||
ESW_P4_LED_0 |_______| | ||
_____________________________ | ||
ESW_P3_LED_0 |__________________________ | ||
|
||
: : : : | ||
: : [4]...: | ||
: : | ||
[2]................: | ||
|
||
[1] Reset is asserted. | ||
[2] Period of 1000 - 1100 usec. | ||
[3] Reset is deasserted. | ||
[4] Period of 315 usec. HWTRAP register is populated with incorrect | ||
XTAL frequency. | ||
[5] Signals reflect the bootstrapped configuration. | ||
|
||
Increase the delay between reset_control_assert() and | ||
reset_control_deassert(), and gpiod_set_value_cansleep(priv->reset, 0) and | ||
gpiod_set_value_cansleep(priv->reset, 1) to 5000 - 5100 usec. This amount | ||
ensures a higher possibility that the switch IC will have these pins back | ||
to the bootstrapping configuration before reset deassertion. | ||
|
||
With a cable from an active peer connected to port 3 before reset, the | ||
correct crystal frequency (0b10 = 40MHz) is selected: | ||
|
||
[1] [2-1] [3] [5] | ||
: : : : | ||
_____________________________ __________________ | ||
ESW_P4_LED_0 |_______| | ||
___________________ _______ | ||
ESW_P3_LED_0 |_________| |__________________ | ||
|
||
: : : : : | ||
: [2-2]...: [4]...: | ||
[2]................: | ||
|
||
[1] Reset is asserted. | ||
[2] Period of 5000 - 5100 usec. | ||
[2-1] ESW_P3_LED_0 goes low. | ||
[2-2] Remaining period of 5000 - 5100 usec. | ||
[3] Reset is deasserted. | ||
[4] Period of 310 usec. HWTRAP register is populated with bootstrapped | ||
XTAL frequency. | ||
[5] Signals reflect the bootstrapped configuration. | ||
|
||
ESW_P3_LED_0 low period before reset deassertion: | ||
|
||
5000 usec | ||
- 5100 usec | ||
TEST RESET HOLD | ||
# (usec) | ||
--------------------- | ||
1 5410 | ||
2 5440 | ||
3 4375 | ||
4 5490 | ||
5 5475 | ||
6 4335 | ||
7 4370 | ||
8 5435 | ||
9 4205 | ||
10 4335 | ||
11 3750 | ||
12 3170 | ||
13 4395 | ||
14 4375 | ||
15 3515 | ||
16 4335 | ||
17 4220 | ||
18 4175 | ||
19 4175 | ||
20 4350 | ||
|
||
Min 3170 | ||
Max 5490 | ||
|
||
Median 4342.500 | ||
Avg 4466.500 | ||
|
||
Revert commit 2920dd92b980 ("net: dsa: mt7530: disable LEDs before reset"). | ||
Changing the state of pins via reset assertion is simpler and more | ||
efficient than doing so by setting the LED controller off. | ||
|
||
Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch") | ||
Fixes: c288575f7810 ("net: dsa: mt7530: Add the support of MT7531 switch") | ||
Co-developed-by: Justin Swartz <justin.swartz@risingedge.co.za> | ||
Signed-off-by: Justin Swartz <justin.swartz@risingedge.co.za> | ||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com> | ||
Signed-off-by: David S. Miller <davem@davemloft.net> | ||
Signed-off-by: Sasha Levin <sashal@kernel.org> | ||
--- | ||
drivers/net/dsa/mt7530.c | 8 ++++---- | ||
1 file changed, 4 insertions(+), 4 deletions(-) | ||
|
||
--- a/drivers/net/dsa/mt7530.c | ||
+++ b/drivers/net/dsa/mt7530.c | ||
@@ -2187,11 +2187,11 @@ mt7530_setup(struct dsa_switch *ds) | ||
*/ | ||
if (priv->mcm) { | ||
reset_control_assert(priv->rstc); | ||
- usleep_range(1000, 1100); | ||
+ usleep_range(5000, 5100); | ||
reset_control_deassert(priv->rstc); | ||
} else { | ||
gpiod_set_value_cansleep(priv->reset, 0); | ||
- usleep_range(1000, 1100); | ||
+ usleep_range(5000, 5100); | ||
gpiod_set_value_cansleep(priv->reset, 1); | ||
} | ||
|
||
@@ -2401,11 +2401,11 @@ mt7531_setup(struct dsa_switch *ds) | ||
*/ | ||
if (priv->mcm) { | ||
reset_control_assert(priv->rstc); | ||
- usleep_range(1000, 1100); | ||
+ usleep_range(5000, 5100); | ||
reset_control_deassert(priv->rstc); | ||
} else { | ||
gpiod_set_value_cansleep(priv->reset, 0); | ||
- usleep_range(1000, 1100); | ||
+ usleep_range(5000, 5100); | ||
gpiod_set_value_cansleep(priv->reset, 1); | ||
} | ||
|
173 changes: 173 additions & 0 deletions
173
...ric/backport-6.1/789-STABLE-02-net-dsa-mt7530-fix-link-local-frames-that-ingress-vl.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
From f1fa919ea59655f73cb3972264e157b8831ba546 Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com> | ||
Date: Thu, 14 Mar 2024 12:33:41 +0300 | ||
Subject: [PATCH 2/3] net: dsa: mt7530: fix link-local frames that ingress vlan | ||
filtering ports | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
|
||
[ Upstream commit e8bf353577f382c7066c661fed41b2adc0fc7c40 ] | ||
|
||
Whether VLAN-aware or not, on every VID VLAN table entry that has the CPU | ||
port as a member of it, frames are set to egress the CPU port with the VLAN | ||
tag stacked. This is so that VLAN tags can be appended after hardware | ||
special tag (called DSA tag in the context of Linux drivers). | ||
|
||
For user ports on a VLAN-unaware bridge, frame ingressing the user port | ||
egresses CPU port with only the special tag. | ||
|
||
For user ports on a VLAN-aware bridge, frame ingressing the user port | ||
egresses CPU port with the special tag and the VLAN tag. | ||
|
||
This causes issues with link-local frames, specifically BPDUs, because the | ||
software expects to receive them VLAN-untagged. | ||
|
||
There are two options to make link-local frames egress untagged. Setting | ||
CONSISTENT or UNTAGGED on the EG_TAG bits on the relevant register. | ||
CONSISTENT means frames egress exactly as they ingress. That means | ||
egressing with the VLAN tag they had at ingress or egressing untagged if | ||
they ingressed untagged. Although link-local frames are not supposed to be | ||
transmitted VLAN-tagged, if they are done so, when egressing through a CPU | ||
port, the special tag field will be broken. | ||
|
||
BPDU egresses CPU port with VLAN tag egressing stacked, received on | ||
software: | ||
|
||
00:01:25.104821 AF Unknown (382365846), length 106: | ||
| STAG | | VLAN | | ||
0x0000: 0000 6c27 614d 4143 0001 0000 8100 0001 ..l'aMAC........ | ||
0x0010: 0026 4242 0300 0000 0000 0000 6c27 614d .&BB........l'aM | ||
0x0020: 4143 0000 0000 0000 6c27 614d 4143 0000 AC......l'aMAC.. | ||
0x0030: 0000 1400 0200 0f00 0000 0000 0000 0000 ................ | ||
|
||
BPDU egresses CPU port with VLAN tag egressing untagged, received on | ||
software: | ||
|
||
00:23:56.628708 AF Unknown (25215488), length 64: | ||
| STAG | | ||
0x0000: 0000 6c27 614d 4143 0001 0000 0026 4242 ..l'aMAC.....&BB | ||
0x0010: 0300 0000 0000 0000 6c27 614d 4143 0000 ........l'aMAC.. | ||
0x0020: 0000 0000 6c27 614d 4143 0000 0000 1400 ....l'aMAC...... | ||
0x0030: 0200 0f00 0000 0000 0000 0000 ............ | ||
|
||
BPDU egresses CPU port with VLAN tag egressing tagged, received on | ||
software: | ||
|
||
00:01:34.311963 AF Unknown (25215488), length 64: | ||
| Mess | | ||
0x0000: 0000 6c27 614d 4143 0001 0001 0026 4242 ..l'aMAC.....&BB | ||
0x0010: 0300 0000 0000 0000 6c27 614d 4143 0000 ........l'aMAC.. | ||
0x0020: 0000 0000 6c27 614d 4143 0000 0000 1400 ....l'aMAC...... | ||
0x0030: 0200 0f00 0000 0000 0000 0000 ............ | ||
|
||
To prevent confusing the software, force the frame to egress UNTAGGED | ||
instead of CONSISTENT. This way, frames can't possibly be received TAGGED | ||
by software which would have the special tag field broken. | ||
|
||
VLAN Tag Egress Procedure | ||
|
||
For all frames, one of these options set the earliest in this order will | ||
apply to the frame: | ||
|
||
- EG_TAG in certain registers for certain frames. | ||
This will apply to frame with matching MAC DA or EtherType. | ||
|
||
- EG_TAG in the address table. | ||
This will apply to frame at its incoming port. | ||
|
||
- EG_TAG in the PVC register. | ||
This will apply to frame at its incoming port. | ||
|
||
- EG_CON and [EG_TAG per port] in the VLAN table. | ||
This will apply to frame at its outgoing port. | ||
|
||
- EG_TAG in the PCR register. | ||
This will apply to frame at its outgoing port. | ||
|
||
EG_TAG in certain registers for certain frames: | ||
|
||
PPPoE Discovery_ARP/RARP: PPP_EG_TAG and ARP_EG_TAG in the APC register. | ||
IGMP_MLD: IGMP_EG_TAG and MLD_EG_TAG in the IMC register. | ||
BPDU and PAE: BPDU_EG_TAG and PAE_EG_TAG in the BPC register. | ||
REV_01 and REV_02: R01_EG_TAG and R02_EG_TAG in the RGAC1 register. | ||
REV_03 and REV_0E: R03_EG_TAG and R0E_EG_TAG in the RGAC2 register. | ||
REV_10 and REV_20: R10_EG_TAG and R20_EG_TAG in the RGAC3 register. | ||
REV_21 and REV_UN: R21_EG_TAG and RUN_EG_TAG in the RGAC4 register. | ||
|
||
With this change, it can be observed that a bridge interface with stp_state | ||
and vlan_filtering enabled will properly block ports now. | ||
|
||
Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch") | ||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com> | ||
Signed-off-by: Paolo Abeni <pabeni@redhat.com> | ||
Signed-off-by: Sasha Levin <sashal@kernel.org> | ||
--- | ||
drivers/net/dsa/mt7530.c | 23 +++++++++++++++-------- | ||
drivers/net/dsa/mt7530.h | 9 ++++++++- | ||
2 files changed, 23 insertions(+), 9 deletions(-) | ||
|
||
--- a/drivers/net/dsa/mt7530.c | ||
+++ b/drivers/net/dsa/mt7530.c | ||
@@ -1001,16 +1001,23 @@ unlock_exit: | ||
static void | ||
mt753x_trap_frames(struct mt7530_priv *priv) | ||
{ | ||
- /* Trap BPDUs to the CPU port(s) */ | ||
- mt7530_rmw(priv, MT753X_BPC, MT753X_BPDU_PORT_FW_MASK, | ||
+ /* Trap 802.1X PAE frames and BPDUs to the CPU port(s) and egress them | ||
+ * VLAN-untagged. | ||
+ */ | ||
+ mt7530_rmw(priv, MT753X_BPC, MT753X_PAE_EG_TAG_MASK | | ||
+ MT753X_PAE_PORT_FW_MASK | MT753X_BPDU_EG_TAG_MASK | | ||
+ MT753X_BPDU_PORT_FW_MASK, | ||
+ MT753X_PAE_EG_TAG(MT7530_VLAN_EG_UNTAGGED) | | ||
+ MT753X_PAE_PORT_FW(MT753X_BPDU_CPU_ONLY) | | ||
+ MT753X_BPDU_EG_TAG(MT7530_VLAN_EG_UNTAGGED) | | ||
MT753X_BPDU_CPU_ONLY); | ||
|
||
- /* Trap 802.1X PAE frames to the CPU port(s) */ | ||
- mt7530_rmw(priv, MT753X_BPC, MT753X_PAE_PORT_FW_MASK, | ||
- MT753X_PAE_PORT_FW(MT753X_BPDU_CPU_ONLY)); | ||
- | ||
- /* Trap LLDP frames with :0E MAC DA to the CPU port(s) */ | ||
- mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_PORT_FW_MASK, | ||
+ /* Trap LLDP frames with :0E MAC DA to the CPU port(s) and egress them | ||
+ * VLAN-untagged. | ||
+ */ | ||
+ mt7530_rmw(priv, MT753X_RGAC2, MT753X_R0E_EG_TAG_MASK | | ||
+ MT753X_R0E_PORT_FW_MASK, | ||
+ MT753X_R0E_EG_TAG(MT7530_VLAN_EG_UNTAGGED) | | ||
MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY)); | ||
} | ||
|
||
--- a/drivers/net/dsa/mt7530.h | ||
+++ b/drivers/net/dsa/mt7530.h | ||
@@ -63,12 +63,18 @@ enum mt753x_id { | ||
|
||
/* Registers for BPDU and PAE frame control*/ | ||
#define MT753X_BPC 0x24 | ||
-#define MT753X_BPDU_PORT_FW_MASK GENMASK(2, 0) | ||
+#define MT753X_PAE_EG_TAG_MASK GENMASK(24, 22) | ||
+#define MT753X_PAE_EG_TAG(x) FIELD_PREP(MT753X_PAE_EG_TAG_MASK, x) | ||
#define MT753X_PAE_PORT_FW_MASK GENMASK(18, 16) | ||
#define MT753X_PAE_PORT_FW(x) FIELD_PREP(MT753X_PAE_PORT_FW_MASK, x) | ||
+#define MT753X_BPDU_EG_TAG_MASK GENMASK(8, 6) | ||
+#define MT753X_BPDU_EG_TAG(x) FIELD_PREP(MT753X_BPDU_EG_TAG_MASK, x) | ||
+#define MT753X_BPDU_PORT_FW_MASK GENMASK(2, 0) | ||
|
||
/* Register for :03 and :0E MAC DA frame control */ | ||
#define MT753X_RGAC2 0x2c | ||
+#define MT753X_R0E_EG_TAG_MASK GENMASK(24, 22) | ||
+#define MT753X_R0E_EG_TAG(x) FIELD_PREP(MT753X_R0E_EG_TAG_MASK, x) | ||
#define MT753X_R0E_PORT_FW_MASK GENMASK(18, 16) | ||
#define MT753X_R0E_PORT_FW(x) FIELD_PREP(MT753X_R0E_PORT_FW_MASK, x) | ||
|
||
@@ -251,6 +257,7 @@ enum mt7530_port_mode { | ||
enum mt7530_vlan_port_eg_tag { | ||
MT7530_VLAN_EG_DISABLED = 0, | ||
MT7530_VLAN_EG_CONSISTENT = 1, | ||
+ MT7530_VLAN_EG_UNTAGGED = 4, | ||
}; | ||
|
||
enum mt7530_vlan_port_attr { |
Oops, something went wrong.