]> err.no Git - linux-2.6/blobdiff - drivers/net/sky2.c
Merge branch 'origin'
[linux-2.6] / drivers / net / sky2.c
index cae2edf23004e9b54c571f0b23f34dbacf8a2662..73260364cba3f9c590dbc05775868d7ce62283c8 100644 (file)
@@ -74,7 +74,7 @@
 #define TX_RING_SIZE           512
 #define TX_DEF_PENDING         (TX_RING_SIZE - 1)
 #define TX_MIN_PENDING         64
-#define MAX_SKB_TX_LE          (4 + 2*MAX_SKB_FRAGS)
+#define MAX_SKB_TX_LE          (4 + (sizeof(dma_addr_t)/sizeof(u32))*MAX_SKB_FRAGS)
 
 #define STATUS_RING_SIZE       2048    /* 2 ports * (TX + 2*RX) */
 #define STATUS_LE_BYTES                (STATUS_RING_SIZE*sizeof(struct sky2_status_le))
@@ -96,10 +96,6 @@ static int copybreak __read_mostly = 256;
 module_param(copybreak, int, 0);
 MODULE_PARM_DESC(copybreak, "Receive copy threshold");
 
-static int disable_msi = 0;
-module_param(disable_msi, int, 0);
-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) },
@@ -195,11 +191,11 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
        pr_debug("sky2_set_power_state %d\n", state);
        sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
 
-       pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_PMC, &power_control);
+       power_control = sky2_pci_read16(hw, hw->pm_cap + PCI_PM_PMC);
        vaux = (sky2_read16(hw, B0_CTST) & Y2_VAUX_AVAIL) &&
                (power_control & PCI_PM_CAP_PME_D3cold);
 
-       pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_CTRL, &power_control);
+       power_control = sky2_pci_read16(hw, hw->pm_cap + PCI_PM_CTRL);
 
        power_control |= PCI_PM_CTRL_PME_STATUS;
        power_control &= ~(PCI_PM_CTRL_STATE_MASK);
@@ -223,7 +219,7 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
                        sky2_write8(hw, B2_Y2_CLK_GATE, 0);
 
                /* Turn off phy power saving */
-               pci_read_config_dword(hw->pdev, PCI_DEV_REG1, &reg1);
+               reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
                reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
 
                /* looks like this XL is back asswards .. */
@@ -232,18 +228,28 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
                        if (hw->ports > 1)
                                reg1 |= PCI_Y2_PHY2_COMA;
                }
-               pci_write_config_dword(hw->pdev, PCI_DEV_REG1, reg1);
+
+               if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
+                       sky2_pci_write32(hw, PCI_DEV_REG3, 0);
+                       reg1 = sky2_pci_read32(hw, PCI_DEV_REG4);
+                       reg1 &= P_ASPM_CONTROL_MSK;
+                       sky2_pci_write32(hw, PCI_DEV_REG4, reg1);
+                       sky2_pci_write32(hw, PCI_DEV_REG5, 0);
+               }
+
+               sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
+
                break;
 
        case PCI_D3hot:
        case PCI_D3cold:
                /* Turn on phy power saving */
-               pci_read_config_dword(hw->pdev, PCI_DEV_REG1, &reg1);
+               reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
                if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
                        reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
                else
                        reg1 |= (PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
-               pci_write_config_dword(hw->pdev, PCI_DEV_REG1, reg1);
+               sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
 
                if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
                        sky2_write8(hw, B2_Y2_CLK_GATE, 0);
@@ -265,7 +271,7 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
                ret = -1;
        }
 
-       pci_write_config_byte(hw->pdev, hw->pm_cap + PCI_PM_CTRL, power_control);
+       sky2_pci_write16(hw, hw->pm_cap + PCI_PM_CTRL, power_control);
        sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
        return ret;
 }
@@ -463,16 +469,31 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
                ledover |= PHY_M_LED_MO_RX(MO_LED_OFF);
        }
 
