2022-10-21 21:08:54 +00:00
|
|
|
From 73472c830eae5fce2107f7f086f1e6827d215caf Mon Sep 17 00:00:00 2001
|
2022-08-26 14:21:44 +00:00
|
|
|
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
|
2022-10-21 21:08:54 +00:00
|
|
|
Date: Tue, 13 Sep 2022 20:06:48 +0100
|
|
|
|
Subject: [PATCH 1/1] net: sfp: add support for HALNy GPON SFP
|
2022-08-26 14:21:44 +00:00
|
|
|
|
|
|
|
Add a quirk for the HALNy HL-GSFP module, which appears to have an
|
2022-10-21 21:08:54 +00:00
|
|
|
inverted RX_LOS signal, and maybe uses TX_FAULT as a serial port
|
|
|
|
transmit pin. Rather than use these hardware signals, switch to
|
|
|
|
using software polling for these status signals.
|
2022-08-26 14:21:44 +00:00
|
|
|
|
|
|
|
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
2022-10-21 21:08:54 +00:00
|
|
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
2022-08-26 14:21:44 +00:00
|
|
|
---
|
|
|
|
drivers/net/phy/sfp-bus.c | 2 +-
|
2022-10-21 21:08:54 +00:00
|
|
|
drivers/net/phy/sfp.c | 21 ++++++++++++++++++---
|
|
|
|
2 files changed, 19 insertions(+), 4 deletions(-)
|
2022-08-26 14:21:44 +00:00
|
|
|
|
|
|
|
--- a/drivers/net/phy/sfp-bus.c
|
|
|
|
+++ b/drivers/net/phy/sfp-bus.c
|
|
|
|
@@ -283,7 +283,7 @@ void sfp_parse_support(struct sfp_bus *b
|
|
|
|
phylink_set(modes, 2500baseX_Full);
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (bus->sfp_quirk)
|
|
|
|
+ if (bus->sfp_quirk && bus->sfp_quirk->modes)
|
|
|
|
bus->sfp_quirk->modes(id, modes);
|
|
|
|
|
2022-09-07 02:54:34 +00:00
|
|
|
linkmode_or(support, support, modes);
|
2022-08-26 14:21:44 +00:00
|
|
|
--- a/drivers/net/phy/sfp.c
|
|
|
|
+++ b/drivers/net/phy/sfp.c
|
2023-04-20 12:53:12 +00:00
|
|
|
@@ -327,6 +327,15 @@ static void sfp_fixup_ignore_tx_fault(st
|
2022-08-26 14:21:44 +00:00
|
|
|
sfp->tx_fault_ignore = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static void sfp_fixup_halny_gsfp(struct sfp *sfp)
|
|
|
|
+{
|
2022-10-21 21:08:54 +00:00
|
|
|
+ /* Ignore the TX_FAULT and LOS signals on this module.
|
|
|
|
+ * these are possibly used for other purposes on this
|
|
|
|
+ * module, e.g. a serial port.
|
|
|
|
+ */
|
|
|
|
+ sfp->state_hw_mask &= ~(SFP_F_TX_FAULT | SFP_F_LOS);
|
2022-08-26 14:21:44 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id,
|
|
|
|
unsigned long *modes)
|
|
|
|
{
|
2023-04-20 12:53:12 +00:00
|
|
|
@@ -359,6 +368,10 @@ static const struct sfp_quirk sfp_quirks
|
2022-08-26 14:21:44 +00:00
|
|
|
.modes = sfp_quirk_2500basex,
|
|
|
|
.fixup = sfp_fixup_long_startup,
|
|
|
|
}, {
|
|
|
|
+ .vendor = "HALNy",
|
|
|
|
+ .part = "HL-GSFP",
|
|
|
|
+ .fixup = sfp_fixup_halny_gsfp,
|
|
|
|
+ }, {
|
|
|
|
// Huawei MA5671A can operate at 2500base-X, but report 1.2GBd
|
|
|
|
// NRZ in their EEPROM
|
|
|
|
.vendor = "HUAWEI",
|
2023-04-20 12:53:12 +00:00
|
|
|
@@ -375,16 +388,18 @@ static const struct sfp_quirk sfp_quirks
|
2022-08-26 14:21:44 +00:00
|
|
|
.vendor = "UBNT",
|
|
|
|
.part = "UF-INSTANT",
|
|
|
|
.modes = sfp_quirk_ubnt_uf_instant,
|
|
|
|
- },
|
|
|
|
+ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static size_t sfp_strlen(const char *str, size_t maxlen)
|
|
|
|
{
|
|
|
|
size_t size, i;
|
|
|
|
|
|
|
|
- /* Trailing characters should be filled with space chars */
|
|
|
|
+ /* Trailing characters should be filled with space chars, but
|
|
|
|
+ * some manufacturers can't read SFF-8472 and use NUL.
|
|
|
|
+ */
|
|
|
|
for (i = 0, size = 0; i < maxlen; i++)
|
|
|
|
- if (str[i] != ' ')
|
|
|
|
+ if (str[i] != ' ' && str[i] != '\0')
|
|
|
|
size = i + 1;
|
|
|
|
|
|
|
|
return size;
|