Re: [PATCH 1/5] spidernet: add missing initialization

2008-01-17 Thread Ishizaki Kou
Jens-san,

 Hi Ishizaki,

 Linas has left the company and is no longer doing kernel related stuff,
 so I suggest, given Jeff is ok with that, that the two of us take over
 spidernet maintainership.
 (snip)
 Change maintainership for spidernet.

 Signed-off-by: Jens Osterkamp [EMAIL PROTECTED]

I apologize to my late reply.

I hope to accept your suggestion. But I have to get authorization
to take maintainership in my company. I have started negotiation
to my boss.


I can't check that spidernet driver works on Cell Blade, because I
don't have one.  So I hope you check spidernet driver works on Cell
Blade when it changes.

And then, will you review our latest patches?

Best regards,
Kou Ishizaki
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] spidernet: increase auto-negotiation timeout to 5 seconds

2008-01-10 Thread Ishizaki Kou
This patch extends the timeout for spidernet auto-negotiation.
Auto-negotiation often fails to finish in 2 seconds.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

Index: linux-powerpc-git/drivers/net/spider_net.h
===
--- linux-powerpc-git.orig/drivers/net/spider_net.h
+++ linux-powerpc-git/drivers/net/spider_net.h
@@ -52,7 +52,7 @@ extern char spider_net_driver_name[];
 
 #define SPIDER_NET_TX_TIMER(HZ/5)
 #define SPIDER_NET_ANEG_TIMER  (HZ)
-#define SPIDER_NET_ANEG_TIMEOUT2
+#define SPIDER_NET_ANEG_TIMEOUT5
 
 #define SPIDER_NET_RX_CSUM_DEFAULT 1
 
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] spidernet: revise link status logging

2008-01-10 Thread Ishizaki Kou
This patch revises the logging for link informations of spidernet.

  - The link down message is too verbose because auto-negotiation timeout
occurs periodically while an ethernet cable is not connected. 
  - We want to see the link result, and we think it should be displayed. 

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

Index: linux-powerpc-git/drivers/net/spider_net.c
===
--- linux-powerpc-git.orig/drivers/net/spider_net.c
+++ linux-powerpc-git/drivers/net/spider_net.c
@@ -2045,7 +2045,8 @@ static void spider_net_link_phy(unsigned
/* 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);
+   pr_debug(%s: link is down trying to bring it up\n,
+card-netdev-name);
 
switch (card-medium) {
case BCM54XX_COPPER:
@@ -2096,9 +2097,10 @@ static void spider_net_link_phy(unsigned
 
card-aneg_count = 0;
 
-   pr_debug(Found %s with %i Mbps, %s-duplex %sautoneg.\n,
-   phy-def-name, phy-speed, phy-duplex==1 ? Full : Half,
-   phy-autoneg==1 ?  : no );
+   pr_info(%s: link up, %i Mbps, %s-duplex %sautoneg.\n,
+   card-netdev-name, phy-speed,
+   phy-duplex == 1 ? Full : Half,
+   phy-autoneg == 1 ?  : no );
 
return;
 }
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] spidernet: add missing initialization

2008-01-10 Thread Ishizaki Kou
This patch fixes initialization of aneg_count and medium fields in
spider_net_card to make spidernet driver correctly sets link status.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

Index: linux-powerpc-git/drivers/net/spider_net.c
===
--- linux-powerpc-git.orig/drivers/net/spider_net.c
+++ linux-powerpc-git/drivers/net/spider_net.c
@@ -1399,6 +1399,8 @@ spider_net_link_reset(struct net_device 
spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0);
 
/* reset phy and setup aneg */
+   card-aneg_count = 0;
+   card-medium = BCM54XX_COPPER;
spider_net_setup_aneg(card);
mod_timer(card-aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER);
 
@@ -1982,6 +1984,8 @@ spider_net_open(struct net_device *netde
goto init_firmware_failed;
 
/* start probing with copper */
+   card-aneg_count = 0;
+   card-medium = BCM54XX_COPPER;
spider_net_setup_aneg(card);
if (card-phy.def-phy_id)
mod_timer(card-aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER);
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] spidernet: change interrupt masks

2008-01-10 Thread Ishizaki Kou
This patch changes spidernet interrupt masks.

 - unmask GDAINVAINT. There is an operation to do by spidernet
   interrupt handler.
 - mask some interrupts. There are no operations in the interrupt handler.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

Index: linux-powerpc-git/drivers/net/spider_net.h
===
--- linux-powerpc-git.orig/drivers/net/spider_net.h
+++ linux-powerpc-git/drivers/net/spider_net.h
@@ -159,9 +159,8 @@ extern char spider_net_driver_name[];
 
 /** interrupt mask registers */
 #define SPIDER_NET_INT0_MASK_VALUE 0x3f7fe2c7
-#define SPIDER_NET_INT1_MASK_VALUE 0x7ff7
-/* no MAC aborts - auto retransmission */
-#define SPIDER_NET_INT2_MASK_VALUE 0xffef7ff1
+#define SPIDER_NET_INT1_MASK_VALUE 0xfff2
+#define SPIDER_NET_INT2_MASK_VALUE 0x03f1
 
 /* we rely on flagged descriptor interrupts */
 #define SPIDER_NET_FRAMENUM_VALUE  0x
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] spidernet: fix error interrupt handling

2008-01-10 Thread Ishizaki Kou
In addition to the value of GHIINT0STS, spidernet interrupt handler
should check the values of GHIINT1STS/GHIINT2STS registers at the
beginning of spider_net_interrupt() so as not to drop error
interrupts.

GHIINT1STS/GHIINT2STS registers indicates some of erroneous conditions
in spidernet, and a few bits of GHIINT0STS register reflects these
conditions. But GHIINT0MSK masks these bits, so you should check these
conditions by reading GHIINT1STS/GHIINT2STS registers directly.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

Index: linux-powerpc-git/drivers/net/spider_net.c
===
--- linux-powerpc-git.orig/drivers/net/spider_net.c
+++ linux-powerpc-git/drivers/net/spider_net.c
@@ -1415,18 +1415,12 @@ spider_net_link_reset(struct net_device 
  * found when an interrupt is presented
  */
 static void
-spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
+spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg,
+   u32 error_reg1, u32 error_reg2)
 {
-   u32 error_reg1, error_reg2;
u32 i;
int show_error = 1;
 
-   error_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1STS);
-   error_reg2 = spider_net_read_reg(card, SPIDER_NET_GHIINT2STS);
-
-   error_reg1 = SPIDER_NET_INT1_MASK_VALUE;
-   error_reg2 = SPIDER_NET_INT2_MASK_VALUE;
-
/* check GHIINT0STS /
if (status_reg)
for (i = 0; i  32; i++)
@@ -1656,12 +1650,15 @@ spider_net_interrupt(int irq, void *ptr)
 {
struct net_device *netdev = ptr;
struct spider_net_card *card = netdev_priv(netdev);
-   u32 status_reg;
+   u32 status_reg, error_reg1, error_reg2;
 
status_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0STS);
-   status_reg = SPIDER_NET_INT0_MASK_VALUE;
+   error_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1STS);
+   error_reg2 = spider_net_read_reg(card, SPIDER_NET_GHIINT2STS);
 
-   if (!status_reg)
+   if (!(status_reg  SPIDER_NET_INT0_MASK_VALUE) 
+   !(error_reg1  SPIDER_NET_INT1_MASK_VALUE) 
+   !(error_reg2  SPIDER_NET_INT2_MASK_VALUE))
return IRQ_NONE;
 
if (status_reg  SPIDER_NET_RXINT ) {
@@ -1676,7 +1673,8 @@ spider_net_interrupt(int irq, void *ptr)
spider_net_link_reset(netdev);
 
if (status_reg  SPIDER_NET_ERRINT )
-   spider_net_handle_error_irq(card, status_reg);
+   spider_net_handle_error_irq(card, status_reg,
+   error_reg1, error_reg2);
 
/* clear interrupt sources */
spider_net_write_reg(card, SPIDER_NET_GHIINT0STS, status_reg);
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Cbe-oss-dev] [PATCH] spidernet: fix interrupt reason recognition

