Re: [PATCH] [9/11] pasemi_mac: clear out old errors on interface open

2007-10-03 Thread Jeff Garzik

Olof Johansson wrote:

pasemi_mac: clear out old errors on interface open

Clear out any pending errors when an interface is brought up. Since the bits
are sticky, they might be from interface shutdown time after firmware has
used it, etc.

Signed-off-by: Olof Johansson [EMAIL PROTECTED]


In general, interface-open should completely reset and initialize the 
hardware.  does pasemi_mac not do that?


Jeff



-
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] [9/11] pasemi_mac: clear out old errors on interface open

2007-10-03 Thread Olof Johansson
On Wed, Oct 03, 2007 at 01:46:16PM -0400, Jeff Garzik wrote:
 Olof Johansson wrote:
 pasemi_mac: clear out old errors on interface open
 Clear out any pending errors when an interface is brought up. Since the 
 bits
 are sticky, they might be from interface shutdown time after firmware has
 used it, etc.
 Signed-off-by: Olof Johansson [EMAIL PROTECTED]

 In general, interface-open should completely reset and initialize the 
 hardware.  does pasemi_mac not do that?

There's no explicit way to reset just one interface besides disabling it
(which we do at close, and re-enable at open). It seems that some of
the error bits are sticky across disable/enable, which is why this was
needed. Also, they're RW1C, so writing 0 doesn't remove them (need to
write 1 to clear).

The only other dependency from firmware at this time is the setting of mac
addresses, something that will be taken care of once we allow override of
them via ethtool, since we'd need to program them from the driver then
no matter what. Right now we assume that firmware has programmed it.


-Olof

-
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] [9/11] pasemi_mac: clear out old errors on interface open

2007-10-03 Thread Jeff Garzik

Olof Johansson wrote:

On Wed, Oct 03, 2007 at 01:46:16PM -0400, Jeff Garzik wrote:

Olof Johansson wrote:

pasemi_mac: clear out old errors on interface open
Clear out any pending errors when an interface is brought up. Since the 
bits

are sticky, they might be from interface shutdown time after firmware has
used it, etc.
Signed-off-by: Olof Johansson [EMAIL PROTECTED]
In general, interface-open should completely reset and initialize the 
hardware.  does pasemi_mac not do that?


There's no explicit way to reset just one interface besides disabling it
(which we do at close, and re-enable at open). It seems that some of
the error bits are sticky across disable/enable, which is why this was
needed. Also, they're RW1C, so writing 0 doesn't remove them (need to
write 1 to clear).


OK just making sure, thanks.



The only other dependency from firmware at this time is the setting of mac
addresses, something that will be taken care of once we allow override of
them via ethtool, since we'd need to program them from the driver then
no matter what. Right now we assume that firmware has programmed it.


Standard procedure for this is

* upon module-load, obtain the MAC address from whatever canonical source
* upon interface-up, program dev-dev_addr[] into chip's RX filter (aka 
MAC address) registers


That permits the admin to override the MAC address via ifconfig. 
(ethtool doesn't support that, but you basically had the right idea)


Jeff


-
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/11] pasemi_mac: clear out old errors on interface open

2007-10-02 Thread Olof Johansson
pasemi_mac: clear out old errors on interface open

Clear out any pending errors when an interface is brought up. Since the bits
are sticky, they might be from interface shutdown time after firmware has
used it, etc.

Signed-off-by: Olof Johansson [EMAIL PROTECTED]

Index: k.org/drivers/net/pasemi_mac.c
===
--- k.org.orig/drivers/net/pasemi_mac.c
+++ k.org/drivers/net/pasemi_mac.c
@@ -903,16 +903,27 @@ static int pasemi_mac_open(struct net_de
 
/* enable rx if */
write_dma_reg(mac, PAS_DMA_RXINT_RCMDSTA(mac-dma_if),
-  PAS_DMA_RXINT_RCMDSTA_EN);
+  PAS_DMA_RXINT_RCMDSTA_EN |
+  PAS_DMA_RXINT_RCMDSTA_DROPS_M |
+  PAS_DMA_RXINT_RCMDSTA_BP |
+  PAS_DMA_RXINT_RCMDSTA_OO |
+  PAS_DMA_RXINT_RCMDSTA_BT);
 
/* enable rx channel */
write_dma_reg(mac, PAS_DMA_RXCHAN_CCMDSTA(mac-dma_rxch),
   PAS_DMA_RXCHAN_CCMDSTA_EN |
-  PAS_DMA_RXCHAN_CCMDSTA_DU);
+  PAS_DMA_RXCHAN_CCMDSTA_DU |
+  PAS_DMA_RXCHAN_CCMDSTA_OD |
+  PAS_DMA_RXCHAN_CCMDSTA_FD |
+  PAS_DMA_RXCHAN_CCMDSTA_DT);
 
