cns3xxx: ethernet - clean the tx ring before refilling the rx ring to reduce memory...
[librecmc/librecmc.git] / target / linux / cns3xxx / files / drivers / net / ethernet / cavium / cns3xxx_eth.c
index c9040b1647f1dc675f238f401089112ba7d76823..db15a2e2e50d8f664c8ebd757dc9352f0ee1289d 100644 (file)
@@ -26,7 +26,7 @@
 
 #define DRV_NAME "cns3xxx_eth"
 
-#define RX_DESCS 128
+#define RX_DESCS 256
 #define TX_DESCS 128
 #define TX_DESC_RESERVE        20
 
@@ -436,14 +436,20 @@ static void cns3xxx_adjust_link(struct net_device *dev)
               dev->name, port->speed, port->duplex ? "full" : "half");
 }
 
+static void eth_schedule_poll(struct sw *sw)
+{
+       if (unlikely(!napi_schedule_prep(&sw->napi)))
+               return;
+
+       disable_irq_nosync(IRQ_CNS3XXX_SW_R0RXC);
+       __napi_schedule(&sw->napi);
+}
+
 irqreturn_t eth_rx_irq(int irq, void *pdev)
 {
        struct net_device *dev = pdev;
        struct sw *sw = netdev_priv(dev);
-       if (likely(napi_schedule_prep(&sw->napi))) {
-               disable_irq_nosync(IRQ_CNS3XXX_SW_R0RXC);
-               __napi_schedule(&sw->napi);
-       }
+       eth_schedule_poll(sw);
        return (IRQ_HANDLED);
 }
 
@@ -712,6 +718,10 @@ static int eth_poll(struct napi_struct *napi, int budget)
                enable_irq(IRQ_CNS3XXX_SW_R0RXC);
        }
 
+       spin_lock_bh(&tx_lock);
+       eth_complete_tx(sw);
+       spin_unlock_bh(&tx_lock);
+
        cns3xxx_alloc_rx_buf(sw, received);
 
        rx_ring->cur_index = i;
@@ -719,10 +729,6 @@ static int eth_poll(struct napi_struct *napi, int budget)
        wmb();
        enable_rx_dma(sw);
 
-       spin_lock_bh(&tx_lock);
-       eth_complete_tx(sw);
-       spin_unlock_bh(&tx_lock);
-
        return received;
 }
 
@@ -767,9 +773,8 @@ static int eth_xmit(struct sk_buff *skb, struct net_device *dev)
        skb_walk_frags(skb, skb1)
                nr_desc++;
 
+       eth_schedule_poll(sw);
        spin_lock_bh(&tx_lock);
-
-       eth_complete_tx(sw);
        if ((tx_ring->num_used + nr_desc + 1) >= TX_DESCS) {
                spin_unlock_bh(&tx_lock);
                return NETDEV_TX_BUSY;