aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/virtio_net.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-05-21 20:22:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-21 20:22:52 -0400
commit1756ac3d3c41341297ea25b818b7fce505bb2a9a (patch)
tree96382220afbb82fd5c576c4c08b3c3e13282851f /drivers/net/virtio_net.c
parent98edb6ca4174f17a64890a02f44c211c8b44fb3c (diff)
parent0643e4c6e4fd67778fa886a89e6ec2320e0ff4d3 (diff)
Merge branch 'virtio' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
* 'virtio' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus: (27 commits) drivers/char: Eliminate use after free virtio: console: Accept console size along with resize control message virtio: console: Store each console's size in the console structure virtio: console: Resize console port 0 on config intr only if multiport is off virtio: console: Add support for nonblocking write()s virtio: console: Rename wait_is_over() to will_read_block() virtio: console: Don't always create a port 0 if using multiport virtio: console: Use a control message to add ports virtio: console: Move code around for future patches virtio: console: Remove config work handler virtio: console: Don't call hvc_remove() on unplugging console ports virtio: console: Return -EPIPE to hvc_console if we lost the connection virtio: console: Let host know of port or device add failures virtio: console: Add a __send_control_msg() that can send messages without a valid port virtio: Revert "virtio: disable multiport console support." virtio: add_buf_gfp trans_virtio: use virtqueue_xxx wrappers virtio-rng: use virtqueue_xxx wrappers virtio_ring: remove a level of indirection virtio_net: use virtqueue_xxx wrappers ... Fix up conflicts in drivers/net/virtio_net.c due to new virtqueue_xxx wrappers changes conflicting with some other cleanups.
Diffstat (limited to 'drivers/net/virtio_net.c')
-rw-r--r--drivers/net/virtio_net.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b0a85d038796..78eb3190b9b1 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -122,7 +122,7 @@ static void skb_xmit_done(struct virtqueue *svq)
122 struct virtnet_info *vi = svq->vdev->priv; 122 struct virtnet_info *vi = svq->vdev->priv;
123 123
124 /* Suppress further interrupts. */ 124 /* Suppress further interrupts. */
125 svq->vq_ops->disable_cb(svq); 125 virtqueue_disable_cb(svq);
126 126
127 /* We were probably waiting for more output buffers. */ 127 /* We were probably waiting for more output buffers. */
128 netif_wake_queue(vi->dev); 128 netif_wake_queue(vi->dev);
@@ -210,7 +210,7 @@ static int receive_mergeable(struct virtnet_info *vi, struct sk_buff *skb)
210 return -EINVAL; 210 return -EINVAL;
211 } 211 }
212 212
213 page = vi->rvq->vq_ops->get_buf(vi->rvq, &len); 213 page = virtqueue_get_buf(vi->rvq, &len);
214 if (!page) { 214 if (!page) {
215 pr_debug("%s: rx error: %d buffers missing\n", 215 pr_debug("%s: rx error: %d buffers missing\n",
216 skb->dev->name, hdr->mhdr.num_buffers); 216 skb->dev->name, hdr->mhdr.num_buffers);
@@ -340,7 +340,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, gfp_t gfp)
340 340
341 skb_to_sgvec(skb, vi->rx_sg + 1, 0, skb->len); 341 skb_to_sgvec(skb, vi->rx_sg + 1, 0, skb->len);
342 342
343 err = vi->rvq->vq_ops->add_buf(vi->rvq, vi->rx_sg, 0, 2, skb); 343 err = virtqueue_add_buf(vi->rvq, vi->rx_sg, 0, 2, skb);
344 if (err < 0) 344 if (err < 0)
345 dev_kfree_skb(skb); 345 dev_kfree_skb(skb);
346 346
@@ -385,7 +385,7 @@ static int add_recvbuf_big(struct virtnet_info *vi, gfp_t gfp)
385 385
386 /* chain first in list head */ 386 /* chain first in list head */
387 first->private = (unsigned long)list; 387 first->private = (unsigned long)list;
388 err = vi->rvq->vq_ops->add_buf(vi->rvq, vi->rx_sg, 0, MAX_SKB_FRAGS + 2, 388 err = virtqueue_add_buf(vi->rvq, vi->rx_sg, 0, MAX_SKB_FRAGS + 2,
389 first); 389 first);
390 if (err < 0) 390 if (err < 0)
391 give_pages(vi, first); 391 give_pages(vi, first);
@@ -404,7 +404,7 @@ static int add_recvbuf_mergeable(struct virtnet_info *vi, gfp_t gfp)
404 404
405 sg_init_one(vi->rx_sg, page_address(page), PAGE_SIZE); 405 sg_init_one(vi->rx_sg, page_address(page), PAGE_SIZE);
406 406
407 err = vi->rvq->vq_ops->add_buf(vi->rvq, vi->rx_sg, 0, 1, page); 407 err = virtqueue_add_buf(vi->rvq, vi->rx_sg, 0, 1, page);
408 if (err < 0) 408 if (err < 0)
409 give_pages(vi, page); 409 give_pages(vi, page);
410 410
@@ -433,7 +433,7 @@ static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)
433 } while (err > 0); 433 } while (err > 0);
434 if (unlikely(vi->num > vi->max)) 434 if (unlikely(vi->num > vi->max))
435 vi->max = vi->num; 435 vi->max = vi->num;
436 vi->rvq->vq_ops->kick(vi->rvq); 436 virtqueue_kick(vi->rvq);
437 return !oom; 437 return !oom;
438} 438}
439 439
@@ -442,7 +442,7 @@ static void skb_recv_done(struct virtqueue *rvq)
442 struct virtnet_info *vi = rvq->vdev->priv; 442 struct virtnet_info *vi = rvq->vdev->priv;
443 /* Schedule NAPI, Suppress further interrupts if successful. */ 443 /* Schedule NAPI, Suppress further interrupts if successful. */
444 if (napi_schedule_prep(&vi->napi)) { 444 if (napi_schedule_prep(&vi->napi)) {
445 rvq->vq_ops->disable_cb(rvq); 445 virtqueue_disable_cb(rvq);
446 __napi_schedule(&vi->napi); 446 __napi_schedule(&vi->napi);
447 } 447 }
448} 448}
@@ -471,7 +471,7 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
471 471
472again: 472again:
473 while (received < budget && 473 while (received < budget &&
474 (buf = vi->rvq->vq_ops->get_buf(vi->rvq, &len)) != NULL) { 474 (buf = virtqueue_get_buf(vi->rvq, &len)) != NULL) {
475 receive_buf(vi->dev, buf, len); 475 receive_buf(vi->dev, buf, len);
476 --vi->num; 476 --vi->num;
477 received++; 477 received++;
@@ -485,9 +485,9 @@ again:
485 /* Out of packets? */ 485 /* Out of packets? */
486 if (received < budget) { 486 if (received < budget) {
487 napi_complete(napi); 487 napi_complete(napi);
488 if (unlikely(!vi->rvq->vq_ops->enable_cb(vi->rvq)) && 488 if (unlikely(!virtqueue_enable_cb(vi->rvq)) &&
489 napi_schedule_prep(napi)) { 489 napi_schedule_prep(napi)) {
490 vi->rvq->vq_ops->disable_cb(vi->rvq); 490 virtqueue_disable_cb(vi->rvq);
491 __napi_schedule(napi); 491 __napi_schedule(napi);
492 goto again; 492 goto again;
493 } 493 }
@@ -501,7 +501,7 @@ static unsigned int free_old_xmit_skbs(struct virtnet_info *vi)
501 struct sk_buff *skb; 501 struct sk_buff *skb;
502 unsigned int len, tot_sgs = 0; 502 unsigned int len, tot_sgs = 0;
503 503
504 while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) { 504 while ((skb = virtqueue_get_buf(vi->svq, &len)) != NULL) {
505 pr_debug("Sent skb %p\n", skb); 505 pr_debug("Sent skb %p\n", skb);
506 vi->dev->stats.tx_bytes += skb->len; 506 vi->dev->stats.tx_bytes += skb->len;
507 vi->dev->stats.tx_packets++; 507 vi->dev->stats.tx_packets++;
@@ -554,7 +554,7 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb)
554 sg_set_buf(vi->tx_sg, &hdr->hdr, sizeof hdr->hdr); 554 sg_set_buf(vi->tx_sg, &hdr->hdr, sizeof hdr->hdr);
555 555
556 hdr->num_sg = skb_to_sgvec(skb, vi->tx_sg + 1, 0, skb->len) + 1; 556 hdr->num_sg = skb_to_sgvec(skb, vi->tx_sg + 1, 0, skb->len) + 1;
557 return vi->svq->vq_ops->add_buf(vi->svq, vi->tx_sg, hdr->num_sg, 557 return virtqueue_add_buf(vi->svq, vi->tx_sg, hdr->num_sg,
558 0, skb); 558 0, skb);
559} 559}
560 560
@@ -574,14 +574,14 @@ again:
574 if (unlikely(capacity < 0)) { 574 if (unlikely(capacity < 0)) {
575 netif_stop_queue(dev); 575 netif_stop_queue(dev);
576 dev_warn(&dev->dev, "Unexpected full queue\n"); 576 dev_warn(&dev->dev, "Unexpected full queue\n");
577 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { 577 if (unlikely(!virtqueue_enable_cb(vi->svq))) {
578 vi->svq->vq_ops->disable_cb(vi->svq); 578 virtqueue_disable_cb(vi->svq);
579 netif_start_queue(dev); 579 netif_start_queue(dev);
580 goto again; 580 goto again;
581 } 581 }
582 return NETDEV_TX_BUSY; 582 return NETDEV_TX_BUSY;
583 } 583 }
584 vi->svq->vq_ops->kick(vi->svq); 584 virtqueue_kick(vi->svq);
585 585
586 /* Don't wait up for transmitted skbs to be freed. */ 586 /* Don't wait up for transmitted skbs to be freed. */
587 skb_orphan(skb); 587 skb_orphan(skb);
@@ -591,12 +591,12 @@ again:
591 * before it gets out of hand. Naturally, this wastes entries. */ 591 * before it gets out of hand. Naturally, this wastes entries. */
592 if (capacity < 2+MAX_SKB_FRAGS) { 592 if (capacity < 2+MAX_SKB_FRAGS) {
593 netif_stop_queue(dev); 593 netif_stop_queue(dev);
594 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { 594 if (unlikely(!virtqueue_enable_cb(vi->svq))) {
595 /* More just got used, free them then recheck. */ 595 /* More just got used, free them then recheck. */
596 capacity += free_old_xmit_skbs(vi); 596 capacity += free_old_xmit_skbs(vi);
597 if (capacity >= 2+MAX_SKB_FRAGS) { 597 if (capacity >= 2+MAX_SKB_FRAGS) {
598 netif_start_queue(dev); 598 netif_start_queue(dev);
599 vi->svq->vq_ops->disable_cb(vi->svq); 599 virtqueue_disable_cb(vi->svq);
600 } 600 }
601 } 601 }
602 } 602 }
@@ -641,7 +641,7 @@ static int virtnet_open(struct net_device *dev)
641 * now. virtnet_poll wants re-enable the queue, so we disable here. 641 * now. virtnet_poll wants re-enable the queue, so we disable here.
642 * We synchronize against interrupts via NAPI_STATE_SCHED */ 642 * We synchronize against interrupts via NAPI_STATE_SCHED */
643 if (napi_schedule_prep(&vi->napi)) { 643 if (napi_schedule_prep(&vi->napi)) {
644 vi->rvq->vq_ops->disable_cb(vi->rvq); 644 virtqueue_disable_cb(vi->rvq);
645 __napi_schedule(&vi->napi); 645 __napi_schedule(&vi->napi);
646 } 646 }
647 return 0; 647 return 0;
@@ -678,15 +678,15 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
678 sg_set_buf(&sg[i + 1], sg_virt(s), s->length); 678 sg_set_buf(&sg[i + 1], sg_virt(s), s->length);
679 sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); 679 sg_set_buf(&sg[out + in - 1], &status, sizeof(status));
680 680
681 BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) < 0); 681 BUG_ON(virtqueue_add_buf(vi->cvq, sg, out, in, vi) < 0);
682 682
683 vi->cvq->vq_ops->kick(vi->cvq); 683 virtqueue_kick(vi->cvq);
684 684
685 /* 685 /*
686 * Spin for a response, the kick causes an ioport write, trapping 686 * Spin for a response, the kick causes an ioport write, trapping
687 * into the hypervisor, so the request should be handled immediately. 687 * into the hypervisor, so the request should be handled immediately.
688 */ 688 */
689 while (!vi->cvq->vq_ops->get_buf(vi->cvq, &tmp)) 689 while (!virtqueue_get_buf(vi->cvq, &tmp))
690 cpu_relax(); 690 cpu_relax();
691 691
692 return status == VIRTIO_NET_OK; 692 return status == VIRTIO_NET_OK;
@@ -1003,13 +1003,13 @@ static void free_unused_bufs(struct virtnet_info *vi)
1003{ 1003{
1004 void *buf; 1004 void *buf;
1005 while (1) { 1005 while (1) {
1006 buf = vi->svq->vq_ops->detach_unused_buf(vi->svq); 1006 buf = virtqueue_detach_unused_buf(vi->svq);
1007 if (!buf) 1007 if (!buf)
1008 break; 1008 break;
1009 dev_kfree_skb(buf); 1009 dev_kfree_skb(buf);
1010 } 1010 }
1011 while (1) { 1011 while (1) {
1012 buf = vi->rvq->vq_ops->detach_unused_buf(vi->rvq); 1012 buf = virtqueue_detach_unused_buf(vi->rvq);
1013 if (!buf) 1013 if (!buf)
1014 break; 1014 break;
1015 if (vi->mergeable_rx_bufs || vi->big_packets) 1015 if (vi->mergeable_rx_bufs || vi->big_packets)