]> err.no Git - linux-2.6/blobdiff - drivers/net/sky2.c
[PATCH] kill eth_io_copy_and_sum()
[linux-2.6] / drivers / net / sky2.c
index 5abcf853e98b99e1363c961346a3b7be44703f3f..f2ab3d56e5653663040190dd91dcdfbc3e38ed70 100644 (file)
@@ -49,7 +49,7 @@
 #include "sky2.h"
 
 #define DRV_NAME               "sky2"
-#define DRV_VERSION            "1.11.1"
+#define DRV_VERSION            "1.12"
 #define PFX                    DRV_NAME " "
 
 /*
@@ -105,6 +105,7 @@ static const struct pci_device_id sky2_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) },    /* DGE-560T */
        { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) },    /* DGE-550SX */
        { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4B02) },    /* DGE-560SX */
+       { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4B03) },    /* DGE-550T */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, /* 88E8021 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, /* 88E8022 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, /* 88E8061 */
@@ -126,6 +127,9 @@ static const struct pci_device_id sky2_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, /* 88EC036 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, /* 88EC032 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */
        { 0 }
 };
 
@@ -140,7 +144,7 @@ static const u32 portirq_msk[] = { Y2_IS_PORT_1, Y2_IS_PORT_2 };
 static const char *yukon2_name[] = {
        "XL",           /* 0xb3 */
        "EC Ultra",     /* 0xb4 */
-       "UNKNOWN",      /* 0xb5 */
+       "Extreme",      /* 0xb5 */
        "EC",           /* 0xb6 */
        "FE",           /* 0xb7 */
 };
@@ -211,7 +215,7 @@ static void sky2_power_on(struct sky2_hw *hw)
        else
                sky2_write8(hw, B2_Y2_CLK_GATE, 0);
 
-       if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
+       if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) {
                u32 reg1;
 
                sky2_pci_write32(hw, PCI_DEV_REG3, 0);
@@ -289,8 +293,10 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
        struct sky2_port *sky2 = netdev_priv(hw->dev[port]);
        u16 ctrl, ct1000, adv, pg, ledctrl, ledover, reg;
 
-       if (sky2->autoneg == AUTONEG_ENABLE &&
-           !(hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)) {
+       if (sky2->autoneg == AUTONEG_ENABLE
+           && !(hw->chip_id == CHIP_ID_YUKON_XL
+                || hw->chip_id == CHIP_ID_YUKON_EC_U
+                || hw->chip_id == CHIP_ID_YUKON_EX)) {
                u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL);
 
                ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK |
@@ -317,8 +323,10 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
                        /* enable automatic crossover */
                        ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO);
 
-                       if (sky2->autoneg == AUTONEG_ENABLE &&
-                           (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)) {
+                       if (sky2->autoneg == AUTONEG_ENABLE
+                           && (hw->chip_id == CHIP_ID_YUKON_XL
+                               || hw->chip_id == CHIP_ID_YUKON_EC_U
+                               || hw->chip_id == CHIP_ID_YUKON_EX)) {
                                ctrl &= ~PHY_M_PC_DSC_MSK;
                                ctrl |= PHY_M_PC_DSC(2) | PHY_M_PC_DOWN_S_ENA;
                        }
@@ -473,7 +481,9 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
                /* restore page register */
                gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
                break;
+
        case CHIP_ID_YUKON_EC_U:
+       case CHIP_ID_YUKON_EX:
                pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
 
                /* select page 3 to access LED control register */
@@ -515,7 +525,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
 
                /* set page register to 0 */
                gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
-       } else {
+       } else if (hw->chip_id != CHIP_ID_YUKON_EX) {
                gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
 
                if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
@@ -727,7 +737,7 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
        sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR);
        sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON);
 