2007-08-29 Thread Ishizaki Kou

Linas-san,

Ishizaki Kou wrote:
 Linas Vepstas wrote:
  On Mon, Aug 20, 2007 at 10:13:27PM +0900, Ishizaki Kou wrote:
   Please apply this to 2.6.23.
  
  I'll review and forward shortly.  Kick me if you don't see a formal
  reply in a few days.
  
   And also, please apply the following Arnd-san's patch to fix a problem
   that spidernet driver sometimes causes a BUG_ON at open.
   
http://patchwork.ozlabs.org/cbe-oss-dev/patch?id=12211
  
  Are you sure? This patch no longer applies cleanly, in part because
 
 I see. I'll send another applicable patch.
 
  your patch [PATCH] spidernet: improve interrupt handling 
  from Mon, 09 Jul 2007 added a spider_net_enable_interrupts(card); 
  at the end of spider_net_open().  Because of this, it seems like 
  Arnd's patch is no longer needed, right?
 
 As you pointed out, we intended that [PATCH] spidernet: improve
 interrupt handling solves the same problem which Arnd's patch solves.
 
 When spider_net_open() is called, interrupt reasons sometimes remain
 on interrupt status register, even though they are masked by mask
 register.  With this patch, spider_net_interrupt() compares the value
 of interrupt status register with SPIDER_NET_INTX_MASK_VALUE, not with
 interrupt mask register value.  As a result, spider_net_interrupt()
 (which is called from request_irq() in spider_net_open()) starts
 polling and causes BUG_ON().
 
 So, netif_poll_enable() must be called before request_irq() is
 called. This is the reason that we also need Arnd's patch.


How about following two patches that I posted last week:

 http://patchwork.ozlabs.org/cbe-oss-dev/patch?id=12997
 http://patchwork.ozlabs.org/cbe-oss-dev/patch?id=13049

Best regards,
Kou Ishizaki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Cbe-oss-dev] [PATCH] spidernet: fix interrupt reason recognition

2007-08-21 Thread Ishizaki Kou
Linas Vepstas wrote:
 On Mon, Aug 20, 2007 at 10:13:27PM +0900, Ishizaki Kou wrote:
  Please apply this to 2.6.23.
 
 I'll review and forward shortly.  Kick me if you don't see a formal
 reply in a few days.
 
  And also, please apply the following Arnd-san's patch to fix a problem
  that spidernet driver sometimes causes a BUG_ON at open.
  
   http://patchwork.ozlabs.org/cbe-oss-dev/patch?id=12211
 
 Are you sure? This patch no longer applies cleanly, in part because

I see. I'll send another applicable patch.

 your patch [PATCH] spidernet: improve interrupt handling 
 from Mon, 09 Jul 2007 added a spider_net_enable_interrupts(card); 
 at the end of spider_net_open().  Because of this, it seems like 
 Arnd's patch is no longer needed, right?

As you pointed out, we intended that [PATCH] spidernet: improve
interrupt handling solves the same problem which Arnd's patch solves.

When spider_net_open() is called, interrupt reasons sometimes remain
on interrupt status register, even though they are masked by mask
register.  With this patch, spider_net_interrupt() compares the value
of interrupt status register with SPIDER_NET_INTX_MASK_VALUE, not with
interrupt mask register value.  As a result, spider_net_interrupt()
(which is called from request_irq() in spider_net_open()) starts
polling and causes BUG_ON().

So, netif_poll_enable() must be called before request_irq() is
called. This is the reason that we also need Arnd's patch.

Best regards,
Kou Ishizaki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] spidernet: enable poll() before registering interrupts

2007-08-21 Thread Ishizaki Kou
We must not call netif_poll_enable after enabling interrupts,
because an interrupt might come in and set the __LINK_STATE_RX_SCHED
bit before we get to clear that bit again. If that happens,
the next call to the -poll() function will oops.

Signed-off-by: Arnd Bergmann [EMAIL PROTECTED]
Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

I refreshed Arnd-san's patch.


Index: linux-powerpc-git/drivers/net/spider_net.c
===
--- linux-powerpc-git.orig/drivers/net/spider_net.c 2007-08-21 
16:58:44.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-08-21 17:11:07.0 
+0900
@@ -2030,6 +2030,7 @@ spider_net_open(struct net_device *netde
/* further enhancement: setup hw vlan, if needed */
 
result = -EBUSY;
+   netif_poll_enable(netdev);
if (request_irq(netdev-irq, spider_net_interrupt,
 IRQF_SHARED, netdev-name, netdev))
goto register_int_failed;
@@ -2038,13 +2039,13 @@ spider_net_open(struct net_device *netde
 
netif_start_queue(netdev);
netif_carrier_on(netdev);
-   netif_poll_enable(netdev);
 
spider_net_enable_interrupts(card);
 
return 0;
 
 register_int_failed:
+   netif_poll_disable(netdev);
spider_net_free_rx_chain_contents(card);
 alloc_skbs_failed:
spider_net_free_chain(card, card-rx_chain);
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] spidernet: fix interrupt reason recognition

2007-08-20 Thread Ishizaki Kou
This patch solves a problem that the spidernet driver sometimes fails
to handle IRQ.

The problem happens because,
- In Cell architecture, interrupts may arrive at an interrupt
  controller, even if they are masked by the setting on registers of
  devices. It happens when interrupt packets are sent just before 
  the interrupts are masked.
- spidernet interrupt handler compares interrupt reasons with
  interrupt masks, so when such interrupts occurs, spidernet interrupt
  handler returns IRQ_NONE.
- When all of interrupt handler return IRQ_NONE, linux kernel disables
  the IRQ and it no longer delivers interrupts to the interrupt handlers.

spidernet doesn't work after above sequence, because it can't receive
interrupts.
 
This patch changes spidernet interrupt handler that it compares
interrupt reason with SPIDER_NET_INTX_MASK_VALUE.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

Linas-san,

Please apply this to 2.6.23. Because this problem is sometimes happens
and we cannot use the ethernet port any more.

And also, please apply the following Arnd-san's patch to fix a problem
that spidernet driver sometimes causes a BUG_ON at open.

 http://patchwork.ozlabs.org/cbe-oss-dev/patch?id=12211


Index: linux-powerpc-git/drivers/net/spider_net.c
===
--- linux-powerpc-git.orig/drivers/net/spider_net.c 2007-07-19 
18:42:02.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-08-20 20:52:23.0 
+0900
@@ -1441,17 +1441,14 @@ static void
 spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
 {
u32 error_reg1, error_reg2;
-   u32 mask_reg1, mask_reg2;
u32 i;
int show_error = 1;
 
error_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1STS);
error_reg2 = spider_net_read_reg(card, SPIDER_NET_GHIINT2STS);
-   mask_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1MSK);
-   mask_reg2 = spider_net_read_reg(card,SPIDER_NET_GHIINT2MSK);
 
-   error_reg1 = mask_reg1;
-   error_reg2 = mask_reg2;
+   error_reg1 = SPIDER_NET_INT1_MASK_VALUE;
+   error_reg2 = SPIDER_NET_INT2_MASK_VALUE;
 
