Re: [PATCH] tcp_output: Re: rare bad TCP checksum with 2.6.19?

2007-01-21 Thread Herbert Xu
On Mon, Jan 22, 2007 at 07:52:14AM +0100, Jarek Poplawski wrote:
>  
> I was so impressed by the amount of work done by Michael
> that I magnified his merit and forgot to mention the role
> of Patrick and Herbert, particularly here:

You don't need to be so modest!

While no doubt Patrick helped in tracking this down, my role in
this thread is solely in adding this bug in the first place :)

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-
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] tcp_output: Re: rare bad TCP checksum with 2.6.19?

2007-01-21 Thread Michael Tokarev
Jarek Poplawski wrote:
> On Fri, Jan 19, 2007 at 03:08:20PM +0100, Jarek Poplawski wrote:
> ...
>> You are welcome! But you probably didn't read this with
>> attention: if it works, you should thank mainly to that
>> other guy...
>>
>> Btw. I can't remember I've seen such ferocious testing
>> ever!
> 
> After checking in the dictionary I found my btw. could
> be rather confusing:
> 
>> ferocious:
>> 1.savagely fierce, as a wild beast, person, action,
>>  or aspect; violently cruel: a ferocious beating.
>> 2.extreme or intense: a ferocious thirst. 
> 
> I've only meant #2 - and nothing like #1.
> If you were confused - sorry!

Heh.

Jarek, thank you for your apprecation of my efforts.

And no, I noticied this your statement in the first place
(in good sense - like, #2 above) -- I wanted to comment on
it first, but didn't.

I was only running tcpdump - yes, it was running almost the
whole day, with different options.  I did almost nothing.

You over-estimate my contribution, really ;)

The very good thing is that this bug is now found, and *that*
is what matters.

/mjt
-
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] tcp_output: Re: rare bad TCP checksum with 2.6.19?

2007-01-21 Thread Jarek Poplawski
On Fri, Jan 19, 2007 at 03:08:20PM +0100, Jarek Poplawski wrote:
...
> You are welcome! But you probably didn't read this with
> attention: if it works, you should thank mainly to that
> other guy...
> 
> Btw. I can't remember I've seen such ferocious testing
> ever!

After checking in the dictionary I found my btw. could
be rather confusing:

> ferocious:
> 1.savagely fierce, as a wild beast, person, action,
>  or aspect; violently cruel: a ferocious beating.
> 2.extreme or intense: a ferocious thirst. 

I've only meant #2 - and nothing like #1.
If you were confused - sorry!

Jarek P.
-
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] tcp_output: Re: rare bad TCP checksum with 2.6.19?

2007-01-21 Thread Jarek Poplawski
On Sat, Jan 20, 2007 at 08:10:27AM +1100, Herbert Xu wrote:
> On Fri, Jan 19, 2007 at 12:06:41PM +0100, Jarek Poplawski wrote:
> > 
> > [PATCH][NET] tcp_output: rare bad TCP checksum with 2.6.19
> > 
> > The patch "Replace CHECKSUM_HW by CHECKSUM_PARTIAL/CHECKSUM_COMPLETE"
> > changed to unconditional copying of ip_summed field from collapsed
> > skb. This patch reverts this change.   
> > 
> > All substantial work including heavy testing and diagnosing by:
> > Michael Tokarev <[EMAIL PROTECTED]>
> > 
> > Signed-off-by: Jarek Poplawski <[EMAIL PROTECTED]>
> 
> Acked-by: Herbert Xu <[EMAIL PROTECTED]>
> 
> Thanks for catching this! I'll take the credit for adding this bug :)
> 
> Dave, we'll need this fix for 2.6.20 as well as 2.6.19.
 
I was so impressed by the amount of work done by Michael
that I magnified his merit and forgot to mention the role
of Patrick and Herbert, particularly here:

> Since you're certain that this is being seen on the wire, one
> possibility is that we've got a bug somewhere that's zeroing
> skb->ip_summed on a packet with a partial checksum.

which exactly pointed the reason.

So, I apologize to them and, if there is such possibility,
I would like to ask David Miller to change the description
like that: 
---
[PATCH][NET] tcp_output: rare bad TCP checksum with 2.6.19

The patch "Replace CHECKSUM_HW by CHECKSUM_PARTIAL/CHECKSUM_COMPLETE"
changed to unconditional copying of ip_summed field from collapsed
skb. This patch reverts this change.

The majority of substantial work including heavy testing
and diagnosing by: Michael Tokarev <[EMAIL PROTECTED]>
Possible reasons pointed by: Herbert Xu and Patrick McHardy.

Signed-off-by: Jarek Poplawski <[EMAIL PROTECTED]>

Acked-by: Herbert Xu <[EMAIL PROTECTED]>
---

Regards,
Jarek P.
-
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 V2] bcm43xx: Fix problem with >1 GB RAM

2007-01-21 Thread Larry Finger
Some versions of the bcm43xx chips only support 30-bit DMA, which means
that the descriptors and buffers must be in the first 1 GB of RAM. On
the i386 and x86_64 architectures with more than 1 GB RAM, an incorrect
assignment may occur. This patch ensures that the various DMA addresses
are within the capability of the chip. Testing has been limited to x86_64
as no one has an i386 system with more than 1 GB RAM.

Signed-off-by: Larry Finger <[EMAIL PROTECTED]>
---

John,

This patch should be applied to wireless-2.6 and pushed up to 2.6.20.
V2 removes a couple of BUG statements that were used for debugging, and
accidentally left in.

Thanks,

Larry

Index: wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
===
--- wireless-2.6.orig/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
+++ wireless-2.6/drivers/net/wireless/bcm43xx/bcm43xx_dma.c
@@ -145,16 +145,14 @@ dma_addr_t map_descbuffer(struct bcm43xx
  int tx)
 {
dma_addr_t dmaaddr;
+   int direction = PCI_DMA_FROMDEVICE;
 
-   if (tx) {
-   dmaaddr = dma_map_single(&ring->bcm->pci_dev->dev,
-buf, len,
-DMA_TO_DEVICE);
-   } else {
-   dmaaddr = dma_map_single(&ring->bcm->pci_dev->dev,
+   if (tx)
+   direction = PCI_DMA_TODEVICE;
+
+   dmaaddr = pci_map_single(ring->bcm->pci_dev,
 buf, len,
-DMA_FROM_DEVICE);
-   }
+direction);
 
return dmaaddr;
 }
@@ -166,13 +164,13 @@ void unmap_descbuffer(struct bcm43xx_dma
  int tx)
 {
if (tx) {
-   dma_unmap_single(&ring->bcm->pci_dev->dev,
+   pci_unmap_single(ring->bcm->pci_dev,
 addr, len,
-DMA_TO_DEVICE);
+PCI_DMA_TODEVICE);
} else {
-   dma_unmap_single(&ring->bcm->pci_dev->dev,
+   pci_unmap_single(ring->bcm->pci_dev,
 addr, len,
-DMA_FROM_DEVICE);
+PCI_DMA_FROMDEVICE);
}
 }
 
