ep93xx_eth PHY problems
Subsystems (2)
Hello,
I was having problems with the ep93xx_eth driver: apparently the PHY auto-negotiated "100/full" with the switch, but the driver didn't care about it (or is it the other way round?). This led to lots of packets being dropped under load. Anyway, the patch that was posted last november (http://marc.info/?l=linux-netdev&m=119520642207001&w=4)
helped.
Now I'm having different problems: When auto-negotiation is enabled, it sometimes randomly changes the link state:
PHY: 0:01 - Link is Down
PHY: 0:01 - Link is Up - 100/Full
PHY: 0:01 - Link is Up - 100/Half
PHY: 0:01 - Link is Up - 100/Full
PHY: 0:01 - Link is Up - 10/Half
PHY: 0:01 - Link is Up - 100/Full
It could be related to some kind of error handling - often, when this
happens, our test (a simple RFC 862 UDP echo server, see [1]) loses packets, but the message seems to appear only after the test fails.
If I disable auto-negotiation with ethtool, it first changes to the mode I choose, but seconds later changes to "1000/Full":
PHY: 0:01 - Link is Up - 100/Full
PHY: 0:01 - Link is Up - 1000/Full
This is obviously impossible, and while it mostly works, it seems to confuse something (PHY? MAC? driver?), as there seem to be more dropped packets than with the Cirrus 2.4 driver (on a TS-7260 with the default TS-Linux).
Maybe some error condition isn't handled properly, causing both the packet loss and the PHY state change? Of course, I'm just speculating and it might be something entirely different.
Any ideas?
Signature · 3 lines
Oliver [1] http://murli.34sp.com/o/ep93xx-eth/echo/
Am Tue, 04 Mar 2008 14:02:15 +0100
schrieb Oliver Martin <[email protected]>:
Quoted 7 lines
Now I'm having different problems: When auto-negotiation is enabled, it sometimes randomly changes the link state:
PHY: 0:01 - Link is Down
PHY: 0:01 - Link is Up - 100/Full
I've found at least one part of the problem. The MDIO clock divisor wasn't set again after the reset in ep93xx_start_hw. It was left at the default, resulting in a 12.5 MHz clock, which the PHY (Micrel KSZ8721BL) didn't like too much. Calling ep93xx_mdio_reset after the reset fixed it, the link is now perfectly stable in auto-negotiation mode.
There still seems to be another bug with auto-negotiation disabled: It doesn't switch to 1000 Mbps any more, but most times it doesn't stay in the intended configuration either. I haven't done any extensive testing of this yet, though.
drivers/net/arm/ep93xx_eth.c renamed from drivers/net/arm/ep93xx_eth.c.orig +19 -16
@@ -535,6 +535,22 @@ err:return 1 ; } +static int ep93xx_mdio_reset (struct mii_bus *bus) +{ +struct ep93xx_priv *ep = bus->priv; + +u32 selfctl =rdl (ep,REG_SELFCTL ); + + selfctl &= ~(REG_SELFCTL_MDCDIV_MSK |REG_SELFCTL_PSPRS ); + + selfctl |= (ep->mdc_divisor -1 ) <<REG_SELFCTL_MDCDIV_OFS ; + selfctl |=REG_SELFCTL_PSPRS ; + +wrl (ep,REG_SELFCTL , selfctl); + +return 0 ; +} +static int ep93xx_start_hw (struct net_device *dev) {struct ep93xx_priv *ep =netdev_priv (dev);
@@ -553,6 +569,9 @@ static int ep93xx_start_hw(struct net_dereturn 1 ; } +/* The reset cleared REG_SELFCTL, so set the MDC divisor again */ +ep93xx_mdio_reset (&ep->mii_bus); +/* Receive descriptor ring. */ addr = ep->descs_dma_addr + offsetof(struct ep93xx_descs , rdesc);wrl (ep,REG_RXDQBADD , addr);
@@ -776,22 +795,6 @@ static int ep93xx_mdio_write(struct mii_return 0 ; } -static int ep93xx_mdio_reset (struct mii_bus *bus) -{ -struct ep93xx_priv *ep = bus->priv; - -u32 selfctl =rdl (ep,REG_SELFCTL ); - - selfctl &= ~(REG_SELFCTL_MDCDIV_MSK |REG_SELFCTL_PSPRS ); - - selfctl |= (ep->mdc_divisor -1 ) <<REG_SELFCTL_MDCDIV_OFS ; - selfctl |=REG_SELFCTL_PSPRS ; - -wrl (ep,REG_SELFCTL , selfctl); - -return 0 ; -} -static void ep93xx_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info) {
Quoted 15 lines · Oliver Martin
Am Tue, 04 Mar 2008 14:02:15 +0100
schrieb Oliver Martin <[email protected]>:Quoted 6 lines
Now I'm having different problems: When auto-negotiation is enabled, it sometimes randomly changes the link state:
PHY: 0:01 - Link is Down
PHY: 0:01 - Link is Up - 100/FullI've found at least one part of the problem. The MDIO clock divisor wasn't set again after the reset in
ep93xx_start_hw. It was left at the default, resulting in a 12.5 MHz clock, which the PHY (Micrel KSZ8721BL) didn't like too much. Callingep93xx_mdio_resetafter the reset fixed it, the link is now perfectly stable in auto-negotiation mode.
Quoted 6 lines
There still seems to be another bug with auto-negotiation disabled: It doesn't switch to 1000 Mbps any more, but most times it doesn't stay in the intended configuration either. I haven't done any extensive testing of this yet, though.
Signed-off-by Oliver Martin <[email protected]>
ACKs from Lennert, others?
I don't know enough about the hardware to say...
Seems straightforward to me?
2.6.25 or 2.6.26 material?
Any more testing results?
Am Wed, 26 Mar 2008 00:42:32 -0400 schrieb Jeff Garzik:
Quoted 8 lines
ACKs from Lennert, others?
I don't know enough about the hardware to say...
Seems straightforward to me?
2.6.25 or 2.6.26 material?
It depends on Herbert Valerio Riedel's ep93xx_eth phylib conversion, which isn't in 2.6.25-rc7 (but received an ACK from Lennert some weeks ago). I guess it should go in whenever that is merged.
Quoted 3 lines
Any more testing results?
Sorry, I haven't had much time recently, so I haven't further investigated the autoneg off issue. I've seen it work fine sometimes, so it's either some very weird bug or something totally unrelated.
Signature · 1 line
Oliver
Quoted 11 lines · Oliver Martin
Quoted 7 lines
ACKs from Lennert, others?
I don't know enough about the hardware to say...
Seems straightforward to me?
2.6.25 or 2.6.26 material?
It depends on Herbert Valerio Riedel's
ep93xx_ethphylib conversion, which isn't in 2.6.25-rc7 (but received an ACK from Lennert some weeks ago). I guess it should go in whenever that is merged.
ACK for 2.6.26, together with Herbert's changes.
Herbert, can you resend your latest?
Quoted 15 lines · Oliver Martin
Am Tue, 04 Mar 2008 14:02:15 +0100
schrieb Oliver Martin <[email protected]>:Quoted 6 lines
Now I'm having different problems: When auto-negotiation is enabled, it sometimes randomly changes the link state:
PHY: 0:01 - Link is Down
PHY: 0:01 - Link is Up - 100/FullI've found at least one part of the problem. The MDIO clock divisor wasn't set again after the reset in
ep93xx_start_hw. It was left at the default, resulting in a 12.5 MHz clock, which the PHY (Micrel KSZ8721BL) didn't like too much. Callingep93xx_mdio_resetafter the reset fixed it, the link is now perfectly stable in auto-negotiation mode.
Quoted 6 lines
There still seems to be another bug with auto-negotiation disabled: It doesn't switch to 1000 Mbps any more, but most times it doesn't stay in the intended configuration either. I haven't done any extensive testing of this yet, though.
Signed-off-by Oliver Martin <[email protected]>
Testing feedback? Lennert ack?
Quoted 14 lines · Jeff Garzik
Quoted 14 lines
Am Tue, 04 Mar 2008 14:02:15 +0100
schrieb Oliver Martin <[email protected]>:Quoted 5 lines
Now I'm having different problems: When auto-negotiation is enabled, it sometimes randomly changes the link state:
PHY: 0:01 - Link is Down
PHY: 0:01 - Link is Up - 100/FullI've found at least one part of the problem. The MDIO clock divisor wasn't set again after the reset in
ep93xx_start_hw. It was left at the default, resulting in a 12.5 MHz clock, which the PHY (Micrel KSZ8721BL) didn't like too much. Callingep93xx_mdio_resetafter the reset fixed it, the link is now perfectly stable in auto-negotiation mode.
Quoted 8 lines
Quoted 6 lines
There still seems to be another bug with auto-negotiation disabled: It doesn't switch to 1000 Mbps any more, but most times it doesn't stay in the intended configuration either. I haven't done any extensive testing of this yet, though.
Signed-off-by Oliver Martin <[email protected]>Testing feedback? Lennert ack?
ACKed on March 29. Since this patch depends on Herbert Valerio Riedel's ep93xx_eth phylib conversion, I asked Herbert to resend his latest version of those patches at that time, but I didn't see that yet.
Herbert, have you made changes to the ep93xx_eth phylib patch since you last posted it and/or what is the latest version?
Quoted 2 lines · Lennert Buytenhek
Herbert, have you made changes to the
ep93xx_ethphylib patch since you last posted it and/or what is the latest version?
I have made no changes since last post, and right now I wouldn't have the hardware available to test anything... :-/
cheers,
hvr
Am Sat, 13 Sep 2008 22:11:32 -0400 schrieb Jeff Garzik:
Quoted 17 lines
Quoted 16 lines · Oliver Martin
Am Tue, 04 Mar 2008 14:02:15 +0100
schrieb Oliver Martin <[email protected]>:Quoted 6 lines
Now I'm having different problems: When auto-negotiation is enabled, it sometimes randomly changes the link state:
PHY: 0:01 - Link is Down
PHY: 0:01 - Link is Up - 100/FullI've found at least one part of the problem. The MDIO clock divisor wasn't set again after the reset in
ep93xx_start_hw. It was left at the default, resulting in a 12.5 MHz clock, which the PHY (Micrel KSZ8721BL) didn't like too much. Callingep93xx_mdio_resetafter the reset fixed it, the link is now perfectly stable in auto-negotiation mode.
Quoted 8 lines
Quoted 6 lines
There still seems to be another bug with auto-negotiation disabled:
It doesn't switch to 1000 Mbps any more, but most times it doesn't stay in the intended configuration either. I haven't done any extensive testing of this yet, though.Signed-off-by Oliver Martin <[email protected]>Testing feedback? Lennert ack?
We're currently using a variation of my original patch, which didn't handle ifdown correctly (there's a similar reset there). With the current setup, everything seems stable, but we still have some rather hackish workarounds for the original issue in our startup scripts. I don't have the hardware right now, but we'll specifically test without them both with and without auto-negotiation next week and report the results.
drivers/net/arm/ep93xx_eth.c +22 -16
@@ -535,6 +535,22 @@return 1 ; } +static int ep93xx_mdio_reset (struct mii_bus *bus) +{ +struct ep93xx_priv *ep = bus->priv; + +u32 selfctl =rdl (ep,REG_SELFCTL ); + + selfctl &= ~(REG_SELFCTL_MDCDIV_MSK |REG_SELFCTL_PSPRS ); + + selfctl |= (ep->mdc_divisor -1 ) <<REG_SELFCTL_MDCDIV_OFS ; + selfctl |=REG_SELFCTL_PSPRS ; + +wrl (ep,REG_SELFCTL , selfctl); + +return 0 ; +} +static int ep93xx_start_hw (struct net_device *dev) {struct ep93xx_priv *ep =netdev_priv (dev);
@@ -553,6 +569,9 @@return 1 ; } +/* The reset cleared REG_SELFCTL, so set the MDC divisor again */ +ep93xx_mdio_reset (&ep->mii_bus); +/* Receive descriptor ring. */ addr = ep->descs_dma_addr + offsetof(struct ep93xx_descs , rdesc);wrl (ep,REG_RXDQBADD , addr);
@@ -625,6 +644,9 @@if (i ==10 ) printk(KERN_CRIT DRV_MODULE_NAME ": hw failed to reset\n"); + +/* The reset cleared REG_SELFCTL, so set the MDC divisor again */ +ep93xx_mdio_reset (&ep->mii_bus); }static int ep93xx_open (struct net_device *dev)
@@ -776,22 +798,6 @@return 0 ; } -static int ep93xx_mdio_reset (struct mii_bus *bus) -{ -struct ep93xx_priv *ep = bus->priv; - -u32 selfctl =rdl (ep,REG_SELFCTL ); - - selfctl &= ~(REG_SELFCTL_MDCDIV_MSK |REG_SELFCTL_PSPRS ); - - selfctl |= (ep->mdc_divisor -1 ) <<REG_SELFCTL_MDCDIV_OFS ; - selfctl |=REG_SELFCTL_PSPRS ; - -wrl (ep,REG_SELFCTL , selfctl); - -return 0 ; -} -static void ep93xx_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info) {
Quoted 26 lines · Oliver Martin
Quoted 17 lines
Quoted 16 lines · Oliver Martin
Am Tue, 04 Mar 2008 14:02:15 +0100
schrieb Oliver Martin <[email protected]>:Quoted 6 lines
Now I'm having different problems: When auto-negotiation is enabled, it sometimes randomly changes the link state:
PHY: 0:01 - Link is Down
PHY: 0:01 - Link is Up - 100/FullI've found at least one part of the problem. The MDIO clock divisor wasn't set again after the reset in
ep93xx_start_hw. It was left at the default, resulting in a 12.5 MHz clock, which the PHY (Micrel KSZ8721BL) didn't like too much. Callingep93xx_mdio_resetafter the reset fixed it, the link is now perfectly stable in auto-negotiation mode.Quoted 8 lines
Quoted 6 lines
There still seems to be another bug with auto-negotiation disabled:
It doesn't switch to 1000 Mbps any more, but most times it doesn't stay in the intended configuration either. I haven't done any extensive testing of this yet, though.Signed-off-by Oliver Martin <[email protected]>Testing feedback? Lennert ack?
Quoted 7 lines
We're currently using a variation of my original patch, which didn't handle ifdown correctly (there's a similar reset there). With the current setup, everything seems stable, but we still have some rather hackish workarounds for the original issue in our startup scripts. I don't have the hardware right now, but we'll specifically test without them both with and without auto-negotiation next week and report the results.
Can you stick this somewhere together with the version of the phylib patch you are using?
Am Sun, 14 Sep 2008 14:12:26 +0200 schrieb Lennert Buytenhek:
Quoted 11 lines
Quoted 8 lines
We're currently using a variation of my original patch, which didn't handle ifdown correctly (there's a similar reset there). With the current setup, everything seems stable, but we still have some rather hackish workarounds for the original issue in our startup scripts. I don't have the hardware right now, but we'll specifically test without them both with and without auto-negotiation next week and report the results.
Can you stick this somewhere together with the version of the phylib patch you are using?
I've only changed a single line for 2.6.26, specifically the change of mii_bus.id from int to string. Anyway, here it is:
Currently, the ep93xx_eth driver doesn't care about the PHY state, but it should, in order to tell the MAC when full duplex operation is required; failure to do so causes degraded performance on full duplex links. This patch implements proper PHY handling via the phylib framework:
- clean up ep93xx_mdio_{read,write} to conform to ep93xx manual
- convert ep93xx_eth driver to phylib framework
- set full duplex bit in configuration of MAC when FDX link detected
- convert to use print_mac()
---
If you need me to split this patch, please let me know into what parts
drivers/net/arm/Kconfig | 1 + drivers/net/arm/ep93xx_eth.c | 354 +++++++++++++++++++++++++++++++++--------- 2 files changed, 282 insertions(+), 73 deletions(-)
drivers/net/arm/Kconfig +1 -0
@@ -44,6 +44,7 @@ tristate "EP93xx Ethernet support" depends on ARM && ARCH_EP93XX select MII + select PHYLIB help This is a driver for the ethernet hardware included in EP93xx CPUs. Say Y if you are building a kernel for EP93xx based devices.
drivers/net/arm/ep93xx_eth.c +281 -73
499 lines not on this page · raw message
Quoted 25 lines · Oliver Martin
Quoted 16 lines
Quoted 16 lines
Am Tue, 04 Mar 2008 14:02:15 +0100
schrieb Oliver Martin <[email protected]>:Quoted 6 lines
Now I'm having different problems: When auto-negotiation is enabled, it sometimes randomly changes the link state:
PHY: 0:01 - Link is Down
PHY: 0:01 - Link is Up - 100/FullI've found at least one part of the problem. The MDIO clock divisor wasn't set again after the reset in
ep93xx_start_hw. It was left at the default, resulting in a 12.5 MHz clock, which the PHY (Micrel KSZ8721BL) didn't like too much. Callingep93xx_mdio_resetafter the reset fixed it, the link is now perfectly stable in auto-negotiation mode.Quoted 8 lines
Quoted 6 lines
There still seems to be another bug with auto-negotiation disabled:
It doesn't switch to 1000 Mbps any more, but most times it doesn't stay in the intended configuration either. I haven't done any extensive testing of this yet, though.Signed-off-by Oliver Martin <[email protected]>Testing feedback? Lennert ack?
Quoted 7 lines
We're currently using a variation of my original patch, which didn't handle ifdown correctly (there's a similar reset there). With the current setup, everything seems stable, but we still have some rather hackish workarounds for the original issue in our startup scripts. I don't have the hardware right now, but we'll specifically test without them both with and without auto-negotiation next week and report the results.
OK, can you provide a commit message for this so that I can add it to
http://git.wantstofly.org/?p=ep93xx_eth.git/.git;a=summary and ask Jeff to pull it?
Quoted 70 lines
Index:
linux-2.6.26/drivers/net/arm/ep93xx_eth.c
===================================================================drivers/net/arm/ep93xx_eth.c +22
-16@@ -535,6 +535,22 @@return 1 ; } +static int ep93xx_mdio_reset (struct mii_bus *bus) +{ +struct ep93xx_priv *ep = bus->priv; + +u32 selfctl =rdl (ep,REG_SELFCTL ); + + selfctl &= ~(REG_SELFCTL_MDCDIV_MSK |REG_SELFCTL_PSPRS ); + + selfctl |= (ep->mdc_divisor -1 ) <<REG_SELFCTL_MDCDIV_OFS ; + selfctl |=REG_SELFCTL_PSPRS ; + +wrl (ep,REG_SELFCTL , selfctl); + +return 0 ; +} +static int ep93xx_start_hw (struct net_device *dev) {struct ep93xx_priv *ep =netdev_priv (dev);@@ -553,6 +569,9 @@return 1 ; } +/* The reset cleared REG_SELFCTL, so set the MDC divisor again */ +ep93xx_mdio_reset (&ep->mii_bus); +/* Receive descriptor ring. */ addr = ep->descs_dma_addr + offsetof(struct ep93xx_descs , rdesc);wrl (ep,REG_RXDQBADD , addr);@@ -625,6 +644,9 @@if (i ==10 ) printk(KERN_CRIT DRV_MODULE_NAME ": hw failed to reset\n"); + +/* The reset cleared REG_SELFCTL, so set the MDC divisor again */ +ep93xx_mdio_reset (&ep->mii_bus); }static int ep93xx_open (struct net_device *dev)@@ -776,22 +798,6 @@return 0 ; } -static int ep93xx_mdio_reset (struct mii_bus *bus) -{ -struct ep93xx_priv *ep = bus->priv; - -u32 selfctl =rdl (ep,REG_SELFCTL ); - - selfctl &= ~(REG_SELFCTL_MDCDIV_MSK |REG_SELFCTL_PSPRS ); - - selfctl |= (ep->mdc_divisor -1 ) <<REG_SELFCTL_MDCDIV_OFS ; - selfctl |=REG_SELFCTL_PSPRS ; - -wrl (ep,REG_SELFCTL , selfctl); - -return 0 ; -} -static void ep93xx_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info) {
Am Tue, 16 Sep 2008 14:51:25 +0200 schrieb Lennert Buytenhek:
Quoted 5 lines
OK, can you provide a commit message for this so that I can add it to
http://git.wantstofly.org/?p=ep93xx_eth.git/.git;a=summary and ask Jeff to pull it?
Previously, the MDIO clock divisor wasn't set again after the reset in ep93xx_start_hw. It was left at the default, resulting in a 12.5 MHz clock, which the PHY on our TS-7260 (Micrel KSZ8721BL) didn't like too much. Calling ep93xx_mdio_reset after the reset fixed the problems we were having. This small update to the previous patch also adds a call to ep93xx_mdio_reset in ep93xx_stop_hw.
drivers/net/arm/ep93xx_eth.c +22 -16
@@ -535,6 +535,22 @@return 1 ; } +static int ep93xx_mdio_reset (struct mii_bus *bus) +{ +struct ep93xx_priv *ep = bus->priv; + +u32 selfctl =rdl (ep,REG_SELFCTL ); + + selfctl &= ~(REG_SELFCTL_MDCDIV_MSK |REG_SELFCTL_PSPRS ); + + selfctl |= (ep->mdc_divisor -1 ) <<REG_SELFCTL_MDCDIV_OFS ; + selfctl |=REG_SELFCTL_PSPRS ; + +wrl (ep,REG_SELFCTL , selfctl); + +return 0 ; +} +static int ep93xx_start_hw (struct net_device *dev) {struct ep93xx_priv *ep =netdev_priv (dev);
@@ -553,6 +569,9 @@return 1 ; } +/* The reset cleared REG_SELFCTL, so set the MDC divisor again */ +ep93xx_mdio_reset (&ep->mii_bus); +/* Receive descriptor ring. */ addr = ep->descs_dma_addr + offsetof(struct ep93xx_descs , rdesc);wrl (ep,REG_RXDQBADD , addr);
@@ -625,6 +644,9 @@if (i ==10 ) printk(KERN_CRIT DRV_MODULE_NAME ": hw failed to reset\n"); + +/* The reset cleared REG_SELFCTL, so set the MDC divisor again */ +ep93xx_mdio_reset (&ep->mii_bus); }static int ep93xx_open (struct net_device *dev)
@@ -776,22 +798,6 @@return 0 ; } -static int ep93xx_mdio_reset (struct mii_bus *bus) -{ -struct ep93xx_priv *ep = bus->priv; - -u32 selfctl =rdl (ep,REG_SELFCTL ); - - selfctl &= ~(REG_SELFCTL_MDCDIV_MSK |REG_SELFCTL_PSPRS ); - - selfctl |= (ep->mdc_divisor -1 ) <<REG_SELFCTL_MDCDIV_OFS ; - selfctl |=REG_SELFCTL_PSPRS ; - -wrl (ep,REG_SELFCTL , selfctl); - -return 0 ; -} -static void ep93xx_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info) {