[EMAIL PROTECTED]: [PATCH] PCI Error Recovery: e100 network device driver]

2006-01-06 Thread linas
Hi,

The following patch to the e100 device driver is in the current
2.6.15-mm1 tree, and is being pushed to the mainline 2.6.15 tree.

I wrote this patch, and I believe I've cc'ed you on previous 
versions, but certainly not recently. Please review, comment,
ACK or NAK as appropriate.

Background: Newer PCI controllers can detect and respond to 
serious PCI bus errors, typically by isolating the PCI slot 
(cutting off i/o to the failing card). An arch-specific 
framework can report these errors back to the device driver,
and coordinate the recovery of the card. Detailed documentation
for this is in the kernel tree, at Documentation/pci-error-recovery.txt

This patch adds the detection and recovery callbacks to the
e100 driver. A version of this patch has been shipping as 
a part of SUSE SLES9 for about a year, and so has been 
tested in the field.

Similar patches to follow for the e1000 and the ixgb. 

--linas

- Forwarded message from Greg KH <[EMAIL PROTECTED]> -

Subject: [PATCH] PCI Error Recovery: e100 network device driver
Reply-To: Greg K-H <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
From: Greg KH <[EMAIL PROTECTED]>

[PATCH] PCI Error Recovery: e100 network device driver

Various PCI bus errors can be signaled by newer PCI controllers.  This
patch adds the PCI error recovery callbacks to the intel ethernet e100
device driver. The patch has been tested, and appears to work well.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>

---
commit 414eee4fa72175d3c0be116d6cb8b0634e4ae916
tree e1cc342377037142e0fd46f89b4cabaa3bb12adb
parent 113cc803a20d72ee5e3c92302ac5a06e0c651d01
author linas <[EMAIL PROTECTED]> Fri, 18 Nov 2005 16:23:26 -0600
committer Greg Kroah-Hartman <[EMAIL PROTECTED]> Thu, 05 Jan 2006 21:54:55 -0800

 drivers/net/e100.c |   70 
 1 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 22cd045..095d953 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2704,6 +2704,75 @@ static void e100_shutdown(struct pci_dev
 }
 
 
