Subject: mv88e6xxx: 2500base-x inband AN is broken on Amethyst? what to do?

From: Marek Behún <[email-masked]>
Date: Wed, 13 Jan 2021 01:18:23 +0100

Hello,

it seems that inband AN is broken on Amethyst when on 2500base-x mode.

Even SERDES scripts for Amethyst from Marvell has autonegotiation
disabled for 2500base-x mode. For all the other supported Serdes modes
autonegotiation is enabled in these scripts.

The current implementation in mv88e6390_serdes_pcs_config() enables
autonegotiation if phylink_autoneg_inband(mode) is true:

  if (phylink_autoneg_inband(mode))
    bmcr = val | BMCR_ANENABLE;
  else
    bmcr = val & ~BMCR_ANENABLE;

But for PHY_INTERFACE_MODE_2500BASEX this is broken on Amethyst. The
2500base-x mode seems to work only with autoneg disabled.

The result is that when I connect via a passive SFP cable Amethyst
serdes port with a Peridot serdes port, they will not link. If I
disable autonegotiation on both sides, they will link, though.

What is strange is that if I don't use Peridot, but connect the SFP
directly to Serdes on Armada 3720, where the mvneta driver also enables
autonegotiation for 2500base-x mode, they will link even if Amethyst
does not enable 2500base-x.

To summarize:
	Amethyst  <->	Peridot
	AN -		AN -		works
	AN -		AN +		does not work

	Amethyst  <->	Armada 3720 serdes
	AN -		AN +		works

(It is possible that Marvell may find some workaround by touch some
 undocumented registers, to solve this. I will try to open a bug
 report.)

Should we just print an error in the serdes_pcs_config method if inband
autonegotiation is being requested?

phylink's code currently allows connecting SFPs in non MLO_AN_INBAND
mode only for when there is Broadcom BCM84881 PHY inside the SFP (by
method phylink_phy_no_inband() in phylink.c).

I wonder whether we can somehow in a sane way implement code to inform
phylink from the mv88e6xxx driver that inband is not supported for the
specific mode. Maybe the .mac_config/.pcs_config method could return an
error indicating this? Or the mv88e6xxx driver can just print an error
that the mode is not supported, and try to ask the user to disable AN?
That would need implementing this in ethtool for SFP, though.

What do you guys think?

Marek