Re: [PATCH net-next v1 2/4] net: phy: micrel: add EEE configuration support for KSZ9477 variants of PHYs

From: Andrew Lunn
Date: Thu Jan 19 2023 - 09:11:18 EST


> +static int ksz9477_get_eee_caps(struct phy_device *phydev,
> + struct ethtool_eee *data)
> +{
> + int val;
> +
> + /* At least on KSZ8563 (which has same PHY_ID as KSZ9477), the
> + * MDIO_PCS_EEE_ABLE register is a mirror of MDIO_AN_EEE_ADV register.
> + * So, we need to provide this information by driver.
> + */
> + data->supported = SUPPORTED_100baseT_Full;
> +
> + /* KSZ8563 is able to advertise not supported MDIO_EEE_1000T.
> + * We need to test if the PHY is 1Gbit capable.
> + */
> + val = phy_read(phydev, MII_BMSR);
> + if (val < 0)
> + return val;
> +
> + if (val & BMSR_ERCAP)
> + data->supported |= SUPPORTED_1000baseT_Full;

This works, but you could also look at phydev->supported and see if
one of the 1G modes is listed. That should be faster, since there is
no MDIO transaction involved. Not that this is on any sort of hot
path.

Andrew