+/* -- PCI Error Recovery infrastructure  -- */
+/** e100_io_error_detected() is called when PCI error is detected */
+static pci_ers_result_t e100_io_error_detected(struct pci_dev *pdev, 
pci_channel_state_t state)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+
+   /* Same as calling e100_down(netdev_priv(netdev)), but generic */
+   netdev->stop(netdev);
+
+   /* Is a detach needed ?? */
+   // netif_device_detach(netdev);
+
+   /* Request a slot reset. */
+   return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/** e100_io_slot_reset is called after the pci bus has been reset.
+ *  Restart the card from scratch. */
+static pci_ers_result_t e100_io_slot_reset(struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct nic *nic = netdev_priv(netdev);
+
+   if(pci_enable_device(pdev)) {
+   printk(KERN_ERR "e100: Cannot re-enable PCI device after 
reset.\n");
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+   pci_set_master(pdev);
+
+   /* Only one device per card can do a reset */
+   if (0 != PCI_FUNC (pdev->devfn))
+   return PCI_ERS_RESULT_RECOVERED;
+
+   e100_hw_reset(nic);
+   e100_phy_init(nic);
+
+   if(e100_hw_init(nic)) {
+   DPRINTK(HW, ERR, "e100_hw_init failed\n");
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+
+   return PCI_ERS_RESULT_RECOVERED;
+}
+
+/** e100_io_resume is called when the error recovery driver
+ *  tells us that its OK to resume normal operation.
+ */
+static void e100_io_resume(struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct nic *nic = netdev_priv(netdev);
+
+   /* ack any pending wake events, disable PME */
+   pci_enable_wake(pdev, 0, 0);
+
+   netif_device_attach(netdev);
+   if(netif_running(netdev)) {
+   e100_open (netdev);
+   mod_timer(&nic->watchdog, jiffies);
+   }
+}
+
+static struct pci_error_handlers e100_err_handler = {
+   .error_detected = e100_io_error_detected,
+   .slot_reset = e100_io_slot_reset,
+   .resume = e100_io_resume,
+};
+
+
 static struct pci_driver e100_driver = {
.name = DRV_NAME,
.id_table = e100_id_table,
@@ -2714,6 +2783,7 @@ static struct pci_driver e100_driver = {
.resume =   e100_resume,
 #endif
.shutdown = e100_shutdown,
+   .err_handler = &e100_err_handler,
 };
 
 static int __init e100_init_module(void)



- End forwarded message -
-
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


[EMAIL PROTECTED]: [PATCH] PCI Error Recovery: e1000 network device driver]

2006-01-06 Thread linas

Here's the correspondig patch fo the e1000
--linas

> Hi,
> 
> The following patch to the e100 device driver is in the current
> 2.6.15-mm1 tree, and is being pushed to the mainline 2.6.15 tree.
> 
> I wrote this patch, and I believe I've cc'ed you on previous
> versions, but certainly not recently. Please review, comment,
> ACK or NAK as appropriate.
> 
> Background: Newer PCI controllers can detect and respond to
> serious PCI bus errors, typically by isolating the PCI slot
> (cutting off i/o to the failing card). An arch-specific
> framework can report these errors back to the device driver,
> and coordinate the recovery of the card. Detailed documentation
> for this is in the kernel tree, at Documentation/pci-error-recovery.txt
> 
> This patch adds the detection and recovery callbacks to the
> e100 driver. A version of this patch has been shipping as
> a part of SUSE SLES9 for about a year, and so has been
> tested in the field.
> 
> Similar patches to follow for the e1000 and the ixgb.
> 
> --linas

- Forwarded message from Greg KH <[EMAIL PROTECTED]> -

Subject: [PATCH] PCI Error Recovery: e1000 network device driver
To: [EMAIL PROTECTED]
From: Greg KH <[EMAIL PROTECTED]>

[PATCH] PCI Error Recovery: e1000 network device driver

Various PCI bus errors can be signaled by newer PCI controllers.  This
patch adds the PCI error recovery callbacks to the intel gigabit
ethernet e1000 device driver. The patch has been tested, and appears
to work well.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>

---
commit 113cc803a20d72ee5e3c92302ac5a06e0c651d01
tree aae6aa3b20f14a36eba84867c2406cbe385affad
parent 5a02e3abf1e74c159deca91d6af01297379eede7
author linas <[EMAIL PROTECTED]> Fri, 18 Nov 2005 16:23:54 -0600
committer Greg Kroah-Hartman <[EMAIL PROTECTED]> Thu, 05 Jan 2006 21:54:55 -0800

 drivers/net/e1000/e1000_main.c |  101 
 1 files changed, 100 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 438a931..76352fe 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -206,6 +206,16 @@ static void e1000_netpoll (struct net_de
 void e1000_rx_schedule(void *data);
 #endif
 
+static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, 
pci_channel_state_t state);
+static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev);
+static void e1000_io_resume(struct pci_dev *pdev);
+
+static struct pci_error_handlers e1000_err_handler = {
+   .error_detected = e1000_io_error_detected,
+   .slot_reset = e1000_io_slot_reset,
+   .resume = e1000_io_resume,
+};
+
 /* Exported from other modules */
 
 extern void e1000_check_options(struct e1000_adapter *adapter);
@@ -218,8 +228,9 @@ static struct pci_driver e1000_driver = 
/* Power Managment Hooks */
 #ifdef CONFIG_PM
.suspend  = e1000_suspend,
-   .resume   = e1000_resume
+   .resume   = e1000_resume,
 #endif
+   .err_handler = &e1000_err_handler,
 };
 
 MODULE_AUTHOR("Intel Corporation, <[EMAIL PROTECTED]>");
@@ -2941,6 +2952,10 @@ e1000_update_stats(struct e1000_adapter 
 
 #define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
 
+   /* Prevent stats update while adapter is being reset */
+   if (adapter->link_speed == 0)
+   return;
+
spin_lock_irqsave(&adapter->stats_lock, flags);
 
/* these counters are modified from e1000_adjust_tbi_stats,
@@ -4331,4 +4346,88 @@ e1000_netpoll(struct net_device *netdev)
 }
 #endif
 
+/* --- PCI Error Recovery infrastructure  */
+/** e1000_io_error_detected() is called when PCI error is detected */
+static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, 
pci_channel_state_t state)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct e1000_adapter *adapter = netdev->priv;
+
+   if (netif_running(netdev))
+   e1000_down(adapter);
+
+   /* Request a slot slot reset. */
+   return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/** e1000_io_slot_reset is called after the pci bus has been reset.
+ *  Restart the card from scratch.
+ *  Implementation resembles the first-half of the
+ *  e1000_resume routine.
+ */
+static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct e1000_adapter *adapter = netdev->priv;
+
+   if (pci_enable_device(pdev)) {
+   printk(KERN_ERR "e1000: Cannot re-enable PCI device after 
reset.\n");
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+   pci_set_master(pdev);
+
+   pci_enable_wake(pdev, 3, 0);
+   pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
+
+   /* Perf

[EMAIL PROTECTED]: [PATCH] PCI Error Recovery: ixgb network device driver]

2006-01-06 Thread linas

Here's the corresponding patch for the ixgb.

--linas

> Hi,
> 
> The following patch to the e100 device driver is in the current
> 2.6.15-mm1 tree, and is being pushed to the mainline 2.6.15 tree.
> 
> I wrote this patch, and I believe I've cc'ed you on previous
> versions, but certainly not recently. Please review, comment,
> ACK or NAK as appropriate.
> 
> Background: Newer PCI controllers can detect and respond to
> serious PCI bus errors, typically by isolating the PCI slot
> (cutting off i/o to the failing card). An arch-specific
> framework can report these errors back to the device driver,
> and coordinate the recovery of the card. Detailed documentation
> for this is in the kernel tree, at Documentation/pci-error-recovery.txt
> 
>  This patch adds the detection and recovery callbacks to the
> e100 driver. A version of this patch has been shipping as
> a part of SUSE SLES9 for about a year, and so has been
> tested in the field.
> 
> Similar patches to follow for the e1000 and the ixgb.
> 
> --linas
> 

- Forwarded message from Greg KH <[EMAIL PROTECTED]> -

Subject: [PATCH] PCI Error Recovery: ixgb network device driver
To: [EMAIL PROTECTED]
From: Greg KH <[EMAIL PROTECTED]>

[PATCH] PCI Error Recovery: ixgb network device driver

Various PCI bus errors can be signaled by newer PCI controllers.  This
patch adds the PCI error recovery callbacks to the intel ten-gigabit
ethernet ixgb device driver. The patch has been tested, and appears
to work well.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>

---
commit 3c0006afdd8ade574257c88df81c93b0bb71b544
tree 4cc697ccc74b8d67a9f08e68f71584f9d538e90e
parent d78cde68ab78766c3a175466aa8adcbdc5520963
author linas <[EMAIL PROTECTED]> Fri, 18 Nov 2005 16:24:20 -0600
committer Greg Kroah-Hartman <[EMAIL PROTECTED]> Thu, 05 Jan 2006 21:54:55 -0800

 drivers/net/ixgb/ixgb_main.c |   86 ++
 1 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index f9f77e4..166832c 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -132,6 +132,16 @@ static void ixgb_restore_vlan(struct ixg
 static void ixgb_netpoll(struct net_device *dev);
 #endif
 
+static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev, 
pci_channel_state_t state);
+static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev);
+static void ixgb_io_resume (struct pci_dev *pdev);
+
+static struct pci_error_handlers ixgb_err_handler = {
+   .error_detected = ixgb_io_error_detected,
+   .slot_reset = ixgb_io_slot_reset,
+   .resume = ixgb_io_resume,
+};
+
 /* Exported from other modules */
 
 extern void ixgb_check_options(struct ixgb_adapter *adapter);
@@ -141,6 +151,8 @@ static struct pci_driver ixgb_driver = {
.id_table = ixgb_pci_tbl,
.probe= ixgb_probe,
.remove   = __devexit_p(ixgb_remove),
+   .err_handler = &ixgb_err_handler,
+
 };
 
 MODULE_AUTHOR("Intel Corporation, <[EMAIL PROTECTED]>");
@@ -1654,8 +1666,16 @@ ixgb_intr(int irq, void *data, struct pt
unsigned int i;
 #endif
 
+#ifdef XXX_CONFIG_IXGB_EEH_RECOVERY
+   if(unlikely(icr==EEH_IO_ERROR_VALUE(4))) {
+   if (eeh_slot_is_isolated (adapter->pdev))
+   // disable_irq_nosync (adapter->pdev->irq);
+   return IRQ_NONE;  /* Not our interrupt */
+   }
+#else
if(unlikely(!icr))
return IRQ_NONE;  /* Not our interrupt */
+#endif /* CONFIG_IXGB_EEH_RECOVERY */
 
if(unlikely(icr & (IXGB_INT_RXSEQ | IXGB_INT_LSC))) {
mod_timer(&adapter->watchdog_timer, jiffies);
@@ -2125,4 +2145,70 @@ static void ixgb_netpoll(struct net_devi
 }
 #endif
 
+/* -- PCI Error Recovery infrastructure  */
+/** ixgb_io_error_detected() is called when PCI error is detected */
+static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev, 
pci_channel_state_t state)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct ixgb_adapter *adapter = netdev->priv;
+
+   if(netif_running(netdev))
+   ixgb_down(adapter, TRUE);
+
+   /* Request a slot reset. */
+   return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/** ixgb_io_slot_reset is called after the pci bus has been reset.
+ *  Restart the card from scratch.
+ *  Implementation resembles the first-half of the
+ *  ixgb_resume routine.
+ */
+static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct ixgb_adapter *adapter = netdev->priv;
+
+   if(pci_enable_device(pdev)) {
+   printk(KERN_ERR "ixgb: Cannot re-enable PCI dev

[PATCH] PCI Error Recovery: ixgb network device driver

2006-01-18 Thread linas

Jeff, 

Please review, apply and forward upstream the patch below,
for the Intel ixgb driver.  Similar patches for the Intel e1000
and e100 to follow shortly.

--linas

On Wed, Jan 18, 2006 at 02:13:55PM -0800, Ronciak, John was heard to remark:
> Patches for e100, e1000 and ixgb need to go out to netdev and Jeff
> Garzik.  We are co-maintainers with him.  Jeff is the one who puts them
> into the actual kernel tree source however.
> 
> > > > From: linas [mailto:[EMAIL PROTECTED] 
> > > > 
> > > > I'm trying to get this patch, and related patches for 
> > > > the e100 and e1000, submitted into the mainline kernel.
> > > > I'd previously submitted these to GregKH, together with
> > > > some related patches; Jesse Brandeburg was kind enough
> > > > to ack them recently.
> > > > 
> > > > 
- Forwarded message from Greg KH <[EMAIL PROTECTED]> -

Subject: [PATCH] PCI Error Recovery: ixgb network device driver
In-Reply-To: <[EMAIL PROTECTED]>
X-Mailer: gregkh_patchbomb
Date: Thu, 5 Jan 2006 22:38:34 -0800
Message-Id: <[EMAIL PROTECTED]>
Reply-To: Greg K-H <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
From: Greg KH <[EMAIL PROTECTED]>
Sender: [EMAIL PROTECTED]

[PATCH] PCI Error Recovery: ixgb network device driver

Various PCI bus errors can be signaled by newer PCI controllers.  This
patch adds the PCI error recovery callbacks to the intel ten-gigabit 
ethernet ixgb device driver. The patch has been tested, and appears
to work well.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>

---
commit 3c0006afdd8ade574257c88df81c93b0bb71b544
tree 4cc697ccc74b8d67a9f08e68f71584f9d538e90e
parent d78cde68ab78766c3a175466aa8adcbdc5520963
author linas <[EMAIL PROTECTED]> Fri, 18 Nov 2005 16:24:20 -0600
committer Greg Kroah-Hartman <[EMAIL PROTECTED]> Thu, 05 Jan 
2006 21:54:55 -0800

 drivers/net/ixgb/ixgb_main.c |   86 
++
 1 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ixgb/ixgb_main.c 
b/drivers/net/ixgb/ixgb_main.c
index f9f77e4..166832c 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -132,6 +132,16 @@ static void ixgb_restore_vlan(struct ixg
 static void ixgb_netpoll(struct net_device *dev);
 #endif
 
+static pci_ers_result_t ixgb_io_error_detected (struct 
pci_dev *pdev, pci_channel_state_t state);
+static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev);
+static void ixgb_io_resume (struct pci_dev *pdev);
+
+static struct pci_error_handlers ixgb_err_handler = {
+   .error_detected = ixgb_io_error_detected,
+   .slot_reset = ixgb_io_slot_reset,
+   .resume = ixgb_io_resume,
+};
+
 /* Exported from other modules */
 
 extern void ixgb_check_options(struct ixgb_adapter *adapter);
@@ -141,6 +151,8 @@ static struct pci_driver ixgb_driver = {
.id_table = ixgb_pci_tbl,
.probe= ixgb_probe,
.remove   = __devexit_p(ixgb_remove),
+   .err_handler = &ixgb_err_handler,
+
 };
 
 MODULE_AUTHOR("Intel Corporation, <[EMAIL PROTECTED]>");
@@ -1654,8 +1666,16 @@ ixgb_intr(int irq, void *data, struct pt
unsigned int i;
 #endif
 
+#ifdef XXX_CONFIG_IXGB_EEH_RECOVERY
+   if(unlikely(icr==EEH_IO_ERROR_VALUE(4))) {
+   if (eeh_slot_is_isolated (adapter->pdev))
+   // disable_irq_nosync (adapter->pdev->irq);
+   return IRQ_NONE;  /* Not our interrupt */
+   }
+#else
if(unlikely(!icr))
return IRQ_NONE;  /* Not our interrupt */
+#endif /* CONFIG_IXGB_EEH_RECOVERY */
 
if(unlikely(icr & (IXGB_INT_RXSEQ | IXGB_INT_LSC))) {
mod_timer(&adapter->watchdog_timer, jiffies);
@@ -2125,4 +2145,70 @@ static void ixgb_netpoll(struct net_devi
 }
 #endif
 
+/* -- PCI Error Recovery infrastructure  */
+/** ixgb_io_error_detected() is called when PCI error is detected */
+static pci_ers_result_t ixgb_io_error_detected (struct pci_dev *pdev, 
pci_channel_state_t state)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct ixgb_adapter *adapter = netdev->priv;
+
+   if(netif_running(netdev))
+   ixgb_down(adapter, TRUE);
+
+   /* Request a slot reset. */
+   return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/** ixgb_io_slot_reset is called after the pci bus has been reset.
+ *  Restart the card from scratch.
+ *  Implementation resembles the first-half of the
+ *  ixgb_resume routine.
+ */
+static pci_ers_result_t ixgb_io_slot_reset (struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct ixgb_adapter *adapter = netdev->priv;
+
+   if(pci_enable_device(pdev)) {
+   printk(KERN_ERR "ixgb: Cannot r

[PATCH] PCI Error Recovery: e1000 network device driver

2006-01-18 Thread linas

Hi Jeff,

Please review, apply and forward this patch upstream,
as appropriate. 

--linas


[PATCH] PCI Error Recovery: e1000 network device driver

Various PCI bus errors can be signaled by newer PCI controllers.  This
patch adds the PCI error recovery callbacks to the intel gigabit
ethernet e1000 device driver. The patch has been tested, and appears
to work well.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>

---
commit 113cc803a20d72ee5e3c92302ac5a06e0c651d01
tree aae6aa3b20f14a36eba84867c2406cbe385affad
parent 5a02e3abf1e74c159deca91d6af01297379eede7
author linas <[EMAIL PROTECTED]> Fri, 18 Nov 2005 16:23:54 -0600
committer Greg Kroah-Hartman <[EMAIL PROTECTED]> Thu, 05 Jan 2006 21:54:55 -0800

 drivers/net/e1000/e1000_main.c |  101 
 1 files changed, 100 insertions(+), 1 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 438a931..76352fe 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -206,6 +206,16 @@ static void e1000_netpoll (struct net_de
 void e1000_rx_schedule(void *data);
 #endif
 
+static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, 
pci_channel_state_t state);
+static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev);
+static void e1000_io_resume(struct pci_dev *pdev);
+
+static struct pci_error_handlers e1000_err_handler = {
+   .error_detected = e1000_io_error_detected,
+   .slot_reset = e1000_io_slot_reset,
+   .resume = e1000_io_resume,
+};
+
 /* Exported from other modules */
 
 extern void e1000_check_options(struct e1000_adapter *adapter);
@@ -218,8 +228,9 @@ static struct pci_driver e1000_driver = 
/* Power Managment Hooks */
 #ifdef CONFIG_PM
.suspend  = e1000_suspend,
-   .resume   = e1000_resume
+   .resume   = e1000_resume,
 #endif
+   .err_handler = &e1000_err_handler,
 };
 
 MODULE_AUTHOR("Intel Corporation, <[EMAIL PROTECTED]>");
@@ -2941,6 +2952,10 @@ e1000_update_stats(struct e1000_adapter 
 
 #define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
 
+   /* Prevent stats update while adapter is being reset */
+   if (adapter->link_speed == 0)
+   return;
+
spin_lock_irqsave(&adapter->stats_lock, flags);
 
/* these counters are modified from e1000_adjust_tbi_stats,
@@ -4331,4 +4346,88 @@ e1000_netpoll(struct net_device *netdev)
 }
 #endif
 
+/* --- PCI Error Recovery infrastructure  */
+/** e1000_io_error_detected() is called when PCI error is detected */
+static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, 
pci_channel_state_t state)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct e1000_adapter *adapter = netdev->priv;
+
+   if (netif_running(netdev))
+   e1000_down(adapter);
+
+   /* Request a slot slot reset. */
+   return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/** e1000_io_slot_reset is called after the pci bus has been reset.
+ *  Restart the card from scratch.
+ *  Implementation resembles the first-half of the
+ *  e1000_resume routine.
+ */
+static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct e1000_adapter *adapter = netdev->priv;
+
+   if (pci_enable_device(pdev)) {
+   printk(KERN_ERR "e1000: Cannot re-enable PCI device after 
reset.\n");
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+   pci_set_master(pdev);
+
+   pci_enable_wake(pdev, 3, 0);
+   pci_enable_wake(pdev, 4, 0); /* 4 == D3 cold */
+
+   /* Perform card reset only on one instance of the card */
+   if(0 != PCI_FUNC (pdev->devfn))
+   return PCI_ERS_RESULT_RECOVERED;
+
+   e1000_reset(adapter);
+   E1000_WRITE_REG(&adapter->hw, WUS, ~0);
+
+   return PCI_ERS_RESULT_RECOVERED;
+}
+
+/** e1000_io_resume is called when the error recovery driver
+ *  tells us that its OK to resume normal operation.
+ *  Implementation resembles the second-half of the
+ *  e1000_resume routine.
+ */
+static void e1000_io_resume(struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct e1000_adapter *adapter = netdev->priv;
+   uint32_t manc, swsm;
+
+   if(netif_running(netdev)) {
+   if (e1000_up(adapter)) {
+   printk("e1000: can't bring device back up after 
reset\n");
+   return;
+   }
+   }
+
+   netif_device_attach(netdev);
+
+   if(adapter->hw.mac_type >= e1000_82540 &&
+   adapter->hw.media_type == e1000_media_type_copper) {
+   manc = E1000_READ_REG(&adapter->hw, MANC);
+   manc &= ~(E1000_MANC_ARP_EN);
+   E1000_WRITE_REG(&adapter->hw, MANC, manc);
+ 

[PATCH] PCI Error Recovery: e100 network device driver

2006-01-18 Thread linas

Hi Jeff,

Please review, apply and forward upstream as appropriate.

--linas

[PATCH] PCI Error Recovery: e100 network device driver

Various PCI bus errors can be signaled by newer PCI controllers.  This
patch adds the PCI error recovery callbacks to the intel ethernet e100
device driver. The patch has been tested, and appears to work well.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>

---
commit 414eee4fa72175d3c0be116d6cb8b0634e4ae916
tree e1cc342377037142e0fd46f89b4cabaa3bb12adb
parent 113cc803a20d72ee5e3c92302ac5a06e0c651d01
author linas <[EMAIL PROTECTED]> Fri, 18 Nov 2005 16:23:26 -0600
committer Greg Kroah-Hartman <[EMAIL PROTECTED]> Thu, 05 Jan 2006 21:54:55 -0800

 drivers/net/e100.c |   70 
 1 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 22cd045..095d953 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2704,6 +2704,75 @@ static void e100_shutdown(struct pci_dev
 }
 
 
+/* -- PCI Error Recovery infrastructure  -- */
+/** e100_io_error_detected() is called when PCI error is detected */
+static pci_ers_result_t e100_io_error_detected(struct pci_dev *pdev, 
pci_channel_state_t state)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+
+   /* Same as calling e100_down(netdev_priv(netdev)), but generic */
+   netdev->stop(netdev);
+
+   /* Is a detach needed ?? */
+   // netif_device_detach(netdev);
+
+   /* Request a slot reset. */
+   return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/** e100_io_slot_reset is called after the pci bus has been reset.
+ *  Restart the card from scratch. */
+static pci_ers_result_t e100_io_slot_reset(struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct nic *nic = netdev_priv(netdev);
+
+   if(pci_enable_device(pdev)) {
+   printk(KERN_ERR "e100: Cannot re-enable PCI device after 
reset.\n");
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+   pci_set_master(pdev);
+
+   /* Only one device per card can do a reset */
+   if (0 != PCI_FUNC (pdev->devfn))
+   return PCI_ERS_RESULT_RECOVERED;
+
+   e100_hw_reset(nic);
+   e100_phy_init(nic);
+
+   if(e100_hw_init(nic)) {
+   DPRINTK(HW, ERR, "e100_hw_init failed\n");
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+
+   return PCI_ERS_RESULT_RECOVERED;
+}
+
+/** e100_io_resume is called when the error recovery driver
+ *  tells us that its OK to resume normal operation.
+ */
+static void e100_io_resume(struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct nic *nic = netdev_priv(netdev);
+
+   /* ack any pending wake events, disable PME */
+   pci_enable_wake(pdev, 0, 0);
+
+   netif_device_attach(netdev);
+   if(netif_running(netdev)) {
+   e100_open (netdev);
+   mod_timer(&nic->watchdog, jiffies);
+   }
+}
+
+static struct pci_error_handlers e100_err_handler = {
+   .error_detected = e100_io_error_detected,
+   .slot_reset = e100_io_slot_reset,
+   .resume = e100_io_resume,
+};
+
+
 static struct pci_driver e100_driver = {
.name = DRV_NAME,
.id_table = e100_id_table,
@@ -2714,6 +2783,7 @@ static struct pci_driver e100_driver = {
.resume =   e100_resume,
 #endif
.shutdown = e100_shutdown,
+   .err_handler = &e100_err_handler,
 };
 
 static int __init e100_init_module(void)



- End forwarded message -
-
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] PCI Error Recovery: ixgb network device driver

2006-01-26 Thread linas
Hi,

Sorry for late response, I was trying to find some h/w so as
to retest this before responding.  (Which I wasn't able to 
find, and so haven't retested yet).

On Thu, Jan 19, 2006 at 05:23:07AM +0100, Andi Kleen was heard to remark:
> 
> >  
> > +#ifdef XXX_CONFIG_IXGB_EEH_RECOVERY
> > +   if(unlikely(icr==EEH_IO_ERROR_VALUE(4))) {
> > +   if (eeh_slot_is_isolated (adapter->pdev))
> > +   // disable_irq_nosync (adapter->pdev->irq);
> > +   return IRQ_NONE;  /* Not our interrupt */
> 
> 
> So does the return belong below the first or the second if()? It certainly
> looks weird. 

This is left-over crud (its not compiled) that I should have removed 
from the patch.  I had left it in as a "note to self" because, at one 
point, it cured a hang.  

Background: (I think you get this but let me repeat):

A variety of device drivers have a "design flaw" in that they will
poll an interrupt status register in an infinite loop in the 
interrupt handler, waiting for a certain value to be set/cleared. 
This would be a deadly behaviour for any PCMCIA card that might get
yanked at any time. Similarly, its a problem for PCI error recovery:
when the PCI device is "frozen", all further reads return 0xff,
and so the interrupt status won't ever change.  With just the right
timing, one hangs in a spinloop with interrupts disabled. :(

> And returning IRQ_NONE looks wrong too - if means if 
> the hardware is broken and there is nobody else on the same interrupt
> then the kernel will complain about buggy drivers, which is not true
> here. Probably it needs a new IRQ_ERR return value or somesuch that 
> stops the complaining and acts otherwise like IRQ_NONE.

Ah!! I was struggling with trying to figure out the "right" way of
dealing with this case. I kept at it with various hacky attempts,
none terribly satisfying. I'll take a look at the "new return code"
idea.


--linas
-
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 poor network performance

2006-11-17 Thread Linas Vepstas

Andrew, 

Please apply.

--linas


This patch corrects a problem seen on later kernels running 
the NetPIPE application.  Specifically, NetPIPE would begin 
running very slowly at the 1533 packet size. It was
determined that Spidernet slowed with an idle DMA 
engine.

Signed-off-by: James K Lewis <[EMAIL PROTECTED]>
Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |2 +-
 drivers/net/spider_net.h |8 
 2 files changed, 5 insertions(+), 5 deletions(-)

Index: linux-2.6.19-rc4-git3/drivers/net/spider_net.c
===
--- linux-2.6.19-rc4-git3.orig/drivers/net/spider_net.c 2006-11-01 
19:14:34.0 -0600
+++ linux-2.6.19-rc4-git3/drivers/net/spider_net.c  2006-11-17 
13:33:44.0 -0600
@@ -1606,7 +1606,7 @@ spider_net_enable_card(struct spider_net
 SPIDER_NET_INT2_MASK_VALUE);
 
spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,
-SPIDER_NET_GDTBSTA | SPIDER_NET_GDTDCEIDIS);
+SPIDER_NET_GDTBSTA);
 }
 
 /**
Index: linux-2.6.19-rc4-git3/drivers/net/spider_net.h
===
--- linux-2.6.19-rc4-git3.orig/drivers/net/spider_net.h 2006-11-01 
19:14:34.0 -0600
+++ linux-2.6.19-rc4-git3/drivers/net/spider_net.h  2006-11-17 
16:19:30.0 -0600
@@ -24,7 +24,7 @@
 #ifndef _SPIDER_NET_H
 #define _SPIDER_NET_H
 
-#define VERSION "1.1 A"
+#define VERSION "1.6 A"
 
 #include "sungem_phy.h"
 
@@ -217,8 +217,7 @@ extern char spider_net_driver_name[];
 #define SPIDER_NET_GDTBSTA 0x0300
 #define SPIDER_NET_GDTDCEIDIS  0x0002
 #define SPIDER_NET_DMA_TX_VALUESPIDER_NET_TX_DMA_EN | \
-   SPIDER_NET_GDTBSTA | \
-   SPIDER_NET_GDTDCEIDIS
+   SPIDER_NET_GDTBSTA
 
 #define SPIDER_NET_DMA_TX_FEND_VALUE   0x00030003
 
@@ -328,7 +327,8 @@ enum spider_net_int2_status {
SPIDER_NET_GRISPDNGINT
 };
 
-#define SPIDER_NET_TXINT   ( (1 << SPIDER_NET_GDTFDCINT) )
+#define SPIDER_NET_TXINT   ( (1 << SPIDER_NET_GDTFDCINT) | \
+ (1 << SPIDER_NET_GDTDCEINT) )
 
 /* We rely on flagged descriptor interrupts */
 #define SPIDER_NET_RXINT   ( (1 << SPIDER_NET_GDAFDCINT) )
-
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/16] Spidernet RX Misc cleanups and fixes

2006-12-06 Thread Linas Vepstas

Andrew, 

Please apply and forward upstream. This series of 16 small patches 
consist of mostly of various cleanups, a few fixes, and a clarification
of the flow of the RX side of the spidernet ethernet driver.  The 
first patch, though, is a resubmit of an old patch.

--linas
-
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/16] Spidernet DMA coalescing

2006-12-06 Thread Linas Vepstas

The current driver code performs 512 DMA mappings of a bunch of 
32-byte structures. This is silly, as they are all in contiguous 
memory. Ths patch changes the code to DMA map the entie area
with just one call.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Acked-by: Joel Schopp <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |  107 +++
 drivers/net/spider_net.h |   16 ++-
 2 files changed, 59 insertions(+), 64 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
15:53:23.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 15:56:20.0 
-0600
@@ -269,25 +269,6 @@ spider_net_get_descr_status(struct spide
 }
 
 /**
- * spider_net_free_chain - free descriptor chain
- * @card: card structure
- * @chain: address of chain
- *
- */
-static void
-spider_net_free_chain(struct spider_net_card *card,
- struct spider_net_descr_chain *chain)
-{
-   struct spider_net_descr *descr;
-
-   for (descr = chain->tail; !descr->bus_addr; descr = descr->next) {
-   pci_unmap_single(card->pdev, descr->bus_addr,
-SPIDER_NET_DESCR_SIZE, PCI_DMA_BIDIRECTIONAL);
-   descr->bus_addr = 0;
-   }
-}
-
-/**
  * spider_net_init_chain - links descriptor chain
  * @card: card structure
  * @chain: address of chain
@@ -299,15 +280,15 @@ spider_net_free_chain(struct spider_net_
  *
  * returns 0 on success, <0 on failure
  */
-static int
+static void
 spider_net_init_chain(struct spider_net_card *card,
   struct spider_net_descr_chain *chain,
   struct spider_net_descr *start_descr,
+  dma_addr_t buf,
   int no)
 {
int i;
struct spider_net_descr *descr;
-   dma_addr_t buf;
 
descr = start_descr;
memset(descr, 0, sizeof(*descr) * no);
@@ -316,17 +297,12 @@ spider_net_init_chain(struct spider_net_
for (i=0; idmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
 
-   buf = pci_map_single(card->pdev, descr,
-SPIDER_NET_DESCR_SIZE,
-PCI_DMA_BIDIRECTIONAL);
-
-   if (pci_dma_mapping_error(buf))
-   goto iommu_error;
-
descr->bus_addr = buf;
+   descr->next_descr_addr = 0;
descr->next = descr + 1;
descr->prev = descr - 1;
 
+   buf += sizeof(struct spider_net_descr);
}
/* do actual circular list */
(descr-1)->next = start_descr;
@@ -335,17 +311,6 @@ spider_net_init_chain(struct spider_net_
spin_lock_init(&chain->lock);
chain->head = start_descr;
chain->tail = start_descr;
-
-   return 0;
-
-iommu_error:
-   descr = start_descr;
-   for (i=0; i < no; i++, descr++)
-   if (descr->bus_addr)
-   pci_unmap_single(card->pdev, descr->bus_addr,
-SPIDER_NET_DESCR_SIZE,
-PCI_DMA_BIDIRECTIONAL);
-   return -ENOMEM;
 }
 
 /**
@@ -1652,24 +1617,32 @@ spider_net_open(struct net_device *netde
 {
struct spider_net_card *card = netdev_priv(netdev);
struct spider_net_descr *descr;
-   int i, result;
+   int result = -ENOMEM;
 
-   result = -ENOMEM;
-   if (spider_net_init_chain(card, &card->tx_chain, card->descr,
- card->num_tx_desc))
-   goto alloc_tx_failed;
+   card->descr_dma_addr = pci_map_single(card->pdev, card->descr,
+   (card->num_tx_desc+card->num_rx_desc)*sizeof(struct 
spider_net_descr),
+PCI_DMA_BIDIRECTIONAL);
+   if (pci_dma_mapping_error(card->descr_dma_addr))
+   return -ENOMEM;
+
+   spider_net_init_chain(card, &card->tx_chain, card->descr,
+ card->descr_dma_addr,
+ card->num_tx_desc);
 
card->low_watermark = NULL;
 
/* rx_chain is after tx_chain, so offset is descr + tx_count */
-   if (spider_net_init_chain(card, &card->rx_chain,
+   spider_net_init_chain(card, &card->rx_chain,
  card->descr + card->num_tx_desc,
- card->num_rx_desc))
-   goto alloc_rx_failed;
+ card->descr_dma_addr
+   + card->num_tx_desc * sizeof(struct 
spider_net

[PATCH 2/16] Spidernet add net_ratelimit to suppress long output

2006-12-06 Thread Linas Vepstas

This patch adds net_ratelimit to many of the printks 
in order to limit extraneous warning messages 
This patch supercedes all previous ratelimit patches.
This has been tested, please apply.

From: James K Lewis <[EMAIL PROTECTED]>
Signed-off-by: James K Lewis <[EMAIL PROTECTED]>
Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   11 +--
 drivers/net/spider_net.h |2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
15:56:20.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 15:58:27.0 
-0600
@@ -1008,11 +1008,10 @@ spider_net_decode_one_descr(struct spide
 
if ( (status != SPIDER_NET_DESCR_COMPLETE) &&
 (status != SPIDER_NET_DESCR_FRAME_END) ) {
-   if (netif_msg_rx_err(card)) {
+   if (netif_msg_rx_err(card))
pr_err("%s: RX descriptor with state %d\n",
   card->netdev->name, status);
-   card->spider_stats.rx_desc_unk_state++;
-   }
+   card->spider_stats.rx_desc_unk_state++;
goto refill;
}
 
@@ -1331,7 +1330,7 @@ spider_net_handle_error_irq(struct spide
case SPIDER_NET_GRFAFLLINT: /* fallthrough */
case SPIDER_NET_GRMFLLINT:
if (netif_msg_intr(card) && net_ratelimit())
-   pr_debug("Spider RX RAM full, incoming packets "
+   pr_err("Spider RX RAM full, incoming packets "
   "might be discarded!\n");
spider_net_rx_irq_off(card);
tasklet_schedule(&card->rxram_full_tl);
@@ -1349,7 +1348,7 @@ spider_net_handle_error_irq(struct spide
case SPIDER_NET_GDCDCEINT: /* fallthrough */
case SPIDER_NET_GDBDCEINT: /* fallthrough */
case SPIDER_NET_GDADCEINT:
-   if (netif_msg_intr(card))
+   if (netif_msg_intr(card) && net_ratelimit())
pr_err("got descriptor chain end interrupt, "
   "restarting DMAC %c.\n",
   'D'-(i-SPIDER_NET_GDDDCEINT)/3);
@@ -1420,7 +1419,7 @@ spider_net_handle_error_irq(struct spide
break;
}
 
-   if ((show_error) && (netif_msg_intr(card)))
+   if ((show_error) && (netif_msg_intr(card)) && net_ratelimit())
pr_err("Got error interrupt on %s, GHIINT0STS = 0x%08x, "
   "GHIINT1STS = 0x%08x, GHIINT2STS = 0x%08x\n",
   card->netdev->name,
Index: linux-2.6.19-git7/drivers/net/spider_net.h
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.h 2006-12-06 
15:56:20.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.h  2006-12-06 15:57:28.0 
-0600
@@ -24,7 +24,7 @@
 #ifndef _SPIDER_NET_H
 #define _SPIDER_NET_H
 
-#define VERSION "1.6 A"
+#define VERSION "1.6 B"
 
 #include "sungem_phy.h"
 
-
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/16] Spidernet RX Locking

2006-12-06 Thread Linas Vepstas

The RX packet handling can be called from several
places, yet does not protect the rx ring structure.
This patch places the ring buffer pointers under a lock.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
15:58:27.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:01:49.0 
-0600
@@ -969,28 +969,33 @@ static int
 spider_net_decode_one_descr(struct spider_net_card *card, int napi)
 {
struct spider_net_descr_chain *chain = &card->rx_chain;
-   struct spider_net_descr *descr = chain->tail;
+   struct spider_net_descr *descr;
int status;
int result;
+   unsigned long flags;
+
+   spin_lock_irqsave(&chain->lock, flags);
+   descr = chain->tail;
 
status = spider_net_get_descr_status(descr);
 
if (status == SPIDER_NET_DESCR_CARDOWNED) {
/* nothing in the descriptor yet */
-   result=0;
-   goto out;
+   spin_unlock_irqrestore(&chain->lock, flags);
+   return 0;
}
 
if (status == SPIDER_NET_DESCR_NOT_IN_USE) {
/* not initialized yet, the ring must be empty */
+   spin_unlock_irqrestore(&chain->lock, flags);
spider_net_refill_rx_chain(card);
spider_net_enable_rxdmac(card);
-   result=0;
-   goto out;
+   return 0;
}
 
/* descriptor definitively used -- move on tail */
chain->tail = descr->next;
+   spin_unlock_irqrestore(&chain->lock, flags);
 
result = 0;
if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) ||
@@ -1022,7 +1027,6 @@ refill:
/* change the descriptor state: */
if (!napi)
spider_net_refill_rx_chain(card);
-out:
return result;
 }
 
-
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/16] Spidernet Refactor RX refill

2006-12-06 Thread Linas Vepstas

Refactor how spider_net_refill_rx_chain() is called. 
No functional change; this just simplifies the code
by moving the subroutine call to a more appropriate spot.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:01:49.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:02:58.0 
-0600
@@ -1023,10 +1023,8 @@ spider_net_decode_one_descr(struct spide
/* ok, we've got a packet in descr */
result = spider_net_pass_skb_up(descr, card, napi);
 refill:
-   descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
/* change the descriptor state: */
-   if (!napi)
-   spider_net_refill_rx_chain(card);
+   descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
return result;
 }
 
@@ -1205,8 +1203,11 @@ spider_net_set_mac(struct net_device *ne
 static void
 spider_net_handle_rxram_full(struct spider_net_card *card)
 {
-   while (spider_net_decode_one_descr(card, 0))
-   ;
+   int rc = 1;
+   while (rc) {
+   rc = spider_net_decode_one_descr(card, 0);
+   spider_net_refill_rx_chain(card);
+   }
spider_net_enable_rxchtails(card);
spider_net_enable_rxdmac(card);
netif_rx_schedule(card->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 5/16] Spidernet RX skb mem leak

2006-12-06 Thread Linas Vepstas

One of the unlikely error branches has an skb memory leak.
Fix this by handling the error conditions consistently.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:02:58.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:00.0 
-0600
@@ -884,8 +884,8 @@ spider_net_do_ioctl(struct net_device *n
  *
  * returns 1 on success, 0 if no packet was passed to the stack
  *
- * iommu-unmaps the skb, fills out skb structure and passes the data to the
- * stack. The descriptor state is not changed.
+ * Fills out skb structure and passes the data to the stack.
+ * The descriptor state is not changed.
  */
 static int
 spider_net_pass_skb_up(struct spider_net_descr *descr,
@@ -900,10 +900,6 @@ spider_net_pass_skb_up(struct spider_net
 
netdev = card->netdev;
 
-   /* unmap descriptor */
-   pci_unmap_single(card->pdev, descr->buf_addr, SPIDER_NET_MAX_FRAME,
-   PCI_DMA_FROMDEVICE);
-
/* the cases we'll throw away the packet immediately */
if (data_error & SPIDER_NET_DESTROY_RX_FLAGS) {
if (netif_msg_rx_err(card))
@@ -998,6 +994,11 @@ spider_net_decode_one_descr(struct spide
spin_unlock_irqrestore(&chain->lock, flags);
 
result = 0;
+
+   /* unmap descriptor */
+   pci_unmap_single(card->pdev, descr->buf_addr,
+   SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
+
if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) ||
 (status == SPIDER_NET_DESCR_PROTECTION_ERROR) ||
 (status == SPIDER_NET_DESCR_FORCE_END) ) {
@@ -1005,8 +1006,6 @@ spider_net_decode_one_descr(struct spide
pr_err("%s: dropping RX descriptor with state %d\n",
   card->netdev->name, status);
card->netdev_stats.rx_dropped++;
-   pci_unmap_single(card->pdev, descr->buf_addr,
-   SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
dev_kfree_skb_irq(descr->skb);
goto refill;
}
@@ -1014,9 +1013,10 @@ spider_net_decode_one_descr(struct spide
if ( (status != SPIDER_NET_DESCR_COMPLETE) &&
 (status != SPIDER_NET_DESCR_FRAME_END) ) {
if (netif_msg_rx_err(card))
-   pr_err("%s: RX descriptor with state %d\n",
+   pr_err("%s: RX descriptor with unkown state %d\n",
   card->netdev->name, status);
card->spider_stats.rx_desc_unk_state++;
+   dev_kfree_skb_irq(descr->skb);
goto refill;
}
 
-
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 6/16] Spidernet another skb mem leak

2006-12-06 Thread Linas Vepstas

Another skb leak in an error branch. Fix this by adding
call to dev_kfree_skb_irq() after moving to a more
appropriate spot.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:00.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:04.0 
-0600
@@ -897,19 +897,8 @@ spider_net_pass_skb_up(struct spider_net
 
data_status = descr->data_status;
data_error = descr->data_error;
-
netdev = card->netdev;
 
-   /* the cases we'll throw away the packet immediately */
-   if (data_error & SPIDER_NET_DESTROY_RX_FLAGS) {
-   if (netif_msg_rx_err(card))
-   pr_err("error in received descriptor found, "
-  "data_status=x%08x, data_error=x%08x\n",
-  data_status, data_error);
-   card->spider_stats.rx_desc_error++;
-   return 0;
-   }
-
skb = descr->skb;
skb->dev = netdev;
skb_put(skb, descr->valid_size);
@@ -1020,6 +1009,18 @@ spider_net_decode_one_descr(struct spide
goto refill;
}
 
+   /* The cases we'll throw away the packet immediately */
+   if (descr->data_error & SPIDER_NET_DESTROY_RX_FLAGS) {
+   if (netif_msg_rx_err(card))
+   pr_err("%s: error in received descriptor found, "
+  "data_status=x%08x, data_error=x%08x\n",
+  card->netdev->name,
+  descr->data_status, descr->data_error);
+   card->spider_stats.rx_desc_error++;
+   dev_kfree_skb_irq(descr->skb);
+   goto refill;
+   }
+
/* ok, we've got a packet in descr */
result = spider_net_pass_skb_up(descr, card, napi);
 refill:
-
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 7/16] Spidernet Cleanup return codes

2006-12-06 Thread Linas Vepstas

Simplify the somewhat convoluted use of return codes
in the rx buffre handling.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   31 ---
 1 file changed, 12 insertions(+), 19 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:04.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:06.0 
-0600
@@ -882,12 +882,10 @@ spider_net_do_ioctl(struct net_device *n
  * @card: card structure
  * @napi: whether caller is in NAPI context
  *
- * returns 1 on success, 0 if no packet was passed to the stack
- *
  * Fills out skb structure and passes the data to the stack.
  * The descriptor state is not changed.
  */
-static int
+static void
 spider_net_pass_skb_up(struct spider_net_descr *descr,
   struct spider_net_card *card, int napi)
 {
@@ -935,8 +933,6 @@ spider_net_pass_skb_up(struct spider_net
/* update netdevice statistics */
card->netdev_stats.rx_packets++;
card->netdev_stats.rx_bytes += skb->len;
-
-   return 1;
 }
 
 /**
@@ -956,7 +952,6 @@ spider_net_decode_one_descr(struct spide
struct spider_net_descr_chain *chain = &card->rx_chain;
struct spider_net_descr *descr;
int status;
-   int result;
unsigned long flags;
 
spin_lock_irqsave(&chain->lock, flags);
@@ -982,8 +977,6 @@ spider_net_decode_one_descr(struct spide
chain->tail = descr->next;
spin_unlock_irqrestore(&chain->lock, flags);
 
-   result = 0;
-
/* unmap descriptor */
pci_unmap_single(card->pdev, descr->buf_addr,
SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
@@ -995,8 +988,7 @@ spider_net_decode_one_descr(struct spide
pr_err("%s: dropping RX descriptor with state %d\n",
   card->netdev->name, status);
card->netdev_stats.rx_dropped++;
-   dev_kfree_skb_irq(descr->skb);
-   goto refill;
+   goto bad_desc;
}
 
if ( (status != SPIDER_NET_DESCR_COMPLETE) &&
@@ -1005,8 +997,7 @@ spider_net_decode_one_descr(struct spide
pr_err("%s: RX descriptor with unkown state %d\n",
   card->netdev->name, status);
card->spider_stats.rx_desc_unk_state++;
-   dev_kfree_skb_irq(descr->skb);
-   goto refill;
+   goto bad_desc;
}
 
/* The cases we'll throw away the packet immediately */
@@ -1017,16 +1008,18 @@ spider_net_decode_one_descr(struct spide
   card->netdev->name,
   descr->data_status, descr->data_error);
card->spider_stats.rx_desc_error++;
-   dev_kfree_skb_irq(descr->skb);
-   goto refill;
+   goto bad_desc;
}
 
-   /* ok, we've got a packet in descr */
-   result = spider_net_pass_skb_up(descr, card, napi);
-refill:
-   /* change the descriptor state: */
+   /* Ok, we've got a packet in descr */
+   spider_net_pass_skb_up(descr, card, napi);
descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
-   return result;
+   return 1;
+
+bad_desc:
+   dev_kfree_skb_irq(descr->skb);
+   descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
+   return 0;
 }
 
 /**
-
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 9/16] Spidernet Merge error branches

2006-12-06 Thread Linas Vepstas

Two distinct if() statements have the ame body. Merge the clauses.
Also clean up punctuation, capitalization, etc.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   28 
 1 file changed, 12 insertions(+), 16 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:08.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:09.0 
-0600
@@ -936,15 +936,16 @@ spider_net_pass_skb_up(struct spider_net
 }
 
 /**
- * spider_net_decode_one_descr - processes an rx descriptor
+ * spider_net_decode_one_descr - Processes an RX descriptor
  * @card: card structure
  * @napi: whether caller is in NAPI context
  *
- * returns 1 if a packet has been sent to the stack, otherwise 0
+ * Returns 1 if a packet has been sent to the stack, otherwise 0.
  *
- * processes an rx descriptor by iommu-unmapping the data buffer and passing
- * the packet up to the stack. This function is called in softirq
- * context, e.g. either bottom half from interrupt or NAPI polling context
+ * Processes an RX descriptor by iommu-unmapping the data buffer
+ * and passing the packet up to the stack. This function is called
+ * in a softirq context, e.g. either bottom half from interrupt or
+ * NAPI polling context.
  */
 static int
 spider_net_decode_one_descr(struct spider_net_card *card, int napi)
@@ -959,23 +960,18 @@ spider_net_decode_one_descr(struct spide
 
status = spider_net_get_descr_status(descr);
 
-   if (status == SPIDER_NET_DESCR_CARDOWNED) {
-   /* nothing in the descriptor yet */
+   /* Nothing in the descriptor yet, or ring is empty */
+   if ( (status == SPIDER_NET_DESCR_CARDOWNED) ||
+(status == SPIDER_NET_DESCR_NOT_IN_USE) ) {
spin_unlock_irqrestore(&chain->lock, flags);
return 0;
}
 
-   if (status == SPIDER_NET_DESCR_NOT_IN_USE) {
-   /* not initialized yet, the ring must be empty */
-   spin_unlock_irqrestore(&chain->lock, flags);
-   return 0;
-   }
-
-   /* descriptor definitively used -- move on tail */
+   /* Descriptor definitively used -- move on tail. */
chain->tail = descr->next;
spin_unlock_irqrestore(&chain->lock, flags);
 
-   /* unmap descriptor */
+   /* Unmap descriptor. */
pci_unmap_single(card->pdev, descr->buf_addr,
SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
 
@@ -998,7 +994,7 @@ spider_net_decode_one_descr(struct spide
goto bad_desc;
}
 
-   /* The cases we'll throw away the packet immediately */
+   /* The cases we'll throw away the packet immediately. */
if (descr->data_error & SPIDER_NET_DESTROY_RX_FLAGS) {
if (netif_msg_rx_err(card))
pr_err("%s: error in received descriptor found, "
-
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 8/16] Spidernet RX Refill

2006-12-06 Thread Linas Vepstas

The invocation of the rx ring refill routine is haphazard;
centralize and make its usage consistent.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:06.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:08.0 
-0600
@@ -968,8 +968,6 @@ spider_net_decode_one_descr(struct spide
if (status == SPIDER_NET_DESCR_NOT_IN_USE) {
/* not initialized yet, the ring must be empty */
spin_unlock_irqrestore(&chain->lock, flags);
-   spider_net_refill_rx_chain(card);
-   spider_net_enable_rxdmac(card);
return 0;
}
 
@@ -1058,6 +1056,7 @@ spider_net_poll(struct net_device *netde
netdev->quota -= packets_done;
*budget -= packets_done;
spider_net_refill_rx_chain(card);
+   spider_net_enable_rxdmac(card);
 
/* if all packets are in the stack, enable interrupts and return 0 */
/* if not, return 1 */
@@ -1197,11 +1196,9 @@ spider_net_set_mac(struct net_device *ne
 static void
 spider_net_handle_rxram_full(struct spider_net_card *card)
 {
-   int rc = 1;
-   while (rc) {
-   rc = spider_net_decode_one_descr(card, 0);
-   spider_net_refill_rx_chain(card);
-   }
+   while (spider_net_decode_one_descr(card, 0));
+
+   spider_net_refill_rx_chain(card);
spider_net_enable_rxchtails(card);
spider_net_enable_rxdmac(card);
netif_rx_schedule(card->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 10/16] Spidernet Remove unused variable

2006-12-06 Thread Linas Vepstas

Remove unused variable; this makes code easier to read.
Tweak commentary.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:09.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:11.0 
-0600
@@ -341,17 +341,16 @@ spider_net_free_rx_chain_contents(struct
  * @card: card structure
  * @descr: descriptor to re-init
  *
- * return 0 on succes, <0 on failure
+ * Return 0 on succes, <0 on failure.
  *
- * allocates a new rx skb, iommu-maps it and attaches it to the descriptor.
- * Activate the descriptor state-wise
+ * Allocates a new rx skb, iommu-maps it and attaches it to the 
+ * descriptor. Mark the descriptor as activated, ready-to-use.
  */
 static int
 spider_net_prepare_rx_descr(struct spider_net_card *card,
struct spider_net_descr *descr)
 {
dma_addr_t buf;
-   int error = 0;
int offset;
int bufsize;
 
@@ -379,7 +378,7 @@ spider_net_prepare_rx_descr(struct spide
(SPIDER_NET_RXBUF_ALIGN - 1);
if (offset)
skb_reserve(descr->skb, SPIDER_NET_RXBUF_ALIGN - offset);
-   /* io-mmu-map the skb */
+   /* iommu-map the skb */
buf = pci_map_single(card->pdev, descr->skb->data,
SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
descr->buf_addr = buf;
@@ -394,7 +393,7 @@ spider_net_prepare_rx_descr(struct spide
 SPIDER_NET_DMAC_NOINTR_COMPLETE;
}
 
-   return error;
+   return 0;
 }
 
 /**
-
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 11/16] Spidernet RX Chain tail

2006-12-06 Thread Linas Vepstas

Tell the hardware the location of the rx ring tail.
More punctuation cleanup.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:11.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:13.0 
-0600
@@ -457,10 +457,10 @@ spider_net_refill_rx_chain(struct spider
 }
 
 /**
- * spider_net_alloc_rx_skbs - allocates rx skbs in rx descriptor chains
+ * spider_net_alloc_rx_skbs - Allocates rx skbs in rx descriptor chains
  * @card: card structure
  *
- * returns 0 on success, <0 on failure
+ * Returns 0 on success, <0 on failure.
  */
 static int
 spider_net_alloc_rx_skbs(struct spider_net_card *card)
@@ -471,17 +471,18 @@ spider_net_alloc_rx_skbs(struct spider_n
result = -ENOMEM;
 
chain = &card->rx_chain;
-   /* put at least one buffer into the chain. if this fails,
-* we've got a problem. if not, spider_net_refill_rx_chain
-* will do the rest at the end of this function */
+   /* Put at least one buffer into the chain. if this fails,
+* we've got a problem. If not, spider_net_refill_rx_chain
+* will do the rest at the end of this function. */
if (spider_net_prepare_rx_descr(card, chain->head))
goto error;
else
chain->head = chain->head->next;
 
-   /* this will allocate the rest of the rx buffers; if not, it's
-* business as usual later on */
+   /* This will allocate the rest of the rx buffers;
+* if not, it's business as usual later on. */
spider_net_refill_rx_chain(card);
+   spider_net_enable_rxchtails(card);
spider_net_enable_rxdmac(card);
return 0;
 
-
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 13/16] Spidernet Memory barrier

2006-12-06 Thread Linas Vepstas

Add memory barrier to make sure that the rest of the 
RX descriptor state is flushed to memory before we tell 
the hardware that its ready to go.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:15.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:16.0 
-0600
@@ -389,6 +389,7 @@ spider_net_prepare_rx_descr(struct spide
card->spider_stats.rx_iommu_map_error++;
descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
} else {
+   wmb();
descr->dmac_cmd_status = SPIDER_NET_DESCR_CARDOWNED |
 SPIDER_NET_DMAC_NOINTR_COMPLETE;
}
-
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 12/16] Spidernet Turn RX irq back on

2006-12-06 Thread Linas Vepstas

Re-enable irq's after emptying the RX ring; these had
been previously turned off on reception of the rxram_full
interrupt. More punctuation cleanup.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:13.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:15.0 
-0600
@@ -1182,12 +1182,11 @@ spider_net_set_mac(struct net_device *ne
 }
 
 /**
- * spider_net_handle_rxram_full - cleans up RX ring upon RX RAM full interrupt
+ * spider_net_handle_rxram_full - Clean RX ring on RX RAM full interrupt
  * @card: card structure
  *
- * spider_net_handle_rxram_full empties the RX ring so that spider can put
- * more packets in it and empty its RX RAM. This is called in bottom half
- * context
+ * Empty the RX ring so that the hardware can put more packets
+ * in it and empty its RX RAM. This is called in bottom half context.
  */
 static void
 spider_net_handle_rxram_full(struct spider_net_card *card)
@@ -1198,6 +1197,7 @@ spider_net_handle_rxram_full(struct spid
spider_net_enable_rxchtails(card);
spider_net_enable_rxdmac(card);
netif_rx_schedule(card->netdev);
+   spider_net_rx_irq_on(card);
 }
 
 /**
-
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 14/16] Spidernet Avoid possible RX chain corruption

2006-12-06 Thread Linas Vepstas

Delete possible source of chain corruption; the hardware
already knows the location of the tail, and writing it
again is likely to mess it up.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>



 drivers/net/spider_net.c |1 -
 1 file changed, 1 deletion(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:16.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:18.0 
-0600
@@ -1195,7 +1195,6 @@ spider_net_handle_rxram_full(struct spid
while (spider_net_decode_one_descr(card, 0));
 
spider_net_refill_rx_chain(card);
-   spider_net_enable_rxchtails(card);
spider_net_enable_rxdmac(card);
netif_rx_schedule(card->netdev);
spider_net_rx_irq_on(card);
-
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 15/16] Spidernet RX Debugging printout

2006-12-06 Thread Linas Vepstas

Add some debugging and error printing.

The show_rx_chain() prints out the status of the rx chain,
which shows that the status of the descriptors gets
messed up after the second & subsequent RX ramfulls.

Print out contents of bad packets if error occurs.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   47 +++
 1 file changed, 47 insertions(+)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:18.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:03:20.0 
-0600
@@ -936,6 +936,34 @@ spider_net_pass_skb_up(struct spider_net
card->netdev_stats.rx_bytes += skb->len;
 }
 
+#ifdef DEBUG
+static void show_rx_chain(struct spider_net_card *card)
+{
+   struct spider_net_descr_chain *chain = &card->rx_chain;
+   struct spider_net_descr *start= chain->tail;
+   struct spider_net_descr *descr= start;
+   int status;
+
+   int cnt = 0;
+   int cstat = spider_net_get_descr_status(descr);
+   printk(KERN_INFO "RX chain tail at descr=%ld\n",
+(start - card->descr) - card->num_tx_desc);
+   status = cstat;
+   do
+   {
+   status = spider_net_get_descr_status(descr);
+   if (cstat != status) {
+   printk(KERN_INFO "Have %d descrs with stat=x%08x\n", 
cnt, cstat);
+   cstat = status;
+   cnt = 0;
+   }
+   cnt ++;
+   descr = descr->next;
+   } while (descr != start);
+   printk(KERN_INFO "Last %d descrs with stat=x%08x\n", cnt, cstat);
+}
+#endif
+
 /**
  * spider_net_decode_one_descr - Processes an RX descriptor
  * @card: card structure
@@ -1006,6 +1034,25 @@ spider_net_decode_one_descr(struct spide
goto bad_desc;
}
 
+   if (descr->dmac_cmd_status & 0xfefe) {
+   pr_err("%s: bad status, cmd_status=x%08x\n",
+  card->netdev->name,
+  descr->dmac_cmd_status);
+   pr_err("buf_addr=x%08x\n", descr->buf_addr);
+   pr_err("buf_size=x%08x\n", descr->buf_size);
+   pr_err("next_descr_addr=x%08x\n", descr->next_descr_addr);
+   pr_err("result_size=x%08x\n", descr->result_size);
+   pr_err("valid_size=x%08x\n", descr->valid_size);
+   pr_err("data_status=x%08x\n", descr->data_status);
+   pr_err("data_error=x%08x\n", descr->data_error);
+   pr_err("bus_addr=x%08x\n", descr->bus_addr);
+   pr_err("which=%ld\n",
+  (descr - card->descr) - card->num_tx_desc);
+
+   card->spider_stats.rx_desc_error++;
+   goto bad_desc;
+   }
+
/* Ok, we've got a packet in descr */
spider_net_pass_skb_up(descr, card, napi);
descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
-
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 16/16] Spidernet Rework RX linked list

2006-12-06 Thread Linas Vepstas

Make the hardware perceive the RX descriptor ring as a 
null-terminated linked list, instead of a circular ring.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 
16:03:20.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-06 16:05:48.0 
-0600
@@ -389,9 +389,13 @@ spider_net_prepare_rx_descr(struct spide
card->spider_stats.rx_iommu_map_error++;
descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
} else {
+   descr->next_descr_addr = 0;
wmb();
descr->dmac_cmd_status = SPIDER_NET_DESCR_CARDOWNED |
 SPIDER_NET_DMAC_NOINTR_COMPLETE;
+
+   wmb();
+   descr->prev->next_descr_addr = descr->bus_addr;
}
 
return 0;
@@ -1676,12 +1680,6 @@ spider_net_open(struct net_device *netde
+ card->num_tx_desc * sizeof(struct 
spider_net_descr),
  card->num_rx_desc);
 
-   descr = card->rx_chain.head;
-   do {
-   descr->next_descr_addr = descr->next->bus_addr;
-   descr = descr->next;
-   } while (descr != card->rx_chain.head);
-
/* allocate rx skbs */
if (spider_net_alloc_rx_skbs(card))
goto alloc_skbs_failed;
-
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 1/16] Spidernet DMA coalescing

2006-12-07 Thread Linas Vepstas
On Wed, Dec 06, 2006 at 11:08:47PM -0800, Andrew Morton wrote:
> 
> It worries me when a patch series gets resent a few hours later.
> 
> Did anything change?

I did not resend this patch series.  However, I did receive a large 
number of MTA errors:
   <[EMAIL PROTECTED]>: mail forwarding loop for [EMAIL PROTECTED]

which might be related to what you saw.

(I also cc'ed several lists, and delivry on one of the lists may have
been delayed by a few hours??)

--linas
-
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 3/16] Spidernet RX Locking

2006-12-07 Thread Linas Vepstas
On Thu, Dec 07, 2006 at 05:09:20AM -0500, Jeff Garzik wrote:
> Linas Vepstas wrote:
> >The RX packet handling can be called from several
> >places, yet does not protect the rx ring structure.
> >This patch places the ring buffer pointers under a lock.
> >
> >Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
> >Cc: James K Lewis <[EMAIL PROTECTED]>
> >Cc: Arnd Bergmann <[EMAIL PROTECTED]>
> 
> This is a HUGELY invasive patch.  A sledgehammer.

I am rather unlear what you perceive as being invasive, 
since the patch summary states:

 drivers/net/spider_net.c |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

> What /specifically/ are these "several places", 

spider_net_decode_one_descr() is called from
spider_net_poll() (which is the netdev->poll callback)
and also from spider_net_handle_rxram_full(). 

The rxramfull routine is called from a tasklet that
is fired off after a "RX ram full" interrupt is receved.
This interrupt is generated when the hardware runs out
of space to store incoming packets. We are seeing this
interrupt fire when the CPU is heavily loaded, and a
lot of traffic is being fired at the device.

> and what other 
> non-sledgehammer approaches were discarded before arriving at this one?

Well, I'm not that good at kernel programming, so I guess
I did not perceive this as a "sledgehammer."  And alternative
approach is to simply ignore the rxramfull interrupt entirely,
and depend on poll() do all the work.   I'll try this shortly.

--linas
-
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 3/16] Spidernet RX Locking

2006-12-11 Thread Linas Vepstas
On Sat, Dec 09, 2006 at 09:47:05AM +1100, Benjamin Herrenschmidt wrote:
> A spinlock is expensive in the fast path, which is why Jeff says it's
> invasive.
> 
> > spider_net_decode_one_descr() is called from
> > spider_net_poll() (which is the netdev->poll callback)
> > and also from spider_net_handle_rxram_full(). 
> > 
> > The rxramfull routine is called from a tasklet that
> > is fired off after a "RX ram full" interrupt is receved.
> > This interrupt is generated when the hardware runs out
> > of space to store incoming packets. We are seeing this
> > interrupt fire when the CPU is heavily loaded, and a
> > lot of traffic is being fired at the device.
> 
> How often does that interrupt happen in that case ?

It is hard to reproduce; it is highly dependent on kernel version
and network config. It seems to occur when the system is somehow
loaded, and the tcp stack is unable to empty out the rx ring in a
timely manner. Jim is able o trigger this trivially for some kernels, 
but not others.

> A better approach is to keep the fast path (ie. poll()) lockless, and in
> handle_rxram_full(), the slow path, protect against poll using
> netif_disable_poll(). Though that means using a work queue, not a
> tasklet, since it needs to schedule.

Yes. Actually, I am thinking of treating this interrupt as if it were
just another RX interrupt. What the original drivers seemed to want to
do was to treat this as some sort of "high priority" rx interrupt, but
there doesn't seem to be any real way of doing this, so it seems simpler
just to rip out the tasklet and leave it at that.

> or you can schedule rx work from the rxramfull interrupt after setting a
> "something bad happened" flag. Then, poll can check this flag and do the
> right thing.

Yes, exactly.

--linas
> 
-
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-12 Thread Linas Vepstas
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 patch is not tested on CellBlade.

I just tested this, and it does not work. Jim Lewis is gone
until the new year. However, as he was leaving, he grumbled something
about how autonegotiation simply won't work on the spider. 
(I didn't think to ask about the details). Perhaps he'll 
look at his email soon?

I've been trying to figure out how to modify the patch to make it 
work anyway, but so far, no success. 

Basically, in genmii_poll_link(), 
  status = phy_read(phy, MII_BMSR);
status & BMSR_LSTATUS will always be zero.

So I tried ignoring this value, and calling setup_forced()
However, this still doesn't get the thing working.
I am somewhat at a loss to see why right now, since
I don't see what may be causing this.

--linas

-
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-13 Thread Linas Vepstas
On Wed, Dec 13, 2006 at 02:54:37PM +1100, Benjamin Herrenschmidt wrote:
> Cell blade because it's using a fiber link

Oh. I didn't know that. 

--linas
-
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 1/16] Spidernet DMA coalescing

2006-12-13 Thread Linas Vepstas
On Thu, Dec 07, 2006 at 10:11:51AM +, Christoph Hellwig wrote:
> On Wed, Dec 06, 2006 at 05:27:45PM -0600, Linas Vepstas wrote:
> > 
> > The current driver code performs 512 DMA mappings of a bunch of 
> > 32-byte structures. This is silly, as they are all in contiguous 
> > memory. Ths patch changes the code to DMA map the entie area
> > with just one call.
> 
> This is still wrong.  The descriptor array must be in dma_alloc_coherent
> memory, not a streaming mapping.  (I also think I pointed this out a while
> ago when I made dma_alloc_coherent node-aware)

Sorry, I missed this the first time. I'm splitting this off now; will 
resubmit shortly.

--linas
-
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/14]: Spidernet RX-side patches

2006-12-13 Thread Linas Vepstas

Andrew, 

Please apply; these patches obsolete/replace the series of 16 patches
I'd previously sent, by addressing problems raised by Christoph Hellwig
and Jeff Garzik. 

Most of te focus of this series of patches is to simplify the RX code
be removing extraneous flags, branches, arguments, etc. The first
few patches are the biggest: using dma_alloc_coherent for the rings,
and removing a bogus tasklet that does work that could be better done in
the poll loop. The rest are mostly cleanup.

--linas
-
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/14] Spidernet add net_ratelimit to suppress long output

2006-12-13 Thread Linas Vepstas

This patch adds net_ratelimit to many of the printks in order to
limit extraneous warning messages (created in response to Bug 28554).
This patch supercedes all previous ratelimit patches.
This has been tested, please apply.

From: James K Lewis <[EMAIL PROTECTED]>
Signed-off-by: James K Lewis <[EMAIL PROTECTED]>
Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   11 +--
 drivers/net/spider_net.h |2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
13:04:04.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 13:19:59.0 
-0600
@@ -1038,11 +1038,10 @@ spider_net_decode_one_descr(struct spide
 
if ( (status != SPIDER_NET_DESCR_COMPLETE) &&
 (status != SPIDER_NET_DESCR_FRAME_END) ) {
-   if (netif_msg_rx_err(card)) {
+   if (netif_msg_rx_err(card))
pr_err("%s: RX descriptor with state %d\n",
   card->netdev->name, status);
-   card->spider_stats.rx_desc_unk_state++;
-   }
+   card->spider_stats.rx_desc_unk_state++;
goto refill;
}
 
@@ -1361,7 +1360,7 @@ spider_net_handle_error_irq(struct spide
case SPIDER_NET_GRFAFLLINT: /* fallthrough */
case SPIDER_NET_GRMFLLINT:
if (netif_msg_intr(card) && net_ratelimit())
-   pr_debug("Spider RX RAM full, incoming packets "
+   pr_err("Spider RX RAM full, incoming packets "
   "might be discarded!\n");
spider_net_rx_irq_off(card);
tasklet_schedule(&card->rxram_full_tl);
@@ -1379,7 +1378,7 @@ spider_net_handle_error_irq(struct spide
case SPIDER_NET_GDCDCEINT: /* fallthrough */
case SPIDER_NET_GDBDCEINT: /* fallthrough */
case SPIDER_NET_GDADCEINT:
-   if (netif_msg_intr(card))
+   if (netif_msg_intr(card) && net_ratelimit())
pr_err("got descriptor chain end interrupt, "
   "restarting DMAC %c.\n",
   'D'-(i-SPIDER_NET_GDDDCEINT)/3);
@@ -1450,7 +1449,7 @@ spider_net_handle_error_irq(struct spide
break;
}
 
-   if ((show_error) && (netif_msg_intr(card)))
+   if ((show_error) && (netif_msg_intr(card)) && net_ratelimit())
pr_err("Got error interrupt on %s, GHIINT0STS = 0x%08x, "
   "GHIINT1STS = 0x%08x, GHIINT2STS = 0x%08x\n",
   card->netdev->name,
Index: linux-2.6.19-git7/drivers/net/spider_net.h
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.h 2006-12-13 
12:04:02.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.h  2006-12-13 13:19:59.0 
-0600
@@ -24,7 +24,7 @@
 #ifndef _SPIDER_NET_H
 #define _SPIDER_NET_H
 
-#define VERSION "1.6 A"
+#define VERSION "1.6 B"
 
 #include "sungem_phy.h"
 
-
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/14] Spidernet DMA coalescing

2006-12-13 Thread Linas Vepstas

The current driver code performs 512 DMA mappings of a bunch of 
32-byte ring descriptor structures. This is silly, as they are 
all in contiguous memory. This patch changes the code to 
dma_map_coherent() each rx/tx ring as a whole.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |  103 +--
 drivers/net/spider_net.h |   17 +-
 drivers/net/spider_net_ethtool.c |4 -
 3 files changed, 54 insertions(+), 70 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
11:55:53.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 13:04:04.0 
-0600
@@ -280,72 +280,67 @@ spider_net_free_chain(struct spider_net_
 {
struct spider_net_descr *descr;
 
-   for (descr = chain->tail; !descr->bus_addr; descr = descr->next) {
-   pci_unmap_single(card->pdev, descr->bus_addr,
-SPIDER_NET_DESCR_SIZE, PCI_DMA_BIDIRECTIONAL);
+   descr = chain->ring;
+   do {
descr->bus_addr = 0;
-   }
+   descr->next_descr_addr = 0;
+   descr = descr->next;
+   } while (descr != chain->ring);
+
+   dma_free_coherent(&card->pdev->dev, chain->num_desc,
+   chain->ring, chain->dma_addr);
 }
 
 /**
- * spider_net_init_chain - links descriptor chain
+ * spider_net_init_chain - alloc and link descriptor chain
  * @card: card structure
  * @chain: address of chain
- * @start_descr: address of descriptor array
- * @no: number of descriptors
  *
- * we manage a circular list that mirrors the hardware structure,
+ * We manage a circular list that mirrors the hardware structure,
  * except that the hardware uses bus addresses.
  *
- * returns 0 on success, <0 on failure
+ * Returns 0 on success, <0 on failure
  */
 static int
 spider_net_init_chain(struct spider_net_card *card,
-  struct spider_net_descr_chain *chain,
-  struct spider_net_descr *start_descr,
-  int no)
+  struct spider_net_descr_chain *chain)
 {
int i;
struct spider_net_descr *descr;
dma_addr_t buf;
+   size_t alloc_size;
 
-   descr = start_descr;
-   memset(descr, 0, sizeof(*descr) * no);
+   alloc_size = chain->num_desc * sizeof (struct spider_net_descr);
 
-   /* set up the hardware pointers in each descriptor */
-   for (i=0; idmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
+   chain->ring = dma_alloc_coherent(&card->pdev->dev, alloc_size,
+   &chain->dma_addr, GFP_KERNEL);
 
-   buf = pci_map_single(card->pdev, descr,
-SPIDER_NET_DESCR_SIZE,
-PCI_DMA_BIDIRECTIONAL);
+   if (!chain->ring)
+   return -ENOMEM;
 
-   if (pci_dma_mapping_error(buf))
-   goto iommu_error;
+   descr = chain->ring;
+   memset(descr, 0, alloc_size);
+
+   /* Set up the hardware pointers in each descriptor */
+   buf = chain->dma_addr;
+   for (i=0; i < chain->num_desc; i++, descr++) {
+   descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
 
descr->bus_addr = buf;
+   descr->next_descr_addr = 0;
descr->next = descr + 1;
descr->prev = descr - 1;
 
+   buf += sizeof(struct spider_net_descr);
}
/* do actual circular list */
-   (descr-1)->next = start_descr;
-   start_descr->prev = descr-1;
+   (descr-1)->next = chain->ring;
+   chain->ring->prev = descr-1;
 
spin_lock_init(&chain->lock);
-   chain->head = start_descr;
-   chain->tail = start_descr;
-
+   chain->head = chain->ring;
+   chain->tail = chain->ring;
return 0;
-
-iommu_error:
-   descr = start_descr;
-   for (i=0; i < no; i++, descr++)
-   if (descr->bus_addr)
-   pci_unmap_single(card->pdev, descr->bus_addr,
-SPIDER_NET_DESCR_SIZE,
-PCI_DMA_BIDIRECTIONAL);
-   return -ENOMEM;
 }
 
 /**
@@ -707,7 +702,7 @@ spider_net_set_low_watermark(struct spid
}
 
/* If TX queue is short, don't even bother with interrupts */
-   if (cnt < card->num_tx_desc/4)
+   if (cnt < card->tx_chain.num_desc/4)
return cnt;
 
/* Set low-watermark 3/4th's of the way into the queue. */
@@ -1652,26 +1647,25 

[PATCH 4/14] Spidernet cleanup un-needed API

2006-12-13 Thread Linas Vepstas

There is no need to pass a flag into spider_net_decode_one_descr()
so remove this, and perform some othre minor cleanup.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   35 ---
 1 file changed, 12 insertions(+), 23 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:24:07.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:24:13.0 
-0600
@@ -910,7 +910,6 @@ spider_net_do_ioctl(struct net_device *n
  * spider_net_pass_skb_up - takes an skb from a descriptor and passes it on
  * @descr: descriptor to process
  * @card: card structure
- * @napi: whether caller is in NAPI context
  *
  * returns 1 on success, 0 if no packet was passed to the stack
  *
@@ -919,7 +918,7 @@ spider_net_do_ioctl(struct net_device *n
  */
 static int
 spider_net_pass_skb_up(struct spider_net_descr *descr,
-  struct spider_net_card *card, int napi)
+  struct spider_net_card *card)
 {
struct sk_buff *skb;
struct net_device *netdev;
@@ -972,10 +971,7 @@ spider_net_pass_skb_up(struct spider_net
}
 
/* pass skb up to stack */
-   if (napi)
-   netif_receive_skb(skb);
-   else
-   netif_rx_ni(skb);
+   netif_receive_skb(skb);
 
/* update netdevice statistics */
card->netdev_stats.rx_packets++;
@@ -987,16 +983,15 @@ spider_net_pass_skb_up(struct spider_net
 /**
  * spider_net_decode_one_descr - processes an rx descriptor
  * @card: card structure
- * @napi: whether caller is in NAPI context
  *
- * returns 1 if a packet has been sent to the stack, otherwise 0
+ * Returns 1 if a packet has been sent to the stack, otherwise 0
  *
- * processes an rx descriptor by iommu-unmapping the data buffer and passing
+ * Processes an rx descriptor by iommu-unmapping the data buffer and passing
  * the packet up to the stack. This function is called in softirq
  * context, e.g. either bottom half from interrupt or NAPI polling context
  */
 static int
-spider_net_decode_one_descr(struct spider_net_card *card, int napi)
+spider_net_decode_one_descr(struct spider_net_card *card)
 {
struct spider_net_descr_chain *chain = &card->rx_chain;
struct spider_net_descr *descr = chain->tail;
@@ -1005,18 +1000,15 @@ spider_net_decode_one_descr(struct spide
 
status = spider_net_get_descr_status(descr);
 
-   if (status == SPIDER_NET_DESCR_CARDOWNED) {
-   /* nothing in the descriptor yet */
-   result=0;
-   goto out;
-   }
+   /* nothing in the descriptor yet */
+   if (status == SPIDER_NET_DESCR_CARDOWNED)
+   return 0;
 
if (status == SPIDER_NET_DESCR_NOT_IN_USE) {
/* not initialized yet, the ring must be empty */
spider_net_refill_rx_chain(card);
spider_net_enable_rxdmac(card);
-   result=0;
-   goto out;
+   return 0;
}
 
/* descriptor definitively used -- move on tail */
@@ -1046,13 +1038,10 @@ spider_net_decode_one_descr(struct spide
}
 
/* ok, we've got a packet in descr */
-   result = spider_net_pass_skb_up(descr, card, napi);
+   result = spider_net_pass_skb_up(descr, card);
 refill:
-   descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
/* change the descriptor state: */
-   if (!napi)
-   spider_net_refill_rx_chain(card);
-out:
+   descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
return result;
 }
 
@@ -1079,7 +1068,7 @@ spider_net_poll(struct net_device *netde
packets_to_do = min(*budget, netdev->quota);
 
while (packets_to_do) {
-   if (spider_net_decode_one_descr(card, 1)) {
+   if (spider_net_decode_one_descr(card)) {
packets_done++;
packets_to_do--;
} else {
-
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/14] Spidernet remove rxramfull tasklet

2006-12-13 Thread Linas Vepstas

Get rid of the rxramfull tasklet, and let the NAPI poll routine
deal with this situation. (The rxramfull interrupt is simply 
stating that the h/w has run out of room for incoming packets).

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   24 +---
 drivers/net/spider_net.h |1 -
 2 files changed, 1 insertion(+), 24 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:24:04.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:24:07.0 
-0600
@@ -1221,24 +1221,6 @@ spider_net_set_mac(struct net_device *ne
 }
 
 /**
- * spider_net_handle_rxram_full - cleans up RX ring upon RX RAM full interrupt
- * @card: card structure
- *
- * spider_net_handle_rxram_full empties the RX ring so that spider can put
- * more packets in it and empty its RX RAM. This is called in bottom half
- * context
- */
-static void
-spider_net_handle_rxram_full(struct spider_net_card *card)
-{
-   while (spider_net_decode_one_descr(card, 0))
-   ;
-   spider_net_enable_rxchtails(card);
-   spider_net_enable_rxdmac(card);
-   netif_rx_schedule(card->netdev);
-}
-
-/**
  * spider_net_handle_error_irq - handles errors raised by an interrupt
  * @card: card structure
  * @status_reg: interrupt status register 0 (GHIINT0STS)
@@ -1363,7 +1345,7 @@ spider_net_handle_error_irq(struct spide
pr_err("Spider RX RAM full, incoming packets "
   "might be discarded!\n");
spider_net_rx_irq_off(card);
-   tasklet_schedule(&card->rxram_full_tl);
+   netif_rx_schedule(card->netdev);
show_error = 0;
break;
 
@@ -1895,7 +1877,6 @@ spider_net_stop(struct net_device *netde
 {
struct spider_net_card *card = netdev_priv(netdev);
 
-   tasklet_kill(&card->rxram_full_tl);
netif_poll_disable(netdev);
netif_carrier_off(netdev);
netif_stop_queue(netdev);
@@ -2037,9 +2018,6 @@ spider_net_setup_netdev(struct spider_ne
 
pci_set_drvdata(card->pdev, netdev);
 
-   card->rxram_full_tl.data = (unsigned long) card;
-   card->rxram_full_tl.func =
-   (void (*)(unsigned long)) spider_net_handle_rxram_full;
init_timer(&card->tx_timer);
card->tx_timer.function =
(void (*)(unsigned long)) spider_net_cleanup_tx_ring;
Index: linux-2.6.19-git7/drivers/net/spider_net.h
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.h 2006-12-13 
14:24:04.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.h  2006-12-13 14:24:07.0 
-0600
@@ -442,7 +442,6 @@ struct spider_net_card {
struct spider_net_descr_chain rx_chain;
struct spider_net_descr *low_watermark;
 
-   struct tasklet_struct rxram_full_tl;
struct timer_list tx_timer;
struct work_struct tx_timeout_task;
atomic_t tx_timeout_task_counter;
-
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 6/14] Spidernet another skb mem leak

2006-12-13 Thread Linas Vepstas

Another skb leak in an error branch. Fix this by adding
call to dev_kfree_skb_irq() after moving to a more
appropriate spot.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:24:16.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:24:20.0 
-0600
@@ -926,19 +926,8 @@ spider_net_pass_skb_up(struct spider_net
 
data_status = descr->data_status;
data_error = descr->data_error;
-
netdev = card->netdev;
 
-   /* the cases we'll throw away the packet immediately */
-   if (data_error & SPIDER_NET_DESTROY_RX_FLAGS) {
-   if (netif_msg_rx_err(card))
-   pr_err("error in received descriptor found, "
-  "data_status=x%08x, data_error=x%08x\n",
-  data_status, data_error);
-   card->spider_stats.rx_desc_error++;
-   return 0;
-   }
-
skb = descr->skb;
skb->dev = netdev;
skb_put(skb, descr->valid_size);
@@ -1037,6 +1026,18 @@ spider_net_decode_one_descr(struct spide
goto refill;
}
 
+   /* The cases we'll throw away the packet immediately */
+   if (descr->data_error & SPIDER_NET_DESTROY_RX_FLAGS) {
+   if (netif_msg_rx_err(card))
+   pr_err("%s: error in received descriptor found, "
+  "data_status=x%08x, data_error=x%08x\n",
+  card->netdev->name,
+  descr->data_status, descr->data_error);
+   card->spider_stats.rx_desc_error++;
+   dev_kfree_skb_irq(descr->skb);
+   goto refill;
+   }
+
/* ok, we've got a packet in descr */
result = spider_net_pass_skb_up(descr, card);
 refill:
-
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/14] Spidernet RX skb mem leak

2006-12-13 Thread Linas Vepstas

One of the unlikely error branches has an skb memory leak.
Fix this by handling the error conditions consistently.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:24:13.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:24:16.0 
-0600
@@ -913,8 +913,8 @@ spider_net_do_ioctl(struct net_device *n
  *
  * returns 1 on success, 0 if no packet was passed to the stack
  *
- * iommu-unmaps the skb, fills out skb structure and passes the data to the
- * stack. The descriptor state is not changed.
+ * Fills out skb structure and passes the data to the stack.
+ * The descriptor state is not changed.
  */
 static int
 spider_net_pass_skb_up(struct spider_net_descr *descr,
@@ -929,10 +929,6 @@ spider_net_pass_skb_up(struct spider_net
 
netdev = card->netdev;
 
-   /* unmap descriptor */
-   pci_unmap_single(card->pdev, descr->buf_addr, SPIDER_NET_MAX_FRAME,
-   PCI_DMA_FROMDEVICE);
-
/* the cases we'll throw away the packet immediately */
if (data_error & SPIDER_NET_DESTROY_RX_FLAGS) {
if (netif_msg_rx_err(card))
@@ -1015,6 +1011,11 @@ spider_net_decode_one_descr(struct spide
chain->tail = descr->next;
 
result = 0;
+
+   /* unmap descriptor */
+   pci_unmap_single(card->pdev, descr->buf_addr,
+   SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
+
if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) ||
 (status == SPIDER_NET_DESCR_PROTECTION_ERROR) ||
 (status == SPIDER_NET_DESCR_FORCE_END) ) {
@@ -1022,8 +1023,6 @@ spider_net_decode_one_descr(struct spide
pr_err("%s: dropping RX descriptor with state %d\n",
   card->netdev->name, status);
card->netdev_stats.rx_dropped++;
-   pci_unmap_single(card->pdev, descr->buf_addr,
-   SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
dev_kfree_skb_irq(descr->skb);
goto refill;
}
@@ -1031,9 +1030,10 @@ spider_net_decode_one_descr(struct spide
if ( (status != SPIDER_NET_DESCR_COMPLETE) &&
 (status != SPIDER_NET_DESCR_FRAME_END) ) {
if (netif_msg_rx_err(card))
-   pr_err("%s: RX descriptor with state %d\n",
+   pr_err("%s: RX descriptor with unkown state %d\n",
   card->netdev->name, status);
card->spider_stats.rx_desc_unk_state++;
+   dev_kfree_skb_irq(descr->skb);
goto refill;
}
 
-
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 11/14] Spidernet Memory barrier

2006-12-13 Thread Linas Vepstas

Add memory barrier to make sure that the rest of the 
RX descriptor state is flushed to memory before we tell 
the hardware that its ready to go.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:28:19.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:28:23.0 
-0600
@@ -419,6 +419,7 @@ spider_net_prepare_rx_descr(struct spide
card->spider_stats.rx_iommu_map_error++;
descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
} else {
+   wmb();
descr->dmac_cmd_status = SPIDER_NET_DESCR_CARDOWNED |
 SPIDER_NET_DMAC_NOINTR_COMPLETE;
}
-
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 12/14] Spidernet Avoid possible RX chain corruption

2006-12-13 Thread Linas Vepstas

Delete possible source of chain corruption; the hardware
already knows the location of the tail, and writing it
again is likely to mess it up.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>



 drivers/net/spider_net.c |1 -
 1 file changed, 1 deletion(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:28:23.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:28:25.0 
-0600
@@ -513,7 +513,6 @@ spider_net_alloc_rx_skbs(struct spider_n
/* This will allocate the rest of the rx buffers;
 * if not, it's business as usual later on. */
spider_net_refill_rx_chain(card);
-   spider_net_enable_rxchtails(card);
spider_net_enable_rxdmac(card);
return 0;
 
-
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 10/14] Spidernet RX Chain tail

2006-12-13 Thread Linas Vepstas

Tell the hardware the location of the rx ring tail.
More punctuation cleanup.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:28:15.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:28:19.0 
-0600
@@ -487,10 +487,10 @@ spider_net_refill_rx_chain(struct spider
 }
 
 /**
- * spider_net_alloc_rx_skbs - allocates rx skbs in rx descriptor chains
+ * spider_net_alloc_rx_skbs - Allocates rx skbs in rx descriptor chains
  * @card: card structure
  *
- * returns 0 on success, <0 on failure
+ * Returns 0 on success, <0 on failure.
  */
 static int
 spider_net_alloc_rx_skbs(struct spider_net_card *card)
@@ -501,17 +501,18 @@ spider_net_alloc_rx_skbs(struct spider_n
result = -ENOMEM;
 
chain = &card->rx_chain;
-   /* put at least one buffer into the chain. if this fails,
-* we've got a problem. if not, spider_net_refill_rx_chain
-* will do the rest at the end of this function */
+   /* Put at least one buffer into the chain. if this fails,
+* we've got a problem. If not, spider_net_refill_rx_chain
+* will do the rest at the end of this function. */
if (spider_net_prepare_rx_descr(card, chain->head))
goto error;
else
chain->head = chain->head->next;
 
-   /* this will allocate the rest of the rx buffers; if not, it's
-* business as usual later on */
+   /* This will allocate the rest of the rx buffers;
+* if not, it's business as usual later on. */
spider_net_refill_rx_chain(card);
+   spider_net_enable_rxchtails(card);
spider_net_enable_rxdmac(card);
return 0;
 
-
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 8/14] Spidernet RX Refill

2006-12-13 Thread Linas Vepstas

The invocation of the rx ring refill routine is haphazard,
it can be called from a central location.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:27:35.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:28:11.0 
-0600
@@ -980,17 +980,11 @@ spider_net_decode_one_descr(struct spide
 
status = spider_net_get_descr_status(descr);
 
-   /* nothing in the descriptor yet */
-   if (status == SPIDER_NET_DESCR_CARDOWNED)
+   /* Nothing in the descriptor, or ring must be empty */
+   if ((status == SPIDER_NET_DESCR_CARDOWNED) ||
+   (status == SPIDER_NET_DESCR_NOT_IN_USE))
return 0;
 
-   if (status == SPIDER_NET_DESCR_NOT_IN_USE) {
-   /* not initialized yet, the ring must be empty */
-   spider_net_refill_rx_chain(card);
-   spider_net_enable_rxdmac(card);
-   return 0;
-   }
-
/* descriptor definitively used -- move on tail */
chain->tail = descr->next;
 
@@ -1074,6 +1068,7 @@ spider_net_poll(struct net_device *netde
netdev->quota -= packets_done;
*budget -= packets_done;
spider_net_refill_rx_chain(card);
+   spider_net_enable_rxdmac(card);
 
/* if all packets are in the stack, enable interrupts and return 0 */
/* if not, return 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 7/14] Spidernet Cleanup return codes

2006-12-13 Thread Linas Vepstas

Simplify the somewhat convoluted use of return codes
in the rx buffer handling.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   32 
 1 file changed, 12 insertions(+), 20 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:24:20.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:27:35.0 
-0600
@@ -911,12 +911,10 @@ spider_net_do_ioctl(struct net_device *n
  * @descr: descriptor to process
  * @card: card structure
  *
- * returns 1 on success, 0 if no packet was passed to the stack
- *
  * Fills out skb structure and passes the data to the stack.
  * The descriptor state is not changed.
  */
-static int
+static void
 spider_net_pass_skb_up(struct spider_net_descr *descr,
   struct spider_net_card *card)
 {
@@ -961,8 +959,6 @@ spider_net_pass_skb_up(struct spider_net
/* update netdevice statistics */
card->netdev_stats.rx_packets++;
card->netdev_stats.rx_bytes += skb->len;
-
-   return 1;
 }
 
 /**
@@ -981,7 +977,6 @@ spider_net_decode_one_descr(struct spide
struct spider_net_descr_chain *chain = &card->rx_chain;
struct spider_net_descr *descr = chain->tail;
int status;
-   int result;
 
status = spider_net_get_descr_status(descr);
 
@@ -999,8 +994,6 @@ spider_net_decode_one_descr(struct spide
/* descriptor definitively used -- move on tail */
chain->tail = descr->next;
 
-   result = 0;
-
/* unmap descriptor */
pci_unmap_single(card->pdev, descr->buf_addr,
SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
@@ -1012,8 +1005,7 @@ spider_net_decode_one_descr(struct spide
pr_err("%s: dropping RX descriptor with state %d\n",
   card->netdev->name, status);
card->netdev_stats.rx_dropped++;
-   dev_kfree_skb_irq(descr->skb);
-   goto refill;
+   goto bad_desc;
}
 
if ( (status != SPIDER_NET_DESCR_COMPLETE) &&
@@ -1022,8 +1014,7 @@ spider_net_decode_one_descr(struct spide
pr_err("%s: RX descriptor with unkown state %d\n",
   card->netdev->name, status);
card->spider_stats.rx_desc_unk_state++;
-   dev_kfree_skb_irq(descr->skb);
-   goto refill;
+   goto bad_desc;
}
 
/* The cases we'll throw away the packet immediately */
@@ -1033,17 +1024,18 @@ spider_net_decode_one_descr(struct spide
   "data_status=x%08x, data_error=x%08x\n",
   card->netdev->name,
   descr->data_status, descr->data_error);
-   card->spider_stats.rx_desc_error++;
-   dev_kfree_skb_irq(descr->skb);
-   goto refill;
+   goto bad_desc;
}
 
-   /* ok, we've got a packet in descr */
-   result = spider_net_pass_skb_up(descr, card);
-refill:
-   /* change the descriptor state: */
+   /* Ok, we've got a packet in descr */
+   spider_net_pass_skb_up(descr, card);
descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
-   return result;
+   return 1;
+
+bad_desc:
+   dev_kfree_skb_irq(descr->skb);
+   descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
+   return 0;
 }
 
 /**
-
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 9/14] Spidernet Remove unused variable

2006-12-13 Thread Linas Vepstas

Remove unused variable; this makes code easier to read.
Tweak commentary.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:28:11.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:28:15.0 
-0600
@@ -367,21 +367,20 @@ spider_net_free_rx_chain_contents(struct
 }
 
 /**
- * spider_net_prepare_rx_descr - reinitializes a rx descriptor
+ * spider_net_prepare_rx_descr - Reinitialize RX descriptor
  * @card: card structure
  * @descr: descriptor to re-init
  *
- * return 0 on succes, <0 on failure
+ * Return 0 on succes, <0 on failure.
  *
- * allocates a new rx skb, iommu-maps it and attaches it to the descriptor.
- * Activate the descriptor state-wise
+ * Allocates a new rx skb, iommu-maps it and attaches it to the
+ * descriptor. Mark the descriptor as activated, ready-to-use.
  */
 static int
 spider_net_prepare_rx_descr(struct spider_net_card *card,
struct spider_net_descr *descr)
 {
dma_addr_t buf;
-   int error = 0;
int offset;
int bufsize;
 
@@ -409,7 +408,7 @@ spider_net_prepare_rx_descr(struct spide
(SPIDER_NET_RXBUF_ALIGN - 1);
if (offset)
skb_reserve(descr->skb, SPIDER_NET_RXBUF_ALIGN - offset);
-   /* io-mmu-map the skb */
+   /* iommu-map the skb */
buf = pci_map_single(card->pdev, descr->skb->data,
SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
descr->buf_addr = buf;
@@ -424,7 +423,7 @@ spider_net_prepare_rx_descr(struct spide
 SPIDER_NET_DMAC_NOINTR_COMPLETE;
}
 
-   return error;
+   return 0;
 }
 
 /**
-
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 13/14] Spidernet RX Debugging printout

2006-12-13 Thread Linas Vepstas

Add some debugging and error printing.

The show_rx_chain() prints out the status of the rx chain,
which shows that the status of the descriptors gets
messed up after the second & subsequent RX ramfulls.

Print out contents of bad packets if error occurs.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   46 ++
 1 file changed, 46 insertions(+)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:30:43.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:32:13.0 
-0600
@@ -961,6 +961,34 @@ spider_net_pass_skb_up(struct spider_net
card->netdev_stats.rx_bytes += skb->len;
 }
 
+#ifdef DEBUG
+static void show_rx_chain(struct spider_net_card *card)
+{
+   struct spider_net_descr_chain *chain = &card->rx_chain;
+   struct spider_net_descr *start= chain->tail;
+   struct spider_net_descr *descr= start;
+   int status;
+
+   int cnt = 0;
+   int cstat = spider_net_get_descr_status(descr);
+   printk(KERN_INFO "RX chain tail at descr=%ld\n",
+(start - card->descr) - card->tx_chain.num_desc);
+   status = cstat;
+   do
+   {
+   status = spider_net_get_descr_status(descr);
+   if (cstat != status) {
+   printk(KERN_INFO "Have %d descrs with stat=x%08x\n", 
cnt, cstat);
+   cstat = status;
+   cnt = 0;
+   }
+   cnt ++;
+   descr = descr->next;
+   } while (descr != start);
+   printk(KERN_INFO "Last %d descrs with stat=x%08x\n", cnt, cstat);
+}
+#endif
+
 /**
  * spider_net_decode_one_descr - processes an rx descriptor
  * @card: card structure
@@ -1021,6 +1049,24 @@ spider_net_decode_one_descr(struct spide
goto bad_desc;
}
 
+   if (descr->dmac_cmd_status & 0xfefe) {
+   pr_err("%s: bad status, cmd_status=x%08x\n",
+  card->netdev->name,
+  descr->dmac_cmd_status);
+   pr_err("buf_addr=x%08x\n", descr->buf_addr);
+   pr_err("buf_size=x%08x\n", descr->buf_size);
+   pr_err("next_descr_addr=x%08x\n", descr->next_descr_addr);
+   pr_err("result_size=x%08x\n", descr->result_size);
+   pr_err("valid_size=x%08x\n", descr->valid_size);
+   pr_err("data_status=x%08x\n", descr->data_status);
+   pr_err("data_error=x%08x\n", descr->data_error);
+   pr_err("bus_addr=x%08x\n", descr->bus_addr);
+   pr_err("which=%ld\n", descr - card->rx_chain.ring);
+
+   card->spider_stats.rx_desc_error++;
+   goto bad_desc;
+   }
+
/* Ok, we've got a packet in descr */
spider_net_pass_skb_up(descr, card);
descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
-
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 14/14] Spidernet Rework RX linked list

2006-12-13 Thread Linas Vepstas

Make the hardware perceive the RX descriptor ring as a 
null-terminated linked list, instead of a circular ring.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   12 
 1 file changed, 4 insertions(+), 8 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:32:13.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-13 14:33:21.0 
-0600
@@ -419,9 +419,13 @@ spider_net_prepare_rx_descr(struct spide
card->spider_stats.rx_iommu_map_error++;
descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
} else {
+   descr->next_descr_addr = 0;
wmb();
descr->dmac_cmd_status = SPIDER_NET_DESCR_CARDOWNED |
 SPIDER_NET_DMAC_NOINTR_COMPLETE;
+
+   wmb();
+   descr->prev->next_descr_addr = descr->bus_addr;
}
 
return 0;
@@ -1650,7 +1654,6 @@ int
 spider_net_open(struct net_device *netdev)
 {
struct spider_net_card *card = netdev_priv(netdev);
-   struct spider_net_descr *descr;
int result;
 
result = spider_net_init_chain(card, &card->tx_chain);
@@ -1662,13 +1665,6 @@ spider_net_open(struct net_device *netde
if (result)
goto alloc_rx_failed;
 
-   /* Make a ring of of bus addresses */
-   descr = card->rx_chain.ring;
-   do {
-   descr->next_descr_addr = descr->next->bus_addr;
-   descr = descr->next;
-   } while (descr != card->rx_chain.ring);
-
/* Allocate rx skbs */
if (spider_net_alloc_rx_skbs(card))
goto alloc_skbs_failed;
-
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 1/14] Spidernet DMA coalescing

2006-12-14 Thread Linas Vepstas
On Thu, Dec 14, 2006 at 11:05:17AM +, Christoph Hellwig wrote:
> On Wed, Dec 13, 2006 at 03:06:59PM -0600, Linas Vepstas wrote:
> > 
> > The current driver code performs 512 DMA mappings of a bunch of 
> > 32-byte ring descriptor structures. This is silly, as they are 
> > all in contiguous memory. This patch changes the code to 
> > dma_map_coherent() each rx/tx ring as a whole.
> 
> It's acutally dma_alloc_coherent now that you updated the patch :)
> 
> > +   chain->ring = dma_alloc_coherent(&card->pdev->dev, alloc_size,
> > +   &chain->dma_addr, GFP_KERNEL);
> >  
> > +   if (!chain->ring)
> > +   return -ENOMEM;
> >  
> > +   descr = chain->ring;
> > +   memset(descr, 0, alloc_size);
> 
> dma_alloc_coherent is defined to zero the allocated memory, so you
> won't need this memset.

Being unclear on the concept, should a send a new version of this patch,
or should I send a new patch that removes this?

--linas
-
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 12/14] Spidernet Avoid possible RX chain corruption

2006-12-14 Thread Linas Vepstas
On Thu, Dec 14, 2006 at 11:22:43AM +1100, Michael Ellerman wrote:
> > spider_net_refill_rx_chain(card);
> > -   spider_net_enable_rxchtails(card);
> > spider_net_enable_rxdmac(card);
> > return 0;
> 
> Didn't you just add that line?

Dagnabbit. The earlier pach was moving around existing code.
Or, more precisely, trying to maintain the general function
of the old code even while moving things around.

Later on, when I started looking at what the danged function 
actually did, and the context it was in, I realized that it 
was a bad idea to call the thing.  So then I removed it. :-/

How should I handle this proceedurally? Resend the patch sequence? 
Let it slide?

--linas

-
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


Revised: [PATCH 1/14] Spidernet DMA coalescing

2006-12-14 Thread Linas Vepstas

Andrew, 

I'm hoping its not irritatingly obthersome to ask you to rip out 
the first patch of this series, and replace it with the one below. 

On Thu, Dec 14, 2006 at 05:35:34PM +, Christoph Hellwig wrote:
> On Thu, Dec 14, 2006 at 11:07:37AM -0600, Linas Vepstas wrote:
> > Being unclear on the concept, should a send a new version of this patch,
> > or should I send a new patch that removes this?
> 
> For just the memset issue an incremental patch would be fine.  But given
> the small mistake in the patch description a resend with the fixed
> description mighrt be in order here.

--linas

The current driver code performs 512 DMA mappings of a bunch of 
32-byte ring descriptor structures. This is silly, as they are 
all in contiguous memory. This patch changes the code to 
dma_alloc_coherent() each rx/tx ring as a whole.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: James K Lewis <[EMAIL PROTECTED]>
Cc: Arnd Bergmann <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |  101 +--
 drivers/net/spider_net.h |   17 +-
 drivers/net/spider_net_ethtool.c |4 -
 3 files changed, 52 insertions(+), 70 deletions(-)

Index: linux-2.6.19-git7/drivers/net/spider_net.c
===
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-13 
14:23:11.0 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c  2006-12-14 11:02:59.0 
-0600
@@ -280,72 +280,65 @@ spider_net_free_chain(struct spider_net_
 {
struct spider_net_descr *descr;
 
-   for (descr = chain->tail; !descr->bus_addr; descr = descr->next) {
-   pci_unmap_single(card->pdev, descr->bus_addr,
-SPIDER_NET_DESCR_SIZE, PCI_DMA_BIDIRECTIONAL);
+   descr = chain->ring;
+   do {
descr->bus_addr = 0;
-   }
+   descr->next_descr_addr = 0;
+   descr = descr->next;
+   } while (descr != chain->ring);
+
+   dma_free_coherent(&card->pdev->dev, chain->num_desc,
+   chain->ring, chain->dma_addr);
 }
 
 /**
- * spider_net_init_chain - links descriptor chain
+ * spider_net_init_chain - alloc and link descriptor chain
  * @card: card structure
  * @chain: address of chain
- * @start_descr: address of descriptor array
- * @no: number of descriptors
  *
- * we manage a circular list that mirrors the hardware structure,
+ * We manage a circular list that mirrors the hardware structure,
  * except that the hardware uses bus addresses.
  *
- * returns 0 on success, <0 on failure
+ * Returns 0 on success, <0 on failure
  */
 static int
 spider_net_init_chain(struct spider_net_card *card,
-  struct spider_net_descr_chain *chain,
-  struct spider_net_descr *start_descr,
-  int no)
+  struct spider_net_descr_chain *chain)
 {
int i;
struct spider_net_descr *descr;
dma_addr_t buf;
+   size_t alloc_size;
 
-   descr = start_descr;
-   memset(descr, 0, sizeof(*descr) * no);
+   alloc_size = chain->num_desc * sizeof (struct spider_net_descr);
 
-   /* set up the hardware pointers in each descriptor */
-   for (i=0; idmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
+   chain->ring = dma_alloc_coherent(&card->pdev->dev, alloc_size,
+   &chain->dma_addr, GFP_KERNEL);
 
-   buf = pci_map_single(card->pdev, descr,
-SPIDER_NET_DESCR_SIZE,
-PCI_DMA_BIDIRECTIONAL);
+   if (!chain->ring)
+   return -ENOMEM;
 
-   if (pci_dma_mapping_error(buf))
-   goto iommu_error;
+   /* Set up the hardware pointers in each descriptor */
+   descr = chain->ring;
+   buf = chain->dma_addr;
+   for (i=0; i < chain->num_desc; i++, descr++) {
+   descr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
 
descr->bus_addr = buf;
+   descr->next_descr_addr = 0;
descr->next = descr + 1;
descr->prev = descr - 1;
 
+   buf += sizeof(struct spider_net_descr);
}
/* do actual circular list */
-   (descr-1)->next = start_descr;
-   start_descr->prev = descr-1;
+   (descr-1)->next = chain->ring;
+   chain->ring->prev = descr-1;
 
spin_lock_init(&chain->lock);
-   chain->head = start_descr;
-   chain->tail = start_descr;
-
+   chain->head = chain->ring;
+   chain->tail = chain->ring;
return 0;
-
-iommu_error:
-   descr = start_descr;
-   for (i=0; i < no; i++, descr++)
-   if (descr->bus_addr)
-  

NAPI wait before enabling irq's [was Re: [Cbe-oss-dev] Spider DMA wrongness]

2006-12-14 Thread Linas Vepstas
On Wed, Nov 08, 2006 at 07:38:12AM +1100, Benjamin Herrenschmidt wrote:
> 
> What about Linas patches to do interrupt mitigation with NAPI polling ?
> That didn't end up working ?

It seems to be "working as designed", which is different than "working
as naively expected".

For large packets: 
-- a packet comes in
-- rx interrupt generated
-- rx interrupts turned off
-- tcp poll function runs, receives packet
-- completes all work before next packet has arrived, 
   so interupts are turned back on.
-- go to start

This results in a high number of interrupts, and a high cpu usage.
We were able to prove that napi works by stalling in the poll function
just long enough to allow the next packet to arrive.  In this case, 
napi works great, and number of irqs is vastly reduced. 

Unfortunately, I could not figure out any simple way of turning this
into acceptable code.  I can't just wait a little bit before turning 
on interrupts.  Some network apps, such as netpipe, want to receive 
something before sending the next thing. Without the interrupt, the
packet just sits there, and the OS doesn't realize (until milliseconds
later) that there's a packet that can be handled.  This is a variant
of the so-called "rotting packet" discussed in the napi docs.

What is needed is for the tcp stack to wait for 
  1500Bytes / (1Gbit/sec) = 12 microsecs
and then poll again. If there are *still* no new packets, then and
only then do we re-enable interrupts. This would require a new napi.
Presuming the network stack folks find it even remotely acceptable.

--linas

-
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: NAPI wait before enabling irq's [was Re: [Cbe-oss-dev] Spider DMA wrongness]

2006-12-14 Thread Linas Vepstas
On Thu, Dec 14, 2006 at 12:51:14PM -0800, [EMAIL PROTECTED] wrote:
> On Thu, 14 Dec 2006, Linas Vepstas wrote:
> 
> >On Wed, Nov 08, 2006 at 07:38:12AM +1100, Benjamin Herrenschmidt wrote:
> >>
> >>What about Linas patches to do interrupt mitigation with NAPI polling ?
> >>That didn't end up working ?
> >
> >It seems to be "working as designed", which is different than "working
> >as naively expected".
> >
> >For large packets:
> >-- a packet comes in
> >-- rx interrupt generated
> >-- rx interrupts turned off
> >-- tcp poll function runs, receives packet
> >-- completes all work before next packet has arrived,
> >  so interupts are turned back on.
> >-- go to start
> >
> >This results in a high number of interrupts, and a high cpu usage.
> >We were able to prove that napi works by stalling in the poll function
> >just long enough to allow the next packet to arrive.  In this case,
> >napi works great, and number of irqs is vastly reduced.
> >
> 
> This sounds awfully familiar. We went through the same
> with the tg3 driver on Altix. In that case we succeeded
> getting interrupt coalescence added to the driver, which
> ended up working pretty well for us. See the thread
> beginning with:
> 
> http://oss.sgi.com/archives/netdev/2005-05/msg00497.html
> 
> if you're interested.

I'm interested. The tg3 seems to have "hardware coalescing",
which, from what I can tell, is a way of delaying an RX
interrupt for some number of microseconds?  I assume there's 
nothing more to it than that?

The spider has some suggestively named registers and functions,
hinting that it can similarly delay an RX interupt, but the 
docs are opaque and mysteriously worded, so I cannot really tell.

Perhaps Ishizaki Kou can clue us in? 

> As for the "stalling NAPI" idea, Jamal did a bit of work
> with that idea and wrote it up in:
> 
> www.kernel.org/pub/linux/kernel/people/hadi/docs/UKUUG2005.pdf

Reading now ... 

--linas
-
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] Read back MSI message in rtas_setup_msi_irqs() so restore works

2007-11-07 Thread Linas Vepstas
On Tue, Oct 23, 2007 at 02:23:44PM +1000, Michael Ellerman wrote:
> There are plans afoot to use pci_restore_msi_state() to restore MSI
> state after a device reset. In order for this to work for the RTAS MSI
> backend, we need to read back the MSI message from config space after
> it has been setup by firmware.
> 
> This should be sufficient for restoring the MSI state after a device
> reset, however we will need to revisit this for suspend to disk if that
> is ever implemented on pseries.
> 
> Signed-off-by: Michael Ellerman <[EMAIL PROTECTED]>
> ---
> 
> Linas, can you test this on your setup with your EEH stuff? I haven't got
> any MSI supporting hardware/firmware combination.

Acked-by: Linas Vepstas <[EMAIL PROTECTED]>

I *finally* was able to get onto some hardware long enough to run this.
And that took a lot of work. Sigh. Yes, this is exactly what I'd wanted.

--linas
-
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] PCI: export pci_restore_msi_state()

2007-11-07 Thread Linas Vepstas

PCI error recovery usually involves the PCI adapter being reset.
If the device is using MSI, the reset will cause the MSI state 
to be lost; the device driver needs to restore the MSI state.

The pci_restore_msi_state() routine is currently protected
by CONFIG_PM; remove this, and also export the symbol, so
that it can be used in a modle.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


I am so sorry I wasn't able to send this 3 weeks ago, when
I first wrote the patch. There was simply no functional
hardware available to actually run this stuff :-(

Patches that use this, including those for tg3 and e1000e and ixgbe
i.e. MSI-using drivers, are to follow "real soon now". 

 drivers/pci/msi.c   |3 +--
 drivers/pci/pci.h   |6 --
 include/linux/pci.h |2 ++
 3 files changed, 3 insertions(+), 8 deletions(-)

Index: linux-2.6.23-rc8-mm1/drivers/pci/msi.c
===
--- linux-2.6.23-rc8-mm1.orig/drivers/pci/msi.c 2007-10-16 15:14:20.0 
-0500
+++ linux-2.6.23-rc8-mm1/drivers/pci/msi.c  2007-10-16 15:14:42.0 
-0500
@@ -224,7 +224,6 @@ static struct msi_desc* alloc_msi_entry(
return entry;
 }
 
-#ifdef CONFIG_PM
 static void __pci_restore_msi_state(struct pci_dev *dev)
 {
int pos;
@@ -282,7 +281,7 @@ void pci_restore_msi_state(struct pci_de
__pci_restore_msi_state(dev);
__pci_restore_msix_state(dev);
 }
-#endif /* CONFIG_PM */
+EXPORT_SYMBOL_GPL(pci_restore_msi_state);
 
 /**
  * msi_capability_init - configure device's MSI capability structure
Index: linux-2.6.23-rc8-mm1/drivers/pci/pci.h
===
--- linux-2.6.23-rc8-mm1.orig/drivers/pci/pci.h 2007-10-16 15:14:20.0 
-0500
+++ linux-2.6.23-rc8-mm1/drivers/pci/pci.h  2007-10-16 15:19:33.0 
-0500
@@ -45,12 +45,6 @@ static inline void pci_no_msi(void) { }
 static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { }
 #endif
 
-#if defined(CONFIG_PCI_MSI) && defined(CONFIG_PM)
-void pci_restore_msi_state(struct pci_dev *dev);
-#else
-static inline void pci_restore_msi_state(struct pci_dev *dev) {}
-#endif
-
 static inline int pci_no_d1d2(struct pci_dev *dev)
 {
unsigned int parent_dstates = 0;
Index: linux-2.6.23-rc8-mm1/include/linux/pci.h
===
--- linux-2.6.23-rc8-mm1.orig/include/linux/pci.h   2007-10-01 
13:26:38.0 -0500
+++ linux-2.6.23-rc8-mm1/include/linux/pci.h2007-10-16 15:19:07.0 
-0500
@@ -665,6 +665,7 @@ static inline int pci_enable_msix(struct
struct msix_entry *entries, int nvec) {return -1;}
 static inline void pci_disable_msix(struct pci_dev *dev) {}
 static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) {}
+static inline void pci_restore_msi_state(struct pci_dev *dev) {}
 #else
 extern int pci_enable_msi(struct pci_dev *dev);
 extern void pci_disable_msi(struct pci_dev *dev);
@@ -672,6 +673,7 @@ extern int pci_enable_msix(struct pci_de
struct msix_entry *entries, int nvec);
 extern void pci_disable_msix(struct pci_dev *dev);
 extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
+extern void pci_restore_msi_state(struct pci_dev *dev);
 #endif
 
 #ifdef CONFIG_HT_IRQ
-
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] PCI: export pci_restore_msi_state()

2007-11-07 Thread Linas Vepstas
Hi,

On Wed, Nov 07, 2007 at 03:43:59PM -0600, Linas Vepstas wrote:
> 
> PCI error recovery usually involves the PCI adapter being reset.
> If the device is using MSI, the reset will cause the MSI state 
> to be lost; the device driver needs to restore the MSI state.
> 
> The pci_restore_msi_state() routine is currently protected
> by CONFIG_PM; remove this, and also export the symbol, so
> that it can be used in a modle.
> 
> Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>

The long time delay has managed to muddle notes & recollection 
of prior discussions. This patch should have had a 

Signed-off-by: Matt Carlson <[EMAIL PROTECTED]>
Signed-off-by: Michael Chan <[EMAIL PROTECTED]>

on it; its the same patch that was submitted a long time ago.

During the discussions of 21 Oct, it was proposed that there
should be an arch hook for pci_restore_msi_state(), so that
it would be treated at the same level as msi setup and teardown.
I'd volunteered to write that patch. 

When I sat down to do it, however, I realized that I did not
actually *need* it. And so I wondered: why am I writing un-needed,
but theoretically proper, code? So I punted, and I didn't.
Does that make sense?

That's also why this patch is just a resubmission of the old
patch. The original thread is here:

http://www.mail-archive.com/netdev@vger.kernel.org/msg51296.html

--linas



-
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 2/2]: e1000: avoid lockup durig error recovery

2007-11-07 Thread Linas Vepstas
On Wed, Nov 07, 2007 at 02:45:18PM -0800, Kok, Auke wrote:
> [adding netdev, jeff G to the Cc]
> 
> Linas Vepstas wrote:
> > On Wed, Nov 07, 2007 at 01:50:17PM -0800, Kok, Auke wrote:
> >> Linas Vepstas wrote:
> >>> If a PCI bus error is encountered during device open, the
> >>> error recovery routines will attempt to close the device.
> >>> If napi has not yet been enabled, the napi disable in the
> >>> close will hang. 
> >>>
> >>> Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
> >>>
> >>> 
> >>> The "elegence" of this solution is arguable: one could
> >>> say its "better" to perform this check in e1000_down().
> >>> However, doing so will disrupt a commonly used path,
> >>> whereas here, the hack is in the infrequently used
> >>> error path, and thus less intrusive. 
> >>>
> >>>  drivers/net/e1000/e1000_main.c |9 -
> >>>  1 file changed, 8 insertions(+), 1 deletion(-)
> >>>
> >> I think this is OK, but it's quite awful looking if you ask me.
> > 
> > Yeah, ... 
> > 
> > There are several alternatives: below are two. If you
> > find one to be more appealing.. could you use it? Consider them
> > to be "signed-off-by"; I have not actually compiled or tested
> > either of them.
> 
> I'm not a particular fan of putting extra state tracking in the driver for
> something we could extract from the napi subsystem already.
> 
> Jeff, Stephen, can't we have a generic napi_enabled() inline in netdevice.h 
> that
> tests for NAPI_STATE_SCHED ?

Like this?

 include/linux/netdevice.h |   12 
 1 file changed, 12 insertions(+)

Index: linux-2.6.23-rc8-mm1/include/linux/netdevice.h
===
--- linux-2.6.23-rc8-mm1.orig/include/linux/netdevice.h 2007-09-26 
15:07:05.0 -0500
+++ linux-2.6.23-rc8-mm1/include/linux/netdevice.h  2007-11-07 
17:14:50.0 -0600
@@ -384,6 +384,18 @@ static inline void napi_enable(struct na
clear_bit(NAPI_STATE_SCHED, &n->state);
 }
 
+/**
+ * napi_enabled_p - return non-zero if napi enabled
+ * @n: napi context
+ * 
+ * Mnemonic: _p stands for "predicate", returning a yes/no
+ * answer to the question.
+ */
+static inline int napi_enabled_p(struct napi_struct *n)
+{
+   return !test_bit(NAPI_STATE_SCHED, &n->state);
+}
+
 /*
  * The DEVICE structure.
  * Actually, this whole structure is a big mistake.  It mixes I/O


> I wonder if there isn't something in the PCI error recovery missing the point 
> and
> we can solve this problem better for all drivers somehow.

Well, there's also scsi, which doesn't use napi :-)
For the most part, error recovery is a fairly cut-n-paste
set of steps. However, I don't quite have enough confidence
to say "yea verily, all network adapters will use these 
same steps."

--linas
-
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] PCI: export pci_restore_msi_state()

2007-11-09 Thread Linas Vepstas
On Thu, Nov 08, 2007 at 07:21:01PM -0600, Wen Xiong wrote:
> Hi Linas,
> 
> I saw you have submitted several patches to support pci-express network 
> adapters EEH. But looks only this patch fixed something in linux kernel 
> code.

And its an old patch, submitted long ago ... I've resubmitted, because
it seems that its the best/most correct thing to do.

> Do you mean I can test EEH callback functions in device driver after I 
> apply  this patch in the kernel?

Yes, please.  Note, however, I was never able to make the pci-e 
version of the e1000 work. It comes up, generates interrupts, and
registeres are readable and writeable. But it behvaes as if the PHY 
is turned off -- no network traffic goes thorugh. (I tried turning
PHY on explicitly; that didn't help). So there is still something 
wrong somewhere, probably in the e1000 deice driver. I'm guessing
the pci-e to pci-x bridge chip on that card is not quite resetting
the card completely.

> Do you do "pci_save_msi_state" somewhere in the kernel? Or you suggest to 
> do "pci_save_msi_state" and "pci_restore_msi_state" in each device driver?

There is no "save state", the msi state can't be saved. The MSI regs
are write-only, and they are controlled by firmware. The restore_state
function is the only one you need.

--linas
-
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 2/2]: e1000: avoid lockup durig error recovery

2007-11-09 Thread Linas Vepstas
On Fri, Nov 09, 2007 at 06:02:34PM +0100, Ingo Oeser wrote:
> Linas Vepstas schrieb:
> > + * napi_enabled_p - return non-zero if napi enabled
> > + * 
> > + * Mnemonic: _p stands for "predicate", returning a yes/no
> > + * answer to the question.
> 
> Call it "is_napi_enabled()" an nobody will ask :-)

Heh. The suffix _p is standard coding style for lisp/scheme
and first-order logic interpreters.  This was my lame attempt
to introduce it to the kernel. I guess that lame duck won't fly.

--linas

-
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] netdev: create an "is_napi_enabled()" call

2007-11-13 Thread Linas Vepstas

In certain rare cases, it can be nice to be able to check
if napi is enabled or not. Create an is_napi_enabled() call.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
---
Actually, I'm confused about whether I'd mailed this previously.
It might be a duplicate submission.

 include/linux/netdevice.h |   11 +++
 1 file changed, 11 insertions(+)

Index: linux-2.6.23-rc8-mm1/include/linux/netdevice.h
===
--- linux-2.6.23-rc8-mm1.orig/include/linux/netdevice.h 2007-11-09 
17:36:51.0 -0600
+++ linux-2.6.23-rc8-mm1/include/linux/netdevice.h  2007-11-09 
17:40:19.0 -0600
@@ -384,6 +384,17 @@ static inline void napi_enable(struct na
clear_bit(NAPI_STATE_SCHED, &n->state);
 }
 
+/**
+ * is_napi_enabled - return non-zero if napi enabled
+ * @n: napi context
+ *
+ * Return true if napi is enabled.
+ */
+static inline bool is_napi_enabled(struct napi_struct *n)
+{
+   return !test_bit(NAPI_STATE_SCHED, &n->state);
+}
+
 /*
  * The DEVICE structure.
  * Actually, this whole structure is a big mistake.  It mixes I/O
-
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] ehea: Add kdump support

2007-11-26 Thread Linas Vepstas

Hi,

On Mon, Nov 26, 2007 at 01:41:37PM -0200, Luke Browning wrote:
> On Mon, 2007-11-26 at 19:16 +1100, Michael Ellerman wrote:
> 
> > For kdump we have to assume that the kernel is fundamentally broken,

If I may so humbly suggest: since ehea is a power6 thing only,
we should refocus our energies on "hypervisor assisted dump",
which solves all of these problems. 

In short, upon crash, the hypervisor will reset the 
pci devices into working order, and will then boot
a new fresh kernel into a tiny corner of ram. The rest
of ram is not cleared, and can be dumped. After the 
dump, the mem is returned to general use.

The key point here, for ehea, is "the hypervisor
will reset he device state to something rational".

Preliminary patches are at
http://patchwork.ozlabs.org/linuxppc/patch?id=14884
and following.

--linas
-
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] ps3: gigabit ethernet driver for PS3, take3

2007-07-06 Thread Linas Vepstas
On Thu, Jul 05, 2007 at 11:47:20AM -0500, jschopp wrote:
> 
> This is the third submission of the network driver for PS3.
> The differences from the previous one are:

I notice that this mostly a cut-n-paste of a very old version
of the spidernet device driver.  Please note that the old
spidernet had absolutely disasterous performance for transmit;
it also had a variety of crazy hangs and lockups under 
high-stress conditions; or NFS operation, or certain back-to-back
tcp usage scenarios. A few dozen bugfixes went in since
the time that the gelic snapshot was taken.

Wouldn't it be better to just add the hypervisor bits-n-pieces 
to spidernet?  That way, you get not only the various fixes, but 
also the benefit of fairly regular testing...


--linas
-
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] ps3: gigabit ethernet driver for PS3, take3

2007-07-09 Thread Linas Vepstas
On Mon, Jul 09, 2007 at 10:50:19AM +0900, Akira Tsukamoto wrote:
> Hi,
> 
> On Fri, 6 Jul 2007 13:02:41 -0500, [EMAIL PROTECTED] (Linas Vepstas) 
> mentioned: 
> > of the spidernet device driver.  Please note that the old
> > spidernet had absolutely disasterous performance for transmit;
> > it also had a variety of crazy hangs and lockups under 
> > high-stress conditions; or NFS operation, or certain back-to-back
> > tcp usage scenarios. A few dozen bugfixes went in since
> > the time that the gelic snapshot was taken.
> 
> I think we know the problems of old spidernet issues, we uses QS20 also 
> in our lab.
> Current gelic has fixed them all separated from your work and it have no 
> remaining issues or performance problem.
> In our measurement, PS3 network performance is better than IBM QS20 right
> now.

!! Well, gee, I wish this plan had been made public. I'd spent something
between 3-6 months working full-time on spidernet issues. This was a lot
of work and effort.  Worse, this was *not* my main job; it was rather to 
help the neighbors prevent a disaster in the making.  Certainly, I would 
not have spent any time on this, if I'd known someone else was also working 
to fix the same bugs. :-(

> I totally understand difficultness of your effort that fixing spidernet 
> without decent documentation which we have, but the changes we made was 
> significantly large as you see if you diff gelic driver with current 
> spidernet driver (totally different), 

The differences are very large, because very large changes have been made
to the spidernet. However, a diff between gelic and the old spidernet is
much smaller.  So I'm somewhat confused by this.  Perhaps I am mistaken, 
and should read the code more carefully.

> so the conclusion of discussion at 
> 3C common-linux wg (Sony, IBM and Toshiba) 

?? What working group is this?  This is the first time that I am hearing
of it, and, as the only active spidernet maintainer, I'd hope to have
been a part of suc discussion. Oh well.

-- Linas Vepstas
-
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: don't use debug flag

2007-07-09 Thread Linas Vepstas
On Mon, Jul 09, 2007 at 05:45:21PM +0900, Ishizaki Kou wrote:
> GDTDCEIDIS flag is defined that it is for debug and should not be used.

!? Certainly, my spec doesn't say anything like this;
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.

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

--linas
-
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: improve interrupt handling

2007-07-09 Thread Linas Vepstas
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,
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. 

QUILT_DIFF_OPTS="-Nupr"
in ~/.quiltrc if you use quilt.

--linas

-
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 Linas Vepstas

From: Ishizaki Kou <[EMAIL PROTECTED]>

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]>
Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


Jeff, please apply for 2.6.23

Linas.

 drivers/net/spider_net.c |   59 +++
 1 file changed, 45 insertions(+), 14 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-06-14 
17:23:32.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-07-09 14:10:04.0 
-0500
@@ -1478,11 +1478,17 @@ 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;
 
/* check GHIINT0STS /
if (status_reg)
@@ -1710,9 +1716,11 @@ 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, 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;
@@ -1754,6 +1762,38 @@ spider_net_poll_controller(struct net_de
 #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
  *
@@ -1773,6 +1813,7 @@ spider_net_init_card(struct spider_net_c
spider_net_write_reg(card, SPIDER_NET_GMACOPEMD,
spider_net_read_reg(card, SPIDER_NET_GMACOPEMD) | 0x4);
 
+   spider_net_disable_interrupts(card);
 }
 
 /**
@@ -1860,14 +1901,6 @@ spider_net_enable_card(struct spider_net
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);
 }
@@ -2044,6 +2077,8 @@ spider_net_open(struct net_device *netde
netif_carrier_on(netdev);
netif_poll_enable(netdev);
 
+   spider_net_enable_interrupts(card);
+
return 0;
 
 register_int_failed:
@@ -2216,11 +2251,7 @@ spider_net_stop(struct net_device *netde
del_timer_sync(&card->tx_timer);
del_timer_sync(&card->aneg_time

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

2007-07-11 Thread Linas Vepstas
On Wed, Jul 11, 2007 at 04:57:38PM +0900, Ishizaki Kou wrote:
[...]
> I need more investigation. Please drop the patch.

OK.

--linas

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?


-
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] crash in 2.6.22-git2 sysctl_set_parent()

2007-07-13 Thread Linas Vepstas

This is a patch (& bug report) for a crash in sysctl_set_parent() 
in 2.6.22-git2. 

Problem: 2.6.22-git2 crashes with a stack trace 
[c1d0fb00] c0067b4c .sysctl_set_parent+0x48/0x7c
[c1d0fb90] c0069b40 .register_sysctl_table+0x7c/0xf4
[c1d0fc30] c065e710 .devinet_init+0x88/0xb0
[c1d0fcc0] c065db74 .ip_rt_init+0x17c/0x32c
[c1d0fd70] c065deec .ip_init+0x10/0x34
[c1d0fdf0] c065e898 .inet_init+0x160/0x3dc
[c1d0fea0] c0630bc4 .kernel_init+0x204/0x3c8

A bit of poking around makes it clear what the problem is:
In sysctl_set_parent(), the for loop 

   for (; table->ctl_name || table->procname; table++) {

walks off the end of the table, and into garbage.  Basically,
this for-loop iterator expects all table arrays to be 
"null terminated".  However, net/ipv4/devinet.c statically 
declares an array that is not null-terminated.  The patch 
below fixes that; it works for me.  Its somewhat conservative;
if one wishes to assume that the compiler will always zero out
the empty parts of the structure, then this pach can be shrunk 
to one line: +  ctl_table   devinet_root_dir[3];

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


I tried to audit some of the code to see where else there 
might be similar badly-formed static declarations.  This is hard,
as there's a lot of code. Most seems fine.


 net/core/neighbour.c |4 
 net/ipv4/devinet.c   |7 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

Index: linux-2.6.22-git2/net/ipv4/devinet.c
===
--- linux-2.6.22-git2.orig/net/ipv4/devinet.c   2007-07-13 14:23:21.0 
-0500
+++ linux-2.6.22-git2/net/ipv4/devinet.c2007-07-13 14:24:15.0 
-0500
@@ -1424,7 +1424,7 @@ static struct devinet_sysctl_table {
ctl_table   devinet_dev[2];
ctl_table   devinet_conf_dir[2];
ctl_table   devinet_proto_dir[2];
-   ctl_table   devinet_root_dir[2];
+   ctl_table   devinet_root_dir[3];
 } devinet_sysctl = {
.devinet_vars = {
DEVINET_SYSCTL_COMPLEX_ENTRY(FORWARDING, "forwarding",
@@ -1493,8 +1493,13 @@ static struct devinet_sysctl_table {
.data   = &ipv4_devconf.loop,
.maxlen = sizeof(int),
.mode   = 0644,
+   .child  = 0x0,
.proc_handler   = &proc_dointvec,
},
+   {
+   .ctl_name   = 0,
+   .procname   = 0,
+   },
},
 };
 
-
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] crash in 2.6.22-git2 sysctl_set_parent()

2007-07-16 Thread Linas Vepstas
On Fri, Jul 13, 2007 at 07:06:56PM -0600, Eric W. Biederman wrote:
> > .data   = &ipv4_devconf.loop,
> > .maxlen = sizeof(int),
> > .mode   = 0644,
> > +   .child  = 0x0,
> > .proc_handler   = &proc_dointvec,
> > },
> Where did this entry above in devinet_sysctl come from?

My bad.
I habitually apply the "send-to-self" patch, since some of the 
network testing that I do is easiest if I load up the all of the 
adapters in the same box. (If you're not familiar with this patch ... 
its great, and I wish it was integratedd into mainline. It allows
one to drive network traffic through the physical devices, even
if they are in the same box.  Without it, the network stack is
too clever, and won't allow you to do this.)

> > +   {
> > +   .ctl_name   = 0,
> > +   .procname   = 0,
> > +   },
> I probably would have just done:
> + {},

Yes, in retrospect, this would have been the simplest solution.

> What added the additional entry to devinet_root_dir?  I don't see that
> in Linus' tree?
> 
> The result may be fine but if it isn't named in a per network device
> manner we are adding duplicate entries to the root /proc/sys directory
> which is wrong.
> 
> Actually come to think of it I am concerned that someone added a
> settable entry into /proc/sys/ it should at least be in /proc/sys/net/
> where it won't conflict with other uses of that directory.  Especially
> as things like network devices have user controlled names.

Sigh. Silly me. Haste makes waste.

--linas

-
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] crash in 2.6.22-git2 sysctl_set_parent()

2007-07-16 Thread Linas Vepstas
On Fri, Jul 13, 2007 at 03:47:02PM -0700, David Miller wrote:
> From: [EMAIL PROTECTED] (Linas Vepstas)
> Date: Fri, 13 Jul 2007 15:05:15 -0500
> 
> > 
> > This is a patch (& bug report) for a crash in sysctl_set_parent() 
> > in 2.6.22-git2. 
> > 
> > Problem: 2.6.22-git2 crashes with a stack trace 
> > 
> > Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
> 
> Thanks for tracking this down, I'll apply your patch.

NAK. As I just explained in another email, this bug
was introduced by the "send-to-self" patch I habitually
apply -- so habitually, that I forgot I was not working 
with a "clean" tree. So it goes ... 

--linas
-
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] tg3: add PCI error recovery support

2007-07-18 Thread Linas Vepstas

Add support for PCI Error Recovery for the tg3 ethernet
device driver. The general principles of operation are
described in Documentation/pci-error-recovery.txt
Other drivers having similar structure include e100,
e1000, ixgb, s2io, ipr, sym53c8xx_2, and lpfc

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Cc: Michael Chan <[EMAIL PROTECTED]>



Michael, you are listed as the tg3 maintainer; could you
please forward upstream if you agree?  

Tested on the PCI-E version of this adapter, on power6, 
for 85 (artificial) error injections (overnight) while
ftp'ing dvd iso images over the link. Worked well.

 drivers/net/tg3.c |  108 +-
 1 file changed, 107 insertions(+), 1 deletion(-)

Index: linux-2.6.22-git2/drivers/net/tg3.c
===
--- linux-2.6.22-git2.orig/drivers/net/tg3.c2007-07-17 11:07:30.0 
-0500
+++ linux-2.6.22-git2/drivers/net/tg3.c 2007-07-18 15:10:09.0 -0500
@@ -64,7 +64,7 @@
 
 #define DRV_MODULE_NAME"tg3"
 #define PFX DRV_MODULE_NAME": "
-#define DRV_MODULE_VERSION "3.77"
+#define DRV_MODULE_VERSION "3.77-a"
 #define DRV_MODULE_RELDATE "May 31, 2007"
 
 #define TG3_DEF_MAC_MODE   0
@@ -12126,11 +12126,117 @@ out:
return err;
 }
 
+/**
+ * tg3_io_error_detected - called when PCI error is detected
+ * @pdev: Pointer to PCI device
+ * @state: The current pci connection state
+ *
+ * This function is called after a PCI bus error affecting
+ * this device has been detected. 
+ */
+static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev,
+   pci_channel_state_t state)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct tg3 *tp = netdev_priv(netdev);
+   struct device *dev = &netdev->dev;
+
+   dev_info(dev, "PCI I/O error detected on %s\n", netdev->name);
+
+   if (!netif_running(netdev))
+   return PCI_ERS_RESULT_NEED_RESET;
+
+   /* Want to make sure that the reset task doesn't run */
+   cancel_work_sync(&tp->reset_task);
+   tg3_netif_stop(tp);
+   del_timer_sync(&tp->timer);
+   netif_device_detach(netdev);
+   pci_disable_device(pdev);
+
+   if (state == pci_channel_io_perm_failure) {
+   /* avoid hang in dev_close() with rtnl_lock held */
+   netif_poll_enable(netdev);
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+   return PCI_ERS_RESULT_NEED_RESET;
+}
+
+/**
+ * tg3_io_slot_reset - called after the pci bus has been reset.
+ * @pdev: Pointer to PCI device
+ *
+ * Restart the card from scratch, as if from a cold-boot.
+ * At this point, the card has exprienced a hard reset,
+ * followed by fixups by BIOS, and has its config space
+ * set up identically to what it was at cold boot.
+ */
+static pci_ers_result_t tg3_io_slot_reset(struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct tg3 *tp = netdev_priv(netdev);
+   int err;
+
+   if (!netif_running(netdev))
+   return PCI_ERS_RESULT_RECOVERED;
+
+   if (pci_enable_device(pdev)) {
+   printk(KERN_ERR "tg3: %s: "
+  "Cannot re-enable PCI device after reset.\n", 
netdev->name);
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+
+   pci_set_master(pdev);
+   pci_restore_state(tp->pdev);
+   netif_device_attach(netdev);
+
+   tg3_full_lock(tp, 0);
+   tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
+   err = tg3_restart_hw(tp, 1);
+   tg3_full_unlock(tp);
+   if (err) {
+   printk(KERN_ERR "tg3: %s: "
+  "Cannot restart hardware after reset.\n", netdev->name);
+   return PCI_ERS_RESULT_DISCONNECT;
+   }
+
+   return PCI_ERS_RESULT_RECOVERED;
+}
+
+/**
+ * tg3_io_resume - called when traffic can start flowing again.
+ * @pdev: Pointer to PCI device
+ *
+ * This callback is called when the error recovery driver tells
+ * us that its OK to resume normal operation.
+ */
+static void tg3_io_resume(struct pci_dev *pdev)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct tg3 *tp = netdev_priv(netdev);
+
+   if (!netif_running(netdev))
+   return;
+
+   netif_wake_queue(netdev);
+
+   tp->timer.expires = jiffies + tp->timer_offset;
+   add_timer(&tp->timer);
+
+   tg3_netif_start(tp);
+}
+
+static struct pci_error_handlers tg3_err_handler = {
+   .error_detected = tg3_io_error_detected,
+   .slot_reset = tg3_io_slot_reset,
+   .resume = tg3_io_resume,
+};
+
 static struct pci_driver tg3_driver = {
.name   = DRV_MODULE_NAME,
.id_table   = tg3_pci_tbl,
  

Re: [PATCH 0/4][RFC] lro: Generic Large Receive Offload for TCP traffic

2007-07-30 Thread Linas Vepstas
On Mon, Jul 30, 2007 at 05:24:33PM +0200, Jan-Bernd Themann wrote:
> 
> Changes to http://www.spinics.net/lists/netdev/msg36912.html
> 
> 1) A new field called "features" has been added to the net_lro_mgr struct.
>It is set by the driver to indicate:
>- LRO_F_NAPI:Use NAPI / netif_rx to pass packets to stack
> 
>- LRO_F_EXTRACT_VLAN_ID: Set by driver if HW extracts VLAN IDs for VLAN
> packets but does not modify ETH protocol (ETH_P_8021Q)
> 
> 2) Padded frames are not aggregated for now. Bug fixed
> 
> 3) Correct header length now used. No minimal header length for aggregated
>packets used anymore.
> 
> 4) Statistic counters were introduced. They are stored in a new struct in
>the net_lro_mgr. This has the advantage that no locking is required in
>cases where the driver uses multiple lro_mgrs for different receive queues.
>Thus we get the following statistics per lro_mgr / eth device:
>- Number of aggregated packets
>- Number of flushed packets
>- Number of times we run out of lro_desc.
> 
>The ratio of "aggregated packets" and "flushed packets" give you an
>idea how well LRO is working.

I'd like to see an edited form of this, together with an introduction to
LRO, written up in the Documentation subdirectory.  

As someone with some driver experience, but not on te bleeding edge,
some basc newbie questions pop into mind:

-- what is LRO?
-- Basic principles of operation?
-- Can I use it in my driver?  
-- Does my hardware have to have some special feature before I can use it?
-- What sort of performance improvement does it provide? Throughput?
   Latency? CPU usage? How does it affect DMA allocation? Does it 
   improve only a certain type of traffic (large/small packets, etc.)
-- Example code? What's the API? How should my driver use it?

Right now, I can maybe find answers by doing lots of googling.  I'd like
to have some quick way of getting a grip on this.

--linas
   
-
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 v2] gianfar: Add I/O barriers when touching buffer descriptor ownership.

2007-05-04 Thread Linas Vepstas
On Wed, May 02, 2007 at 03:40:20PM -0500, Scott Wood wrote:
> 
> Well, Segher doesn't want me to use iobarrier (because it's not I/O). 
> Andy doesn't want me to use wmb() (because it's sync).  I don't think 
> something like gfar_wmb() would be appropriate.  So the remaining 
> options are either eieio(), 

? Just curious... the original intent of eieio was to order I/O, 
such as MMIO; it has no effect on memory that isn't marked 
cache-inhibited or write-trhough or guarded. Has this changed?
I guess I haven't kept up with the times ... is eieio now
being used to provide some other kind of barrier?
Is eieio providing some sort of SMP synchronization side-effect?

Point being: if Segher doesn't let you "use iobarrier (because 
it's not I/O)", then I don't understand why eieio would work (since
that's for io only).  

--linas
-
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 06/17] sky2: advanced error reporting

2007-05-09 Thread Linas Vepstas
On Tue, May 08, 2007 at 08:49:55PM -0700, Stephen Hemminger wrote:
> Use the kernel interfaces for advanced error reporting.
> This should be cleaner and clear up errors on boot.

Hmm. I thought that the AER functions would eventually 
be handled by the struct pci_error_handlers callbacks,
so that dev drivers wouldn't actually have code such as

> + pci_read_config_dword(pdev, pos + PCI_ERR_UNCOR_STATUS, 
> &status);
> + pci_read_config_dword(pdev, pos + PCI_ERR_UNCOR_SEVER, &mask);

in them. But perhaps I haven't studed what this drivr is trying to 
do; nor have I really kept track of the aer code.

--linas

-
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-10 Thread Linas Vepstas


Jeff, please apply for 2.6.22; This is a purely janitorial patch.

(I will have additonal patches for the spidernet in a few days;
I'm still debugging a rather nasty hang.)

--linas


From: Ishizaki Kou <[EMAIL PROTECTED]>

This patch removes unnecessary accesses to phy registers.

Signed-off-by: Kou Ishizaki <[EMAIL PROTECTED]>
Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

Index: linux-2.6.21-rc7-mm2/drivers/net/spider_net.c
===
--- linux-2.6.21-rc7-mm2.orig/drivers/net/spider_net.c  2007-05-09 
14:19:29.0 -0500
+++ linux-2.6.21-rc7-mm2/drivers/net/spider_net.c   2007-05-09 
14:20:28.0 -0500
@@ -175,12 +175,10 @@ spider_net_setup_aneg(struct spider_net_
 {
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


Re: [PATCH] spidernet: remove unnecessary accesses to phy

2007-05-11 Thread Linas Vepstas
On Fri, May 11, 2007 at 04:56:28PM -0400, Jeff Garzik wrote:
> 
> applied.  

Thanks.

> Please move comments that do not belong in the permanent 
> record BELOW the "---".  See Documentation/SubmittingPatches for more info.

oops, sorry.

--linas

I've also got a multi-month old s2io patch that's in limbo. It was
ack'ed by an s2io maintainer, but otherwise fell through the cracks.
If you can find it and apply it, great, otherwise I'll resubmit 
"real soon now".

--linas
-
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: remove unnecessary accesses to phy

2007-05-11 Thread Linas Vepstas
On Fri, May 11, 2007 at 08:36:52PM -0400, Jeff Garzik wrote:
> Linas Vepstas wrote:
> >
> >I've also got a multi-month old s2io patch that's in limbo. It was
> >ack'ed by an s2io maintainer, but otherwise fell through the cracks.
> >If you can find it and apply it, great, otherwise I'll resubmit 
> >"real soon now".
> 
> If you don't hear about a patch in over 14 days, you may assume I've 
> deleted it from my mbox queue.

Next week then. yow! I don't have enough disk space for all this stuff...

--linas
-
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/2] s2io: add PCI error recovery support

2007-05-14 Thread Linas Vepstas

This patch adds PCI error recovery support to the 
s2io 10-Gigabit ethernet device driver. Third revision,
blocks interrupts and the watchdog.

Tested, seems to work well.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Acked-by: Ramkrishna Vepa <[EMAIL PROTECTED]>
Cc: Raghavendra Koushik <[EMAIL PROTECTED]>
Cc: Wen Xiong <[EMAIL PROTECTED]>



Jeff, please apply for 2.6.22

--linas


 drivers/net/s2io.c |  116 ++---
 drivers/net/s2io.h |5 ++
 2 files changed, 116 insertions(+), 5 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/s2io.c
===
--- linux-2.6.22-rc1.orig/drivers/net/s2io.c2007-05-14 17:05:03.0 
-0500
+++ linux-2.6.22-rc1/drivers/net/s2io.c 2007-05-14 17:23:45.0 -0500
@@ -480,11 +480,18 @@ static struct pci_device_id s2io_tbl[] _
 
 MODULE_DEVICE_TABLE(pci, s2io_tbl);
 
+static struct pci_error_handlers s2io_err_handler = {
+   .error_detected = s2io_io_error_detected,
+   .slot_reset = s2io_io_slot_reset,
+   .resume = s2io_io_resume,
+};
+
 static struct pci_driver s2io_driver = {
   .name = "S2IO",
   .id_table = s2io_tbl,
   .probe = s2io_init_nic,
   .remove = __devexit_p(s2io_rem_nic),
+  .err_handler = &s2io_err_handler,
 };
 
 /* A simplifier macro used both by init and free shared_mem Fns(). */
@@ -2700,6 +2707,9 @@ static void s2io_netpoll(struct net_devi
u64 val64 = 0xULL;
int i;
 
+   if (pci_channel_offline(nic->pdev))
+   return;
+
disable_irq(dev->irq);
 
atomic_inc(&nic->isr_cnt);
@@ -3225,6 +3235,8 @@ static void alarm_intr_handler(struct s2
int i;
if (atomic_read(&nic->card_state) == CARD_DOWN)
return;
+   if (pci_channel_offline(nic->pdev))
+   return;
nic->mac_control.stats_info->sw_stat.ring_full_cnt = 0;
/* Handling the XPAK counters update */
if(nic->mac_control.stats_info->xpak_stat.xpak_timer_count < 72000) {
@@ -4324,6 +4336,10 @@ static irqreturn_t s2io_isr(int irq, voi
struct mac_info *mac_control;
struct config_param *config;
 
+   /* Pretend we handled any irq's from a disconnected card */
+   if (pci_channel_offline(sp->pdev))
+   return IRQ_NONE;
+
atomic_inc(&sp->isr_cnt);
mac_control = &sp->mac_control;
config = &sp->config;
@@ -6579,7 +6595,7 @@ static void s2io_rem_isr(struct s2io_nic
} while(cnt < 5);
 }
 
-static void s2io_card_down(struct s2io_nic * sp)
+static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
 {
int cnt = 0;
struct XENA_dev_config __iomem *bar0 = sp->bar0;
@@ -6594,7 +6610,8 @@ static void s2io_card_down(struct s2io_n
atomic_set(&sp->card_state, CARD_DOWN);
 
/* disable Tx and Rx traffic on the NIC */
-   stop_nic(sp);
+   if (do_io)
+   stop_nic(sp);
 
s2io_rem_isr(sp);
 
@@ -6602,7 +6619,7 @@ static void s2io_card_down(struct s2io_n
tasklet_kill(&sp->task);
 
/* Check if the device is Quiescent and then Reset the NIC */
-   do {
+   while(do_io) {
/* As per the HW requirement we need to replenish the
 * receive buffer to avoid the ring bump. Since there is
 * no intention of processing the Rx frame at this pointwe are
@@ -6627,8 +6644,9 @@ static void s2io_card_down(struct s2io_n
  (unsigned long long) val64);
break;
}
-   } while (1);
-   s2io_reset(sp);
+   }
+   if (do_io)
+   s2io_reset(sp);
 
spin_lock_irqsave(&sp->tx_lock, flags);
/* Free all Tx buffers */
@@ -6643,6 +6661,11 @@ static void s2io_card_down(struct s2io_n
clear_bit(0, &(sp->link_state));
 }
 
+static void s2io_card_down(struct s2io_nic * sp)
+{
+   do_s2io_card_down(sp, 1);
+}
+
 static int s2io_card_up(struct s2io_nic * sp)
 {
int i, ret = 0;
@@ -8020,3 +8043,86 @@ static void lro_append_pkt(struct s2io_n
sp->mac_control.stats_info->sw_stat.clubbed_frms_cnt++;
return;
 }
+
+/**
+ * s2io_io_error_detected - called when PCI error is detected
+ * @pdev: Pointer to PCI device
+ * @state: The current pci conneection state
+ *
+ * This function is called after a PCI bus error affecting
+ * this device has been detected.
+ */
+static pci_ers_result_t s2io_io_error_detected(struct pci_dev *pdev,
+   pci_channel_state_t state)
+{
+   struct net_device *netdev = pci_get_drvdata(pdev);
+   struct s2io_nic *sp = netdev->priv;
+
+   netif_device_detach(netdev);
+
+   if (netif_running(netdev)) {
+   /* B

Re: [PATCH 2/2] s2io: add PCI error recovery support

2007-05-14 Thread Linas Vepstas

s2io cleanup suggestions, per discussion on mailing lists.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/s2io.c |2 --
 drivers/net/s2io.h |1 -
 2 files changed, 3 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/s2io.c
===
--- linux-2.6.22-rc1.orig/drivers/net/s2io.c2007-05-14 17:23:45.0 
-0500
+++ linux-2.6.22-rc1/drivers/net/s2io.c 2007-05-14 17:24:03.0 -0500
@@ -3980,7 +3980,6 @@ static int s2io_close(struct net_device 
/* Reset card, kill tasklet and free Tx and Rx buffers. */
s2io_card_down(sp);
 
-   sp->device_close_flag = TRUE;   /* Device is shut down. */
return 0;
 }
 
@@ -8063,7 +8062,6 @@ static pci_ers_result_t s2io_io_error_de
if (netif_running(netdev)) {
/* Bring down the card, while avoiding PCI I/O */
do_s2io_card_down(sp, 0);
-   sp->device_close_flag = TRUE;   /* Device is shut down. */
}
pci_disable_device(pdev);
 
Index: linux-2.6.22-rc1/drivers/net/s2io.h
===
--- linux-2.6.22-rc1.orig/drivers/net/s2io.h2007-05-14 17:23:45.0 
-0500
+++ linux-2.6.22-rc1/drivers/net/s2io.h 2007-05-14 17:24:03.0 -0500
@@ -794,7 +794,6 @@ struct s2io_nic {
 
struct net_device_stats stats;
int high_dma_flag;
-   int device_close_flag;
int device_enabled_once;
 
char name[60];
-
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 1/2] s2io: add PCI error recovery support

2007-05-14 Thread Linas Vepstas

I failed to cc some of the people on the cc list ... so am resending.
--linas

On Mon, May 14, 2007 at 06:37:30PM -0500, Linas Vepstas wrote:
> 
> This patch adds PCI error recovery support to the 
> s2io 10-Gigabit ethernet device driver. Third revision,
> blocks interrupts and the watchdog.
> 
> Tested, seems to work well.
> 
> Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
> Acked-by: Ramkrishna Vepa <[EMAIL PROTECTED]>
> Cc: Raghavendra Koushik <[EMAIL PROTECTED]>
> Cc: Wen Xiong <[EMAIL PROTECTED]>
> 
> 
> 
> Jeff, please apply for 2.6.22
> 
> --linas
> 
> 
>  drivers/net/s2io.c |  116 
> ++---
>  drivers/net/s2io.h |5 ++
>  2 files changed, 116 insertions(+), 5 deletions(-)
> 
> Index: linux-2.6.22-rc1/drivers/net/s2io.c
> ===
> --- linux-2.6.22-rc1.orig/drivers/net/s2io.c  2007-05-14 17:05:03.0 
> -0500
> +++ linux-2.6.22-rc1/drivers/net/s2io.c   2007-05-14 17:23:45.0 
> -0500
> @@ -480,11 +480,18 @@ static struct pci_device_id s2io_tbl[] _
>  
>  MODULE_DEVICE_TABLE(pci, s2io_tbl);
>  
> +static struct pci_error_handlers s2io_err_handler = {
> + .error_detected = s2io_io_error_detected,
> + .slot_reset = s2io_io_slot_reset,
> + .resume = s2io_io_resume,
> +};
> +
>  static struct pci_driver s2io_driver = {
>.name = "S2IO",
>.id_table = s2io_tbl,
>.probe = s2io_init_nic,
>.remove = __devexit_p(s2io_rem_nic),
> +  .err_handler = &s2io_err_handler,
>  };
>  
>  /* A simplifier macro used both by init and free shared_mem Fns(). */
> @@ -2700,6 +2707,9 @@ static void s2io_netpoll(struct net_devi
>   u64 val64 = 0xULL;
>   int i;
>  
> + if (pci_channel_offline(nic->pdev))
> + return;
> +
>   disable_irq(dev->irq);
>  
>   atomic_inc(&nic->isr_cnt);
> @@ -3225,6 +3235,8 @@ static void alarm_intr_handler(struct s2
>   int i;
>   if (atomic_read(&nic->card_state) == CARD_DOWN)
>   return;
> + if (pci_channel_offline(nic->pdev))
> + return;
>   nic->mac_control.stats_info->sw_stat.ring_full_cnt = 0;
>   /* Handling the XPAK counters update */
>   if(nic->mac_control.stats_info->xpak_stat.xpak_timer_count < 72000) {
> @@ -4324,6 +4336,10 @@ static irqreturn_t s2io_isr(int irq, voi
>   struct mac_info *mac_control;
>   struct config_param *config;
>  
> + /* Pretend we handled any irq's from a disconnected card */
> + if (pci_channel_offline(sp->pdev))
> + return IRQ_NONE;
> +
>   atomic_inc(&sp->isr_cnt);
>   mac_control = &sp->mac_control;
>   config = &sp->config;
> @@ -6579,7 +6595,7 @@ static void s2io_rem_isr(struct s2io_nic
>   } while(cnt < 5);
>  }
>  
> -static void s2io_card_down(struct s2io_nic * sp)
> +static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
>  {
>   int cnt = 0;
>   struct XENA_dev_config __iomem *bar0 = sp->bar0;
> @@ -6594,7 +6610,8 @@ static void s2io_card_down(struct s2io_n
>   atomic_set(&sp->card_state, CARD_DOWN);
>  
>   /* disable Tx and Rx traffic on the NIC */
> - stop_nic(sp);
> + if (do_io)
> + stop_nic(sp);
>  
>   s2io_rem_isr(sp);
>  
> @@ -6602,7 +6619,7 @@ static void s2io_card_down(struct s2io_n
>   tasklet_kill(&sp->task);
>  
>   /* Check if the device is Quiescent and then Reset the NIC */
> - do {
> + while(do_io) {
>   /* As per the HW requirement we need to replenish the
>* receive buffer to avoid the ring bump. Since there is
>* no intention of processing the Rx frame at this pointwe are
> @@ -6627,8 +6644,9 @@ static void s2io_card_down(struct s2io_n
> (unsigned long long) val64);
>   break;
>   }
> - } while (1);
> - s2io_reset(sp);
> + }
> + if (do_io)
> + s2io_reset(sp);
>  
>   spin_lock_irqsave(&sp->tx_lock, flags);
>   /* Free all Tx buffers */
> @@ -6643,6 +6661,11 @@ static void s2io_card_down(struct s2io_n
>   clear_bit(0, &(sp->link_state));
>  }
>  
> +static void s2io_card_down(struct s2io_nic * sp)
> +{
> + do_s2io_card_down(sp, 1);
> +}
> +
>  static int s2io_card_up(struct s2io_nic * sp)
>  {
>   int i, ret = 0;
> @@ -8020,3 +8043,86 @@ static void lro_append_pkt(str

[PATCH 0/10] spidernet assorted fixes

2007-05-16 Thread Linas Vepstas

Jeff, 

Please apply & forward upstream the following patch series.

There's a variety of fixes & cleanups in here; the key fix
is a rather hard-to-reproduce bug where the hardware runs out
of ram, resulting in corruption of some sequencer. The only fix
is to reset the card. v-v  Unfortunately, this hard-to-repro
bug is hit during the fedora-core install process. Ugh.

--linas
-
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/10] spidernet: node-aware skbuff allocation

2007-05-16 Thread Linas Vepstas

From: Christoph Hellwig <[EMAIL PROTECTED]>

Spidernet was the driver I original did all the node-aware netdevice
allocation for, but after a year it still hasn't hit mainline.

Signed-off-by: Christoph Hellwig <[EMAIL PROTECTED]>
Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>



 drivers/net/spider_net.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-05-16 
11:58:41.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-05-16 12:00:25.0 
-0500
@@ -430,7 +430,8 @@ spider_net_prepare_rx_descr(struct spide
/* and we need to have it 128 byte aligned, therefore we allocate a
 * bit more */
/* allocate an skb */
-   descr->skb = dev_alloc_skb(bufsize + SPIDER_NET_RXBUF_ALIGN - 1);
+   descr->skb = netdev_alloc_skb(card->netdev,
+ bufsize + SPIDER_NET_RXBUF_ALIGN - 1);
if (!descr->skb) {
if (netif_msg_rx_err(card) && net_ratelimit())
pr_err("Not enough memory to allocate rx buffer\n");
-
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/10] spidernet: beautify error messages

2007-05-16 Thread Linas Vepstas

Make error messages print which interface they apply to.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   10 ++
 drivers/net/spider_net.h |2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-05-14 
17:05:03.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-05-15 14:47:38.0 
-0500
@@ -433,7 +433,8 @@ spider_net_prepare_rx_descr(struct spide
descr->skb = dev_alloc_skb(bufsize + SPIDER_NET_RXBUF_ALIGN - 1);
if (!descr->skb) {
if (netif_msg_rx_err(card) && net_ratelimit())
-   pr_err("Not enough memory to allocate rx buffer\n");
+   pr_err("%s: Not enough memory to allocate rx buffer\n",
+   card->netdev->name);
card->spider_stats.alloc_rx_skb_error++;
return -ENOMEM;
}
@@ -454,7 +455,8 @@ spider_net_prepare_rx_descr(struct spide
dev_kfree_skb_any(descr->skb);
descr->skb = NULL;
if (netif_msg_rx_err(card) && net_ratelimit())
-   pr_err("Could not iommu-map rx buffer\n");
+   pr_err("%s: Could not iommu-map rx buffer\n",
+ card->netdev->name);
card->spider_stats.rx_iommu_map_error++;
hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
} else {
@@ -1454,8 +1456,8 @@ spider_net_handle_error_irq(struct spide
case SPIDER_NET_GRFAFLLINT: /* fallthrough */
case SPIDER_NET_GRMFLLINT:
if (netif_msg_intr(card) && net_ratelimit())
-   pr_err("Spider RX RAM full, incoming packets "
-  "might be discarded!\n");
+   pr_err("%s: Spider RX RAM full, incoming packets "
+  "might be discarded!\n", card->netdev->name);
spider_net_rx_irq_off(card);
netif_rx_schedule(card->netdev);
show_error = 0;
Index: linux-2.6.22-rc1/drivers/net/spider_net.h
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.h  2007-05-15 
14:47:33.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.h   2007-05-15 14:47:58.0 
-0500
@@ -25,7 +25,7 @@
 #ifndef _SPIDER_NET_H
 #define _SPIDER_NET_H
 
-#define VERSION "2.0 A"
+#define VERSION "2.0 B"
 
 #include "sungem_phy.h"
 
-
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/10] spidernet: move a block of code around

2007-05-16 Thread Linas Vepstas

Put the enable and disable routines next to one-another, 
as this makes verifying thier symmetry that much easier.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-05-15 
13:31:05.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-05-15 13:31:11.0 
-0500
@@ -505,6 +505,20 @@ spider_net_enable_rxdmac(struct spider_n
 }
 
 /**
+ * spider_net_disable_rxdmac - disables the receive DMA controller
+ * @card: card structure
+ *
+ * spider_net_disable_rxdmac terminates processing on the DMA controller
+ * by turing off the DMA controller, with the force-end flag set.
+ */
+static inline void
+spider_net_disable_rxdmac(struct spider_net_card *card)
+{
+   spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR,
+SPIDER_NET_DMA_RX_FEND_VALUE);
+}
+
+/**
  * spider_net_refill_rx_chain - refills descriptors/skbs in the rx chains
  * @card: card structure
  *
@@ -656,20 +670,6 @@ write_hash:
 }
 
 /**
- * spider_net_disable_rxdmac - disables the receive DMA controller
- * @card: card structure
- *
- * spider_net_disable_rxdmac terminates processing on the DMA controller by
- * turing off DMA and issueing a force end
- */
-static void
-spider_net_disable_rxdmac(struct spider_net_card *card)
-{
-   spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR,
-SPIDER_NET_DMA_RX_FEND_VALUE);
-}
-
-/**
  * spider_net_prepare_tx_descr - fill tx descriptor with skb data
  * @card: card structure
  * @descr: descriptor structure to fill out
-
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/10] spidernet: zero out a pointer.

2007-05-16 Thread Linas Vepstas

Invalidate a pointer as its pci_unmap'ed; this is a bit of 
paranoia to make sure hardware doesn't continue trying to 
DMA to it.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-05-15 
13:31:11.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-05-15 13:31:16.0 
-0500
@@ -1068,6 +1068,7 @@ spider_net_decode_one_descr(struct spide
struct spider_net_descr_chain *chain = &card->rx_chain;
struct spider_net_descr *descr = chain->tail;
struct spider_net_hw_descr *hwdescr = descr->hwdescr;
+   u32 hw_buf_addr;
int status;
 
status = spider_net_get_descr_status(hwdescr);
@@ -1081,7 +1082,9 @@ spider_net_decode_one_descr(struct spide
chain->tail = descr->next;
 
/* unmap descriptor */
-   pci_unmap_single(card->pdev, hwdescr->buf_addr,
+   hw_buf_addr = hwdescr->buf_addr;
+   hwdescr->buf_addr = 0x0;
+   pci_unmap_single(card->pdev, hw_buf_addr,
SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
 
if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) ||
@@ -1117,7 +1120,7 @@ spider_net_decode_one_descr(struct spide
pr_err("%s: bad status, cmd_status=x%08x\n",
   card->netdev->name,
   hwdescr->dmac_cmd_status);
-   pr_err("buf_addr=x%08x\n", hwdescr->buf_addr);
+   pr_err("buf_addr=x%08x\n", hw_buf_addr);
pr_err("buf_size=x%08x\n", hwdescr->buf_size);
pr_err("next_descr_addr=x%08x\n", hwdescr->next_descr_addr);
pr_err("result_size=x%08x\n", hwdescr->result_size);
-
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/10] spidernet: null out skb pointer after its been used.

2007-05-16 Thread Linas Vepstas

If the ethernet interface is brought down while there is still
RX traffic in flight, the device shutdown routine can end up
trying to double-free an skb, leading to a crash in mm/slab.c
Avoid the double-free by nulling out the skb pointer.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |1 +
 1 file changed, 1 insertion(+)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-05-15 
14:36:13.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-05-15 14:39:18.0 
-0500
@@ -1135,6 +1135,7 @@ spider_net_decode_one_descr(struct spide
 
/* Ok, we've got a packet in descr */
spider_net_pass_skb_up(descr, card);
+   descr->skb = NULL;
hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
return 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 6/10] spidernet: Don't terminate the RX ring

2007-05-16 Thread Linas Vepstas

There is no real reason to terminate the RX ring; it
doesn't make the operation any smooother, and it does
require an extra sync. So don't do it.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-05-15 
13:31:16.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-05-15 13:51:39.0 
-0500
@@ -461,13 +461,9 @@ spider_net_prepare_rx_descr(struct spide
hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
} else {
hwdescr->buf_addr = buf;
-   hwdescr->next_descr_addr = 0;
wmb();
hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_CARDOWNED |
 SPIDER_NET_DMAC_NOINTR_COMPLETE;
-
-   wmb();
-   descr->prev->hwdescr->next_descr_addr = descr->bus_addr;
}
 
return 0;
@@ -556,12 +552,16 @@ spider_net_refill_rx_chain(struct spider
 static int
 spider_net_alloc_rx_skbs(struct spider_net_card *card)
 {
-   int result;
-   struct spider_net_descr_chain *chain;
+   struct spider_net_descr_chain *chain = &card->rx_chain;
+   struct spider_net_descr *start= chain->tail;
+   struct spider_net_descr *descr = start;
 
-   result = -ENOMEM;
+   /* Link up the hardware chain pointers */
+   do {
+   descr->prev->hwdescr->next_descr_addr = descr->bus_addr;
+   descr = descr->next;
+   } while (descr != start);
 
-   chain = &card->rx_chain;
/* Put at least one buffer into the chain. if this fails,
 * we've got a problem. If not, spider_net_refill_rx_chain
 * will do the rest at the end of this function. */
@@ -578,7 +578,7 @@ spider_net_alloc_rx_skbs(struct spider_n
 
 error:
spider_net_free_rx_chain_contents(card);
-   return result;
+   return -ENOMEM;
 }
 
 /**
-
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 7/10] spidernet: enhance the dump routine

2007-05-16 Thread Linas Vepstas

Crazy device problems are hard to debug, when one does not have
good trace info. This patch makes a major enhancement to the
device dump routine.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   62 ---
 1 file changed, 54 insertions(+), 8 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-05-15 
14:39:24.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-05-15 14:39:25.0 
-0500
@@ -1023,34 +1023,78 @@ spider_net_pass_skb_up(struct spider_net
card->netdev_stats.rx_bytes += skb->len;
 }
 
-#ifdef DEBUG
 static void show_rx_chain(struct spider_net_card *card)
 {
struct spider_net_descr_chain *chain = &card->rx_chain;
struct spider_net_descr *start= chain->tail;
struct spider_net_descr *descr= start;
+   struct spider_net_hw_descr *hwd = start->hwdescr;
+   char *iface = card->netdev->name;
+   u32 curr_desc, next_desc;
int status;
 
int cnt = 0;
-   int cstat = spider_net_get_descr_status(descr);
-   printk(KERN_INFO "RX chain tail at descr=%ld\n",
-(start - card->descr) - card->tx_chain.num_desc);
+   int off = 0;
+   int cstat = hwd->dmac_cmd_status;
+
+   printk(KERN_INFO "%s: Total number of descrs=%d\n",
+   iface, chain->num_desc);
+   printk(KERN_INFO "%s: Chain tail located at descr=%d\n",
+   iface, (int) (start - chain->ring));
+
+   curr_desc = spider_net_read_reg(card, SPIDER_NET_GDACTDPA);
+   next_desc = spider_net_read_reg(card, SPIDER_NET_GDACNEXTDA);
+
status = cstat;
do
{
-   status = spider_net_get_descr_status(descr);
+   hwd = descr->hwdescr;
+   off = descr - chain->ring;
+   if (descr==chain->head)
+   printk(KERN_INFO "%s: chain head is at %d\n", iface, 
off);
+   if (curr_desc == descr->bus_addr)
+   printk(KERN_INFO "%s: hw curr desc is at %d\n", iface, 
off);
+   if (next_desc == descr->bus_addr)
+   printk(KERN_INFO "%s: hw next desc is at %d\n", iface, 
off);
+   if (hwd->next_descr_addr == 0)
+   printk(KERN_INFO "%s: chain is cut at %d\n", iface, 
off);
+   status = hwd->dmac_cmd_status;
if (cstat != status) {
-   printk(KERN_INFO "Have %d descrs with stat=x%08x\n", 
cnt, cstat);
+   printk(KERN_INFO "%s: Have %d descrs with stat=x%08x\n",
+   iface, cnt, cstat);
cstat = status;
cnt = 0;
}
cnt ++;
descr = descr->next;
} while (descr != start);
-   printk(KERN_INFO "Last %d descrs with stat=x%08x\n", cnt, cstat);
-}
+   printk(KERN_INFO "%s: Last %d descrs with stat=x%08x\n",
+   iface, cnt, cstat);
+
+#ifdef DEBUG
+   /* Now dump the whole ring */
+   descr = start;
+   do
+   {
+   struct spider_net_hw_descr *hwd = descr->hwdescr;
+   status = spider_net_get_descr_status(hwd);
+   cnt = descr - chain->ring;
+   printk(KERN_INFO "Descr %d stat=0x%08x skb=%p\n",
+   cnt, status, descr->skb);
+   printk(KERN_INFO "bus addr=%08x buf addr=%08x sz=%d\n",
+   descr->bus_addr, hwd->buf_addr, hwd->buf_size);
+   printk(KERN_INFO "next=%08x result sz=%d valid sz=%d\n",
+   hwd->next_descr_addr, hwd->result_size, 
hwd->valid_size);
+   printk(KERN_INFO "dmac=%08x data stat=%08x data err=%08x\n",
+   hwd->dmac_cmd_status, hwd->data_status, 
hwd->data_error);
+   printk(KERN_INFO "\n");
+
+   descr = descr->next;
+   } while (descr != start);
 #endif
 
+}
+
 /**
  * spider_net_decode_one_descr - processes an RX descriptor
  * @card: card structure
@@ -1140,6 +1184,8 @@ spider_net_decode_one_descr(struct spide
return 1;
 
 bad_desc:
+   if (netif_msg_rx_err(card))
+   show_rx_chain(card);
dev_kfree_skb_irq(descr->skb);
descr->skb = NULL;
hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
-
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 8/10] spidernet: reset the card when an rxramfull is seen

2007-05-16 Thread Linas Vepstas

Some versions of the spider have a firmware bug, where the
RX ring sequencer goes crazy when the RX RAM on the device
fills up. Appearently the only viable wrkaround is a soft
reset of the card.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |   14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-05-15 
14:48:06.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-05-15 16:34:46.0 
-0500
@@ -1505,11 +1505,17 @@ spider_net_handle_error_irq(struct spide
case SPIDER_NET_GRFBFLLINT: /* fallthrough */
case SPIDER_NET_GRFAFLLINT: /* fallthrough */
case SPIDER_NET_GRMFLLINT:
-   if (netif_msg_intr(card) && net_ratelimit())
-   pr_err("%s: Spider RX RAM full, incoming packets "
-  "might be discarded!\n", card->netdev->name);
+   if (netif_msg_intr(card) && net_ratelimit()) {
+   pr_err("%s: Spider RX RAM full, reseting device.\n",
+  card->netdev->name);
+   show_rx_chain(card);
+   }
spider_net_rx_irq_off(card);
netif_rx_schedule(card->netdev);
+
+   /* If the card is spewing rxramfulls, then reset */
+   atomic_inc(&card->tx_timeout_task_counter);
+   schedule_work(&card->tx_timeout_task);
show_error = 0;
break;
 
@@ -2086,6 +2092,8 @@ spider_net_workaround_rxramfull(struct s
 {
int i, sequencer = 0;
 
+   printk(KERN_INFO "%s: calling rxramfull workaround\n", 
card->netdev->name);
+
/* cancel reset */
spider_net_write_reg(card, SPIDER_NET_CKRCTRL,
 SPIDER_NET_CKRCTRL_RUN_VALUE);
-
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 9/10] spidernet: service TX later.

2007-05-16 Thread Linas Vepstas

When entering the netdev poll routine, empty out the RX
chain first, before cleaning up the TX chain. This should
help avoid RX buffer overflows.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-05-16 
17:20:36.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-05-16 17:20:44.0 
-0500
@@ -1212,7 +1212,6 @@ spider_net_poll(struct net_device *netde
int packets_to_do, packets_done = 0;
int no_more_packets = 0;
 
-   spider_net_cleanup_tx_ring(card);
packets_to_do = min(*budget, netdev->quota);
 
while (packets_to_do) {
@@ -1231,6 +1230,8 @@ spider_net_poll(struct net_device *netde
spider_net_refill_rx_chain(card);
spider_net_enable_rxdmac(card);
 
+   spider_net_cleanup_tx_ring(card);
+
/* if all packets are in the stack, enable interrupts and return 0 */
/* if not, return 1 */
if (no_more_packets) {
-
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 10/10] spidernet: increase the NAPI weight

2007-05-16 Thread Linas Vepstas

Another way of minimizing the likelyhood of RX ram from overflowing
is to empty out the entire rx ring every chance we get. Change
the crazy watchdog timeout from 50 seconds to 3 seconds, while
we're here.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/spider_net.h |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.h
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.h  2007-05-16 
12:00:35.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.h   2007-05-16 12:00:35.0 
-0500
@@ -56,8 +56,13 @@ extern char spider_net_driver_name[];
 
 #define SPIDER_NET_RX_CSUM_DEFAULT 1
 
-#define SPIDER_NET_WATCHDOG_TIMEOUT50*HZ
-#define SPIDER_NET_NAPI_WEIGHT 64
+#define SPIDER_NET_WATCHDOG_TIMEOUT3*HZ
+
+/* We really really want to empty the ring buffer every time,
+ * so as to avoid the RX ram full bug. So set te napi wieght
+ * to the ring size 
+ */
+#define SPIDER_NET_NAPI_WEIGHT 
SPIDER_NET_RX_DESCRIPTORS_DEFAULT
 
 #define SPIDER_NET_FIRMWARE_SEQS   6
 #define SPIDER_NET_FIRMWARE_SEQWORDS   1024
-
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


RT patches expose netdev race [was Re: [RFC] [patch 2/2] powerpc 2.6.21-rt1: fix kernel hang and/or panic

2007-05-16 Thread Linas Vepstas
Hi,

On Tue, May 15, 2007 at 08:09:02PM +1000, Benjamin Herrenschmidt wrote:
> On Tue, 2007-05-15 at 17:47 +0900, Tsutomu OWA wrote:
> >   I encountered the following error when doing netperf from other machine 
> > to Celleb running RT kernel.  PREEPT_NONE kernel works just fine as well.
> 
> Hrm... sounds a bit weird. I wonder if there's a locking bug in the
> driver in the first place.
> 
> Linas, what's your take ?

Heh. I almost deleted the entire email thread cause it
didn't say "spidernet" in the subject line. :-)
Seriously, I really almost did 

Since this is a long email; let me put a summary up front:
I think the RT/premption patches are exposing some sort
of race in the ip header handling code. The rest of the 
note is forensics pointing to this.



Reading the patch, it looks like all it did was to move
around the locks, without changing the semantics. Two
comments about that:

-- The current spidernet locks are very fine-grained;
   this makes the whole thing function more smoothly.
   The patch would make them coarse-grained, I don't
   like that.

-- Moving around locks like that changes the timing
   completely, and changing the timing makes races
   come and go. The races seem to vanish, but that's
   only cause you are getting lucky.

Since I'm sick-n-tired of dealing with spidernet, I thought
I'd give this one a little extra attention.

The crash is a null pointer deref. The spidernet doesn't
use locks to protect null pointers. The spidernet mostly
doesn't play with pointers at all; they're mostly static.
So this crash is "unusual" from the get-go.

>> Instruction dump:
>> 6000 81790088 901f000c 913f0018 913f0008 917f0004 48132e8d
>> 6000
>> a019009e 2f800800 409e0038 e9390038 <88690009> 2f830006 419e0010
>> 2f830011

The crashing instruction is <88690009> which is very unique:
  lbz r3,9(r9)

load byte ... at an offset of 9 bytes!? spidernet does
nothing with bytes, so its another reason its not spidernet.

Below follows a manual disassembly. The guilty party appears
to the the skb, and spcifically, skb->head has not been set.
You'll have to read the details below to see why.

I do not know why sk_buff->head would be null, or
would be set in a racy kind of way, or why the rt patches
would cause this. But the evidence implicates that.

--linas

Long stuff below. For the record:

> > Unable to handle kernel paging request for data at address 0x0009
> > Faulting instruction address: 0xc0295434
> > Oops: Kernel access of bad area, sig: 11 [#1]
> > PREEMPT SMP NR_CPUS=2 NUMA 
> > Modules linked in:
> > NIP: C0295434 LR: C0295420 CTR: 
> > REGS: c95d6e30 TRAP: 0300   Not tainted  (2.6.21-rc5-rt7)
> > MSR: 80009032   CR: 24000482  XER: 2000
> > DAR: 0009, DSISR: 4000
> > TASK = c1e7c440[626] 'netserver' THREAD: c95d4000 CPU: 0
> > GPR00: 0800 C95D70B0 C05D77B8 0001 
> > GPR04: 0001  C95D7080  
> > GPR08: C95D7030  C95D7040  
> > GPR12: FC69925300080D5D C04DE680  00422208 
> > GPR16: 0040 00420D10  C95D7C88 
> > GPR20: C1E7C440  0001 C8ACEAE0 
> > GPR24: 0020 C0E50C80 81F84C5E C1C00BE0 
> > GPR28: C1C05430 C1C00B80 C0570F30 C1FD1720 
> > NIP [C0295434] .spider_net_xmit+0x1dc/0x448
> > LR [C0295420] .spider_net_xmit+0x1c8/0x448
> > Call Trace:
> > [C95D70B0] [C0295420] .spider_net_xmit+0x1c8/0x448 
> > (unreliable)
> > [C95D7160] [C0327EE8] .dev_hard_start_xmit+0x238/0x300
> > [C95D7200] [C033A7F4] .__qdisc_run+0xdc/0x2a4
> > [C95D72B0] [C032A948] .dev_queue_xmit+0x1b0/0x2fc
> > [C95D7350] [C034B470] .ip_output+0x280/0x2d8
> > [C95D73F0] [C034C6CC] .ip_queue_xmit+0x448/0x4d8
> > [C95D74F0] [C035F6D8] .tcp_transmit_skb+0x850/0x8c0
> > [C95D75C0] [C035C394] .__tcp_ack_snd_check+0x84/0xc0
> > [C95D7650] [C035E114] .tcp_rcv_established+0x4f0/0x8ac
> > [C95D7700] [C0365B24] .tcp_v4_do_rcv+0x5c/0x448
> > [C95D77D0] [C031C2C4] .release_sock+0x94/0x11c
> > [C95D7870] [C0354E7C] .tcp_recvmsg+0x374/0x8d8
> > [C95D7960] [C031B8A0] .sock_common_recvmsg+0x5c/0x84
> > [C00

Resending: RT patches expose netdev race [was Re: [RFC] [patch 2/2] powerpc 2.6.21-rt1: fix kernel hang and/or panic

2007-05-16 Thread Linas Vepstas
(resending , Owa-san was cut from cc list!??)

Hi,

On Tue, May 15, 2007 at 08:09:02PM +1000, Benjamin Herrenschmidt wrote:
> On Tue, 2007-05-15 at 17:47 +0900, Tsutomu OWA wrote:
> >   I encountered the following error when doing netperf from other machine 
> > to Celleb running RT kernel.  PREEPT_NONE kernel works just fine as well.
> 
> Hrm... sounds a bit weird. I wonder if there's a locking bug in the
> driver in the first place.
> 
> Linas, what's your take ?

Heh. I almost deleted the entire email thread cause it
didn't say "spidernet" in the subject line. :-)
Seriously, I really almost did 

Since this is a long email; let me put a summary up front:
I think the RT/premption patches are exposing some sort
of race in the ip header handling code. The rest of the 
note is forensics pointing to this.



Reading the patch, it looks like all it did was to move
around the locks, without changing the semantics. Two
comments about that:

-- The current spidernet locks are very fine-grained;
   this makes the whole thing function more smoothly.
   The patch would make them coarse-grained, I don't
   like that.

-- Moving around locks like that changes the timing
   completely, and changing the timing makes races
   come and go. The races seem to vanish, but that's
   only cause you are getting lucky.

Since I'm sick-n-tired of dealing with spidernet, I thought
I'd give this one a little extra attention.

The crash is a null pointer deref. The spidernet doesn't
use locks to protect null pointers. The spidernet mostly
doesn't play with pointers at all; they're mostly static.
So this crash is "unusual" from the get-go.

>> Instruction dump:
>> 6000 81790088 901f000c 913f0018 913f0008 917f0004 48132e8d
>> 6000
>> a019009e 2f800800 409e0038 e9390038 <88690009> 2f830006 419e0010
>> 2f830011

The crashing instruction is <88690009> which is very unique:
  lbz r3,9(r9)

load byte ... at an offset of 9 bytes!? spidernet does
nothing with bytes, so its another reason its not spidernet.

Below follows a manual disassembly. The guilty party appears
to the the skb, and spcifically, skb->head has not been set.
You'll have to read the details below to see why.

I do not know why sk_buff->head would be null, or
would be set in a racy kind of way, or why the rt patches
would cause this. But the evidence implicates that.

--linas

Long stuff below. For the record:

> > Unable to handle kernel paging request for data at address 0x0009
> > Faulting instruction address: 0xc0295434
> > Oops: Kernel access of bad area, sig: 11 [#1]
> > PREEMPT SMP NR_CPUS=2 NUMA 
> > Modules linked in:
> > NIP: C0295434 LR: C0295420 CTR: 
> > REGS: c95d6e30 TRAP: 0300   Not tainted  (2.6.21-rc5-rt7)
> > MSR: 80009032   CR: 24000482  XER: 2000
> > DAR: 0009, DSISR: 4000
> > TASK = c1e7c440[626] 'netserver' THREAD: c95d4000 CPU: 0
> > GPR00: 0800 C95D70B0 C05D77B8 0001 
> > GPR04: 0001  C95D7080  
> > GPR08: C95D7030  C95D7040  
> > GPR12: FC69925300080D5D C04DE680  00422208 
> > GPR16: 0040 00420D10  C95D7C88 
> > GPR20: C1E7C440  0001 C8ACEAE0 
> > GPR24: 0020 C0E50C80 81F84C5E C1C00BE0 
> > GPR28: C1C05430 C1C00B80 C0570F30 C1FD1720 
> > NIP [C0295434] .spider_net_xmit+0x1dc/0x448
> > LR [C0295420] .spider_net_xmit+0x1c8/0x448
> > Call Trace:
> > [C95D70B0] [C0295420] .spider_net_xmit+0x1c8/0x448 
> > (unreliable)
> > [C95D7160] [C0327EE8] .dev_hard_start_xmit+0x238/0x300
> > [C95D7200] [C033A7F4] .__qdisc_run+0xdc/0x2a4
> > [C95D72B0] [C032A948] .dev_queue_xmit+0x1b0/0x2fc
> > [C95D7350] [C034B470] .ip_output+0x280/0x2d8
> > [C95D73F0] [C034C6CC] .ip_queue_xmit+0x448/0x4d8
> > [C95D74F0] [C035F6D8] .tcp_transmit_skb+0x850/0x8c0
> > [C95D75C0] [C035C394] .__tcp_ack_snd_check+0x84/0xc0
> > [C95D7650] [C035E114] .tcp_rcv_established+0x4f0/0x8ac
> > [C95D7700] [C0365B24] .tcp_v4_do_rcv+0x5c/0x448
> > [C95D77D0] [C031C2C4] .release_sock+0x94/0x11c
> > [C95D7870] [C0354E7C] .tcp_recvmsg+0x374/0x8d8
> > [C95D7960] [C031B

Re: Resending: RT patches expose netdev race [was Re: [RFC] [patch 2/2] powerpc 2.6.21-rt1: fix kernel hang and/or panic

2007-05-17 Thread Linas Vepstas
On Thu, May 17, 2007 at 10:49:45AM +1000, Benjamin Herrenschmidt wrote:
> 
> > I do not know why sk_buff->head would be null, or
> > would be set in a racy kind of way, or why the rt patches
> > would cause this. But the evidence implicates that.
> 
> Would it be possible that a locking bug in spidernet would cause it
> under some circumstances to get a stale skb pointer ?

The skb pointer should be brand-spanking new/fresh. 
It is passed to spidernet by the netdev->hard_start_xmit
callback:

netdev->hard_start_xmit = &spider_net_xmit;

I'd expect that anything that hard_start_xmit() passed to 
a device driver should have a fully valid skb.  Locking
problems in spidernet could cause it to work with the wrong 
skb; however, in this case, the skb pointer is passed 
unmodified, directly to the spot where it fails.

Maybe there is some "make ip header fresh and clean on skb" call
that should have been made; if so, I don't know what it is. 

--linas
-
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: RT patches expose netdev race [was Re: [RFC] [patch 2/2] powerpc 2.6.21-rt1: fix kernel hang and/or panic

2007-05-17 Thread Linas Vepstas
On Wed, May 16, 2007 at 05:41:01PM -0700, David Miller wrote:
> From: [EMAIL PROTECTED] (Linas Vepstas)
> Date: Wed, 16 May 2007 19:18:02 -0500
> 
> > Since this is a long email; let me put a summary up front:
> > I think the RT/premption patches are exposing some sort
> > of race in the ip header handling code. The rest of the 
> > note is forensics pointing to this.
> 
> skb->head should never ever be NULL.

The stack trace from Owa-san showed a null pointer deref at 
ip_hdr(skb)->protocol for an skb passed in via hard_start_xmit()

I dunno, memory corruption?

Tsutomu, can you reproduce this with something similr to the following
patch?

--linas

 drivers/net/spider_net.c |   16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c  2007-05-17 
18:31:40.0 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c   2007-05-17 18:51:49.0 
-0500
@@ -720,7 +720,19 @@ spider_net_prepare_tx_descr(struct spide
SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_NOCS;
spin_unlock_irqrestore(&chain->lock, flags);
 
-   if (skb->protocol == htons(ETH_P_IP) && skb->ip_summed == 
CHECKSUM_PARTIAL)
+   if (skb->protocol == htons(ETH_P_IP) && skb->ip_summed == 
CHECKSUM_PARTIAL) {
+   struct iphdr *hp=ip_hdr(skb);
+   if (((unsigned long) hp < 0x10) || 
+   ((unsigned long)hp > 0xUL)) {
+   printk(KERN_ERROR "spidernet: bad ip header! "
+   "skb=%p ip_hdr=%p head=%p data=%p net=%x\n", 
skb, hp,
+   skb->head, skb->data, skb->network_header);
+   int i;
+   unsinged long *s=(unsigned long*) skb;
+   for (i=0; i<20; i++) {
+   printk("%d %lx %lx\n", i, s[2*i],s[2*i+1]);
+   }
+   } else {
switch (ip_hdr(skb)->protocol) {
case IPPROTO_TCP:
hwdescr->dmac_cmd_status |= SPIDER_NET_DMAC_TCP;
@@ -728,6 +740,8 @@ spider_net_prepare_tx_descr(struct spide
case IPPROTO_UDP:
hwdescr->dmac_cmd_status |= SPIDER_NET_DMAC_UDP;
break;
+   }
+   }
}
 
/* Chain the bus address, so that the DMA engine finds this descr. */
-
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 2/10] spidernet: beautify error messages

2007-05-18 Thread Linas Vepstas
On Thu, May 17, 2007 at 09:28:53AM +1000, Michael Ellerman wrote:
> On Wed, 2007-05-16 at 17:00 -0500, Linas Vepstas wrote:
> > -   pr_err("Not enough memory to allocate rx buffer\n");
> > +   pr_err("%s: Not enough memory to allocate rx buffer\n",
> > +   card->netdev->name);
> 
> Isn't that what dev_err() is for?

Ahh, did not know that. These patches just got pushed upstream, I'll send 
a separate round to clean this up.

--linas


-
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 1/10] spidernet: node-aware skbuff allocation

2007-05-18 Thread Linas Vepstas
On Thu, May 17, 2007 at 08:46:00PM -0400, Jeff Garzik wrote:
> Linas Vepstas wrote:
> 
> applied

Thanks

--linas

-
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 1/2] s2io: add PCI error recovery support

2007-05-21 Thread Linas Vepstas
On Fri, May 18, 2007 at 03:06:53AM -0400, Sivakumar Subramani wrote:
> Hi,
> 
> Fix looks good. I have couple of comments,
> 
> 1) Return from s2io_updt_stats function if the PCI bus is offline
> (pci_channel_offline). 
>  if (pci_channel_offline(pdev))
> return;

OK, missed that one.

> 2) No Need to call netif_wake_queue() in s2io_io_resume as
> netif_device_attach() will take care of calling it.

OK.

> 3) We need to return from s2io_msix_ring_handle(),
> s2io_msix_fifo_handle(), s2io_msi_handle() if the PCI channel is
> offline. Some thing similary to the below condition that is added in the
> s2io_isr()

I was thinking that these wouldn't be needed, as MSI should stop
flowing along with everything else. However, there is a small race
window where the MSI was delivered on the PCI bus, then the error was
detected, and then the kernel delivers the MSI to device driver.
The if statements should close that gap.

I'll send an updated patch shortly.

--linas
-
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/2 v4] s2io: add PCI error recovery support

2007-05-21 Thread Linas Vepstas

This patch adds PCI error recovery support to the 
s2io 10-Gigabit ethernet device driver. Fourth revision,
blocks MSI interrupts, and statistics gathering, as well.

Tested, seems to work well.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>
Acked-by: Ramkrishna Vepa <[EMAIL PROTECTED]>
Cc: Sivakumar Subramani <[EMAIL PROTECTED]>
Cc: Sreenivasa Honnur <[EMAIL PROTECTED]>
Cc: Rastapur Santosh <[EMAIL PROTECTED]>
Cc: Wen Xiong <[EMAIL PROTECTED]>


Please apply. This has been submitted for 2.6.19, 2.6.20 and 2.6.21
with no major criticisms made, although with minor polish & fixups.
I think its ready.

Linas.

 drivers/net/s2io.c |  127 ++---
 drivers/net/s2io.h |5 ++
 2 files changed, 127 insertions(+), 5 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/s2io.c
===
--- linux-2.6.22-rc1.orig/drivers/net/s2io.c2007-05-21 11:52:40.0 
-0500
+++ linux-2.6.22-rc1/drivers/net/s2io.c 2007-05-21 13:35:18.0 -0500
@@ -480,11 +480,18 @@ static struct pci_device_id s2io_tbl[] _
 
 MODULE_DEVICE_TABLE(pci, s2io_tbl);
 
+static struct pci_error_handlers s2io_err_handler = {
+   .error_detected = s2io_io_error_detected,
+   .slot_reset = s2io_io_slot_reset,
+   .resume = s2io_io_resume,
+};
+
 static struct pci_driver s2io_driver = {
   .name = "S2IO",
   .id_table = s2io_tbl,
   .probe = s2io_init_nic,
   .remove = __devexit_p(s2io_rem_nic),
+  .err_handler = &s2io_err_handler,
 };
 
 /* A simplifier macro used both by init and free shared_mem Fns(). */
@@ -2700,6 +2707,9 @@ static void s2io_netpoll(struct net_devi
u64 val64 = 0xULL;
int i;
 
+   if (pci_channel_offline(nic->pdev))
+   return;
+
disable_irq(dev->irq);
 
atomic_inc(&nic->isr_cnt);
@@ -3223,6 +3233,8 @@ static void alarm_intr_handler(struct s2
register u64 val64 = 0, err_reg = 0;
u64 cnt;
int i;
+   if (pci_channel_offline(nic->pdev))
+   return;
if (atomic_read(&nic->card_state) == CARD_DOWN)
return;
nic->mac_control.stats_info->sw_stat.ring_full_cnt = 0;
@@ -4191,6 +4203,9 @@ static irqreturn_t s2io_msi_handle(int i
struct mac_info *mac_control;
struct config_param *config;
 
+   if (pci_channel_offline(sp->pdev))
+   return IRQ_NONE;
+
atomic_inc(&sp->isr_cnt);
mac_control = &sp->mac_control;
config = &sp->config;
@@ -4221,6 +4236,9 @@ static irqreturn_t s2io_msix_ring_handle
struct ring_info *ring = (struct ring_info *)dev_id;
struct s2io_nic *sp = ring->nic;
 
+   if (pci_channel_offline(sp->pdev))
+   return IRQ_NONE;
+
atomic_inc(&sp->isr_cnt);
 
rx_intr_handler(ring);
@@ -4235,6 +4253,9 @@ static irqreturn_t s2io_msix_fifo_handle
struct fifo_info *fifo = (struct fifo_info *)dev_id;
struct s2io_nic *sp = fifo->nic;
 
+   if (pci_channel_offline(sp->pdev))
+   return IRQ_NONE;
+
atomic_inc(&sp->isr_cnt);
tx_intr_handler(fifo);
atomic_dec(&sp->isr_cnt);
@@ -4324,6 +4345,10 @@ static irqreturn_t s2io_isr(int irq, voi
struct mac_info *mac_control;
struct config_param *config;
 
+   /* Pretend we handled any irq's from a disconnected card */
+   if (pci_channel_offline(sp->pdev))
+   return IRQ_NONE;
+
atomic_inc(&sp->isr_cnt);
mac_control = &sp->mac_control;
config = &sp->config;
@@ -4413,6 +4438,9 @@ static void s2io_updt_stats(struct s2io_
u64 val64;
int cnt = 0;
 
+   if (pci_channel_offline(sp->pdev))
+   return;
+
if (atomic_read(&sp->card_state) == CARD_UP) {
/* Apprx 30us on a 133 MHz bus */
val64 = SET_UPDT_CLICKS(10) |
@@ -6579,7 +6607,7 @@ static void s2io_rem_isr(struct s2io_nic
} while(cnt < 5);
 }
 
-static void s2io_card_down(struct s2io_nic * sp)
+static void do_s2io_card_down(struct s2io_nic * sp, int do_io)
 {
int cnt = 0;
struct XENA_dev_config __iomem *bar0 = sp->bar0;
@@ -6594,7 +6622,8 @@ static void s2io_card_down(struct s2io_n
atomic_set(&sp->card_state, CARD_DOWN);
 
/* disable Tx and Rx traffic on the NIC */
-   stop_nic(sp);
+   if (do_io)
+   stop_nic(sp);
 
s2io_rem_isr(sp);
 
@@ -6602,7 +6631,7 @@ static void s2io_card_down(struct s2io_n
tasklet_kill(&sp->task);
 
/* Check if the device is Quiescent and then Reset the NIC */
-   do {
+   while(do_io) {
/* As per the HW requirement we need to replenish the
   

[PATCH 2/2]: s2io: minor janitoring

2007-05-21 Thread Linas Vepstas

s2io cleanup suggestions, per discussion on mailing lists.

Signed-off-by: Linas Vepstas <[EMAIL PROTECTED]>


 drivers/net/s2io.c |2 --
 drivers/net/s2io.h |1 -
 2 files changed, 3 deletions(-)

Index: linux-2.6.22-rc1/drivers/net/s2io.c
===
--- linux-2.6.22-rc1.orig/drivers/net/s2io.c2007-05-21 13:32:45.0 
-0500
+++ linux-2.6.22-rc1/drivers/net/s2io.c 2007-05-21 13:33:18.0 -0500
@@ -3980,7 +3980,6 @@ static int s2io_close(struct net_device 
/* Reset card, kill tasklet and free Tx and Rx buffers. */
s2io_card_down(sp);
 
-   sp->device_close_flag = TRUE;   /* Device is shut down. */
return 0;
 }
 
@@ -8075,7 +8074,6 @@ static pci_ers_result_t s2io_io_error_de
if (netif_running(netdev)) {
/* Bring down the card, while avoiding PCI I/O */
do_s2io_card_down(sp, 0);
-   sp->device_close_flag = TRUE;   /* Device is shut down. */
}
pci_disable_device(pdev);
 
Index: linux-2.6.22-rc1/drivers/net/s2io.h
===
--- linux-2.6.22-rc1.orig/drivers/net/s2io.h2007-05-21 11:54:52.0 
-0500
+++ linux-2.6.22-rc1/drivers/net/s2io.h 2007-05-21 13:33:18.0 -0500
@@ -794,7 +794,6 @@ struct s2io_nic {
 
struct net_device_stats stats;
int high_dma_flag;
-   int device_close_flag;
int device_enabled_once;
 
char name[60];
-
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 1/2 v4] s2io: add PCI error recovery support

2007-05-21 Thread Linas Vepstas
On Mon, May 21, 2007 at 02:48:47PM -0700, Andrew Morton wrote:
> On Mon, 21 May 2007 13:58:53 -0500
> [EMAIL PROTECTED] (Linas Vepstas) wrote:
> > This patch adds PCI error recovery support to the 
> 
> This is already in Jeff's development tree.  Your new patch neither
> applies nor unapplies, so if you've changed it, Jeff is now sitting
> on an old version.  I assume he'd like an incremental update patch.

Ahh ! 

I assume I have to git-pull
  /pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git
or something like that. Will try that now.

The part that confuses me is that I'd gotten a message from Jeff
back in March (well before 2.6.21 came out), saying it was in his
development tree; yet, the patch its not in 2.6.22-rc; Torvalds
hasn't yet pulled from it?

--linas
-
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 1/2 v4] s2io: add PCI error recovery support

2007-05-22 Thread Linas Vepstas
On Mon, May 21, 2007 at 06:51:45PM -0400, Jeff Garzik wrote:
> 
> >The part that confuses me is that I'd gotten a message from Jeff
> >back in March (well before 2.6.21 came out), saying it was in his
> >development tree; yet, the patch its not in 2.6.22-rc; Torvalds
> >hasn't yet pulled from it?
> 
> It only appeared in my tree on May 14.  I tend to drop patches that are 
> repeatedly revised, allowing the dust to settle.

OK, a new patch is coming. I did not want to pester you until after -rc1
came out, but perhaps that was the wrong strategy.

--linas

-
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


  1   2   3   4   >