Message ID | 20201230154755.14746-3-pali@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: sfp: add support for GPON RTL8672/RTL9601C and Ubiquiti U-Fiber | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | warning | Target tree name not specified in the subject |
netdev/cc_maintainers | success | CCed 6 of 6 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 9 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Wed, Dec 30, 2020 at 04:47:53PM +0100, Pali Rohár wrote: > Some GPON SFP modules (e.g. Ubiquiti U-Fiber Instant) have set SFF phys_id > in their EEPROM. Kernel SFP subsystem currently does not allow to use > modules detected as SFF. > > This change extends check for SFP modules so also those with SFF phys_id > are allowed. With this change also GPON SFP module Ubiquiti U-Fiber Instant > is recognized. I really don't want to do this for every single module out there. It's likely that Ubiquiti do this crap as a vendor lock-in measure. Let's make it specific to Ubiquiti modules _only_ until such time that we know better.
On Wednesday 30 December 2020 16:11:51 Russell King - ARM Linux admin wrote: > On Wed, Dec 30, 2020 at 04:47:53PM +0100, Pali Rohár wrote: > > Some GPON SFP modules (e.g. Ubiquiti U-Fiber Instant) have set SFF phys_id > > in their EEPROM. Kernel SFP subsystem currently does not allow to use > > modules detected as SFF. > > > > This change extends check for SFP modules so also those with SFF phys_id > > are allowed. With this change also GPON SFP module Ubiquiti U-Fiber Instant > > is recognized. > > I really don't want to do this for every single module out there. > It's likely that Ubiquiti do this crap as a vendor lock-in measure. > Let's make it specific to Ubiquiti modules _only_ until such time > that we know better. Ok. This module_supported() function is called in sfp_sm_mod_probe() function. Current code is: /* Check whether we support this module */ if (!sfp->type->module_supported(&id)) { dev_err(sfp->dev, "module is not supported - phys id 0x%02x 0x%02x\n", sfp->id.base.phys_id, sfp->id.base.phys_ext_id); return -EINVAL; } Do you want to change code to something like this? /* Check whether we support this module */ if (!sfp->type->module_supported(&id) && (memcmp(id.base.vendor_name, "UBNT ", 16) || memcmp(id.base.vendor_pn, "UF-INSTANT ", 16))) dev_err(sfp->dev, "module is not supported - phys id 0x%02x 0x%02x\n", sfp->id.base.phys_id, sfp->id.base.phys_ext_id); return -EINVAL; } Or do you have a better idea how to skip that module_supported check for this UBNT SFP?
On Wed, 30 Dec 2020 18:06:52 +0100 Pali Rohár <pali@kernel.org> wrote: > if (!sfp->type->module_supported(&id) && > (memcmp(id.base.vendor_name, "UBNT ", 16) || > memcmp(id.base.vendor_pn, "UF-INSTANT ", 16))) I would rather add a quirk member (bitfield) to the sfp structure and do something like this if (!sfp->type->module_supported(&id) && !(sfp->quirks & SFP_QUIRK_BAD_PHYS_ID)) or maybe put this check into the module_supported method. Marek
On Wed, Dec 30, 2020 at 06:27:07PM +0100, Marek Behún wrote: > On Wed, 30 Dec 2020 18:06:52 +0100 > Pali Rohár <pali@kernel.org> wrote: > > > if (!sfp->type->module_supported(&id) && > > (memcmp(id.base.vendor_name, "UBNT ", 16) || > > memcmp(id.base.vendor_pn, "UF-INSTANT ", 16))) > > I would rather add a quirk member (bitfield) to the sfp structure and do > something like this > > if (!sfp->type->module_supported(&id) && > !(sfp->quirks & SFP_QUIRK_BAD_PHYS_ID)) > > or maybe put this check into the module_supported method. Sorry, definitely not. If you've ever looked at the SDHCI driver with its multiple "quirks" bitfields, doing this is a recipe for creating a very horrid hard to understand mess. What you suggest just results in yet more complexity.
On Wednesday 30 December 2020 19:12:40 Russell King - ARM Linux admin wrote: > On Wed, Dec 30, 2020 at 06:27:07PM +0100, Marek Behún wrote: > > On Wed, 30 Dec 2020 18:06:52 +0100 > > Pali Rohár <pali@kernel.org> wrote: > > > > > if (!sfp->type->module_supported(&id) && > > > (memcmp(id.base.vendor_name, "UBNT ", 16) || > > > memcmp(id.base.vendor_pn, "UF-INSTANT ", 16))) > > > > I would rather add a quirk member (bitfield) to the sfp structure and do > > something like this > > > > if (!sfp->type->module_supported(&id) && > > !(sfp->quirks & SFP_QUIRK_BAD_PHYS_ID)) > > > > or maybe put this check into the module_supported method. > > Sorry, definitely not. If you've ever looked at the SDHCI driver with > its multiple "quirks" bitfields, doing this is a recipe for creating > a very horrid hard to understand mess. > > What you suggest just results in yet more complexity. Should I rather put this vendor name/pn check into the sfp_module_supported() function? static bool sfp_module_supported(const struct sfp_eeprom_id *id) { if (id->base.phys_id == SFF8024_ID_SFP && id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP) return true; if (id->base.phys_id == SFF8024_ID_SFF_8472 && id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP && !memcmp(id->base.vendor_name, "UBNT ", 16) && !memcmp(id->base.vendor_pn, "UF-INSTANT ", 16)) return true; return false; }
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 490e78a72dd6..73f3ecf15260 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -273,7 +273,8 @@ static const struct sff_data sff_data = { static bool sfp_module_supported(const struct sfp_eeprom_id *id) { - return id->base.phys_id == SFF8024_ID_SFP && + return (id->base.phys_id == SFF8024_ID_SFP || + id->base.phys_id == SFF8024_ID_SFF_8472) && id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP; }
Some GPON SFP modules (e.g. Ubiquiti U-Fiber Instant) have set SFF phys_id in their EEPROM. Kernel SFP subsystem currently does not allow to use modules detected as SFF. This change extends check for SFP modules so also those with SFF phys_id are allowed. With this change also GPON SFP module Ubiquiti U-Fiber Instant is recognized. Signed-off-by: Pali Rohár <pali@kernel.org> --- drivers/net/phy/sfp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)