spidernet: dynamic phy setup code
Subsystems (2)
This patch modifies the patch submitted by Kou Ishizaki to make it work on the blade (http://marc.theaimsgroup.com/?l=linux-netdev&m=116593424505539&w=2).
Unfortunately I dont have access to a Celleb so I cannot test it there.
The basic logic behind this is simple : when the interface first comes up it tries to detect the phy. When the phy is detected, it is initially set up to use copper. A timer is set to check the link status in spidernet_link_phy using poll_link. If link check fails more than SPIDER_NET_ANEG_TIMEOUT times, it switches to fiber link with autonegotiation. If that fails more than SPIDER_NET_ANEG_TIMEOUT times, it switches to fiber link with no autonegotiation. If that also fails, it goes back to copper, and so forth. If the link comes up, it prints the link abilites and we are done.
The name of the phy found attached to the spider chip is reported to the user. Hardcoded values for the timeout are moved to #defines. I put in a few comments to make the code more readable.
drivers/net/spider_net.c +9 -6
@@ -1280,19 +1280,23 @@ spider_net_set_mac(struct net_device *ne* spider_net_link_reset * @netdev: net device structure * +* This is called when the PHY_LINK signal is asserted. For the blade this is +* not connected so we should never get here. +* */ static void spider_net_link_reset (struct net_device *netdev) { -struct spider_net_card *card=netdev_priv (netdev);del_timer_sync (&card->aneg_timer); +/* clear interrupt, block further interrupts */ spider_net_write_reg (card,SPIDER_NET_GMACST ,spider_net_read_reg (card,SPIDER_NET_GMACST ));spider_net_write_reg (card,SPIDER_NET_GMACINTEN ,0 ); +/* reset phy and setup aneg */ mii_phy_probe (&card->phy, card->phy.mii_id);spider_net_setup_aneg (card, is1000);if (card->phy.def->phy_id)
@@ -1616,6 +1620,7 @@ spider_net_init_card(struct spider_net_cspider_net_write_reg (card,SPIDER_NET_CKRCTRL ,SPIDER_NET_CKRCTRL_RUN_VALUE ); +/* trigger ETOMOD signal */ spider_net_write_reg (card,SPIDER_NET_GMACOPEMD ,spider_net_read_reg (card,SPIDER_NET_GMACOPEMD ) |0x4 );
@@ -1739,6 +1744,8 @@ spider_net_open(struct net_device *netdeif (spider_net_init_firmware (card)) goto init_firmware_failed; +/* start probing with copper */ + card->phy.medium =GMII_COPPER ;spider_net_setup_aneg (card, is1000);if (card->phy.def->phy_id)mod_timer (&card->aneg_timer, jiffies +SPIDER_NET_ANEG_TIMER );
@@ -1805,43 +1812,54 @@ static void spider_net_link_phy(unsignedstruct spider_net_card *card = (struct spider_net_card *)data;struct mii_phy *phy = &card->phy; -if (card->aneg_count >10 ) { -/* timeout */ - card->aneg_count =0 ; - is1000 = !is1000; - goto re_setup; +/* if link didn't come up after SPIDER_NET_ANEG_TIMEOUT tries, setup phy
again */
+ if (card->aneg_count > SPIDER_NET_ANEG_TIMEOUT) {
+
+ pr_info("%s: link is down, trying to bring it up\n", card->netdev->name); +
+ switch(phy->medium) {
+ case GMII_COPPER:
+ /* enable fiber with autonegotiation first */
+ if (phy->def->ops->enable_fiber)
+ phy->def->ops->enable_fiber(phy, 1);
+ phy->medium = GMII_FIBER;
+ break;
+
+ case GMII_FIBER:
+ /* fiber didn't come up, try to disable fiber autoneg */
+ if (phy->def->ops->enable_fiber)
+ phy->def->ops->enable_fiber(phy, 0);
+ phy->medium = GMII_UNKNOWN;
+ break;
+
+ case GMII_UNKNOWN:
+ /* copper, fiber with and without autoneg failed,
+ * retry from beginning */
+ spider_net_setup_aneg(card, is1000); + phy->medium = GMII_COPPER; + break;
+ }
+
+ card->aneg_count = 0;
+ mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER);
+ return;
}
+ /* link still not up, try again later */
if (!(phy->def->ops->poll_link(phy))) {
card->aneg_count++;
mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); return;
}
+ /* link came up, get abilities */
phy->def->ops->read_link(phy);
- if (phy->speed == 1000 && !is1000) {
- is1000 = 1;
- goto re_setup;
- } else if(phy->speed != 1000 && is1000) {
- is1000 = 0;
- goto re_setup;
- }
-
- spider_net_write_reg(card, SPIDER_NET_GMACST,
- spider_net_read_reg(card, SPIDER_NET_GMACST));
- spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0x4); -
- pr_info("Found %s with %i Mbps, %s-duplex.\n",
- phy->def->name, phy->speed, phy->duplex==1 ? "Full" : "Half");
+ pr_info("%s: link is up with %i Mbps, %s-duplex, %sautoneg.\n",
+ card->netdev->name, phy->speed, phy->duplex==1 ? "Full" : "Half",
+ phy->autoneg==1 ? "" : "no ");
return;
-
-re_setup:
- mii_phy_probe(phy, phy->mii_id);
- spider_net_setup_aneg(card, is1000);
- card->aneg_count = 0;
- mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); }
/**
@@ -1871,8 +1889,10 @@ spider_net_setup_phy(struct spider_net_c
unsigned short id;
id = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); if (id != 0x0000 && id != 0xffff) {
- mii_phy_probe(phy, phy->mii_id);
+ if (!mii_phy_probe(phy, phy->mii_id)) {
+ pr_info("Found %s.\n", phy->def->name);
break;+ }
}
}
drivers/net/spider_net.h +2 -1
@@ -51,7 +51,8 @@ extern char spider_net_driver_name[];#define SPIDER_NET_TX_DESCRIPTORS_MAX 512#define SPIDER_NET_TX_TIMER (HZ/5) -#define SPIDER_NET_ANEG_TIMER (HZ*2) +#define SPIDER_NET_ANEG_TIMER (HZ) +#define SPIDER_NET_ANEG_TIMEOUT 2#define SPIDER_NET_RX_CSUM_DEFAULT 1
Quoted 5 lines · Jens Osterkamp
This patch modifies the patch submitted by Kou Ishizaki to make it work on the blade (http://marc.theaimsgroup.com/?l=linux-netdev&m=116593424505539&w=2).
Index:
linux-2.6/drivers/net/spider_net.c
+ if (card->aneg_count>SPIDER_NET_ANEG_TIMEOUT) {
Review
Quoted 10 lines
(quoted diff) +10
-0+ + pr_info("%s: link is down, trying to bring it up\n", card->netdev->name); + + switch(phy->medium) { + case GMII_COPPER: + /* enable fiber with autonegotiation first */ + if (phy->def->ops->enable_fiber) + phy->def->ops->enable_fiber(phy, 1); + phy->medium = GMII_FIBER; + break;
Can you fix this to use tabs for indentation, instead of spaces?
Please note, if you do not like tabs of 8 spaces, you can always change this in your editor, e.g "set ts=3" for making a tab be 3 spaces in vi. You would put this in your .exrc or .vimrc file.
Patches submitted to the kernel should use tabs, uniformly.
--linas
Quoted 13 lines · Jens Osterkamp
This patch modifies the patch submitted by Kou Ishizaki to make it work on the blade (http://marc.theaimsgroup.com/?l=linux-netdev&m=116593424505539&w=2).
Unfortunately I dont have access to a Celleb so I cannot test it there.The basic logic behind this is simple : when the interface first comes up it tries to detect the phy. When the phy is detected, it is initially set up to use copper. A timer is set to check the link status in
spidernet_link_phyusingpoll_link. If link check fails more thanSPIDER_NET_ANEG_TIMEOUTtimes, it switches to fiber link with autonegotiation. If that fails more thanSPIDER_NET_ANEG_TIMEOUTtimes, it switches to fiber link with no autonegotiation. If that also fails, it goes back to copper, and so forth. If the link comes up, it prints the link abilites and we are done.
Quoted 3 lines
The name of the phy found attached to the spider chip is reported to the user. Hardcoded values for the timeout are moved to #defines. I put in a few comments to make the code more readable.
Can't we have a device-tree property indicating wether to use fiber or copper ?
Ben.
Linas Vepstas
Acked-byQuoted 1 line · Jens Osterkamp
Seems like my kmail has eaten the tabs...i am attaching it as a file,
Ahhh
Quoted 1 line
does it look ok for you now ?
Yes.
FWIW,
--linas
Quoted 7 lines · Linas Vepstas
Quoted 1 line · Jens Osterkamp
Seems like my kmail has eaten the tabs...i am attaching it as a file,
Ahhh
Quoted 1 line
does it look ok for you now ?
Quoted 7 lines
Yes.
FWIW,
Acked-by Linas Vepstas <[email protected]>--linas
Sending it again as attached file
Jens
Subject: spidernet: dynamic phy setup code
This patch modifies the patch submitted by Kou Ishizaki to make it work on the blade (http://marc.theaimsgroup.com/?l=linux-netdev&m=116593424505539&w=2).
Unfortunately I dont have access to a Celleb so I cannot test it there.
The basic logic behind this is simple : when the interface first comes up it tries to detect the phy. When the phy is detected, it is initially set up to use copper. A timer is set to check the link status in spidernet_link_phy using poll_link. If link check fails more than SPIDER_NET_ANEG_TIMEOUT times, it switches to fiber link with autonegotiation. If that fails more than SPIDER_NET_ANEG_TIMEOUT times, it switches to fiber link with no autonegotiation. If that also fails, it goes back to copper, and so forth. If the link comes up, it prints the link abilites and we are done.
The name of the phy found attached to the spider chip is reported to the user. Hardcoded values for the timeout are moved to #defines. I put in a few comments to make the code more readable.
drivers/net/spider_net.c +47 -27
@@ -1280,19 +1280,23 @@ spider_net_set_mac(struct net_device *ne* spider_net_link_reset * @netdev: net device structure * +* This is called when the PHY_LINK signal is asserted. For the blade this is +* not connected so we should never get here. +* */ static void spider_net_link_reset (struct net_device *netdev) { -struct spider_net_card *card=netdev_priv (netdev);del_timer_sync (&card->aneg_timer); +/* clear interrupt, block further interrupts */ spider_net_write_reg (card,SPIDER_NET_GMACST ,spider_net_read_reg (card,SPIDER_NET_GMACST ));spider_net_write_reg (card,SPIDER_NET_GMACINTEN ,0 ); +/* reset phy and setup aneg */ mii_phy_probe (&card->phy, card->phy.mii_id);spider_net_setup_aneg (card, is1000);if (card->phy.def->phy_id)
@@ -1616,6 +1620,7 @@ spider_net_init_card(struct spider_net_cspider_net_write_reg (card,SPIDER_NET_CKRCTRL ,SPIDER_NET_CKRCTRL_RUN_VALUE ); +/* trigger ETOMOD signal */ spider_net_write_reg (card,SPIDER_NET_GMACOPEMD ,spider_net_read_reg (card,SPIDER_NET_GMACOPEMD ) |0x4 );
@@ -1739,6 +1744,8 @@ spider_net_open(struct net_device *netdeif (spider_net_init_firmware (card)) goto init_firmware_failed; +/* start probing with copper */ + card->phy.medium =GMII_COPPER ;spider_net_setup_aneg (card, is1000);if (card->phy.def->phy_id)mod_timer (&card->aneg_timer, jiffies +SPIDER_NET_ANEG_TIMER );
@@ -1805,43 +1812,54 @@ static void spider_net_link_phy(unsignedstruct spider_net_card *card = (struct spider_net_card *)data;struct mii_phy *phy = &card->phy; -if (card->aneg_count >10 ) { -/* timeout */ - card->aneg_count =0 ; - is1000 = !is1000; - goto re_setup; +/* if link didn't come up after SPIDER_NET_ANEG_TIMEOUT tries, setup phy again */ +if (card->aneg_count >SPIDER_NET_ANEG_TIMEOUT ) { + +pr_info ("%s: link is down, trying to bring it up\n" , card->netdev->name); + +switch (phy->medium) { +case GMII_COPPER : +/* enable fiber with autonegotiation first */ +if (phy->def->ops->enable_fiber) + phy->def->ops->enable_fiber (phy,1 ); + phy->medium =GMII_FIBER ; +break ; + +case GMII_FIBER : +/* fiber didn't come up, try to disable fiber autoneg */ +if (phy->def->ops->enable_fiber) + phy->def->ops->enable_fiber (phy,0 ); + phy->medium =GMII_UNKNOWN ; +break ; + +case GMII_UNKNOWN : +/* copper, fiber with and without autoneg failed, +* retry from beginning */ +spider_net_setup_aneg (card, is1000); + phy->medium =GMII_COPPER ; +break ; + } + + card->aneg_count =0 ; +mod_timer (&card->aneg_timer, jiffies +SPIDER_NET_ANEG_TIMER ); +return ; } +/* link still not up, try again later */ if (!(phy->def->ops->poll_link (phy))) { card->aneg_count++;mod_timer (&card->aneg_timer, jiffies +SPIDER_NET_ANEG_TIMER );return ; } +/* link came up, get abilities */ phy->def->ops->read_link (phy); -if (phy->speed ==1000 && !is1000) { - is1000 =1 ; - goto re_setup; - }else if (phy->speed !=1000 && is1000) { - is1000 =0 ; - goto re_setup; - } - -spider_net_write_reg (card,SPIDER_NET_GMACST , -spider_net_read_reg (card,SPIDER_NET_GMACST )); -spider_net_write_reg (card,SPIDER_NET_GMACINTEN ,0x4 ); - -pr_info ("Found %s with %i Mbps, %s-duplex.\n" , - phy->def->name, phy->speed, phy->duplex==1 ?"Full" :"Half" ); +pr_info ("%s: link is up with %i Mbps, %s-duplex, %sautoneg.\n" , + card->netdev->name, phy->speed, phy->duplex==1 ?"Full" :"Half" , + phy->autoneg==1 ?"" :"no " );return ; - -re_setup: -mii_phy_probe (phy, phy->mii_id); -spider_net_setup_aneg (card, is1000); - card->aneg_count =0 ; -mod_timer (&card->aneg_timer, jiffies +SPIDER_NET_ANEG_TIMER ); }/**
@@ -1871,8 +1889,10 @@ spider_net_setup_phy(struct spider_net_cunsigned short id; id =spider_net_read_phy (card->netdev, phy->mii_id,MII_BMSR );if (id !=0x0000 && id !=0xffff ) { -mii_phy_probe (phy, phy->mii_id); +if (!mii_phy_probe (phy, phy->mii_id)) { +pr_info ("Found %s.\n" , phy->def->name);break ; + } } }
drivers/net/spider_net.h +2 -1
@@ -51,7 +51,8 @@ extern char spider_net_driver_name[];#define SPIDER_NET_TX_DESCRIPTORS_MAX 512#define SPIDER_NET_TX_TIMER (HZ/5) -#define SPIDER_NET_ANEG_TIMER (HZ*2) +#define SPIDER_NET_ANEG_TIMER (HZ) +#define SPIDER_NET_ANEG_TIMEOUT 2#define SPIDER_NET_RX_CSUM_DEFAULT 1
I apologize if you received this mail many times.
Jens-san
Quoted 1 line
This patch modifies the patch submitted by Kou Ishizaki to make it
work on the
Quoted 1 line
blade
(http://marc.theaimsgroup.com/?l=linux-netdev&m=116593424505539&w=2).
Quoted 1 line
Unfortunately I dont have access to a Celleb so I cannot test it
there.
Thanks for arranging our patch to work on Cell Blade.
This patch partially works on celleb but remains following several problems.
1. It doesn't recover once an ethernet cable which is connected to a spider_net card is unpluged.
2. It doesn't work when the spider_net card is connected to a 100Mbps ethernet switch.
To solve these problems, we need to restore some codes you removed from your patch.
(1)
Review
Quoted 13 lines
- if (
card->aneg_count> 10) {(quoted diff) +0
-11- /* timeout */ - card->aneg_count = 0; - is1000 = !is1000; - goto re_setup; - if (phy->speed == 1000 && !is1000) { - is1000 = 1; - goto re_setup; - } else if(phy->speed != 1000 && is1000) { - is1000 = 0; - goto re_setup; - }
We need to use different auto-neg initial settings between for 10/100Mbps ethernet switches and for Gbps ethernet switches. Driver don't know which type of network switch is connected to network card, so we try both settings alternately in auto negtiation sequences by using a variable "is1000".
Furthermore, we have a problem that poll_link() may succeed even when the auto-neg initial setting is for different network switch type, and the network card does not work on this case. We retry auto-neg with the another initial setting on this case.
#We are commented that "is1000" should be in spider_net_card. #We fixed it in another patch. Please refer the following. #http://ozlabs.org/pipermail/linuxppc-dev/2007-January/030203.html
But we don't think this is the best solution, and we are still developing
our spidernet driver. If you have a good alternative idea, please tell us.
(2)
Quoted 3 lines
- spider_net_write_reg(card,
SPIDER_NET_GMACST,
-spider_net_read_reg(card, SPIDER_NET_GMACST));
-spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0x4);
These codes are enabling LINK status interrupt which is disabled at the beginning of auto-neg.
Without this operation, auto negotiation works only when a connection detected for the first time, and auto negotiation will not work when an ethernet cable is unpluged or pluged.
(3)
Quoted 1 line
-
mii_phy_probe(phy, phy->mii_id);
It seems that PHY reset is necessary before auto negotiation, after a link once went down.
We can't call directly reset routine from driver, so we call mii_phy_probe().
We are still developping the patch as we noted, and we are considering to call mii_phy_probe() from spider_net_setup_aneg(), or to call reset_one_mii_phy() from bcm54xx_setup_aneg().
We think these (1)-(3) are necessary, but we are afraid that you removed them
by a reason that they causes some trouble in Cell Blade. If so please tell us.
Best regards,
Kou Ishizaki
Quoted 2 lines · Benjamin Herrenschmidt
Can't we have a device-tree property indicating wether to use fiber or copper ?
Well, yes, I am sure we could, but what would be the benefit of doing so if we can get the same information dynamically ?
Jens
Ishizaki-san,
Quoted 4 lines
This patch partially works on celleb but remains following several problems.
1. It doesn't recover once an ethernet cable which is connected to aspider_netcard is unpluged.
My understanding is that you are using the LINK interrupt to detect this. For the blade this is not connected but reenabling it wont hurt, I hope.
Quoted 21 lines
2. It doesn't work when the
spider_netcard is connected to a 100Mbps ethernet switch.To solve these problems, we need to restore some codes you removed from your patch.
(1)
Review
Quoted 13 lines
- if (
card->aneg_count> 10) {(quoted diff) +0
-11- /* timeout */ - card->aneg_count = 0; - is1000 = !is1000; - goto re_setup; - if (phy->speed == 1000 && !is1000) { - is1000 = 1; - goto re_setup; - } else if(phy->speed != 1000 && is1000) { - is1000 = 0; - goto re_setup; - }
Quoted 5 lines
We need to use different auto-neg initial settings between for 10/100Mbps ethernet switches and for Gbps ethernet switches. Driver don't know which type of network switch is connected to network card, so we try both settings alternately in auto negtiation sequences by using a variable "is1000".
I still dont see why you need different settings for different speed switches. This is getting to a point where access to some hardware would be handy. What exact phy are using anyway ?
Quoted 4 lines
Furthermore, we have a problem that
poll_link()may succeed even when the auto-neg initial setting is for different network switch type, and the network card does not work on this case. We retry auto-neg with the another initial setting on this case.
See above, could you give some more details why this is the case. Or maybe Ben knows more about this ?
Quoted 14 lines
#We are commented that "is1000" should be in
spider_net_card. #We fixed it in another patch. Please refer the following. #http://ozlabs.org/pipermail/linuxppc-dev/2007-January/030203.htmlBut we don't think this is the best solution, and we are still developing
our spidernet driver. If you have a good alternative idea, please tell us.(2)
Quoted 3 lines
- spider_net_write_reg(card,
SPIDER_NET_GMACST,
-spider_net_read_reg(card, SPIDER_NET_GMACST));
-spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0x4);
Quoted 5 lines
These codes are enabling LINK status interrupt which is disabled at the beginning of auto-neg.
Without this operation, auto negotiation works only when a connection detected for the first time, and auto negotiation will not work when an ethernet cable is unpluged or pluged.
I will reenable it and see wether it affects us. The pin is not connected so we should never enter this part of the code.
Quoted 9 lines
(3)
Quoted 1 line
-
mii_phy_probe(phy, phy->mii_id);It seems that PHY reset is necessary before auto negotiation, after a link once went down.
We can't call directly reset routine from driver, so we callmii_phy_probe().
We are still developping the patch as we noted, and we are considering to callmii_phy_probe()fromspider_net_setup_aneg(), or to callreset_one_mii_phy()frombcm54xx_setup_aneg().
IMHO using mii_phy_probe is the right way to do this.
Quoted 4 lines
We think these (1)-(3) are necessary, but we are afraid that you removed them
by a reason that they causes some trouble in Cell Blade. If so please tell us.
I'll do some investigations and let you know of the results.
Jens
Jens-san,
Thanks for your comments.
Quoted 8 lines
Ishizaki-san,
Quoted 4 lines
This patch partially works on celleb but remains following several problems.
1. It doesn't recover once an ethernet cable which is connected to aspider_netcard is unpluged.My understanding is that you are using the LINK interrupt to detect this.
Yes. We use the LINK interrupt for this purpose.
Quoted 29 lines
For the blade this is not connected but reenabling it wont hurt, I hope.
Quoted 21 lines
2. It doesn't work when the
spider_netcard is connected to a 100Mbps ethernet switch.To solve these problems, we need to restore some codes you removed from your patch.
(1)
Review
Quoted 13 lines
- if (
card->aneg_count> 10) {(quoted diff) +0
-11- /* timeout */ - card->aneg_count = 0; - is1000 = !is1000; - goto re_setup; - if (phy->speed == 1000 && !is1000) { - is1000 = 1; - goto re_setup; - } else if(phy->speed != 1000 && is1000) { - is1000 = 0; - goto re_setup; - }Quoted 5 lines
We need to use different auto-neg initial settings between for 10/100Mbps ethernet switches and for Gbps ethernet switches. Driver don't know which type of network switch is connected to network card, so we try both settings alternately in auto negtiation sequences by using a variable "is1000".
Quoted 3 lines
I still dont see why you need different settings for different speed switches. This is getting to a point where access to some hardware would be handy. What exact phy are using anyway ?
We use bcm5461. There is a possibility that we don't know the appropriate setting which is applicable for both type of switches.
Quoted 7 lines
Quoted 4 lines
Furthermore, we have a problem that
poll_link()may succeed even when the auto-neg initial setting is for different network switch type, and the network card does not work on this case. We retry auto-neg with the another initial setting on this case.See above, could you give some more details why this is the case. Or maybe Ben knows more about this ?
We didn't investigate for the detail, but we met the following phenomena.
1. When auto-neg starts with Gbps setting and ethernet card is connected to a 100Mbps switch, LINK is not detected.
2. When auto-neg starts with 100/10Mbps setting and ethernet card is connected to Gbps switch, LINK is detected (poll_link() succeeds), but the network is not available.
Quoted 7 lines
Quoted 7 lines
#We are commented that "is1000" should be in
spider_net_card. #We fixed it in another patch. Please refer the following. #http://ozlabs.org/pipermail/linuxppc-dev/2007-January/030203.htmlBut we don't think this is the best solution, and we are still developing
our spidernet driver. If you have a good alternative idea, please
tell
Quoted 7 lines
Quoted 7 lines
us.
(2)
Quoted 3 lines
- spider_net_write_reg(card,
SPIDER_NET_GMACST,
-spider_net_read_reg(card, SPIDER_NET_GMACST));
-spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0x4);
Quoted 7 lines
Quoted 5 lines
These codes are enabling LINK status interrupt which is disabled at the beginning of auto-neg.
Without this operation, auto negotiation works only when a connection detected for the first time, and auto negotiation will not work when an ethernet cable is unpluged or pluged.I will reenable it and see wether it affects us. The pin is not
connected so
Quoted 12 lines
we should never enter this part of the code.
Quoted 9 lines
(3)
Quoted 1 line
-
mii_phy_probe(phy, phy->mii_id);It seems that PHY reset is necessary before auto negotiation, after a link once went down.
We can't call directly reset routine from driver, so we callmii_phy_probe().
We are still developping the patch as we noted, and we are considering to callmii_phy_probe()fromspider_net_setup_aneg(), or to callreset_one_mii_phy()frombcm54xx_setup_aneg().
Quoted 1 line
IMHO using
mii_phy_probeis the right way to do this.
OK. We will do so.
Quoted 6 lines
Quoted 4 lines
We think these (1)-(3) are necessary, but we are afraid that you removed them
by a reason that they causes some trouble in Cell Blade. If so please tell us.I'll do some investigations and let you know of the results.
Thanks for your cooperation to us.
By the way, we have a suggestion. Would you please make your spidernet patch based main-line code(not based on our patch)?
Our patch are still changing, so we think it's more convenient for you and us to maintain the code.
We will not mind whether it includes our code or not.
We will post our recent spidernet patch set based on 2.6.20-rc6. This patch set is merged Jens-san's spidernet patch and works on celleb. We hope this patch set will work on Cell blade.
We intend this patch set is just for a test so far(not intended to be taken for main-line immediately). Please try this, if you can.
Best regards,
Kou Ishizaki
PATCH 1/4 spidernet: autoneg support for Celleb
In reply to Jens OsterkampAdd auto negotiation support for Celleb.
This patch is just for a test. Please try this, if you can.
---
drivers/net/spider_net.h +11 -1
@@ -50,6 +50,8 @@#define SPIDER_NET_TX_DESCRIPTORS_MAX 512#define SPIDER_NET_TX_TIMER (HZ/5) +#define SPIDER_NET_ANEG_TIMER (HZ) +#define SPIDER_NET_ANEG_TIMEOUT 2#define SPIDER_NET_RX_CSUM_DEFAULT 1
@@ -104,6 +106,7 @@#define SPIDER_NET_GMACOPEMD 0x00000100#define SPIDER_NET_GMACLENLMT 0x00000108 +#define SPIDER_NET_GMACST 0x00000110#define SPIDER_NET_GMACINTEN 0x00000118#define SPIDER_NET_GMACPHYCTRL 0x00000120
@@ -333,9 +336,12 @@/* We rely on flagged descriptor interrupts */ #define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) ) +#define SPIDER_NET_LINKINT ( 1 << SPIDER_NET_GMAC2INT ) +#define SPIDER_NET_ERRINT ( 0xffffffff & \ (~SPIDER_NET_TXINT) & \ - (~SPIDER_NET_RXINT) ) + (~SPIDER_NET_RXINT) & \ + (~SPIDER_NET_LINKINT) )#define SPIDER_NET_GPREXEC 0x80000000#define SPIDER_NET_GPRDAT_MASK 0x0000ffff
@@ -447,6 +453,10 @@spinlock_t intmask_lock;struct tasklet_struct rxram_full_tl; + +int aneg_count; +int is1000; +struct timer_list aneg_timer;struct timer_list tx_timer;struct work_struct tx_timeout_task;
drivers/net/spider_net.c +203 -15
290 lines not on this page · raw message
PATCH 2/4 spidernet: load firmaware when open
In reply to Jens OsterkampThis patch moves calling init_firmware() from spider_net_probe() to spider_net_open() so as to use the driver by built-in.
This patch is just for a test. Please try this, if you can.
---
drivers/net/spider_net.c +123 -124
@@ -1718,6 +1718,124 @@ }/** +* spider_net_download_firmware - loads firmware into the adapter +* @card: card structure +* @firmware_ptr: pointer to firmware data +* +* spider_net_download_firmware loads the firmware data into the +* adapter. It assumes the length etc. to be allright. +*/ +static int +spider_net_download_firmware (struct spider_net_card *card, +const void *firmware_ptr) +{ +int sequencer, i; +const u32 *fw_ptr = firmware_ptr; + +/* stop sequencers */ +spider_net_write_reg (card,SPIDER_NET_GSINIT , +SPIDER_NET_STOP_SEQ_VALUE ); + +for (sequencer =0 ; sequencer <SPIDER_NET_FIRMWARE_SEQS ; + sequencer++) { +spider_net_write_reg (card, + SPIDER_NET_GSnPRGADR + sequencer *8 ,0 ); +for (i =0 ; i <SPIDER_NET_FIRMWARE_SEQWORDS ; i++) { +spider_net_write_reg (card, SPIDER_NET_GSnPRGDAT + + sequencer *8 , *fw_ptr); + fw_ptr++; + } + } + +if (spider_net_read_reg (card,SPIDER_NET_GSINIT )) +return -EIO ; + +spider_net_write_reg (card,SPIDER_NET_GSINIT , +SPIDER_NET_RUN_SEQ_VALUE ); + +return 0 ; +} + +/** +* spider_net_init_firmware - reads in firmware parts +* @card: card structure +* +* Returns 0 on success, <0 on failure +* +* spider_net_init_firmware opens the sequencer firmware and does some basic +* checks. This function opens and releases the firmware structure. A call +* to download the firmware is performed before the release. +* +* Firmware format +* =============== +* spider_fw.bin is expected to be a file containing 6*1024*4 bytes, 4k being +* the program for each sequencer. Use the command +* tail -q -n +2 Seq_code1_0x088.txt Seq_code2_0x090.txt \ +* Seq_code3_0x098.txt Seq_code4_0x0A0.txt Seq_code5_0x0A8.txt \ +* Seq_code6_0x0B0.txt | xxd -r -p -c4 > spider_fw.bin +* +* to generate spider_fw.bin, if you have sequencer programs with something +* like the following contents for each sequencer: +* <ONE LINE COMMENT> +* <FIRST 4-BYTES-WORD FOR SEQUENCER> +* <SECOND 4-BYTES-WORD FOR SEQUENCER> +* ... +* <1024th 4-BYTES-WORD FOR SEQUENCER> +*/ +static int +spider_net_init_firmware (struct spider_net_card *card) +{ +struct firmware *firmware =NULL ; +struct device_node *dn; +const u8 *fw_prop =NULL ; +int err = -ENOENT ; +int fw_size; + +if (request_firmware ((const struct firmware **)&firmware, +SPIDER_NET_FIRMWARE_NAME , &card->pdev->dev) ==0 ) { +if ( (firmware->size !=SPIDER_NET_FIRMWARE_LEN ) && +netif_msg_probe (card) ) { +pr_err ("Incorrect size of spidernet firmware in " \ +"filesystem. Looking in host firmware...\n" ); + goto try_host_fw; + } + err =spider_net_download_firmware (card, firmware->data); + +release_firmware (firmware); +if (err) + goto try_host_fw; + + goto done; + } + +try_host_fw: + dn =pci_device_to_OF_node (card->pdev); +if (!dn) + goto out_err; + + fw_prop =get_property (dn,"firmware" , &fw_size); +if (!fw_prop) + goto out_err; + +if ( (fw_size !=SPIDER_NET_FIRMWARE_LEN ) && +netif_msg_probe (card) ) { +pr_err ("Incorrect size of spidernet firmware in " \ +"host firmware\n" ); + goto done; + } + + err =spider_net_download_firmware (card, fw_prop); + +done: +return err; +out_err: +if (netif_msg_probe (card)) +pr_err ("Couldn't find spidernet firmware in filesystem " \ +"or host firmware\n" ); +return err; +} + +/** * spider_net_open - called upon ifonfig up * @netdev: interface device structure *
@@ -1735,6 +1853,10 @@ result = -ENOMEM ; + result =spider_net_init_firmware (card); +if (result) + goto init_firmware_failed; +/* start probing with copper */ spider_net_setup_aneg (card);if (card->phy.def->phy_id)
@@ -1785,6 +1907,7 @@spider_net_free_chain (card, &card->tx_chain); alloc_tx_failed:del_timer_sync (&card->aneg_timer); +init_firmware_failed:return result; }
@@ -1920,124 +2043,6 @@ }/** -* spider_net_download_firmware - loads firmware into the adapter -* @card: card structure -* @firmware_ptr: pointer to firmware data -* -* spider_net_download_firmware loads the firmware data into the -* adapter. It assumes the length etc. to be allright. -*/ -static int -spider_net_download_firmware (struct spider_net_card *card, -const void *firmware_ptr) -{ -int sequencer, i; -const u32 *fw_ptr = firmware_ptr; - -/* stop sequencers */ -spider_net_write_reg (card,SPIDER_NET_GSINIT , -SPIDER_NET_STOP_SEQ_VALUE ); - -for (sequencer =0 ; sequencer <SPIDER_NET_FIRMWARE_SEQS ; - sequencer++) { -spider_net_write_reg (card, - SPIDER_NET_GSnPRGADR + sequencer *8 ,0 ); -for (i =0 ; i <SPIDER_NET_FIRMWARE_SEQWORDS ; i++) { -spider_net_write_reg (card, SPIDER_NET_GSnPRGDAT + - sequencer *8 , *fw_ptr); - fw_ptr++; - } - } - -if (spider_net_read_reg (card,SPIDER_NET_GSINIT )) -return -EIO ; - -spider_net_write_reg (card,SPIDER_NET_GSINIT , -SPIDER_NET_RUN_SEQ_VALUE ); - -return 0 ; -} - -/** -* spider_net_init_firmware - reads in firmware parts -* @card: card structure -* -* Returns 0 on success, <0 on failure -* -* spider_net_init_firmware opens the sequencer firmware and does some basic -* checks. This function opens and releases the firmware structure. A call -* to download the firmware is performed before the release. -* -* Firmware format -* =============== -* spider_fw.bin is expected to be a file containing 6*1024*4 bytes, 4k being -* the program for each sequencer. Use the command -* tail -q -n +2 Seq_code1_0x088.txt Seq_code2_0x090.txt \ -* Seq_code3_0x098.txt Seq_code4_0x0A0.txt Seq_code5_0x0A8.txt \ -* Seq_code6_0x0B0.txt | xxd -r -p -c4 > spider_fw.bin -* -* to generate spider_fw.bin, if you have sequencer programs with something -* like the following contents for each sequencer: -* <ONE LINE COMMENT> -* <FIRST 4-BYTES-WORD FOR SEQUENCER> -* <SECOND 4-BYTES-WORD FOR SEQUENCER> -* ... -* <1024th 4-BYTES-WORD FOR SEQUENCER> -*/ -static int -spider_net_init_firmware (struct spider_net_card *card) -{ -struct firmware *firmware =NULL ; -struct device_node *dn; -const u8 *fw_prop =NULL ; -int err = -ENOENT ; -int fw_size; - -if (request_firmware ((const struct firmware **)&firmware, -SPIDER_NET_FIRMWARE_NAME , &card->pdev->dev) ==0 ) { -if ( (firmware->size !=SPIDER_NET_FIRMWARE_LEN ) && -netif_msg_probe (card) ) { -pr_err ("Incorrect size of spidernet firmware in " \ -"filesystem. Looking in host firmware...\n" ); - goto try_host_fw; - } - err =spider_net_download_firmware (card, firmware->data); - -release_firmware (firmware); -if (err) - goto try_host_fw; - - goto done; - } - -try_host_fw: - dn =pci_device_to_OF_node (card->pdev); -if (!dn) - goto out_err; - - fw_prop =get_property (dn,"firmware" , &fw_size); -if (!fw_prop) - goto out_err; - -if ( (fw_size !=SPIDER_NET_FIRMWARE_LEN ) && -netif_msg_probe (card) ) { -pr_err ("Incorrect size of spidernet firmware in " \ -"host firmware\n" ); - goto done; - } - - err =spider_net_download_firmware (card, fw_prop); - -done: -return err; -out_err: -if (netif_msg_probe (card)) -pr_err ("Couldn't find spidernet firmware in filesystem " \ -"or host firmware\n" ); -return err; -} - -/** * spider_net_workaround_rxramfull - work around firmware bug * @card: card structure *
@@ -2138,8 +2143,6 @@if (spider_net_setup_phy (card)) goto out; -if (spider_net_init_firmware (card)) - goto out;spider_net_open (netdev);spider_net_kick_tx_dma (card);
@@ -2419,10 +2422,6 @@if (err) goto out_undo_pci; - err =spider_net_init_firmware (card); -if (err) - goto out_undo_pci; - err =spider_net_setup_netdev (card);if (err) goto out_undo_pci;
PATCH 3/4 spidernet: add support for Celleb
In reply to Jens OsterkampThis patch adds or changes some HW specific settings for spider_net on Celleb.
This patch is just for a test. Please try this, if you can.
---
drivers/net/Kconfig +1 -1
@@ -2256,7 +2256,7 @@ config SPIDER_NET tristate "Spider Gigabit Ethernet driver" - depends on PCI && PPC_IBM_CELL_BLADE + depends on PCI && (PPC_IBM_CELL_BLADE || PPC_CELLEB) select FW_LOADER help This driver supports the Gigabit Ethernet chips present on the
drivers/net/spider_net.h +4 -2
@@ -1,7 +1,8 @@/* -* Network device driver for Cell Processor-Based Blade +* Network device driver for Cell Processor-Based Blade and Celleb platform * * (C) Copyright IBM Corp. 2005 +* (C) Copyright 2006 TOSHIBA CORPORATION * * Authors : Utz Bacher <[email protected]> * Jens Osterkamp <[email protected]>
@@ -184,7 +185,8 @@/* pause frames: automatic, no upper retransmission count */ /* outside loopback mode: ETOMOD signal dont matter, not connected */ -#define SPIDER_NET_OPMODE_VALUE 0x00000063 +/* ETOMOD signal is brought to PHY reset. bit 2 must be 1 in Celleb */ +#define SPIDER_NET_OPMODE_VALUE 0x00000067/*#define SPIDER_NET_OPMODE_VALUE 0x001b0062*/ #define SPIDER_NET_LENLMT_VALUE 0x00000908
drivers/net/spider_net.c +7 -1
@@ -1,7 +1,8 @@/* -* Network device driver for Cell Processor-Based Blade +* Network device driver for Cell Processor-Based Blade and Celleb platform * * (C) Copyright IBM Corp. 2005 +* (C) Copyright 2006 TOSHIBA CORPORATION * * Authors : Utz Bacher <[email protected]> * Jens Osterkamp <[email protected]>
@@ -1618,6 +1619,11 @@spider_net_write_reg (card,SPIDER_NET_CKRCTRL ,SPIDER_NET_CKRCTRL_RUN_VALUE ); + +/* trigger ETOMOD signal */ +spider_net_write_reg (card,SPIDER_NET_GMACOPEMD , +spider_net_read_reg (card,SPIDER_NET_GMACOPEMD ) |0x4 ); + }/**
PATCH 4/4 spidernet: remove txram full logging
In reply to Jens OsterkampThis patches removes logging for SPIDER_NET_GTMFLLINT interrupts. Since the interrupts are not irregular, and they happen frequently when using 100Mbps network switches.
This patch is just for a test. Please try this if you can.
---
drivers/net/spider_net.c +2 -2
@@ -1435,8 +1435,8 @@switch (i) {case SPIDER_NET_GTMFLLINT : -if (netif_msg_intr (card) &&net_ratelimit ()) -pr_err ("Spider TX RAM full\n" ); +/* TX RAM full may happen on a usual case. +* Logging is not needed. */ show_error =0 ;break ;case SPIDER_NET_GRFDFLLINT :/* fallthrough */
Quoted 9 lines · Jens Osterkamp
Ishizaki-san,
Quoted 4 lines
This patch partially works on celleb but remains following several problems.
1. It doesn't recover once an ethernet cable which is connected to aspider_netcard is unpluged.My understanding is that you are using the LINK interrupt to detect this. For the blade this is not connected but reenabling it wont hurt, I hope.
I would suggest just polling from a delayed work or a timer like sungem does.
Quoted 3 lines
I still dont see why you need different settings for different speed switches. This is getting to a point where access to some hardware would be handy. What exact phy are using anyway ?
Yeah, same question...
Quoted 7 lines
Quoted 4 lines
Furthermore, we have a problem that
poll_link()may succeed even when the auto-neg initial setting is for different network switch type, and the network card does not work on this case. We retry auto-neg with the another initial setting on this case.See above, could you give some more details why this is the case. Or maybe Ben knows more about this ?
No, I'm surprised too.
Ben.
Quoted 3 lines
We use bcm5461. There is a possibility that we don't know the appropriate setting which is applicable for both type of switches.
Have you tested the existing 54xx code in sungem_phy.c ? We use that with 5462 at least in K2 and all sorts of 54xx chips and it works fine... Just setup the right advertisement bits and call setup_aneg in the PHY ops. You don't even need to implement the "forced" fallback code that is in sungem. It's not necessary with most broadcom PHYs as they do that themselves, just setup aneg and poll the link from a timer, that's it. Once you get a link, then setup your GMACMODE based on the link speed.
I don't have the datasheet of the 5461 at hand but I doubt it's any different... Like other Broadcom 54xx PHYs, it might need some special initialization code to work around firmware bugs though...
Quoted 6 lines
We didn't investigate for the detail, but we met the following phenomena.
1. When auto-neg starts with Gbps setting and ethernet card is connected to a 100Mbps switch, LINK is not detected.
2. When auto-neg starts with 100/10Mbps setting and ethernet card is connected to Gbps switch, LINK is detected (poll_link()succeeds), but the network is not available.
That is very strange... I would need to review your code in more details or eventually have HW access to run my own experiments, but none of this should happen if things are setup properly. Also avoid relying on the link interrupt, it's a known cause of trouble. Just poll.
Ben.