virtio_net.c (4e9816d012dbc28dc89559261c6ffbf8ffc440dd) virtio_net.c (2ffa75988fff39741e60141ce4a349e2419b41e6)
1/* A network driver using virtio.
2 *
3 * Copyright 2007 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 711 unchanged lines hidden (view full) ---

720 /* In theory, this can happen: if we don't get any buffers in
721 * we will *never* try to fill again.
722 */
723 if (still_empty)
724 schedule_delayed_work(&vi->refill, HZ/2);
725 }
726}
727
1/* A network driver using virtio.
2 *
3 * Copyright 2007 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 711 unchanged lines hidden (view full) ---

720 /* In theory, this can happen: if we don't get any buffers in
721 * we will *never* try to fill again.
722 */
723 if (still_empty)
724 schedule_delayed_work(&vi->refill, HZ/2);
725 }
726}
727
728static int virtnet_poll(struct napi_struct *napi, int budget)
728static 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
736again:
737 while (received < budget &&
738 (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) {
739 receive_buf(rq, buf, len);
740 received++;
741 }
742
743 if (rq->vq->num_free > virtqueue_get_vring_size(rq->vq) / 2) {
744 if (!try_fill_recv(rq, GFP_ATOMIC))
745 schedule_delayed_work(&vi->refill, 0);
746 }
747
734 while (received < budget &&
735 (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) {
736 receive_buf(rq, buf, len);
737 received++;
738 }
739
740 if (rq->vq->num_free > virtqueue_get_vring_size(rq->vq) / 2) {
741 if (!try_fill_recv(rq, GFP_ATOMIC))
742 schedule_delayed_work(&vi->refill, 0);
743 }
744
745 return received;
746}
747
748static 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
754again:
755 received += virtnet_receive(rq, budget - received);
756
748 /* Out of packets? */
749 if (received < budget) {
750 r = virtqueue_enable_cb_prepare(rq->vq);
751 napi_complete(napi);
752 if (unlikely(virtqueue_poll(rq->vq, r)) &&
753 napi_schedule_prep(napi)) {
754 virtqueue_disable_cb(rq->vq);
755 __napi_schedule(napi);

--- 1187 unchanged lines hidden ---
757 /* Out of packets? */
758 if (received < budget) {
759 r = virtqueue_enable_cb_prepare(rq->vq);
760 napi_complete(napi);
761 if (unlikely(virtqueue_poll(rq->vq, r)) &&
762 napi_schedule_prep(napi)) {
763 virtqueue_disable_cb(rq->vq);
764 __napi_schedule(napi);

--- 1187 unchanged lines hidden ---