From nobody Sat May 11 22:40:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1711643026; cv=none; d=zohomail.com; s=zohoarc; b=QS82J/dRjrKfXwmrAVUeQyxVWTTmDR4ep16l3F9hIv2kglKjaHKHrCo6a5RNlbjWXw703istj/tg/rouI6tIgdxpvfvdoAw9yukg9AePUwyK1om9yd7o565S66n6xk7B63Nwx4WyaCY0s5nq3P8iJthvoypR6YbXX4o8lO7iRq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711643026; 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=t+MOBr6NcxD2+45PzNWIRJWhFZkAKFOHgU3aasbwS2Q=; b=klHADoRzq9EoUOrw138l4JRYi5ueNyCSgv76v4Y21ApE4UbDl/BxXh7TmoSQifNahlNFyDtJgT7Jq05dptYLpSTan7EOfUyc60hFjHGQ0mit3B8TNYcko73WSAb8oLY7c4ZpiTbgVAJrLzy0qDLK1uf36L/w6Y2YnzNYUEqD8hE= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17116430269631003.2503395180076; Thu, 28 Mar 2024 09:23:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rpsWr-00078H-Te; Thu, 28 Mar 2024 12:23:02 -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 1rpsWZ-00072F-Gv; Thu, 28 Mar 2024 12:22:43 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rpsWT-00087L-HE; Thu, 28 Mar 2024 12:22:43 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42SFP3Gj009598; Thu, 28 Mar 2024 16:22:09 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3x2s9h0jtw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 16:22:09 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 42SGG4FM015182; Thu, 28 Mar 2024 16:22:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3x1nhgfgfk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 16:22:07 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 42SGM5Zv010492; Thu, 28 Mar 2024 16:22:07 GMT Received: from jonah-ol8.us.oracle.com (dhcp-10-39-220-183.vpn.oracle.com [10.39.220.183]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3x1nhgfgcy-2; Thu, 28 Mar 2024 16:22:07 +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=t+MOBr6NcxD2+45PzNWIRJWhFZkAKFOHgU3aasbwS2Q=; b=PeEXh6VPCBq5F3IObjBRiYRY8OhsqKH9MqkWsnSSQbUyLzawWN1d0kAoYNZXISEQ87d/ nCjKVcacYvftWcoL4aV3bpUlumYuoWvoqsZnZIts4vILCuThfbV1Zy4Y5SNgzVF+xwhP I62Qz1mS7q0EKXWnPCgmFRRFv750fXXSgVPykwC3kDngFgWOFTroa7knSm7SPQeIw8RS eSZjiJvukKcEldeVf9stki0t8GxnMsi1pi217wcHC8XiHniB2idgr6RTFuJp5kppRVcw jlkQEIQevR/3o8Clh9eK8ZKwSivrn0D95F+wBOGCd9fHE3SMK37z4OR9uow2BvFwx1yk qA== 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: [RFC v2 1/5] virtio: Initialize sequence variables Date: Thu, 28 Mar 2024 12:21:59 -0400 Message-Id: <20240328162203.3775114-2-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240328162203.3775114-1-jonah.palmer@oracle.com> References: <20240328162203.3775114-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_15,2024-03-28_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403280111 X-Proofpoint-GUID: yIwmXhld4fui8KBKq2wn5XuC7ZmmavOX X-Proofpoint-ORIG-GUID: yIwmXhld4fui8KBKq2wn5XuC7ZmmavOX 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.165.32; envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1711643028800100003 Content-Type: text/plain; charset="utf-8" Initialize sequence variables for VirtQueue and VirtQueueElement structures. A VirtQueue's sequence variables are initialized when a VirtQueue is being created or reset. A VirtQueueElement's sequence variable is initialized when a VirtQueueElement is being initialized. These variables will be used to support the VIRTIO_F_IN_ORDER feature. A VirtQueue's used_seq_idx represents the next expected index in a sequence of VirtQueueElements to be processed (put on the used ring). The next VirtQueueElement added to the used ring must match this sequence number before additional elements can be safely added to the used ring. It's also particularly useful for helping find the number of new elements added to the used ring. A VirtQueue's current_seq_idx represents the current sequence index. This value is essentially a counter where the value is assigned to a new VirtQueueElement and then incremented. Given its uint16_t type, this sequence number can be between 0 and 65,535. A VirtQueueElement's seq_idx represents the sequence number assigned to the VirtQueueElement when it was created. This value must match with the VirtQueue's used_seq_idx before the element can be put on the used ring by the device. Signed-off-by: Jonah Palmer --- hw/virtio/virtio.c | 18 ++++++++++++++++++ include/hw/virtio/virtio.h | 1 + 2 files changed, 19 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index fb6b4ccd83..069d96df99 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -132,6 +132,10 @@ struct VirtQueue uint16_t used_idx; bool used_wrap_counter; =20 + /* In-Order sequence indices */ + uint16_t used_seq_idx; + uint16_t current_seq_idx; + /* Last used index value we have signalled on */ uint16_t signalled_used; =20 @@ -1621,6 +1625,11 @@ static void *virtqueue_split_pop(VirtQueue *vq, size= _t sz) elem->in_sg[i] =3D iov[out_num + i]; } =20 + /* Assign sequence index for in-order processing */ + if (virtio_vdev_has_feature(vdev, VIRTIO_F_IN_ORDER)) { + elem->seq_idx =3D vq->current_seq_idx++; + } + vq->inuse++; =20 trace_virtqueue_pop(vq, elem, elem->in_num, elem->out_num); @@ -1760,6 +1769,11 @@ static void *virtqueue_packed_pop(VirtQueue *vq, siz= e_t sz) vq->shadow_avail_idx =3D vq->last_avail_idx; vq->shadow_avail_wrap_counter =3D vq->last_avail_wrap_counter; =20 + /* Assign sequence index for in-order processing */ + if (virtio_vdev_has_feature(vdev, VIRTIO_F_IN_ORDER)) { + elem->seq_idx =3D vq->current_seq_idx++; + } + trace_virtqueue_pop(vq, elem, elem->in_num, elem->out_num); done: address_space_cache_destroy(&indirect_desc_cache); @@ -2087,6 +2101,8 @@ static void __virtio_queue_reset(VirtIODevice *vdev, = uint32_t i) vdev->vq[i].notification =3D true; vdev->vq[i].vring.num =3D vdev->vq[i].vring.num_default; vdev->vq[i].inuse =3D 0; + vdev->vq[i].used_seq_idx =3D 0; + vdev->vq[i].current_seq_idx =3D 0; virtio_virtqueue_reset_region_cache(&vdev->vq[i]); } =20 @@ -2334,6 +2350,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int q= ueue_size, vdev->vq[i].vring.align =3D VIRTIO_PCI_VRING_ALIGN; vdev->vq[i].handle_output =3D handle_output; vdev->vq[i].used_elems =3D g_new0(VirtQueueElement, queue_size); + vdev->vq[i].used_seq_idx =3D 0; + vdev->vq[i].current_seq_idx =3D 0; =20 return &vdev->vq[i]; } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b3c74a1bca..910b2a3427 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -75,6 +75,7 @@ typedef struct VirtQueueElement hwaddr *out_addr; struct iovec *in_sg; struct iovec *out_sg; + uint16_t seq_idx; } VirtQueueElement; =20 #define VIRTIO_QUEUE_MAX 1024 --=20 2.39.3 From nobody Sat May 11 22:40:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1711643044; cv=none; d=zohomail.com; s=zohoarc; b=k1a2ZXFK457yabSJZwkwYNwjlPCSNlK9Q8NpZjwpg6z2ek42Wn8ScaN9dLMYWmrDLb7m+tFnD+psEcQK4uWE0zw2PcH8DMOkIVqTB1VHYgUMRihlg5v4SOVGEE5EJb4QmgTeXaXz/aFfcpVRXWMhJqmXrDUtB1lcWLZ6v0CZBRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711643044; 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=Lw0nJnb3HAsgTV+5C1hLep7WC/u74bJmes3myuB1IwE=; b=SPineVuWfub4Y+Lv4L13Hil10Ikm5/oJnQznsl4hcnzesiYPWwoWKVysDvA0aJUBm0s08RAyjx/Yq7pybHozbYDyoLK30qv3zXh6XAGAvlXkYOi+HjJAkPz5lA9l6LISMT6T6OKx6syn/JlqPkQLw+bVrzpZWJ5dZohinnEtKwE= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711643044825684.5856159108891; Thu, 28 Mar 2024 09:24:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rpsWh-00076B-6u; Thu, 28 Mar 2024 12:22:53 -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 1rpsWX-00071E-Gw; Thu, 28 Mar 2024 12:22:41 -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 1rpsWT-00087D-Fh; Thu, 28 Mar 2024 12:22:41 -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 42SFOrIh015505; Thu, 28 Mar 2024 16:22:09 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3x1nv4a2pn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 16:22:09 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 42SEwKhr015043; Thu, 28 Mar 2024 16:22:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3x1nhgfggj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 16:22:08 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 42SGM5Zx010492; Thu, 28 Mar 2024 16:22:08 GMT Received: from jonah-ol8.us.oracle.com (dhcp-10-39-220-183.vpn.oracle.com [10.39.220.183]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3x1nhgfgcy-3; Thu, 28 Mar 2024 16:22:08 +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=Lw0nJnb3HAsgTV+5C1hLep7WC/u74bJmes3myuB1IwE=; b=ku/SXYP5LuBlMU1SvrYjuu54BzfR/zXLM7mLFof3TL3rlTM2hl59YukVo5MRoe2o1pXZ JTPeawBmOG9HblLSFMx0DOvVe+4rNn0i88sJTlP7uppnxPRpRsVbW6YN5lQUz1dLF5B8 q3K3e+HQCnwbnC6ZroVZB7at/9oCZoKY1ubgvHko5DhCCSGRr2EPLt3klw4NVQkByb8N 36H7rcn3JI5vwWQvOIF7oyqkX5TwlvCPRpns809M7whz3YCHIk99HQ5COxWkV6MEVFVj 6i1D6f7rGwiKDz2YpemK3VsXnXRw4MvRDXg+ibbZJDaMKPgBj1X69/LARFyCaDk+5PnC /Q== 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: [RFC v2 2/5] virtio: In-order support for split VQs Date: Thu, 28 Mar 2024 12:22:00 -0400 Message-Id: <20240328162203.3775114-3-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240328162203.3775114-1-jonah.palmer@oracle.com> References: <20240328162203.3775114-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_15,2024-03-28_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403280111 X-Proofpoint-ORIG-GUID: nppdPIFbTzmLh9H_ehYtfI2vc6hghKlk X-Proofpoint-GUID: nppdPIFbTzmLh9H_ehYtfI2vc6hghKlk 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1711643046767100010 Content-Type: text/plain; charset="utf-8" Implements VIRTIO_F_IN_ORDER feature support for virtio devices using the split virtqueue layout. For a virtio device that has negotiated the VIRTIO_F_IN_ORDER feature whose virtqueues use a split virtqueue layout, it's essential that used VirtQueueElements are written to the used ring in-order. For devices that use this in-order feature, its VirtQueue's used_elems array is used to hold processed VirtQueueElements until they can be presented to the driver in-order. In the split virtqueue case, we check to see if the element was the next expected element to be written to the used ring. If it's not, nothing get written to the used ring and we're done. If it is, the element is written to the used ring and then we check to see if the next expected element continues the order. This process is repeated until we're unable to continue the order. If no elements were written to the used ring, no update to the used ring's index is needed. Signed-off-by: Jonah Palmer --- hw/virtio/virtio.c | 50 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 069d96df99..19d3d43816 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -856,16 +856,38 @@ static void virtqueue_split_fill(VirtQueue *vq, const= VirtQueueElement *elem, unsigned int len, unsigned int idx) { VRingUsedElem uelem; + uint16_t uelem_idx; =20 if (unlikely(!vq->vring.used)) { return; } =20 - idx =3D (idx + vq->used_idx) % vq->vring.num; + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_IN_ORDER)) { + /* Write element(s) to used ring if they're in-order */ + while (true) { + uelem_idx =3D vq->used_seq_idx % vq->vring.num; =20 - uelem.id =3D elem->index; - uelem.len =3D len; - vring_used_write(vq, &uelem, idx); + /* Stop if element has been used */ + if (vq->used_elems[uelem_idx].in_num + + vq->used_elems[uelem_idx].out_num <=3D 0) { + break; + } + uelem.id =3D vq->used_elems[uelem_idx].index; + uelem.len =3D vq->used_elems[uelem_idx].len; + vring_used_write(vq, &uelem, uelem_idx); + + /* Mark this element as used */ + vq->used_elems[uelem_idx].in_num =3D 0; + vq->used_elems[uelem_idx].out_num =3D 0; + vq->used_seq_idx++; + } + } else { + idx =3D (idx + vq->used_idx) % vq->vring.num; + + uelem.id =3D elem->index; + uelem.len =3D len; + vring_used_write(vq, &uelem, idx); + } } =20 static void virtqueue_packed_fill(VirtQueue *vq, const VirtQueueElement *e= lem, @@ -918,6 +940,8 @@ static void virtqueue_packed_fill_desc(VirtQueue *vq, void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len, unsigned int idx) { + uint16_t seq_idx; + trace_virtqueue_fill(vq, elem, len, idx); =20 virtqueue_unmap_sg(vq, elem, len); @@ -926,6 +950,16 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueElem= ent *elem, return; } =20 + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_IN_ORDER)) { + seq_idx =3D elem->seq_idx % vq->vring.num; + + vq->used_elems[seq_idx].index =3D elem->index; + vq->used_elems[seq_idx].len =3D elem->len; + vq->used_elems[seq_idx].ndescs =3D elem->ndescs; + vq->used_elems[seq_idx].in_num =3D elem->in_num; + vq->used_elems[seq_idx].out_num =3D elem->out_num; + } + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) { virtqueue_packed_fill(vq, elem, len, idx); } else { @@ -944,6 +978,14 @@ static void virtqueue_split_flush(VirtQueue *vq, unsig= ned int count) =20 /* Make sure buffer is written before we update index. */ smp_wmb(); + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_IN_ORDER)) { + count =3D (vq->used_seq_idx - vq->used_idx) % vq->vring.num; + + /* No in-order elements were written, nothing to update */ + if (!count) { + return; + } + } trace_virtqueue_flush(vq, count); old =3D vq->used_idx; new =3D old + count; --=20 2.39.3 From nobody Sat May 11 22:40:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1711643043; cv=none; d=zohomail.com; s=zohoarc; b=QXqumDd7+Tt3qw8eEl0WCd3xHi93QL+6/R8CNnC1NqF1RmUbuBQhFf+iFrWGQnl/niuDm1fnGXnLj8+LrTqEkUeSQKnQ3YczzFS2uYDRYALGYgrawK0e4+k3xsuz/SxccNOW26B4/CjrFcL+I7+v+P5qAt98lxg1FxS+NlNKETw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711643043; 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=Oy5nFN0etsJJPGxpWCIMafxrPnNst3dVL5vKPOpE5qg=; b=FqyF9He8yfOo9eOLg2mxnt5yCQMl3VBfa0OB9P6w6WvQG/hcZawxhNrIJeaXnZJp230CYDiprV3MQmWapuO7OgS6K/GrVXfQyfRqnHvENUQDQ7peYU3cijaUEsYEjeeka2OORTEwaHb3OAemll4uJRRVZ3SKuYjBl91wSdjzGKY= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711643043022694.027380172167; Thu, 28 Mar 2024 09:24:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rpsWf-00074u-Ml; Thu, 28 Mar 2024 12:22:50 -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 1rpsWX-00071G-JX; Thu, 28 Mar 2024 12:22:41 -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 1rpsWT-000878-EK; Thu, 28 Mar 2024 12:22:41 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42SFOwnp009851; Thu, 28 Mar 2024 16:22:10 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3x2f6h8w75-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 16:22:10 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 42SG2jwR015085; Thu, 28 Mar 2024 16:22:10 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3x1nhgfgj6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 16:22:09 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 42SGM5a1010492; Thu, 28 Mar 2024 16:22:09 GMT Received: from jonah-ol8.us.oracle.com (dhcp-10-39-220-183.vpn.oracle.com [10.39.220.183]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3x1nhgfgcy-4; Thu, 28 Mar 2024 16:22:09 +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=Oy5nFN0etsJJPGxpWCIMafxrPnNst3dVL5vKPOpE5qg=; b=RKgVt1mLZ4UZumfv/UHz0fd+O5U+jbduo8efFtGExWI3VQz1qU0eTdPK9Jkyncsfg9hi GYAmG1/d7gJamSdl1W36GkgGqyUAMW9EcoV8ubRP5wSwG4tt4t8YrXSqXdu/aJPWEva+ rPJ5AgJ0HLg627bcDIqP/yFqLO+KDuBuU4Fgtvb4vmCD/80xmFJIn2rBuXnS9tZWxo8+ fZd7ZIf2sJChOn10M46GsQRlMz+fmVtduA7jum/uGF/ZXpu3SguWMJimpR4/HXR4zR60 1ryzefN5xTfFmg05sMK5tdoQQPZsKX5hqNa37Rg6FfnQL54vSc+1JOqjC0a1F4WW1ua6 wg== 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: [RFC v2 3/5] virtio: In-order support for packed VQs Date: Thu, 28 Mar 2024 12:22:01 -0400 Message-Id: <20240328162203.3775114-4-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240328162203.3775114-1-jonah.palmer@oracle.com> References: <20240328162203.3775114-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_15,2024-03-28_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403280111 X-Proofpoint-GUID: k7Vubl2-zRR0a3m-VmYP5KX2AJ3YbW-E X-Proofpoint-ORIG-GUID: k7Vubl2-zRR0a3m-VmYP5KX2AJ3YbW-E 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1711643044739100003 Content-Type: text/plain; charset="utf-8" Implements VIRTIO_F_IN_ORDER feature support for virtio devices using the packed virtqueue layout. For a virtio device that has negotiated the VIRTIO_F_IN_ORDER feature whose virtqueues use a packed virtqueue layout, it's essential that used VirtQueueElements are written to the descriptor ring in-order. In the packed virtqueue case, since we already write to the virtqueue's used_elems array at the start of virtqueue_fill, we don't need to call virtqueue_packed_fill. Furthermore, due to change in behavior of the used_elems array and not knowing how many unused in-order elements exist, separate logic is required for the flushing operation of packed virtqueues. Signed-off-by: Jonah Palmer --- hw/virtio/virtio.c | 50 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 19d3d43816..dc2eabd18b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -960,7 +960,8 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueEleme= nt *elem, vq->used_elems[seq_idx].out_num =3D elem->out_num; } =20 - if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) { + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED) && + !virtio_vdev_has_feature(vq->vdev, VIRTIO_F_IN_ORDER)) { virtqueue_packed_fill(vq, elem, len, idx); } else { virtqueue_split_fill(vq, elem, len, idx); @@ -997,18 +998,53 @@ static void virtqueue_split_flush(VirtQueue *vq, unsi= gned int count) =20 static void virtqueue_packed_flush(VirtQueue *vq, unsigned int count) { - unsigned int i, ndescs =3D 0; + unsigned int i, j, uelem_idx, ndescs =3D 0; =20 if (unlikely(!vq->vring.desc)) { return; } =20 - for (i =3D 1; i < count; i++) { - virtqueue_packed_fill_desc(vq, &vq->used_elems[i], i, false); - ndescs +=3D vq->used_elems[i].ndescs; + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_IN_ORDER)) { + /* First expected element is used, nothing to do */ + if (vq->used_elems[vq->used_idx].in_num + + vq->used_elems[vq->used_idx].out_num <=3D 0) { + return; + } + + j =3D vq->used_idx; + + for (i =3D j + 1; ; i++) { + uelem_idx =3D i % vq->vring.num; + + /* Stop if element has been used */ + if (vq->used_elems[uelem_idx].in_num + + vq->used_elems[uelem_idx].out_num <=3D 0) { + break; + } + + virtqueue_packed_fill_desc(vq, &vq->used_elems[uelem_idx], + uelem_idx, false); + ndescs +=3D vq->used_elems[uelem_idx].ndescs; + + /* Mark this element as used */ + vq->used_elems[uelem_idx].in_num =3D 0; + vq->used_elems[uelem_idx].out_num =3D 0; + } + + /* Mark first expected element as used */ + vq->used_elems[vq->used_idx].in_num =3D 0; + vq->used_elems[vq->used_idx].out_num =3D 0; + } else { + j =3D 0; + + for (i =3D 1; i < count; i++) { + virtqueue_packed_fill_desc(vq, &vq->used_elems[i], i, false); + ndescs +=3D vq->used_elems[i].ndescs; + } } - virtqueue_packed_fill_desc(vq, &vq->used_elems[0], 0, true); - ndescs +=3D vq->used_elems[0].ndescs; + + virtqueue_packed_fill_desc(vq, &vq->used_elems[j], j, true); + ndescs +=3D vq->used_elems[j].ndescs; =20 vq->inuse -=3D ndescs; vq->used_idx +=3D ndescs; --=20 2.39.3 From nobody Sat May 11 22:40:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711643064385765.9462975235627; Thu, 28 Mar 2024 09:24:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rpsWl-00077N-0P; Thu, 28 Mar 2024 12:22:56 -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 1rpsWX-00071H-Lh; Thu, 28 Mar 2024 12:22:41 -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 1rpsWT-000874-FD; Thu, 28 Mar 2024 12:22:41 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42SFOjHv000733; Thu, 28 Mar 2024 16:22:12 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3x4cxy3jc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 16:22:11 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 42SG6uJk015089; Thu, 28 Mar 2024 16:22:11 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3x1nhgfgkp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 16:22:11 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 42SGM5a3010492; Thu, 28 Mar 2024 16:22:10 GMT Received: from jonah-ol8.us.oracle.com (dhcp-10-39-220-183.vpn.oracle.com [10.39.220.183]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3x1nhgfgcy-5; Thu, 28 Mar 2024 16:22:10 +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-type : content-transfer-encoding; s=corp-2023-11-20; bh=NCxxLo4RlxRydMdSCKc3FePLGo3S5WU5DOyvQHDa3kg=; b=O5+rkGoeZLNWH313Xt8I/2mBLzm1oYLP8ygLT7xJDWIIw+nEI3zXcR7t9DuJilF2lx/G MB5LoY/DxU6HalxTGOYlAsKvTBQ0AYRZVkFdX87MiH2rLTYp+mkjBALjCnHQY5MZiS61 DoHCjF+MH5GgAMuHZJNMaxtM+PicALZ+DYOjvIj6Uko9LjXoQzesRPLS79F08HEopaiq WttlTo1Xg9gXTijLw4pVPpjLqwiNXbytH1o/wpmC+9QIJriavkKCkefwxMgyjW9lsq6x 8D+CNesuVx7kWdJ+H+/xHYyNJq/bkPOTHkLd3Z2APuricSXQna87t2ugde1zh/rgvrY5 vQ== 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: [RFC v2 4/5] vhost, vhost-user: Add VIRTIO_F_IN_ORDER to vhost feature bits Date: Thu, 28 Mar 2024 12:22:02 -0400 Message-Id: <20240328162203.3775114-5-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240328162203.3775114-1-jonah.palmer@oracle.com> References: <20240328162203.3775114-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_15,2024-03-28_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403280111 X-Proofpoint-ORIG-GUID: GBAbzjABFBmkmS9YtKLnshBMZm8A-t79 X-Proofpoint-GUID: GBAbzjABFBmkmS9YtKLnshBMZm8A-t79 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1711643064799100002 Add support for the VIRTIO_F_IN_ORDER feature across a variety of vhost devices. The inclusion of VIRTIO_F_IN_ORDER in the feature bits arrays for these devices ensures that the backend is capable of offering and providing support for this feature, and that it can be disabled if the backend does not support it. Acked-by: Eugenio P=C3=A9rez Signed-off-by: Jonah Palmer --- hw/block/vhost-user-blk.c | 1 + hw/net/vhost_net.c | 2 ++ hw/scsi/vhost-scsi.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/virtio/vhost-user-fs.c | 1 + hw/virtio/vhost-user-vsock.c | 1 + net/vhost-vdpa.c | 1 + 7 files changed, 8 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 6a856ad51a..d176ed857e 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -51,6 +51,7 @@ static const int user_feature_bits[] =3D { VIRTIO_F_RING_PACKED, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VHOST_INVALID_FEATURE_BIT }; =20 diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index fd1a93701a..eb0b1c06e5 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -48,6 +48,7 @@ static const int kernel_feature_bits[] =3D { VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VIRTIO_NET_F_HASH_REPORT, VHOST_INVALID_FEATURE_BIT }; @@ -76,6 +77,7 @@ static const int user_feature_bits[] =3D { VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VIRTIO_NET_F_RSS, VIRTIO_NET_F_HASH_REPORT, VIRTIO_NET_F_GUEST_USO4, diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index ae26bc19a4..40e7630191 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -38,6 +38,7 @@ static const int kernel_feature_bits[] =3D { VIRTIO_RING_F_EVENT_IDX, VIRTIO_SCSI_F_HOTPLUG, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VHOST_INVALID_FEATURE_BIT }; =20 diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index a63b1f4948..1d59951ab7 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -36,6 +36,7 @@ static const int user_feature_bits[] =3D { VIRTIO_RING_F_EVENT_IDX, VIRTIO_SCSI_F_HOTPLUG, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, VHOST_INVALID_FEATURE_BIT }; =20 diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index cca2cd41be..9243dbb128 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -33,6 +33,7 @@ static const int user_feature_bits[] =3D { VIRTIO_F_RING_PACKED, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_RESET, + VIRTIO_F_IN_ORDER, =20 VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 9431b9792c..cc7e4e47b4 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -21,6 +21,7 @@ static const int user_feature_bits[] =3D { VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_F_IN_ORDER, VHOST_INVALID_FEATURE_BIT }; =20 diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 85e73dd6a7..ed3185acfa 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -62,6 +62,7 @@ const int vdpa_feature_bits[] =3D { VIRTIO_F_RING_PACKED, VIRTIO_F_RING_RESET, VIRTIO_F_VERSION_1, + VIRTIO_F_IN_ORDER, VIRTIO_NET_F_CSUM, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, VIRTIO_NET_F_CTRL_MAC_ADDR, --=20 2.39.3 From nobody Sat May 11 22:40:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1711643016; cv=none; d=zohomail.com; s=zohoarc; b=idCtCw6nRAEfaBhLHjQmCYr2bQMCiaQZFc5AqgWwIqScwh6StUCJkJ2VoRLrkV8Yx1QWQ2ZiT4q91jCLxfln7EUeoZZb3/KE4yRGZC6cQisYzwkfna5QvD+RMnMcuJAV9ISBpdH0ftKNKGy7pAiZwx2fW4MtjcYgURbZWyaQVGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711643016; h=Content-Type: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=RXAXZmlb2weeKovb+RHg6OccVPWam3gxkItbEs0ZnTE=; b=O61oRs9AUDTPoHaf7QThh+vNLGzGeJfCUuq4gYsKukfX7AdhwNuP5Zp9t/gCFdIDMbHoUkn4iNAKfy59vDcPb5438Z5wqI6gXXCNtZFaqCO2zBDRJHdpSAHf9787cy+C5deamW3bhdAnEALoy/hW8rq7J436+CCTomhRWCObJss= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711643016737370.87380070095367; Thu, 28 Mar 2024 09:23:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rpsWb-00072a-MO; Thu, 28 Mar 2024 12:22:46 -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 1rpsWW-00070p-5n; Thu, 28 Mar 2024 12:22:40 -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 1rpsWT-00087I-FI; Thu, 28 Mar 2024 12:22:39 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42SFP5AL010488; Thu, 28 Mar 2024 16:22:14 GMT Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3x2f6h8w77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 16:22:14 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 42SG5hSI015060; Thu, 28 Mar 2024 16:22:13 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3x1nhgfgnn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Mar 2024 16:22:13 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 42SGM5a5010492; Thu, 28 Mar 2024 16:22:12 GMT Received: from jonah-ol8.us.oracle.com (dhcp-10-39-220-183.vpn.oracle.com [10.39.220.183]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3x1nhgfgcy-6; Thu, 28 Mar 2024 16:22:12 +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-type : content-transfer-encoding; s=corp-2023-11-20; bh=RXAXZmlb2weeKovb+RHg6OccVPWam3gxkItbEs0ZnTE=; b=OBgkSReYnmG1FFzo3PuYXBAu5WIWK8VArxdDZlEE6aeu0qdESiBg9EsYCZOthGGjsrXV 8qd2bdE4VxC8w++k0unnwslVEzTPxQJIRRr9H6xKv0RmwyZM3UitSMA/kYT/1/f3pZD/ pa1voubumFvBG8anVw68Y0gVlFRiu63vY3sClOkcMtN7BrCpV/jeIurE8wcvDfCQObYC iIIhnScrdej64tBj0Wy+w+5+bwbUxY+ih6TrWV31F/EObtIUs04eql1jBDKfcpwr3d1w sfSd0XuycHDpeBa6Yo2Tuj4lJkwiNOYzQhBV8CNqTkXywYR3RVpsYgkZD82R9iBGDN1F eg== 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: [RFC v2 5/5] virtio: Add VIRTIO_F_IN_ORDER property definition Date: Thu, 28 Mar 2024 12:22:03 -0400 Message-Id: <20240328162203.3775114-6-jonah.palmer@oracle.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240328162203.3775114-1-jonah.palmer@oracle.com> References: <20240328162203.3775114-1-jonah.palmer@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-28_15,2024-03-28_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2403210000 definitions=main-2403280111 X-Proofpoint-GUID: 6mNrfM0ubRVKoL65MUibRyNUmgW7_cyL X-Proofpoint-ORIG-GUID: 6mNrfM0ubRVKoL65MUibRyNUmgW7_cyL 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1711643018941100003 Extend the virtio device property definitions to include the VIRTIO_F_IN_ORDER feature. The default state of this feature is disabled, allowing it to be explicitly enabled where it's supported. Acked-by: Eugenio P=C3=A9rez Signed-off-by: Jonah Palmer --- include/hw/virtio/virtio.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 910b2a3427..dd0ba6e57f 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -385,7 +385,9 @@ typedef struct VirtIORNGConf VirtIORNGConf; DEFINE_PROP_BIT64("packed", _state, _field, \ VIRTIO_F_RING_PACKED, false), \ DEFINE_PROP_BIT64("queue_reset", _state, _field, \ - VIRTIO_F_RING_RESET, true) + VIRTIO_F_RING_RESET, true), \ + DEFINE_PROP_BIT64("in_order", _state, _field, \ + VIRTIO_F_IN_ORDER, false) =20 hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n); bool virtio_queue_enabled_legacy(VirtIODevice *vdev, int n); --=20 2.39.3