net: phy: add and use genphy_c45_an_config_an
Subsystems (4)
Heiner Kallweit
maintainerv3 cover net: phy: add and use genphy_c45_an_config_an
This series adds genphy_c45_an_config_an() and uses it in the marvell10g diver. In addition patch 4 aligns the aneg configuration with what is done in genphy_config_aneg().
v2:
- in patch 2 changed function name to genphy_c45_an_config_aneg
- in patch 3 add a comment regarding 1000BaseT vendor registers
v3:
- rebase patch 3
Andrew Lunn (2):
net: phy: add genphy_c45_an_config_an
net: phy: marvell10g: use genphy_c45_an_config_aneg
Heiner Kallweit (2):
net: phy: add helper linkmode_adv_to_mii_10gbt_adv_t
net: phy: marvell10g: check for newly set aneg
drivers/net/phy/marvell10g.c | 31 ++++++++++--------------- drivers/net/phy/phy-c45.c | 44 ++++++++++++++++++++++++++++++++++++ include/linux/mdio.h | 25 ++++++++++++++++++++ include/linux/phy.h | 1 + 4 files changed, 82 insertions(+), 19 deletions(-)
Signature · 1 line
2.20.1
Heiner Kallweit
maintainerPATCH v3 1/4 net: phy: add helper linkmode_adv_to_mii_10gbt_adv_t
Add a helper linkmode_adv_to_mii_10gbt_adv_t(), similar to linkmode_adv_to_mii_adv_t.
--- include/linux/mdio.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
include/linux/mdio.h +25 -0
@@ -280,6 +280,31 @@ static inline void mii_10gbt_stat_mod_linkmode_lpa_t(unsigned long *advertising, advertising, lpa & MDIO_AN_10GBT_STAT_LP10G); } +/** +* linkmode_adv_to_mii_10gbt_adv_t +* @advertising: the linkmode advertisement settings +* +* A small helper function that translates linkmode advertisement +* settings to phy autonegotiation advertisements for the C45 +* 10GBASE-T AN CONTROL (7.32) register. +*/ +static inline u32 linkmode_adv_to_mii_10gbt_adv_t (unsigned long *advertising) +{ +u32 result =0 ; + +if (linkmode_test_bit (ETHTOOL_LINK_MODE_2500baseT_Full_BIT, + advertising)) + result |=MDIO_AN_10GBT_CTRL_ADV2_5G ; +if (linkmode_test_bit (ETHTOOL_LINK_MODE_5000baseT_Full_BIT, + advertising)) + result |=MDIO_AN_10GBT_CTRL_ADV5G ; +if (linkmode_test_bit (ETHTOOL_LINK_MODE_10000baseT_Full_BIT, + advertising)) + result |=MDIO_AN_10GBT_CTRL_ADV10G ; + +return result; +} +int __mdiobus_read (struct mii_bus *bus,int addr,u32 regnum);int __mdiobus_write (struct mii_bus *bus,int addr,u32 regnum,u16 val);
Signature · 1 line
2.20.1
Heiner Kallweit
maintainerPATCH v3 2/4 net: phy: add genphy_c45_an_config_aneg
In reply to Heiner KallweitFrom: Andrew Lunn <[email protected]>
C45 configuration of 10/100 and multi-giga bit auto negotiation advertisement is standardized. Configuration of 1000Base-T however appears to be vendor specific. Move the generic code out of the Marvell driver into the common phy-c45.c file.
v2:
- change function name to genphy_c45_an_config_aneg
--- drivers/net/phy/phy-c45.c | 44 +++++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 1 + 2 files changed, 45 insertions(+)
drivers/net/phy/phy-c45.c +44 -0
@@ -78,6 +78,50 @@ int genphy_c45_pma_setup_forced(struct phy_device *phydev) }EXPORT_SYMBOL_GPL (genphy_c45_pma_setup_forced); +/** +* genphy_c45_an_config_aneg - configure advertisement registers +* @phydev: target phy_device struct +* +* Configure advertisement registers based on modes set in phydev->advertising +* +* Returns negative errno code on failure, 0 if advertisement didn't change, +* or 1 if advertised modes changed. +*/ +int genphy_c45_an_config_aneg (struct phy_device *phydev) +{ +int changed =0 , ret; +u32 adv; + +linkmode_and (phydev->advertising, phydev->advertising, + phydev->supported); + + adv =linkmode_adv_to_mii_adv_t (phydev->advertising); + + ret =phy_modify_mmd (phydev,MDIO_MMD_AN ,MDIO_AN_ADVERTISE , +ADVERTISE_ALL |ADVERTISE_100BASE4 | +ADVERTISE_PAUSE_CAP |ADVERTISE_PAUSE_ASYM , + adv); +if (ret <0 ) +return ret; +if (ret >0 ) + changed =1 ; + + adv =linkmode_adv_to_mii_10gbt_adv_t (phydev->advertising); + + ret =phy_modify_mmd (phydev,MDIO_MMD_AN ,MDIO_AN_10GBT_CTRL , +MDIO_AN_10GBT_CTRL_ADV10G | +MDIO_AN_10GBT_CTRL_ADV5G | +MDIO_AN_10GBT_CTRL_ADV2_5G , + adv); +if (ret <0 ) +return ret; +if (ret >0 ) + changed =1 ; + +return changed; +} +EXPORT_SYMBOL_GPL (genphy_c45_an_config_aneg); +/** * genphy_c45_an_disable_aneg - disable auto-negotiation * @phydev: target phy_device struct
include/linux/phy.h +1 -0
@@ -1101,6 +1101,7 @@ int genphy_c45_read_link(struct phy_device *phydev);int genphy_c45_read_lpa (struct phy_device *phydev);int genphy_c45_read_pma (struct phy_device *phydev);int genphy_c45_pma_setup_forced (struct phy_device *phydev); +int genphy_c45_an_config_aneg (struct phy_device *phydev);int genphy_c45_an_disable_aneg (struct phy_device *phydev);int genphy_c45_read_mdix (struct phy_device *phydev);int genphy_c45_pma_read_abilities (struct phy_device *phydev);
Signature · 1 line
2.20.1
Heiner Kallweit
maintainerPATCH v3 3/4 net: phy: marvell10g: use genphy_c45_an_config_aneg
In reply to Heiner KallweitFrom: Andrew Lunn <[email protected]>
Use new function genphy_c45_config_aneg() in mv3310_config_aneg().
v2:
- add a comment regarding 1000BaseT vendor registers v3:
- rebased
--- drivers/net/phy/marvell10g.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-)
drivers/net/phy/marvell10g.c +4 -21
@@ -274,18 +274,15 @@ static int mv3310_config_aneg(struct phy_device *phydev)if (phydev->autoneg ==AUTONEG_DISABLE )return genphy_c45_pma_setup_forced (phydev); -linkmode_and (phydev->advertising, phydev->advertising, - phydev->supported); - - ret =phy_modify_mmd_changed (phydev,MDIO_MMD_AN ,MDIO_AN_ADVERTISE , -ADVERTISE_ALL |ADVERTISE_100BASE4 | -ADVERTISE_PAUSE_CAP |ADVERTISE_PAUSE_ASYM , -linkmode_adv_to_mii_adv_t (phydev->advertising)); + ret =genphy_c45_an_config_aneg (phydev);if (ret <0 )return ret;if (ret >0 ) changed = true; +/* Clause 45 has no standardized support for 1000BaseT, therefore +* use vendor registers for this mode. +*/ reg =linkmode_adv_to_mii_ctrl1000_t (phydev->advertising); ret =phy_modify_mmd_changed (phydev,MDIO_MMD_AN ,MV_AN_CTRL1000 ,ADVERTISE_1000FULL |ADVERTISE_1000HALF , reg);
@@ -294,20 +291,6 @@ static int mv3310_config_aneg(struct phy_device *phydev)if (ret >0 ) changed = true; -/* 10G control register */ -if (linkmode_test_bit (ETHTOOL_LINK_MODE_10000baseT_Full_BIT, - phydev->advertising)) - reg =MDIO_AN_10GBT_CTRL_ADV10G ; -else - reg =0 ; - - ret =phy_modify_mmd_changed (phydev,MDIO_MMD_AN ,MDIO_AN_10GBT_CTRL , -MDIO_AN_10GBT_CTRL_ADV10G , reg); -if (ret <0 ) -return ret; -if (ret >0 ) - changed = true; -if (changed) ret =genphy_c45_restart_aneg (phydev);
Signature · 1 line
2.20.1
Heiner Kallweit
maintainerPATCH v3 4/4 net: phy: marvell10g: check for newly set aneg
In reply to Heiner KallweitEven if the advertisement registers content didn't change, we may have just switched to aneg, and therefore have to trigger an aneg restart. This matches the behavior of genphy_config_aneg().
--- drivers/net/phy/marvell10g.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/phy/marvell10g.c +10 -0
@@ -296,6 +296,16 @@ static int mv3310_config_aneg(struct phy_device *phydev)if (ret >0 ) changed = true; +if (!changed) { +/* Configure and restart aneg if it wasn't set before */ + ret =phy_read_mmd (phydev,MDIO_MMD_AN ,MDIO_CTRL1 ); +if (ret <0 ) +return ret; + +if (!(ret &MDIO_AN_CTRL1_ENABLE )) + changed =1 ; + } +if (changed) ret =genphy_c45_restart_aneg (phydev);
Signature · 1 line
2.20.1
David Miller
maintainerFrom: Heiner Kallweit <[email protected]>
Date: Sun, 17 Feb 2019 10:27:43 +0100
Quoted 10 lines
This series adds
genphy_c45_an_config_an()and uses it in the marvell10g diver. In addition patch 4 aligns the aneg configuration with what is done ingenphy_config_aneg().v2:
- in patch 2 changed function name togenphy_c45_an_config_aneg
- in patch 3 add a comment regarding 1000BaseT vendor registersv3:
- rebase patch 3
Series applied.
For patches #1 and #4 there was some fuzz which I resolved.
Did you really rebase this series? :-)
Heiner Kallweit
maintainerQuoted 11 lines · David Miller
From: Heiner Kallweit <[email protected]>
Date: Sun, 17 Feb 2019 10:27:43 +0100Quoted 8 lines
This series adds
genphy_c45_an_config_an()and uses it in the marvell10g diver. In addition patch 4 aligns the aneg configuration with what is done ingenphy_config_aneg().v2:
- in patch 2 changed function name togenphy_c45_an_config_aneg
- in patch 3 add a comment regarding 1000BaseT vendor registers
Quoted 9 lines
Quoted 2 lines
v3:
- rebase patch 3Series applied.
For patches #1 and #4 there was some fuzz which I resolved.
Did you really rebase this series? :-)
I swear .. I think reason is that there are further patches under review dealing with the same file(s).