Re: [PATCH net-next] net: phy: vitesse: implement MDI-X configuration in vsc73xx

From: Andrew Lunn
Date: Sun Aug 25 2024 - 22:14:10 EST


On Fri, Aug 23, 2024 at 10:46:44AM +0200, Paweł Dembicki wrote:
> czw., 22 sie 2024 o 17:58 Andrew Lunn <andrew@xxxxxxx> napisał(a):
> >
> > > +static int vsc73xx_mdix_set(struct phy_device *phydev, u8 mdix)
> > > +{
> > > + int ret;
> > > + u16 val;
> > > +
> > > + val = phy_read(phydev, MII_VSC73XX_PHY_BYPASS_CTRL);
> > > +
> > > + switch (mdix) {
> > > + case ETH_TP_MDI:
> > > + val |= MII_VSC73XX_PBC_FOR_SPD_AUTO_MDIX_DIS |
> > > + MII_VSC73XX_PBC_PAIR_SWAP_DIS |
> > > + MII_VSC73XX_PBC_POL_INV_DIS;
> > > + break;
> > > + case ETH_TP_MDI_X:
> > > + /* When MDI-X auto configuration is disabled, is possible
> > > + * to force only MDI mode. Let's use autoconfig for forced
> > > + * MDIX mode.
> > > + */
> > > + default:
> > > + val &= ~(MII_VSC73XX_PBC_FOR_SPD_AUTO_MDIX_DIS |
> >
> > This could be a little bit more readable if rather than default: you
> > used case ETH_TP_MDI_AUTO: . Then after this code, add a real default:
> > which returns -EINVAL,
> >
>
> How should I handle ETH_TP_MDI_INVALID? Should I do it like in
> marvell.c or rockchip.c, or leave it as the default?

ETH_TP_MDI_INVALID generally means there is no support for controlling
MDI. But you are adding support. The most useful default is
ETH_TP_MDI_AUTO. So i would do that here. I would also set
phydev->mdio_ctrl to whatever the hardware defaults to in .probe, or
.config_init

Andrew