-       gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
+       if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev >= 2) {
+               /* apply fixes in PHY AFE */
+               gm_phy_write(hw, port, 22, 255);
+               /* increase differential signal amplitude in 10BASE-T */
+               gm_phy_write(hw, port, 24, 0xaa99);
+               gm_phy_write(hw, port, 23, 0x2011);
 
-       if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
-               /* turn on 100 Mbps LED (LED_LINK100) */
-               ledover |= PHY_M_LED_MO_100(MO_LED_ON);
-       }
+               /* fix for IEEE A/B Symmetry failure in 1000BASE-T */
+               gm_phy_write(hw, port, 24, 0xa204);
+               gm_phy_write(hw, port, 23, 0x2002);
 
-       if (ledover)
-               gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover);
+               /* set page register to 0 */
+               gm_phy_write(hw, port, 22, 0);
+       } else {
+               gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
+
+               if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
+                       /* turn on 100 Mbps LED (LED_LINK100) */
+                       ledover |= PHY_M_LED_MO_100(MO_LED_ON);
+               }
+
+               if (ledover)
+                       gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover);
 
+       }
        /* Enable phy interrupt on auto-negotiation complete (or link up) */
        if (sky2->autoneg == AUTONEG_ENABLE)
                gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_AN_COMPL);
@@ -520,10 +541,16 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
 
                switch (sky2->speed) {
                case SPEED_1000:
+                       reg &= ~GM_GPCR_SPEED_100;
                        reg |= GM_GPCR_SPEED_1000;
-                       /* fallthru */
+                       break;
                case SPEED_100:
+                       reg &= ~GM_GPCR_SPEED_1000;
                        reg |= GM_GPCR_SPEED_100;
+                       break;
+               case SPEED_10:
+                       reg &= ~(GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100);
+                       break;
                }
 
                if (sky2->duplex == DUPLEX_FULL)
@@ -595,8 +622,8 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
 
        /* Configure Rx MAC FIFO */
        sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR);
-       sky2_write16(hw, SK_REG(port, RX_GMF_CTRL_T),
-                    GMF_RX_CTRL_DEF);
+       sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T),
+                    GMF_OPER_ON | GMF_RX_F_FL_ON);
 
        /* Flush Rx MAC FIFO on any flow control or error */
        sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), GMR_FS_ANY_ERR);
@@ -947,6 +974,12 @@ static int sky2_rx_start(struct sky2_port *sky2)
 
        sky2->rx_put = sky2->rx_next = 0;
        sky2_qset(hw, rxq);
+
+       if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev >= 2) {
+               /* MAC Rx RAM Read is controlled by hardware */
+               sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS);
+       }
+
        sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
 
        rx_set_checksum(sky2);
@@ -962,6 +995,10 @@ static int sky2_rx_start(struct sky2_port *sky2)
                sky2_rx_add(sky2, re->mapaddr);
        }
 
+       /* Truncate oversize frames */
+       sky2_write16(hw, SK_REG(sky2->port, RX_GMF_TR_THR), sky2->rx_bufsize - 8);
+       sky2_write32(hw, SK_REG(sky2->port, RX_GMF_CTRL_T), RX_TRUNC_ON);
+
        /* Tell chip about available buffers */
        sky2_write16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX), sky2->rx_put);
        sky2->rx_last_put = sky2_read16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX));
@@ -1029,9 +1066,10 @@ static int sky2_up(struct net_device *dev)
                    RB_RST_SET);
 
        sky2_qset(hw, txqaddr[port]);
-       if (hw->chip_id == CHIP_ID_YUKON_EC_U)
-               sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), 0x1a0);
 
+       /* Set almost empty threshold */
+       if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == 1)
+               sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), 0x1a0);
 
        sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map,
                           TX_RING_SIZE - 1);
@@ -1041,8 +1079,10 @@ static int sky2_up(struct net_device *dev)
                goto err_out;
 
        /* Enable interrupts from phy/mac for port */