/* check GHIINT0STS /
if (status_reg)
@@ -1679,11 +1676,10 @@ spider_net_interrupt(int irq, void *ptr)
 {
struct net_device *netdev = ptr;
struct spider_net_card *card = netdev_priv(netdev);
-   u32 status_reg, mask_reg;
+   u32 status_reg;
 
status_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0STS);
-   mask_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0MSK);
-   status_reg = mask_reg;
+   status_reg = SPIDER_NET_INT0_MASK_VALUE;
 
if (!status_reg)
return IRQ_NONE;
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Cbe-oss-dev] [PATCH] spidernet: don't use debug flag

2007-07-13 Thread Ishizaki Kou
Linas-san,

 p.s. I tested ifdown/ifup, and didn't see any problems.
 Does your bug happen immediately, or does it take many attempts 
 to trigger it?

Thanks for your testing.

It happens immediately in our environment. It may be celleb specific.

Best regards,
Kou Ishizaki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Cbe-oss-dev] [PATCH] spidernet: don't use debug flag

2007-07-11 Thread Ishizaki Kou
Linas-san,

  GDTDCEIDIS flag is defined that it is for debug and should not be
used.
 
 !? Certainly, my spec doesn't say anything like this;

First, I'm sorry to say that GDTDCEDIS is for debug. It's my
misunderstanding.

My HW manual of SCC simply said that GDTDCEDIS must not be set(Is 
it same for you?).  But I don't know concretely what will go wrong 
by setting this bit.

 I don't know of any other way of turning off the descriptor 
 chain end interrupt; leaving it on hurts performance in a big way.
 
 I get the following TX performance numbers:
 
 pkt sz   rate w/o patch  rate w/patch
 (bytes)  (Mbits/sec) (Mbits/sec)
 ---  --  -
 400503 353
 200239  88
 100122  44
  60 73  26
 
 That's not quite a 3x performance degradation.
 
 In addition, with your patch, the number of interrupts jumps
 from just about zero, to about 55K/second. From what I can tell, 
 this huge interrupt rate eats up all the CPU cycles, which is
 why the performance drops so drasically.

I understand the influence for performance by setting GDTDCEDIS and
why you set this bit.

  We met some troubles on Celleb platform by setting this flag.
   -network does not recover after ifconfig down, then up operations.
 
 Can you be more specific?  I can't imagine why this flag would
 have anything to do with ifdown/ifup. The device open/close 
 routines should reset all hardware state; this shouldn't make
 any difference. (It doesn't for me, at least).  

Sorry, I have no more information that ifconfig down/up commands. All
about I know is that I met the phenomenon when GDTDCEDIS is set.

I need more investigation. Please drop the patch.

Best regards,
Kou Ishizaki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Cbe-oss-dev] [PATCH] spidernet: improve interrupt handling

2007-07-10 Thread Ishizaki Kou
Linas-san,

 On Mon, Jul 09, 2007 at 05:48:08PM +0900, Ishizaki Kou wrote:
  We intend this patch to improve spidernet interrupt handling to be
  more strict.  We had following problem and this patch solves it.
 
 Looks reasonable to me. I'll forward it upstream. In the future,

Thank you.

 could you use diff -Nupr? it adds some extra information
 (the name of the subroutine) to the patch chunks; this makes 
 it easier to read. 

I see. I will do so next time. 

Best regards,
Kou Ishizaki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] spidernet: improve interrupt handling

2007-07-09 Thread Ishizaki Kou
We intend this patch to improve spidernet interrupt handling to be
more strict.  We had following problem and this patch solves it.

 -when CONFIG_DEBUG_SHIRQ=y, request_irq() calls handler().
 -when spider_net_open() is called, it calls request_irq() which calls
  spider_net_interrupt().
 -if some specific interrupt bit is set at this timing, it calls
  netif_rx_schedule() and spider_net_poll() is scheduled.
 -spider_net_open() calls netif_poll_enable() which clears the bit 
  __LINK_STATE_RX_SCHED.
 -when spider_net_poll() is called, it calls netif_rx_complete() which
  causes BUG_ON() because __LINK_STATE_RX_SCHED is not set.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

Index: linux-powerpc-git/drivers/net/spider_net.c
diff -u linux-powerpc-git/drivers/net/spider_net.c:1.1.1.13 
linux-powerpc-git/drivers/net/spider_net.c:1.18
--- linux-powerpc-git/drivers/net/spider_net.c:1.1.1.13 Tue Jul  3 15:43:29 2007
+++ linux-powerpc-git/drivers/net/spider_net.c  Fri Jul  6 14:31:38 2007
@@ -1376,11 +1376,17 @@
 spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
 {
u32 error_reg1, error_reg2;
+   u32 mask_reg1, mask_reg2;
u32 i;
int show_error = 1;
 
error_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1STS);
error_reg2 = spider_net_read_reg(card, SPIDER_NET_GHIINT2STS);
+   mask_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1MSK);
+   mask_reg2 = spider_net_read_reg(card,SPIDER_NET_GHIINT2MSK);
+
+   error_reg1 = mask_reg1;
+   error_reg2 = mask_reg2;
 
/* check GHIINT0STS /
if (status_reg)
@@ -1609,9 +1615,11 @@
 {
struct net_device *netdev = ptr;
struct spider_net_card *card = netdev_priv(netdev);
-   u32 status_reg;
+   u32 status_reg, mask_reg;
 
status_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0STS);
+   mask_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0MSK);
+   status_reg = mask_reg;
 
if (!status_reg)
return IRQ_NONE;
@@ -1653,6 +1661,38 @@
 #endif /* CONFIG_NET_POLL_CONTROLLER */
 
 /**
+ * spider_net_enable_interrupts - enable interrupts
+ * @card: card structure
+ *
+ * spider_net_enable_interrupt enables several interrupts
+ */
+static void 
+spider_net_enable_interrupts(struct spider_net_card *card)
+{
+   spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK,
+SPIDER_NET_INT0_MASK_VALUE);
+   spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK,
+SPIDER_NET_INT1_MASK_VALUE);
+   spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK,
+SPIDER_NET_INT2_MASK_VALUE);
+}
+
+/**
+ * spider_net_disable_interrupts - disable interrupts
+ * @card: card structure
+ *
+ * spider_net_disable_interrupts disables all the interrupts
+ */
+static void 
+spider_net_disable_interrupts(struct spider_net_card *card)
+{
+   spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0);
+   spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0);
+   spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0);
+   spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0);
+}
+
+/**
  * spider_net_init_card - initializes the card
  * @card: card structure
  *
@@ -1672,6 +1712,7 @@
spider_net_write_reg(card, SPIDER_NET_GMACOPEMD,
spider_net_read_reg(card, SPIDER_NET_GMACOPEMD) | 0x4);
 
+   spider_net_disable_interrupts(card);
 }
 
 /**
@@ -1759,14 +1800,6 @@
spider_net_write_reg(card, SPIDER_NET_GMACOPEMD,
 SPIDER_NET_OPMODE_VALUE);
 
-   /* set interrupt mask registers */
-   spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK,
-SPIDER_NET_INT0_MASK_VALUE);
-   spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK,
-SPIDER_NET_INT1_MASK_VALUE);
-   spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK,
-SPIDER_NET_INT2_MASK_VALUE);
-
spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,
 SPIDER_NET_GDTBSTA);
 }
@@ -1941,6 +1974,8 @@
netif_carrier_on(netdev);
netif_poll_enable(netdev);
 
+   spider_net_enable_interrupts(card);
+
return 0;
 
 register_int_failed:
@@ -2113,11 +2148,7 @@
del_timer_sync(card-tx_timer);
del_timer_sync(card-aneg_timer);
 
-   /* disable/mask all interrupts */
-   spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0);
-   spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0);
-   spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0);
-   spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0);
+   spider_net_disable_interrupts(card);
 
free_irq(netdev-irq, netdev);
 
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] spidernet: remove unnecessary accesses to phy

2007-05-09 Thread Ishizaki Kou
This patch removes unnecessary accesses to phy registers.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

Index: linux-powerpc-git/drivers/net/spider_net.c
diff -u linux-powerpc-git/drivers/net/spider_net.c:1.1.1.9 
linux-powerpc-git/drivers/net/spider_net.c:1.14
--- linux-powerpc-git/drivers/net/spider_net.c:1.1.1.9  Tue May  8 09:41:28 2007
+++ linux-powerpc-git/drivers/net/spider_net.c  Tue May  8 10:16:59 2007
@@ -175,12 +175,10 @@
 {
struct mii_phy *phy = card-phy;
u32 advertise = 0;
-   u16 bmcr, bmsr, stat1000, estat;
+   u16 bmsr, estat;
 
-   bmcr = spider_net_read_phy(card-netdev, phy-mii_id, MII_BMCR);
-   bmsr = spider_net_read_phy(card-netdev, phy-mii_id, MII_BMSR);
-   stat1000 = spider_net_read_phy(card-netdev, phy-mii_id, MII_STAT1000);
-   estat= spider_net_read_phy(card-netdev, phy-mii_id, MII_ESTATUS);
+   bmsr  = spider_net_read_phy(card-netdev, phy-mii_id, MII_BMSR);
+   estat = spider_net_read_phy(card-netdev, phy-mii_id, MII_ESTATUS);
 
if (bmsr  BMSR_10HALF)
advertise |= ADVERTISED_10baseT_Half;
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] spidernet: load firmware when open

