Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934708AbaGPGWq (ORCPT ); Wed, 16 Jul 2014 02:22:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28847 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934633AbaGPGWG (ORCPT ); Wed, 16 Jul 2014 02:22:06 -0400 From: Jason Wang To: rusty@rustcorp.com.au, mst@redhat.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jason Wang , Vlad Yasevich , Eric Dumazet Subject: [PATCH net-next V2 2/3] virtio-net: introduce virtnet_receive() Date: Wed, 16 Jul 2014 14:21:46 +0800 Message-Id: <1405491707-22706-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1405491707-22706-1-git-send-email-jasowang@redhat.com> References: <1405491707-22706-1-git-send-email-jasowang@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move common receive logic to a new helper virtnet_receive(). It will also be used by rx busy polling method. Cc: Rusty Russell Cc: Michael S. Tsirkin Cc: Vlad Yasevich Cc: Eric Dumazet Signed-off-by: Jason Wang --- drivers/net/virtio_net.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index e1e1691..e417d93 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) } } -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; + unsigned int len, received = 0; void *buf; - unsigned int r, len, received = 0; -again: while (received < budget && (buf = virtqueue_get_buf(rq->vq, &len)) != NULL) { receive_buf(rq, buf, len); @@ -745,6 +742,18 @@ again: 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); + /* Out of packets? */ if (received < budget) { r = virtqueue_enable_cb_prepare(rq->vq); @@ -753,6 +762,7 @@ again: napi_schedule_prep(napi)) { virtqueue_disable_cb(rq->vq); __napi_schedule(napi); + budget -= received; goto again; } } -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/