+       spin_lock_irq(&hw->hw_lock);
        hw->intr_mask |= (port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2;
        sky2_write32(hw, B0_IMSK, hw->intr_mask);
+       spin_unlock_irq(&hw->hw_lock);
        return 0;
 
 err_out:
@@ -1109,6 +1149,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
        struct sky2_tx_le *le = NULL;
        struct tx_ring_info *re;
        unsigned i, len;
+       int avail;
        dma_addr_t mapping;
        u32 addr64;
        u16 mss;
@@ -1251,12 +1292,16 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
        re->idx = sky2->tx_prod;
        le->ctrl |= EOP;
 
+       avail = tx_avail(sky2);
+       if (mss != 0 || avail < TX_MIN_PENDING) {
+               le->ctrl |= FRC_STAT;
+               if (avail <= MAX_SKB_TX_LE)
+                       netif_stop_queue(dev);
+       }
+
        sky2_put_idx(hw, txqaddr[sky2->port], sky2->tx_prod,
                     &sky2->tx_last_put, TX_RING_SIZE);
 
-       if (tx_avail(sky2) <= MAX_SKB_TX_LE)
-               netif_stop_queue(dev);
-
 out_unlock:
        spin_unlock(&sky2->tx_lock);
 
@@ -1342,10 +1387,10 @@ static int sky2_down(struct net_device *dev)
        netif_stop_queue(dev);
 
        /* Disable port IRQ */
-       local_irq_disable();
+       spin_lock_irq(&hw->hw_lock);
        hw->intr_mask &= ~((sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2);
        sky2_write32(hw, B0_IMSK, hw->intr_mask);
-       local_irq_enable();
+       spin_unlock_irq(&hw->hw_lock);
 
        flush_scheduled_work();
 
@@ -1446,6 +1491,29 @@ static void sky2_link_up(struct sky2_port *sky2)
        sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), GMAC_DEF_MSK);
 
        reg = gma_read16(hw, port, GM_GP_CTRL);
+       if (sky2->autoneg == AUTONEG_DISABLE) {
+               reg |= GM_GPCR_AU_ALL_DIS;
+
+               /* Is write/read necessary?  Copied from sky2_mac_init */
+               gma_write16(hw, port, GM_GP_CTRL, reg);
+               gma_read16(hw, port, GM_GP_CTRL);
+
+               switch (sky2->speed) {
+               case SPEED_1000:
+                       reg &= ~GM_GPCR_SPEED_100;
+                       reg |= GM_GPCR_SPEED_1000;
+                       break;
+               case SPEED_100:
+                       reg &= ~GM_GPCR_SPEED_1000;
+                       reg |= GM_GPCR_SPEED_100;
+                       break;
+               case SPEED_10:
+                       reg &= ~(GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100);
+                       break;
+               }
+       } else
+               reg &= ~GM_GPCR_AU_ALL_DIS;
+
        if (sky2->duplex == DUPLEX_FULL || sky2->autoneg == AUTONEG_ENABLE)
                reg |= GM_GPCR_DUP_FULL;
 
@@ -1604,10 +1672,10 @@ static void sky2_phy_task(void *arg)
 out:
        up(&sky2->phy_sema);
 
-       local_irq_disable();
+       spin_lock_irq(&hw->hw_lock);
        hw->intr_mask |= (sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2;
        sky2_write32(hw, B0_IMSK, hw->intr_mask);
-       local_irq_enable();
+       spin_unlock_irq(&hw->hw_lock);
 }
 
 
@@ -1648,10 +1716,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 */
+/* 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 + 4, 8);
+       return roundup(mtu + ETH_HLEN + VLAN_HLEN, 8) + 8;
 }
 
 static int sky2_change_mtu(struct net_device *dev, int new_mtu)
@@ -1734,7 +1804,7 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2,
        if (!(status & GMR_FS_RX_OK))
                goto resubmit;
 
-       if ((status >> 16) != length || length > sky2->rx_bufsize)
+       if (length > sky2->netdev->mtu + ETH_HLEN)
                goto oversize;
 
        if (length < copybreak) {
@@ -1834,6 +1904,17 @@ static int sky2_poll(struct net_device *dev0, int *budget)
 
        sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
 
+       /*
+        * Kick the STAT_LEV_TIMER_CTRL timer.
+        * This fixes my hangs on Yukon-EC (0xb6) rev 1.
+        * The if clause is there to start the timer only if it has been
+        * configured correctly and not been disabled via ethtool.
+        */
+       if (sky2_read8(hw, STAT_LEV_TIMER_CTRL) == TIM_START) {
+               sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_STOP);
+               sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_START);
+       }
+
        hwidx = sky2_read16(hw, STAT_PUT_IDX);
        BUG_ON(hwidx >= STATUS_RING_SIZE);
        rmb();