2007-02-14 Thread Ishizaki Kou
This moves calling init_firmware() from spider_net_probe() to
spider_net_open() so as to use the driver by built-in.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
Acked-by: Linas Vepstas [EMAIL PROTECTED]
Acked-by: Benjamin Herrenschmidt [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-14 
12:13:38.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-14 12:17:28.0 
+0900
@@ -1727,6 +1727,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
  *
@@ -1741,6 +1859,10 @@
struct spider_net_card *card = netdev_priv(netdev);
int result;
 
+   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)
@@ -1784,6 +1906,7 @@
spider_net_free_chain(card, card-tx_chain);
 

[PATCH 3/4] spidernet: spidernet: add support for Celleb

2007-02-14 Thread Ishizaki Kou
This adds or changes some HW specific settings for spider_net on
Celleb.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
Acked-by: Linas Vepstas [EMAIL PROTECTED]
Acked-by: Benjamin Herrenschmidt [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/Kconfig   2007-02-14 13:33:09.0 
+0900
+++ linux-powerpc-git/drivers/net/Kconfig   2007-02-14 13:33:17.0 
+0900
@@ -2243,7 +2243,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
--- org-linux-powerpc-git/drivers/net/spider_net.h  2007-02-14 
12:13:44.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.h  2007-02-14 13:31:22.0 
+0900
@@ -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_VALUE0x0063
+/* ETOMOD signal is brought to PHY reset. bit 2 must be 1 in Celleb */
+#define SPIDER_NET_OPMODE_VALUE0x0067
 /*#define SPIDER_NET_OPMODE_VALUE  0x001b0062*/
 #define SPIDER_NET_LENLMT_VALUE0x0908
 
--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-14 
12:19:28.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-14 13:31:22.0 
+0900
@@ -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]
@@ -1627,6 +1628,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);
+
 }
 
 /**
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] spidernet: remove txram full logging

2007-02-14 Thread Ishizaki Kou
This removes logging for SPIDER_NET_GTMFLLINT interrupts.
Since the interrupts are not irregular, and they happen frequently
when using 100Mbps network switches.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
Acked-by: Linas Vepstas [EMAIL PROTECTED]
Acked-by: Benjamin Herrenschmidt [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-14 
13:35:20.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-14 13:36:01.0 
+0900
@@ -1444,8 +1444,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 */
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] spidernet: support for Celleb

2007-02-14 Thread Ishizaki Kou
Jeff-san,

This is a revised patch set for spider_net to work on Celleb.

This patch set is based on Jens-san's v3 phy patch and Linas-san's
spider_net patch.

Please apply our patch set with them.


Note: You need not apply Jens-san's spidernet patch because our patch
set includes it.

Best regards,
Kou Ishizaki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] spidernet: autoneg support for Celleb

2007-02-14 Thread Ishizaki Kou
Add auto negotiation support for Celleb. 

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
Acked-by: Linas Vepstas [EMAIL PROTECTED]
Acked-by: Benjamin Herrenschmidt [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.h  2007-02-14 
11:56:03.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.h  2007-02-14 12:05:11.0 
+0900
@@ -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_TIMEOUT2
 
 #define SPIDER_NET_RX_CSUM_DEFAULT 1
 
@@ -104,6 +106,7 @@
 
 #define SPIDER_NET_GMACOPEMD   0x0100
 #define SPIDER_NET_GMACLENLMT  0x0108
+#define SPIDER_NET_GMACST  0x0110
 #define SPIDER_NET_GMACINTEN   0x0118
 #define SPIDER_NET_GMACPHYCTRL 0x0120
 
@@ -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  ( 0x  \
  (~SPIDER_NET_TXINT)  \
- (~SPIDER_NET_RXINT) )
+ (~SPIDER_NET_RXINT)  \
+ (~SPIDER_NET_LINKINT) )
 
 #define SPIDER_NET_GPREXEC 0x8000
 #define SPIDER_NET_GPRDAT_MASK 0x
@@ -439,12 +445,16 @@
struct pci_dev *pdev;
struct mii_phy phy;
 
+   int medium;
+
void __iomem *regs;
 
struct spider_net_descr_chain tx_chain;
struct spider_net_descr_chain rx_chain;
struct spider_net_descr *low_watermark;
 
+   int aneg_count;
+   struct timer_list aneg_timer;
struct timer_list tx_timer;
struct work_struct tx_timeout_task;
atomic_t tx_timeout_task_counter;
--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-14 
11:55:57.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-14 12:09:06.0 
+0900
@@ -165,6 +165,38 @@
return readvalue;
 }
 