@@ -183,8 +181,8 @@ void sync_descbuffer_for_cpu(struct bcm4
 {
assert(!ring->tx);
 
-   dma_sync_single_for_cpu(&ring->bcm->pci_dev->dev,
-   addr, len, DMA_FROM_DEVICE);
+   pci_dma_sync_single_for_cpu(ring->bcm->pci_dev,
+   addr, len, PCI_DMA_FROMDEVICE);
 }
 
 static inline
@@ -194,8 +192,8 @@ void sync_descbuffer_for_device(struct b
 {
assert(!ring->tx);
 
-   dma_sync_single_for_device(&ring->bcm->pci_dev->dev,
-  addr, len, DMA_FROM_DEVICE);
+   pci_dma_sync_single_for_cpu(ring->bcm->pci_dev,
+   addr, len, PCI_DMA_TODEVICE);
 }
 
 /* Unmap and free a descriptor buffer. */
@@ -214,17 +212,53 @@ void free_descriptor_buffer(struct bcm43
 
 static int alloc_ringmemory(struct bcm43xx_dmaring *ring)
 {
-   struct device *dev = &(ring->bcm->pci_dev->dev);
-
-   ring->descbase = dma_alloc_coherent(dev, BCM43xx_DMA_RINGMEMSIZE,
-   &(ring->dmabase), GFP_KERNEL);
+   ring->descbase = pci_alloc_consistent(ring->bcm->pci_dev, 
BCM43xx_DMA_RINGMEMSIZE,
+   &(ring->dmabase));
if (!ring->descbase) {
-   printk(KERN_ERR PFX "DMA ringmemory allocation failed\n");
-   return -ENOMEM;
+   /* Allocation may have failed due to pci_alloc_consistent
+  insisting on use of GFP_DMA, which is more restrictive
+  than necessary...  */
+   struct dma_desc *rx_ring;
+   dma_addr_t rx_ring_dma;
+
+   rx_ring = kzalloc(BCM43xx_DMA_RINGMEMSIZE, GFP_KERNEL);
+   if (!rx_ring)
+   goto out_err;
+
+   rx_ring_dma = pci_map_single(ring->bcm->pci_dev, rx_ring,
+BCM43xx_DMA_RINGMEMSIZE,
+PCI_DMA_BIDIRECTIONAL);
+
+   if (pci_dma_mapping_error(rx_ring_dma) ||
+   rx_ring_dma + BCM43xx_DMA_RINGMEMSIZE > 
ring->bcm->dma_mask) {
+   /* Sigh... */
+   if (!pci_dma_mapping_error(rx_ring_dma))
+   pci_unmap_single(ring->bcm->pci_dev,
+rx_ring_dma, 
BCM43xx_DMA_RINGMEMSIZE,
+PCI_DMA_BIDIRECTIONAL);
+   rx_ring_dma = pci_map_single(ring->bcm->pci_dev,
+rx_ring, 
BCM43xx_DMA_RINGMEMSIZE,
+  

Re: [PATCH 4/4] atl1: Ancillary C files for Attansic L1 driver

2007-01-21 Thread Jay Cliburn

Randy Dunlap wrote:

On Sun, 21 Jan 2007 15:07:37 -0600 Jay Cliburn wrote:

[snip]


+   value = ioread16(hw->hw_addr + REG_PCIE_CAP_LIST);
+   return ((value & 0xFF00) == 0x6C00) ? 0 : 1;


Are there defines or enums for these?
Fewer magic numbers would be nice/helpful/readable.

[snip]

+   s32 ret;
+   ret = atl1_write_phy_reg(hw, 29, 0x0029);


Fewer magic numbers?


Unfortunately, we don't have a spec.  This is how the vendor coded it.

[snip]

+
+int enable_msi;
+module_param(enable_msi, int, 0444);
+MODULE_PARM_DESC(enable_msi, "Enable PCI MSI");


Hm, I thought that we didn't want individual drivers having MSI config
options...


Luca?  This one was yours IIRC.  Care to chime in?

Randy, thank you for the review.

Jay
-
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 4/4] atl1: Ancillary C files for Attansic L1 driver

2007-01-21 Thread Randy Dunlap
On Sun, 21 Jan 2007 15:07:37 -0600 Jay Cliburn wrote:

> This patch contains auxiliary C files for the Attansic L1 gigabit ethernet
> adapter driver.
> 
> Signed-off-by: Jay Cliburn <[EMAIL PROTECTED]>
> Signed-off-by: Chris Snook <[EMAIL PROTECTED]>
> ---
> 
>  atl1_ethtool.c |  436 ++
>  atl1_hw.c  |  728 
> +
>  atl1_param.c   |  223 +
>  3 files changed, 1387 insertions(+)
> 
> diff --git a/drivers/net/atl1/atl1_ethtool.c b/drivers/net/atl1/atl1_ethtool.c
> new file mode 100644
> index 000..4c6e505
> --- /dev/null
> +++ b/drivers/net/atl1/atl1_ethtool.c
> @@ -0,0 +1,436 @@
> +/**

Please use "/**" _only_ to begin kernel-doc comments
(and this is not a kernel-doc comment).
(occurs at multiple other places in this and the other patches)

> + * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
> + * Copyright(c) 2006 Chris Snook <[EMAIL PROTECTED]>
> + * Copyright(c) 2006 Jay Cliburn <[EMAIL PROTECTED]>
> + * 
> + * Derived from Intel e1000 driver
> + * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
> + * 
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the Free
> + * Software Foundation; either version 2 of the License, or (at your option)
> + * any later version.
> + * 
> + * This program is distributed in the hope that it will be useful, but 
> WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + * 
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program; if not, write to the Free Software Foundation, Inc., 59
> + * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
> + **/
> +
> +
> +static int atl1_get_settings(struct net_device *netdev, struct ethtool_cmd 
> *ecmd)
> +{
> + struct atl1_adapter *adapter = netdev_priv(netdev);
> + struct atl1_hw *hw = &adapter->hw;
> +
> + ecmd->supported = (SUPPORTED_10baseT_Half |
> +SUPPORTED_10baseT_Full |
> +SUPPORTED_100baseT_Half |
> +SUPPORTED_100baseT_Full |
> +SUPPORTED_1000baseT_Full |
> +SUPPORTED_Autoneg | SUPPORTED_TP);
> + ecmd->advertising = ADVERTISED_TP;
> + if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
> + hw->media_type == MEDIA_TYPE_1000M_FULL) {
> + ecmd->advertising |= ADVERTISED_Autoneg;
> + if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR) {
> + ecmd->advertising |= ADVERTISED_Autoneg;
> + ecmd->advertising |=
> + (ADVERTISED_10baseT_Half |
> +  ADVERTISED_10baseT_Full |
> +  ADVERTISED_100baseT_Half |
> +  ADVERTISED_100baseT_Full |
> +  ADVERTISED_1000baseT_Full);
> + } else {
> + ecmd->advertising |= (ADVERTISED_1000baseT_Full);

Kernel coding style is not to use braces around one-statement "blocks."
(occurs in multiple other places)

> + }
> + }
> + ecmd->port = PORT_TP;
> + ecmd->phy_address = 0;
> + ecmd->transceiver = XCVR_INTERNAL;
> +
> + if (netif_carrier_ok(adapter->netdev)) {
> + u16 link_speed, link_duplex;
> + atl1_get_speed_and_duplex(hw, &link_speed, &link_duplex);
> + ecmd->speed = link_speed;
> + if (link_duplex == FULL_DUPLEX)
> + ecmd->duplex = DUPLEX_FULL;
> + else
> + ecmd->duplex = DUPLEX_HALF;
> + } else {
> + ecmd->speed = -1;
> + ecmd->duplex = -1;
> + }
> + if (hw->media_type == MEDIA_TYPE_AUTO_SENSOR ||
> + hw->media_type == MEDIA_TYPE_1000M_FULL) {
> + ecmd->autoneg = AUTONEG_ENABLE;
> + } else {
> + ecmd->autoneg = AUTONEG_DISABLE;
> + }
> + 
> + return 0;
> +}
> +
> +static int atl1_set_settings(struct net_device *netdev, struct ethtool_cmd 
> *ecmd)
> +{
> + struct atl1_adapter *adapter = netdev_priv(netdev);
> + struct atl1_hw *hw = &adapter->hw;
> + u16 phy_data;
> + int ret_val = 0;
> + u16 old_media_type = hw->media_type;
> +
> + if (netif_running(adapter->netdev)) {
> + printk(KERN_DEBUG "%s: ethtool shutting down link adapter\n", 

What's a "link adapter"?

> + atl1_driver_name);
> + atl1_down(adapter);
> + }
> +
> + if (ecmd->autoneg == AUTONEG_ENABLE) {
> + hw->media_type = MEDIA_TYPE_AUTO_SENSOR;
> + } else {
> + if (ecmd->speed == SPEED_1000) {
> + if (ecmd->duplex != DUPLEX_FULL) {
>

[PATCH 5/12] forcedeth: optimized routines

2007-01-21 Thread Ayaz Abdulla

This patch breaks up the routines into two versions, one for legacy
descriptor versions (ver 1 and ver 2) and one for desc ver 3. This will
make the new desc functions more leaner and further reductions will be
made in next few patches.

Signed-Off-By: Ayaz Abdulla <[EMAIL PROTECTED]>

--- orig/drivers/net/forcedeth.c2007-01-19 10:54:32.0 -0500
+++ new/drivers/net/forcedeth.c 2007-01-19 10:54:14.0 -0500
@@ -1307,50 +1307,57 @@
 static int nv_alloc_rx(struct net_device *dev)
 {
struct fe_priv *np = netdev_priv(dev);
-   union ring_type less_rx;
+   struct ring_desc* less_rx;
 
-   if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
-   less_rx.orig = np->get_rx.orig;
-   if (less_rx.orig-- == np->first_rx.orig)
-   less_rx.orig = np->last_rx.orig;
-   } else {
-   less_rx.ex = np->get_rx.ex;
-   if (less_rx.ex-- == np->first_rx.ex)
-   less_rx.ex = np->last_rx.ex;
-   }
+   less_rx = np->get_rx.orig;
+   if (less_rx-- == np->first_rx.orig)
+   less_rx = np->last_rx.orig;
 
-   while (1) {
-   struct sk_buff *skb;
-
-   if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
-   if (np->put_rx.orig == less_rx.orig)
-   break;
+   while (np->put_rx.orig != less_rx) {
+   struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + 
NV_RX_ALLOC_PAD);
+   if (skb) {
+   skb->dev = dev;
+   np->put_rx_ctx->skb = skb;
+   np->put_rx_ctx->dma = pci_map_single(np->pci_dev, 
skb->data,
+
skb->end-skb->data, PCI_DMA_FROMDEVICE);
+   np->put_rx_ctx->dma_len = skb->end-skb->data;
+   np->put_rx.orig->buf = cpu_to_le32(np->put_rx_ctx->dma);
+   wmb();
+   np->put_rx.orig->flaglen = cpu_to_le32(np->rx_buf_sz | 
NV_RX_AVAIL);
+   if (np->put_rx.orig++ == np->last_rx.orig)
+   np->put_rx.orig = np->first_rx.orig;
+   if (np->put_rx_ctx++ == np->last_rx_ctx)
+   np->put_rx_ctx = np->first_rx_ctx;
} else {
-   if (np->put_rx.ex == less_rx.ex)
-   break;
+   return 1;
}
+   }
+   return 0;
+}
+
+static int nv_alloc_rx_optimized(struct net_device *dev)
+{
+   struct fe_priv *np = netdev_priv(dev);
+   struct ring_desc_ex* less_rx;
+
+   less_rx = np->get_rx.ex;
+   if (less_rx-- == np->first_rx.ex)
+   less_rx = np->last_rx.ex;
 
-   skb = dev_alloc_skb(np->rx_buf_sz + NV_RX_ALLOC_PAD);
+   while (np->put_rx.ex != less_rx) {
+   struct sk_buff *skb = dev_alloc_skb(np->rx_buf_sz + 
NV_RX_ALLOC_PAD);
if (skb) {
skb->dev = dev;
np->put_rx_ctx->skb = skb;
np->put_rx_ctx->dma = pci_map_single(np->pci_dev, 
skb->data,
 
skb->end-skb->data, PCI_DMA_FROMDEVICE);
np->put_rx_ctx->dma_len = skb->end-skb->data;
-   if (np->desc_ver == DESC_VER_1 || np->desc_ver == 
DESC_VER_2) {
-   np->put_rx.orig->buf = 
cpu_to_le32(np->put_rx_ctx->dma);
-   wmb();
-   np->put_rx.orig->flaglen = 
cpu_to_le32(np->rx_buf_sz | NV_RX_AVAIL);
-   if (np->put_rx.orig++ == np->last_rx.orig)
-   np->put_rx.orig = np->first_rx.orig;
-   } else {
-   np->put_rx.ex->bufhigh = 
cpu_to_le64(np->put_rx_ctx->dma) >> 32;
-   np->put_rx.ex->buflow = 
cpu_to_le64(np->put_rx_ctx->dma) & 0x0;
-   wmb();
-   np->put_rx.ex->flaglen = 
cpu_to_le32(np->rx_buf_sz | NV_RX2_AVAIL);
-   if (np->put_rx.ex++ == np->last_rx.ex)
-   np->put_rx.ex = np->first_rx.ex;
-   }
+   np->put_rx.ex->bufhigh = 
cpu_to_le64(np->put_rx_ctx->dma) >> 32;
+   np->put_rx.ex->buflow = 
cpu_to_le64(np->put_rx_ctx->dma) & 0x0;
+   wmb();
+   np->put_rx.ex->flaglen = cpu_to_le32(np->rx_buf_sz | 
NV_RX2_AVAIL);
+   if (np->put_rx.ex++ == np->last_rx.ex)
+   np->put_rx.ex = np->first_rx.ex;
if (np->put_rx_ctx++ == np->last_rx_ctx)
np->put_rx_ct

[PATCH 12/12] forcedeth: statistics optimization

2007-01-21 Thread Ayaz Abdulla

This patch optimizes the data paths that can support hw counters. It
removes the sw counted statistics.

This is the last patch for the optimization set. Bumping up version of 
driver.


Signed-Off-By: Ayaz Abdulla <[EMAIL PROTECTED]>

--- orig/drivers/net/forcedeth.c2007-01-21 17:38:50.0 -0500
+++ new/drivers/net/forcedeth.c 2007-01-21 17:41:49.0 -0500
@@ -111,6 +111,7 @@
  * 0.57: 14 May 2006: Mac address set in probe/remove and order 
corrections.
  * 0.58: 30 Oct 2006: Added support for sideband management unit.
  * 0.59: 30 Oct 2006: Added support for recoverable error.
+ * 0.60: 20 Jan 2007: Code optimizations for rings, rx & tx data paths, 
and stats.
  *
  * Known bugs:
  * We suspect that on some hardware no TX done interrupts are generated.
@@ -127,7 +128,7 @@
 #else
 #define DRIVERNAPI
 #endif
-#define FORCEDETH_VERSION  "0.59"
+#define FORCEDETH_VERSION  "0.60"
 #define DRV_NAME   "forcedeth"
 
 #include 
@@ -1351,10 +1352,19 @@
 {
struct fe_priv *np = netdev_priv(dev);
 
-   /* It seems that the nic always generates interrupts and doesn't
-* accumulate errors internally. Thus the current values in np->stats
-* are already up to date.
-*/
+   /* If the nic supports hw counters then retrieve latest values */
+   if (np->driver_data & (DEV_HAS_STATISTICS_V1|DEV_HAS_STATISTICS_V2)) {
+   nv_get_hw_stats(dev);
+
+   /* copy to net_device stats */
+   np->stats.tx_bytes = np->estats.tx_bytes;
+   np->stats.tx_fifo_errors = np->estats.tx_fifo_errors;
+   np->stats.tx_carrier_errors = np->estats.tx_carrier_errors;
+   np->stats.rx_crc_errors = np->estats.rx_crc_errors;
+   np->stats.rx_over_errors = np->estats.rx_over_errors;
+   np->stats.rx_errors = np->estats.rx_errors_total;
+   np->stats.tx_errors = np->estats.tx_errors_total;
+   }
return &np->stats;
 }
 
@@ -1944,16 +1954,8 @@
np->get_tx_ctx->dma = 0;
 
if (flags & NV_TX2_LASTPACKET) {
-   if (flags & NV_TX2_ERROR) {
-   if (flags & NV_TX2_UNDERFLOW)
-   np->stats.tx_fifo_errors++;
-   if (flags & NV_TX2_CARRIERLOST)
-   np->stats.tx_carrier_errors++;
-   np->stats.tx_errors++;
-   } else {
+   if (!(flags & NV_TX2_ERROR))
np->stats.tx_packets++;
-   np->stats.tx_bytes += np->get_tx_ctx->skb->len;
-   }
dev_kfree_skb_any(np->get_tx_ctx->skb);
np->get_tx_ctx->skb = NULL;
}
@@ -2290,7 +2292,6 @@
if (flags & NV_RX2_ERROR4) {
len = nv_getlen(dev, skb->data, len);
if (len < 0) {
-   np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt;
}
@@ -2303,11 +2304,6 @@
}
/* the rest are hard errors */
else {
-   if (flags & NV_RX2_CRCERR)
-   np->stats.rx_crc_errors++;
-   if (flags & NV_RX2_OVERFLOW)
-   np->stats.rx_over_errors++;
-   np->stats.rx_errors++;
dev_kfree_skb(skb);
goto next_pkt;
}
@@ -4941,7 +4937,7 @@
np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK;
dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
dev->features |= NETIF_F_TSO;
-   }
+   }
 
np->vlanctl_bits = 0;
if (id->driver_data & DEV_HAS_VLAN) {


[PATCH 11/12] forcedeth: statistics supported

2007-01-21 Thread Ayaz Abdulla

This patch introduces hw statistics for older devices that supported it.
It breaks up the counters supported into separate versions.

Signed-Off-By: Ayaz Abdulla <[EMAIL PROTECTED]>
--- orig/drivers/net/forcedeth.c2007-01-21 17:33:59.0 -0500
+++ new/drivers/net/forcedeth.c 2007-01-21 17:38:23.0 -0500
@@ -173,9 +173,10 @@
 #define DEV_HAS_MSI_X   0x0080  /* device supports MSI-X */
 #define DEV_HAS_POWER_CNTRL 0x0100  /* device supports power savings */
 #define DEV_HAS_PAUSEFRAME_TX   0x0200  /* device supports tx pause frames */
-#define DEV_HAS_STATISTICS  0x0400  /* device supports hw statistics */
-#define DEV_HAS_TEST_EXTENDED   0x0800  /* device supports extended diagnostic 
test */
-#define DEV_HAS_MGMT_UNIT   0x1000  /* device supports management unit */
+#define DEV_HAS_STATISTICS_V1   0x0400  /* device supports hw statistics 
version 1 */
+#define DEV_HAS_STATISTICS_V2   0x0800  /* device supports hw statistics 
version 2 */
+#define DEV_HAS_TEST_EXTENDED   0x1000  /* device supports extended diagnostic 
test */
+#define DEV_HAS_MGMT_UNIT   0x2000  /* device supports management unit */
 
 enum {
NvRegIrqStatus = 0x000,
@@ -487,7 +488,8 @@
 
 /* Miscelaneous hardware related defines: */
 #define NV_PCI_REGSZ_VER1  0x270
-#define NV_PCI_REGSZ_VER2  0x604
+#define NV_PCI_REGSZ_VER2  0x2d4
+#define NV_PCI_REGSZ_VER3  0x604
 
 /* various timeout delays: all in usec */
 #define NV_TXRX_RESET_DELAY4
@@ -605,9 +607,6 @@
{ "tx_carrier_errors" },
{ "tx_excess_deferral" },
{ "tx_retry_error" },
-   { "tx_deferral" },
-   { "tx_packets" },
-   { "tx_pause" },
{ "rx_frame_error" },
{ "rx_extra_byte" },
{ "rx_late_collision" },
@@ -620,11 +619,17 @@
{ "rx_unicast" },
{ "rx_multicast" },
{ "rx_broadcast" },
+   { "rx_packets" },
+   { "rx_errors_total" },
+   { "tx_errors_total" },
+
+   /* version 2 stats */
+   { "tx_deferral" },
+   { "tx_packets" },
{ "rx_bytes" },
+   { "tx_pause" },
{ "rx_pause" },
-   { "rx_drop_frame" },
-   { "rx_packets" },
-   { "rx_errors_total" }
+   { "rx_drop_frame" }
 };
 
 struct nv_ethtool_stats {
@@ -637,9 +642,6 @@
u64 tx_carrier_errors;
u64 tx_excess_deferral;
u64 tx_retry_error;
-   u64 tx_deferral;
-   u64 tx_packets;
-   u64 tx_pause;
u64 rx_frame_error;
u64 rx_extra_byte;
u64 rx_late_collision;
@@ -652,13 +654,22 @@
u64 rx_unicast;
u64 rx_multicast;
u64 rx_broadcast;
+   u64 rx_packets;
+   u64 rx_errors_total;
+   u64 tx_errors_total;
+
+   /* version 2 stats */
+   u64 tx_deferral;
+   u64 tx_packets;
u64 rx_bytes;
+   u64 tx_pause;
u64 rx_pause;
u64 rx_drop_frame;
-   u64 rx_packets;
-   u64 rx_errors_total;
 };
 
+#define NV_DEV_STATISTICS_V2_COUNT (sizeof(struct 
nv_ethtool_stats)/sizeof(u64))
+#define NV_DEV_STATISTICS_V1_COUNT (NV_DEV_STATISTICS_V2_COUNT - 6)
+
 /* diagnostics */
 #define NV_TEST_COUNT_BASE 3
 #define NV_TEST_COUNT_EXTENDED 4
@@ -1275,6 +1286,61 @@
pci_push(base);
 }
 
+static void nv_get_hw_stats(struct net_device *dev)
+{
+   struct fe_priv *np = netdev_priv(dev);
+   u8 __iomem *base = get_hwbase(dev);
+
+   np->estats.tx_bytes += readl(base + NvRegTxCnt);
+   np->estats.tx_zero_rexmt += readl(base + NvRegTxZeroReXmt);
+   np->estats.tx_one_rexmt += readl(base + NvRegTxOneReXmt);
+   np->estats.tx_many_rexmt += readl(base + NvRegTxManyReXmt);
+   np->estats.tx_late_collision += readl(base + NvRegTxLateCol);
+   np->estats.tx_fifo_errors += readl(base + NvRegTxUnderflow);
+   np->estats.tx_carrier_errors += readl(base + NvRegTxLossCarrier);
+   np->estats.tx_excess_deferral += readl(base + NvRegTxExcessDef);
+   np->estats.tx_retry_error += readl(base + NvRegTxRetryErr);
+   np->estats.rx_frame_error += readl(base + NvRegRxFrameErr);
+   np->estats.rx_extra_byte += readl(base + NvRegRxExtraByte);
+   np->estats.rx_late_collision += readl(base + NvRegRxLateCol);
+   np->estats.rx_runt += readl(base + NvRegRxRunt);
+   np->estats.rx_frame_too_long += readl(base + NvRegRxFrameTooLong);
+   np->estats.rx_over_errors += readl(base + NvRegRxOverflow);
+   np->estats.rx_crc_errors += readl(base + NvRegRxFCSErr);
+   np->estats.rx_frame_align_error += readl(base + NvRegRxFrameAlignErr);
+   np->estats.rx_length_error += readl(base + NvRegRxLenErr);
+   np->estats.rx_unicast += readl(base + NvRegRxUnicast);
+   np->estats.rx_multicast += readl(base + NvRegRxMulticast);
+   np->estats.rx_broadcast += readl(base + NvRegRxBroadcast);
+   np->estats.rx_packets =
+   np->estats.rx_unicast +
+   np->estats.rx_multicast +
+   np->est

[PATCH 9/12] forcedeth: irq data path optimization

2007-01-21 Thread Ayaz Abdulla

This patch optimizes the irq data paths and cleans up the code.

Signed-Off-By: Ayaz Abdulla <[EMAIL PROTECTED]>

--- orig/drivers/net/forcedeth.c2007-01-19 11:11:35.0 -0500
+++ new/drivers/net/forcedeth.c 2007-01-19 11:13:25.0 -0500
@@ -2777,7 +2777,6 @@
events = readl(base + NvRegMSIXIrqStatus) & 
NVREG_IRQSTAT_MASK;
writel(NVREG_IRQSTAT_MASK, base + NvRegMSIXIrqStatus);
}
-   pci_push(base);
dprintk(KERN_DEBUG "%s: irq: %08x\n", dev->name, events);
if (!(events & np->irqmask))
break;
@@ -2786,22 +2785,46 @@
nv_tx_done(dev);
spin_unlock(&np->lock);
 
-   if (events & NVREG_IRQ_LINK) {
+#ifdef CONFIG_FORCEDETH_NAPI
+   if (events & NVREG_IRQ_RX_ALL) {
+   netif_rx_schedule(dev);
+
+   /* Disable furthur receive irq's */
+   spin_lock(&np->lock);
+   np->irqmask &= ~NVREG_IRQ_RX_ALL;
+
+   if (np->msi_flags & NV_MSI_X_ENABLED)
+   writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask);
+   else
+   writel(np->irqmask, base + NvRegIrqMask);
+   spin_unlock(&np->lock);
+   }
+#else
+   if (nv_rx_process(dev, dev->weight)) {
+   if (unlikely(nv_alloc_rx(dev))) {
+   spin_lock(&np->lock);
+   if (!np->in_shutdown)
+   mod_timer(&np->oom_kick, jiffies + 
OOM_REFILL);
+   spin_unlock(&np->lock);
+   }
+   }
+#endif
+   if (unlikely(events & NVREG_IRQ_LINK)) {
spin_lock(&np->lock);
nv_link_irq(dev);
spin_unlock(&np->lock);
}
-   if (np->need_linktimer && time_after(jiffies, 
np->link_timeout)) {
+   if (unlikely(np->need_linktimer && time_after(jiffies, 
np->link_timeout))) {
spin_lock(&np->lock);
nv_linkchange(dev);
spin_unlock(&np->lock);
np->link_timeout = jiffies + LINK_TIMEOUT;
}
-   if (events & (NVREG_IRQ_TX_ERR)) {
+   if (unlikely(events & (NVREG_IRQ_TX_ERR))) {
dprintk(KERN_DEBUG "%s: received irq with events 0x%x. 
Probably TX fail.\n",
dev->name, events);
}
-   if (events & (NVREG_IRQ_UNKNOWN)) {
+   if (unlikely(events & (NVREG_IRQ_UNKNOWN))) {
printk(KERN_DEBUG "%s: received irq with unknown events 
0x%x. Please report\n",
dev->name, events);
}
@@ -2822,30 +2845,7 @@
spin_unlock(&np->lock);
break;
}
-#ifdef CONFIG_FORCEDETH_NAPI
-   if (events & NVREG_IRQ_RX_ALL) {
-   netif_rx_schedule(dev);
-
-   /* Disable furthur receive irq's */
-   spin_lock(&np->lock);
-   np->irqmask &= ~NVREG_IRQ_RX_ALL;
-
-   if (np->msi_flags & NV_MSI_X_ENABLED)
-   writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask);
-   else
-   writel(np->irqmask, base + NvRegIrqMask);
-   spin_unlock(&np->lock);
-   }
-#else
-   nv_rx_process(dev, dev->weight);
-   if (nv_alloc_rx(dev)) {
-   spin_lock(&np->lock);
-   if (!np->in_shutdown)
-   mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
-   spin_unlock(&np->lock);
-   }
-#endif
-   if (i > max_interrupt_work) {
+   if (unlikely(i > max_interrupt_work)) {
spin_lock(&np->lock);
/* disable interrupts on the nic */
if (!(np->msi_flags & NV_MSI_X_ENABLED))
@@ -2869,6 +2869,13 @@
return IRQ_RETVAL(i);
 }
 
+#define TX_WORK_PER_LOOP  64
+#define RX_WORK_PER_LOOP  64
+/**
+ * All _optimized functions are used to help increase performance
+ * (reduce CPU and increase throughput). They use descripter version 3,
+ * compiler directives, and reduce memory accesses.
+ */
 static irqreturn_t nv_nic_irq_optimized(int foo, void *data)
 {
struct net_device *dev = (struct net_device *) data;
@@ -2887,7 +2894,6 @@
events = readl(base + NvRegMSIXIrqStatus) & 
NVREG_IRQSTAT_MASK;
writel(NVREG_IRQSTAT_MASK, base + N

[PATCH 0/12] forcedeth: optimization fixup

2007-01-21 Thread Ayaz Abdulla

A few fixes have been made based on Jeff's comments. Resending patchs 5-12.

Ayaz
-
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/12] forcedeth: tx data path optimization

2007-01-21 Thread Ayaz Abdulla

This patch optimizes the tx data paths and cleans up the code (removes
vlan from descr1/2 since only valid for desc3, changes to make code
easier to read, etc).

Signed-Off-By: Ayaz Abdulla <[EMAIL PROTECTED]>


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
--- orig/drivers/net/forcedeth.c2007-01-19 11:03:43.0 -0500
+++ new/drivers/net/forcedeth.c 2007-01-19 11:07:48.0 -0500
@@ -1563,7 +1563,6 @@
u32 size = skb->len-skb->data_len;
u32 entries = (size >> NV_TX2_TSO_MAX_SHIFT) + ((size & 
(NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
u32 empty_slots;
-   u32 tx_flags_vlan = 0;
struct ring_desc* put_tx;
struct ring_desc* start_tx;
struct ring_desc* prev_tx;
@@ -1576,7 +1575,7 @@
}
 
empty_slots = nv_get_empty_tx_slots(np);
-   if (empty_slots <= entries) {
+   if (unlikely(empty_slots <= entries)) {
spin_lock_irq(&np->lock);
netif_stop_queue(dev);
np->tx_stop = 1;
@@ -1596,12 +1595,13 @@
np->put_tx_ctx->dma_len = bcnt;
put_tx->buf = cpu_to_le32(np->put_tx_ctx->dma);
put_tx->flaglen = cpu_to_le32((bcnt-1) | tx_flags);
+
tx_flags = np->tx_flags;
offset += bcnt;
size -= bcnt;
-   if (put_tx++ == np->last_tx.orig)
+   if (unlikely(put_tx++ == np->last_tx.orig))
put_tx = np->first_tx.orig;
-   if (np->put_tx_ctx++ == np->last_tx_ctx)
+   if (unlikely(np->put_tx_ctx++ == np->last_tx_ctx))
np->put_tx_ctx = np->first_tx_ctx;
} while (size);
 
@@ -1618,14 +1618,14 @@
np->put_tx_ctx->dma = pci_map_page(np->pci_dev, 
frag->page, frag->page_offset+offset, bcnt,
   PCI_DMA_TODEVICE);
np->put_tx_ctx->dma_len = bcnt;
-
put_tx->buf = cpu_to_le32(np->put_tx_ctx->dma);
put_tx->flaglen = cpu_to_le32((bcnt-1) | tx_flags);
+
offset += bcnt;
size -= bcnt;
-   if (put_tx++ == np->last_tx.orig)
+   if (unlikely(put_tx++ == np->last_tx.orig))
put_tx = np->first_tx.orig;
-   if (np->put_tx_ctx++ == np->last_tx_ctx)
+   if (unlikely(np->put_tx_ctx++ == np->last_tx_ctx))
np->put_tx_ctx = np->first_tx_ctx;
} while (size);
}
@@ -1642,11 +1642,6 @@
tx_flags_extra = skb->ip_summed == CHECKSUM_PARTIAL ?
 NV_TX2_CHECKSUM_L3 | NV_TX2_CHECKSUM_L4 : 0;
 
-   /* vlan tag */
-   if (np->vlangrp && vlan_tx_tag_present(skb)) {
-   tx_flags_vlan = NV_TX3_VLAN_TAG_PRESENT | vlan_tx_tag_get(skb);
-   }
-
spin_lock_irq(&np->lock);
 
/* set tx flags */
@@ -1669,7 +1664,6 @@
 
dev->trans_start = jiffies;
writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + 
NvRegTxRxControl);
-   pci_push(get_hwbase(dev));
return NETDEV_TX_OK;
 }
 
@@ -1677,7 +1671,7 @@
 {
struct fe_priv *np = netdev_priv(dev);
u32 tx_flags = 0;
-   u32 tx_flags_extra = NV_TX2_LASTPACKET;
+   u32 tx_flags_extra;
unsigned int fragments = skb_shinfo(skb)->nr_frags;
unsigned int i;
u32 offset = 0;
@@ -1685,7 +1679,6 @@
u32 size = skb->len-skb->data_len;
u32 entries = (size >> NV_TX2_TSO_MAX_SHIFT) + ((size & 
(NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
u32 empty_slots;
-   u32 tx_flags_vlan = 0;
struct ring_desc_ex* put_tx;
struct ring_desc_ex* start_tx;
struct ring_desc_ex* prev_tx;
@@ -1698,7 +1691,7 @@
}
 
empty_slots = nv_get_empty_tx_slots(np);
-   if (empty_slots <= entries) {
+   if (unlikely(empty_slots <= entries)) {
spin_lock_irq(&np->lock);
netif_stop_queue(dev);
np->tx_stop = 1;
@@ -1719,12 +1712,13 @@
put_tx->bufhigh = cpu_to_le64(np->put_tx_ctx->dma) >> 32;
put_tx->buflow = cpu_to_le64(np->put_tx_ctx->dma) & 0x0;
put_tx->flaglen = cpu_to_le32((bcnt-1) | tx_flags);
-   tx_flags = np->tx_flags;
+
+   tx_flags = NV_TX2_VALID;
offset += bcnt;
size -= bcnt;
-   if (

[PATCH 8/12] forcedeth: rx data path optimization

2007-01-21 Thread Ayaz Abdulla

This patch optimizes the rx data paths and cleans up the code.

Signed-Off-By: Ayaz Abdulla <[EMAIL PROTECTED]>
--- orig/drivers/net/forcedeth.c2007-01-19 11:08:24.0 -0500
+++ new/drivers/net/forcedeth.c 2007-01-19 11:11:04.0 -0500
@@ -1317,9 +1317,9 @@
np->put_rx.orig->buf = cpu_to_le32(np->put_rx_ctx->dma);
wmb();
np->put_rx.orig->flaglen = cpu_to_le32(np->rx_buf_sz | 
NV_RX_AVAIL);
-   if (np->put_rx.orig++ == np->last_rx.orig)
+   if (unlikely(np->put_rx.orig++ == np->last_rx.orig))
np->put_rx.orig = np->first_rx.orig;
-   if (np->put_rx_ctx++ == np->last_rx_ctx)
+   if (unlikely(np->put_rx_ctx++ == np->last_rx_ctx))
np->put_rx_ctx = np->first_rx_ctx;
} else {
return 1;
@@ -1349,9 +1349,9 @@
np->put_rx.ex->buflow = 
cpu_to_le64(np->put_rx_ctx->dma) & 0x0;
wmb();
np->put_rx.ex->flaglen = cpu_to_le32(np->rx_buf_sz | 
NV_RX2_AVAIL);
-   if (np->put_rx.ex++ == np->last_rx.ex)
+   if (unlikely(np->put_rx.ex++ == np->last_rx.ex))
np->put_rx.ex = np->first_rx.ex;
-   if (np->put_rx_ctx++ == np->last_rx_ctx)
+   if (unlikely(np->put_rx_ctx++ == np->last_rx_ctx))
np->put_rx_ctx = np->first_rx_ctx;
} else {
return 1;
@@ -2046,24 +2046,17 @@
 {
struct fe_priv *np = netdev_priv(dev);
u32 flags;
-   u32 vlanflags = 0;
-   int count;
-
-   for (count = 0; count < limit; ++count) {
-   struct sk_buff *skb;
-   int len;
-
-   if (np->get_rx.orig == np->put_rx.orig)
-   break;  /* we scanned the whole ring - do not continue 
*/
-   flags = le32_to_cpu(np->get_rx.orig->flaglen);
-   len = nv_descr_getlength(np->get_rx.orig, np->desc_ver);
+   u32 rx_processed_cnt = 0;
+   struct sk_buff *skb;
+   int len;
+
+   while((np->get_rx.orig != np->put_rx.orig) &&
+ !((flags = le32_to_cpu(np->get_rx.orig->flaglen)) & NV_RX_AVAIL) 
&&
+   (rx_processed_cnt++ < limit)) {
 
dprintk(KERN_DEBUG "%s: nv_rx_process: flags 0x%x.\n",
dev->name, flags);
 
-   if (flags & NV_RX_AVAIL)
-   break;  /* still owned by hardware, */
-
/*
 * the packet is for us - immediately tear down the pci mapping.
 * TODO: check if a prefetch of the first cacheline improves
@@ -2087,99 +2080,80 @@
}
/* look at what we actually got: */
if (np->desc_ver == DESC_VER_1) {
-   if (!(flags & NV_RX_DESCRIPTORVALID)) {
-   dev_kfree_skb(skb);
-   goto next_pkt;
-   }
-
-   if (flags & NV_RX_ERROR) {
-   if (flags & NV_RX_MISSEDFRAME) {
-   np->stats.rx_missed_errors++;
-   np->stats.rx_errors++;
-   dev_kfree_skb(skb);
-   goto next_pkt;
-   }
-   if (flags & 
(NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3)) {
-   np->stats.rx_errors++;
-   dev_kfree_skb(skb);
-   goto next_pkt;
-   }
-   if (flags & NV_RX_CRCERR) {
-   np->stats.rx_crc_errors++;
-   np->stats.rx_errors++;
-   dev_kfree_skb(skb);
-   goto next_pkt;
-   }
-   if (flags & NV_RX_OVERFLOW) {
-   np->stats.rx_over_errors++;
-   np->stats.rx_errors++;
-   dev_kfree_skb(skb);
-   goto next_pkt;
-   }
-   if (flags & NV_RX_ERROR4) {
-   len = nv_getlen(dev, skb->data, len);
-   if (len < 0) {
+   if (likely(flags & NV_RX_DESCRIPTORVALID)) {
+   len = flags & LEN_MASK_V1;
+   if (unlikely(flags & NV_RX_ERROR)) {
+ 

[PATCH 6/12] forcedeth: tx limiting

2007-01-21 Thread Ayaz Abdulla

This patch optimizes the logic for tx limiting. It adds a flag to check
on the completion side instead of recalculating the number of empty
slots. Also, it removes the fields that were previous used for limiting
since they have no value.

Signed-Off-By: Ayaz Abdulla <[EMAIL PROTECTED]>

--- orig/drivers/net/forcedeth.c2007-01-19 11:01:30.0 -0500
+++ new/drivers/net/forcedeth.c 2007-01-19 11:03:13.0 -0500
@@ -518,12 +518,6 @@
 #define TX_RING_MIN64
 #define RING_MAX_DESC_VER_11024
 #define RING_MAX_DESC_VER_2_3  16384
-/*
- * Difference between the get and put pointers for the tx ring.
- * This is used to throttle the amount of data outstanding in the
- * tx ring.
- */
-#define TX_LIMIT_DIFFERENCE1
 
 /* rx/tx mac addr + type + vlan + align + slack*/
 #define NV_RX_HEADERS  (64)
@@ -777,8 +771,7 @@
union ring_type tx_ring;
u32 tx_flags;
int tx_ring_size;
-   int tx_limit_start;
-   int tx_limit_stop;
+   int tx_stop;
 
/* vlan fields */
struct vlan_group *vlangrp;
@@ -1583,9 +1576,10 @@
}
 
empty_slots = nv_get_empty_tx_slots(np);
-   if ((empty_slots - np->tx_limit_stop) <= entries) {
+   if (empty_slots <= entries) {
spin_lock_irq(&np->lock);
netif_stop_queue(dev);
+   np->tx_stop = 1;
spin_unlock_irq(&np->lock);
return NETDEV_TX_BUSY;
}
@@ -1704,9 +1698,10 @@
}
 
empty_slots = nv_get_empty_tx_slots(np);
-   if ((empty_slots - np->tx_limit_stop) <= entries) {
+   if (empty_slots <= entries) {
spin_lock_irq(&np->lock);
netif_stop_queue(dev);
+   np->tx_stop = 1;
spin_unlock_irq(&np->lock);
return NETDEV_TX_BUSY;
}
@@ -1813,6 +1808,7 @@
struct fe_priv *np = netdev_priv(dev);
u32 flags;
struct sk_buff *skb;
+   struct ring_desc* orig_get_tx = np->get_tx.orig;
 
while (np->get_tx.orig != np->put_tx.orig) {
flags = le32_to_cpu(np->get_tx.orig->flaglen);
@@ -1858,8 +1854,10 @@
if (np->get_tx_ctx++ == np->last_tx_ctx)
np->get_tx_ctx = np->first_tx_ctx;
}
-   if (nv_get_empty_tx_slots(np) > np->tx_limit_start)
+   if ((np->tx_stop == 1) && (np->get_tx.orig != orig_get_tx)) {
+   np->tx_stop = 0;
netif_wake_queue(dev);
+   }
 }
 
 static void nv_tx_done_optimized(struct net_device *dev)
@@ -1867,6 +1865,7 @@
struct fe_priv *np = netdev_priv(dev);
u32 flags;
struct sk_buff *skb;
+   struct ring_desc_ex* orig_get_tx = np->get_tx.ex;
 
while (np->get_tx.ex == np->put_tx.ex) {
flags = le32_to_cpu(np->get_tx.ex->flaglen);
@@ -1895,8 +1894,10 @@
if (np->get_tx_ctx++ == np->last_tx_ctx)
np->get_tx_ctx = np->first_tx_ctx;
}
-   if (nv_get_empty_tx_slots(np) > np->tx_limit_start)
+   if ((np->tx_stop == 1) && (np->get_tx.ex != orig_get_tx)) {
+   np->tx_stop = 0;
netif_wake_queue(dev);
+   }
 }
 
 /*
@@ -4001,8 +4002,6 @@
/* set new values */
np->rx_ring_size = ring->rx_pending;
np->tx_ring_size = ring->tx_pending;
-   np->tx_limit_stop = TX_LIMIT_DIFFERENCE;
-   np->tx_limit_start = TX_LIMIT_DIFFERENCE;
if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
np->rx_ring.orig = (struct ring_desc*)rxtx_ring;
np->tx_ring.orig = &np->rx_ring.orig[np->rx_ring_size];
@@ -4967,8 +4966,6 @@
 
np->rx_ring_size = RX_RING_DEFAULT;
np->tx_ring_size = TX_RING_DEFAULT;
-   np->tx_limit_stop = TX_LIMIT_DIFFERENCE;
-   np->tx_limit_start = TX_LIMIT_DIFFERENCE;
 
if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
np->rx_ring.orig = pci_alloc_consistent(pci_dev,


Re: [BUG] e100: eth0 appers many times in /proc/interrupts after resume

2007-01-21 Thread Frederik Deweerdt
On Sun, Jan 21, 2007 at 01:45:27PM -0800, Auke Kok wrote:
> Frederik Deweerdt wrote:
> >On Sun, Jan 21, 2007 at 09:17:41PM +0200, Andrei Popa wrote:
> >>It's the 10th resume and in /proc/interrupts eth0 appers 10 times.
> >The e100_resume() function should be calling netif_device_detach and
> >free_irq. Could you try the following (compile tested) patch?
> 
> I just fixed suspend/shutdown for e100 in 2.6.19, not sure why the problem 
> still shows up. Since it's a driver/net issue, you 
> should CC netdev on it tho, otherwise it might go unnoticed.
Thanks for adding the CC
> 
> I'll open up the can-o-worms on this issue and see what's up with it.
> 
> I'm not so sure that this patch is OK, and I wonder why it stopped working, 
> because I spent quite some time fixing it only a 
> few months ago. Did swsup change again? sigh...

I may well be wrong (It appears that most of the time I am :)), but the
unbalanced netif_device_attach (in resume) looks suspicious.  resume()
also calls request_irq, so calling free_irq on suspend seemed logical.

Regards,
Frederik

> 
> Auke
> 
> >Signed-off-by: Frederik Deweerdt <[EMAIL PROTECTED]>
> >diff --git a/drivers/net/e100.c b/drivers/net/e100.c
> >index 2fe0445..0c376e4 100644
> >--- a/drivers/net/e100.c
> >+++ b/drivers/net/e100.c
> >@@ -2671,6 +2671,7 @@ static int e100_suspend(struct pci_dev *pdev, 
> >pm_message_t state)
> > del_timer_sync(&nic->watchdog);
> > netif_carrier_off(nic->netdev);
> > +   netif_device_detach(netdev);
> > pci_save_state(pdev);
> > if ((nic->flags & wol_magic) | e100_asf(nic)) {
> >@@ -2682,6 +2683,7 @@ static int e100_suspend(struct pci_dev *pdev, 
> >pm_message_t state)
> > }
> > pci_disable_device(pdev);
> >+free_irq(pdev->irq, netdev);
> > pci_set_power_state(pdev, PCI_D3hot);
> > return 0;
> >-
> >To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> >the body of a message to [EMAIL PROTECTED]
> >More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >Please read the FAQ at  http://www.tux.org/lkml/
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
-
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: [BUG] e100: eth0 appers many times in /proc/interrupts after resume

2007-01-21 Thread Auke Kok

Frederik Deweerdt wrote:

On Sun, Jan 21, 2007 at 09:17:41PM +0200, Andrei Popa wrote:

It's the 10th resume and in /proc/interrupts eth0 appers 10 times.


The e100_resume() function should be calling netif_device_detach and
free_irq. Could you try the following (compile tested) patch?


I just fixed suspend/shutdown for e100 in 2.6.19, not sure why the problem still 
shows up. Since it's a driver/net issue, you should CC netdev on it tho, 
otherwise it might go unnoticed.


I'll open up the can-o-worms on this issue and see what's up with it.

I'm not so sure that this patch is OK, and I wonder why it stopped working, 
because I spent quite some time fixing it only a few months ago. Did swsup 
change again? sigh...


Auke



Signed-off-by: Frederik Deweerdt <[EMAIL PROTECTED]>

diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 2fe0445..0c376e4 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2671,6 +2671,7 @@ static int e100_suspend(struct pci_dev *pdev, 
pm_message_t state)
del_timer_sync(&nic->watchdog);
netif_carrier_off(nic->netdev);
 
+	netif_device_detach(netdev);

pci_save_state(pdev);
 
 	if ((nic->flags & wol_magic) | e100_asf(nic)) {

@@ -2682,6 +2683,7 @@ static int e100_suspend(struct pci_dev *pdev, 
pm_message_t state)
}
 
 	pci_disable_device(pdev);

+   free_irq(pdev->irq, netdev);
pci_set_power_state(pdev, PCI_D3hot);
 
 	return 0;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

-
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: [2.6 patch] drivers/net/irda/vlsi_ir.{h,c}: remove kernel 2.4 code

2007-01-21 Thread Samuel Ortiz
On Thu, Jan 18, 2007 at 10:56:13PM +0100, Adrian Bunk wrote:
> This patch removes kernel 2.4 compatibility code.
Looks correct to me, thanks.


> Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
Acked-by: Samuel Ortiz <[EMAIL PROTECTED]>

 
> ---
> 
>  drivers/net/irda/vlsi_ir.c |   16 
>  drivers/net/irda/vlsi_ir.h |   33 -
>  2 files changed, 8 insertions(+), 41 deletions(-)
> 
> --- linux-2.6.20-rc4-mm1/drivers/net/irda/vlsi_ir.h.old   2007-01-18 
> 21:50:43.0 +0100
> +++ linux-2.6.20-rc4-mm1/drivers/net/irda/vlsi_ir.h   2007-01-18 
> 21:53:54.0 +0100
> @@ -41,39 +41,6 @@
>  #define PCI_CLASS_SUBCLASS_MASK  0x
>  #endif
>  
> -/* in recent 2.5 interrupt handlers have non-void return value */
> -#ifndef IRQ_RETVAL
> -typedef void irqreturn_t;
> -#define IRQ_NONE
> -#define IRQ_HANDLED
> -#define IRQ_RETVAL(x)
> -#endif
> -
> -/* some stuff need to check kernelversion. Not all 2.5 stuff was present
> - * in early 2.5.x - the test is merely to separate 2.4 from 2.5
> - */
> -#include 
> -
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
> -
> -/* PDE() introduced in 2.5.4 */
> -#ifdef CONFIG_PROC_FS
> -#define PDE(inode) ((inode)->i_private)
> -#endif
> -
> -/* irda crc16 calculation exported in 2.5.42 */
> -#define irda_calc_crc16(fcs,buf,len) (GOOD_FCS)
> -
> -/* we use this for unified pci device name access */
> -#define PCIDEV_NAME(pdev)((pdev)->name)
> -
> -#else /* 2.5 or later */
> -
> -/* whatever we get from the associated struct device - bus:slot:dev.fn id */
> -#define PCIDEV_NAME(pdev)(pci_name(pdev))
> -
> -#endif
> -
>  /*  */
>  
>  /* non-standard PCI registers */
> --- linux-2.6.20-rc4-mm1/drivers/net/irda/vlsi_ir.c.old   2007-01-18 
> 21:53:58.0 +0100
> +++ linux-2.6.20-rc4-mm1/drivers/net/irda/vlsi_ir.c   2007-01-18 
> 21:54:56.0 +0100
> @@ -166,7 +166,7 @@
>   unsigned i;
>  
>   seq_printf(seq, "\n%s (vid/did: %04x/%04x)\n",
> -PCIDEV_NAME(pdev), (int)pdev->vendor, (int)pdev->device);
> +pci_name(pdev), (int)pdev->vendor, (int)pdev->device);
>   seq_printf(seq, "pci-power-state: %u\n", (unsigned) 
> pdev->current_state);
>   seq_printf(seq, "resources: irq=%u / io=0x%04x / dma_mask=0x%016Lx\n",
>  pdev->irq, (unsigned)pci_resource_start(pdev, 0), (unsigned 
> long long)pdev->dma_mask);
> @@ -1401,7 +1401,7 @@
>  
>   if (vlsi_start_hw(idev))
>   IRDA_ERROR("%s: failed to restart hw - %s(%s) unusable!\n",
> -__FUNCTION__, PCIDEV_NAME(idev->pdev), ndev->name);
> +__FUNCTION__, pci_name(idev->pdev), ndev->name);
>   else
>   netif_start_queue(ndev);
>  }
> @@ -1643,7 +1643,7 @@
>   pdev->current_state = 0; /* hw must be running now */
>  
>   IRDA_MESSAGE("%s: IrDA PCI controller %s detected\n",
> -  drivername, PCIDEV_NAME(pdev));
> +  drivername, pci_name(pdev));
>  
>   if ( !pci_resource_start(pdev,0)
>|| !(pci_resource_flags(pdev,0) & IORESOURCE_IO) ) {
> @@ -1728,7 +1728,7 @@
>  
>   pci_set_drvdata(pdev, NULL);
>  
> - IRDA_MESSAGE("%s: %s removed\n", drivername, PCIDEV_NAME(pdev));
> + IRDA_MESSAGE("%s: %s removed\n", drivername, pci_name(pdev));
>  }
>  
>  #ifdef CONFIG_PM
> @@ -1748,7 +1748,7 @@
>  
>   if (!ndev) {
>   IRDA_ERROR("%s - %s: no netdevice \n",
> -__FUNCTION__, PCIDEV_NAME(pdev));
> +__FUNCTION__, pci_name(pdev));
>   return 0;
>   }
>   idev = ndev->priv;  
> @@ -1759,7 +1759,7 @@
>   pdev->current_state = state.event;
>   }
>   else
> - IRDA_ERROR("%s - %s: invalid suspend request %u -> 
> %u\n", __FUNCTION__, PCIDEV_NAME(pdev), pdev->current_state, state.event);
> + IRDA_ERROR("%s - %s: invalid suspend request %u -> 
> %u\n", __FUNCTION__, pci_name(pdev), pdev->current_state, state.event);
>   up(&idev->sem);
>   return 0;
>   }
> @@ -1787,7 +1787,7 @@
>  
>   if (!ndev) {
>   IRDA_ERROR("%s - %s: no netdevice \n",
> -__FUNCTION__, PCIDEV_NAME(pdev));
> +__FUNCTION__, pci_name(pdev));
>   return 0;
>   }
>   idev = ndev->priv;  
> @@ -1795,7 +1795,7 @@
>   if (pdev->current_state == 0) {
>   up(&idev->sem);
>   IRDA_WARNING("%s - %s: already resumed\n",
> -  __FUNCTION__, PCIDEV_NAME(pdev));
> +  __FUNCTION__, pci_name(pdev));
>   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:/

[PATCH 4/4] atl1: Ancillary C files for Attansic L1 driver

2007-01-21 Thread Jay Cliburn

From: Jay Cliburn <[EMAIL PROTECTED]>
From: Chris Snook <[EMAIL PROTECTED]>

This patch contains auxiliary C files for the Attansic L1 gigabit ethernet
adapter driver.

Signed-off-by: Jay Cliburn <[EMAIL PROTECTED]>
Signed-off-by: Chris Snook <[EMAIL PROTECTED]>
---

 atl1_ethtool.c |  436 ++
 atl1_hw.c  |  728 +
 atl1_param.c   |  223 +
 3 files changed, 1387 insertions(+)

diff --git a/drivers/net/atl1/atl1_ethtool.c b/drivers/net/atl1/atl1_ethtool.c
new file mode 100644
index 000..4c6e505
--- /dev/null
+++ b/drivers/net/atl1/atl1_ethtool.c
@@ -0,0 +1,436 @@
+/**
+ * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
+ * Copyright(c) 2006 Chris Snook <[EMAIL PROTECTED]>
+ * Copyright(c) 2006 Jay Cliburn <[EMAIL PROTECTED]>
+ * 
+ * Derived from Intel e1000 driver
+ * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ **/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "atl1.h"
+
+
+extern char atl1_driver_name[];
+extern char atl1_driver_version[];
+
+struct atl1_stats {
+   char stat_string[ETH_GSTRING_LEN];
+   int sizeof_stat;
+   int stat_offset;
+};
+
+#define ATL1_STAT(m) sizeof(((struct atl1_adapter *)0)->m), \
+   offsetof(struct atl1_adapter, m)
+
+static struct atl1_stats atl1_gstrings_stats[] = {
+   {"rx_packets", ATL1_STAT(soft_stats.rx_packets)},
+   {"tx_packets", ATL1_STAT(soft_stats.tx_packets)},
+   {"rx_bytes", ATL1_STAT(soft_stats.rx_bytes)},
+   {"tx_bytes", ATL1_STAT(soft_stats.tx_bytes)},
+   {"rx_errors", ATL1_STAT(soft_stats.rx_errors)},
+   {"tx_errors", ATL1_STAT(soft_stats.tx_errors)},
+   {"rx_dropped", ATL1_STAT(net_stats.rx_dropped)},
+   {"tx_dropped", ATL1_STAT(net_stats.tx_dropped)},
+   {"multicast", ATL1_STAT(soft_stats.multicast)},
+   {"collisions", ATL1_STAT(soft_stats.collisions)},
+   {"rx_length_errors", ATL1_STAT(soft_stats.rx_length_errors)},
+   {"rx_over_errors", ATL1_STAT(soft_stats.rx_missed_errors)},
+   {"rx_crc_errors", ATL1_STAT(soft_stats.rx_crc_errors)},
+   {"rx_frame_errors", ATL1_STAT(soft_stats.rx_frame_errors)},
+   {"rx_fifo_errors", ATL1_STAT(soft_stats.rx_fifo_errors)},
+   {"rx_missed_errors", ATL1_STAT(soft_stats.rx_missed_errors)},
+   {"tx_aborted_errors", ATL1_STAT(soft_stats.tx_aborted_errors)},
+   {"tx_carrier_errors", ATL1_STAT(soft_stats.tx_carrier_errors)},
+   {"tx_fifo_errors", ATL1_STAT(soft_stats.tx_fifo_errors)},
+   {"tx_window_errors", ATL1_STAT(soft_stats.tx_window_errors)},
+   {"tx_abort_exce_coll", ATL1_STAT(soft_stats.excecol)},
+   {"tx_abort_late_coll", ATL1_STAT(soft_stats.latecol)},
+   {"tx_deferred_ok", ATL1_STAT(soft_stats.deffer)},
+   {"tx_single_coll_ok", ATL1_STAT(soft_stats.scc)},
+   {"tx_multi_coll_ok", ATL1_STAT(soft_stats.mcc)},
+   {"tx_underun", ATL1_STAT(soft_stats.tx_underun)},
+   {"tx_trunc", ATL1_STAT(soft_stats.tx_trunc)},
+   {"tx_pause", ATL1_STAT(soft_stats.tx_pause)},
+   {"rx_pause", ATL1_STAT(soft_stats.rx_pause)},
+   {"rx_rrd_ov", ATL1_STAT(soft_stats.rx_rrd_ov)},
+   {"rx_trunc", ATL1_STAT(soft_stats.rx_trunc)}
+};
+
+static void atl1_get_ethtool_stats(struct net_device *netdev,
+   struct ethtool_stats *stats, u64 *data)
+{
+   struct atl1_adapter *adapter = netdev_priv(netdev);
+   int i;
+   char *p;
+
+   for (i = 0; i < ARRAY_SIZE(atl1_gstrings_stats); i++) {
+   p = (char *)adapter+atl1_gstrings_stats[i].stat_offset;
+   data[i] = (atl1_gstrings_stats[i].sizeof_stat ==
+   sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
+   }
+
+}
+
+static int atl1_get_stats_count(struct net_device *netdev)
+{
+   return ARRAY_SIZE(atl1_gstrings_stats);
+}
+
+static int atl1_get_settings(struct net_device *netdev, struct ethtool_cmd 
*ecmd)
+{
+   struct atl1_adapter *adapter = netdev_priv(netdev);
+   struct atl1_hw *hw = &adapter->hw;
+
+   ecmd->supported = (SUPPORTED_10baseT_Half |
+  SUPPORTED_10baseT_Full |
+  SUPPOR

[PATCH 2/4] atl1: Header files for Attansic L1 driver

2007-01-21 Thread Jay Cliburn

From: Jay Cliburn <[EMAIL PROTECTED]>
From: Chris Snook <[EMAIL PROTECTED]>

This patch contains the header files needed by the Attansic L1 gigabit
ethernet adapter driver.

Signed-off-by: Jay Cliburn <[EMAIL PROTECTED]>
Signed-off-by: Chris Snook <[EMAIL PROTECTED]>
---

 atl1.h|  288 ++
 atl1_hw.h |  965 ++
 2 files changed, 1253 insertions(+)

diff --git a/drivers/net/atl1/atl1.h b/drivers/net/atl1/atl1.h
new file mode 100644
index 000..1d13e8f
--- /dev/null
+++ b/drivers/net/atl1/atl1.h
@@ -0,0 +1,288 @@
+/**
+ * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
+ * Copyright(c) 2006 Chris Snook <[EMAIL PROTECTED]>
+ * Copyright(c) 2006 Jay Cliburn <[EMAIL PROTECTED]>
+ * 
+ * Derived from Intel e1000 driver
+ * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
+ * 
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ **/
+
+#ifndef _ATL1_H_
+#define _ATL1_H_
+
+#include 
+#include 
+#include 
+
+#include "atl1_hw.h"
+
+/* function prototypes needed by multiple files */
+s32 atl1_up(struct atl1_adapter *adapter);
+void atl1_down(struct atl1_adapter *adapter);
+int atl1_reset(struct atl1_adapter *adapter);
+s32 atl1_setup_ring_resources(struct atl1_adapter *adapter);
+void atl1_free_ring_resources(struct atl1_adapter *adapter);
+
+struct atl1_adapter;
+
+#define ATL1_MAX_INTR  3
+
+#define ATL1_DEFAULT_TPD   256
+#define ATL1_MAX_TPD   1023
+#define ATL1_MIN_TPD   64
+#define ATL1_DEFAULT_RFD   512
+#define ATL1_MIN_RFD   128
+#define ATL1_MAX_RFD   2047
+
+#define ATL1_GET_DESC(R, i, type)  (&(((type *)((R)->desc))[i]))
+#define ATL1_RFD_DESC(R, i)ATL1_GET_DESC(R, i, struct rx_free_desc)
+#define ATL1_TPD_DESC(R, i)ATL1_GET_DESC(R, i, struct tx_packet_desc)
+#define ATL1_RRD_DESC(R, i)ATL1_GET_DESC(R, i, struct rx_return_desc)
+
+/**
+ * Some workarounds require millisecond delays and are run during interrupt
+ * context.  Most notably, when establishing link, the phy may need tweaking
+ * but cannot process phy register reads/writes faster than millisecond
+ * intervals...and we establish link due to a "link status change" interrupt.
+ **/
+
+/**
+ * wrapper around a pointer to a socket buffer,
+ * so a DMA handle can be stored along with the buffer
+ **/
+struct atl1_buffer {
+   struct sk_buff *skb;
+   u16 length;
+   u16 alloced;
+   dma_addr_t dma;
+};
+
+#define MAX_TX_BUF_LEN 0x3000  /* 12KB */
+
+struct atl1_tpd_ring {
+   void *desc; /* pointer to the descriptor ring memory */
+   dma_addr_t dma; /* physical adress of the descriptor ring */
+   u16 size;   /* length of descriptor ring in bytes */
+   u16 count;  /* number of descriptors in the ring */
+
+   u16 hw_idx; /* hardware index */
+   atomic_t next_to_clean;
+   atomic_t next_to_use;
+   struct atl1_buffer *buffer_info;
+};
+
+struct atl1_rfd_ring {
+   void *desc;
+   dma_addr_t dma;
+   u16 size;
+   u16 count;
+   atomic_t next_to_use;
+   u16 next_to_clean;
+   struct atl1_buffer *buffer_info;
+};
+
+struct atl1_rrd_ring {
+   void *desc;
+   dma_addr_t dma;
+   unsigned int size;
+   u16 count;
+   u16 next_to_use;
+   atomic_t next_to_clean;
+};
+
+struct atl1_ring_header {
+   /* pointer to the descriptor ring memory */
+   void *desc;
+   /* physical adress of the descriptor ring */
+   dma_addr_t dma;
+   /* length of descriptor ring in bytes */
+   unsigned int size;
+};
+
+struct atl1_cmb {
+   struct coals_msg_block *cmb;
+   dma_addr_t dma;
+};
+
+struct atl1_smb {
+   struct stats_msg_block *smb;
+   dma_addr_t dma;
+};
+
+/* Statistics counters */
+struct atl1_sft_stats {
+   u64 rx_packets;
+   u64 tx_packets;
+   u64 rx_bytes;
+   u64 tx_bytes;
+   u64 multicast;
+   u64 collisions;
+   u64 rx_errors;
+   u64 rx_length_errors;
+   u64 rx_crc_errors;
+   u64 rx_frame_errors;
+   u64 rx_fifo_errors;
+   u64 rx_missed_errors;
+   u64 tx_errors;
+   u64 tx_fifo_errors;
+   u64 tx_aborted_errors;
+   u64 tx_window_

[PATCH 1/4] atl1: Build files for Attansic L1 driver

2007-01-21 Thread Jay Cliburn

From: Jay Cliburn <[EMAIL PROTECTED]>
From: Chris Snook <[EMAIL PROTECTED]>

This patch contains the build files for the Attansic L1 gigabit ethernet
adapter driver.

Signed-off-by: Jay Cliburn <[EMAIL PROTECTED]>
Signed-off-by: Chris Snook <[EMAIL PROTECTED]>
---

 Kconfig   |   11 +++
 Makefile  |1 +
 atl1/Makefile |2 ++
 3 files changed, 14 insertions(+)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 8aa8dd0..0bb3c1e 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2348,6 +2348,17 @@ config QLA3XXX
  To compile this driver as a module, choose M here: the module
  will be called qla3xxx.
 
+config ATL1
+   tristate "Attansic L1 Gigabit Ethernet support (EXPERIMENTAL)"
+   depends on NET_PCI && PCI && EXPERIMENTAL
+   select CRC32
+   select MII
+   help
+ This driver supports the Attansic L1 gigabit ethernet adapter.
+
+ To compile this driver as a module, choose M here.  The module
+ will be called atl1.
+
 endmenu
 
 #
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 4c0d4e5..d0beced 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_IXGB) += ixgb/
 obj-$(CONFIG_CHELSIO_T1) += chelsio/
 obj-$(CONFIG_EHEA) += ehea/
 obj-$(CONFIG_BONDING) += bonding/
+obj-$(CONFIG_ATL1) += atl1/
 obj-$(CONFIG_GIANFAR) += gianfar_driver.o
 
 gianfar_driver-objs := gianfar.o \
diff --git a/drivers/net/atl1/Makefile b/drivers/net/atl1/Makefile
new file mode 100644
index 000..a6b707e
--- /dev/null
+++ b/drivers/net/atl1/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_ATL1) += atl1.o
+atl1-y += atl1_main.o atl1_hw.o atl1_ethtool.o atl1_param.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


[PATCH 0/4] atl1: Attansic L1 ethernet driver

2007-01-21 Thread Jay Cliburn

This is the latest submittal of the patchset providing support for the 
Attansic L1 gigabit ethernet adapter.  This patchset is built against 
kernel version 2.6.20-rc5.

This version incorporates all comments from:

Christoph Hellwig:
http://lkml.org/lkml/2007/1/11/43
http://lkml.org/lkml/2007/1/11/45
http://lkml.org/lkml/2007/1/11/48
http://lkml.org/lkml/2007/1/11/49

Jeff Garzik:
http://lkml.org/lkml/2007/1/18/233

Many thanks to both for reviewing the driver.

The monolithic version of this patchset may be found at:
ftp://hogchain.net/pub/linux/attansic/kernel_driver/atl1-2.0.5-linux-2.6.20.rc5.patch.bz2

As a reminder, this driver is a modified version of the Attansic reference 
driver for the L1 ethernet adapter.  Attansic has granted permission for 
its inclusion in the mainline kernel.

This patchset contains:

drivers/net/Kconfig |   11 +
drivers/net/Makefile|1 +
drivers/net/atl1/Makefile   |2 +
drivers/net/atl1/atl1.h |  288 +
drivers/net/atl1/atl1_ethtool.c |  436 +++
drivers/net/atl1/atl1_hw.c  |  728 
drivers/net/atl1/atl1_hw.h  |  965 +++
drivers/net/atl1/atl1_main.c| 2490 
drivers/net/atl1/atl1_param.c   |  223 
9 files changed, 5144 insertions(+), 0 deletions(-)

-
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


[-mm patch] remove one remaining "#define BCM_TSO 1"

2007-01-21 Thread Adrian Bunk
On Thu, Jan 11, 2007 at 10:26:27PM -0800, Andrew Morton wrote:
>...
> Changes since 2.6.20-rc3-mm1:
>...
>  git-netdev-all.patch
>...
>  git trees
>...

Since it's no longer used, this "#define BCM_TSO 1" can now be removed.

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>

--- linux-2.6.20-rc4-mm1/drivers/net/bnx2.c.old 2007-01-21 18:25:52.0 
+0100
+++ linux-2.6.20-rc4-mm1/drivers/net/bnx2.c 2007-01-21 18:25:58.0 
+0100
@@ -42,7 +42,6 @@
 #include 
 #include 
 #include 
-#define BCM_TSO 1
 #include 
 #include 
 #include 

-
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


[2.6 patch] net/sunrpc/: cleanups

2007-01-21 Thread Adrian Bunk
This patch contains the following cleanups:
- proper prototypes in header files for global variables and functions
- make the following needlessly global struct static:
  - auth_gss/gss_spkm3_seal.c: struct cast5_cbc_oid
- make the following needlessly global variables static:
  - xprtsock.c: xprt_udp_slot_table_entries
  - xprtsock.c: xprt_tcp_slot_table_entries
  - xprtsock.c: xprt_min_resvport
  - xprtsock.c: xprt_max_resvport
- make the following needlessly global functions static:
  - auth_gss/gss_spkm3_seal.c: gss_mech_get()
  - clnt.c: rpc_ping()
  - xdr.c: write_bytes_to_xdr_buf()
- remove the following unused EXPORT_SYMBOL's:
  - auth_gss/gss_mech_switch.c: gss_mech_get_by_name
  - auth_gss/gss_mech_switch.c: gss_mech_get_by_pseudoflavor
  - auth_gss/gss_mech_switch.c: gss_pseudoflavor_to_service
  - auth_gss/gss_mech_switch.c: gss_service_to_auth_domain_name
  - auth_gss/gss_mech_switch.c: gss_mech_put
  - auth_gss/svcauth_gss.c: svcauth_gss_register_pseudoflavor
  - auth_gss/svcauth_gss.c: svcauth_gss_unregister_pseudoflavor
  - auth_gss/gss_spkm3_seal.c: make_spkm3_checksum
  - stats.c: rpc_alloc_iostats
  - stats.c: rpc_free_iostats
  - sunrpc_syms.c: rpc_wake_up_next
  - sunrpc_syms.c: rpc_killall_tasks
  - sunrpc_syms.c: xprt_set_timeout
  - sunrpc_syms.c: svc_drop
  - sunrpc_syms.c: svc_authenticate
- remove the following unused EXPORT_SYMBOL_GPL:
  - clnt.c: rpc_peeraddr2str

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>

---

 include/linux/sunrpc/clnt.h   |1 -
 include/linux/sunrpc/gss_api.h|3 ---
 include/linux/sunrpc/gss_spkm3.h  |1 -
 include/linux/sunrpc/rpc_pipe_fs.h|3 +++
 include/linux/sunrpc/svcauth.h|1 +
 include/linux/sunrpc/xdr.h|1 -
 include/linux/sunrpc/xprt.h   |   12 +++-
 net/sunrpc/auth_gss/gss_mech_switch.c |   14 +-
 net/sunrpc/auth_gss/gss_spkm3_seal.c  |3 +--
 net/sunrpc/auth_gss/svcauth_gss.c |4 
 net/sunrpc/clnt.c |5 +++--
 net/sunrpc/stats.c|2 --
 net/sunrpc/sunrpc_syms.c  |   16 +++-
 net/sunrpc/xdr.c  |3 ++-
 net/sunrpc/xprtsock.c |9 +
 15 files changed, 22 insertions(+), 56 deletions(-)

--- linux-2.6.20-rc4-mm1/include/linux/sunrpc/gss_api.h.old 2007-01-20 
15:37:56.0 +0100
+++ linux-2.6.20-rc4-mm1/include/linux/sunrpc/gss_api.h 2007-01-20 
15:38:07.0 +0100
@@ -123,9 +123,6 @@
 /* Similar, but get by pseudoflavor. */
 struct gss_api_mech *gss_mech_get_by_pseudoflavor(u32);
 
-/* Just increments the mechanism's reference count and returns its input: */
-struct gss_api_mech * gss_mech_get(struct gss_api_mech *);
-
 /* For every successful gss_mech_get or gss_mech_get_by_* call there must be a
  * corresponding call to gss_mech_put. */
 void gss_mech_put(struct gss_api_mech *);
--- linux-2.6.20-rc4-mm1/net/sunrpc/auth_gss/gss_mech_switch.c.old  
2007-01-20 15:38:19.0 +0100
+++ linux-2.6.20-rc4-mm1/net/sunrpc/auth_gss/gss_mech_switch.c  2007-01-20 
15:39:45.0 +0100
@@ -137,15 +137,13 @@
 
 EXPORT_SYMBOL(gss_mech_unregister);
 
-struct gss_api_mech *
+static struct gss_api_mech *
 gss_mech_get(struct gss_api_mech *gm)
 {
__module_get(gm->gm_owner);
return gm;
 }
 
-EXPORT_SYMBOL(gss_mech_get);
-
 struct gss_api_mech *
 gss_mech_get_by_name(const char *name)
 {
@@ -164,8 +162,6 @@
 
 }
 
-EXPORT_SYMBOL(gss_mech_get_by_name);
-
 static inline int
 mech_supports_pseudoflavor(struct gss_api_mech *gm, u32 pseudoflavor)
 {
@@ -197,8 +193,6 @@
return gm;
 }
 
-EXPORT_SYMBOL(gss_mech_get_by_pseudoflavor);
-
 u32
 gss_pseudoflavor_to_service(struct gss_api_mech *gm, u32 pseudoflavor)
 {
@@ -211,8 +205,6 @@
return 0;
 }
 
-EXPORT_SYMBOL(gss_pseudoflavor_to_service);
-
 char *
 gss_service_to_auth_domain_name(struct gss_api_mech *gm, u32 service)
 {
@@ -225,8 +217,6 @@
return NULL;
 }
 
-EXPORT_SYMBOL(gss_service_to_auth_domain_name);
-
 void
 gss_mech_put(struct gss_api_mech * gm)
 {
@@ -234,8 +224,6 @@
module_put(gm->gm_owner);
 }
 
-EXPORT_SYMBOL(gss_mech_put);
-
 /* The mech could probably be determined from the token instead, but it's just
  * as easy for now to pass it in. */
 int
--- linux-2.6.20-rc4-mm1/net/sunrpc/auth_gss/svcauth_gss.c.old  2007-01-20 
15:41:02.0 +0100
+++ linux-2.6.20-rc4-mm1/net/sunrpc/auth_gss/svcauth_gss.c  2007-01-20 
20:52:55.0 +0100
@@ -775,8 +775,6 @@
return stat;
 }
 
-EXPORT_SYMBOL(svcauth_gss_register_pseudoflavor);
-
 void svcauth_gss_unregister_pseudoflavor(char *name)
 {
struct auth_domain *dom;
@@ -788,8 +786,6 @@
}
 }
 
-EXPORT_SYMBOL(svcauth_gss_unregister_pseudoflavor);
-
 static inline int
 read_u32_from_xdr_buf(struct xdr_buf *buf, int base, u32 *obj)
 {
--- linux-2.6.20-rc4-mm1/net/sunrpc/stats.c.old 2007-01-20 15:41:45.0 
+0100
+++ linux-2.6.20-rc4-mm

[2.6 patch] process include/linux/if_{addr,link}.h with unifdef

2007-01-21 Thread Adrian Bunk
After commit d3dcc077bf88806201093f86325ec656e4dbfbce, 
include/linux/if_{addr,link}.h should be processed with unifdef.

Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>

---

 include/linux/Kbuild |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6.20-rc4-mm1/include/linux/Kbuild.old   2007-01-20 
20:14:02.0 +0100
+++ linux-2.6.20-rc4-mm1/include/linux/Kbuild   2007-01-20 20:15:12.0 
+0100
@@ -70,7 +70,6 @@
 header-y += i2c-dev.h
 header-y += i8k.h
 header-y += icmp.h
-header-y += if_addr.h
 header-y += if_arcnet.h
 header-y += if_arp.h
 header-y += if_bonding.h
@@ -80,7 +79,6 @@
 header-y += if.h
 header-y += if_hippi.h
 header-y += if_infiniband.h
-header-y += if_link.h
 header-y += if_packet.h
 header-y += if_plip.h
 header-y += if_ppp.h
@@ -214,6 +212,7 @@
 unifdef-y += i2c.h
 unifdef-y += i2o-dev.h
 unifdef-y += icmpv6.h
+unifdef-y += if_addr.h
 unifdef-y += if_bridge.h
 unifdef-y += if_ec.h
 unifdef-y += if_eql.h
@@ -221,6 +220,7 @@
 unifdef-y += if_fddi.h
 unifdef-y += if_frad.h
 unifdef-y += if_ltalk.h
+unifdef-y += if_link.h
 unifdef-y += if_pppox.h
 unifdef-y += if_shaper.h
 unifdef-y += if_tr.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] cfg80211: Correct conditional compile of wext-common.c.

2007-01-21 Thread Marcus Better
wext-common.o is required if CONFIG_WIRELESS_EXT is set. Looks like 
`CONFIG_NET_WIRELESS' is a typo.

Signed-off-by: Marcus Better <[EMAIL PROTECTED]>

--- a/net/wireless/Makefile
+++ b/net/wireless/Makefile
@@ -12,5 +12,5 @@ obj-ny :=
 
 # this needs to be compiled in...
 obj-$(CONFIG_CFG80211_WEXT_COMPAT) += wext-compat.o
-obj-$(CONFIG_CFG80211_WEXT_COMPAT)$(CONFIG_NET_WIRELESS) += wext-common.o
+obj-$(CONFIG_CFG80211_WEXT_COMPAT)$(CONFIG_WIRELESS_EXT) += wext-common.o
 obj-y += $(obj-yy) $(obj-yn) $(obj-ny)
-- 

-
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: Possible ways of dealing with OOM conditions.

2007-01-21 Thread Rik van Riel

Evgeniy Polyakov wrote:

On Sat, Jan 20, 2007 at 05:36:03PM -0500, Rik van Riel ([EMAIL PROTECTED]) 
wrote:

Evgeniy Polyakov wrote:
On Fri, Jan 19, 2007 at 01:53:15PM +0100, Peter Zijlstra 
([EMAIL PROTECTED]) wrote:

Even further development of such idea is to prevent such OOM condition
at all - by starting swapping early (but wisely) and reduce memory
usage.

These just postpone execution but will not avoid it.

No. If system allows to have such a condition, then
something is broken. It must be prevented, instead of creating special
hacks to recover from it.

Evgeniy, you may want to learn something about the VM before
stating that reality should not occur.


I.e. I should start believing that OOM can not be prevented, bugs can
not be fixed and things can not be changed just because it happens right
now? That is why I'm not subscribed to lkml :)


The reasons for this are often not inside the VM itself,
but are due to the constraints imposed on the VM.

For example, with many of the journaled filesystems there
is no way to know in advance how much IO needs to be done
to complete a writeout of one dirty page (and consequently,
how much memory needs to be allocated to complete this one
writeout).

Parts of the VM could be changed to reduce the pressure
somewhat, eg. limiting the number of IOs in flight, but
that will probably have performance consequences that may
not be acceptable to Andrew and Linus and never get merged.

--
Politics is the struggle between those who want to make their country
the best in the world, and those who believe it already is.  Each group
calls the other unpatriotic.
-
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] Re: kernel BUG in eth_alloc_tx_desc_index at drivers/net/mv643xx_eth.c:1069!

2007-01-21 Thread Thibaut VARENE

On 1/21/07, Thibaut VARENE <[EMAIL PROTECTED]> wrote:

On 1/11/07, Jarek Poplawski <[EMAIL PROTECTED]> wrote:
>
> PS: alas I didn't even check compiling - I had no time to
> find all compile dependencies of this driver
> ---
Hmm, I think this is guaranteed not to work. In between those lines
the lock is released, while data in the mp structure is still being
accessed. It seems that this bit of code is indeed not race-safe
though, I'm gonna try to figure something.


This was indeed the right spot. The attached raw hack seems to fix the
bug (I couldn't crash the box so far).  I haven't checked that the
same "situation" happens elsewhere in the code, I leave that as an
exercise for the maintainers (or until I experience another kind of
crash :)

The patch is a bit ugly (printk with irq disabled will not show, etc)
but at least it does work. I'm sure somebody will figure something

HTH

T-Bone

--
Thibaut VARENE
http://www.parisc-linux.org/~varenet/
--- linux-2.6.19.orig/drivers/net/mv643xx_eth.c	2007-01-21 13:56:04.450689123 +0100
+++ linux-2.6.19/drivers/net/mv643xx_eth.c	2007-01-21 13:39:58.228404763 +0100
@@ -312,8 +312,8 @@
 	int count;
 	int released = 0;
 
+	spin_lock_irqsave(&mp->lock, flags);
 	while (mp->tx_desc_count > 0) {
-		spin_lock_irqsave(&mp->lock, flags);
 		tx_index = mp->tx_used_desc_q;
 		desc = &mp->p_tx_desc_area[tx_index];
 		cmd_sts = desc->cmd_sts;
@@ -332,8 +332,6 @@
 		if (skb)
 			mp->tx_skb[tx_index] = NULL;
 
-		spin_unlock_irqrestore(&mp->lock, flags);
-
 		if (cmd_sts & ETH_ERROR_SUMMARY) {
 			printk("%s: Error in TX\n", dev->name);
 			mp->stats.tx_errors++;
@@ -349,6 +347,7 @@
 
 		released = 1;
 	}
+	spin_unlock_irqrestore(&mp->lock, flags);
 
 	return released;
 }


Re: [PATCH] Re: kernel BUG in eth_alloc_tx_desc_index at drivers/net/mv643xx_eth.c:1069!

2007-01-21 Thread Thibaut VARENE

On 1/11/07, Jarek Poplawski <[EMAIL PROTECTED]> wrote:


PS: alas I didn't even check compiling - I had no time to
find all compile dependencies of this driver
---

Signed-off-by: Jarek Poplawski <[EMAIL PROTECTED]>
---

diff -Nurp linux-2.6.20-rc4-/drivers/net/mv643xx_eth.c 
linux-2.6.20-rc4/drivers/net/mv643xx_eth.c
--- linux-2.6.20-rc4-/drivers/net/mv643xx_eth.c 2006-12-18 08:57:52.0 
+0100
+++ linux-2.6.20-rc4/drivers/net/mv643xx_eth.c  2007-01-11 08:55:34.0 
+0100
@@ -312,8 +312,8 @@ int mv643xx_eth_free_tx_descs(struct net
int count;
int released = 0;

+   spin_lock_irqsave(&mp->lock, flags);
while (mp->tx_desc_count > 0) {
-   spin_lock_irqsave(&mp->lock, flags);
tx_index = mp->tx_used_desc_q;
desc = &mp->p_tx_desc_area[tx_index];
cmd_sts = desc->cmd_sts;
@@ -348,8 +348,10 @@ int mv643xx_eth_free_tx_descs(struct net
dev_kfree_skb_irq(skb);


Hmm, I think this is guaranteed not to work. In between those lines
the lock is released, while data in the mp structure is still being
accessed. It seems that this bit of code is indeed not race-safe
though, I'm gonna try to figure something.


released = 1;
+   spin_lock_irqsave(&mp->lock, flags);
}

+   spin_unlock_irqrestore(&mp->lock, flags);
return released;
 }


Ugh, this is really unclean... Taking a lock "for nothing" like that
has a perf cost.

HTH

T-Bone

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


[RFC] airo.c: Description and function is not the same

2007-01-21 Thread Richard Knutsson

Hello

In the tour of converting local definitions of boolean-type/values, I 
ran into airo.c's description of ex decapsulate():


*  Returns: BOOLEAN - TRUE if packet should be dropped otherwise FALSE

but returns SUCCESS (defined as 0) and ERROR (defined as -1).

Also, shouldn't those functions be converted to return 'bool' when the 
description say so (happy to do it).


Richard Knutsson

-
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