@@ -1916,16 +1997,19 @@ exit_loop:
        sky2_tx_check(hw, 0, tx_done[0]);
        sky2_tx_check(hw, 1, tx_done[1]);
 
+       if (sky2_read8(hw, STAT_TX_TIMER_CTRL) == TIM_START) {
+               sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
+               sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
+       }
+
        if (likely(work_done < to_do)) {
-               /* need to restart TX timer */
-               if (is_ec_a1(hw)) {
-                       sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
-                       sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
-               }
+               spin_lock_irq(&hw->hw_lock);
+               __netif_rx_complete(dev0);
 
-               netif_rx_complete(dev0);
                hw->intr_mask |= Y2_IS_STAT_BMU;
                sky2_write32(hw, B0_IMSK, hw->intr_mask);
+               spin_unlock_irq(&hw->hw_lock);
+
                return 0;
        } else {
                *budget -= work_done;
@@ -1988,13 +2072,13 @@ static void sky2_hw_intr(struct sky2_hw *hw)
        if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
                u16 pci_err;
 
-               pci_read_config_word(hw->pdev, PCI_STATUS, &pci_err);
+               pci_err = sky2_pci_read16(hw, PCI_STATUS);
                if (net_ratelimit())
                        printk(KERN_ERR PFX "%s: pci hw error (0x%x)\n",
                               pci_name(hw->pdev), pci_err);
 
                sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-               pci_write_config_word(hw->pdev, PCI_STATUS,
+               sky2_pci_write16(hw, PCI_STATUS,
                                      pci_err | PCI_STATUS_ERROR_BITS);
                sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
        }
@@ -2003,7 +2087,7 @@ static void sky2_hw_intr(struct sky2_hw *hw)
                /* PCI-Express uncorrectable Error occurred */
                u32 pex_err;
 
-               pci_read_config_dword(hw->pdev, PEX_UNC_ERR_STAT, &pex_err);
+               pex_err = sky2_pci_read32(hw, PEX_UNC_ERR_STAT);
 
                if (net_ratelimit())
                        printk(KERN_ERR PFX "%s: pci express error (0x%x)\n",
@@ -2011,7 +2095,7 @@ static void sky2_hw_intr(struct sky2_hw *hw)
 
                /* clear the interrupt */
                sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-               pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT,
+               sky2_pci_write32(hw, PEX_UNC_ERR_STAT,
                                       0xffffffffUL);
                sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
 
@@ -2057,6 +2141,7 @@ static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
 
        hw->intr_mask &= ~(port == 0 ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2);
        sky2_write32(hw, B0_IMSK, hw->intr_mask);
+
        schedule_work(&sky2->phy_task);
 }
 
@@ -2070,6 +2155,7 @@ static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs)
        if (status == 0 || status == ~0)
                return IRQ_NONE;
 
+       spin_lock(&hw->hw_lock);
        if (status & Y2_IS_HW_ERR)
                sky2_hw_intr(hw);
 
@@ -2098,7 +2184,7 @@ static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs)
 
        sky2_write32(hw, B0_Y2_SP_ICR, 2);
 
-       sky2_read32(hw, B0_IMSK);
+       spin_unlock(&hw->hw_lock);
 
        return IRQ_HANDLED;
 }