+/** spider_net_setup_aneg - initial auto-negotiation setup
+ * @card: device structure 
+ **/
+static void
+spider_net_setup_aneg(struct spider_net_card *card)
+{
+   struct mii_phy *phy = card-phy;
+   u32 advertise = 0;
+   u16 bmsr, estat;
+
+   bmsr = spider_net_read_phy(card-netdev, phy-mii_id, MII_BMSR);
+   estat= spider_net_read_phy(card-netdev, phy-mii_id, MII_ESTATUS);
+
+   if (bmsr  BMSR_10HALF)
+   advertise |= ADVERTISED_10baseT_Half;
+   if (bmsr  BMSR_10FULL)
+   advertise |= ADVERTISED_10baseT_Full;
+   if (bmsr  BMSR_100HALF)
+   advertise |= ADVERTISED_100baseT_Half;
+   if (bmsr  BMSR_100FULL)
+   advertise |= ADVERTISED_100baseT_Full;
+
+   if ((bmsr  BMSR_ESTATEN)  (estat  ESTATUS_1000_TFULL))
+   advertise |= SUPPORTED_1000baseT_Full;
+   if ((bmsr  BMSR_ESTATEN)  (estat  ESTATUS_1000_THALF))
+   advertise |= SUPPORTED_1000baseT_Half;
+
+   mii_phy_probe(phy, phy-mii_id);
+   phy-def-ops-setup_aneg(phy, advertise);
+
+}
+
 /**
  * spider_net_rx_irq_off - switch off rx irq on this spider card
  * @card: device structure
@@ -1273,6 +1305,33 @@
 }
 
 /**
+ * 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 */
+   spider_net_setup_aneg(card);
+   mod_timer(card-aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER);
+
+}
+
+/**
  * spider_net_handle_error_irq - handles errors raised by an interrupt
  * @card: card structure
  * @status_reg: interrupt status register 0 (GHIINT0STS)
@@ -1525,6 +1584,9 @@
if (status_reg  SPIDER_NET_TXINT)
netif_rx_schedule(netdev);
 
+   if (status_reg  SPIDER_NET_LINKINT)
+   spider_net_link_reset(netdev);
+
if (status_reg  SPIDER_NET_ERRINT )
spider_net_handle_error_irq(card, status_reg);
 
@@ -1649,8 +1711,6 @@
 
spider_net_write_reg(card, SPIDER_NET_GMACLENLMT,
 SPIDER_NET_LENLMT_VALUE);
-   spider_net_write_reg(card, SPIDER_NET_GMACMODE,
-SPIDER_NET_MACMODE_VALUE);
spider_net_write_reg(card, SPIDER_NET_GMACOPEMD,

Re: [PATCH 0/4] spidernet: support for Celleb

2007-02-13 Thread Ishizaki Kou
Linas-san, Jens-san,

 Tested this series of patches together with Jen's version 3 patch,
 it worked for me. Code looks reasonable.  Thus

We tried Jens-san's v3 patch on Celleb, and it works for us.

We also need Linas-san's patch set which includes bug-fix and makes
the code compilable etc. But our previous patch set conflicts with
Linas-san's patch set.

So we will post a revised patch set for spider_net, which is based on
Jens-san's phy patch and Linas-san's spider_net patch.  The revised
patch set will differ from our previous patch set only by editorial
changes, so we think it will be ready to go in.


Best regards,
Kou Ishizaki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] spidernet: autoneg support for Celleb

2007-02-07 Thread Ishizaki Kou
Add auto negotiation support for Celleb. 

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---


--- org-linux-powerpc-git/drivers/net/spider_net.h  2007-02-06 
20:24:35.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.h  2007-02-06 20:30:35.0 
+0900
@@ -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_TIMEOUT2
 
 #define SPIDER_NET_RX_CSUM_DEFAULT 1
 
@@ -104,6 +106,7 @@
 
 #define SPIDER_NET_GMACOPEMD   0x0100
 #define SPIDER_NET_GMACLENLMT  0x0108
+#define SPIDER_NET_GMACST  0x0110
 #define SPIDER_NET_GMACINTEN   0x0118
 #define SPIDER_NET_GMACPHYCTRL 0x0120
 
@@ -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  ( 0x  \
  (~SPIDER_NET_TXINT)  \
- (~SPIDER_NET_RXINT) )
+ (~SPIDER_NET_RXINT)  \
+ (~SPIDER_NET_LINKINT) )
 
 #define SPIDER_NET_GPREXEC 0x8000
 #define SPIDER_NET_GPRDAT_MASK 0x
@@ -442,6 +448,8 @@
struct spider_net_descr_chain rx_chain;
struct spider_net_descr *low_watermark;
 
+   int aneg_count;
+   struct timer_list aneg_timer;
struct timer_list tx_timer;
struct work_struct tx_timeout_task;
atomic_t tx_timeout_task_counter;
--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-06 
20:24:35.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-06 20:30:57.0 
+0900
@@ -165,6 +165,40 @@
return readvalue;
 }
 
+/** spider_net_setup_aneg - initial auto-negotiation setup
+ * @card: device structure 
+ **/
+static void
+spider_net_setup_aneg(struct spider_net_card *card)
+{
+   struct mii_phy *phy = card-phy;
+   u32 advertise = 0;
+   u16 bmcr, bmsr, stat1000, estat;
+
+   bmcr = spider_net_read_phy(card-netdev, phy-mii_id, MII_BMCR);
+   bmsr = spider_net_read_phy(card-netdev, phy-mii_id, MII_BMSR);
+   stat1000 = spider_net_read_phy(card-netdev, phy-mii_id, MII_STAT1000);
+   estat= spider_net_read_phy(card-netdev, phy-mii_id, MII_ESTATUS);
+
+   if (bmsr  BMSR_10HALF)
+   advertise |= ADVERTISED_10baseT_Half;
+   if (bmsr  BMSR_10FULL)
+   advertise |= ADVERTISED_10baseT_Full;
+   if (bmsr  BMSR_100HALF)
+   advertise |= ADVERTISED_100baseT_Half;
+   if (bmsr  BMSR_100FULL)
+   advertise |= ADVERTISED_100baseT_Full;
+
+   if ((bmsr  BMSR_ESTATEN)  (estat  ESTATUS_1000_TFULL))
+   advertise |= SUPPORTED_1000baseT_Full;
+   if ((bmsr  BMSR_ESTATEN)  (estat  ESTATUS_1000_THALF))
+   advertise |= SUPPORTED_1000baseT_Half;
+
+   mii_phy_probe(phy, phy-mii_id);
+   phy-def-ops-setup_aneg(phy, advertise);
+
+}
+
 /**
  * spider_net_rx_irq_off - switch off rx irq on this spider card
  * @card: device structure
@@ -1244,6 +1278,33 @@
 }
 
 /**
+ * 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 */
+   spider_net_setup_aneg(card);
+   mod_timer(card-aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER);
+
+}
+
+/**
  * spider_net_handle_error_irq - handles errors raised by an interrupt
  * @card: card structure
  * @status_reg: interrupt status register 0 (GHIINT0STS)
@@ -1496,6 +1557,9 @@
if (status_reg  SPIDER_NET_TXINT)
netif_rx_schedule(netdev);
 
+   if (status_reg  SPIDER_NET_LINKINT)
+   spider_net_link_reset(netdev);
+
if (status_reg  SPIDER_NET_ERRINT )
spider_net_handle_error_irq(card, status_reg);
 
@@ -1620,8 +1684,6 @@
 
spider_net_write_reg(card, SPIDER_NET_GMACLENLMT,
 SPIDER_NET_LENLMT_VALUE);
-   spider_net_write_reg(card, SPIDER_NET_GMACMODE,
-SPIDER_NET_MACMODE_VALUE);
spider_net_write_reg(card, SPIDER_NET_GMACOPEMD,
 SPIDER_NET_OPMODE_VALUE);
 
@@ -1653,6 +1715,11 @@

[PATCH 2/4] spidernet: load firmware when open

2007-02-07 Thread Ishizaki Kou
This patch moves calling init_firmware() from spider_net_probe() to
spider_net_open() so as to use the driver by built-in.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-06 
20:35:55.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-06 20:39:27.0 
+0900
@@ -1700,6 +1700,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
  *
@@ -1715,6 +1833,10 @@
struct spider_net_descr *descr;
int result;
 
+   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)
@@ -1765,6 +1887,7 @@
spider_net_free_chain(card, card-tx_chain);
 alloc_tx_failed:
del_timer_sync(card-aneg_timer);
+init_firmware_failed:
return result;
 }
 
@@ -1876,124 

[PATCH 3/4] spidernet: spidernet: add support for Celleb

2007-02-07 Thread Ishizaki Kou
This patch adds or changes some HW specific settings for spider_net on
Celleb.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/Kconfig   2007-02-06 20:41:01.0 
+0900
+++ linux-powerpc-git/drivers/net/Kconfig   2007-02-06 20:41:44.0 
+0900
@@ -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
--- org-linux-powerpc-git/drivers/net/spider_net.h  2007-02-06 
20:35:51.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.h  2007-02-06 20:41:44.0 
+0900
@@ -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_VALUE0x0063
+/* ETOMOD signal is brought to PHY reset. bit 2 must be 1 in Celleb */
+#define SPIDER_NET_OPMODE_VALUE0x0067
 /*#define SPIDER_NET_OPMODE_VALUE  0x001b0062*/
 #define SPIDER_NET_LENLMT_VALUE0x0908
 
--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-06 
20:41:22.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-06 20:41:44.0 
+0900
@@ -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]
@@ -1600,6 +1601,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);
+
 }
 
 /**
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] spidernet: remove txram full logging

2007-02-07 Thread Ishizaki Kou
This patches removes logging for SPIDER_NET_GTMFLLINT interrupts.
Since the interrupts are not irregular, and they happen frequently
when using 100Mbps network switches.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-06 
20:44:47.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-06 20:48:38.0 
+0900
@@ -1417,8 +1417,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 */
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] spidernet : fix memory leak in spider_net_stop

2007-02-07 Thread Ishizaki Kou
Jeff-san,

 Jens Osterkamp wrote:
  We forget to call spider_net_free_rx_chain_contents which does the
  actual dev_kfree_skb. New skbs are allocated from skbuff_head_cache
  on each ifconfig up letting the cache grow infinitely.
  
  This patch fixes it.
  
  Signed-off-by: Jens Osterkamp [EMAIL PROTECTED]
 
 applied

This fix was applied twice to netdev-2.6.git#upstream.
Because Linas-san's patch has been applied to netdev-2.6.git#upstream.

Best regards,
Kou Ishizaki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: spidernet: dynamic phy setup code

2007-02-06 Thread Ishizaki Kou
Ben-san, Jens-san

Thanks for your comments and advices.
First, we should apologize to you that some troubles which we informed
about spidernet auto-negotiation are caused by our mistake.
We used wrong MACRO for advertise variable to
phy-def-ops-setup_aneg(). 

We will post the revised patch for spider_net.
Following are the current status of troubles we informed.

