ar71xx: remove obsolete '< KERNEL_VERSION(4, 2, 0)' check
[openwrt/openwrt.git] / target / linux / ar71xx / files / drivers / net / ethernet / atheros / ag71xx / ag71xx_main.c
index fc91b9f060a72434ae3a63dd7b1075071fdfa6ac..93f8c5305d1f988255ee1a5045c6123d18f1acd9 100644 (file)
 
 #include "ag71xx.h"
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
-static inline void skb_free_frag(void *data)
-{
-       put_page(virt_to_head_page(data));
-}
-#endif
-
 #define AG71XX_DEFAULT_MSG_ENABLE      \
        (NETIF_MSG_DRV                  \
        | NETIF_MSG_PROBE               \
@@ -527,6 +520,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 +529,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);
@@ -628,6 +622,22 @@ __ag71xx_link_adjust(struct ag71xx *ag, bool update)
        ag71xx_wr(ag, AG71XX_REG_MAC_CFG2, cfg2);
        ag71xx_wr(ag, AG71XX_REG_FIFO_CFG5, fifo5);
        ag71xx_wr(ag, AG71XX_REG_MAC_IFCTL, ifctl);
+
+       if (pdata->disable_inline_checksum_engine) {
+               /*
+                * The rx ring buffer can stall on small packets on QCA953x and
+                * QCA956x. Disabling the inline checksum engine fixes the stall.
+                * The wr, rr functions cannot be used since this hidden register
+                * is outside of the normal ag71xx register block.
+                */
+               void __iomem *dam = ioremap_nocache(0xb90001bc, 0x4);
+               if (dam) {
+                       __raw_writel(__raw_readl(dam) & ~BIT(27), dam);
+                       (void)__raw_readl(dam);
+                       iounmap(dam);
+               }
+       }
+
        ag71xx_hw_start(ag);
 
        netif_carrier_on(ag->dev);
@@ -819,6 +829,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;