Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347462
b: refs/heads/master
c: 9ed4cb0
h: refs/heads/master
v: v3
  • Loading branch information
Rusty Russell committed Dec 18, 2012
1 parent e3a478c commit 3333742
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7bedc7dc7c05e6072dc81da770f70c683c45da10
refs/heads/master: 9ed4cb073438e2154778f0d693d966359afd6549
33 changes: 13 additions & 20 deletions trunk/drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,11 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)
err = add_recvbuf_small(vi, gfp);

oom = err == -ENOMEM;
if (err < 0)
if (err)
break;
++vi->num;
} while (err > 0);
} while (vi->rvq->num_free);

if (unlikely(vi->num > vi->max))
vi->max = vi->num;
virtqueue_kick(vi->rvq);
Expand Down Expand Up @@ -625,27 +626,20 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct virtnet_info *vi = netdev_priv(dev);
int capacity;
int err;

/* Free up any pending old buffers before queueing new ones. */
free_old_xmit_skbs(vi);

/* Try to transmit */
capacity = xmit_skb(vi, skb);
err = xmit_skb(vi, skb);

/* This can happen with OOM and indirect buffers. */
if (unlikely(capacity < 0)) {
if (likely(capacity == -ENOMEM)) {
if (net_ratelimit())
dev_warn(&dev->dev,
"TX queue failure: out of memory\n");
} else {
dev->stats.tx_fifo_errors++;
if (net_ratelimit())
dev_warn(&dev->dev,
"Unexpected TX queue failure: %d\n",
capacity);
}
/* This should not happen! */
if (unlikely(err < 0)) {
dev->stats.tx_fifo_errors++;
if (net_ratelimit())
dev_warn(&dev->dev,
"Unexpected TX queue failure: %d\n", err);
dev->stats.tx_dropped++;
kfree_skb(skb);
return NETDEV_TX_OK;
Expand All @@ -658,13 +652,12 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)

/* Apparently nice girls don't return TX_BUSY; stop the queue
* before it gets out of hand. Naturally, this wastes entries. */
if (capacity < 2+MAX_SKB_FRAGS) {
if (vi->svq->num_free < 2+MAX_SKB_FRAGS) {
netif_stop_queue(dev);
if (unlikely(!virtqueue_enable_cb_delayed(vi->svq))) {
/* More just got used, free them then recheck. */
free_old_xmit_skbs(vi);
capacity = vi->svq->num_free;
if (capacity >= 2+MAX_SKB_FRAGS) {
if (vi->svq->num_free >= 2+MAX_SKB_FRAGS) {
netif_start_queue(dev);
virtqueue_disable_cb(vi->svq);
}
Expand Down

0 comments on commit 3333742

Please sign in to comment.