* Re: [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation
[not found] <20190909204906.2191290-1-taoren@fb.com>
@ 2019-09-09 21:56 ` Tao Ren
2019-09-14 14:17 ` Andrew Lunn
1 sibling, 0 replies; 8+ messages in thread
From: Tao Ren @ 2019-09-09 21:56 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit, David S . Miller,
Vladimir Oltean, Arun Parameswaran, Justin Chen, netdev,
linux-kernel, openbmc
Hi Andrew / Florian,
On 9/9/19 1:49 PM, Tao Ren wrote:
> From: Heiner Kallweit <hkallweit1@gmail.com>
>
> This patch adds support for clause 37 1000Base-X auto-negotiation.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Tao Ren <taoren@fb.com>
> Tested-by: René van Dorst <opensource@vdorst.com>
Just want to check if I missed your comments (I noticed some wired problems on my email client)?
If yes (sorry I missed something), could you please re-send your comments? And I will address them as soon as possible.
Thanks,
Tao
> ---
> Changes in v8:
> - Rebased the patch on top of net-next HEAD.
> Changes in v7:
> - Update "if (AUTONEG_ENABLE != phydev->autoneg)" to
> "if (phydev->autoneg != AUTONEG_ENABLE)" so checkpatch.pl is happy.
> Changes in v6:
> - add "Signed-off-by: Tao Ren <taoren@fb.com>"
> Changes in v1-v5:
> - nothing changed. It's given v5 just to align with the version of
> patch series.
>
> drivers/net/phy/phy_device.c | 139 +++++++++++++++++++++++++++++++++++
> include/linux/phy.h | 4 +
> 2 files changed, 143 insertions(+)
>
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 8933f07d39e9..dd05f750bb3f 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -1607,6 +1607,40 @@ static int genphy_config_advert(struct phy_device *phydev)
> return changed;
> }
>
> +/**
> + * genphy_c37_config_advert - sanitize and advertise auto-negotiation parameters
> + * @phydev: target phy_device struct
> + *
> + * Description: Writes MII_ADVERTISE with the appropriate values,
> + * after sanitizing the values to make sure we only advertise
> + * what is supported. Returns < 0 on error, 0 if the PHY's advertisement
> + * hasn't changed, and > 0 if it has changed. This function is intended
> + * for Clause 37 1000Base-X mode.
> + */
> +static int genphy_c37_config_advert(struct phy_device *phydev)
> +{
> + u16 adv = 0;
> +
> + /* Only allow advertising what this PHY supports */
> + linkmode_and(phydev->advertising, phydev->advertising,
> + phydev->supported);
> +
> + if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT,
> + phydev->advertising))
> + adv |= ADVERTISE_1000XFULL;
> + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT,
> + phydev->advertising))
> + adv |= ADVERTISE_1000XPAUSE;
> + if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
> + phydev->advertising))
> + adv |= ADVERTISE_1000XPSE_ASYM;
> +
> + return phy_modify_changed(phydev, MII_ADVERTISE,
> + ADVERTISE_1000XFULL | ADVERTISE_1000XPAUSE |
> + ADVERTISE_1000XHALF | ADVERTISE_1000XPSE_ASYM,
> + adv);
> +}
> +
> /**
> * genphy_config_eee_advert - disable unwanted eee mode advertisement
> * @phydev: target phy_device struct
> @@ -1715,6 +1749,54 @@ int __genphy_config_aneg(struct phy_device *phydev, bool changed)
> }
> EXPORT_SYMBOL(__genphy_config_aneg);
>
> +/**
> + * genphy_c37_config_aneg - restart auto-negotiation or write BMCR
> + * @phydev: target phy_device struct
> + *
> + * Description: If auto-negotiation is enabled, we configure the
> + * advertising, and then restart auto-negotiation. If it is not
> + * enabled, then we write the BMCR. This function is intended
> + * for use with Clause 37 1000Base-X mode.
> + */
> +int genphy_c37_config_aneg(struct phy_device *phydev)
> +{
> + int err, changed;
> +
> + if (phydev->autoneg != AUTONEG_ENABLE)
> + return genphy_setup_forced(phydev);
> +
> + err = phy_modify(phydev, MII_BMCR, BMCR_SPEED1000 | BMCR_SPEED100,
> + BMCR_SPEED1000);
> + if (err)
> + return err;
> +
> + changed = genphy_c37_config_advert(phydev);
> + if (changed < 0) /* error */
> + return changed;
> +
> + if (!changed) {
> + /* Advertisement hasn't changed, but maybe aneg was never on to
> + * begin with? Or maybe phy was isolated?
> + */
> + int ctl = phy_read(phydev, MII_BMCR);
> +
> + if (ctl < 0)
> + return ctl;
> +
> + if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE))
> + changed = 1; /* do restart aneg */
> + }
> +
> + /* Only restart aneg if we are advertising something different
> + * than we were before.
> + */
> + if (changed > 0)
> + return genphy_restart_aneg(phydev);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(genphy_c37_config_aneg);
> +
> /**
> * genphy_aneg_done - return auto-negotiation status
> * @phydev: target phy_device struct
> @@ -1862,6 +1944,63 @@ int genphy_read_status(struct phy_device *phydev)
> }
> EXPORT_SYMBOL(genphy_read_status);
>
> +/**
> + * genphy_c37_read_status - check the link status and update current link state
> + * @phydev: target phy_device struct
> + *
> + * Description: Check the link, then figure out the current state
> + * by comparing what we advertise with what the link partner
> + * advertises. This function is for Clause 37 1000Base-X mode.
> + */
> +int genphy_c37_read_status(struct phy_device *phydev)
> +{
> + int lpa, err, old_link = phydev->link;
> +
> + /* Update the link, but return if there was an error */
> + err = genphy_update_link(phydev);
> + if (err)
> + return err;
> +
> + /* why bother the PHY if nothing can have changed */
> + if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
> + return 0;
> +
> + phydev->duplex = DUPLEX_UNKNOWN;
> + phydev->pause = 0;
> + phydev->asym_pause = 0;
> +
> + if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) {
> + lpa = phy_read(phydev, MII_LPA);
> + if (lpa < 0)
> + return lpa;
> +
> + linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
> + phydev->lp_advertising, lpa & LPA_LPACK);
> + linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseX_Full_BIT,
> + phydev->lp_advertising, lpa & LPA_1000XFULL);
> + linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT,
> + phydev->lp_advertising, lpa & LPA_1000XPAUSE);
> + linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
> + phydev->lp_advertising,
> + lpa & LPA_1000XPAUSE_ASYM);
> +
> + phy_resolve_aneg_linkmode(phydev);
> + } else if (phydev->autoneg == AUTONEG_DISABLE) {
> + int bmcr = phy_read(phydev, MII_BMCR);
> +
> + if (bmcr < 0)
> + return bmcr;
> +
> + if (bmcr & BMCR_FULLDPLX)
> + phydev->duplex = DUPLEX_FULL;
> + else
> + phydev->duplex = DUPLEX_HALF;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(genphy_c37_read_status);
> +
> /**
> * genphy_soft_reset - software reset the PHY via BMCR_RESET bit
> * @phydev: target phy_device struct
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index a7ecbe0e55aa..cd9786ccf630 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -1104,6 +1104,10 @@ int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad,
> int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
> u16 regnum, u16 val);
>
> +/* Clause 37 */
> +int genphy_c37_config_aneg(struct phy_device *phydev);
> +int genphy_c37_read_status(struct phy_device *phydev);
> +
> /* Clause 45 PHY */
> int genphy_c45_restart_aneg(struct phy_device *phydev);
> int genphy_c45_check_and_restart_aneg(struct phy_device *phydev, bool restart);
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation
[not found] <20190909204906.2191290-1-taoren@fb.com>
2019-09-09 21:56 ` [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation Tao Ren
@ 2019-09-14 14:17 ` Andrew Lunn
2019-09-15 6:15 ` Tao Ren
2019-10-15 17:16 ` Tao Ren
1 sibling, 2 replies; 8+ messages in thread
From: Andrew Lunn @ 2019-09-14 14:17 UTC (permalink / raw)
To: Tao Ren
Cc: Florian Fainelli, Heiner Kallweit, David S . Miller,
Vladimir Oltean, Arun Parameswaran, Justin Chen, netdev,
linux-kernel, openbmc
On Mon, Sep 09, 2019 at 01:49:06PM -0700, Tao Ren wrote:
> From: Heiner Kallweit <hkallweit1@gmail.com>
>
> This patch adds support for clause 37 1000Base-X auto-negotiation.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Tao Ren <taoren@fb.com>
> Tested-by: René van Dorst <opensource@vdorst.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation
2019-09-14 14:17 ` Andrew Lunn
@ 2019-09-15 6:15 ` Tao Ren
2019-10-15 17:16 ` Tao Ren
1 sibling, 0 replies; 8+ messages in thread
From: Tao Ren @ 2019-09-15 6:15 UTC (permalink / raw)
To: Andrew Lunn
Cc: Florian Fainelli, Heiner Kallweit, David S . Miller,
Vladimir Oltean, Arun Parameswaran, Justin Chen, netdev,
linux-kernel, openbmc
On 9/14/19 7:17 AM, Andrew Lunn wrote:
> On Mon, Sep 09, 2019 at 01:49:06PM -0700, Tao Ren wrote:
>> From: Heiner Kallweit <hkallweit1@gmail.com>
>>
>> This patch adds support for clause 37 1000Base-X auto-negotiation.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> Signed-off-by: Tao Ren <taoren@fb.com>
>> Tested-by: René van Dorst <opensource@vdorst.com>
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>
> Andrew
Thanks a lot, Andrew.
Cheers,
Tao
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation
2019-09-14 14:17 ` Andrew Lunn
2019-09-15 6:15 ` Tao Ren
@ 2019-10-15 17:16 ` Tao Ren
2019-10-15 17:20 ` David Miller
1 sibling, 1 reply; 8+ messages in thread
From: Tao Ren @ 2019-10-15 17:16 UTC (permalink / raw)
To: David S . Miller
Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, Vladimir Oltean,
Arun Parameswaran, Justin Chen, netdev, linux-kernel, openbmc
Hi David,
Can you please apply the patch series to net-next tree when you have bandwidth? All the 3 patches are reviewed.
Thanks,
Tao
On 9/14/19 7:17 AM, Andrew Lunn wrote:
> On Mon, Sep 09, 2019 at 01:49:06PM -0700, Tao Ren wrote:
>> From: Heiner Kallweit <hkallweit1@gmail.com>
>>
>> This patch adds support for clause 37 1000Base-X auto-negotiation.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> Signed-off-by: Tao Ren <taoren@fb.com>
>> Tested-by: René van Dorst <opensource@vdorst.com>
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>
> Andrew
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation
2019-10-15 17:16 ` Tao Ren
@ 2019-10-15 17:20 ` David Miller
2019-10-15 17:22 ` Tao Ren
2019-10-15 17:22 ` Florian Fainelli
0 siblings, 2 replies; 8+ messages in thread
From: David Miller @ 2019-10-15 17:20 UTC (permalink / raw)
To: taoren
Cc: andrew, f.fainelli, hkallweit1, olteanv, arun.parameswaran,
justinpopo6, netdev, linux-kernel, openbmc
From: Tao Ren <taoren@fb.com>
Date: Tue, 15 Oct 2019 17:16:26 +0000
> Can you please apply the patch series to net-next tree when you have
> bandwidth? All the 3 patches are reviewed.
If it is not active in patchwork you need to repost.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation
2019-10-15 17:20 ` David Miller
@ 2019-10-15 17:22 ` Tao Ren
2019-10-15 17:22 ` Florian Fainelli
1 sibling, 0 replies; 8+ messages in thread
From: Tao Ren @ 2019-10-15 17:22 UTC (permalink / raw)
To: David Miller
Cc: andrew, f.fainelli, hkallweit1, olteanv, arun.parameswaran,
justinpopo6, netdev, linux-kernel, openbmc
On 10/15/19 10:20 AM, David Miller wrote:
> From: Tao Ren <taoren@fb.com>
> Date: Tue, 15 Oct 2019 17:16:26 +0000
>
>> Can you please apply the patch series to net-next tree when you have
>> bandwidth? All the 3 patches are reviewed.
>
> If it is not active in patchwork you need to repost.
Got it. Let me check and repost soon.
Thanks,
Tao
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation
2019-10-15 17:20 ` David Miller
2019-10-15 17:22 ` Tao Ren
@ 2019-10-15 17:22 ` Florian Fainelli
2019-10-15 17:25 ` Tao Ren
1 sibling, 1 reply; 8+ messages in thread
From: Florian Fainelli @ 2019-10-15 17:22 UTC (permalink / raw)
To: David Miller, taoren
Cc: andrew, hkallweit1, olteanv, arun.parameswaran, justinpopo6,
netdev, linux-kernel, openbmc
On 10/15/19 10:20 AM, David Miller wrote:
> From: Tao Ren <taoren@fb.com>
> Date: Tue, 15 Oct 2019 17:16:26 +0000
>
>> Can you please apply the patch series to net-next tree when you have
>> bandwidth? All the 3 patches are reviewed.
>
> If it is not active in patchwork you need to repost.
>
Tao, can you pick up this series and provide a proper cover letter for
it (git format-patch --cover-letter) that way it can be picked up by David?
--
Florian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation
2019-10-15 17:22 ` Florian Fainelli
@ 2019-10-15 17:25 ` Tao Ren
0 siblings, 0 replies; 8+ messages in thread
From: Tao Ren @ 2019-10-15 17:25 UTC (permalink / raw)
To: Florian Fainelli, David Miller
Cc: andrew, hkallweit1, olteanv, arun.parameswaran, justinpopo6,
netdev, linux-kernel, openbmc
On 10/15/19 10:22 AM, Florian Fainelli wrote:
> On 10/15/19 10:20 AM, David Miller wrote:
>> From: Tao Ren <taoren@fb.com>
>> Date: Tue, 15 Oct 2019 17:16:26 +0000
>>
>>> Can you please apply the patch series to net-next tree when you have
>>> bandwidth? All the 3 patches are reviewed.
>>
>> If it is not active in patchwork you need to repost.
>>
>
> Tao, can you pick up this series and provide a proper cover letter for
> it (git format-patch --cover-letter) that way it can be picked up by David?
Sure. Thank you for the suggestion. Will do it.
Thanks,
Tao
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-10-15 17:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20190909204906.2191290-1-taoren@fb.com>
2019-09-09 21:56 ` [PATCH net-next v8 2/3] net: phy: add support for clause 37 auto-negotiation Tao Ren
2019-09-14 14:17 ` Andrew Lunn
2019-09-15 6:15 ` Tao Ren
2019-10-15 17:16 ` Tao Ren
2019-10-15 17:20 ` David Miller
2019-10-15 17:22 ` Tao Ren
2019-10-15 17:22 ` Florian Fainelli
2019-10-15 17:25 ` Tao Ren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).