diff options
author | Marek BehĂșn <marek.behun@nic.cz> | 2022-01-08 19:56:02 +0100 |
---|---|---|
committer | Christian Lamparter <chunkeey@gmail.com> | 2022-03-26 21:26:07 +0100 |
commit | 0e5350db439259347db2ab689325915864c75e06 (patch) | |
tree | f4cfd5f6d7ebc47c6241b29550113e79dbabae24 /target/linux/generic/backport-5.4 | |
parent | 52de8bf86e616de1b86ec2ab5e874029339adb16 (diff) | |
download | upstream-0e5350db439259347db2ab689325915864c75e06.tar.gz upstream-0e5350db439259347db2ab689325915864c75e06.tar.bz2 upstream-0e5350db439259347db2ab689325915864c75e06.zip |
mvebu: SFP backports for GPON modules
This backports the following upstream Linux patches
net: sfp: add mode quirk for GPON module Ubiquiti U-Fiber Instant
net: sfp: relax bitrate-derived mode check
net: sfp: cope with SFPs that set both LOS normal and LOS inverted
for 5.4 for mvebu platform.
This fixes GPON modules:
Ubiquiti U-Fiber Instant SFP GPON
VSOL V2801F
CarlitoxxPro CPGOS03-0490 v2.0
Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Diffstat (limited to 'target/linux/generic/backport-5.4')
3 files changed, 101 insertions, 7 deletions
diff --git a/target/linux/generic/backport-5.4/768-net-sfp-cope-with-SFPs-that-set-both-LOS-normal-and-.patch b/target/linux/generic/backport-5.4/768-net-sfp-cope-with-SFPs-that-set-both-LOS-normal-and-.patch new file mode 100644 index 0000000000..fbbaae1d2b --- /dev/null +++ b/target/linux/generic/backport-5.4/768-net-sfp-cope-with-SFPs-that-set-both-LOS-normal-and-.patch @@ -0,0 +1,94 @@ +From da5bc1832b325b15e4cca3b63861ecf48be870ef Mon Sep 17 00:00:00 2001 +From: Russell King <rmk+kernel@armlinux.org.uk> +Date: Sun, 10 Jan 2021 10:58:32 +0000 +Subject: [PATCH] net: sfp: cope with SFPs that set both LOS normal and LOS + inverted + +The SFP MSA defines two option bits in byte 65 to indicate how the +Rx_LOS signal on SFP pin 8 behaves: + +bit 2 - Loss of Signal implemented, signal inverted from standard + definition in SFP MSA (often called "Signal Detect"). +bit 1 - Loss of Signal implemented, signal as defined in SFP MSA + (often called "Rx_LOS"). + +Clearly, setting both bits results in a meaningless situation: it would +mean that LOS is implemented in both the normal sense (1 = signal loss) +and inverted sense (0 = signal loss). + +Unfortunately, there are modules out there which set both bits, which +will be initially interpret as "inverted" sense, and then, if the LOS +signal changes state, we will toggle between LINK_UP and WAIT_LOS +states. + +Change our LOS handling to give well defined behaviour: only interpret +these bits as meaningful if exactly one is set, otherwise treat it as +if LOS is not implemented. + +Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> +Reviewed-by: Andrew Lunn <andrew@lunn.ch> +Link: https://lore.kernel.org/r/E1kyYQa-0004iR-CU@rmk-PC.armlinux.org.uk +Signed-off-by: Jakub Kicinski <kuba@kernel.org> +--- + drivers/net/phy/sfp.c | 36 ++++++++++++++++++++++-------------- + 1 file changed, 22 insertions(+), 14 deletions(-) + +--- a/drivers/net/phy/sfp.c ++++ b/drivers/net/phy/sfp.c +@@ -1430,15 +1430,19 @@ static void sfp_sm_link_down(struct sfp + + static void sfp_sm_link_check_los(struct sfp *sfp) + { +- unsigned int los = sfp->state & SFP_F_LOS; ++ const __be16 los_inverted = cpu_to_be16(SFP_OPTIONS_LOS_INVERTED); ++ const __be16 los_normal = cpu_to_be16(SFP_OPTIONS_LOS_NORMAL); ++ __be16 los_options = sfp->id.ext.options & (los_inverted | los_normal); ++ bool los = false; + + /* If neither SFP_OPTIONS_LOS_INVERTED nor SFP_OPTIONS_LOS_NORMAL +- * are set, we assume that no LOS signal is available. ++ * are set, we assume that no LOS signal is available. If both are ++ * set, we assume LOS is not implemented (and is meaningless.) + */ +- if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_INVERTED)) +- los ^= SFP_F_LOS; +- else if (!(sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_NORMAL))) +- los = 0; ++ if (los_options == los_inverted) ++ los = !(sfp->state & SFP_F_LOS); ++ else if (los_options == los_normal) ++ los = !!(sfp->state & SFP_F_LOS); + + if (los) + sfp_sm_next(sfp, SFP_S_WAIT_LOS, 0); +@@ -1448,18 +1452,22 @@ static void sfp_sm_link_check_los(struct + + static bool sfp_los_event_active(struct sfp *sfp, unsigned int event) + { +- return (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_INVERTED) && +- event == SFP_E_LOS_LOW) || +- (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_NORMAL) && +- event == SFP_E_LOS_HIGH); ++ const __be16 los_inverted = cpu_to_be16(SFP_OPTIONS_LOS_INVERTED); ++ const __be16 los_normal = cpu_to_be16(SFP_OPTIONS_LOS_NORMAL); ++ __be16 los_options = sfp->id.ext.options & (los_inverted | los_normal); ++ ++ return (los_options == los_inverted && event == SFP_E_LOS_LOW) || ++ (los_options == los_normal && event == SFP_E_LOS_HIGH); + } + + static bool sfp_los_event_inactive(struct sfp *sfp, unsigned int event) + { +- return (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_INVERTED) && +- event == SFP_E_LOS_HIGH) || +- (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_NORMAL) && +- event == SFP_E_LOS_LOW); ++ const __be16 los_inverted = cpu_to_be16(SFP_OPTIONS_LOS_INVERTED); ++ const __be16 los_normal = cpu_to_be16(SFP_OPTIONS_LOS_NORMAL); ++ __be16 los_options = sfp->id.ext.options & (los_inverted | los_normal); ++ ++ return (los_options == los_inverted && event == SFP_E_LOS_HIGH) || ++ (los_options == los_normal && event == SFP_E_LOS_LOW); + } + + static void sfp_sm_fault(struct sfp *sfp, unsigned int next_state, bool warn) diff --git a/target/linux/generic/backport-5.4/852-v5.10-0001-net-sfp-VSOL-V2801F-CarlitoxxPro-CPGOS03-0490-v2.0-w.patch b/target/linux/generic/backport-5.4/852-v5.10-0001-net-sfp-VSOL-V2801F-CarlitoxxPro-CPGOS03-0490-v2.0-w.patch index 1901054a10..39f4b273ae 100644 --- a/target/linux/generic/backport-5.4/852-v5.10-0001-net-sfp-VSOL-V2801F-CarlitoxxPro-CPGOS03-0490-v2.0-w.patch +++ b/target/linux/generic/backport-5.4/852-v5.10-0001-net-sfp-VSOL-V2801F-CarlitoxxPro-CPGOS03-0490-v2.0-w.patch @@ -68,7 +68,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> msgs[1].len = this_len; -@@ -1569,6 +1579,28 @@ static int sfp_sm_mod_hpower(struct sfp +@@ -1577,6 +1587,28 @@ static int sfp_sm_mod_hpower(struct sfp return 0; } @@ -97,7 +97,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> static int sfp_sm_mod_probe(struct sfp *sfp, bool report) { /* SFP module inserted - read I2C data */ -@@ -1577,14 +1609,20 @@ static int sfp_sm_mod_probe(struct sfp * +@@ -1585,14 +1617,20 @@ static int sfp_sm_mod_probe(struct sfp * u8 check; int ret; @@ -120,7 +120,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net> dev_err(sfp->dev, "EEPROM short read: %d\n", ret); return -EAGAIN; } -@@ -1612,6 +1650,21 @@ static int sfp_sm_mod_probe(struct sfp * +@@ -1620,6 +1658,21 @@ static int sfp_sm_mod_probe(struct sfp * } } diff --git a/target/linux/generic/backport-5.4/852-v5.10-0002-net-sfp-add-workaround-for-Realtek-RTL8672-and-RTL96.patch b/target/linux/generic/backport-5.4/852-v5.10-0002-net-sfp-add-workaround-for-Realtek-RTL8672-and-RTL96.patch index 27ae97cee7..8c95284280 100644 --- a/target/linux/generic/backport-5.4/852-v5.10-0002-net-sfp-add-workaround-for-Realtek-RTL8672-and-RTL96.patch +++ b/target/linux/generic/backport-5.4/852-v5.10-0002-net-sfp-add-workaround-for-Realtek-RTL8672-and-RTL96.patch @@ -102,7 +102,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org> err = sfp_read(sfp, true, 0, &sfp->diag, sizeof(sfp->diag)); if (err < 0) { if (sfp->hwmon_tries--) { -@@ -1579,26 +1585,30 @@ static int sfp_sm_mod_hpower(struct sfp +@@ -1587,26 +1593,30 @@ static int sfp_sm_mod_hpower(struct sfp return 0; } @@ -149,7 +149,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org> } static int sfp_sm_mod_probe(struct sfp *sfp, bool report) -@@ -1609,11 +1619,11 @@ static int sfp_sm_mod_probe(struct sfp * +@@ -1617,11 +1627,11 @@ static int sfp_sm_mod_probe(struct sfp * u8 check; int ret; @@ -165,7 +165,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org> ret = sfp_read(sfp, false, 0, &id.base, sizeof(id.base)); if (ret < 0) { -@@ -1627,6 +1637,33 @@ static int sfp_sm_mod_probe(struct sfp * +@@ -1635,6 +1645,33 @@ static int sfp_sm_mod_probe(struct sfp * return -EAGAIN; } @@ -199,7 +199,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org> /* Cotsworks do not seem to update the checksums when they * do the final programming with the final module part number, * serial number and date code. -@@ -1650,9 +1687,6 @@ static int sfp_sm_mod_probe(struct sfp * +@@ -1658,9 +1695,6 @@ static int sfp_sm_mod_probe(struct sfp * } } |