(1)
- if (card-aneg_count  10) {
-  /* 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.
Solved.

We are now able to use Gbps switches and 10/100Mbps switches with 
the same advertise setting and we don't need to use is1000.
The re_setup is not necessary and they are removed in the revised patch.

2.
 - 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.
Pending(No problem, if they don't cause any trouble on Cell Blades).

By the way, why do you suggest to use polling for auto-neg, Ben-san? 
Is there a merit to use polling, or is there a problem to use interrupt?
Sorry, we couldn't find the reason why sungem use polling for auto-neg. 

They might not be necessary, if we use polling to handle LINK status as
Ben-san said.

3
 - mii_phy_probe(phy, phy-mii_id);
 It seems that PHY reset is necessary before auto negotiation,
 in the case that ethernet card is disconnected from an ethernet switch
 then connected to another ethernet switch.
 We can't call directly reset routine from driver, so we call
mii_phy_probe().
Pending.

After all, we need phy reset.
 If you really need to reset it, then change sungem_phy.c to export the
 reset function. But I'm surprised you need that. Another option is to
 reset the PHY in your PHY's setup_aneg() function.
We still wonder which is the best way, and mii_phy_probe() still remains
so far.

Best regards,
Kou Ishizaki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: spidernet: dynamic phy setup code

2007-02-02 Thread Ishizaki Kou
Jens-san,

Thanks for your comments.

Ishizaki-san,

 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. 

My understanding is that you are using the LINK interrupt to detect this.

Yes. We use the LINK interrupt for this purpose.

For the blade this is not connected but reenabling it wont hurt, I hope.

 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)
 - if (card-aneg_count  10) {
 -  /* 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.

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.

 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.

 #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)
 - 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.

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.

 (3)
 - 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().

IMHO using mii_phy_probe is the right way to do this.

OK. We will do so.

 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
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/PATCH 2.6.20-rc6 1/4] spidernet: autoneg support for Celleb

2007-02-02 Thread Ishizaki Kou
Add auto negotiation support for Celleb. 

This patch is just for a test. Please try this, if you can.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.h  2007-02-02 
14:24:26.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.h  2007-02-02 14:24:45.0 
+0900
@@ -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_TIMEOUT2
 
 #define SPIDER_NET_RX_CSUM_DEFAULT 1
 
@@ -104,6 +106,7 @@
 
 #define SPIDER_NET_GMACOPEMD   0x0100
 #define SPIDER_NET_GMACLENLMT  0x0108
+#define SPIDER_NET_GMACST  0x0110
 #define SPIDER_NET_GMACINTEN   0x0118
 #define SPIDER_NET_GMACPHYCTRL 0x0120
 
@@ -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  ( 0x  \
  (~SPIDER_NET_TXINT)  \
- (~SPIDER_NET_RXINT) )
+ (~SPIDER_NET_RXINT)  \
+ (~SPIDER_NET_LINKINT) )
 
 #define SPIDER_NET_GPREXEC 0x8000
 #define SPIDER_NET_GPRDAT_MASK 0x
@@ -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;
--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-02 
14:24:22.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-02 14:26:17.0 
+0900
@@ -165,6 +165,57 @@
return readvalue;
 }
 
+/** spider_net_setup_aneg - initial auto-negotiation setup
+ * @card: device structure 
+ **/
+static void
+spider_net_setup_aneg(struct spider_net_card *card)
+{
+   struct mii_phy *phy = card-phy;
+   u32 advertise = 0;
+   u16 bmcr, bmsr, ctrl1000, stat1000, estat;
+
+   bmcr = spider_net_read_phy(card-netdev, phy-mii_id, MII_BMCR);
+   bmsr = spider_net_read_phy(card-netdev, phy-mii_id, MII_BMSR);
+   ctrl1000 = spider_net_read_phy(card-netdev, phy-mii_id, MII_CTRL1000);
+   stat1000 = spider_net_read_phy(card-netdev, phy-mii_id, MII_STAT1000);
+   estat= spider_net_read_phy(card-netdev, phy-mii_id, MII_ESTATUS);
+
+   if (bmsr  BMSR_10HALF)
+   advertise |= ADVERTISE_10HALF;
+   if (bmsr  BMSR_10FULL)
+   advertise |= ADVERTISE_10FULL;
+   if (bmsr  BMSR_100HALF)
+   advertise |= ADVERTISE_100HALF;
+   if (bmsr  BMSR_100FULL)
+   advertise |= ADVERTISE_100FULL;
+   if (bmsr  BMSR_100BASE4)
+   advertise |= ADVERTISE_100BASE4;
+
+   mii_phy_probe(phy, phy-mii_id);
+
+   if (card-is1000) {
+   if ((bmsr  BMSR_ESTATEN)  (estat  ESTATUS_1000_TFULL)) {
+   advertise |= ADVERTISE_1000XFULL;
+   ctrl1000 |= ADVERTISE_1000FULL;
+   }
+   if ((bmsr  BMSR_ESTATEN)  (estat  ESTATUS_1000_THALF)) {
+   advertise |= ADVERTISE_1000XHALF;
+   ctrl1000 |= ADVERTISE_1000HALF;
+   }
+
+   spider_net_write_phy(card-netdev, phy-mii_id,
+MII_CTRL1000, ctrl1000);
+
+
+   phy-def-ops-setup_aneg(phy, advertise);
+   } else {
+   bmcr |= (BMCR_ANRESTART | BMCR_ANENABLE);
+   spider_net_write_phy(card-netdev, phy-mii_id,
+MII_BMCR, bmcr);
+   }
+}
+
 /**
  * spider_net_rx_irq_off - switch off rx irq on this spider card
  * @card: device structure
@@ -1245,6 +1296,33 @@
 }
 
 /**
+ * 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 */
+   spider_net_setup_aneg(card);
+   mod_timer(card-aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER);
+
+}
+
+/**
  * spider_net_handle_error_irq - handles errors raised by an interrupt
  * @card: card structure
  * @status_reg: interrupt status register 0 

[RFC/PATCH 2.6.20-rc6 2/4] spidernet: load firmaware when open

2007-02-02 Thread Ishizaki Kou
This 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.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-02 
14:29:17.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-02 14:29:39.0 
+0900
@@ -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:

[RFC/PATCH 2.6.20-rc6 3/4] spidernet: add support for Celleb

2007-02-02 Thread Ishizaki Kou
This 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.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/Kconfig   2007-02-02 14:34:19.0 
+0900
+++ linux-powerpc-git/drivers/net/Kconfig   2007-02-02 14:32:18.0 
+0900
@@ -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
--- org-linux-powerpc-git/drivers/net/spider_net.h  2007-02-02 
14:29:13.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.h  2007-02-02 14:32:18.0 
+0900
@@ -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_VALUE0x0063
+/* ETOMOD signal is brought to PHY reset. bit 2 must be 1 in Celleb */
+#define SPIDER_NET_OPMODE_VALUE0x0067
 /*#define SPIDER_NET_OPMODE_VALUE  0x001b0062*/
 #define SPIDER_NET_LENLMT_VALUE0x0908
 
--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-02 
14:31:39.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-02 14:32:18.0 
+0900
@@ -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);
+
 }
 
 /**
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/PATCH 2.6.20-rc6 4/4] spidernet: remove txram full logging

2007-02-02 Thread Ishizaki Kou
This 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.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-02-02 
14:35:14.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-02-02 14:35:49.0 
+0900
@@ -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 */
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Cbe-oss-dev] spidernet: dynamic phy setup code

2007-02-01 Thread Ishizaki Kou
I apologize if you received this mail many times.


Jens-san

 This patch modifies the patch submitted by Kou Ishizaki to make it
work on the
 blade
(http://marc.theaimsgroup.com/?l=linux-netdevm=116593424505539w=2).
 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)
