Merge master.kernel.org:/home/rmk/linux-2.6-mmc
[pandora-kernel.git] / drivers / net / sky2.c
index ab36a74..68f9c20 100644 (file)
@@ -51,7 +51,7 @@
 #include "sky2.h"
 
 #define DRV_NAME               "sky2"
-#define DRV_VERSION            "0.15"
+#define DRV_VERSION            "1.1"
 #define PFX                    DRV_NAME " "
 
 /*
@@ -1175,7 +1175,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
                /* just drop the packet if non-linear expansion fails */
                if (skb_header_cloned(skb) &&
                    pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
-                       dev_kfree_skb_any(skb);
+                       dev_kfree_skb(skb);
                        goto out_unlock;
                }
 
@@ -1324,7 +1324,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
                                       PCI_DMA_TODEVICE);
                }
 
-               dev_kfree_skb_any(skb);
+               dev_kfree_skb(skb);
        }
 
        sky2->tx_cons = put;
@@ -2066,6 +2066,27 @@ static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
        }
 }
 
+/* This should never happen it is a fatal situation */
+static void sky2_descriptor_error(struct sky2_hw *hw, unsigned port,
+                                 const char *rxtx, u32 mask)
+{
+       struct net_device *dev = hw->dev[port];
+       struct sky2_port *sky2 = netdev_priv(dev);
+       u32 imask;
+
+       printk(KERN_ERR PFX "%s: %s descriptor error (hardware problem)\n",
+              dev ? dev->name : "<not registered>", rxtx);
+
+       imask = sky2_read32(hw, B0_IMSK);
+       imask &= ~mask;
+       sky2_write32(hw, B0_IMSK, imask);
+
+       if (dev) {
+               spin_lock(&sky2->phy_lock);
+               sky2_link_down(sky2);
+               spin_unlock(&sky2->phy_lock);
+       }
+}
 
 static int sky2_poll(struct net_device *dev0, int *budget)
 {
@@ -2074,20 +2095,34 @@ static int sky2_poll(struct net_device *dev0, int *budget)
        int work_done = 0;
        u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
 
-       if (status & Y2_IS_HW_ERR)
-               sky2_hw_intr(hw);
+       if (unlikely(status & ~Y2_IS_STAT_BMU)) {
+               if (status & Y2_IS_HW_ERR)
+                       sky2_hw_intr(hw);
+
+               if (status & Y2_IS_IRQ_PHY1)
+                       sky2_phy_intr(hw, 0);
+
+               if (status & Y2_IS_IRQ_PHY2)
+                       sky2_phy_intr(hw, 1);
+
+               if (status & Y2_IS_IRQ_MAC1)
+                       sky2_mac_intr(hw, 0);
+
+               if (status & Y2_IS_IRQ_MAC2)
+                       sky2_mac_intr(hw, 1);
 
-       if (status & Y2_IS_IRQ_PHY1)
-               sky2_phy_intr(hw, 0);
+               if (status & Y2_IS_CHK_RX1)
+                       sky2_descriptor_error(hw, 0, "receive", Y2_IS_CHK_RX1);
 
-       if (status & Y2_IS_IRQ_PHY2)
-               sky2_phy_intr(hw, 1);
+               if (status & Y2_IS_CHK_RX2)
+                       sky2_descriptor_error(hw, 1, "receive", Y2_IS_CHK_RX2);
 
-       if (status & Y2_IS_IRQ_MAC1)
-               sky2_mac_intr(hw, 0);
+               if (status & Y2_IS_CHK_TXA1)
+                       sky2_descriptor_error(hw, 0, "transmit", Y2_IS_CHK_TXA1);
 
-       if (status & Y2_IS_IRQ_MAC2)
-               sky2_mac_intr(hw, 1);
+               if (status & Y2_IS_CHK_TXA2)
+                       sky2_descriptor_error(hw, 1, "transmit", Y2_IS_CHK_TXA2);
+       }
 
        if (status & Y2_IS_STAT_BMU) {
                work_done = sky2_status_intr(hw, work_limit);
@@ -2443,17 +2478,34 @@ static const struct sky2_stat {
        { "rx_unicast",    GM_RXF_UC_OK },
        { "tx_mac_pause",  GM_TXF_MPAUSE },
        { "rx_mac_pause",  GM_RXF_MPAUSE },
-       { "collisions",    GM_TXF_SNG_COL },
+       { "collisions",    GM_TXF_COL },
        { "late_collision",GM_TXF_LAT_COL },
        { "aborted",       GM_TXF_ABO_COL },
+       { "single_collisions", GM_TXF_SNG_COL },
        { "multi_collisions", GM_TXF_MUL_COL },
-       { "fifo_underrun", GM_TXE_FIFO_UR },
-       { "fifo_overflow", GM_RXE_FIFO_OV },
-       { "rx_toolong",    GM_RXF_LNG_ERR },
-       { "rx_jabber",     GM_RXF_JAB_PKT },
+
+       { "rx_short",      GM_RXF_SHT },
        { "rx_runt",       GM_RXE_FRAG },
+       { "rx_64_byte_packets", GM_RXF_64B },
+       { "rx_65_to_127_byte_packets", GM_RXF_127B },
+       { "rx_128_to_255_byte_packets", GM_RXF_255B },
+       { "rx_256_to_511_byte_packets", GM_RXF_511B },
+       { "rx_512_to_1023_byte_packets", GM_RXF_1023B },
+       { "rx_1024_to_1518_byte_packets", GM_RXF_1518B },
+       { "rx_1518_to_max_byte_packets", GM_RXF_MAX_SZ },
        { "rx_too_long",   GM_RXF_LNG_ERR },
+       { "rx_fifo_overflow", GM_RXE_FIFO_OV },
+       { "rx_jabber",     GM_RXF_JAB_PKT },
        { "rx_fcs_error",   GM_RXF_FCS_ERR },
+
+       { "tx_64_byte_packets", GM_TXF_64B },
+       { "tx_65_to_127_byte_packets", GM_TXF_127B },
+       { "tx_128_to_255_byte_packets", GM_TXF_255B },
+       { "tx_256_to_511_byte_packets", GM_TXF_511B },
+       { "tx_512_to_1023_byte_packets", GM_TXF_1023B },
+       { "tx_1024_to_1518_byte_packets", GM_TXF_1518B },
+       { "tx_1519_to_max_byte_packets", GM_TXF_MAX_SZ },
+       { "tx_fifo_underrun", GM_TXE_FIFO_UR },
 };
 
 static u32 sky2_get_rx_csum(struct net_device *dev)
@@ -2555,7 +2607,7 @@ static struct net_device_stats *sky2_get_stats(struct net_device *dev)
        sky2->net_stats.rx_bytes = data[1];
        sky2->net_stats.tx_packets = data[2] + data[4] + data[6];
        sky2->net_stats.rx_packets = data[3] + data[5] + data[7];
-       sky2->net_stats.multicast = data[5] + data[7];
+       sky2->net_stats.multicast = data[3] + data[5];
        sky2->net_stats.collisions = data[10];
        sky2->net_stats.tx_aborted_errors = data[12];