/* enable tx channel */
write_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac-dma_txch),
-  PAS_DMA_TXCHAN_TCMDSTA_EN);
+  PAS_DMA_TXCHAN_TCMDSTA_EN |
+  PAS_DMA_TXCHAN_TCMDSTA_SZ |
+  PAS_DMA_TXCHAN_TCMDSTA_DB |
+  PAS_DMA_TXCHAN_TCMDSTA_DE |
+  PAS_DMA_TXCHAN_TCMDSTA_DA);
 
pasemi_mac_replenish_rx_ring(dev, RX_RING_SIZE);
 
@@ -987,7 +998,7 @@ out_rx_resources:
 static int pasemi_mac_close(struct net_device *dev)
 {
struct pasemi_mac *mac = netdev_priv(dev);
-   unsigned int stat;
+   unsigned int sta;
int retries;
 
if (mac-phydev) {
@@ -998,6 +1009,26 @@ static int pasemi_mac_close(struct net_d
netif_stop_queue(dev);
napi_disable(mac-napi);
 
+   sta = read_dma_reg(mac, PAS_DMA_RXINT_RCMDSTA(mac-dma_if));
+   if (sta  (PAS_DMA_RXINT_RCMDSTA_BP |
+ PAS_DMA_RXINT_RCMDSTA_OO |
+ PAS_DMA_RXINT_RCMDSTA_BT))
+   printk(KERN_DEBUG pasemi_mac: rcmdsta error: 0x%08x\n, sta);
+
+   sta = read_dma_reg(mac, PAS_DMA_RXCHAN_CCMDSTA(mac-dma_rxch));
+   if (sta  (PAS_DMA_RXCHAN_CCMDSTA_DU |
+PAS_DMA_RXCHAN_CCMDSTA_OD |
+PAS_DMA_RXCHAN_CCMDSTA_FD |
+PAS_DMA_RXCHAN_CCMDSTA_DT))
+   printk(KERN_DEBUG pasemi_mac: ccmdsta error: 0x%08x\n, sta);
+
+   sta = read_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac-dma_txch));
+   if (sta  (PAS_DMA_TXCHAN_TCMDSTA_SZ |
+ PAS_DMA_TXCHAN_TCMDSTA_DB |
+ PAS_DMA_TXCHAN_TCMDSTA_DE |
+ PAS_DMA_TXCHAN_TCMDSTA_DA))
+   printk(KERN_DEBUG pasemi_mac: tcmdsta error: 0x%08x\n, sta);
+
/* Clean out any pending buffers */
pasemi_mac_clean_tx(mac);
pasemi_mac_clean_rx(mac, RX_RING_SIZE);
@@ -1008,33 +1039,33 @@ static int pasemi_mac_close(struct net_d
write_dma_reg(mac, PAS_DMA_RXCHAN_CCMDSTA(mac-dma_rxch), 
PAS_DMA_RXCHAN_CCMDSTA_ST);
 
for (retries = 0; retries  MAX_RETRIES; retries++) {
-   stat = read_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac-dma_txch));
-   if (!(stat  PAS_DMA_TXCHAN_TCMDSTA_ACT))
+   sta = read_dma_reg(mac, PAS_DMA_TXCHAN_TCMDSTA(mac-dma_txch));
+   if (!(sta  PAS_DMA_TXCHAN_TCMDSTA_ACT))
break;
cond_resched();
}
 
-   if (stat  PAS_DMA_TXCHAN_TCMDSTA_ACT)
+   if (sta  PAS_DMA_TXCHAN_TCMDSTA_ACT)
dev_err(mac-dma_pdev-dev, Failed to stop tx channel\n);
 
for (retries = 0; retries  MAX_RETRIES; retries++) {
-   stat = read_dma_reg(mac, PAS_DMA_RXCHAN_CCMDSTA(mac-dma_rxch));
-   if (!(stat  PAS_DMA_RXCHAN_CCMDSTA_ACT))
+   sta = read_dma_reg(mac, PAS_DMA_RXCHAN_CCMDSTA(mac-dma_rxch));
+   if (!(sta  PAS_DMA_RXCHAN_CCMDSTA_ACT))
break;
cond_resched();
}
 
-   if (stat  PAS_DMA_RXCHAN_CCMDSTA_ACT)
+   if (sta  PAS_DMA_RXCHAN_CCMDSTA_ACT)
dev_err(mac-dma_pdev-dev, Failed to stop rx channel\n);
 
for (retries = 0; retries  MAX_RETRIES; retries++) {
-   stat = read_dma_reg(mac, PAS_DMA_RXINT_RCMDSTA(mac-dma_if));
-   if (!(stat  PAS_DMA_RXINT_RCMDSTA_ACT))
+   sta = read_dma_reg(mac, PAS_DMA_RXINT_RCMDSTA(mac-dma_if));
+   if (!(sta  PAS_DMA_RXINT_RCMDSTA_ACT))
break;