aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-09-24 00:26:31 -0400
committerRusty Russell <rusty@rustcorp.com.au>2009-09-23 08:56:31 -0400
commit3c1b27d5043086a485f8526353ae9fe37bfa1065 (patch)
treee3b6eda3c66bcd1fc3af6e7fa6e4e3af77459474 /drivers/net
parentf68d24082e22ccee3077d11aeb6dc5354f0ca7f1 (diff)
virtio: make add_buf return capacity remaining
This API change means that virtio_net can tell how much capacity remains for buffers. It's necessarily fuzzy, since VIRTIO_RING_F_INDIRECT_DESC means we can fit any number of descriptors in one, *if* we can kmalloc. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Cc: Dinesh Subhraveti <dineshs@us.ibm.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/virtio_net.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 32266fb89c20..fbf04a553f5a 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -320,7 +320,7 @@ static bool try_fill_recv_maxbufs(struct virtnet_info *vi, gfp_t gfp)
320 skb_queue_head(&vi->recv, skb); 320 skb_queue_head(&vi->recv, skb);
321 321
322 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb); 322 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb);
323 if (err) { 323 if (err < 0) {
324 skb_unlink(skb, &vi->recv); 324 skb_unlink(skb, &vi->recv);
325 trim_pages(vi, skb); 325 trim_pages(vi, skb);
326 kfree_skb(skb); 326 kfree_skb(skb);
@@ -373,7 +373,7 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)
373 skb_queue_head(&vi->recv, skb); 373 skb_queue_head(&vi->recv, skb);
374 374
375 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, 1, skb); 375 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, 1, skb);
376 if (err) { 376 if (err < 0) {
377 skb_unlink(skb, &vi->recv); 377 skb_unlink(skb, &vi->recv);
378 kfree_skb(skb); 378 kfree_skb(skb);
379 break; 379 break;
@@ -527,7 +527,7 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
527 num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1; 527 num = skb_to_sgvec(skb, sg+1, 0, skb->len) + 1;
528 528
529 err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb); 529 err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb);
530 if (!err && !vi->free_in_tasklet) 530 if (err >= 0 && !vi->free_in_tasklet)
531 mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10)); 531 mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10));
532 532
533 return err; 533 return err;
@@ -538,7 +538,7 @@ static void xmit_tasklet(unsigned long data)
538 struct virtnet_info *vi = (void *)data; 538 struct virtnet_info *vi = (void *)data;
539 539
540 netif_tx_lock_bh(vi->dev); 540 netif_tx_lock_bh(vi->dev);
541 if (vi->last_xmit_skb && xmit_skb(vi, vi->last_xmit_skb) == 0) { 541 if (vi->last_xmit_skb && xmit_skb(vi, vi->last_xmit_skb) >= 0) {
542 vi->svq->vq_ops->kick(vi->svq); 542 vi->svq->vq_ops->kick(vi->svq);
543 vi->last_xmit_skb = NULL; 543 vi->last_xmit_skb = NULL;
544 } 544 }
@@ -557,7 +557,7 @@ again:
557 557
558 /* If we has a buffer left over from last time, send it now. */ 558 /* If we has a buffer left over from last time, send it now. */
559 if (unlikely(vi->last_xmit_skb) && 559 if (unlikely(vi->last_xmit_skb) &&
560 xmit_skb(vi, vi->last_xmit_skb) != 0) 560 xmit_skb(vi, vi->last_xmit_skb) < 0)
561 goto stop_queue; 561 goto stop_queue;
562 562
563 vi->last_xmit_skb = NULL; 563 vi->last_xmit_skb = NULL;
@@ -565,7 +565,7 @@ again:
565 /* Put new one in send queue and do transmit */ 565 /* Put new one in send queue and do transmit */
566 if (likely(skb)) { 566 if (likely(skb)) {
567 __skb_queue_head(&vi->send, skb); 567 __skb_queue_head(&vi->send, skb);
568 if (xmit_skb(vi, skb) != 0) { 568 if (xmit_skb(vi, skb) < 0) {
569 vi->last_xmit_skb = skb; 569 vi->last_xmit_skb = skb;
570 skb = NULL; 570 skb = NULL;
571 goto stop_queue; 571 goto stop_queue;
@@ -668,7 +668,7 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
668 sg_set_buf(&sg[i + 1], sg_virt(s), s->length); 668 sg_set_buf(&sg[i + 1], sg_virt(s), s->length);
669 sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); 669 sg_set_buf(&sg[out + in - 1], &status, sizeof(status));
670 670
671 BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi)); 671 BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) < 0);
672 672
673 vi->cvq->vq_ops->kick(vi->cvq); 673 vi->cvq->vq_ops->kick(vi->cvq);
674 674