From nobody Sun Apr 12 16:56:12 2026 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1715008028; cv=none; d=zohomail.com; s=zohoarc; b=MNQDJgjCVtLxsyMW+IWlNCGGft3/R9E0FSmGXKoKRT6epq8C5ClDtXMaJzVcnyf7j8MdqnIPTiiz4X5//sHaKRGovTmGwG9rV6oCHVNB9toJVp21PNSsi+nsUVWroOAlcHI8ro5KV5SgncK92JOHaVszLjMyKDv6E8V59yl8hXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715008028; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LWjbGscupnTTl7SaGvk7rGF8ER7++IAlDB75F8Famo4=; b=A0vcNDjvohjN4L6sIfD0TE7eCWscvRDQWKwd9xEw0OIxAgbdITWYbeEm1qjJOYVr8PgUmzdVlKCly6bWfYo0yMxrUS5KaVOxVeyjC2WrwvDNLyQXZWaie/asFzmFCC5BkctejcI4g/ylbpCxqlxFUWw8dwgTWmhIL9DEDoB1McE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715008028136335.00567748939943; Mon, 6 May 2024 08:07:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3zug-0006vi-VH; Mon, 06 May 2024 11:05:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3zue-0006mb-JW; Mon, 06 May 2024 11:05:56 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3zuc-00048P-Hi; Mon, 06 May 2024 11:05:56 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 446AnBn0031893; Mon, 6 May 2024 15:04:43 GMT Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3xwbt52ty8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 15:04:42 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 446DmJWv006938; Mon, 6 May 2024 15:04:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3xwbf6rwhj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 May 2024 15:04:41 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 446F4ZlL002521; Mon, 6 May 2024 15:04:41 GMT Received: from jonah-ol8.us.oracle.com (dhcp-10-39-221-117.vpn.oracle.com [10.39.221.117]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3xwbf6rw8e-3; Mon, 06 May 2024 15:04:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=LWjbGscupnTTl7SaGvk7rGF8ER7++IAlDB75F8Famo4=; b=LZVJbChrjpO4DHGGw1jsOvM9Qylld3kjL5lTdqq3snlWiFmVh3tJ8gl+hYe5k0GW1rjJ K4hKQr6utXzl+G/A9OiVziOlwvsxRfWdg05dhFdhZgprfPexXV6g0a3fb7Rc7rX3LQdi xcmTEYLaL2+tcPb4I/BM7IsjPQMJ2bKxM6/DwMwmRz6L+FKrCgyohVCQjE5iyXlapoWv VlS19qrk/6LzTEmsIIwTwj59cXDy5b+lpM9Zg+PFD1eMyH0zxl5E1pytTdj4EGATy34y RQQ60hGR3WUqZ6VXEDntHxjtylWxLAVPU8odrSu8tnUZlP2/8F4o1tU9/OyTs3moyQts dw== From: Jonah Palmer To: qemu-devel@nongnu.org Cc: mst@redhat.com, raphael@enfabrica.net, kwolf@redhat.com, hreitz@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, fam@euphon.net, eperezma@redhat.com, stefanha@redhat.com, qemu-block@nongnu.org, schalla@marvell.com, leiyang@redhat.com, virtio-fs@lists.linux.dev, si-wei.liu@oracle.com, boris.ostrovsky@oracle.com, jonah.palmer@oracle.com Subject: [PATCH 2/6] virtio: virtqueue_pop - VIRTIO_F_IN_ORDER support Date: Mon, 6 May 2024 11:04:24 -0400 Message-Id: <20240506150428.1203387-3-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240506150428.1203387-1-jonah.palmer@oracle.com> References: <20240506150428.1203387-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-06_09,2024-05-06_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2405060104 X-Proofpoint-GUID: oYqQiqa3vHMRANC54IwcfVPKxMxhhijg X-Proofpoint-ORIG-GUID: oYqQiqa3vHMRANC54IwcfVPKxMxhhijg Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=jonah.palmer@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1715008030205100003 Content-Type: text/plain; charset="utf-8" Add VIRTIO_F_IN_ORDER feature support in virtqueue_split_pop and virtqueue_packed_pop. VirtQueueElements popped from the available/descritpor ring are added to the VirtQueue's used_elems array in-order and in the same fashion as they would be added the used and descriptor rings, respectively. This will allow us to keep track of the current order, what elements have been written, as well as an element's essential data after being processed. Tested-by: Lei Yang Signed-off-by: Jonah Palmer --- hw/virtio/virtio.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 893a072c9d..e6eb1bb453 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1506,7 +1506,7 @@ static void *virtqueue_alloc_element(size_t sz, unsig= ned out_num, unsigned in_nu =20 static void *virtqueue_split_pop(VirtQueue *vq, size_t sz) { - unsigned int i, head, max; + unsigned int i, j, head, max; VRingMemoryRegionCaches *caches; MemoryRegionCache indirect_desc_cache; MemoryRegionCache *desc_cache; @@ -1539,6 +1539,8 @@ static void *virtqueue_split_pop(VirtQueue *vq, size_= t sz) goto done; } =20 + j =3D vq->last_avail_idx; + if (!virtqueue_get_head(vq, vq->last_avail_idx++, &head)) { goto done; } @@ -1630,6 +1632,12 @@ static void *virtqueue_split_pop(VirtQueue *vq, size= _t sz) elem->in_sg[i] =3D iov[out_num + i]; } =20 + if (virtio_vdev_has_feature(vdev, VIRTIO_F_IN_ORDER)) { + vq->used_elems[j].index =3D elem->index; + vq->used_elems[j].len =3D elem->len; + vq->used_elems[j].ndescs =3D elem->ndescs; + } + vq->inuse++; =20 trace_virtqueue_pop(vq, elem, elem->in_num, elem->out_num); @@ -1758,6 +1766,13 @@ static void *virtqueue_packed_pop(VirtQueue *vq, siz= e_t sz) =20 elem->index =3D id; elem->ndescs =3D (desc_cache =3D=3D &indirect_desc_cache) ? 1 : elem_e= ntries; + + if (virtio_vdev_has_feature(vdev, VIRTIO_F_IN_ORDER)) { + vq->used_elems[vq->last_avail_idx].index =3D elem->index; + vq->used_elems[vq->last_avail_idx].len =3D elem->len; + vq->used_elems[vq->last_avail_idx].ndescs =3D elem->ndescs; + } + vq->last_avail_idx +=3D elem->ndescs; vq->inuse +=3D elem->ndescs; =20 --=20 2.39.3