- if (card-aneg_count  10) {
-  /* 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)
- 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)
- 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
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/4] spidernet: add support for Celleb

2007-01-24 Thread Ishizaki Kou
Jens-san,

   This is a revised version of the patch set for spider_net driver
   that works on Toshiba Cell Refererence Set (aka Celleb).
  
   This patch set is based on netdev-2.6.git#upstream.
 
  Jens, can you give that a go on our blades see if it doesn't break
  anything ? We are all at LCA here so it's a bit hard to test !
 
 Nope, doesn't work for us...
 
 I have a patch based on Ishizaki's previous patch which I think will work
 on Celleb. Will post it here when I have adapted it to the new version.

Thank you for testing our patch and we are sorry that our patch does
not work on Cell Blade.

We will test your modified patch on celleb when you post it.

Best regards,
Kou Ishizaki
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] spidernet: add support for Celleb

2007-01-17 Thread Ishizaki Kou
Dear everyone,

This is a revised version of the patch set for spider_net driver
that works on Toshiba Cell Refererence Set (aka Celleb).

This patch set is based on netdev-2.6.git#upstream.

Best regards,
Kou Ishizaki
Toshiba
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] spidernet: add auto negotiation on Celleb

2007-01-17 Thread Ishizaki Kou
This patch enables spider_net driver to use auto negotiation on
Celleb. This driver also tries traditional link methods(setup_force()
and enable_fibre()). This driver is designed so as to work a PHY that
is not able to negotiate automatically, but we didn't test on it.


Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.h  2007-01-15 
10:37:48.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.h  2007-01-15 10:41:25.0 
+0900
@@ -50,6 +50,7 @@
 #define SPIDER_NET_TX_DESCRIPTORS_MAX  512
 
 #define SPIDER_NET_TX_TIMER(HZ/5)
+#define SPIDER_NET_ANEG_TIMER  (HZ)
 
 #define SPIDER_NET_RX_CSUM_DEFAULT 1
 
@@ -104,6 +105,7 @@
 
 #define SPIDER_NET_GMACOPEMD   0x0100
 #define SPIDER_NET_GMACLENLMT  0x0108
+#define SPIDER_NET_GMACST  0x0110
 #define SPIDER_NET_GMACINTEN   0x0118
 #define SPIDER_NET_GMACPHYCTRL 0x0120
 
@@ -333,9 +335,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  ( 0x  \
  (~SPIDER_NET_TXINT)  \
- (~SPIDER_NET_RXINT) )
+ (~SPIDER_NET_RXINT)  \
+ (~SPIDER_NET_LINKINT) )
 
 #define SPIDER_NET_GPREXEC 0x8000
 #define SPIDER_NET_GPRDAT_MASK 0x
@@ -442,6 +447,10 @@
struct spider_net_descr_chain rx_chain;
struct spider_net_descr *low_watermark;
 
+   int aneg_count;
+   int forced;
+   int is1000;
+   struct timer_list aneg_timer;
struct timer_list tx_timer;
struct work_struct tx_timeout_task;
atomic_t tx_timeout_task_counter;
--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-01-15 
10:37:48.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-01-15 10:48:17.0 
+0900
@@ -165,6 +165,74 @@
return readvalue;
 }
 
+/** spider_net_setup_forced - initial force setup
+ * @card: device structure 
+ * @speed: speed
+ * @fd: duplex mode
+ **/
+static void
+spider_net_setup_forced(struct spider_net_card *card, int speed, int fd)
+{
+   struct mii_phy *phy = card-phy;
+
+   card-forced = 1;
+   if (phy-def-ops-setup_forced)
+   phy-def-ops-setup_forced(phy, speed, fd);
+
+   phy-def-ops-enable_fiber(phy);
+}
+
+/** spider_net_setup_aneg - initial auto-negotiation setup
+ * @card: device structure 
+ **/
+static void
+spider_net_setup_aneg(struct spider_net_card *card)
+{
+   struct mii_phy *phy = card-phy;
+   u32 advertise = 0;
+   u16 bmcr, bmsr, ctrl1000, stat1000, estat;
+
+   card-forced = 0;
+   bmcr = spider_net_read_phy(card-netdev, phy-mii_id, MII_BMCR);
+   bmsr = spider_net_read_phy(card-netdev, phy-mii_id, MII_BMSR);
+   ctrl1000 = spider_net_read_phy(card-netdev, phy-mii_id, MII_CTRL1000);
+   stat1000 = spider_net_read_phy(card-netdev, phy-mii_id, MII_STAT1000);
+   estat= spider_net_read_phy(card-netdev, phy-mii_id, MII_ESTATUS);
+
+   if (bmsr  BMSR_10HALF)
+   advertise |= ADVERTISE_10HALF;
+   if (bmsr  BMSR_10FULL)
+   advertise |= ADVERTISE_10FULL;
+   if (bmsr  BMSR_100HALF)
+   advertise |= ADVERTISE_100HALF;
+   if (bmsr  BMSR_100FULL)
+   advertise |= ADVERTISE_100FULL;
+   if (bmsr  BMSR_100BASE4)
+   advertise |= ADVERTISE_100BASE4;
+
+   if (card-is1000) {
+   if ((bmsr  BMSR_ESTATEN)  (estat  ESTATUS_1000_TFULL)) {
+   advertise |= ADVERTISE_1000XFULL;
+   ctrl1000 |= ADVERTISE_1000FULL;
+   }
+   if ((bmsr  BMSR_ESTATEN)  (estat  ESTATUS_1000_THALF)) {
+   advertise |= ADVERTISE_1000XHALF;
+   ctrl1000 |= ADVERTISE_1000HALF;
+   }
+
+   spider_net_write_phy(card-netdev, phy-mii_id,
+MII_CTRL1000, ctrl1000);
+   spider_net_write_reg(card, SPIDER_NET_GMACMODE, 0x0001);
+
+   phy-def-ops-setup_aneg(phy, advertise);
+   } else {
+   spider_net_write_reg(card, SPIDER_NET_GMACMODE, 0);
+   bmcr |= (BMCR_ANRESTART | BMCR_ANENABLE);
+   spider_net_write_phy(card-netdev, phy-mii_id,
+MII_BMCR, bmcr);
+   }
+}
+
 /**
  * spider_net_rx_irq_off - switch off rx irq on this spider card
  * @card: device structure
@@ -1244,6 +1312,29 @@
 }
 
 /**
+ * spider_net_link_reset
+ * @netdev: net device structure
+ *
+ */
+static void
+spider_net_link_reset(struct net_device *netdev)
+{
+
+   struct spider_net_card *card = netdev_priv(netdev);

[PATCH 2/4] spidernet: call init_firmware at open

2007-01-17 Thread Ishizaki Kou
This patch moves calling init_firmware() from spider_net_probe() to
spider_net_open() so as to use the driver by built-in.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-01-15 
10:57:23.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-01-15 11:02:45.0 
+0900
@@ -1730,6 +1730,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
  *
@@ -1745,6 +1863,10 @@
struct spider_net_descr *descr;
int result;
 
+   result = spider_net_init_firmware(card);
+   if (result)
+   goto init_firmware_failed;
+
spider_net_setup_forced(card, SPEED_1000, DUPLEX_FULL);
mod_timer(card-aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER);
 
@@ -1793,6 +1915,7 @@
spider_net_free_chain(card, card-tx_chain);
 alloc_tx_failed:
del_timer_sync(card-aneg_timer);
+init_firmware_failed:
return 

[PATCH 3/4] spidernet: add support for Celleb

2007-01-17 Thread Ishizaki Kou
This patch adds or changes some HW specific settings for spider_net on
Celleb.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/Kconfig   2007-01-15 10:37:30.0 
+0900
+++ linux-powerpc-git/drivers/net/Kconfig   2007-01-15 11:06:57.0 
+0900
@@ -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
--- org-linux-powerpc-git/drivers/net/spider_net.h  2007-01-15 
10:57:19.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.h  2007-01-15 11:06:57.0 
+0900
@@ -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]
@@ -183,7 +184,8 @@
 
 /* pause frames: automatic, no upper retransmission count */
 /* outside loopback mode: ETOMOD signal dont matter, not connected */
-#define SPIDER_NET_OPMODE_VALUE0x0063
+/* ETOMOD signal is brought to PHY reset. bit 2 must be 1 in Celleb */
+#define SPIDER_NET_OPMODE_VALUE0x0067
 /*#define SPIDER_NET_OPMODE_VALUE  0x001b0062*/
 #define SPIDER_NET_LENLMT_VALUE0x0908
 
--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-01-15 
11:06:10.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-01-15 11:06:57.0 
+0900
@@ -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]
@@ -1630,6 +1631,10 @@
 
spider_net_write_reg(card, SPIDER_NET_CKRCTRL,
 SPIDER_NET_CKRCTRL_RUN_VALUE);
