* [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an
@ 2019-02-17 8:35 Heiner Kallweit
2019-02-17 8:36 ` [PATCH net-next v2 1/4] net: phy: add helper linkmode_adv_to_mii_10gbt_adv_t Heiner Kallweit
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-17 8:35 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller,
Russell King - ARM Linux
Cc: netdev@vger.kernel.org
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
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(-)
--
2.20.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v2 1/4] net: phy: add helper linkmode_adv_to_mii_10gbt_adv_t
2019-02-17 8:35 [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an Heiner Kallweit
@ 2019-02-17 8:36 ` Heiner Kallweit
2019-02-17 8:37 ` [PATCH net-next v2 2/4] net: phy: add genphy_c45_an_config_aneg Heiner Kallweit
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-17 8:36 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller,
Russell King - ARM Linux
Cc: netdev@vger.kernel.org
Add a helper linkmode_adv_to_mii_10gbt_adv_t(), similar to
linkmode_adv_to_mii_adv_t.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
include/linux/mdio.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 5b872c45f..5a65f32d8 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -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);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 2/4] net: phy: add genphy_c45_an_config_aneg
2019-02-17 8:35 [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an Heiner Kallweit
2019-02-17 8:36 ` [PATCH net-next v2 1/4] net: phy: add helper linkmode_adv_to_mii_10gbt_adv_t Heiner Kallweit
@ 2019-02-17 8:37 ` Heiner Kallweit
2019-02-17 8:39 ` [PATCH net-next v2 3/4] net: phy: marvell10g: use genphy_c45_an_config_aneg Heiner Kallweit
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-17 8:37 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller,
Russell King - ARM Linux
Cc: netdev@vger.kernel.org
From: Andrew Lunn <andrew@lunn.ch>
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
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
[hkallweit1@gmail.com: use new helper linkmode_adv_to_mii_10gbt_adv_t and split patch]
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/phy-c45.c | 44 +++++++++++++++++++++++++++++++++++++++
include/linux/phy.h | 1 +
2 files changed, 45 insertions(+)
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 98a04d4cd..16636d49b 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -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
diff --git a/include/linux/phy.h b/include/linux/phy.h
index bf1070c2a..3db507e68 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -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);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 3/4] net: phy: marvell10g: use genphy_c45_an_config_aneg
2019-02-17 8:35 [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an Heiner Kallweit
2019-02-17 8:36 ` [PATCH net-next v2 1/4] net: phy: add helper linkmode_adv_to_mii_10gbt_adv_t Heiner Kallweit
2019-02-17 8:37 ` [PATCH net-next v2 2/4] net: phy: add genphy_c45_an_config_aneg Heiner Kallweit
@ 2019-02-17 8:39 ` Heiner Kallweit
2019-02-17 8:40 ` [PATCH net-next v2 4/4] net: phy: marvell10g: check for newly set aneg Heiner Kallweit
2019-02-17 9:26 ` [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an Heiner Kallweit
4 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-17 8:39 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller,
Russell King - ARM Linux
Cc: netdev@vger.kernel.org
From: Andrew Lunn <andrew@lunn.ch>
Use new function genphy_c45_config_aneg() in mv3310_config_aneg().
v2:
- add a comment regarding 1000BaseT vendor registers
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
[hkallweit1@gmail.com: patch splitted]
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/marvell10g.c | 25 ++++---------------------
1 file changed, 4 insertions(+), 21 deletions(-)
diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index 496805c0d..895574083 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -279,18 +279,15 @@ static int mv3310_config_aneg(struct phy_device *phydev)
return genphy_c45_an_disable_aneg(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);
@@ -299,20 +296,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);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v2 4/4] net: phy: marvell10g: check for newly set aneg
2019-02-17 8:35 [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an Heiner Kallweit
` (2 preceding siblings ...)
2019-02-17 8:39 ` [PATCH net-next v2 3/4] net: phy: marvell10g: use genphy_c45_an_config_aneg Heiner Kallweit
@ 2019-02-17 8:40 ` Heiner Kallweit
2019-02-17 9:26 ` [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an Heiner Kallweit
4 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-17 8:40 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller,
Russell King - ARM Linux
Cc: netdev@vger.kernel.org
Even 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().
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/marvell10g.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index 895574083..b83eb19cf 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -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);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an
2019-02-17 8:35 [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an Heiner Kallweit
` (3 preceding siblings ...)
2019-02-17 8:40 ` [PATCH net-next v2 4/4] net: phy: marvell10g: check for newly set aneg Heiner Kallweit
@ 2019-02-17 9:26 ` Heiner Kallweit
4 siblings, 0 replies; 6+ messages in thread
From: Heiner Kallweit @ 2019-02-17 9:26 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller,
Russell King - ARM Linux
Cc: netdev@vger.kernel.org
On 17.02.2019 09:35, Heiner Kallweit wrote:
> 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
>
> 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(-)
>
Forgot to rebase patch 3 what's needed due to another pending patch.
Will send a v3.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-02-17 9:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-17 8:35 [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an Heiner Kallweit
2019-02-17 8:36 ` [PATCH net-next v2 1/4] net: phy: add helper linkmode_adv_to_mii_10gbt_adv_t Heiner Kallweit
2019-02-17 8:37 ` [PATCH net-next v2 2/4] net: phy: add genphy_c45_an_config_aneg Heiner Kallweit
2019-02-17 8:39 ` [PATCH net-next v2 3/4] net: phy: marvell10g: use genphy_c45_an_config_aneg Heiner Kallweit
2019-02-17 8:40 ` [PATCH net-next v2 4/4] net: phy: marvell10g: check for newly set aneg Heiner Kallweit
2019-02-17 9:26 ` [PATCH net-next v2 0/4] net: phy: add and use genphy_c45_an_config_an Heiner Kallweit
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).