Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1522961 > unrolled thread

[PATCH 01/15] net: phy: Add phy_ethtool_nway_reset

Started byFlorian Fainelli <f.fainelli@gmail.com>
First post2016-11-15 19:10 +0100
Last post2016-11-17 11:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 01/15] net: phy: Add phy_ethtool_nway_reset Florian Fainelli <f.fainelli@gmail.com> - 2016-11-15 19:10 +0100
    Re: [PATCH 01/15] net: phy: Add phy_ethtool_nway_reset khalasa@piap.pl (Krzysztof Hałasa) - 2016-11-17 11:10 +0100

#1522961 — [PATCH 01/15] net: phy: Add phy_ethtool_nway_reset

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2016-11-15 19:10 +0100
Subject[PATCH 01/15] net: phy: Add phy_ethtool_nway_reset
Message-ID<sDQlb-8ps-13@gated-at.bofh.it>
This function just calls into genphy_restart_aneg() to perform an
autonegotation restart.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/phy.c | 11 +++++++++++
 include/linux/phy.h   |  1 +
 2 files changed, 12 insertions(+)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index e6dd222fddb1..73adbaa9ac86 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1441,3 +1441,14 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev,
 	return phy_ethtool_ksettings_set(phydev, cmd);
 }
 EXPORT_SYMBOL(phy_ethtool_set_link_ksettings);
+
+int phy_ethtool_nway_reset(struct net_device *ndev)
+{
+	struct phy_device *phydev = ndev->phydev;
+
+	if (!phydev)
+		return -ENODEV;
+
+	return genphy_restart_aneg(phydev);
+}
+EXPORT_SYMBOL(phy_ethtool_nway_reset);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 9880d73a2c3d..b9bd3b4f4ea1 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -860,6 +860,7 @@ int phy_ethtool_get_link_ksettings(struct net_device *ndev,
 				   struct ethtool_link_ksettings *cmd);
 int phy_ethtool_set_link_ksettings(struct net_device *ndev,
 				   const struct ethtool_link_ksettings *cmd);
+int phy_ethtool_nway_reset(struct net_device *ndev);
 
 int __init mdio_bus_init(void);
 void mdio_bus_exit(void);
-- 
2.9.3

[toc] | [next] | [standalone]


#1524228

Fromkhalasa@piap.pl (Krzysztof Hałasa)
Date2016-11-17 11:10 +0100
Message-ID<sErNN-7If-47@gated-at.bofh.it>
In reply to#1522961
Hi,

Florian Fainelli <f.fainelli@gmail.com> writes:

> This function just calls into genphy_restart_aneg() to perform an
> autonegotation restart.
>
> +int phy_ethtool_nway_reset(struct net_device *ndev)
> +{
> +	struct phy_device *phydev = ndev->phydev;
> +
> +	if (!phydev)
> +		return -ENODEV;
> +
> +	return genphy_restart_aneg(phydev);
> +}

and then you're using this function as .nway_reset of all netdev drivers
in question.

genphy_restart_aneg() deals directly with MII BMCR register:

int genphy_restart_aneg(struct phy_device *phydev)
{
        int ctl = phy_read(phydev, MII_BMCR);

        if (ctl < 0)
                return ctl;

        ctl |= BMCR_ANENABLE | BMCR_ANRESTART;

        /* Don't isolate the PHY if we're negotiating */
        ctl &= ~BMCR_ISOLATE;

        return phy_write(phydev, MII_BMCR, ctl);
}

Will the above work if the PHY is something special, e.g. a "fixed"
connection, or some kind of fiber trx etc? Normally, the PHY driver
could provide its own config_aneg().
-- 
Krzysztof Halasa

Industrial Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web