Commit 2ffa7598 authored by Jason Wang's avatar Jason Wang Committed by David S. Miller

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: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 96b3bff4
...@@ -725,15 +725,12 @@ static void refill_work(struct work_struct *work) ...@@ -725,15 +725,12 @@ static void refill_work(struct work_struct *work)
} }
} }
static int virtnet_poll(struct napi_struct *napi, int budget) static int virtnet_receive(struct receive_queue *rq, int budget)
{ {
struct receive_queue *rq =
container_of(napi, struct receive_queue, napi);
struct virtnet_info *vi = rq->vq->vdev->priv; struct virtnet_info *vi = rq->vq->vdev->priv;
unsigned int len, received = 0;
void *buf; void *buf;
unsigned int r, len, received = 0;
again:
while (received < budget && while (received < budget &&
(buf = virtqueue_get_buf(rq->vq, &len)) != NULL) { (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) {
receive_buf(rq, buf, len); receive_buf(rq, buf, len);
...@@ -745,6 +742,18 @@ static int virtnet_poll(struct napi_struct *napi, int budget) ...@@ -745,6 +742,18 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
schedule_delayed_work(&vi->refill, 0); schedule_delayed_work(&vi->refill, 0);
} }
return received;
}
static int virtnet_poll(struct napi_struct *napi, int budget)
{
struct receive_queue *rq =
container_of(napi, struct receive_queue, napi);
unsigned int r, received = 0;
again:
received += virtnet_receive(rq, budget - received);
/* Out of packets? */ /* Out of packets? */
if (received < budget) { if (received < budget) {
r = virtqueue_enable_cb_prepare(rq->vq); r = virtqueue_enable_cb_prepare(rq->vq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment