]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/sky2.c
sky2: backout NAPI reschedule
[linux-2.6-omap-h63xx.git] / drivers / net / sky2.c
index 36db93811ac74c850f5b50f5080239dfe171c648..76da74fbe859b16d44c1ca109c6b77bb747e8f82 100644 (file)
@@ -51,7 +51,7 @@
 #include "sky2.h"
 
 #define DRV_NAME               "sky2"
-#define DRV_VERSION            "1.1"
+#define DRV_VERSION            "1.2"
 #define PFX                    DRV_NAME " "
 
 /*
@@ -99,8 +99,6 @@ MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
 static const struct pci_device_id sky2_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) },
        { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) },
-       { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) },
-       { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) },
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) },
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) },
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) },
@@ -579,8 +577,8 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
        reg = gma_read16(hw, port, GM_PHY_ADDR);
        gma_write16(hw, port, GM_PHY_ADDR, reg | GM_PAR_MIB_CLR);
 
-       for (i = 0; i < GM_MIB_CNT_SIZE; i++)
-               gma_read16(hw, port, GM_MIB_CNT_BASE + 8 * i);
+       for (i = GM_MIB_CNT_BASE; i <= GM_MIB_CNT_END; i += 4)
+               gma_read16(hw, port, i);
        gma_write16(hw, port, GM_PHY_ADDR, reg);
 
        /* transmit control */
@@ -927,8 +925,7 @@ static inline struct sk_buff *sky2_alloc_skb(unsigned int size, gfp_t gfp_mask)
        skb = alloc_skb(size + RX_SKB_ALIGN, gfp_mask);
        if (likely(skb)) {
                unsigned long p = (unsigned long) skb->data;
-               skb_reserve(skb,
-                       ((p + RX_SKB_ALIGN - 1) & ~(RX_SKB_ALIGN - 1)) - p);
+               skb_reserve(skb, ALIGN(p, RX_SKB_ALIGN) - p);
        }
 
        return skb;
@@ -1175,7 +1172,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 +1321,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;
@@ -1688,13 +1685,12 @@ static void sky2_tx_timeout(struct net_device *dev)
 }
 
 
-#define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
 /* Want receive buffer size to be multiple of 64 bits
  * and incl room for vlan and truncation
  */
 static inline unsigned sky2_buf_size(int mtu)
 {
-       return roundup(mtu + ETH_HLEN + VLAN_HLEN, 8) + 8;
+       return ALIGN(mtu + ETH_HLEN + VLAN_HLEN, 8) + 8;
 }
 
 static int sky2_change_mtu(struct net_device *dev, int new_mtu)
@@ -2088,6 +2084,20 @@ static void sky2_descriptor_error(struct sky2_hw *hw, unsigned port,
        }
 }
 
+/* If idle then force a fake soft NAPI poll once a second
+ * to work around cases where sharing an edge triggered interrupt.
+ */
+static void sky2_idle(unsigned long arg)
+{
+       struct net_device *dev = (struct net_device *) arg;
+
+       local_irq_disable();
+       if (__netif_rx_schedule_prep(dev))
+               __netif_rx_schedule(dev);
+       local_irq_enable();
+}
+
+
 static int sky2_poll(struct net_device *dev0, int *budget)
 {
        struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw;
@@ -2135,6 +2145,8 @@ static int sky2_poll(struct net_device *dev0, int *budget)
                sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
        }
 
+       mod_timer(&hw->idle_timer, jiffies + HZ);
+
        netif_rx_complete(dev0);
 
        status = sky2_read32(hw, B0_Y2_SP_LISR);
@@ -2195,7 +2207,7 @@ static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
 }
 
 
-static int sky2_reset(struct sky2_hw *hw)
+static int __devinit sky2_reset(struct sky2_hw *hw)
 {
        u16 status;
        u8 t8, pmd_type;
@@ -2484,7 +2496,7 @@ static const struct sky2_stat {
        { "single_collisions", GM_TXF_SNG_COL },
        { "multi_collisions", GM_TXF_MUL_COL },
 
-       { "rx_short",      GM_RXE_SHT },
+       { "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 },
@@ -2607,7 +2619,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];
 
@@ -3278,6 +3290,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
 
        sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
 
+       setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) dev);
+
        pci_set_drvdata(pdev, hw);
 
        return 0;
@@ -3313,13 +3327,15 @@ static void __devexit sky2_remove(struct pci_dev *pdev)
        if (!hw)
                return;
 
+       del_timer_sync(&hw->idle_timer);
+
+       sky2_write32(hw, B0_IMSK, 0);
        dev0 = hw->dev[0];
        dev1 = hw->dev[1];
        if (dev1)
                unregister_netdev(dev1);
        unregister_netdev(dev0);
 
-       sky2_write32(hw, B0_IMSK, 0);
        sky2_set_power_state(hw, PCI_D3hot);
        sky2_write16(hw, B0_Y2LED, LED_STAT_OFF);
        sky2_write8(hw, B0_CTST, CS_RST_SET);