+
+   spider_net_write_reg(card, SPIDER_NET_GMACOPEMD,
+   spider_net_read_reg(card, SPIDER_NET_GMACOPEMD) | 0x4);
+
 }
 
 /**

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] spidernet: remove txram full logging

2007-01-17 Thread Ishizaki Kou
This patches removes logging for SPIDER_NET_GTMFLLINT interrupts.
Since the interrupts are not irregular, and they happen frequently
when using 100Mbps network switches.

Signed-off-by: Kou Ishizaki [EMAIL PROTECTED]
---

--- org-linux-powerpc-git/drivers/net/spider_net.c  2007-01-15 
11:16:16.0 +0900
+++ linux-powerpc-git/drivers/net/spider_net.c  2007-01-15 11:16:42.0 
+0900
@@ -1447,8 +1447,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 */

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] drivers/net: spidernet driver on Celleb

2006-12-14 Thread Ishizaki Kou
Christoph-san,

Thanks for your comments.

On Tue, Dec 12, 2006 at 02:25:50PM +0900, Ishizaki Kou wrote:
 
 Following are the changes.
 -This patch enables auto-negotiation.
 -Loading firmware is done when spidernet_open() is called.
 -And this patch adds other several small changes for Celleb. 

This should be split into three separate patches, sent as a patch
series.

We are now working to separeting the patch. We'll send later.

 -/* outside loopback mode: ETOMOD signal dont matter, not connected */
 -#define SPIDER_NET_OPMODE_VALUE 0x0063
 +/* ETOMOD signal is brought to PHY reset. bit2 must be 1 in Celleb */
 +#define SPIDER_NET_OPMODE_VALUE 0x0067

Is it okay to simple change this value for the ibm blades?

Sorry, we didn't test on ibm blades, because we don't have one.
We hope to develop together so that the driver works on both platform.

 +static int is1000 = 1;

This should be in struct spider_net_card instead of a global flag.

We'll move it in struct spider_net_card.

  case SPIDER_NET_GTMFLLINT:
 -if (netif_msg_intr(card)  net_ratelimit())
 -pr_err(Spider TX RAM full\n);
 +/* if (netif_msg_intr(card)  net_ratelimit())
 +pr_err(Spider TX RAM full\n); */

Either this should be kept or removed entirely.  In the latter case you
need a good description why it's removed in the patch header.

We'll remove it entirely.

GTMFLLINT occures frequently when we use 100M HUB. We didn't find any
bad influence by this interrupt so far, so we removed the output.

 +
 +spider_net_write_reg(card, SPIDER_NET_GMACOPEMD,
 + spider_net_read_reg(card, SPIDER_NET_GMACOPEMD) | 
 0x4);

Please make sure this doesn't overflow the 80 characters per line limit.

We'll correct it. 

 +static int spider_net_init_firmware(struct spider_net_card *);

Random forward declarations in the middle of the file aren't very nice.
If you really need them put them at the beggining of the file, but it would
be even better if you moved spider_net_init_firmware further up in the
file so we wouldn't need the forward-declaration at all.

We'll move some functions.

 +if (card-phy.def-phy_id)
 +mod_timer(card-aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER);
 +else
 +pr_err(No phy is available\n);

What is this idiom about?  Is not having a phy a fatal error in which case
we should abort here, or is it tolerable in which case pr_err is too much.

Checking phy_id is not required here, so we'll change to call
mod_timer() simply.

 +static void spider_net_init_card(struct spider_net_card *);

Same comment above forward declarations as above.

Thank you,
Kou Ishizaki
Toshiba
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] drivers/net: spidernet driver on Celleb

2006-12-11 Thread Ishizaki Kou

Following are the changes.
-This patch enables auto-negotiation.
-Loading firmware is done when spidernet_open() is called.
-And this patch adds other several small changes for Celleb. 
-This patch is not tested on CellBlade.

Signed-off-by: Kou Ishizaki kou.ishizaki at toshiba.co.jp
---

Dear everyone,

This is the patch (besed on powerpc-git (2006-12-05)) for spidernet driver to
work on Toshiba Cell reference set(Celleb). 
The reference set consists of Cell, 512MB memory, Super Companion Chip(SCC) 
and some peripherals such as HDD, GbE, etc. You can see brief explanation
and picture of Cell reference set at following URLs.

http://www.toshiba.co.jp/about/press/2005_09/pr2001.htm
http://cell-industries.com/toshiba_announces.php

This patch set is intended to be merged to 2.6.20.
If you have any comment, please write to me.

---
Index: linux-2.6.19/drivers/net/Kconfig
diff -u linux-2.6.19/drivers/net/Kconfig:1.1.1.4 
linux-2.6.19/drivers/net/Kconfig:1.6
--- linux-2.6.19/drivers/net/Kconfig:1.1.1.4Tue Nov 14 11:15:25 2006
+++ linux-2.6.19/drivers/net/KconfigFri Dec  1 15:16:10 2006
@@ -2245,7 +2245,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
Index: linux-2.6.19/drivers/net/spider_net.h
diff -u linux-2.6.19/drivers/net/spider_net.h:1.1.1.2 
linux-2.6.19/drivers/net/spider_net.h:1.5
--- linux-2.6.19/drivers/net/spider_net.h:1.1.1.2   Tue Oct 17 08:42:39 2006
+++ linux-2.6.19/drivers/net/spider_net.h   Tue Nov  7 12:36:35 2006
@@ -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]
@@ -50,6 +51,7 @@
 #define SPIDER_NET_TX_DESCRIPTORS_MAX  512
 
 #define SPIDER_NET_TX_TIMER(HZ/5)
+#define SPIDER_NET_ANEG_TIMER  (HZ*2)
 
 #define SPIDER_NET_RX_CSUM_DEFAULT 1
 
@@ -104,6 +106,7 @@
 
 #define SPIDER_NET_GMACOPEMD   0x0100
 #define SPIDER_NET_GMACLENLMT  0x0108
+#define SPIDER_NET_GMACST  0x0110
 #define SPIDER_NET_GMACINTEN   0x0118
 #define SPIDER_NET_GMACPHYCTRL 0x0120
 
@@ -180,8 +183,8 @@
 #define SPIDER_NET_IPSECINIT_VALUE 0x6f716f71
 
 /* pause frames: automatic, no upper retransmission count */
-/* outside loopback mode: ETOMOD signal dont matter, not connected */
-#define SPIDER_NET_OPMODE_VALUE0x0063
+/* ETOMOD signal is brought to PHY reset. bit2 must be 1 in Celleb */
+#define SPIDER_NET_OPMODE_VALUE0x0067
 /*#define SPIDER_NET_OPMODE_VALUE  0x001b0062*/
 #define SPIDER_NET_LENLMT_VALUE0x0908
 
@@ -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  ( 0x  \
  (~SPIDER_NET_TXINT)  \
- (~SPIDER_NET_RXINT) )
+ (~SPIDER_NET_RXINT)  \
+ (~SPIDER_NET_LINKINT) )
 
 #define SPIDER_NET_GPREXEC 0x8000
 #define SPIDER_NET_GPRDAT_MASK 0x
@@ -447,6 +453,8 @@
 
spinlock_t intmask_lock;
struct tasklet_struct rxram_full_tl;
+   int aneg_count;
+   struct timer_list aneg_timer;
struct timer_list tx_timer;
 
struct work_struct tx_timeout_task;
Index: linux-2.6.19/drivers/net/spider_net.c
diff -u linux-2.6.19/drivers/net/spider_net.c:1.1.1.2 
linux-2.6.19/drivers/net/spider_net.c:1.10
--- linux-2.6.19/drivers/net/spider_net.c:1.1.1.2   Tue Oct 17 08:42:39 2006
+++ linux-2.6.19/drivers/net/spider_net.c   Tue Dec  5 20:30:42 2006
@@ -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]
@@ -78,6 +79,8 @@
 
 MODULE_DEVICE_TABLE(pci, spider_net_pci_tbl);
 
+static int is1000 = 1;
+
 /**
  * spider_net_read_reg - reads an SMMIO register of a card
  * @card: device structure
@@ -163,6 +166,53 @@
return readvalue;
 }
 
+static void
+spider_net_setup_aneg(struct spider_net_card *card, int is1000)
+{
+   struct mii_phy *phy = card-phy;
+   u32 advertise = 0;
+   u16 bmcr, bmsr, ctrl1000, stat1000, estat;
+
+   bmcr =