@@ -2141,7 +2227,7 @@ static int sky2_reset(struct sky2_hw *hw)
 {
        u16 status;
        u8 t8, pmd_type;
-       int i, err;
+       int i;
 
        sky2_write8(hw, B0_CTST, CS_RST_CLR);
 
@@ -2163,25 +2249,18 @@ static int sky2_reset(struct sky2_hw *hw)
        sky2_write8(hw, B0_CTST, CS_RST_CLR);
 
        /* clear PCI errors, if any */
-       err = pci_read_config_word(hw->pdev, PCI_STATUS, &status);
-       if (err)
-               goto pci_err;
+       status = sky2_pci_read16(hw, PCI_STATUS);
 
        sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-       err = pci_write_config_word(hw->pdev, PCI_STATUS,
-                                   status | PCI_STATUS_ERROR_BITS);
-       if (err)
-               goto pci_err;
+       sky2_pci_write16(hw, PCI_STATUS, status | PCI_STATUS_ERROR_BITS);
+
 
        sky2_write8(hw, B0_CTST, CS_MRST_CLR);
 
        /* clear any PEX errors */
-       if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP)) {
-               err = pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT,
-                                                0xffffffffUL);
-               if (err)
-                       goto pci_err;
-       }
+       if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP)) 
+               sky2_pci_write32(hw, PEX_UNC_ERR_STAT, 0xffffffffUL);
+
 
        pmd_type = sky2_read8(hw, B2_PMD_TYP);
        hw->copper = !(pmd_type == 'L' || pmd_type == 'S');
@@ -2280,8 +2359,7 @@ static int sky2_reset(struct sky2_hw *hw)
                        sky2_write8(hw, STAT_FIFO_ISR_WM, 16);
 
                sky2_write32(hw, STAT_TX_TIMER_INI, sky2_us2clk(hw, 1000));
-               sky2_write32(hw, STAT_LEV_TIMER_INI, sky2_us2clk(hw, 100));
-               sky2_write32(hw, STAT_ISR_TIMER_INI, sky2_us2clk(hw, 20));
+               sky2_write32(hw, STAT_ISR_TIMER_INI, sky2_us2clk(hw, 7));
        }
 
        /* enable status unit */
@@ -2292,14 +2370,6 @@ static int sky2_reset(struct sky2_hw *hw)
        sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START);
 
        return 0;
-
-pci_err:
-       /* This is to catch a BIOS bug workaround where
-        * mmconfig table doesn't have other buses.
-        */
-       printk(KERN_ERR PFX "%s: can't access PCI config space\n",
-              pci_name(hw->pdev));
-       return err;
 }
 
 static u32 sky2_supported_modes(const struct sky2_hw *hw)
@@ -2823,11 +2893,11 @@ static int sky2_set_coalesce(struct net_device *dev,
            (ecmd->rx_coalesce_usecs_irq < tmin || ecmd->rx_coalesce_usecs_irq > tmax))
                return -EINVAL;
 
-       if (ecmd->tx_max_coalesced_frames > 0xffff)
+       if (ecmd->tx_max_coalesced_frames >= TX_RING_SIZE-1)
                return -EINVAL;
-       if (ecmd->rx_max_coalesced_frames > 0xff)
+       if (ecmd->rx_max_coalesced_frames > RX_MAX_PENDING)
                return -EINVAL;
-       if (ecmd->rx_max_coalesced_frames_irq > 0xff)
+       if (ecmd->rx_max_coalesced_frames_irq >RX_MAX_PENDING)
                return -EINVAL;
 
        if (ecmd->tx_coalesce_usecs == 0)
@@ -3063,61 +3133,6 @@ static void __devinit sky2_show_addr(struct net_device *dev)
                       dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
 }
 
