Re: [PATCH net-next 2/2] net: phy: marvell: implement cable-test for 88E308X/88E609X family

From: Andrew Lunn
Date: Tue Mar 26 2024 - 10:33:43 EST


> + ret = phy_write(phydev, MII_BMCR, 0xa100);

BMCR_RESET | BMCR_ANENABLE | BMCR_FULLDPLX

You should check i have that correct, but no need for magic values
with this register.

> +static int m88e3082_vct_cable_test_report_trans(int result, u8 distance)
> +{
> + switch (result) {
> + case MII_VCT_TXRXPINS_VCTTST_OK:
> + if (distance == MII_VCT_TXRXPINS_DISTRFLN_MAX)
> + return ETHTOOL_A_CABLE_RESULT_CODE_OK;
> + /* Impedance mismatch */
> + return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC;

It is possible to add more results code, if you think Impedance
mismatch is useful.

> + ret = phy_write(phydev, MII_BMCR, priv->m88e3082_vct_reg_backup);
> + if (ret < 0)
> + return ret;

I'm not sure this is required. When the cable test is finished, the
PHY state machine is moved to PHY_UP. That will cause
phy_config_aneg() to be called which should set BMCR back to the
correct value.

Andrew