diff options
author | Jason Wang <jasowang@redhat.com> | 2014-07-23 04:33:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-23 18:12:01 -0400 |
commit | 2ffa75988fff39741e60141ce4a349e2419b41e6 (patch) | |
tree | 514ca37970b5808e9a1a2f0fbdf40397a4761eba /drivers/net/virtio_net.c | |
parent | 96b3bff4c94cebc97726dc7f019cfc7ba3ced2e1 (diff) |
virtio-net: introduce virtnet_receive()
Move common receive logic to a new helper virtnet_receive(). It will
also be used by rx busy polling method.
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Vlad Yasevich <vyasevic@redhat.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/virtio_net.c')
-rw-r--r-- | drivers/net/virtio_net.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7d9f84a91f37..b647d0d5c00e 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -725,15 +725,12 @@ static void refill_work(struct work_struct *work) | |||
725 | } | 725 | } |
726 | } | 726 | } |
727 | 727 | ||
728 | static int virtnet_poll(struct napi_struct *napi, int budget) | 728 | static int virtnet_receive(struct receive_queue *rq, int budget) |
729 | { | 729 | { |
730 | struct receive_queue *rq = | ||
731 | container_of(napi, struct receive_queue, napi); | ||
732 | struct virtnet_info *vi = rq->vq->vdev->priv; | 730 | struct virtnet_info *vi = rq->vq->vdev->priv; |
731 | unsigned int len, received = 0; | ||
733 | void *buf; | 732 | void *buf; |
734 | unsigned int r, len, received = 0; | ||
735 | 733 | ||
736 | again: | ||
737 | while (received < budget && | 734 | while (received < budget && |
738 | (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) { | 735 | (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) { |
739 | receive_buf(rq, buf, len); | 736 | receive_buf(rq, buf, len); |
@@ -745,6 +742,18 @@ again: | |||
745 | schedule_delayed_work(&vi->refill, 0); | 742 | schedule_delayed_work(&vi->refill, 0); |
746 | } | 743 | } |
747 | 744 | ||
745 | return received; | ||
746 | } | ||
747 | |||
748 | static int virtnet_poll(struct napi_struct *napi, int budget) | ||
749 | { | ||
750 | struct receive_queue *rq = | ||
751 | container_of(napi, struct receive_queue, napi); | ||
752 | unsigned int r, received = 0; | ||
753 | |||
754 | again: | ||
755 | received += virtnet_receive(rq, budget - received); | ||
756 | |||
748 | /* Out of packets? */ | 757 | /* Out of packets? */ |
749 | if (received < budget) { | 758 | if (received < budget) { |
750 | r = virtqueue_enable_cb_prepare(rq->vq); | 759 | r = virtqueue_enable_cb_prepare(rq->vq); |