#define DRV_NAME "cns3xxx_eth"
-#define RX_DESCS 128
+#define RX_DESCS 256
#define TX_DESCS 128
#define TX_DESC_RESERVE 20
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);
}
}
}
-static void eth_complete_tx(struct sw *sw)
+static int eth_complete_tx(struct sw *sw)
{
struct _tx_ring *tx_ring = &sw->tx_ring;
struct tx_desc *desc;
tx_ring->free_index = index;
tx_ring->num_used -= i;
eth_check_num_used(tx_ring);
+
+ return TX_DESCS - tx_ring->num_used;
}
static int eth_poll(struct napi_struct *napi, int budget)
unsigned int length;
unsigned int i = rx_ring->cur_index;
struct rx_desc *desc = &(rx_ring)->desc[i];
+ unsigned int alloc_count = rx_ring->alloc_count;
- while (desc->cown) {
+ while (desc->cown && alloc_count + received < RX_DESCS - 1) {
struct sk_buff *skb;
int reserve = SKB_HEAD_ALIGN;
}
}
+ rx_ring->cur_index = i;
if (!received) {
napi_complete(napi);
enable_irq(IRQ_CNS3XXX_SW_R0RXC);
+
+ /* if rx descriptors are full schedule another poll */
+ if (rx_ring->desc[(i-1) & (RX_DESCS-1)].cown)
+ eth_schedule_poll(sw);
}
- cns3xxx_alloc_rx_buf(sw, received);
+ spin_lock_bh(&tx_lock);
+ eth_complete_tx(sw);
+ spin_unlock_bh(&tx_lock);
- rx_ring->cur_index = i;
+ cns3xxx_alloc_rx_buf(sw, received);
wmb();
enable_rx_dma(sw);
- spin_lock_bh(&tx_lock);
- eth_complete_tx(sw);
- spin_unlock_bh(&tx_lock);
-
return received;
}
nr_desc++;
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;
+ /* clean up tx descriptors when needed */
+ if (eth_complete_tx(sw) < nr_desc) {
+ spin_unlock_bh(&tx_lock);
+ return NETDEV_TX_BUSY;
+ }
}
index = index0 = tx_ring->cur_index;