-/* Handle software interrupt used during MSI test */
-static irqreturn_t __devinit sky2_test_intr(int irq, void *dev_id,
-                                           struct pt_regs *regs)
-{
-       struct sky2_hw *hw = dev_id;
-       u32 status = sky2_read32(hw, B0_Y2_SP_ISRC2);
-
-       if (status == 0)
-               return IRQ_NONE;
-
-       if (status & Y2_IS_IRQ_SW) {
-               sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ);
-               hw->msi = 1;
-       }
-       sky2_write32(hw, B0_Y2_SP_ICR, 2);
-
-       sky2_read32(hw, B0_IMSK);
-       return IRQ_HANDLED;
-}
-
-/* Test interrupt path by forcing a a software IRQ */
-static int __devinit sky2_test_msi(struct sky2_hw *hw)
-{
-       struct pci_dev *pdev = hw->pdev;
-       int i, err;
-
-       sky2_write32(hw, B0_IMSK, Y2_IS_IRQ_SW);
-
-       err = request_irq(pdev->irq, sky2_test_intr, SA_SHIRQ, DRV_NAME, hw);
-       if (err) {
-               printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
-                      pci_name(pdev), pdev->irq);
-               return err;
-       }
-
-       sky2_write8(hw, B0_CTST, CS_ST_SW_IRQ);
-       wmb();
-
-       for (i = 0; i < 10; i++) {
-               barrier();
-               if (hw->msi)
-                       goto found;
-               mdelay(1);
-       }
-
-       err = -EOPNOTSUPP;
-       sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ);
- found:
-       sky2_write32(hw, B0_IMSK, 0);
-
-       free_irq(pdev->irq, hw);
-
-       return err;
-}
-
 static int __devinit sky2_probe(struct pci_dev *pdev,
                                const struct pci_device_id *ent)
 {
@@ -3169,17 +3184,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
                }
        }
 
-#ifdef __BIG_ENDIAN
-       /* byte swap descriptors in hardware */
-       {
-               u32 reg;
-
-               pci_read_config_dword(pdev, PCI_DEV_REG2, &reg);
-               reg |= PCI_REV_DESC;
-               pci_write_config_dword(pdev, PCI_DEV_REG2, reg);
-       }
-#endif
-
        err = -ENOMEM;
        hw = kzalloc(sizeof(*hw), GFP_KERNEL);
        if (!hw) {
@@ -3197,6 +3201,18 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
                goto err_out_free_hw;
        }
        hw->pm_cap = pm_cap;
+       spin_lock_init(&hw->hw_lock);
+
+#ifdef __BIG_ENDIAN
+       /* byte swap descriptors in hardware */
+       {
+               u32 reg;
+
+               reg = sky2_pci_read32(hw, PCI_DEV_REG2);
+               reg |= PCI_REV_DESC;
+               sky2_pci_write32(hw, PCI_DEV_REG2, reg);
+       }
+#endif
 
        /* ring for status responses */
        hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES,
@@ -3238,22 +3254,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
                }
        }
 
-       if (!disable_msi && pci_enable_msi(pdev) == 0) {
-               err = sky2_test_msi(hw);
-               if (err == -EOPNOTSUPP) {
-                       /* MSI test failed, go back to INTx mode */
-                       printk(KERN_WARNING PFX "%s: No interrupt was generated using MSI, "
-                              "switching to INTx mode. Please report this failure to "
-                              "the PCI maintainer and include system chipset information.\n",
-                              pci_name(pdev));
-                       pci_disable_msi(pdev);
-               }
-               else if (err)
-                       goto err_out_unregister;
-       }
-
-       err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ | SA_SAMPLE_RANDOM,
-                         DRV_NAME, hw);
+       err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ, DRV_NAME, hw);
        if (err) {
                printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
                       pci_name(pdev), pdev->irq);
@@ -3268,8 +3269,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
        return 0;
 
 err_out_unregister:
-       if (hw->msi)
-               pci_disable_msi(pdev);
        if (dev1) {
                unregister_netdev(dev1);
                free_netdev(dev1);
@@ -3312,8 +3311,6 @@ static void __devexit sky2_remove(struct pci_dev *pdev)
        sky2_read8(hw, B0_CTST);
 
        free_irq(pdev->irq, hw);
-       if (hw->msi)
-               pci_disable_msi(pdev);
        pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma);
        pci_release_regions(pdev);
        pci_disable_device(pdev);