Commit 4a459bdc authored by Andrew Lunn's avatar Andrew Lunn Committed by Jakub Kicinski

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: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarMichal Kubecek <mkubecek@suse.cz>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent fc879f72
...@@ -492,6 +492,7 @@ static void phy_abort_cable_test(struct phy_device *phydev) ...@@ -492,6 +492,7 @@ static void phy_abort_cable_test(struct phy_device *phydev)
int phy_start_cable_test(struct phy_device *phydev, int phy_start_cable_test(struct phy_device *phydev,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct net_device *dev = phydev->attached_dev;
int err = -ENOMEM; int err = -ENOMEM;
if (!(phydev->drv && if (!(phydev->drv &&
...@@ -525,8 +526,10 @@ int phy_start_cable_test(struct phy_device *phydev, ...@@ -525,8 +526,10 @@ int phy_start_cable_test(struct phy_device *phydev,
/* Mark the carrier down until the test is complete */ /* Mark the carrier down until the test is complete */
phy_link_down(phydev, true); phy_link_down(phydev, true);
netif_testing_on(dev);
err = phydev->drv->cable_test_start(phydev); err = phydev->drv->cable_test_start(phydev);
if (err) { if (err) {
netif_testing_off(dev);
phy_link_up(phydev); phy_link_up(phydev);
goto out_free; goto out_free;
} }
...@@ -879,6 +882,8 @@ EXPORT_SYMBOL(phy_free_interrupt); ...@@ -879,6 +882,8 @@ EXPORT_SYMBOL(phy_free_interrupt);
*/ */
void phy_stop(struct phy_device *phydev) void phy_stop(struct phy_device *phydev)
{ {
struct net_device *dev = phydev->attached_dev;
if (!phy_is_started(phydev)) { if (!phy_is_started(phydev)) {
WARN(1, "called from state %s\n", WARN(1, "called from state %s\n",
phy_state_to_str(phydev->state)); phy_state_to_str(phydev->state));
...@@ -887,8 +892,10 @@ void phy_stop(struct phy_device *phydev) ...@@ -887,8 +892,10 @@ void phy_stop(struct phy_device *phydev)
mutex_lock(&phydev->lock); mutex_lock(&phydev->lock);
if (phydev->state == PHY_CABLETEST) if (phydev->state == PHY_CABLETEST) {
phy_abort_cable_test(phydev); phy_abort_cable_test(phydev);
netif_testing_off(dev);
}
if (phydev->sfp_bus) if (phydev->sfp_bus)
sfp_upstream_stop(phydev->sfp_bus); sfp_upstream_stop(phydev->sfp_bus);
...@@ -950,6 +957,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -950,6 +957,7 @@ void phy_state_machine(struct work_struct *work)
struct delayed_work *dwork = to_delayed_work(work); struct delayed_work *dwork = to_delayed_work(work);
struct phy_device *phydev = struct phy_device *phydev =
container_of(dwork, struct phy_device, state_queue); container_of(dwork, struct phy_device, state_queue);
struct net_device *dev = phydev->attached_dev;
bool needs_aneg = false, do_suspend = false; bool needs_aneg = false, do_suspend = false;
enum phy_state old_state; enum phy_state old_state;
bool finished = false; bool finished = false;
...@@ -975,6 +983,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -975,6 +983,7 @@ void phy_state_machine(struct work_struct *work)
err = phydev->drv->cable_test_get_status(phydev, &finished); err = phydev->drv->cable_test_get_status(phydev, &finished);
if (err) { if (err) {
phy_abort_cable_test(phydev); phy_abort_cable_test(phydev);
netif_testing_off(dev);
needs_aneg = true; needs_aneg = true;
phydev->state = PHY_UP; phydev->state = PHY_UP;
break; break;
...@@ -982,6 +991,7 @@ void phy_state_machine(struct work_struct *work) ...@@ -982,6 +991,7 @@ void phy_state_machine(struct work_struct *work)
if (finished) { if (finished) {
ethnl_cable_test_finished(phydev); ethnl_cable_test_finished(phydev);
netif_testing_off(dev);
needs_aneg = true; needs_aneg = true;
phydev->state = PHY_UP; phydev->state = PHY_UP;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment