diff options
-rw-r--r-- | drivers/net/ethernet/cadence/macb.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index edb2aba9045c..27991ddb6ff0 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/moduleparam.h> | 14 | #include <linux/moduleparam.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
17 | #include <linux/circ_buf.h> | ||
17 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
18 | #include <linux/init.h> | 19 | #include <linux/init.h> |
19 | #include <linux/gpio.h> | 20 | #include <linux/gpio.h> |
@@ -38,8 +39,8 @@ | |||
38 | #define TX_RING_SIZE 128 /* must be power of 2 */ | 39 | #define TX_RING_SIZE 128 /* must be power of 2 */ |
39 | #define TX_RING_BYTES (sizeof(struct macb_dma_desc) * TX_RING_SIZE) | 40 | #define TX_RING_BYTES (sizeof(struct macb_dma_desc) * TX_RING_SIZE) |
40 | 41 | ||
41 | /* minimum number of free TX descriptors before waking up TX process */ | 42 | /* level of occupied TX descriptors under which we wake up TX process */ |
42 | #define MACB_TX_WAKEUP_THRESH (TX_RING_SIZE / 4) | 43 | #define MACB_TX_WAKEUP_THRESH (3 * TX_RING_SIZE / 4) |
43 | 44 | ||
44 | #define MACB_RX_INT_FLAGS (MACB_BIT(RCOMP) | MACB_BIT(RXUBR) \ | 45 | #define MACB_RX_INT_FLAGS (MACB_BIT(RCOMP) | MACB_BIT(RXUBR) \ |
45 | | MACB_BIT(ISR_ROVR)) | 46 | | MACB_BIT(ISR_ROVR)) |
@@ -60,11 +61,6 @@ static unsigned int macb_tx_ring_wrap(unsigned int index) | |||
60 | return index & (TX_RING_SIZE - 1); | 61 | return index & (TX_RING_SIZE - 1); |
61 | } | 62 | } |
62 | 63 | ||
63 | static unsigned int macb_tx_ring_avail(struct macb *bp) | ||
64 | { | ||
65 | return (bp->tx_tail - bp->tx_head) & (TX_RING_SIZE - 1); | ||
66 | } | ||
67 | |||
68 | static struct macb_dma_desc *macb_tx_desc(struct macb *bp, unsigned int index) | 64 | static struct macb_dma_desc *macb_tx_desc(struct macb *bp, unsigned int index) |
69 | { | 65 | { |
70 | return &bp->tx_ring[macb_tx_ring_wrap(index)]; | 66 | return &bp->tx_ring[macb_tx_ring_wrap(index)]; |
@@ -524,7 +520,8 @@ static void macb_tx_interrupt(struct macb *bp) | |||
524 | 520 | ||
525 | bp->tx_tail = tail; | 521 | bp->tx_tail = tail; |
526 | if (netif_queue_stopped(bp->dev) | 522 | if (netif_queue_stopped(bp->dev) |
527 | && macb_tx_ring_avail(bp) > MACB_TX_WAKEUP_THRESH) | 523 | && CIRC_CNT(bp->tx_head, bp->tx_tail, |
524 | TX_RING_SIZE) <= MACB_TX_WAKEUP_THRESH) | ||
528 | netif_wake_queue(bp->dev); | 525 | netif_wake_queue(bp->dev); |
529 | } | 526 | } |
530 | 527 | ||
@@ -818,7 +815,7 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
818 | spin_lock_irqsave(&bp->lock, flags); | 815 | spin_lock_irqsave(&bp->lock, flags); |
819 | 816 | ||
820 | /* This is a hard error, log it. */ | 817 | /* This is a hard error, log it. */ |
821 | if (macb_tx_ring_avail(bp) < 1) { | 818 | if (CIRC_SPACE(bp->tx_head, bp->tx_tail, TX_RING_SIZE) < 1) { |
822 | netif_stop_queue(dev); | 819 | netif_stop_queue(dev); |
823 | spin_unlock_irqrestore(&bp->lock, flags); | 820 | spin_unlock_irqrestore(&bp->lock, flags); |
824 | netdev_err(bp->dev, "BUG! Tx Ring full when queue awake!\n"); | 821 | netdev_err(bp->dev, "BUG! Tx Ring full when queue awake!\n"); |
@@ -855,7 +852,7 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
855 | 852 | ||
856 | macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TSTART)); | 853 | macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TSTART)); |
857 | 854 | ||
858 | if (macb_tx_ring_avail(bp) < 1) | 855 | if (CIRC_SPACE(bp->tx_head, bp->tx_tail, TX_RING_SIZE) < 1) |
859 | netif_stop_queue(dev); | 856 | netif_stop_queue(dev); |
860 | 857 | ||
861 | spin_unlock_irqrestore(&bp->lock, flags); | 858 | spin_unlock_irqrestore(&bp->lock, flags); |