[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190612160534.23533-14-andrew@lunn.ch>
Date: Wed, 12 Jun 2019 18:05:34 +0200
From: Andrew Lunn <andrew@...n.ch>
To: netdev <netdev@...r.kernel.org>
Cc: Florian Fainelli <f.fainelli@...il.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Raju.Lakkaraju@...rochip.com, Andrew Lunn <andrew@...n.ch>
Subject: [PATCH RFC 13/13] net: phy: Put interface into oper testing during cable test
Since running a cable test is disruptive, put the interface into
operative state testing while the test is running.
Signed-off-by: Andrew Lunn <andrew@...n.ch>
---
drivers/net/phy/phy.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 9a210927aec0..f3fa73974af3 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -585,6 +585,7 @@ int phy_start_cable_test(struct phy_device *phydev,
struct netlink_ext_ack *extack, u32 seq,
int options)
{
+ struct net_device *dev = phydev->attached_dev;
int err = -ENOMEM;
int ret;
@@ -627,8 +628,10 @@ int phy_start_cable_test(struct phy_device *phydev,
/* Mark the carrier down until the test is complete */
phy_link_down(phydev, true);
+ netif_testing_on(dev);
err = phydev->drv->cable_test_start(phydev, options);
if (err) {
+ netif_testing_off(dev);
phy_link_up(phydev);
goto out_free;
}
@@ -988,6 +991,8 @@ EXPORT_SYMBOL(phy_request_interrupt);
*/
void phy_stop(struct phy_device *phydev)
{
+ struct net_device *dev = phydev->attached_dev;
+
if (!phy_is_started(phydev)) {
WARN(1, "called from state %s\n",
phy_state_to_str(phydev->state));
@@ -996,8 +1001,10 @@ void phy_stop(struct phy_device *phydev)
mutex_lock(&phydev->lock);
- if (phydev->state == PHY_CABLETEST)
+ if (phydev->state == PHY_CABLETEST) {
phy_cable_test_abort(phydev);
+ netif_testing_off(dev);
+ };
if (phy_interrupt_is_valid(phydev))
phy_disable_interrupts(phydev);
@@ -1068,6 +1075,7 @@ void phy_state_machine(struct work_struct *work)
struct delayed_work *dwork = to_delayed_work(work);
struct phy_device *phydev =
container_of(dwork, struct phy_device, state_queue);
+ struct net_device *dev = phydev->attached_dev;
bool needs_aneg = false, do_suspend = false;
enum phy_state old_state;
bool finished = false;
@@ -1108,6 +1116,7 @@ void phy_state_machine(struct work_struct *work)
err = phydev->drv->cable_test_get_status(phydev, &finished);
if (err) {
phy_cable_test_abort(phydev);
+ netif_testing_off(dev);
needs_aneg = true;
phydev->state = PHY_UP;
break;
@@ -1115,6 +1124,7 @@ void phy_state_machine(struct work_struct *work)
if (finished) {
phy_cable_test_finished(phydev);
+ netif_testing_off(dev);
needs_aneg = true;
phydev->state = PHY_UP;
}
--
2.20.1
Powered by blists - more mailing lists