Message ID | 8abed37d01d427bf9d27a157860c54375c994ea1.1700887953.git.daniel@makrotopia.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1740368vqx; Fri, 24 Nov 2023 20:57:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3y9FDG1iRE6//BNyk0pwCyoWaCNpgrWl0avfpyWq6P1Ehjy9IBgWibTYVh69f8GQa8OSt X-Received: by 2002:a05:6a20:160d:b0:187:60da:4767 with SMTP id l13-20020a056a20160d00b0018760da4767mr11087248pzj.25.1700888229830; Fri, 24 Nov 2023 20:57:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700888229; cv=none; d=google.com; s=arc-20160816; b=e/Gjj981sYBsEnZ6U6W6fIrYSjssx7WKZ33cEcnfy++3asgeoyWfB8z4EgFawrIwlJ SbNlQ5+2BrAugfZF48SHvekKvv1+tWYHipgpfJUBkkSmHhoFSnMpEE/jnkO/kWFimce7 tK6xWw3XY4Gdan2TIezuopPN+w0phPgRt7RHE22GlYDB1uWJWTu+viMPmTwZILIbJ/Mm Nmo+Aq87e9Njq211aEsf56jZxp/EiQnCFeOJW+M8lzwzC2IGACesIO6ex4doG12Vdadb FvvAKoeJj+ukudx68Gux6fT+HRimb7qiS11bdLUjsheyv3Bcw6nZ6U9nT1ry7s3AEeF0 UdlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=ef+epHJ6WVc2H9AfU41QPW9EocFBdlztISpuOzlIjPM=; fh=csWAx59MSkj0aGGuZLBTqdT/8t8pHwSS6qo5iO0HDsk=; b=Xpexb/Hud7ElF6VAcPRRJbjI+Ahsfa/aK7XQ5cpTlIXBQaPWKGQachGljnITK/s3b8 MK9HSUUTTrMFG1I4nO2lwaERiP+PRyi8sM6pj7px8lVx69uKGMMtpMv27TN32j4yZtZu 84z5R8CWe58mJbPW+NhagROwS+npOlwWuMV745paRtFPjyp4wh7hyPsk20p+bhNRIuO5 n/uNae1tmYrUlQpGXDOiG8KTv/bO/TuR/A1oBZvtmi1SxmpaScLUsJRc7/NEQyIGGDNq NFvrKbudSv+7vc30GhNd/m/H3A2iDw9moQOtB/9m6lV03Ex1T0yW81mOy5VU0/EWR0g/ aTTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id y7-20020a634b07000000b005b9b45ba3c1si5098685pga.563.2023.11.24.20.57.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 20:57:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2FB8883037F2; Fri, 24 Nov 2023 20:56:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231671AbjKYE4p (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Fri, 24 Nov 2023 23:56:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjKYE4m (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 24 Nov 2023 23:56:42 -0500 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 819E81707; Fri, 24 Nov 2023 20:56:48 -0800 (PST) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from <daniel@makrotopia.org>) id 1r6kiU-0002Af-1d; Sat, 25 Nov 2023 04:56:31 +0000 Date: Sat, 25 Nov 2023 04:56:20 +0000 From: Daniel Golle <daniel@makrotopia.org> To: Russell King <linux@armlinux.org.uk>, Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Marek =?iso-8859-1?q?Beh=FAn?= <kabel@kernel.org>, Pali =?iso-8859-1?q?Roh=E1r?= <pali@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Eric Woudstra <ericwouds@gmail.com>, John Crispin <john@phrozen.org> Subject: [PATCH net] net: phylink: set phy_state interface when attaching SFP Message-ID: <8abed37d01d427bf9d27a157860c54375c994ea1.1700887953.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 24 Nov 2023 20:56:54 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783510576110628864 X-GMAIL-MSGID: 1783510576110628864 |
Series |
[net] net: phylink: set phy_state interface when attaching SFP
|
|
Commit Message
Daniel Golle
Nov. 25, 2023, 4:56 a.m. UTC
Assume 'usxgmii' being set as initial interface mode in DTS. Now plug
a 2.5GBase-T SFP module with exposed PHY. Currently this results in
a rather bizare situation:
RTL8221B-VB-CG 2.5Gbps PHY (C45) i2c:sfp1-wan:11: rtl822x_c45_get_features: supported=00,00000000,00008000,000080ef
mtk_soc_eth 15100000.ethernet eth2: requesting link mode phy/2500base-x with support 00,00000000,00008000,0000e0ef
mtk_soc_eth 15100000.ethernet eth2: switched to phy/2500base-x link mode <<< !!!!!!
mtk_soc_eth 15100000.ethernet eth2: major config usxgmii <<< !!!!!!
mtk_soc_eth 15100000.ethernet eth2: phylink_mac_config: mode=phy/usxgmii/none adv=00,00000000,00000000,00000000 pause=00
mtk_soc_eth 15100000.ethernet eth2: PHY [i2c:sfp1-wan:11] driver [RTL8221B-VB-CG 2.5Gbps PHY (C45)] (irq=POLL)
mtk_soc_eth 15100000.ethernet eth2: phy: 2500base-x setting supported 00,00000000,00008000,0000e0ef advertising 00,00000000,00008000,0000e0ef
Then the link seemingly comes up (but is dead) because no subsequent
call to phylink_major_config actually configured MAC and PCS for
2500base-x mode.
This is because phylink_mac_initial_config() considers
pl->phy_state.interface if in MLO_AN_PHY mode while
phylink_sfp_set_config() only sets pl->link_config.interface.
Also set pl->phy_state.interface in phylink_sfp_set_config().
Fixes: 31eb8907aa5b ("net: phylink: allow attaching phy for SFP modules on 802.3z mode")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/net/phy/phylink.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Sat, Nov 25, 2023 at 04:56:20AM +0000, Daniel Golle wrote: > Assume 'usxgmii' being set as initial interface mode in DTS. Now plug > a 2.5GBase-T SFP module with exposed PHY. Currently this results in > a rather bizare situation: > > RTL8221B-VB-CG 2.5Gbps PHY (C45) i2c:sfp1-wan:11: rtl822x_c45_get_features: supported=00,00000000,00008000,000080ef > mtk_soc_eth 15100000.ethernet eth2: requesting link mode phy/2500base-x with support 00,00000000,00008000,0000e0ef > mtk_soc_eth 15100000.ethernet eth2: switched to phy/2500base-x link mode <<< !!!!!! > mtk_soc_eth 15100000.ethernet eth2: major config usxgmii <<< !!!!!! > mtk_soc_eth 15100000.ethernet eth2: phylink_mac_config: mode=phy/usxgmii/none adv=00,00000000,00000000,00000000 pause=00 > mtk_soc_eth 15100000.ethernet eth2: PHY [i2c:sfp1-wan:11] driver [RTL8221B-VB-CG 2.5Gbps PHY (C45)] (irq=POLL) > mtk_soc_eth 15100000.ethernet eth2: phy: 2500base-x setting supported 00,00000000,00008000,0000e0ef advertising 00,00000000,00008000,0000e0ef > > Then the link seemingly comes up (but is dead) because no subsequent > call to phylink_major_config actually configured MAC and PCS for > 2500base-x mode. > > This is because phylink_mac_initial_config() considers > pl->phy_state.interface if in MLO_AN_PHY mode while > phylink_sfp_set_config() only sets pl->link_config.interface. > > Also set pl->phy_state.interface in phylink_sfp_set_config(). Does it _actually_ matter? When the PHY's link comes up, doesn't it get sorted out for the real mode that will be used?
On Sat, Nov 25, 2023 at 08:28:20AM +0000, Russell King (Oracle) wrote: > On Sat, Nov 25, 2023 at 04:56:20AM +0000, Daniel Golle wrote: > > Assume 'usxgmii' being set as initial interface mode in DTS. Now plug > > a 2.5GBase-T SFP module with exposed PHY. Currently this results in > > a rather bizare situation: > > > > RTL8221B-VB-CG 2.5Gbps PHY (C45) i2c:sfp1-wan:11: rtl822x_c45_get_features: supported=00,00000000,00008000,000080ef > > mtk_soc_eth 15100000.ethernet eth2: requesting link mode phy/2500base-x with support 00,00000000,00008000,0000e0ef > > mtk_soc_eth 15100000.ethernet eth2: switched to phy/2500base-x link mode <<< !!!!!! > > mtk_soc_eth 15100000.ethernet eth2: major config usxgmii <<< !!!!!! > > mtk_soc_eth 15100000.ethernet eth2: phylink_mac_config: mode=phy/usxgmii/none adv=00,00000000,00000000,00000000 pause=00 > > mtk_soc_eth 15100000.ethernet eth2: PHY [i2c:sfp1-wan:11] driver [RTL8221B-VB-CG 2.5Gbps PHY (C45)] (irq=POLL) > > mtk_soc_eth 15100000.ethernet eth2: phy: 2500base-x setting supported 00,00000000,00008000,0000e0ef advertising 00,00000000,00008000,0000e0ef > > > > Then the link seemingly comes up (but is dead) because no subsequent > > call to phylink_major_config actually configured MAC and PCS for > > 2500base-x mode. > > > > This is because phylink_mac_initial_config() considers > > pl->phy_state.interface if in MLO_AN_PHY mode while > > phylink_sfp_set_config() only sets pl->link_config.interface. > > > > Also set pl->phy_state.interface in phylink_sfp_set_config(). > > Does it _actually_ matter? It does matter, I'm suggesting this change because the SFP module won't work without it. > When the PHY's link comes up, doesn't it get sorted out for the real > mode that will be used? That does happen once the interface mode *changes* to anything else, than 2500M/Full and the PHY driver sets state->interface to SGMII. However, initially it does *not* happen, probably because phylink ends up believing MAC and PCS are already operating in 2500base-x mode (but that's not the case). Previously (eg. with the BananaPi R3) this has not been a problem because the default interface mode defined in device tree anyway has also been 2500base-x. Now that I'm testing the same module with the R4 which uses usxgmii by default the problem surfaced.
On Fri, Dec 01, 2023 at 06:19:20PM +0000, Daniel Golle wrote: > On Sat, Nov 25, 2023 at 08:28:20AM +0000, Russell King (Oracle) wrote: > > On Sat, Nov 25, 2023 at 04:56:20AM +0000, Daniel Golle wrote: > > > Assume 'usxgmii' being set as initial interface mode in DTS. Now plug > > > a 2.5GBase-T SFP module with exposed PHY. Currently this results in > > > a rather bizare situation: > > > > > > RTL8221B-VB-CG 2.5Gbps PHY (C45) i2c:sfp1-wan:11: rtl822x_c45_get_features: supported=00,00000000,00008000,000080ef > > > mtk_soc_eth 15100000.ethernet eth2: requesting link mode phy/2500base-x with support 00,00000000,00008000,0000e0ef > > > mtk_soc_eth 15100000.ethernet eth2: switched to phy/2500base-x link mode <<< !!!!!! > > > mtk_soc_eth 15100000.ethernet eth2: major config usxgmii <<< !!!!!! > > > mtk_soc_eth 15100000.ethernet eth2: phylink_mac_config: mode=phy/usxgmii/none adv=00,00000000,00000000,00000000 pause=00 > > > mtk_soc_eth 15100000.ethernet eth2: PHY [i2c:sfp1-wan:11] driver [RTL8221B-VB-CG 2.5Gbps PHY (C45)] (irq=POLL) > > > mtk_soc_eth 15100000.ethernet eth2: phy: 2500base-x setting supported 00,00000000,00008000,0000e0ef advertising 00,00000000,00008000,0000e0ef > > > > > > Then the link seemingly comes up (but is dead) because no subsequent > > > call to phylink_major_config actually configured MAC and PCS for > > > 2500base-x mode. > > > > > > This is because phylink_mac_initial_config() considers > > > pl->phy_state.interface if in MLO_AN_PHY mode while > > > phylink_sfp_set_config() only sets pl->link_config.interface. > > > > > > Also set pl->phy_state.interface in phylink_sfp_set_config(). > > > > Does it _actually_ matter? > > It does matter, I'm suggesting this change because the SFP module > won't work without it. > > > When the PHY's link comes up, doesn't it get sorted out for the real > > mode that will be used? > > That does happen once the interface mode *changes* to anything else, > than 2500M/Full and the PHY driver sets state->interface to SGMII. > However, initially it does *not* happen, probably because phylink > ends up believing MAC and PCS are already operating in 2500base-x > mode (but that's not the case). > > Previously (eg. with the BananaPi R3) this has not been a problem > because the default interface mode defined in device tree anyway has > also been 2500base-x. Now that I'm testing the same module with the > R4 which uses usxgmii by default the problem surfaced. Okay, I think what we have here is an ordering issue in phylink_sfp_connect_phy(). phylink_bringup_phy() will set phy_state.interface, but that happens after the major config has happened. With a built-in PHY, the sequence would be: - connect to PHY (which calls phylink_bringup_phy()) - phylink_start() (which calls phylink_major_config()) whereas in this case we have the reverse. That needs to be sorted. I can't do that over this weekend, but if you remind me I'll look at it next week. Thanks.
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index aa842634d5c2c..21ef77e4fe720 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -3056,6 +3056,7 @@ static void phylink_sfp_set_config(struct phylink *pl, u8 mode, pl->link_config.interface != state->interface) { pl->cur_link_an_mode = mode; pl->link_config.interface = state->interface; + pl->phy_state.interface = state->interface; changed = true;