ar71xx: Add GRO support to ag71xx
[openwrt/openwrt.git] / target / linux / ar71xx / files / drivers / net / ethernet / atheros / ag71xx / ag71xx_main.c
index 65bc89eb0d6ae481a6a80d88b907fa5dc47a495e..ae1bdf60662d805d891e18907ac663d443955d7b 100644 (file)
@@ -456,7 +456,7 @@ static void ag71xx_hw_setup(struct ag71xx *ag)
        u32 init = MAC_CFG1_INIT;
 
        /* setup MAC configuration registers */
-       if (pdata->builtin_switch)
+       if (pdata->use_flow_control)
                init |= MAC_CFG1_TFC | MAC_CFG1_RFC;
        ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, init);
 
@@ -527,6 +527,8 @@ static void ag71xx_fast_reset(struct ag71xx *ag)
        mii_reg = ag71xx_rr(ag, AG71XX_REG_MII_CFG);
        rx_ds = ag71xx_rr(ag, AG71XX_REG_RX_DESC);
 
+       ag71xx_tx_packets(ag, true);
+
        ath79_device_reset_set(reset_mask);
        udelay(10);
        ath79_device_reset_clear(reset_mask);
@@ -534,7 +536,6 @@ static void ag71xx_fast_reset(struct ag71xx *ag)
 
        ag71xx_dma_reset(ag);
        ag71xx_hw_setup(ag);
-       ag71xx_tx_packets(ag, true);
        ag->tx_ring.curr = 0;
        ag->tx_ring.dirty = 0;
        netdev_reset_queue(ag->dev);
@@ -819,6 +820,8 @@ static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb,
 
        netdev_sent_queue(dev, skb->len);
 
+       skb_tx_timestamp(skb);
+
        desc->ctrl &= ~DESC_EMPTY;
        ring->curr += n;
 
@@ -950,6 +953,7 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
 {
        struct ag71xx_ring *ring = &ag->tx_ring;
        struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
+       bool dma_stuck = false;
        int ring_mask = BIT(ring->order) - 1;
        int ring_size = BIT(ring->order);
        int sent = 0;
@@ -965,8 +969,10 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
 
                if (!flush && !ag71xx_desc_empty(desc)) {
                        if (pdata->is_ar724x &&
-                           ag71xx_check_dma_stuck(ag, ring->buf[i].timestamp))
+                           ag71xx_check_dma_stuck(ag, ring->buf[i].timestamp)) {
                                schedule_delayed_work(&ag->restart_work, HZ / 2);
+                               dma_stuck = true;
+                       }
                        break;
                }
 
@@ -1002,7 +1008,9 @@ static int ag71xx_tx_packets(struct ag71xx *ag, bool flush)
        netdev_completed_queue(ag->dev, sent, bytes_compl);
        if ((ring->curr - ring->dirty) < (ring_size * 3) / 4)
                netif_wake_queue(ag->dev);
-       cancel_delayed_work(&ag->restart_work);
+
+       if (!dma_stuck)
+               cancel_delayed_work(&ag->restart_work);
 
        return sent;
 }
@@ -1081,7 +1089,7 @@ next:
 
        while ((skb = __skb_dequeue(&queue)) != NULL) {
                skb->protocol = eth_type_trans(skb, dev);
-               netif_receive_skb(skb);
+               napi_gro_receive(&ag->napi, skb);
        }
 
        DBG("%s: rx finish, curr=%u, dirty=%u, done=%d\n",
@@ -1133,7 +1141,7 @@ static int ag71xx_poll(struct napi_struct *napi, int limit)
                DBG("%s: disable polling mode, rx=%d, tx=%d,limit=%d\n",
                        dev->name, rx_done, tx_done, limit);
 
-               napi_complete(napi);
+               napi_complete_done(napi, rx_done);
 
                /* enable interrupts */
                spin_lock_irqsave(&ag->lock, flags);
@@ -1152,7 +1160,7 @@ oom:
                pr_info("%s: out of memory\n", dev->name);
 
        mod_timer(&ag->oom_timer, jiffies + AG71XX_OOM_REFILL);
-       napi_complete(napi);
+       napi_complete_done(napi, rx_done);
        return 0;
 }