ar71xx: disable flow control for ar724x, it can get stuck in a loop of continously...
[openwrt/openwrt.git] / target / linux / ar71xx / files / drivers / net / ag71xx / ag71xx_main.c
index fc838f4..08735a9 100644 (file)
 #include "ag71xx.h"
 
 #define AG71XX_DEFAULT_MSG_ENABLE      \
-       ( NETIF_MSG_DRV                 \
+       (NETIF_MSG_DRV                  \
        | NETIF_MSG_PROBE               \
        | NETIF_MSG_LINK                \
        | NETIF_MSG_TIMER               \
        | NETIF_MSG_IFDOWN              \
        | NETIF_MSG_IFUP                \
        | NETIF_MSG_RX_ERR              \
-       | NETIF_MSG_TX_ERR )
+       | NETIF_MSG_TX_ERR)
 
 static int ag71xx_msg_level = -1;
 
@@ -119,14 +119,15 @@ static int ag71xx_ring_alloc(struct ag71xx_ring *ring, unsigned int size)
        }
 
        for (i = 0; i < size; i++) {
-               ring->buf[i].desc = (struct ag71xx_desc *)&ring->descs_cpu[i * ring->desc_size];
+               int idx = i * ring->desc_size;
+               ring->buf[i].desc = (struct ag71xx_desc *)&ring->descs_cpu[idx];
                DBG("ag71xx: ring %p, desc %d at %p\n",
                        ring, i, ring->buf[i].desc);
        }
 
        return 0;
 
- err:
+err:
        return err;
 }
 
@@ -523,11 +524,7 @@ static void ag71xx_hw_init(struct ag71xx *ag)
        mdelay(100);
 
        /* setup MAC configuration registers */
-       if (pdata->is_ar724x)
-               ag71xx_wr(ag, AG71XX_REG_MAC_CFG1,
-                         MAC_CFG1_INIT | MAC_CFG1_TFC | MAC_CFG1_RFC);
-       else
-               ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, MAC_CFG1_INIT);
+       ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, MAC_CFG1_INIT);
 
        ag71xx_sb(ag, AG71XX_REG_MAC_CFG2,
                  MAC_CFG2_PAD_CRC_EN | MAC_CFG2_LEN_CHECK);
@@ -573,16 +570,12 @@ static void ag71xx_hw_stop(struct ag71xx *ag)
 static int ag71xx_open(struct net_device *dev)
 {
        struct ag71xx *ag = netdev_priv(dev);
-       struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
        int ret;
 
        ret = ag71xx_rings_init(ag);
        if (ret)
                goto err;
 
-       if (pdata->is_ar724x)
-               ag71xx_hw_init(ag);
-
        napi_enable(&ag->napi);
 
        netif_carrier_off(dev);
@@ -599,7 +592,7 @@ static int ag71xx_open(struct net_device *dev)
 
        return 0;
 
- err:
+err:
        ag71xx_rings_cleanup(ag);
        return ret;
 }
@@ -655,6 +648,7 @@ static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb,
                                  DMA_TO_DEVICE);
 
        ring->buf[i].skb = skb;
+       ring->buf[i].timestamp = jiffies;
 
        /* setup descriptor fields */
        desc->data = (u32) dma_addr;
@@ -676,7 +670,7 @@ static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb,
 
        return NETDEV_TX_OK;
 
- err_drop:
+err_drop:
        dev->stats.tx_dropped++;
 
        dev_kfree_skb(skb);
@@ -685,7 +679,6 @@ static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb,
 
 static int ag71xx_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 {
-       struct mii_ioctl_data *data = (struct mii_ioctl_data *) &ifr->ifr_data;
        struct ag71xx *ag = netdev_priv(dev);
        int ret;
 
@@ -717,7 +710,7 @@ static int ag71xx_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
                if (ag->phy_dev == NULL)
                        break;
 
-               return phy_mii_ioctl(ag->phy_dev, data, cmd);
+               return phy_mii_ioctl(ag->phy_dev, ifr, cmd);
 
        default:
                break;
@@ -747,8 +740,13 @@ static void ag71xx_tx_timeout(struct net_device *dev)
 static void ag71xx_restart_work_func(struct work_struct *work)
 {
        struct ag71xx *ag = container_of(work, struct ag71xx, restart_work);
+       struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
 
        ag71xx_stop(ag->dev);
+
+       if (pdata->is_ar724x)
+               ag71xx_hw_init(ag);
+
        ag71xx_open(ag->dev);
 }
 
@@ -909,12 +907,12 @@ static int ag71xx_poll(struct napi_struct *napi, int limit)
                return rx_done;
        }
 
- more:
+more:
        DBG("%s: stay in polling mode, rx=%d, tx=%d, limit=%d\n",
                        dev->name, rx_done, tx_done, limit);
        return rx_done;
 
- oom:
+oom:
        if (netif_msg_rx_err(ag))
                printk(KERN_DEBUG "%s: out of memory\n", dev->name);
 
@@ -991,7 +989,7 @@ static const struct net_device_ops ag71xx_netdev_ops = {
 #endif
 };
 
-static int __init ag71xx_probe(struct platform_device *pdev)
+static int __devinit ag71xx_probe(struct platform_device *pdev)
 {
        struct net_device *dev;
        struct resource *res;
@@ -1058,7 +1056,7 @@ static int __init ag71xx_probe(struct platform_device *pdev)
 
        dev->irq = platform_get_irq(pdev, 0);
        err = request_irq(dev->irq, ag71xx_interrupt,
-                         IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
+                         IRQF_DISABLED,
                          dev->name, dev);
        if (err) {
                dev_err(&pdev->dev, "unable to request IRQ %d\n", dev->irq);
@@ -1106,24 +1104,24 @@ static int __init ag71xx_probe(struct platform_device *pdev)
 
        return 0;
 
- err_phy_disconnect:
+err_phy_disconnect:
        ag71xx_phy_disconnect(ag);
- err_unregister_netdev:
+err_unregister_netdev:
        unregister_netdev(dev);
- err_free_irq:
+err_free_irq:
        free_irq(dev->irq, dev);
- err_unmap_mii_ctrl:
+err_unmap_mii_ctrl:
        iounmap(ag->mii_ctrl);
- err_unmap_base:
+err_unmap_base:
        iounmap(ag->mac_base);
- err_free_dev:
+err_free_dev:
        kfree(dev);
- err_out:
+err_out:
        platform_set_drvdata(pdev, NULL);
        return err;
 }
 
-static int __exit ag71xx_remove(struct platform_device *pdev)
+static int __devexit ag71xx_remove(struct platform_device *pdev)
 {
        struct net_device *dev = platform_get_drvdata(pdev);
 
@@ -1169,11 +1167,11 @@ static int __init ag71xx_module_init(void)
 
        return 0;
 
- err_mdio_exit:
+err_mdio_exit:
        ag71xx_mdio_driver_exit();
- err_debugfs_exit:
+err_debugfs_exit:
        ag71xx_debugfs_root_exit();
- err_out:
+err_out:
        return ret;
 }