-       if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
+       if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) {
                sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8);
                sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
                if (hw->dev[port]->mtu > ETH_DATA_LEN) {
@@ -1687,7 +1697,9 @@ static void sky2_link_up(struct sky2_port *sky2)
        sky2_write8(hw, SK_REG(port, LNK_LED_REG),
                    LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF);
 
-       if (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U) {
+       if (hw->chip_id == CHIP_ID_YUKON_XL
+           || hw->chip_id == CHIP_ID_YUKON_EC_U
+           || hw->chip_id == CHIP_ID_YUKON_EX) {
                u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
                u16 led = PHY_M_LEDC_LOS_CTRL(1);       /* link active */
 
@@ -1780,14 +1792,16 @@ static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
        sky2->duplex = (aux & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
 
        /* Pause bits are offset (9..8) */
-       if (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)
+       if (hw->chip_id == CHIP_ID_YUKON_XL
+           || hw->chip_id == CHIP_ID_YUKON_EC_U
+           || hw->chip_id == CHIP_ID_YUKON_EX)
                aux >>= 6;
 
        sky2->flow_status = sky2_flow(aux & PHY_M_PS_RX_P_EN,
                                      aux & PHY_M_PS_TX_P_EN);
 
        if (sky2->duplex == DUPLEX_HALF && sky2->speed < SPEED_1000
-           && hw->chip_id != CHIP_ID_YUKON_EC_U)
+           && !(hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX))
                sky2->flow_status = FC_NONE;
 
        if (aux & PHY_M_PS_RX_P_EN)
@@ -1840,48 +1854,37 @@ out:
 }
 
 
-/* Transmit timeout is only called if we are running, carries is up
+/* Transmit timeout is only called if we are running, carrier is up
  * and tx queue is full (stopped).
+ * Called with netif_tx_lock held.
  */
 static void sky2_tx_timeout(struct net_device *dev)
 {
        struct sky2_port *sky2 = netdev_priv(dev);
        struct sky2_hw *hw = sky2->hw;
-       unsigned txq = txqaddr[sky2->port];
-       u16 report, done;
+       u32 imask;
 
        if (netif_msg_timer(sky2))
                printk(KERN_ERR PFX "%s: tx timeout\n", dev->name);
 
-       report = sky2_read16(hw, sky2->port == 0 ? STAT_TXA1_RIDX : STAT_TXA2_RIDX);
-       done = sky2_read16(hw, Q_ADDR(txq, Q_DONE));
-
        printk(KERN_DEBUG PFX "%s: transmit ring %u .. %u report=%u done=%u\n",
-              dev->name,
-              sky2->tx_cons, sky2->tx_prod, report, done);
-
-       if (report != done) {
-               printk(KERN_INFO PFX "status burst pending (irq moderation?)\n");
+              dev->name, sky2->tx_cons, sky2->tx_prod,
+              sky2_read16(hw, sky2->port == 0 ? STAT_TXA1_RIDX : STAT_TXA2_RIDX),
+              sky2_read16(hw, Q_ADDR(txqaddr[sky2->port], Q_DONE)));
 
-               sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
-               sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
-       } else if (report != sky2->tx_cons) {
-               printk(KERN_INFO PFX "status report lost?\n");
+       imask = sky2_read32(hw, B0_IMSK);       /* block IRQ in hw */
+       sky2_write32(hw, B0_IMSK, 0);
+       sky2_read32(hw, B0_IMSK);
 
-               netif_tx_lock_bh(dev);
-               sky2_tx_complete(sky2, report);
-               netif_tx_unlock_bh(dev);
-       } else {
-               printk(KERN_INFO PFX "hardware hung? flushing\n");
+       netif_poll_disable(hw->dev[0]);         /* stop NAPI poll */
+       synchronize_irq(hw->pdev->irq);
 
-               sky2_write32(hw, Q_ADDR(txq, Q_CSR), BMU_STOP);
-               sky2_write32(hw, Y2_QADDR(txq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET);
+       netif_start_queue(dev);                 /* don't wakeup during flush */
+       sky2_tx_complete(sky2, sky2->tx_prod);  /* Flush transmit queue */
 
-               sky2_tx_clean(dev);
+       sky2_write32(hw, B0_IMSK, imask);
 
-               sky2_qset(hw, txq);
-               sky2_prefetch_init(hw, txq, sky2->tx_le_map, TX_RING_SIZE - 1);
-       }
+       sky2_phy_reinit(sky2);                  /* this clears flow control etc */
 }
 
 static int sky2_change_mtu(struct net_device *dev, int new_mtu)
@@ -1895,8 +1898,9 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
        if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
                return -EINVAL;
 
+       /* TSO on Yukon Ultra and MTU > 1500 not supported */
        if (hw->chip_id == CHIP_ID_YUKON_EC_U && new_mtu > ETH_DATA_LEN)
-               return -EINVAL;
+               dev->features &= ~NETIF_F_TSO;
 
        if (!netif_running(dev)) {
                dev->mtu = new_mtu;
@@ -2452,6 +2456,7 @@ static inline u32 sky2_mhz(const struct sky2_hw *hw)
        switch (hw->chip_id) {
        case CHIP_ID_YUKON_EC:
        case CHIP_ID_YUKON_EC_U:
+       case CHIP_ID_YUKON_EX:
                return 125;     /* 125 Mhz */
        case CHIP_ID_YUKON_FE:
                return 100;     /* 100 Mhz */
@@ -2484,6 +2489,14 @@ static int __devinit sky2_init(struct sky2_hw *hw)
                return -EOPNOTSUPP;
        }
 
+       if (hw->chip_id == CHIP_ID_YUKON_EX)
+               dev_warn(&hw->pdev->dev, "this driver not yet tested on this chip type\n"
+                        "Please report success or failure to <netdev@vger.kernel.org>\n");
+
+       /* Make sure and enable all clocks */
+       if (hw->chip_id == CHIP_ID_YUKON_EX || hw->chip_id == CHIP_ID_YUKON_EC_U)
+               sky2_pci_write32(hw, PCI_DEV_REG3, 0);
+
        hw->chip_rev = (sky2_read8(hw, B2_MAC_CFG) & CFG_CHIP_R_MSK) >> 4;
 
        /* This rev is really old, and requires untested workarounds */
@@ -2512,7 +2525,13 @@ static void sky2_reset(struct sky2_hw *hw)
 
        /* disable ASF */
        if (hw->chip_id <= CHIP_ID_YUKON_EC) {
-               sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
+               if (hw->chip_id == CHIP_ID_YUKON_EX) {
+                       status = sky2_read16(hw, HCU_CCSR);
+                       status &= ~(HCU_CCSR_AHB_RST | HCU_CCSR_CPU_RST_MODE |
+                                   HCU_CCSR_UC_STATE_MSK);
+                       sky2_write16(hw, HCU_CCSR, status);
+               } else
+                       sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
                sky2_write16(hw, B0_CTST, Y2_ASF_DISABLE);
        }
 
@@ -3350,11 +3369,9 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
 
        sky2->port = port;
 
-       if (hw->chip_id != CHIP_ID_YUKON_EC_U)
-               dev->features |= NETIF_F_TSO;
+       dev->features |= NETIF_F_TSO | NETIF_F_IP_CSUM | NETIF_F_SG;
        if (highmem)
                dev->features |= NETIF_F_HIGHDMA;
-       dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
 
 #ifdef SKY2_VLAN_TAG_USED
        dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;