Add rudimentary SFP module quirk support
Subsystems (4)
Russell King - ARM Linux admin
maintainercover Add rudimentary SFP module quirk support
The SFP module EEPROM describes the capabilities of the module, but doesn't describe the host interface. We have a certain amount of guess-work to work out how to configure the host - which works most of the time.
However, there are some (such as GPON) modules which are able to support different host interfaces, such as 1000BASE-X and 2500BASE-X. The module will switch between each mode until it achieves link with the host.
There is no defined way to describe this in the SFP EEPROM, so we can only recognise the module and handle it appropriately. This series adds the necessary recognition of the modules using a quirk system, and tweaks the support mask to allow them to link with the host at 2500BASE-X, thereby allowing the user to achieve full line rate.
drivers/net/phy/sfp-bus.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
PATCH 1/2 net: sfp: add support for module quirks
Add support for applying module quirks to the list of supported ethtool link modes.
--- drivers/net/phy/sfp-bus.c | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
drivers/net/phy/sfp-bus.c +54 -0
@@ -10,6 +10,12 @@#include "sfp.h" +struct sfp_quirk { +const char *vendor; +const char *part; +void (*modes)(const struct sfp_eeprom_id *id,unsigned long *modes); +}; +/** * struct sfp_bus - internal representation of a sfp bus */
@@ -22,6 +28,7 @@ struct sfp_bus {const struct sfp_socket_ops *socket_ops;struct device *sfp_dev;struct sfp *sfp; +const struct sfp_quirk *sfp_quirk;const struct sfp_upstream_ops *upstream_ops;void *upstream;
@@ -31,6 +38,46 @@ struct sfp_bus {bool started; }; +static const struct sfp_quirk sfp_quirks[] = { +}; + +static size_t sfp_strlen (const char *str,size_t maxlen) +{ +size_t size, i; + +/* Trailing characters should be filled with space chars */ +for (i =0 , size =0 ; i < maxlen; i++) +if (str[i] !=' ' ) + size = i +1 ; + +return size; +} + +static bool sfp_match (const char *qs,const char *str,size_t len) +{ +if (!qs) +return true; +if (strlen (qs) != len) +return false; +return !strncmp (qs, str, len); +} + +static const struct sfp_quirk *sfp_lookup_quirk (const struct sfp_eeprom_id *id) +{ +const struct sfp_quirk *q; +unsigned int i; +size_t vs, ps; + + vs =sfp_strlen (id->base.vendor_name,ARRAY_SIZE (id->base.vendor_name)); + ps =sfp_strlen (id->base.vendor_pn,ARRAY_SIZE (id->base.vendor_pn)); + +for (i =0 , q = sfp_quirks; i <ARRAY_SIZE (sfp_quirks); i++, q++) +if (sfp_match (q->vendor, id->base.vendor_name, vs) && +sfp_match (q->part, id->base.vendor_pn, ps)) +return q; + +return NULL ; +}/** * sfp_parse_port() - Parse the EEPROM base ID, setting the port type * @bus: a pointer to the &struct sfp_bus structure for the sfp module
@@ -245,6 +292,9 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id, phylink_set(modes, 1000baseX_Full); } +if (bus->sfp_quirk) + bus->sfp_quirk->modes (id, modes); +bitmap_or (support, support, modes, __ETHTOOL_LINK_MODE_MASK_NBITS);phylink_set (support, Autoneg);
@@ -622,6 +672,8 @@ int sfp_module_insert(struct sfp_bus *bus, const struct sfp_eeprom_id *id)const struct sfp_upstream_ops *ops =sfp_get_upstream_ops (bus);int ret =0 ; + bus->sfp_quirk =sfp_lookup_quirk (id); +if (ops && ops->module_insert) ret = ops->module_insert (bus->upstream, id);
@@ -635,6 +687,8 @@ void sfp_module_remove(struct sfp_bus *bus)if (ops && ops->module_remove) ops->module_remove (bus->upstream); + + bus->sfp_quirk =NULL ; }EXPORT_SYMBOL_GPL (sfp_module_remove);
Signature · 1 line
2.20.1
PATCH 2/2 net: sfp: add some quirks for GPON modules
In reply to Russell King - ARM Linux adminMarc Micalizzi reports that Huawei MA5671A and Alcatel/Lucent G-010S-P modules are capable of 2500base-X, but incorrectly report their capabilities in the EEPROM. It seems rather common that GPON modules mis-report.
Let's fix these modules by adding some quirks.
--- drivers/net/phy/sfp-bus.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/net/phy/sfp-bus.c +25 -0
@@ -38,7 +38,32 @@ struct sfp_bus {bool started; }; +static void sfp_quirk_2500basex (const struct sfp_eeprom_id *id, +unsigned long *modes) +{ + phylink_set(modes, 2500baseX_Full); +} +static const struct sfp_quirk sfp_quirks[] = { + { +// Alcatel Lucent G-010S-P can operate at 2500base-X, but +// incorrectly report 2500MBd NRZ in their EEPROM + .vendor ="ALCATELLUCENT" , + .part ="G010SP" , + .modes = sfp_quirk_2500basex, + }, { +// Alcatel Lucent G-010S-A can operate at 2500base-X, but +// report 3.2GBd NRZ in their EEPROM + .vendor ="ALCATELLUCENT" , + .part ="3FE46541AA" , + .modes = sfp_quirk_2500basex, + }, { +// Huawei MA5671A can operate at 2500base-X, but report 1.2GBd +// NRZ in their EEPROM + .vendor ="HUAWEI" , + .part ="MA5671A" , + .modes = sfp_quirk_2500basex, + }, };static size_t sfp_strlen (const char *str,size_t maxlen)
Signature · 1 line
2.20.1
Re: [PATCH net-next 2/2] net: sfp: add some quirks for GPON modules
Quoted 11 lines · Russell King
static const struct
sfp_quirksfp_quirks[] = {drivers/net/phy/sfp-bus.c +10
-0+ { +// Alcatel Lucent G-010S-P can operate at 2500base-X, but +// incorrectly report 2500MBd NRZ in their EEPROM + .vendor = "ALCATELLUCENT", + .part = "G010SP", + .modes = sfp_quirk_2500basex, + }, { +// Alcatel Lucent G-010S-A can operate at 2500base-X, but +// report 3.2GBd NRZ in their EEPROM + .vendor = "ALCATELLUCENT",
drivers/net/phy/sfp-bus.c struct sfp_bus { · line 67
Quoted 10 lines
drivers/net/phy/sfp-bus.c +9
-0+ .part = "3FE46541AA", + .modes = sfp_quirk_2500basex, + }, { +// Huawei MA5671A can operate at 2500base-X, but report 1.2GBd +// NRZ in their EEPROM + .vendor = "HUAWEI", + .part = "MA5671A", + .modes = sfp_quirk_2500basex, + }, };
nit: no C++ comment style?
Russell King - ARM Linux admin
maintainerRe: [PATCH net-next 2/2] net: sfp: add some quirks for GPON modules
Quoted 16 lines · Jakub Kicinski
Quoted 15 lines · Russell King
static const struct
sfp_quirksfp_quirks[] = {drivers/net/phy/sfp-bus.c +14
-0+ { + // Alcatel Lucent G-010S-P can operate at 2500base-X, but + // incorrectly report 2500MBd NRZ in their EEPROM + .vendor = "ALCATELLUCENT", + .part = "G010SP", + .modes = sfp_quirk_2500basex, + }, { + // Alcatel Lucent G-010S-A can operate at 2500base-X, but + // report 3.2GBd NRZ in their EEPROM + .vendor = "ALCATELLUCENT", + .part = "3FE46541AA", + .modes = sfp_quirk_2500basex, + }, { + // Huawei MA5671A can operate at 2500base-X, but report 1.2GBd
Quoted 8 lines
drivers/net/phy/sfp-bus.c struct sfp_bus { · line 67
Quoted 6 lines
drivers/net/phy/sfp-bus.c +5
-0+// NRZ in their EEPROM + .vendor = "HUAWEI", + .part = "MA5671A", + .modes = sfp_quirk_2500basex, + }, };nit: no C++ comment style?
Did you read Linus' opinions on commentry style during the discussion over the SPDX tags?
https://lkml.org/lkml/2017/11/2/715
https://lkml.org/lkml/2017/11/25/133
It seems that Linus has decided to prefer // over /* */
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up
Re: [PATCH net-next 2/2] net: sfp: add some quirks for GPON modules
Quoted 26 lines · Russell King - ARM Linux admin
Quoted 16 lines · Jakub Kicinski
Quoted 15 lines · Russell King
static const struct
sfp_quirksfp_quirks[] = {drivers/net/phy/sfp-bus.c +14
-0+ { + // Alcatel Lucent G-010S-P can operate at 2500base-X, but + // incorrectly report 2500MBd NRZ in their EEPROM + .vendor = "ALCATELLUCENT", + .part = "G010SP", + .modes = sfp_quirk_2500basex, + }, { + // Alcatel Lucent G-010S-A can operate at 2500base-X, but + // report 3.2GBd NRZ in their EEPROM + .vendor = "ALCATELLUCENT", + .part = "3FE46541AA", + .modes = sfp_quirk_2500basex, + }, { + // Huawei MA5671A can operate at 2500base-X, but report 1.2GBdQuoted 8 lines
drivers/net/phy/sfp-bus.c struct sfp_bus { · line 67
Quoted 6 lines
drivers/net/phy/sfp-bus.c +5
-0+// NRZ in their EEPROM + .vendor = "HUAWEI", + .part = "MA5671A", + .modes = sfp_quirk_2500basex, + }, };nit: no C++ comment style?
Quoted 7 lines
Did you read Linus' opinions on commentry style during the discussion over the SPDX tags?
https://lkml.org/lkml/2017/11/2/715
https://lkml.org/lkml/2017/11/25/133It seems that Linus has decided to prefer // over /* */
Yeah, I remember that, I did:
$ git grep '// ' drivers/net/phy/ | grep -v SPDX drivers/net/phy/microchip_t1.c:// Copyright (C) 2018 Microchip Technology
before I asked, and assumed since for the last two years they didn't gain much popularity in this corner of the kernel it's worth asking if this is intentional :)
Andrew Lunn
maintainerQuoted 10 lines · Russell King - ARM Linux admin
The SFP module EEPROM describes the capabilities of the module, but doesn't describe the host interface. We have a certain amount of guess-work to work out how to configure the host - which works most of the time.
However, there are some (such as GPON) modules which are able to support different host interfaces, such as 1000BASE-X and 2500BASE-X. The module will switch between each mode until it achieves link with the host.
Quoted 5 lines
There is no defined way to describe this in the SFP EEPROM, so we can only recognise the module and handle it appropriately. This series adds the necessary recognition of the modules using a quirk system, and tweaks the support mask to allow them to link with the host at 2500BASE-X, thereby allowing the user to achieve full line rate.
Hi Russell
Did you consider making the Cotsworks checksum issue a quirk?
Andrew
Re: [PATCH net-next 1/2] net: sfp: add support for module quirks
In reply to Russell Kingdrivers/net/phy/sfp-bus.c struct sfp_bus { · line 51
Quoted 8 lines
drivers/net/phy/sfp-bus.c +8
-0+static size_t sfp_strlen (const char *str,size_t maxlen) +{ +size_t size, i; + +/* Trailing characters should be filled with space chars */ +for (i =0 , size =0 ; i < maxlen; i++) +if (str[i] !=' ' ) + size = i +1 ;
Hi Russell
Is this space padding part of the standard? What's the bet there are some with a NULL character?
Andrew
Re: [PATCH net-next 2/2] net: sfp: add some quirks for GPON modules
In reply to Russell KingQuoted 8 lines · Russell King
Marc Micalizzi reports that Huawei MA5671A and Alcatel/Lucent G-010S-P modules are capable of 2500base-X, but incorrectly report their capabilities in the EEPROM. It seems rather common that GPON modules mis-report.
Let's fix these modules by adding some quirks.
Signed-off-by Russell King <[email protected]>
Andrew
Re: [PATCH net-next 1/2] net: sfp: add support for module quirks
In reply to Russell KingQuoted 4 lines · Russell King
Add support for applying module quirks to the list of supported ethtool link modes.
Signed-off-by Russell King <[email protected]>
Signature · 1 line
Florian
Re: [PATCH net-next 2/2] net: sfp: add some quirks for GPON modules
In reply to Russell KingQuoted 8 lines · Russell King
Marc Micalizzi reports that Huawei MA5671A and Alcatel/Lucent G-010S-P modules are capable of 2500base-X, but incorrectly report their capabilities in the EEPROM. It seems rather common that GPON modules mis-report.
Let's fix these modules by adding some quirks.
Signed-off-by Russell King <[email protected]>
Signature · 1 line
Florian
David Miller
maintainerFrom: Russell King - ARM Linux admin <[email protected]>
Date: Wed, 20 Nov 2019 11:39:00 +0000
Quoted 10 lines
The SFP module EEPROM describes the capabilities of the module, but doesn't describe the host interface. We have a certain amount of guess-work to work out how to configure the host - which works most of the time.
However, there are some (such as GPON) modules which are able to support different host interfaces, such as 1000BASE-X and 2500BASE-X. The module will switch between each mode until it achieves link with the host.
Quoted 5 lines
There is no defined way to describe this in the SFP EEPROM, so we can only recognise the module and handle it appropriately. This series adds the necessary recognition of the modules using a quirk system, and tweaks the support mask to allow them to link with the host at 2500BASE-X, thereby allowing the user to achieve full line rate.
Series applied, thanks.
Russell King - ARM Linux admin
maintainerRe: [PATCH net-next 1/2] net: sfp: add support for module quirks
In reply to Andrew LunnQuoted 11 lines · Andrew Lunn
drivers/net/phy/sfp-bus.c struct sfp_bus { · line 51
Quoted 8 lines
drivers/net/phy/sfp-bus.c +8
-0+static size_t sfp_strlen (const char *str,size_t maxlen) +{ +size_t size, i; + +/* Trailing characters should be filled with space chars */ +for (i =0 , size =0 ; i < maxlen; i++) +if (str[i] !=' ' ) + size = i +1 ;Hi Russell
Quoted 2 lines
Is this space padding part of the standard? What's the bet there are some with a NULL character?
Yes, it's specified. I haven't yet seen a module not space-pad.
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up