[source] lantiq: fix xrx200 switch carrier state

LEDE Commits lede-commits at lists.infradead.org
Sat Sep 9 03:24:41 PDT 2017


mkresin pushed a commit to source.git, branch master:
https://git.lede-project.org/47be42c3476ee8b96f87688dc8f6571191e926ec

commit 47be42c3476ee8b96f87688dc8f6571191e926ec
Author: Mathias Kresin <dev at kresin.me>
AuthorDate: Wed Aug 9 18:43:56 2017 +0200

    lantiq: fix xrx200 switch carrier state
    
    In conditions where none of the switch ports is connected during boot,
    the priv->port[i].link != priv->port[i].phydev->link condition is false
    since both link values are equal (false). The carrier of the switch
    netdev is never set to off and the link state reported by ip is UNKNOWN.
    
    Turn the carrier off if none of the switch ports has a link, regardless
    whether something has been changed. Add a check for a carrier to
    prevent unnecessary calls to netif_carrier_off() if the carrier is
    already off.
    
    Based on a patch send by Martin Schiller.
    
    Signed-off-by: Mathias Kresin <dev at kresin.me>
---
 .../lantiq/patches-4.9/0025-NET-MIPS-lantiq-adds-xrx200-net.patch  | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/target/linux/lantiq/patches-4.9/0025-NET-MIPS-lantiq-adds-xrx200-net.patch b/target/linux/lantiq/patches-4.9/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
index 8711764..5224e7a 100644
--- a/target/linux/lantiq/patches-4.9/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
+++ b/target/linux/lantiq/patches-4.9/0025-NET-MIPS-lantiq-adds-xrx200-net.patch
@@ -209,7 +209,7 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +};
 --- /dev/null
 +++ b/drivers/net/ethernet/lantiq_xrx200.c
-@@ -0,0 +1,1852 @@
+@@ -0,0 +1,1851 @@
 +/*
 + *   This program is free software; you can redistribute it and/or modify it
 + *   under the terms of the GNU General Public License version 2 as published
@@ -1460,7 +1460,7 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +static void xrx200_mdio_link(struct net_device *dev)
 +{
 +	struct xrx200_priv *priv = netdev_priv(dev);
-+	bool changed = false, link = false;
++	bool link = false;
 +	int i;
 +
 +	for (i = 0; i < priv->num_port; i++) {
@@ -1471,7 +1471,6 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +			link = true;
 +
 +		if (priv->port[i].link != priv->port[i].phydev->link) {
-+			changed = true;
 +			xrx200_gmac_update(&priv->port[i]);
 +			priv->port[i].link = priv->port[i].phydev->link;
 +			netdev_info(dev, "port %d %s link\n",
@@ -1479,7 +1478,7 @@ Subject: [PATCH 25/36] NET: MIPS: lantiq: adds xrx200-net
 +				(priv->port[i].link)?("got"):("lost"));
 +		}
 +	}
-+	if (changed && !link)
++	if (netif_carrier_ok(dev) && !link)
 +		netif_carrier_off(dev);
 +}
 +



More information about the lede-commits mailing list