From patchwork Thu Jan 23 15:16:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1228359 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=R/EqqGoc; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 483Tjw4SDkz9sP6 for ; Fri, 24 Jan 2020 04:27:32 +1100 (AEDT) Received: from localhost ([::1]:33422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iugGQ-0000lY-2m for incoming@patchwork.ozlabs.org; Thu, 23 Jan 2020 12:27:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45741) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iueEM-0005eF-J1 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 10:17:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iueEL-0002iH-8R for qemu-devel@nongnu.org; Thu, 23 Jan 2020 10:17:14 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27943 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iueEL-0002i0-5F for qemu-devel@nongnu.org; Thu, 23 Jan 2020 10:17:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579792632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6tLMZZuLaHZ7+9S5a5Q4dO5dyShTG2/4H+EPaxCb43s=; b=R/EqqGocI37H/V32OASl9/RlETDeLFI5cLptqtdy5rikpoNkmgVfRRjAVC6Exe0Z6a6qtI sHq8QxvJ/N1L1SCRZgQfPuzUIQ6lIAnf2hQxGSMS48cWGqmIJpTXyCSj9x8hGtg3CEiu8/ Q07KyCr/Yt9vSxXfjGAClvtpW0rCXz4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-249-BpVsLgrlMyeEa2jOq8f8OA-1; Thu, 23 Jan 2020 10:17:09 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A5F2106BC2A; Thu, 23 Jan 2020 15:17:08 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-204-119.brq.redhat.com [10.40.204.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 661F15DAA4; Thu, 23 Jan 2020 15:17:06 +0000 (UTC) From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [RFC 1/2] virtio-rng: prepare the introduction of a control queue Date: Thu, 23 Jan 2020 16:16:59 +0100 Message-Id: <20200123151700.1367857-2-lvivier@redhat.com> In-Reply-To: <20200123151700.1367857-1-lvivier@redhat.com> References: <20200123151700.1367857-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: BpVsLgrlMyeEa2jOq8f8OA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Amit Shah , Eduardo Habkost , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Rename the existing vq to input_vq and use virtio_delete_queue() rather than virtio_del_queue(). Signed-off-by: Laurent Vivier --- hw/virtio/virtio-rng.c | 18 +++++++++--------- include/hw/virtio/virtio-rng.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index b498a2033263..a0bca55bef55 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -25,7 +25,7 @@ static bool is_guest_ready(VirtIORNG *vrng) { VirtIODevice *vdev = VIRTIO_DEVICE(vrng); - if (virtio_queue_ready(vrng->vq) + if (virtio_queue_ready(vrng->input_vq) && (vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { return true; } @@ -69,7 +69,7 @@ static void chr_read(void *opaque, const void *buf, size_t size) offset = 0; while (offset < size) { - elem = virtqueue_pop(vrng->vq, sizeof(VirtQueueElement)); + elem = virtqueue_pop(vrng->input_vq, sizeof(VirtQueueElement)); if (!elem) { break; } @@ -78,13 +78,13 @@ static void chr_read(void *opaque, const void *buf, size_t size) 0, buf + offset, size - offset); offset += len; - virtqueue_push(vrng->vq, elem, len); + virtqueue_push(vrng->input_vq, elem, len); trace_virtio_rng_pushed(vrng, len); g_free(elem); } - virtio_notify(vdev, vrng->vq); + virtio_notify(vdev, vrng->input_vq); - if (!virtio_queue_empty(vrng->vq)) { + if (!virtio_queue_empty(vrng->input_vq)) { /* If we didn't drain the queue, call virtio_rng_process * to take care of asking for more data as appropriate. */ @@ -112,7 +112,7 @@ static void virtio_rng_process(VirtIORNG *vrng) } else { quota = MIN((uint64_t)vrng->quota_remaining, (uint64_t)UINT32_MAX); } - size = get_request_size(vrng->vq, quota); + size = get_request_size(vrng->input_vq, quota); trace_virtio_rng_request(vrng, size, quota); @@ -122,7 +122,7 @@ static void virtio_rng_process(VirtIORNG *vrng) } } -static void handle_input(VirtIODevice *vdev, VirtQueue *vq) +static void virtio_rng_handle_input(VirtIODevice *vdev, VirtQueue *vq) { VirtIORNG *vrng = VIRTIO_RNG(vdev); virtio_rng_process(vrng); @@ -220,7 +220,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp) virtio_init(vdev, "virtio-rng", VIRTIO_ID_RNG, 0); - vrng->vq = virtio_add_queue(vdev, 8, handle_input); + vrng->input_vq = virtio_add_queue(vdev, 8, virtio_rng_handle_input); vrng->quota_remaining = vrng->conf.max_bytes; vrng->rate_limit_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, check_rate_limit, vrng); @@ -238,7 +238,7 @@ static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp) qemu_del_vm_change_state_handler(vrng->vmstate); timer_del(vrng->rate_limit_timer); timer_free(vrng->rate_limit_timer); - virtio_del_queue(vdev, 0); + virtio_delete_queue(vrng->input_vq); virtio_cleanup(vdev); } diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h index bd05d734b87d..d77daf126828 100644 --- a/include/hw/virtio/virtio-rng.h +++ b/include/hw/virtio/virtio-rng.h @@ -32,7 +32,7 @@ typedef struct VirtIORNG { VirtIODevice parent_obj; /* Only one vq - guest puts buffer(s) on it when it needs entropy */ - VirtQueue *vq; + VirtQueue *input_vq; VirtIORNGConf conf;