On Sun, Apr 28, 2019 at 08:10:43PM +0200, Heiner Kallweit wrote: > On 28.04.2019 19:04, Andrew Lunn wrote: > > On Sun, Apr 28, 2019 at 03:03:37PM +0200, Heiner Kallweit wrote: > >> So far we set the advertising bitmap before setting the pause flags > >> in the supported bitmap. This may cause pause not being advertised. > > > > Hi Heiner > > > > Pause requires that the PHY can advertise the pause bits, and that the > > MAC supports pause. So by default, we don't advertise pause. The MAC > > needs to say it supports pause, by calling one of > > > > void phy_support_sym_pause(struct phy_device *phydev); > > void phy_support_asym_pause(struct phy_device *phydev); > > > > These two then copy supported into advertising. > > > Right, missed that. After checking the code a little bit more I think > we still may have few issues with pause settings.
Hi Heiner I agree the current state could be improved. We just have to be careful how we do it. We don't want to introduce regressions. There are a lot of MAC drivers we have no idea if they support pause or not. We do get some clues from .set_pauseparam. > 1. > We have functions that copy supported -> advertising, e.g. > phy_set_max_speed(). If such a function is called pause gets advertised > even w/o the MAC calling one of the two functions. Yes. I'm not sure supported is the best place to keep this information about what the PHY can do about pause, because off issues like this. You also see such copies in a few MAC drivers. So we might want to move PHY pause capability it into new bits in phydev. > 2. > We have PHY's (e.g. KSZ9031) that support sym pause only due to a hw > erratum. If the MAC now calls phy_support_asym_pause() it sets the > asym pause flag in phydev->supported even though the PHY intentionally > disabled it. That's not nice .. Yes, some validation would be good. > Maybe we should do it differently: > Apply my patch, then both pause modes are initially advertised. > (This also avoids point 3 below) > - remove phy_support_asym_pause() > - phy_support_sym_pause() clears the asym pause bit and doesn't touch > sym pause bit. > - and we may need something like phy_support_no_pause(). I would prefer to keep with the assumption that the MAC does not support pause until it tells us it does. > 3. > What's with all the existing drivers where the MAC supports pause but > drivers call neither of the two functions? Apart from .set_pauseparams, we have no way to identify them. > 4. > Calling either of the two functions will be effective after an autoneg > restart only. Do we have to consider this? The code i've seen does this before calling phy_start(). So i don't think it is an issue. But we could add in code to see if the phy has been started, and if so, restart autoneg. Andrew