public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Sasha Levin <sashal@kernel.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org
Subject: Re: [PATCH AUTOSEL 5.11 16/67] net: sfp: add mode quirk for GPON module Ubiquiti U-Fiber Instant
Date: Thu, 25 Feb 2021 20:03:06 +0100	[thread overview]
Message-ID: <20210225190306.65jnl557vvs6d7o3@pali> (raw)
In-Reply-To: <20210224125026.481804-16-sashal@kernel.org> <20210224125212.482485-12-sashal@kernel.org>

On Wednesday 24 February 2021 07:49:34 Sasha Levin wrote:
> From: Pali Rohár <pali@kernel.org>
> 
> [ Upstream commit f0b4f847673299577c29b71d3f3acd3c313d81b7 ]

Hello! This commit requires also commit~1 from that patch series:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=426c6cbc409cbda9ab1a9dbf15d3c2ef947eb8c1

Without it kernel cannot read EEPROM from Ubiquiti U-Fiber Instant
module and therefore the hook based on EEPROM data which is below would
not be applied.

> The Ubiquiti U-Fiber Instant SFP GPON module has nonsensical information
> stored in its EEPROM. It claims to support all transceiver types including
> 10G Ethernet. Clear all claimed modes and set only 1000baseX_Full, which is
> the only one supported.
> 
> This module has also phys_id set to SFF, and the SFP subsystem currently
> does not allow to use SFP modules detected as SFFs. Add exception for this
> module so it can be detected as supported.
> 
> This change finally allows to detect and use SFP GPON module Ubiquiti
> U-Fiber Instant on Linux system.
> 
> EEPROM content of this SFP module is (where XX is serial number):
> 
> 00: 02 04 0b ff ff ff ff ff ff ff ff 03 0c 00 14 c8    ???........??.??
> 10: 00 00 00 00 55 42 4e 54 20 20 20 20 20 20 20 20    ....UBNT
> 20: 20 20 20 20 00 18 e8 29 55 46 2d 49 4e 53 54 41        .??)UF-INSTA
> 30: 4e 54 20 20 20 20 20 20 34 20 20 20 05 1e 00 36    NT      4   ??.6
> 40: 00 06 00 00 55 42 4e 54 XX XX XX XX XX XX XX XX    .?..UBNTXXXXXXXX
> 50: 20 20 20 20 31 34 30 31 32 33 20 20 60 80 02 41        140123  `??A
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  drivers/net/phy/sfp-bus.c | 15 +++++++++++++++
>  drivers/net/phy/sfp.c     | 17 +++++++++++++++--
>  2 files changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
> index 20b91f5dfc6ed..4cf874fb5c5b4 100644
> --- a/drivers/net/phy/sfp-bus.c
> +++ b/drivers/net/phy/sfp-bus.c
> @@ -44,6 +44,17 @@ static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id,
>  	phylink_set(modes, 2500baseX_Full);
>  }
>  
> +static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id,
> +				      unsigned long *modes)
> +{
> +	/* Ubiquiti U-Fiber Instant module claims that support all transceiver
> +	 * types including 10G Ethernet which is not truth. So clear all claimed
> +	 * modes and set only one mode which module supports: 1000baseX_Full.
> +	 */
> +	phylink_zero(modes);
> +	phylink_set(modes, 1000baseX_Full);
> +}
> +
>  static const struct sfp_quirk sfp_quirks[] = {
>  	{
>  		// Alcatel Lucent G-010S-P can operate at 2500base-X, but
> @@ -63,6 +74,10 @@ static const struct sfp_quirk sfp_quirks[] = {
>  		.vendor = "HUAWEI",
>  		.part = "MA5671A",
>  		.modes = sfp_quirk_2500basex,
> +	}, {
> +		.vendor = "UBNT",
> +		.part = "UF-INSTANT",
> +		.modes = sfp_quirk_ubnt_uf_instant,
>  	},
>  };
>  
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 91d74c1a920ab..804295ad8a044 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -273,8 +273,21 @@ 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 &&
> -	       id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP;
> +	if (id->base.phys_id == SFF8024_ID_SFP &&
> +	    id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP)
> +		return true;
> +
> +	/* SFP GPON module Ubiquiti U-Fiber Instant has in its EEPROM stored
> +	 * phys id SFF instead of SFP. Therefore mark this module explicitly
> +	 * as supported based on vendor name and pn match.
> +	 */
> +	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;
>  }
>  
>  static const struct sff_data sfp_data = {
> -- 
> 2.27.0
> 

On Wednesday 24 February 2021 07:51:28 Sasha Levin wrote:
> From: Pali Rohár <pali@kernel.org>
> 
> [ Upstream commit f0b4f847673299577c29b71d3f3acd3c313d81b7 ]
> 
> The Ubiquiti U-Fiber Instant SFP GPON module has nonsensical information
> stored in its EEPROM. It claims to support all transceiver types including
> 10G Ethernet. Clear all claimed modes and set only 1000baseX_Full, which is
> the only one supported.
> 
> This module has also phys_id set to SFF, and the SFP subsystem currently
> does not allow to use SFP modules detected as SFFs. Add exception for this
> module so it can be detected as supported.
> 
> This change finally allows to detect and use SFP GPON module Ubiquiti
> U-Fiber Instant on Linux system.
> 
> EEPROM content of this SFP module is (where XX is serial number):
> 
> 00: 02 04 0b ff ff ff ff ff ff ff ff 03 0c 00 14 c8    ???........??.??
> 10: 00 00 00 00 55 42 4e 54 20 20 20 20 20 20 20 20    ....UBNT
> 20: 20 20 20 20 00 18 e8 29 55 46 2d 49 4e 53 54 41        .??)UF-INSTA
> 30: 4e 54 20 20 20 20 20 20 34 20 20 20 05 1e 00 36    NT      4   ??.6
> 40: 00 06 00 00 55 42 4e 54 XX XX XX XX XX XX XX XX    .?..UBNTXXXXXXXX
> 50: 20 20 20 20 31 34 30 31 32 33 20 20 60 80 02 41        140123  `??A
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  drivers/net/phy/sfp-bus.c | 15 +++++++++++++++
>  drivers/net/phy/sfp.c     | 17 +++++++++++++++--
>  2 files changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
> index 58014feedf6c8..fb954e8141802 100644
> --- a/drivers/net/phy/sfp-bus.c
> +++ b/drivers/net/phy/sfp-bus.c
> @@ -44,6 +44,17 @@ static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id,
>  	phylink_set(modes, 2500baseX_Full);
>  }
>  
> +static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id,
> +				      unsigned long *modes)
> +{
> +	/* Ubiquiti U-Fiber Instant module claims that support all transceiver
> +	 * types including 10G Ethernet which is not truth. So clear all claimed
> +	 * modes and set only one mode which module supports: 1000baseX_Full.
> +	 */
> +	phylink_zero(modes);
> +	phylink_set(modes, 1000baseX_Full);
> +}
> +
>  static const struct sfp_quirk sfp_quirks[] = {
>  	{
>  		// Alcatel Lucent G-010S-P can operate at 2500base-X, but
> @@ -63,6 +74,10 @@ static const struct sfp_quirk sfp_quirks[] = {
>  		.vendor = "HUAWEI",
>  		.part = "MA5671A",
>  		.modes = sfp_quirk_2500basex,
> +	}, {
> +		.vendor = "UBNT",
> +		.part = "UF-INSTANT",
> +		.modes = sfp_quirk_ubnt_uf_instant,
>  	},
>  };
>  
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 34aa196b7465c..d8a809cf20c15 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -272,8 +272,21 @@ 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 &&
> -	       id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP;
> +	if (id->base.phys_id == SFF8024_ID_SFP &&
> +	    id->base.phys_ext_id == SFP_PHYS_EXT_ID_SFP)
> +		return true;
> +
> +	/* SFP GPON module Ubiquiti U-Fiber Instant has in its EEPROM stored
> +	 * phys id SFF instead of SFP. Therefore mark this module explicitly
> +	 * as supported based on vendor name and pn match.
> +	 */
> +	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;
>  }
>  
>  static const struct sff_data sfp_data = {
> -- 
> 2.27.0
> 


  reply	other threads:[~2021-02-25 19:03 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210224125212.482485-1-sashal@kernel.org>
2021-02-24 12:51 ` [PATCH AUTOSEL 5.10 05/56] wlcore: Fix command execute failure 19 for wl12xx Sasha Levin
2021-02-24 12:51 ` [PATCH AUTOSEL 5.10 07/56] Bluetooth: btusb: fix memory leak on suspend and resume Sasha Levin
2021-02-24 12:51 ` [PATCH AUTOSEL 5.10 08/56] mt76: mt7615: reset token when mac_reset happens Sasha Levin
2021-02-24 12:51 ` [PATCH AUTOSEL 5.10 09/56] pktgen: fix misuse of BUG_ON() in pktgen_thread_worker() Sasha Levin
2021-02-24 12:51 ` [PATCH AUTOSEL 5.10 10/56] ath10k: fix wmi mgmt tx queue full due to race condition Sasha Levin
2021-02-24 12:51 ` [PATCH AUTOSEL 5.10 12/56] net: sfp: add mode quirk for GPON module Ubiquiti U-Fiber Instant Sasha Levin
2021-02-25 19:03   ` Pali Rohár [this message]
2021-03-04 22:33     ` [PATCH AUTOSEL 5.11 16/67] " Sasha Levin
2021-03-05 23:38       ` Pali Rohár
2021-03-06 17:52         ` Sasha Levin
2021-02-24 12:51 ` [PATCH AUTOSEL 5.10 13/56] Bluetooth: Add new HCI_QUIRK_NO_SUSPEND_NOTIFIER quirk Sasha Levin
2021-02-24 12:51 ` [PATCH AUTOSEL 5.10 14/56] Bluetooth: Fix null pointer dereference in amp_read_loc_assoc_final_data Sasha Levin
2021-02-24 12:51 ` [PATCH AUTOSEL 5.10 17/56] brcmfmac: Add DMI nvram filename quirk for Predia Basic tablet Sasha Levin
2021-02-24 12:51 ` [PATCH AUTOSEL 5.10 18/56] brcmfmac: Add DMI nvram filename quirk for Voyo winpad A15 tablet Sasha Levin
2021-02-24 12:49 [PATCH AUTOSEL 5.11 01/67] ath10k: prevent deinitializing NAPI twice Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 05/67] can: flexcan: add CAN wakeup function for i.MX8QM Sasha Levin
2021-02-25  2:48   ` Fabio Estevam
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 07/67] wlcore: Fix command execute failure 19 for wl12xx Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 09/67] Bluetooth: btusb: fix memory leak on suspend and resume Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 10/67] selftests/bpf: Remove memory leak Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 11/67] mt76: mt7915: reset token when mac_reset happens Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 12/67] mt76: mt7615: " Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 13/67] pktgen: fix misuse of BUG_ON() in pktgen_thread_worker() Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 14/67] ath10k: fix wmi mgmt tx queue full due to race condition Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 16/67] net: sfp: add mode quirk for GPON module Ubiquiti U-Fiber Instant Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 17/67] Bluetooth: Add new HCI_QUIRK_NO_SUSPEND_NOTIFIER quirk Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 18/67] Bluetooth: Fix null pointer dereference in amp_read_loc_assoc_final_data Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 21/67] net: ipa: avoid field overflow Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 22/67] brcmfmac: Add DMI nvram filename quirk for Predia Basic tablet Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 23/67] brcmfmac: Add DMI nvram filename quirk for Voyo winpad A15 tablet Sasha Levin
2021-02-24 12:49 ` [PATCH AUTOSEL 5.11 24/67] wilc1000: Fix use of void pointer as a wrong struct type Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210225190306.65jnl557vvs6d7o3@pali \
    --to=pali@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox