netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Frank Wunderlich <frank-w@public-files.de>
Cc: Daniel Golle <daniel@makrotopia.org>,
	netdev@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v12 08/18] net: ethernet: mtk_eth_soc: fix 1000Base-X and 2500Base-X modes
Date: Tue, 14 Mar 2023 10:10:22 +0000	[thread overview]
Message-ID: <ZBBIDqZaqdSfwu9g@shell.armlinux.org.uk> (raw)
In-Reply-To: <trinity-bc4bbf4e-812a-4682-ac8c-5178320467f5-1678788102813@3c-app-gmx-bap66>

On Tue, Mar 14, 2023 at 11:01:42AM +0100, Frank Wunderlich wrote:
> Hi
> 
> > Gesendet: Dienstag, 14. März 2023 um 10:12 Uhr
> > Von: "Russell King (Oracle)" <linux@armlinux.org.uk>
> > On Tue, Mar 14, 2023 at 09:51:12AM +0100, Frank Wunderlich wrote:
> > > Hi,
> > > 
> > > at least the error-message is gone, and interface gets up when i call ethtoo to switch off autoneg.
> ...
> > > [   34.400860] mtk_soc_eth 15100000.ethernet eth1: phylink_mac_config: mode=inband/2500base-x/Unknown/Unknown/none adv=00,00000000,00000000,0000e400 pause=04 link=0 an=1
> > 
> > Looking good - apart from that pesky an=1 (which isn't used by the PCS
> > driver, and I've been thinking of killing it off anyway.) Until such
> > time that happens, we really ought to set that correctly, which means
> > an extra bit is needed in phylink_sfp_set_config(). However, this
> > should not affect anything.
> > 
> > > root@bpi-r3:~# 
> > > root@bpi-r3:~# ethtool -s eth1 autoneg off
> > > root@bpi-r3:~# [  131.031902] mtk_soc_eth 15100000.ethernet eth1: Link is Up - 2.5Gbps/Full - flow control off
> > > [  131.040366] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
> > > 
> > > full log here:
> > > https://pastebin.com/yDC7PuM2
> > > 
> > > i see that an is still 1..maybe because of the fixed value here?
> > > 
> > > https://elixir.bootlin.com/linux/v6.3-rc1/source/drivers/net/phy/phylink.c#L3038
> > 
> > Not sure what that line has to do with it - this is what the above
> > points to:
> > 
> >         phylink_sfp_set_config(pl, MLO_AN_INBAND, pl->sfp_support, &config);
> 
> MLO_AN_INBAND => may cause the an=1 and mode=inband if previously (?) disabled :)

For 802.3z modes, MLO_AN_INBAND with Autoneg clear in the advertising mode
disables in-band negotiation. This is exactly how "ethtool -s ethX
autoneg off" works.

> > The patch below should result in ethtool reporting 2500baseT rather than
> > 2500baseX, and that an=1 should now be an=0. Please try it, and dump the
> > ethtool eth1 before asking for autoneg to be manually disabled, and also
> > report the kernel messages.
> 
> i see no Patch below ;)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 1a2f074685fa..b8844dfcbf51 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2898,6 +2898,10 @@ static void phylink_sfp_set_config(struct phylink *pl, u8 mode,
 		changed = true;
 	}
 
+	if (pl->link_config.an_enabled != state->an_enabled)
+		changed = true;
+	pl->link_config.an_enabled = state->an_enabled;
+
 	if (pl->cur_link_an_mode != mode ||
 	    pl->link_config.interface != state->interface) {
 		pl->cur_link_an_mode = mode;
@@ -3001,7 +3005,8 @@ static int phylink_sfp_config_optical(struct phylink *pl)
 	config.speed = SPEED_UNKNOWN;
 	config.duplex = DUPLEX_UNKNOWN;
 	config.pause = MLO_PAUSE_AN;
-	config.an_enabled = true;
+	config.an_enabled = linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
+					      support);
 
 	/* For all the interfaces that are supported, reduce the sfp_support
 	 * mask to only those link modes that can be supported.
diff --git a/drivers/net/phy/sfp-bus.c b/drivers/net/phy/sfp-bus.c
index daac293e8ede..1dd50f2ca05d 100644
--- a/drivers/net/phy/sfp-bus.c
+++ b/drivers/net/phy/sfp-bus.c
@@ -151,6 +151,10 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
 	unsigned int br_min, br_nom, br_max;
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(modes) = { 0, };
 
+	phylink_set(modes, Autoneg);
+	phylink_set(modes, Pause);
+	phylink_set(modes, Asym_Pause);
+
 	/* Decode the bitrate information to MBd */
 	br_min = br_nom = br_max = 0;
 	if (id->base.br_nominal) {
@@ -329,10 +333,6 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
 		bus->sfp_quirk->modes(id, modes, interfaces);
 
 	linkmode_or(support, support, modes);
-
-	phylink_set(support, Autoneg);
-	phylink_set(support, Pause);
-	phylink_set(support, Asym_Pause);
 }
 EXPORT_SYMBOL_GPL(sfp_parse_support);
 
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 39e3095796d0..9c1fa0b1737f 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -360,6 +360,23 @@ static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id,
 	__set_bit(PHY_INTERFACE_MODE_2500BASEX, interfaces);
 }
 
+static void sfp_quirk_disable_autoneg(const struct sfp_eeprom_id *id,
+				      unsigned long *modes,
+				      unsigned long *interfaces)
+{
+	linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, modes);
+}
+
+static void sfp_quirk_oem_2_5g(const struct sfp_eeprom_id *id,
+			       unsigned long *modes,
+			       unsigned long *interfaces)
+{
+	/* Copper 2.5G SFP */
+	linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, modes);
+	__set_bit(PHY_INTERFACE_MODE_2500BASEX, interfaces);
+	sfp_quirk_disable_autoneg(id, modes, interfaces);
+}
+
 static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id,
 				      unsigned long *modes,
 				      unsigned long *interfaces)
