aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sky2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sky2.c')
-rw-r--r--drivers/net/sky2.c176
1 files changed, 110 insertions, 66 deletions
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 4a009b7b1777..ac36152c68bf 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -49,7 +49,7 @@
49#include "sky2.h" 49#include "sky2.h"
50 50
51#define DRV_NAME "sky2" 51#define DRV_NAME "sky2"
52#define DRV_VERSION "1.13" 52#define DRV_VERSION "1.14"
53#define PFX DRV_NAME " " 53#define PFX DRV_NAME " "
54 54
55/* 55/*
@@ -123,7 +123,10 @@ static const struct pci_device_id sky2_id_table[] = {
123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */ 123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */
124 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, /* 88E8053 */ 124 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, /* 88E8053 */
125 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, /* 88E8055 */ 125 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, /* 88E8055 */
126#ifdef broken
127 /* This device causes data corruption problems that are not resolved */
126 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, /* 88E8056 */ 128 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, /* 88E8056 */
129#endif
127 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, /* 88EC036 */ 130 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, /* 88EC036 */
128 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, /* 88EC032 */ 131 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, /* 88EC032 */
129 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */ 132 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */
@@ -740,12 +743,17 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
740 if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) { 743 if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) {
741 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8); 744 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8);
742 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8); 745 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
743 if (hw->dev[port]->mtu > ETH_DATA_LEN) { 746
744 /* set Tx GMAC FIFO Almost Empty Threshold */ 747 /* set Tx GMAC FIFO Almost Empty Threshold */
745 sky2_write32(hw, SK_REG(port, TX_GMF_AE_THR), 0x180); 748 sky2_write32(hw, SK_REG(port, TX_GMF_AE_THR),
746 /* Disable Store & Forward mode for TX */ 749 (ECU_JUMBO_WM << 16) | ECU_AE_THR);
747 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_STFW_DIS); 750
748 } 751 if (hw->dev[port]->mtu > ETH_DATA_LEN)
752 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
753 TX_JUMBO_ENA | TX_STFW_DIS);
754 else
755 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
756 TX_JUMBO_DIS | TX_STFW_ENA);
749 } 757 }
750 758
751} 759}
@@ -1278,7 +1286,7 @@ static int sky2_up(struct net_device *dev)
1278 /* Set almost empty threshold */ 1286 /* Set almost empty threshold */
1279 if (hw->chip_id == CHIP_ID_YUKON_EC_U 1287 if (hw->chip_id == CHIP_ID_YUKON_EC_U
1280 && hw->chip_rev == CHIP_REV_YU_EC_U_A0) 1288 && hw->chip_rev == CHIP_REV_YU_EC_U_A0)
1281 sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), 0x1a0); 1289 sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), ECU_TXFF_LEV);
1282 1290
1283 sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map, 1291 sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map,
1284 TX_RING_SIZE - 1); 1292 TX_RING_SIZE - 1);
@@ -1584,13 +1592,6 @@ static int sky2_down(struct net_device *dev)
1584 sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL), 1592 sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL),
1585 RB_RST_SET | RB_DIS_OP_MD); 1593 RB_RST_SET | RB_DIS_OP_MD);
1586 1594
1587 /* WA for dev. #4.209 */
1588 if (hw->chip_id == CHIP_ID_YUKON_EC_U
1589 && (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
1590 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1591 sky2->speed != SPEED_1000 ?
1592 TX_STFW_ENA : TX_STFW_DIS);
1593
1594 ctrl = gma_read16(hw, port, GM_GP_CTRL); 1595 ctrl = gma_read16(hw, port, GM_GP_CTRL);
1595 ctrl &= ~(GM_GPCR_TX_ENA | GM_GPCR_RX_ENA); 1596 ctrl &= ~(GM_GPCR_TX_ENA | GM_GPCR_RX_ENA);
1596 gma_write16(hw, port, GM_GP_CTRL, ctrl); 1597 gma_write16(hw, port, GM_GP_CTRL, ctrl);
@@ -1890,6 +1891,7 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1890{ 1891{
1891 struct sky2_port *sky2 = netdev_priv(dev); 1892 struct sky2_port *sky2 = netdev_priv(dev);
1892 struct sky2_hw *hw = sky2->hw; 1893 struct sky2_hw *hw = sky2->hw;
1894 unsigned port = sky2->port;
1893 int err; 1895 int err;
1894 u16 ctl, mode; 1896 u16 ctl, mode;
1895 u32 imask; 1897 u32 imask;
@@ -1897,9 +1899,8 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1897 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) 1899 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
1898 return -EINVAL; 1900 return -EINVAL;
1899 1901
1900 /* TSO on Yukon Ultra and MTU > 1500 not supported */ 1902 if (new_mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_FE)
1901 if (hw->chip_id == CHIP_ID_YUKON_EC_U && new_mtu > ETH_DATA_LEN) 1903 return -EINVAL;
1902 dev->features &= ~NETIF_F_TSO;
1903 1904
1904 if (!netif_running(dev)) { 1905 if (!netif_running(dev)) {
1905 dev->mtu = new_mtu; 1906 dev->mtu = new_mtu;
@@ -1915,8 +1916,18 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1915 1916
1916 synchronize_irq(hw->pdev->irq); 1917 synchronize_irq(hw->pdev->irq);
1917 1918
1918 ctl = gma_read16(hw, sky2->port, GM_GP_CTRL); 1919 if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) {
1919 gma_write16(hw, sky2->port, GM_GP_CTRL, ctl & ~GM_GPCR_RX_ENA); 1920 if (new_mtu > ETH_DATA_LEN) {
1921 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1922 TX_JUMBO_ENA | TX_STFW_DIS);
1923 dev->features &= NETIF_F_TSO | NETIF_F_SG | NETIF_F_IP_CSUM;
1924 } else
1925 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1926 TX_JUMBO_DIS | TX_STFW_ENA);
1927 }
1928
1929 ctl = gma_read16(hw, port, GM_GP_CTRL);
1930 gma_write16(hw, port, GM_GP_CTRL, ctl & ~GM_GPCR_RX_ENA);
1920 sky2_rx_stop(sky2); 1931 sky2_rx_stop(sky2);
1921 sky2_rx_clean(sky2); 1932 sky2_rx_clean(sky2);
1922 1933
@@ -1928,9 +1939,9 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1928 if (dev->mtu > ETH_DATA_LEN) 1939 if (dev->mtu > ETH_DATA_LEN)
1929 mode |= GM_SMOD_JUMBO_ENA; 1940 mode |= GM_SMOD_JUMBO_ENA;
1930 1941
1931 gma_write16(hw, sky2->port, GM_SERIAL_MODE, mode); 1942 gma_write16(hw, port, GM_SERIAL_MODE, mode);
1932 1943
1933 sky2_write8(hw, RB_ADDR(rxqaddr[sky2->port], RB_CTRL), RB_ENA_OP_MD); 1944 sky2_write8(hw, RB_ADDR(rxqaddr[port], RB_CTRL), RB_ENA_OP_MD);
1934 1945
1935 err = sky2_rx_start(sky2); 1946 err = sky2_rx_start(sky2);
1936 sky2_write32(hw, B0_IMSK, imask); 1947 sky2_write32(hw, B0_IMSK, imask);
@@ -1938,7 +1949,7 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1938 if (err) 1949 if (err)
1939 dev_close(dev); 1950 dev_close(dev);
1940 else { 1951 else {
1941 gma_write16(hw, sky2->port, GM_GP_CTRL, ctl); 1952 gma_write16(hw, port, GM_GP_CTRL, ctl);
1942 1953
1943 netif_poll_enable(hw->dev[0]); 1954 netif_poll_enable(hw->dev[0]);
1944 netif_wake_queue(dev); 1955 netif_wake_queue(dev);
@@ -2340,26 +2351,22 @@ static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
2340 } 2351 }
2341} 2352}
2342 2353
2343/* This should never happen it is a fatal situation */ 2354/* This should never happen it is a bug. */
2344static void sky2_descriptor_error(struct sky2_hw *hw, unsigned port, 2355static void sky2_le_error(struct sky2_hw *hw, unsigned port,
2345 const char *rxtx, u32 mask) 2356 u16 q, unsigned ring_size)
2346{ 2357{
2347 struct net_device *dev = hw->dev[port]; 2358 struct net_device *dev = hw->dev[port];
2348 struct sky2_port *sky2 = netdev_priv(dev); 2359 struct sky2_port *sky2 = netdev_priv(dev);
2349 u32 imask; 2360 unsigned idx;
2350 2361 const u64 *le = (q == Q_R1 || q == Q_R2)
2351 printk(KERN_ERR PFX "%s: %s descriptor error (hardware problem)\n", 2362 ? (u64 *) sky2->rx_le : (u64 *) sky2->tx_le;
2352 dev ? dev->name : "<not registered>", rxtx);
2353 2363
2354 imask = sky2_read32(hw, B0_IMSK); 2364 idx = sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_GET_IDX));
2355 imask &= ~mask; 2365 printk(KERN_ERR PFX "%s: descriptor error q=%#x get=%u [%llx] put=%u\n",
2356 sky2_write32(hw, B0_IMSK, imask); 2366 dev->name, (unsigned) q, idx, (unsigned long long) le[idx],
2367 (unsigned) sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX)));
2357 2368
2358 if (dev) { 2369 sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_CLR_IRQ_CHK);
2359 spin_lock(&sky2->phy_lock);
2360 sky2_link_down(sky2);
2361 spin_unlock(&sky2->phy_lock);
2362 }
2363} 2370}
2364 2371
2365/* If idle then force a fake soft NAPI poll once a second 2372/* If idle then force a fake soft NAPI poll once a second
@@ -2383,23 +2390,15 @@ static void sky2_idle(unsigned long arg)
2383 mod_timer(&hw->idle_timer, jiffies + msecs_to_jiffies(idle_timeout)); 2390 mod_timer(&hw->idle_timer, jiffies + msecs_to_jiffies(idle_timeout));
2384} 2391}
2385 2392
2386 2393/* Hardware/software error handling */
2387static int sky2_poll(struct net_device *dev0, int *budget) 2394static void sky2_err_intr(struct sky2_hw *hw, u32 status)
2388{ 2395{
2389 struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw; 2396 if (net_ratelimit())
2390 int work_limit = min(dev0->quota, *budget); 2397 dev_warn(&hw->pdev->dev, "error interrupt status=%#x\n", status);
2391 int work_done = 0;
2392 u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
2393 2398
2394 if (status & Y2_IS_HW_ERR) 2399 if (status & Y2_IS_HW_ERR)
2395 sky2_hw_intr(hw); 2400 sky2_hw_intr(hw);
2396 2401
2397 if (status & Y2_IS_IRQ_PHY1)
2398 sky2_phy_intr(hw, 0);
2399
2400 if (status & Y2_IS_IRQ_PHY2)
2401 sky2_phy_intr(hw, 1);
2402
2403 if (status & Y2_IS_IRQ_MAC1) 2402 if (status & Y2_IS_IRQ_MAC1)
2404 sky2_mac_intr(hw, 0); 2403 sky2_mac_intr(hw, 0);
2405 2404
@@ -2407,16 +2406,33 @@ static int sky2_poll(struct net_device *dev0, int *budget)
2407 sky2_mac_intr(hw, 1); 2406 sky2_mac_intr(hw, 1);
2408 2407
2409 if (status & Y2_IS_CHK_RX1) 2408 if (status & Y2_IS_CHK_RX1)
2410 sky2_descriptor_error(hw, 0, "receive", Y2_IS_CHK_RX1); 2409 sky2_le_error(hw, 0, Q_R1, RX_LE_SIZE);
2411 2410
2412 if (status & Y2_IS_CHK_RX2) 2411 if (status & Y2_IS_CHK_RX2)
2413 sky2_descriptor_error(hw, 1, "receive", Y2_IS_CHK_RX2); 2412 sky2_le_error(hw, 1, Q_R2, RX_LE_SIZE);
2414 2413
2415 if (status & Y2_IS_CHK_TXA1) 2414 if (status & Y2_IS_CHK_TXA1)
2416 sky2_descriptor_error(hw, 0, "transmit", Y2_IS_CHK_TXA1); 2415 sky2_le_error(hw, 0, Q_XA1, TX_RING_SIZE);
2417 2416
2418 if (status & Y2_IS_CHK_TXA2) 2417 if (status & Y2_IS_CHK_TXA2)
2419 sky2_descriptor_error(hw, 1, "transmit", Y2_IS_CHK_TXA2); 2418 sky2_le_error(hw, 1, Q_XA2, TX_RING_SIZE);
2419}
2420
2421static int sky2_poll(struct net_device *dev0, int *budget)
2422{
2423 struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw;
2424 int work_limit = min(dev0->quota, *budget);
2425 int work_done = 0;
2426 u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
2427
2428 if (unlikely(status & Y2_IS_ERROR))
2429 sky2_err_intr(hw, status);
2430
2431 if (status & Y2_IS_IRQ_PHY1)
2432 sky2_phy_intr(hw, 0);
2433
2434 if (status & Y2_IS_IRQ_PHY2)
2435 sky2_phy_intr(hw, 1);
2420 2436
2421 work_done = sky2_status_intr(hw, work_limit); 2437 work_done = sky2_status_intr(hw, work_limit);
2422 if (work_done < work_limit) { 2438 if (work_done < work_limit) {
@@ -2534,16 +2550,14 @@ static void sky2_reset(struct sky2_hw *hw)
2534 int i; 2550 int i;
2535 2551
2536 /* disable ASF */ 2552 /* disable ASF */
2537 if (hw->chip_id <= CHIP_ID_YUKON_EC) { 2553 if (hw->chip_id == CHIP_ID_YUKON_EX) {
2538 if (hw->chip_id == CHIP_ID_YUKON_EX) { 2554 status = sky2_read16(hw, HCU_CCSR);
2539 status = sky2_read16(hw, HCU_CCSR); 2555 status &= ~(HCU_CCSR_AHB_RST | HCU_CCSR_CPU_RST_MODE |
2540 status &= ~(HCU_CCSR_AHB_RST | HCU_CCSR_CPU_RST_MODE | 2556 HCU_CCSR_UC_STATE_MSK);
2541 HCU_CCSR_UC_STATE_MSK); 2557 sky2_write16(hw, HCU_CCSR, status);
2542 sky2_write16(hw, HCU_CCSR, status); 2558 } else
2543 } else 2559 sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
2544 sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); 2560 sky2_write16(hw, B0_CTST, Y2_ASF_DISABLE);
2545 sky2_write16(hw, B0_CTST, Y2_ASF_DISABLE);
2546 }
2547 2561
2548 /* do a SW reset */ 2562 /* do a SW reset */
2549 sky2_write8(hw, B0_CTST, CS_RST_SET); 2563 sky2_write8(hw, B0_CTST, CS_RST_SET);
@@ -3328,6 +3342,36 @@ static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
3328 regs->len - B3_RI_WTO_R1); 3342 regs->len - B3_RI_WTO_R1);
3329} 3343}
3330 3344
3345/* In order to do Jumbo packets on these chips, need to turn off the
3346 * transmit store/forward. Therefore checksum offload won't work.
3347 */
3348static int no_tx_offload(struct net_device *dev)
3349{
3350 const struct sky2_port *sky2 = netdev_priv(dev);
3351 const struct sky2_hw *hw = sky2->hw;
3352
3353 return dev->mtu > ETH_DATA_LEN &&
3354 (hw->chip_id == CHIP_ID_YUKON_EX
3355 || hw->chip_id == CHIP_ID_YUKON_EC_U);
3356}
3357
3358static int sky2_set_tx_csum(struct net_device *dev, u32 data)
3359{
3360 if (data && no_tx_offload(dev))
3361 return -EINVAL;
3362
3363 return ethtool_op_set_tx_csum(dev, data);
3364}
3365
3366
3367static int sky2_set_tso(struct net_device *dev, u32 data)
3368{
3369 if (data && no_tx_offload(dev))
3370 return -EINVAL;
3371
3372 return ethtool_op_set_tso(dev, data);
3373}
3374
3331static const struct ethtool_ops sky2_ethtool_ops = { 3375static const struct ethtool_ops sky2_ethtool_ops = {
3332 .get_settings = sky2_get_settings, 3376 .get_settings = sky2_get_settings,
3333 .set_settings = sky2_set_settings, 3377 .set_settings = sky2_set_settings,
@@ -3343,9 +3387,9 @@ static const struct ethtool_ops sky2_ethtool_ops = {
3343 .get_sg = ethtool_op_get_sg, 3387 .get_sg = ethtool_op_get_sg,
3344 .set_sg = ethtool_op_set_sg, 3388 .set_sg = ethtool_op_set_sg,
3345 .get_tx_csum = ethtool_op_get_tx_csum, 3389 .get_tx_csum = ethtool_op_get_tx_csum,
3346 .set_tx_csum = ethtool_op_set_tx_csum, 3390 .set_tx_csum = sky2_set_tx_csum,
3347 .get_tso = ethtool_op_get_tso, 3391 .get_tso = ethtool_op_get_tso,
3348 .set_tso = ethtool_op_set_tso, 3392 .set_tso = sky2_set_tso,
3349 .get_rx_csum = sky2_get_rx_csum, 3393 .get_rx_csum = sky2_get_rx_csum,
3350 .set_rx_csum = sky2_set_rx_csum, 3394 .set_rx_csum = sky2_set_rx_csum,
3351 .get_strings = sky2_get_strings, 3395 .get_strings = sky2_get_strings,