2018-12-21 18:16:22

by Maxim Uvarov

[permalink] [raw]
Subject: [PATCH] usbnet: smsc95xx: allow to down ethernet link

allow ifconfig ethX to down ethernet link. Ethernet
part of chip is switched to power down more and on
ifconfig up driver does soft reset and restores it's
state.

Signed-off-by: Max Uvarov <[email protected]>
---
drivers/net/usb/smsc95xx.c | 34 +++++++++++++++++++++++++++++++++-
drivers/net/usb/smsc95xx.h | 5 +++++
2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 41e283f3eeb9..e72b038cfb79 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1142,9 +1142,41 @@ static int smsc95xx_reset(struct usbnet *dev)
return 0;
}

+static int smsc95xx_lan_power_down(struct net_device *net)
+{
+ struct usbnet *dev = netdev_priv(net);
+ struct mii_if_info *mii = &dev->mii;
+ int ret;
+
+ ret = smsc95xx_mdio_read_nopm(net, mii->phy_id, SMSC95XX_PHY_BASIC);
+ if (ret < 0)
+ return ret;
+ ret &= ~SMSC95XX_PHY_BASIC_BIT_AUTONEG; /* disable autoneg */
+ smsc95xx_mdio_write_nopm(net, mii->phy_id, SMSC95XX_PHY_BASIC, ret);
+
+ ret = smsc95xx_mdio_read_nopm(net, mii->phy_id, SMSC95XX_PHY_BASIC);
+ if (ret < 0)
+ return ret;
+ ret |= SMSC95XX_PHY_BASIC_BIT_POWER_DOWN; /* enable power down */
+ smsc95xx_mdio_write_nopm(net, mii->phy_id, SMSC95XX_PHY_BASIC, ret);
+
+ return 0;
+}
+
+static int smsc95xx_stop(struct net_device *net)
+{
+ int ret;
+
+ ret = smsc95xx_lan_power_down(net);
+ if (ret)
+ netdev_err(net, "err switch to power down mode\n");
+
+ return usbnet_stop(net);
+}
+
static const struct net_device_ops smsc95xx_netdev_ops = {
.ndo_open = usbnet_open,
- .ndo_stop = usbnet_stop,
+ .ndo_stop = smsc95xx_stop,
.ndo_start_xmit = usbnet_start_xmit,
.ndo_tx_timeout = usbnet_tx_timeout,
.ndo_change_mtu = usbnet_change_mtu,
diff --git a/drivers/net/usb/smsc95xx.h b/drivers/net/usb/smsc95xx.h
index 526faa0c44e6..547e8053feba 100644
--- a/drivers/net/usb/smsc95xx.h
+++ b/drivers/net/usb/smsc95xx.h
@@ -47,6 +47,11 @@
#define RX_STS_DB_ (0x00000004) /* Dribbling */
#define RX_STS_CRC_ (0x00000002) /* CRC Error */

+/* Basic Control Register */
+#define SMSC95XX_PHY_BASIC (0x0)
+#define SMSC95XX_PHY_BASIC_BIT_AUTONEG BIT(12)
+#define SMSC95XX_PHY_BASIC_BIT_POWER_DOWN BIT(11)
+
/* SCSRs */
#define ID_REV (0x00)
#define ID_REV_CHIP_ID_MASK_ (0xFFFF0000)
--
2.17.1



2019-01-03 16:52:11

by RaghuramChary.Jallipalli

[permalink] [raw]
Subject: RE: [PATCH] usbnet: smsc95xx: allow to down ethernet link

> allow ifconfig ethX to down ethernet link. Ethernet part of chip is switched to
> power down more and on ifconfig up driver does soft reset and restores it's
> state.
>
Thanks for the patch.
If I understand the issue correctly, the ethernet link is not going down in power down mode? Pls clarify.
Does these changes be applied to smsc75xx driver as well??

Thanks,
-Raghu



2019-01-04 21:25:51

by Maxim Uvarov

[permalink] [raw]
Subject: Re: [PATCH] usbnet: smsc95xx: allow to down ethernet link

чт, 3 янв. 2019 г. в 16:19, <[email protected]>:
>
> > allow ifconfig ethX to down ethernet link. Ethernet part of chip is switched to
> > power down more and on ifconfig up driver does soft reset and restores it's
> > state.
> >
> Thanks for the patch.
> If I understand the issue correctly, the ethernet link is not going down in power down mode? Pls clarify.

Issue was that if you down interface with ifconfig eth dow, then
ethtool showed that interface is down. But actually pairing ethernet
link is still up.
Later if ifconfig eth up is called then soft reset is called and
pairing ethernet link when down and up. So to down ethernet link I
just followed spec
a) disable autoneg b) enable powerdown bit.

> Does these changes be applied to smsc75xx driver as well??
>
Might be if they have the same sequence for powerdown ethernet part.

Best regards,
Max.


> Thanks,
> -Raghu
>
>