@@ -401,6 +418,7 @@ static const struct sfp_quirk sfp_quirks[] = {
 	SFP_QUIRK_M("UBNT", "UF-INSTANT", sfp_quirk_ubnt_uf_instant),
 
 	SFP_QUIRK_F("OEM", "SFP-10G-T", sfp_fixup_rollball_cc),
+	SFP_QUIRK_M("OEM", "SFP-2.5G-T", sfp_quirk_oem_2_5g),
 	SFP_QUIRK_F("OEM", "RTSFP-10", sfp_fixup_rollball_cc),
 	SFP_QUIRK_F("OEM", "RTSFP-10G", sfp_fixup_rollball_cc),
 	SFP_QUIRK_F("Turris", "RTSFP-10", sfp_fixup_rollball),

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2023-03-14 10:10 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 15:52 [PATCH net-next v12 00/18] net: ethernet: mtk_eth_soc: various enhancements Daniel Golle
2023-03-07 15:52 ` [PATCH net-next v12 01/18] net: ethernet: mtk_eth_soc: add support for MT7981 SoC Daniel Golle
2023-03-07 15:52 ` [PATCH net-next v12 02/18] dt-bindings: net: mediatek,net: add mt7981-eth binding Daniel Golle
2023-03-07 15:52 ` [PATCH net-next v12 03/18] dt-bindings: arm: mediatek: sgmiisys: Convert to DT schema Daniel Golle
2023-03-07 15:53 ` [PATCH net-next v12 04/18] dt-bindings: arm: mediatek: sgmiisys: add MT7981 SoC Daniel Golle
2023-03-07 15:53 ` [PATCH net-next v12 05/18] net: ethernet: mtk_eth_soc: set MDIO bus clock frequency Daniel Golle
2023-03-07 15:53 ` [PATCH net-next v12 06/18] net: ethernet: mtk_eth_soc: reset PCS state Daniel Golle
2023-03-07 18:49   ` Aw: " Frank Wunderlich
2023-03-07 15:53 ` [PATCH net-next v12 07/18] net: ethernet: mtk_eth_soc: only write values if needed Daniel Golle
2023-03-07 18:53   ` Aw: " Frank Wunderlich
2023-03-07 15:53 ` [PATCH net-next v12 08/18] net: ethernet: mtk_eth_soc: fix 1000Base-X and 2500Base-X modes Daniel Golle
2023-03-07 18:52   ` Aw: " Frank Wunderlich
2023-03-08 11:35   ` Russell King (Oracle)
2023-03-08 12:11     ` Daniel Golle
2023-03-08 12:41       ` Russell King (Oracle)
2023-03-08 12:53         ` Daniel Golle
2023-03-08 13:12           ` Russell King (Oracle)
2023-03-08 13:46             ` Vladimir Oltean
2023-03-08 14:12               ` Russell King (Oracle)
2023-03-08 14:32                 ` Daniel Golle
2023-03-08 15:01                   ` Russell King (Oracle)
2023-03-08 15:08                     ` Daniel Golle
2023-03-08 15:24                       ` Russell King (Oracle)
2023-03-11 12:05                         ` Aw: " Frank Wunderlich
2023-03-11 13:26                           ` Frank Wunderlich
2023-03-11 14:51                             ` Daniel Golle
2023-03-11 20:02                               ` Russell King (Oracle)
2023-03-11 20:34                                 ` Daniel Golle
2023-03-11 20:00                           ` Russell King (Oracle)
2023-03-11 20:21                             ` Frank Wunderlich
2023-03-11 20:30                               ` Russell King (Oracle)
2023-03-12 12:40                                 ` Aw: " Frank Wunderlich
2023-03-12 14:26                                   ` Frank Wunderlich
2023-03-12 16:50                                     ` Frank Wunderlich
2023-03-12 20:10                                       ` Russell King (Oracle)
2023-03-12 20:05                                   ` Russell King (Oracle)
2023-03-13 10:59                                     ` Russell King (Oracle)
2023-03-13 18:39                                       ` Aw: " Frank Wunderlich
2023-03-13 22:57                                         ` Russell King (Oracle)
2023-03-14  8:51                                           ` Aw: " Frank Wunderlich
2023-03-14  9:12                                             ` Russell King (Oracle)
2023-03-14 10:01                                               ` Aw: " Frank Wunderlich
2023-03-14 10:10                                                 ` Russell King (Oracle) [this message]
2023-03-14 13:59                                                   ` Aw: " Frank Wunderlich
2023-03-14 14:11                                                     ` Russell King (Oracle)
2023-03-07 15:54 ` [PATCH net-next v12 09/18] net: ethernet: mtk_eth_soc: Fix link status for none-SGMII modes Daniel Golle
2023-03-07 18:50   ` Aw: " Frank Wunderlich
2023-03-08 11:38   ` Russell King (Oracle)
2023-03-08 11:44     ` Frank Wunderlich
2023-03-08 12:05       ` Daniel Golle
2023-03-08 16:24         ` Russell King (Oracle)
2023-03-08 12:35       ` Russell King (Oracle)
2023-03-07 15:54 ` [PATCH net-next v12 10/18] net: ethernet: mtk_eth_soc: ppe: add support for flow accounting Daniel Golle
2023-03-07 15:54 ` [PATCH net-next v12 11/18] net: pcs: add driver for MediaTek SGMII PCS Daniel Golle
2023-03-07 18:52   ` Aw: " Frank Wunderlich
2023-03-07 15:54 ` [PATCH net-next v12 12/18] net: ethernet: mtk_eth_soc: switch to external PCS driver Daniel Golle
2023-03-07 15:55 ` [PATCH net-next v12 13/18] net: dsa: mt7530: use " Daniel Golle
2023-03-07 15:55 ` [PATCH net-next v12 14/18] net: ethernet: mtk_eth_soc: add MTK_NETSYS_V1 capability bit Daniel Golle
2023-03-07 15:55 ` [PATCH net-next v12 15/18] net: ethernet: mtk_eth_soc: move MAX_DEVS in mtk_soc_data Daniel Golle
2023-03-07 15:55 ` [PATCH v12 16/18] net: ethernet: mtk_eth_soc: rely on num_devs and remove MTK_MAC_COUNT Daniel Golle
2023-03-07 15:55 ` [PATCH v12 17/18] net: ethernet: mtk_eth_soc: add MTK_NETSYS_V3 capability bit Daniel Golle
2023-03-07 15:56 ` [PATCH v12 18/18] net: ethernet: mtk_eth_soc: convert caps in mtk_soc_data struct to u64 Daniel Golle

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=ZBBIDqZaqdSfwu9g@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=daniel@makrotopia.org \
    --cc=frank-w@public-files.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=netdev@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;
as well as URLs for NNTP newsgroup(s).