From patchwork Thu Jul 20 18:14:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 084D9EB64DA for ; Thu, 20 Jul 2023 18:15:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBI-0004DH-14; Thu, 20 Jul 2023 14:15:16 -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 1qMYBE-0004CN-J2 for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBD-0003Gn-4w for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876907; 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=409EOOckyGprOXBiPYJE6nLyFod7nNzqMkRIEKlNrxM=; b=EsMw1hHaKQsYscE5NCpavDK6SINTvy3DBDXxCZOoSz6HSxXsgbj9ComEXUDNGCe8GGogVO O8XIUsmUHEo0SA7c3jgt/hV16qTjYwaLMWSSjB1qD/2wBshrgMW+gPtFDn92+YKNUOss/O kEgQv1vRnxMxJb480pPfbVMdJKhLHK8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-209-A191j2kRPru0XieQfzgcvw-1; Thu, 20 Jul 2023 14:15:05 -0400 X-MC-Unique: A191j2kRPru0XieQfzgcvw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DEC6088D1A0; Thu, 20 Jul 2023 18:15:04 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E9D72166B25; Thu, 20 Jul 2023 18:15:03 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 01/12] vhost: add vhost_reset_queue_op Date: Thu, 20 Jul 2023 20:14:48 +0200 Message-Id: <20230720181459.607008-2-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org So different vhost backends can perform custom actions at queue reset. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-backend.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h index 31a251a9f5..37e05fa1f9 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -133,6 +133,8 @@ typedef int (*vhost_set_config_call_op)(struct vhost_dev *dev, typedef void (*vhost_reset_status_op)(struct vhost_dev *dev); +typedef void (*vhost_reset_queue_op)(struct vhost_dev *dev, int idx); + typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -181,6 +183,7 @@ typedef struct VhostOps { vhost_force_iommu_op vhost_force_iommu; vhost_set_config_call_op vhost_set_config_call; vhost_reset_status_op vhost_reset_status; + vhost_reset_queue_op vhost_reset_queue; } VhostOps; int vhost_backend_update_device_iotlb(struct vhost_dev *dev, From patchwork Thu Jul 20 18:14:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9CF00EB64DA for ; Thu, 20 Jul 2023 18:16:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBd-0004L7-Hs; Thu, 20 Jul 2023 14:15:37 -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 1qMYBJ-0004Dm-QY for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBG-0003I3-O4 for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876913; 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=Nag6baYm1KG8EZBPsQkKS/2lJrXvwaihqgRRI4ssZX8=; b=dhs0iUJbeqFqq/xqo/nOrHKxGPhatKk33+YPRrfQ4AhC6NbnQVuiSHKyEgNjdgPQCy9kvi 7Fdt0mqthXaXYAJXBeFQIrThwciimpF2x5po08kjZ09MhTBWMCwo9wwTYlJqMD/GBmo6AD ehNjp+N2B3mdy/Sq4tab/WfGsshO1HY= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-83-o2SLo1nhMSC3D4TIvPaW6g-1; Thu, 20 Jul 2023 14:15:07 -0400 X-MC-Unique: o2SLo1nhMSC3D4TIvPaW6g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 79D851C04356; Thu, 20 Jul 2023 18:15:06 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28D012166B25; Thu, 20 Jul 2023 18:15:05 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 02/12] vhost: add vhost_restart_queue_op Date: Thu, 20 Jul 2023 20:14:49 +0200 Message-Id: <20230720181459.607008-3-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org So different vhost backends can perform custom actions at queue restart. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-backend.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h index 37e05fa1f9..651402af10 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -135,6 +135,8 @@ typedef void (*vhost_reset_status_op)(struct vhost_dev *dev); typedef void (*vhost_reset_queue_op)(struct vhost_dev *dev, int idx); +typedef int (*vhost_restart_queue_op)(struct vhost_dev *dev, int idx); + typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -184,6 +186,7 @@ typedef struct VhostOps { vhost_set_config_call_op vhost_set_config_call; vhost_reset_status_op vhost_reset_status; vhost_reset_queue_op vhost_reset_queue; + vhost_restart_queue_op vhost_restart_queue; } VhostOps; int vhost_backend_update_device_iotlb(struct vhost_dev *dev, From patchwork Thu Jul 20 18:14:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BE260EB64DA for ; Thu, 20 Jul 2023 18:15:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBJ-0004DK-LT; Thu, 20 Jul 2023 14:15:18 -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 1qMYBG-0004CZ-MX for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBE-0003HJ-6r for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876910; 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=8f4eu9n15Kw63ow2RmMKDIC50OvvS8TO7HOPVAUm5P8=; b=P5Cw2Xn/NY4MEjCjbIamTtCdJUJEW1Kj0Zofb4VWwaYvo97fcksCxiJ/3f0j+hYt+WciOW xB3CgzvbB2fjNvtGcWEG6ZHOjwDZ3oT2UmkJtmZLwNwN0xwEuD8RHKl3WwaYiq3GAORXtg RhROBaEmBSizvZ/dlAT6OinY8+MrLc0= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-189-G4igimKGNB6CjPl4WvApKA-1; Thu, 20 Jul 2023 14:15:08 -0400 X-MC-Unique: G4igimKGNB6CjPl4WvApKA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 147A32804601; Thu, 20 Jul 2023 18:15:08 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6FDA2166B25; Thu, 20 Jul 2023 18:15:06 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 03/12] vhost_net: Use ops->vhost_restart_queue in vhost_net_virtqueue_restart Date: Thu, 20 Jul 2023 20:14:50 +0200 Message-Id: <20230720181459.607008-4-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Actually use vhost_restart_queue operation at restart. Signed-off-by: Eugenio Pérez --- hw/net/vhost_net.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 6b958d6363..416b7d8132 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -608,14 +608,16 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc, goto err_start; } - if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { + if (vhost_ops->vhost_restart_queue) { + r = vhost_ops->vhost_restart_queue(&net->dev, idx); + } else if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { file.index = idx; file.fd = net->backend; r = vhost_net_set_backend(&net->dev, &file); - if (r < 0) { - r = -errno; - goto err_start; - } + } + if (r < 0) { + r = -errno; + goto err_start; } return 0; From patchwork Thu Jul 20 18:14:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 13A35EB64DD for ; Thu, 20 Jul 2023 18:15:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBe-0004gE-M1; Thu, 20 Jul 2023 14:15:38 -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 1qMYBJ-0004Dl-QV for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBH-0003JV-2z for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876914; 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=eu4qTpdtrX2d/XYLxdli0lOHKKZpEE/V8SV9u/E5FGY=; b=Sa3GCj/NHyltQXVg8ieX62RiL34tlQwL8/R6CSLJMZDRkU7Rr2axQOIbcA6Ou54pRwGsx2 M2w1z5M6NwUiUXKuRhRPSLdpssGsZo3ym/LGMKsuDas5tuOddRAPmV4mXQ/iWS7NqcVf4d DQyhtumC+l3/OBrAnfxZqMxUzi/mAI8= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-46-p-byukaQP0-7Ei2lchxz0w-1; Thu, 20 Jul 2023 14:15:10 -0400 X-MC-Unique: p-byukaQP0-7Ei2lchxz0w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A35833C01DFA; Thu, 20 Jul 2023 18:15:09 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52A252166B25; Thu, 20 Jul 2023 18:15:08 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 04/12] vhost_net: Use ops->vhost_reset_queue in vhost_net_virtqueue_reset Date: Thu, 20 Jul 2023 20:14:51 +0200 Message-Id: <20230720181459.607008-5-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Actually use vhost_reset_queue operation at queue reset. Signed-off-by: Eugenio Pérez --- hw/net/vhost_net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 416b7d8132..5516b7a5aa 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -571,7 +571,9 @@ void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc, idx = vhost_ops->vhost_get_vq_index(&net->dev, vq_index); - if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { + if (vhost_ops->vhost_reset_queue) { + vhost_ops->vhost_reset_queue(&net->dev, idx); + } else if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { file.index = idx; int r = vhost_net_set_backend(&net->dev, &file); assert(r >= 0); From patchwork Thu Jul 20 18:14:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D18D2EB64DA for ; Thu, 20 Jul 2023 18:16:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBR-0004Ed-SU; Thu, 20 Jul 2023 14:15:36 -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 1qMYBI-0004DJ-5k for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBG-0003I1-D6 for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876913; 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=PYBd5yDnfH/T6/KePGzF5vmEZfP6eou01c1gPkfVF3Q=; b=ZXeCD2r906BTMntaNtu/sNwv4LUhFIykdQVJFZ7NmnMlbPu+IiMggS5Em1jbynTzvwNNhJ c3MjCJoB8tOmgXbMyR0PzuKQwTzkVUh1YP0B9Nf4YQghxbtFDVmGJrvwnezAkViH7euL0R uXaZKeBmIW4QnKM5P92JhGtnpS0/h74= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-369-dpdhQeiUPC6mx4dH7L738g-1; Thu, 20 Jul 2023 14:15:11 -0400 X-MC-Unique: dpdhQeiUPC6mx4dH7L738g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D39B8F1840; Thu, 20 Jul 2023 18:15:11 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id E133C2166B26; Thu, 20 Jul 2023 18:15:09 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 05/12] vdpa: add vhost_vdpa_set_vring_ready_internal Date: Thu, 20 Jul 2023 20:14:52 +0200 Message-Id: <20230720181459.607008-6-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Reset a virtqueue reuses this call with .num = 0, so let's make it possible to use that way. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 12 +++++++++--- hw/virtio/trace-events | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index f51f5d9969..e7ab69165c 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -528,19 +528,25 @@ int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_range) return ret < 0 ? -errno : 0; } -int vhost_vdpa_set_vring_ready(struct vhost_vdpa *v, unsigned idx) +static int vhost_vdpa_set_vring_ready_internal(struct vhost_vdpa *v, + unsigned idx, bool enable) { struct vhost_dev *dev = v->dev; struct vhost_vring_state state = { .index = idx, - .num = 1, + .num = enable, }; int r = vhost_vdpa_call(dev, VHOST_VDPA_SET_VRING_ENABLE, &state); - trace_vhost_vdpa_set_vring_ready(dev, idx, r); + trace_vhost_vdpa_set_vring_ready(dev, idx, enable, r); return r; } +int vhost_vdpa_set_vring_ready(struct vhost_vdpa *v, unsigned idx) +{ + return vhost_vdpa_set_vring_ready_internal(v, idx, true); +} + /* * The use of this function is for requests that only need to be * applied once. Typically such request occurs at the beginning diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 4f6a6ba428..9b90da73af 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -46,7 +46,7 @@ vhost_vdpa_set_features(void *dev, uint64_t features) "dev: %p features: 0x%"PRI vhost_vdpa_get_device_id(void *dev, uint32_t device_id) "dev: %p device_id %"PRIu32 vhost_vdpa_reset_device(void *dev, uint8_t status) "dev: %p status: 0x%"PRIx8 vhost_vdpa_get_vq_index(void *dev, int idx, int vq_idx) "dev: %p idx: %d vq idx: %d" -vhost_vdpa_set_vring_ready(void *dev, unsigned i, int r) "dev: %p, idx: %u, r: %d" +vhost_vdpa_set_vring_ready(void *dev, unsigned i, bool e, int r) "dev: %p, idx: %u, num: %d, r: %d" vhost_vdpa_dump_config(void *dev, const char *line) "dev: %p %s" vhost_vdpa_set_config(void *dev, uint32_t offset, uint32_t size, uint32_t flags) "dev: %p offset: %"PRIu32" size: %"PRIu32" flags: 0x%"PRIx32 vhost_vdpa_get_config(void *dev, void *config, uint32_t config_len) "dev: %p config: %p config_len: %"PRIu32 From patchwork Thu Jul 20 18:14:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 137A5EB64DA for ; Thu, 20 Jul 2023 18:16:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBe-0004ge-MS; Thu, 20 Jul 2023 14:15:38 -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 1qMYBL-0004Ea-N4 for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBK-0003KT-AA for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876917; 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=qg88jCdQgB4EKRvwYnaU1oPtFH+EzvWegO2XUblXAbg=; b=Fu7XIyI80xWgoAC8p6hh2+IxORpS7R84hfrSUNcGT+VCfDpCYSwrX/vwY+DTFB3y1u95w5 5C1TDSLI1jaBBvDE7R660RfDjV84KuJjI5WuP2zpB0FV/WLIkOaxrBkKpf+PYYpJrxOU2d BcZBvG/4zCHVeB/xmEBP4RT5hL88q9M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-543-xQZg8CVsMICA-mX4k1V5pQ-1; Thu, 20 Jul 2023 14:15:14 -0400 X-MC-Unique: xQZg8CVsMICA-mX4k1V5pQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C9AE6858EED; Thu, 20 Jul 2023 18:15:12 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79ECE2166B26; Thu, 20 Jul 2023 18:15:11 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 06/12] vdpa: add vhost_vdpa_svq_stop Date: Thu, 20 Jul 2023 20:14:53 +0200 Message-Id: <20230720181459.607008-7-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org To split each SVQ stop in its own stop routine let's us to reset a VQ individually, and to keep future vhost_vdpa_reset_queue symmetrical with vhost_vdpa_reset_queue. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index e7ab69165c..6ae276ccde 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1263,6 +1263,18 @@ err: return false; } +static void vhost_vdpa_svq_stop(struct vhost_dev *dev, unsigned idx) +{ + struct vhost_vdpa *v = dev->opaque; + VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, idx); + + vhost_svq_stop(svq); + vhost_vdpa_svq_unmap_rings(dev, svq); + + event_notifier_cleanup(&svq->hdev_kick); + event_notifier_cleanup(&svq->hdev_call); +} + static void vhost_vdpa_svqs_stop(struct vhost_dev *dev) { struct vhost_vdpa *v = dev->opaque; @@ -1272,13 +1284,7 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev) } for (unsigned i = 0; i < v->shadow_vqs->len; ++i) { - VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i); - - vhost_svq_stop(svq); - vhost_vdpa_svq_unmap_rings(dev, svq); - - event_notifier_cleanup(&svq->hdev_kick); - event_notifier_cleanup(&svq->hdev_call); + vhost_vdpa_svq_stop(dev, i); } } From patchwork Thu Jul 20 18:14:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 15502C00528 for ; Thu, 20 Jul 2023 18:16:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBg-0004pY-OL; Thu, 20 Jul 2023 14:15:42 -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 1qMYBQ-0004Kv-Pt for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBL-0003Kx-4z for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876918; 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=5QotPEGjo10DbOO0YXVh4lwgMOojeZ5NQ9zmNRsLIvE=; b=IIEKU0Mw9q1sRfyRLebyl+RZNpNKUiVaFbUkLgbefs4V4L7NiY2F4oaFllTVs7j76XUlDt WXz6UPPaWxSP6QIHq/l9JIv0d28+eidwz8pXn3V9QZ1Moysd67obONSE0ovIoGzk5ieyQ7 kvBzlsmJWCPyHRwQmzVC6u4wk9pTBkQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-139-6bYFrr7ePyesrB6GhOo3ww-1; Thu, 20 Jul 2023 14:15:15 -0400 X-MC-Unique: 6bYFrr7ePyesrB6GhOo3ww-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63C0A800C7F; Thu, 20 Jul 2023 18:15:14 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1285A2166B25; Thu, 20 Jul 2023 18:15:12 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 07/12] vdpa: add vhost_vdpa_reset_queue Date: Thu, 20 Jul 2023 20:14:54 +0200 Message-Id: <20230720181459.607008-8-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Split out vq reset operation in its own function, as it may be called with ring reset. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 6ae276ccde..df2515a247 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -547,6 +547,21 @@ int vhost_vdpa_set_vring_ready(struct vhost_vdpa *v, unsigned idx) return vhost_vdpa_set_vring_ready_internal(v, idx, true); } +/* TODO: Properly reorder static functions */ +static void vhost_vdpa_svq_stop(struct vhost_dev *dev, unsigned idx); +static void vhost_vdpa_reset_queue(struct vhost_dev *dev, int idx) +{ + struct vhost_vdpa *v = dev->opaque; + + if (dev->features & VIRTIO_F_RING_RESET) { + vhost_vdpa_set_vring_ready_internal(v, idx, false); + } + + if (v->shadow_vqs_enabled) { + vhost_vdpa_svq_stop(dev, idx - dev->vq_index); + } +} + /* * The use of this function is for requests that only need to be * applied once. Typically such request occurs at the beginning @@ -1543,4 +1558,5 @@ const VhostOps vdpa_ops = { .vhost_force_iommu = vhost_vdpa_force_iommu, .vhost_set_config_call = vhost_vdpa_set_config_call, .vhost_reset_status = vhost_vdpa_reset_status, + .vhost_reset_queue = vhost_vdpa_reset_queue, }; From patchwork Thu Jul 20 18:14:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7A3DFC001DC for ; Thu, 20 Jul 2023 18:16:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBg-0004pV-OP; Thu, 20 Jul 2023 14:15:42 -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 1qMYBN-0004F2-SE for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBM-0003LK-E2 for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876919; 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=ojGrOHq8nhRb5TNbtbaXmRffqo/08cKoEX9WwfmfcUE=; b=LwxFFWI/gPstGvbyClDPgreBl3s+XWIwXBRatvtwSH/N3IwtjFIFCRSxv7vqvTm5rHchcx J5Z5BhMr1LxZ5IKa2EhAb2gNZ4OvfGzFbcClPvT3aOWoJayg4PUHQ3yGHHNAlD3RYp4C3H 7lsLM3Bsf1573+Ze/TSO9l/BCnLy9GQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-615-9ICOeEUwMuqzd8UeYcsh0Q-1; Thu, 20 Jul 2023 14:15:16 -0400 X-MC-Unique: 9ICOeEUwMuqzd8UeYcsh0Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F19EC800C7F; Thu, 20 Jul 2023 18:15:15 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id A081E2166B26; Thu, 20 Jul 2023 18:15:14 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 08/12] vdpa: add vhost_vdpa_svq_start Date: Thu, 20 Jul 2023 20:14:55 +0200 Message-Id: <20230720181459.607008-9-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org To split each SVQ in its own initialization routine let's us to restart a VQ individually, and to keep future vhost_vdpa_restart_queue symmetrical with vhost_vdpa_reset_queue. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 67 ++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index df2515a247..7248072989 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1223,6 +1223,46 @@ static bool vhost_vdpa_svq_setup(struct vhost_dev *dev, return r == 0; } +static bool vhost_vdpa_svq_start(struct vhost_dev *dev, unsigned i, + Error **errp) +{ + struct vhost_vdpa *v = dev->opaque; + VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i); + VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i); + struct vhost_vring_addr addr = { + .index = dev->vq_index + i, + }; + int r; + bool ok = vhost_vdpa_svq_setup(dev, svq, i, errp); + if (unlikely(!ok)) { + goto err; + } + + vhost_svq_start(svq, dev->vdev, vq, v->iova_tree); + ok = vhost_vdpa_svq_map_rings(dev, svq, &addr, errp); + if (unlikely(!ok)) { + goto err_map; + } + + /* Override vring GPA set by vhost subsystem */ + r = vhost_vdpa_set_vring_dev_addr(dev, &addr); + if (unlikely(r != 0)) { + error_setg_errno(errp, -r, "Cannot set device address"); + goto err_set_addr; + } + + return true; + +err_set_addr: + vhost_vdpa_svq_unmap_rings(dev, g_ptr_array_index(v->shadow_vqs, i)); + +err_map: + vhost_svq_stop(g_ptr_array_index(v->shadow_vqs, i)); + +err: + return false; +} + static bool vhost_vdpa_svqs_start(struct vhost_dev *dev) { struct vhost_vdpa *v = dev->opaque; @@ -1234,39 +1274,14 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *dev) } for (i = 0; i < v->shadow_vqs->len; ++i) { - VirtQueue *vq = virtio_get_queue(dev->vdev, dev->vq_index + i); - VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i); - struct vhost_vring_addr addr = { - .index = dev->vq_index + i, - }; - int r; - bool ok = vhost_vdpa_svq_setup(dev, svq, i, &err); + bool ok = vhost_vdpa_svq_start(dev, i, &err); if (unlikely(!ok)) { goto err; } - - vhost_svq_start(svq, dev->vdev, vq, v->iova_tree); - ok = vhost_vdpa_svq_map_rings(dev, svq, &addr, &err); - if (unlikely(!ok)) { - goto err_map; - } - - /* Override vring GPA set by vhost subsystem */ - r = vhost_vdpa_set_vring_dev_addr(dev, &addr); - if (unlikely(r != 0)) { - error_setg_errno(&err, -r, "Cannot set device address"); - goto err_set_addr; - } } return true; -err_set_addr: - vhost_vdpa_svq_unmap_rings(dev, g_ptr_array_index(v->shadow_vqs, i)); - -err_map: - vhost_svq_stop(g_ptr_array_index(v->shadow_vqs, i)); - err: error_reportf_err(err, "Cannot setup SVQ %u: ", i); for (unsigned j = 0; j < i; ++j) { From patchwork Thu Jul 20 18:14:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EF1D6EB64DA for ; Thu, 20 Jul 2023 18:15:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBk-00059Q-TX; Thu, 20 Jul 2023 14:15:45 -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 1qMYBR-0004L8-UT for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBQ-0003Lx-JC for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876923; 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=+ytfb3HXV+wFwSIUmTNAnsUHTHuXBYfLCvZ0GHbLF5w=; b=ijUGZ9Pc19Q8ABUrYNU8psEVXzZzCJI7ZvSdO1AgtBZ1VpIoxiptJb14x2/waq4NazacCB MDPmrojVfJLSC2i2ALiW9kpyBgGrtlQdmXhoZFTckl6ytzxEjgeNfWwuZaE+Ofjx1DGdE+ warKu/aCorz4gJRKepCgBi7aG0Zgmy8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-372-di8aBrTNMa6DgL5B80uODA-1; Thu, 20 Jul 2023 14:15:18 -0400 X-MC-Unique: di8aBrTNMa6DgL5B80uODA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8CFAC88D196; Thu, 20 Jul 2023 18:15:17 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A7222166B25; Thu, 20 Jul 2023 18:15:16 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 09/12] vdpa: add vhost_vdpa_restart_queue Date: Thu, 20 Jul 2023 20:14:56 +0200 Message-Id: <20230720181459.607008-10-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Split out vq restart operation in its own function, as it may be called with ring reset. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-vdpa.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 7248072989..7b24fa3e12 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -562,6 +562,29 @@ static void vhost_vdpa_reset_queue(struct vhost_dev *dev, int idx) } } +/* TODO: Properly reorder static functions */ +static bool vhost_vdpa_svq_start(struct vhost_dev *dev, unsigned i, + Error **errp); +static int vhost_vdpa_restart_queue(struct vhost_dev *dev, int idx) +{ + struct vhost_vdpa *v = dev->opaque; + + if (v->shadow_vqs_enabled) { + Error *err = NULL; + bool ok = vhost_vdpa_svq_start(dev, idx, &err); + if (unlikely(!ok)) { + error_report_err(err); + return -1; + } + } + + if (dev->features & VIRTIO_F_RING_RESET) { + return vhost_vdpa_set_vring_ready_internal(v, idx, true); + } + + return 0; +} + /* * The use of this function is for requests that only need to be * applied once. Typically such request occurs at the beginning @@ -1574,4 +1597,5 @@ const VhostOps vdpa_ops = { .vhost_set_config_call = vhost_vdpa_set_config_call, .vhost_reset_status = vhost_vdpa_reset_status, .vhost_reset_queue = vhost_vdpa_reset_queue, + .vhost_restart_queue = vhost_vdpa_restart_queue, }; From patchwork Thu Jul 20 18:14:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1A8E0EB64DA for ; Thu, 20 Jul 2023 18:16:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBl-0005I6-Lf; Thu, 20 Jul 2023 14:15: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 1qMYBR-0004Kw-AC for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBP-0003Lr-Nu for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876923; 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=P9CKyKCD2Asr59YwlxOKNQ11bPRWkSiQVn9Bq1tQZj4=; b=KLn7TfdEvq6fy0GnsWdkHZD2msllcmqxdmQ6GClw8AW9fmLfTobEYM/dyOhnXWKWzb6f5w bxUsRL0AfjVrG+9b8lZZlW4rcEwGeak8VtgvFYQfXyM0EqTYavwrQDr79uoM78bUIf+lY0 PftdPFjZymcvZw6oq0ihLumJBZSFTeM= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-414-qCsMew6hOeqEtO4NXk0sKQ-1; Thu, 20 Jul 2023 14:15:19 -0400 X-MC-Unique: qCsMew6hOeqEtO4NXk0sKQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3032F3C01DF3; Thu, 20 Jul 2023 18:15:19 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id CABA32166B25; Thu, 20 Jul 2023 18:15:17 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 10/12] vdpa: enable all vqs if the device support RING_RESET feature Date: Thu, 20 Jul 2023 20:14:57 +0200 Message-Id: <20230720181459.607008-11-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Prefer the ring reset approach against the late enable, as it is more aligned with the standard. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 52415d7e0c..af83de92f8 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -840,8 +840,14 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = { */ static bool vhost_vdpa_should_enable(const struct vhost_vdpa *v) { + VhostVDPAState *s = container_of(v, VhostVDPAState, vhost_vdpa); struct vhost_dev *dev = v->dev; + if (dev->features & VIRTIO_F_RING_RESET && !s->always_svq) { + /* Preventing dataplane processing exposing fake SVQ vring */ + return true; + } + if (!dev->vq_index_end % 2) { /* vDPA device does not have CVQ */ return true; From patchwork Thu Jul 20 18:14:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0D8C7EB64DA for ; Thu, 20 Jul 2023 18:16:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBk-00057w-3l; Thu, 20 Jul 2023 14:15:44 -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 1qMYBX-0004N6-Np for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBU-0003Mi-9t for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876927; 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=6AnXRkfbPBY2lKGkgKhB/5jrIYEC5iVGXI+KaHqNwxg=; b=MhbzljXydb+rrAXm9U3hOvXibuYddf1KfW/R4bhWc+29+4oYV3I9MKlI+PDi42oTVocWxN +6KoWU9wqsJr394Ah9peIDGoFWs0+if997n+llzWIyHp7ufNIlJKbhdn5Qy1VjZCI91alW ZZI4CbF7anyEk2IpC6meO1Gpz0tZU0s= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-HN_1A3gbP9Ok9goyrbYUbQ-1; Thu, 20 Jul 2023 14:15:21 -0400 X-MC-Unique: HN_1A3gbP9Ok9goyrbYUbQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF80E38025EA; Thu, 20 Jul 2023 18:15:20 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E3B32166B25; Thu, 20 Jul 2023 18:15:19 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 11/12] vdpa: use SVQ to stall dataplane while NIC state is being restored Date: Thu, 20 Jul 2023 20:14:58 +0200 Message-Id: <20230720181459.607008-12-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Some dynamic state of a virtio-net vDPA devices is restored from CVQ in the event of a live migration. However, dataplane needs to be disabled so the NIC does not receive buffers in the invalid ring. As a default method to achieve it, let's offer a shadow vring with 0 avail idx. As a fallback method, we will enable dataplane vqs later, as proposed previously. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 49 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index af83de92f8..e14ae48f23 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -338,10 +338,25 @@ static int vhost_vdpa_net_data_start(NetClientState *nc) { VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); struct vhost_vdpa *v = &s->vhost_vdpa; + bool has_cvq = v->dev->vq_index_end % 2; assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA); - if (s->always_svq || + if (has_cvq && (v->dev->features & VIRTIO_F_RING_RESET)) { + /* + * Offer a fake vring to the device while the state is restored + * through CVQ. That way, the guest will not see packets in unexpected + * queues. + * + * This will be undone after loading all state through CVQ, at + * vhost_vdpa_net_load. + * + * TODO: Future optimizations may skip some SVQ setup and teardown, + * like set the right kick and call fd or doorbell maps directly, and + * the iova tree. + */ + v->shadow_vqs_enabled = true; + } else if (s->always_svq || migration_is_setup_or_active(migrate_get_current()->state)) { v->shadow_vqs_enabled = true; v->shadow_data = true; @@ -738,10 +753,34 @@ static int vhost_vdpa_net_load(NetClientState *nc) return r; } - for (int i = 0; i < v->dev->vq_index; ++i) { - r = vhost_vdpa_set_vring_ready(v, i); - if (unlikely(r)) { - return r; + if (v->dev->features & VIRTIO_F_RING_RESET && !s->always_svq && + !migration_is_setup_or_active(migrate_get_current()->state)) { + NICState *nic = qemu_get_nic(s->nc.peer); + int queue_pairs = n->multiqueue ? n->max_queue_pairs : 1; + + for (int i = 0; i < queue_pairs; ++i) { + NetClientState *ncs = qemu_get_peer(nic->ncs, i); + VhostVDPAState *s_i = DO_UPCAST(VhostVDPAState, nc, ncs); + + for (int j = 0; j < 2; ++j) { + vhost_net_virtqueue_reset(v->dev->vdev, ncs->peer, j); + } + + s_i->vhost_vdpa.shadow_vqs_enabled = false; + + for (int j = 0; j < 2; ++j) { + r = vhost_net_virtqueue_restart(v->dev->vdev, ncs->peer, j); + if (unlikely(r < 0)) { + return r; + } + } + } + } else { + for (int i = 0; i < v->dev->vq_index; ++i) { + r = vhost_vdpa_set_vring_ready(v, i); + if (unlikely(r)) { + return r; + } } } From patchwork Thu Jul 20 18:14:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13320971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 792A5EB64DD for ; Thu, 20 Jul 2023 18:16:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMYBn-0005L5-QD; Thu, 20 Jul 2023 14:15:47 -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 1qMYBV-0004LH-Pj for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMYBU-0003Mb-3D for qemu-devel@nongnu.org; Thu, 20 Jul 2023 14:15:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689876927; 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=2ZUd9jk4L3cGs5oDAJws5vHCA57czpNMxR7zblhwXCk=; b=MaS5nMdY7edCSiMnq31eg1so2uyDxzQc+JnREWhmmzXnEaLBBlGRuRW6zrP570uJ+v6MRa TrEXFzfQIlcebLzSmOXE6HIqb3BZLe98aewfI07DQan8DItyOCjDzJC1wjDQb2spQ+HnZE mfF45IVya7VjfVucYB6Mh7SS96uJ4TQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-ujPCZzHOOM2gHf2jsyAoRw-1; Thu, 20 Jul 2023 14:15:22 -0400 X-MC-Unique: ujPCZzHOOM2gHf2jsyAoRw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 58CE485A58A; Thu, 20 Jul 2023 18:15:22 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07B922166B25; Thu, 20 Jul 2023 18:15:20 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: yvugenfi@redhat.com, =?utf-8?q?Eugenio_P=C3=A9rez?= , si-wei.liu@oracle.com, Jason Wang , "Michael S. Tsirkin" , Dragos Tatulea , Shannon Nelson Subject: [RFC PATCH 12/12] vhost: Allow _F_RING_RESET with shadow virtqueue Date: Thu, 20 Jul 2023 20:14:59 +0200 Message-Id: <20230720181459.607008-13-eperezma@redhat.com> In-Reply-To: <20230720181459.607008-1-eperezma@redhat.com> References: <20230720181459.607008-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.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_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This is needed to let CVQ restore at the beginning. Not properly tested with actual guest ring reset, only with the reset from qemu. For this to be included, more test is needed, but this series is a good start for it. Signed-off-by: Eugenio Pérez --- hw/virtio/vhost-shadow-virtqueue.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index 1b1d85306c..6490a98db7 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -34,6 +34,7 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp) switch (b) { case VIRTIO_F_ANY_LAYOUT: case VIRTIO_RING_F_EVENT_IDX: + case VIRTIO_F_RING_RESET: continue; case VIRTIO_F_ACCESS_PLATFORM: