From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF14CC433E0 for ; Mon, 1 Feb 2021 06:11:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4F98E64E10 for ; Mon, 1 Feb 2021 06:11:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F98E64E10 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6SR3-0006UT-8u for qemu-devel@archiver.kernel.org; Mon, 01 Feb 2021 01:11:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6SQP-0005xG-Ap for qemu-devel@nongnu.org; Mon, 01 Feb 2021 01:11:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l6SQN-0000kr-P6 for qemu-devel@nongnu.org; Mon, 01 Feb 2021 01:11:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612159858; 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=Fmf3/F4bar93epA9jgT+XZRxFS/bi7T0OzcismX32KQ=; b=g5fxPwfuPBtG7ElU4i9Xq0BDxjITN7d75pTwOefWxteoEkWMOWm8gvJQxlmU7in22nOMbE ZPNgaXAgFvDBBvatFsZpnrMCjBDF8y1q449FhLm7ISgqyIleLwRV8g6FjyYedG45xT91j6 Xd+GRCm2bNvvDQLgCMfK8HIhJFNOISI= 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-43-Ndapx0jlNLWAIfVCrybtsA-1; Mon, 01 Feb 2021 01:10:55 -0500 X-MC-Unique: Ndapx0jlNLWAIfVCrybtsA-1 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 A8BB0190D344; Mon, 1 Feb 2021 06:10:53 +0000 (UTC) Received: from [10.72.13.120] (ovpn-13-120.pek2.redhat.com [10.72.13.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9874E5D9DC; Mon, 1 Feb 2021 06:10:41 +0000 (UTC) Subject: Re: [RFC 03/10] virtio: Add virtio_queue_get_idx To: =?UTF-8?Q?Eugenio_P=c3=a9rez?= , qemu-devel@nongnu.org References: <20210129205415.876290-1-eperezma@redhat.com> <20210129205415.876290-4-eperezma@redhat.com> From: Jason Wang Message-ID: Date: Mon, 1 Feb 2021 14:10:39 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210129205415.876290-4-eperezma@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Received-SPF: pass client-ip=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.079, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Parav Pandit , "Michael S. Tsirkin" , Juan Quintela , Markus Armbruster , virtualization@lists.linux-foundation.org, Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Stefano Garzarella , Michael Lilja , Jim Harford , Rob Miller Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 2021/1/30 上午4:54, Eugenio Pérez wrote: > Signed-off-by: Eugenio Pérez > --- > include/hw/virtio/virtio.h | 2 ++ > hw/virtio/virtio.c | 5 +++++ > 2 files changed, 7 insertions(+) > > diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h > index 9988c6d5c9..9013c03424 100644 > --- a/include/hw/virtio/virtio.h > +++ b/include/hw/virtio/virtio.h > @@ -399,6 +399,8 @@ static inline bool virtio_device_disabled(VirtIODevice *vdev) > return unlikely(vdev->disabled || vdev->broken); > } > > +unsigned virtio_queue_get_idx(const VirtIODevice *vdev, const VirtQueue *vq); > + > bool virtio_legacy_allowed(VirtIODevice *vdev); > bool virtio_legacy_check_disabled(VirtIODevice *vdev); > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > index ebb780fb42..3d14b0ef74 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -500,6 +500,11 @@ void virtio_queue_set_notification(VirtQueue *vq, int enable) > } > } > > +unsigned virtio_queue_get_idx(const VirtIODevice *vdev, const VirtQueue *vq) > +{ > + return vq - vdev->vq; > +} It looks to me we had a dedicated index stored in VirtQueue: vq->queue_index. Thanks > + > int virtio_queue_ready(VirtQueue *vq) > { > return vq->vring.avail != 0; From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63B1BC433E0 for ; Mon, 1 Feb 2021 06:11:04 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B856264E2F for ; Mon, 1 Feb 2021 06:11:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B856264E2F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=virtualization-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 623EB86F63; Mon, 1 Feb 2021 06:11:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JOlQWEH2gf-r; Mon, 1 Feb 2021 06:11:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 9B0BF86F5F; Mon, 1 Feb 2021 06:11:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7CCF6C0FA7; Mon, 1 Feb 2021 06:11:00 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 29B2FC013A for ; Mon, 1 Feb 2021 06:10:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 0DD4D865A1 for ; Mon, 1 Feb 2021 06:10:59 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ctixh-Zh8LO2 for ; Mon, 1 Feb 2021 06:10:58 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by whitealder.osuosl.org (Postfix) with ESMTPS id 5D21D8657C for ; Mon, 1 Feb 2021 06:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612159857; 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=Fmf3/F4bar93epA9jgT+XZRxFS/bi7T0OzcismX32KQ=; b=HdiGMX5/+V7mnEJqMaWRxziFggGQvT63+TIoDl7g028JhBxGBq52G1xXYkD4x+YvmgzhCS kX525T+bhxkW+yhA6sJURc7Z75UckYUOsmCCJbsXa7/BZd9ohtD6YdC0zzjtN45C+6qnL+ Ee3dhWH9nSs5+Rt1vz0jTKOEAkrsDlc= 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-43-Ndapx0jlNLWAIfVCrybtsA-1; Mon, 01 Feb 2021 01:10:55 -0500 X-MC-Unique: Ndapx0jlNLWAIfVCrybtsA-1 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 A8BB0190D344; Mon, 1 Feb 2021 06:10:53 +0000 (UTC) Received: from [10.72.13.120] (ovpn-13-120.pek2.redhat.com [10.72.13.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9874E5D9DC; Mon, 1 Feb 2021 06:10:41 +0000 (UTC) Subject: Re: [RFC 03/10] virtio: Add virtio_queue_get_idx To: =?UTF-8?Q?Eugenio_P=c3=a9rez?= , qemu-devel@nongnu.org References: <20210129205415.876290-1-eperezma@redhat.com> <20210129205415.876290-4-eperezma@redhat.com> From: Jason Wang Message-ID: Date: Mon, 1 Feb 2021 14:10:39 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210129205415.876290-4-eperezma@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Cc: Parav Pandit , "Michael S. Tsirkin" , virtualization@lists.linux-foundation.org, Harpreet Singh Anand , Xiao W Wang , Stefan Hajnoczi , Eli Cohen , Eric Blake , Michael Lilja , Jim Harford , Rob Miller X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" Ck9uIDIwMjEvMS8zMCDkuIrljYg0OjU0LCBFdWdlbmlvIFDDqXJleiB3cm90ZToKPiBTaWduZWQt b2ZmLWJ5OiBFdWdlbmlvIFDDqXJleiA8ZXBlcmV6bWFAcmVkaGF0LmNvbT4KPiAtLS0KPiAgIGlu Y2x1ZGUvaHcvdmlydGlvL3ZpcnRpby5oIHwgMiArKwo+ICAgaHcvdmlydGlvL3ZpcnRpby5jICAg ICAgICAgfCA1ICsrKysrCj4gICAyIGZpbGVzIGNoYW5nZWQsIDcgaW5zZXJ0aW9ucygrKQo+Cj4g ZGlmZiAtLWdpdCBhL2luY2x1ZGUvaHcvdmlydGlvL3ZpcnRpby5oIGIvaW5jbHVkZS9ody92aXJ0 aW8vdmlydGlvLmgKPiBpbmRleCA5OTg4YzZkNWM5Li45MDEzYzAzNDI0IDEwMDY0NAo+IC0tLSBh L2luY2x1ZGUvaHcvdmlydGlvL3Zpcn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