Aw: Re: Re: [PATCH net-next v12 08/18] net: ethernet: mtk_eth_soc: fix 1000Base-X and 2500Base-X modes

From: Frank Wunderlich
Date: Sun Mar 12 2023 - 08:41:31 EST


> Gesendet: Samstag, 11. März 2023 um 21:30 Uhr
> Von: "Russell King (Oracle)" <linux@xxxxxxxxxxxxxxx>

> On Sat, Mar 11, 2023 at 09:21:47PM +0100, Frank Wunderlich wrote:
> > Am 11. März 2023 21:00:20 MEZ schrieb "Russell King (Oracle)" <linux@xxxxxxxxxxxxxxx>:
> > >On Sat, Mar 11, 2023 at 01:05:37PM +0100, Frank Wunderlich wrote:
> >
> > >> i got the 2.5G copper sfps, and tried them...they work well with the v12 (including this patch), but not in v13...
> >
> > >> how can we add a quirk to support this?
> > >
> > >Why does it need a quirk?
> >
> > To disable the inband-mode for this 2.5g copper
> > sfp. But have not found a way to set a flag which i
> > can grab in phylink.
>
> We could make sfp_parse_support() set Autoneg, Pause, and Asym_Pause
> in "modes" at the top of that function, and then use the SFP modes
> quirk to clear the Autoneg bit for this SFP. Would that work for you?

i already tried this (without moving the autoneg/pause to sfp_parse_support):

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);
}

quirk was executed, but no change (no link on 2g5 sfp).

i guess you mean moving code handling the dt-property for inband-mode in phylink_parse_mode (phylink.c) to the sfp-function (drivers/net/phy/sfp-bus.c)

as a first test i tried to disable autoneg for the inband-setting

@@ -840,11 +842,18 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode)

linkmode_zero(pl->supported);
phylink_set(pl->supported, MII);
- phylink_set(pl->supported, Autoneg);
+ //phylink_set(pl->supported, Autoneg);
phylink_set(pl->supported, Asym_Pause);
phylink_set(pl->supported, Pause);
pl->link_config.an_enabled = true;
- pl->cfg_link_an_mode = MLO_AN_INBAND;
+ //pl->cfg_link_an_mode = MLO_AN_INBAND;
+
+ //how to access sfp->inband_disable?
+ printk(KERN_ALERT "DEBUG: Passed %s:%d %d==%d (inband)??",__FUNCTION__,__LINE__, pl->cfg_link_an_mode, MLO_AN_INBAND);
+ //pl->cfg_link_an_mode = MLO_AN_PHY;
+ pl->link_config.an_enabled = false;
+ //phylink_clear(pl->supported, Autoneg);
+ printk(KERN_ALERT "DEBUG: Passed %s:%d %d==%d (inband)?? (forced phy-mode)",__FUNCTION__,__LINE__, pl->cfg_link_an_mode, MLO_AN_INBAND);

switch (pl->link_config.interface) {
case PHY_INTERFACE_MODE_SGMII:
@@ -947,7 +956,7 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode)
}

/* Check if MAC/PCS also supports Autoneg. */
- pl->link_config.an_enabled = phylink_test(pl->supported, Autoneg);
+ //pl->link_config.an_enabled = phylink_test(pl->supported, Autoneg);
}

return 0;

but it seems this is not enough (or i miss something) and i get error when i try to set mac up

root@bpi-r3:~# ip link set eth1 up
[ 30.044144] mtk_soc_eth 15100000.ethernet eth1: mtk_open: could not attach PHY: -19
RTNETLINK answers: No such device

regards Frank