From patchwork Wed Dec 30 15:47:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 11993353 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF5AEC43331 for ; Wed, 30 Dec 2020 15:49:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7FB522227 for ; Wed, 30 Dec 2020 15:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726707AbgL3PtB (ORCPT ); Wed, 30 Dec 2020 10:49:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:46658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbgL3PtA (ORCPT ); Wed, 30 Dec 2020 10:49:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5E13E221F8; Wed, 30 Dec 2020 15:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609343299; bh=2RIclngu6AIneWlw5MfU5187I27yfRJRGgk2OOJIbsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NGrs9Aie3e9CKBhqII1iEsp1j/6AYVzPjRZfXt0EgCCE9IVaPf8pe5/Sfj/qt3KlU ZVfZVcfBccZayp+AcfnLEk6MaWwbebkisab+UckGUQFFsJDB464alGW4dF02TZgLXF O+9xSQ+VuSm+a8o+ydZyAPXyNW0vxAn2GeAYWcHChjRdaeR/pjZzKoxKhuz8DhUXRW zjpUUpiuP2Berp6vC50WPBZrUKnnx6jRBDXyyY91+pq8wGn5OtY46Hb1QQKC3eOtJZ z3EfRk383A69nwu+CDyXfWAce3ojL0AKMecG3SO6zlrfjvXUWBn22Wbe1rE1T2i3XN 78WN7IfRiJmsg== Received: by pali.im (Postfix) id BAC009F8; Wed, 30 Dec 2020 16:48:17 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Russell King , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Jakub Kicinski , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] net: sfp: add workaround for Realtek RTL8672 and RTL9601C chips Date: Wed, 30 Dec 2020 16:47:52 +0100 Message-Id: <20201230154755.14746-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201230154755.14746-1-pali@kernel.org> References: <20201230154755.14746-1-pali@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Workaround for GPON SFP modules based on VSOL V2801F brand was added in commit 0d035bed2a4a ("net: sfp: VSOL V2801F / CarlitoxxPro CPGOS03-0490 v2.0 workaround"). But it works only for ids explicitly added to the list. As there are more rebraded VSOL V2801F modules and OEM vendors are putting into vendor name random strings we cannot build workaround based on ids. Moreover issue which that commit tried to workaround is generic not only to VSOL based modules, but rather to all GPON modules based on Realtek RTL8672 and RTL9601C chips. They can be found for example in following GPON modules: * V-SOL V2801F * C-Data FD511GX-RM0 * OPTON GP801R * BAUDCOM BD-1234-SFM * CPGOS03-0490 v2.0 * Ubiquiti U-Fiber Instant * EXOT EGS1 Those Realtek chips have broken EEPROM emulator which for N-byte read operation returns just one byte of EEPROM data followed by N-1 zeros. So introduce a new function sfp_id_needs_byte_io() which detects SFP modules with these Realtek chips which have broken EEPROM emulator based on N-1 zeros and switch to 1 byte EEPROM reading operation which workaround this issue. This patch fixes reading EEPROM content from SFP modules based on Realtek RTL8672 and RTL9601C chips. Fixes: 0d035bed2a4a ("net: sfp: VSOL V2801F / CarlitoxxPro CPGOS03-0490 v2.0 workaround") Co-developed-by: Russell King Signed-off-by: Russell King Signed-off-by: Pali Rohár --- drivers/net/phy/sfp.c | 78 ++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 91d74c1a920a..490e78a72dd6 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -336,19 +336,11 @@ static int sfp_i2c_read(struct sfp *sfp, bool a2, u8 dev_addr, void *buf, size_t len) { struct i2c_msg msgs[2]; - size_t block_size; + u8 bus_addr = a2 ? 0x51 : 0x50; + size_t block_size = sfp->i2c_block_size; size_t this_len; - u8 bus_addr; int ret; - if (a2) { - block_size = 16; - bus_addr = 0x51; - } else { - block_size = sfp->i2c_block_size; - bus_addr = 0x50; - } - msgs[0].addr = bus_addr; msgs[0].flags = 0; msgs[0].len = 1; @@ -1642,26 +1634,30 @@ static int sfp_sm_mod_hpower(struct sfp *sfp, bool enable) return 0; } -/* Some modules (Nokia 3FE46541AA) lock up if byte 0x51 is read as a - * single read. Switch back to reading 16 byte blocks unless we have - * a CarlitoxxPro module (rebranded VSOL V2801F). Even more annoyingly, - * some VSOL V2801F have the vendor name changed to OEM. +/* GPON modules based on Realtek RTL8672 and RTL9601C chips (e.g. V-SOL + * V2801F, CarlitoxxPro CPGOS03-0490, Ubiquiti U-Fiber Instant, ...) do + * not support multibyte reads from the EEPROM. Each multi-byte read + * operation returns just one byte of EEPROM followed by zeros. There is + * no way to identify which modules are using Realtek RTL8672 and RTL9601C + * chips. Moreover every OEM of V-SOL V2801F module puts its own vendor + * name and vendor id into EEPROM, so there is even no way to detect if + * module is V-SOL V2801F. Therefore check for those zeros in the read + * data and then based on check switch to reading EEPROM to one byte + * at a time. */ -static int sfp_quirk_i2c_block_size(const struct sfp_eeprom_base *base) +static bool sfp_id_needs_byte_io(struct sfp *sfp, void *buf, size_t len) { - if (!memcmp(base->vendor_name, "VSOL ", 16)) - return 1; - if (!memcmp(base->vendor_name, "OEM ", 16) && - !memcmp(base->vendor_pn, "V2801F ", 16)) - return 1; + size_t i, block_size = sfp->i2c_block_size; - /* Some modules can't cope with long reads */ - return 16; -} + /* Already using byte IO */ + if (block_size == 1) + return false; -static void sfp_quirks_base(struct sfp *sfp, const struct sfp_eeprom_base *base) -{ - sfp->i2c_block_size = sfp_quirk_i2c_block_size(base); + for (i = 1; i < len; i += block_size) { + if (memchr_inv(buf + i, '\0', block_size - 1)) + return false; + } + return true; } static int sfp_cotsworks_fixup_check(struct sfp *sfp, struct sfp_eeprom_id *id) @@ -1705,11 +1701,7 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report) u8 check; int ret; - /* Some modules (CarlitoxxPro CPGOS03-0490) do not support multibyte - * reads from the EEPROM, so start by reading the base identifying - * information one byte at a time. - */ - sfp->i2c_block_size = 1; + sfp->i2c_block_size = 16; ret = sfp_read(sfp, false, 0, &id.base, sizeof(id.base)); if (ret < 0) { @@ -1723,6 +1715,27 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report) return -EAGAIN; } + if (sfp_id_needs_byte_io(sfp, &id.base, sizeof(id.base))) { + dev_info(sfp->dev, + "Detected broken RTL8672/RTL9601C emulated EEPROM\n"); + dev_info(sfp->dev, + "Switching to reading EEPROM to one byte at a time\n"); + sfp->i2c_block_size = 1; + + ret = sfp_read(sfp, false, 0, &id.base, sizeof(id.base)); + if (ret < 0) { + if (report) + dev_err(sfp->dev, "failed to read EEPROM: %d\n", + ret); + return -EAGAIN; + } + + if (ret != sizeof(id.base)) { + dev_err(sfp->dev, "EEPROM short read: %d\n", ret); + return -EAGAIN; + } + } + /* 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. @@ -1757,9 +1770,6 @@ static int sfp_sm_mod_probe(struct sfp *sfp, bool report) } } - /* Apply any early module-specific quirks */ - sfp_quirks_base(sfp, &id.base); - ret = sfp_read(sfp, false, SFP_CC_BASE + 1, &id.ext, sizeof(id.ext)); if (ret < 0) { if (report) From patchwork Wed Dec 30 15:47:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 11993349 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74F5BC433E9 for ; Wed, 30 Dec 2020 15:49:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D8CA22227 for ; Wed, 30 Dec 2020 15:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbgL3PtC (ORCPT ); Wed, 30 Dec 2020 10:49:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:46698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbgL3PtC (ORCPT ); Wed, 30 Dec 2020 10:49:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DD8822242; Wed, 30 Dec 2020 15:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609343301; bh=xnHEVZDk0ZJjtLvsuNl+eC760CQNHfhFxMLs1isYStA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L2cDiROy3YnSsBiAv3HhjBbtYwRtKUn4Ogyeo5T4BhVSHEkGOXNh6sR4WuMx3CMdx 1S2H49Lp5og5b6E50QOwp4RoaqUDs3g+F1t9iPvSIssQiu7PrjAdo33qTB/xemmlCY u3o8mdPh+1EPNgM0B84zP2InapfwKGUy/I38sRb4L6JsevVrYybFabDBSvK6yK5L+b ASoyFa4OTdtVWCq/LxVpAkutCh0nMeFiKYB/uj2M/q/39bxs3kV77zNeGggniMqj0a WbNM6WjIkyZ7/Kmtkk/8sIxhFSmA8Uywof+BnW4bSvDweQ6qxg7QAk9hCrA1oijLIr mkqfFA3F73lJA== Received: by pali.im (Postfix) id EC92D9F8; Wed, 30 Dec 2020 16:48:19 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Russell King , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Jakub Kicinski , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] net: sfp: allow to use also SFP modules which are detected as SFF Date: Wed, 30 Dec 2020 16:47:53 +0100 Message-Id: <20201230154755.14746-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201230154755.14746-1-pali@kernel.org> References: <20201230154755.14746-1-pali@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 --- drivers/net/phy/sfp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } From patchwork Wed Dec 30 15:47:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 11993351 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7EA2C4332D for ; Wed, 30 Dec 2020 15:49:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9195A221F8 for ; Wed, 30 Dec 2020 15:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726823AbgL3PtF (ORCPT ); Wed, 30 Dec 2020 10:49:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:46724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726524AbgL3PtE (ORCPT ); Wed, 30 Dec 2020 10:49:04 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7601C2222A; Wed, 30 Dec 2020 15:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609343303; bh=51TxImHoFdm3uhA3pW7rBRVDyN3fYTyOjG61hHz5NvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m1kG1pBkyHYhwdOHDt2jGDmdPvBBsN3oGEy62hT08RsuqRE7vAuQwNQ7qHINtJKKl w9LzsascTx5o/ZxBalScvCdHiQUEJI3V41P+n8W0B2MLCWs9vCvBjqZJgHt/EI4tXV u8tal0xm9n0rWwZlmEKCbJItfiPZ/dOSHMrx7Wg1vWyT/X/ZTmbODvz9CAW0yt2Wbp pnk6dFQGdJKYCu+OXeH00wy+Dr34ReWe3kJGgSXYuWyF2Ix2AogYXOJioUS7kLtTRq wAbjWedJvfNoQg9+VXmJhK2mOV33yTZWvYOM/a7qqnDRQLbNs4K17QFFdgU6c2Bo5i ld2+kMc4JlQOQ== Received: by pali.im (Postfix) id BA6AB125D; Wed, 30 Dec 2020 16:48:21 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Russell King , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Jakub Kicinski , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] net: sfp: assume that LOS is not implemented if both LOS normal and inverted is set Date: Wed, 30 Dec 2020 16:47:54 +0100 Message-Id: <20201230154755.14746-4-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201230154755.14746-1-pali@kernel.org> References: <20201230154755.14746-1-pali@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Some GPON SFP modules (e.g. Ubiquiti U-Fiber Instant) have set both SFP_OPTIONS_LOS_INVERTED and SFP_OPTIONS_LOS_NORMAL bits in their EEPROM. Such combination of bits is meaningless so assume that LOS signal is not implemented. This patch fixes link carrier for GPON SFP module Ubiquiti U-Fiber Instant. Co-developed-by: Russell King Signed-off-by: Russell King Signed-off-by: Pali Rohár --- drivers/net/phy/sfp.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 73f3ecf15260..d47485ed239c 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1475,15 +1475,19 @@ static void sfp_sm_link_down(struct sfp *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); @@ -1493,18 +1497,22 @@ static void sfp_sm_link_check_los(struct sfp *sfp) 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) From patchwork Wed Dec 30 15:47:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 11993355 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46288C433DB for ; Wed, 30 Dec 2020 15:49:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16509221F8 for ; Wed, 30 Dec 2020 15:49:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbgL3PtP (ORCPT ); Wed, 30 Dec 2020 10:49:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:46788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726503AbgL3PtO (ORCPT ); Wed, 30 Dec 2020 10:49:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 303CE2226A; Wed, 30 Dec 2020 15:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609343305; bh=Awk7q1ExXD7Z9lZQDOFC5znJcmFblLnxGitRya5UfYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NEV2DHLDRI3LkegT0vlCrbnjjpxF2dgcm59fZM2S8IJArr/SUAN4UV5JbqzpxMDKm yQ5kStEqLo2gssE0Mr8tesfOeh+u2F29N6f/tDLJh40mK4MSCZrTtOjTs2OPVeK2wx Oiz5mKZgvyaVWafCaeIreY5I2uX518j0ClqX6J3nMojixIo+QNu2piItKoJ3q2K2MV dlDVrrKX5w3yzvifN5moebP/DqRcS0AdouTPybVDyYiR4h7wixaxcJ1nxNwJcvfL5d UyvZCI3pf3hNtQgoMEOYEuIFcrw5K0EFNoDCtI+IUkNRE8fB31v4eSCYl3gUod2KcF Z66JFoWJ1iI6w== Received: by pali.im (Postfix) id 891E89F8; Wed, 30 Dec 2020 16:48:23 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Russell King , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Jakub Kicinski , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] net: sfp: add mode quirk for GPON module Ubiquiti U-Fiber Instant Date: Wed, 30 Dec 2020 16:47:55 +0100 Message-Id: <20201230154755.14746-5-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201230154755.14746-1-pali@kernel.org> References: <20201230154755.14746-1-pali@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org SFP GPON module Ubiquiti U-Fiber Instant has in its EEPROM stored nonsense information. It 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. 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 --- drivers/net/phy/sfp-bus.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c index 20b91f5dfc6e..4cf874fb5c5b 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, }, };