We already clean up tx descriptors in the napi eth_poll() function so it
would likely be rare to run out of available descriptors in eth_xmit. Thus
we can clean them up only when needed and return busy only when we
still don't have enough.
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@39762
3c298f89-4303-0410-b956-
a3cf2f4a3e73
-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;
{
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);
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)
}
static int eth_poll(struct napi_struct *napi, int budget)
skb_walk_frags(skb, skb1)
nr_desc++;
skb_walk_frags(skb, skb1)
nr_desc++;
spin_lock_bh(&tx_lock);
if ((tx_ring->num_used + nr_desc + 1) >= TX_DESCS) {
spin_lock_bh(&tx_lock);
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;
}
index = index0 = tx_ring->cur_index;