Re: [RFC net-next v2 3/5] net: phy: nxp-c45-tja11xx add MACsec support

Sabrina Dubroca
2023-08-28T10:45:36Z

2023-08-25, 15:29:30 +0200, Andrew Lunn wrote:
> On Fri, Aug 25, 2023 at 02:52:57PM +0200, Sabrina Dubroca wrote:
> > 2023-08-24, 12:16:13 +0300, Radu Pirea (NXP OSS) wrote:
> > > +static int nxp_c45_macsec_write(struct phy_device *phydev, u16 reg, u32 val)
> > > +{
> > > + WARN_ON_ONCE(reg % 4);
> > > +
> > > + reg = reg / 2;
> > > + phy_write_mmd(phydev, MDIO_MMD_VEND2,
> > > + VEND1_MACSEC_BASE + reg, val);
> > > + phy_write_mmd(phydev, MDIO_MMD_VEND2,
> > > + VEND1_MACSEC_BASE + reg + 1, val >> 16);
> >
> > Can these calls fail? ie, do you need to handle errors like in
> > nxp_c45_macsec_read (and then in callers of nxp_c45_macsec_write)?
>
> Access to PHY devices can fail, but if it does, such failures are
> generally fatal and there is no real recovery, also the next read/
> write is also likely to fail. So we do recommend checking return codes
> and just return the error up the stack. That failure might get trapped
> up the stack, and turned into a phy_error() call which will disable
> the PHY.

Ok, thanks. A lot of the calls to nxp_c45_macsec_write come from the
core macsec code (via mdo_*), so at least this part of the stack isn't
going to catch them. Either these errors can be caught directly in the
driver, or we'll have to ignore them (once we return from the driver
to the macsec core, we can't know if the error was fatal so we have to
assume it's not). And phy_error's doc says it can't be called under
phydev->lock, which we're holding in all those mdo_* functions (called
from macsec_offload()).

--
Sabrina