From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16606123073901012.7493891900646; Mon, 15 Aug 2022 18:11:47 -0700 (PDT) Received: from localhost ([::1]:37974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNl7R-0008OI-Sc for importer@patchew.org; Mon, 15 Aug 2022 21:11:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2k-0008TR-LE for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:54 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:48616) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2g-000058-7l for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:52 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNhlnW_1660611997) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:38 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R931e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045176; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNhlnW_1660611997; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 01/24] virtio: sync relevant definitions with linux Date: Tue, 16 Aug 2022 09:06:13 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.54; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-54.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612310042100001 Content-Type: text/plain; charset="utf-8" From: Xuan Zhuo This is updated using scripts/update-linux-headers.sh. Added VIRTIO_F_RING_RESET, VIRTIO_PCI_COMMON_Q_RESET. It came from here: https://github.com/oasis-tcs/virtio-spec/issues/124 https://github.com/oasis-tcs/virtio-spec/issues/139 Add VIRTIO_PCI_COMMON_Q_NDATA, which comes from here: https://github.com/oasis-tcs/virtio-spec/issues/89 Signed-off-by: Xuan Zhuo Signed-off-by: Kangjie Xu --- include/standard-headers/linux/virtio_config.h | 5 +++++ include/standard-headers/linux/virtio_pci.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/include/standard-headers/linux/virtio_config.h b/include/stand= ard-headers/linux/virtio_config.h index 7acd8d4abc..47a7eef5e4 100644 --- a/include/standard-headers/linux/virtio_config.h +++ b/include/standard-headers/linux/virtio_config.h @@ -96,4 +96,9 @@ * Does the device support Single Root I/O Virtualization? */ #define VIRTIO_F_SR_IOV 37 + +/* + * This feature indicates that the driver can reset a queue individually. + */ +#define VIRTIO_F_RING_RESET 40 #endif /* _LINUX_VIRTIO_CONFIG_H */ diff --git a/include/standard-headers/linux/virtio_pci.h b/include/standard= -headers/linux/virtio_pci.h index db7a8e2fcb..be912cfc95 100644 --- a/include/standard-headers/linux/virtio_pci.h +++ b/include/standard-headers/linux/virtio_pci.h @@ -202,6 +202,8 @@ struct virtio_pci_cfg_cap { #define VIRTIO_PCI_COMMON_Q_AVAILHI 44 #define VIRTIO_PCI_COMMON_Q_USEDLO 48 #define VIRTIO_PCI_COMMON_Q_USEDHI 52 +#define VIRTIO_PCI_COMMON_Q_NDATA 56 +#define VIRTIO_PCI_COMMON_Q_RESET 58 =20 #endif /* VIRTIO_PCI_NO_MODERN */ =20 --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612493322426.34250738295646; Mon, 15 Aug 2022 18:14:53 -0700 (PDT) Received: from localhost ([::1]:60742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlAR-0005FI-BR for importer@patchew.org; Mon, 15 Aug 2022 21:14:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2l-0008TY-6t for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:55 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:43216) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2g-00005A-BB for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:54 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNmF.I_1660611998) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:39 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R181e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046050; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNmF.I_1660611998; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 02/24] virtio: introduce __virtio_queue_reset() Date: Tue, 16 Aug 2022 09:06:14 +0800 Message-Id: <0031ce31c24905031d8af9df82af18a1f3c932de.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.56; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-56.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612495189100001 Content-Type: text/plain; charset="utf-8" From: Xuan Zhuo Separate the logic of vq reset. This logic will be called directly later. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- hw/virtio/virtio.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 5d607aeaa0..67d54832a9 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2019,6 +2019,26 @@ static enum virtio_device_endian virtio_current_cpu_= endian(void) } } =20 +static void __virtio_queue_reset(VirtIODevice *vdev, uint32_t i) +{ + vdev->vq[i].vring.desc =3D 0; + vdev->vq[i].vring.avail =3D 0; + vdev->vq[i].vring.used =3D 0; + vdev->vq[i].last_avail_idx =3D 0; + vdev->vq[i].shadow_avail_idx =3D 0; + vdev->vq[i].used_idx =3D 0; + vdev->vq[i].last_avail_wrap_counter =3D true; + vdev->vq[i].shadow_avail_wrap_counter =3D true; + vdev->vq[i].used_wrap_counter =3D true; + virtio_queue_set_vector(vdev, i, VIRTIO_NO_VECTOR); + vdev->vq[i].signalled_used =3D 0; + vdev->vq[i].signalled_used_valid =3D false; + vdev->vq[i].notification =3D true; + vdev->vq[i].vring.num =3D vdev->vq[i].vring.num_default; + vdev->vq[i].inuse =3D 0; + virtio_virtqueue_reset_region_cache(&vdev->vq[i]); +} + void virtio_reset(void *opaque) { VirtIODevice *vdev =3D opaque; @@ -2050,22 +2070,7 @@ void virtio_reset(void *opaque) virtio_notify_vector(vdev, vdev->config_vector); =20 for(i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { - vdev->vq[i].vring.desc =3D 0; - vdev->vq[i].vring.avail =3D 0; - vdev->vq[i].vring.used =3D 0; - vdev->vq[i].last_avail_idx =3D 0; - vdev->vq[i].shadow_avail_idx =3D 0; - vdev->vq[i].used_idx =3D 0; - vdev->vq[i].last_avail_wrap_counter =3D true; - vdev->vq[i].shadow_avail_wrap_counter =3D true; - vdev->vq[i].used_wrap_counter =3D true; - virtio_queue_set_vector(vdev, i, VIRTIO_NO_VECTOR); - vdev->vq[i].signalled_used =3D 0; - vdev->vq[i].signalled_used_valid =3D false; - vdev->vq[i].notification =3D true; - vdev->vq[i].vring.num =3D vdev->vq[i].vring.num_default; - vdev->vq[i].inuse =3D 0; - virtio_virtqueue_reset_region_cache(&vdev->vq[i]); + __virtio_queue_reset(vdev, i); } } =20 --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612148282749.4928646523891; Mon, 15 Aug 2022 18:09:08 -0700 (PDT) Received: from localhost ([::1]:60096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNl4t-0002ql-0E for importer@patchew.org; Mon, 15 Aug 2022 21:09:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2l-0008TQ-6r for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:55 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:51938) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2g-00005E-7T for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:52 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNmF.e_1660611999) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:40 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R201e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046059; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNmF.e_1660611999; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 03/24] virtio: introduce virtio_queue_reset() Date: Tue, 16 Aug 2022 09:06:15 +0800 Message-Id: <271124b687a7e9a2c2d0b06f79f05517a294691a.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.133; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-133.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612149138100003 Content-Type: text/plain; charset="utf-8" From: Xuan Zhuo Introduce a new interface function virtio_queue_reset() to implement reset for vq. Add a new callback to VirtioDeviceClass for queue reset operation for each child device. Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- hw/virtio/virtio.c | 11 +++++++++++ include/hw/virtio/virtio.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 67d54832a9..0e9d41366f 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2039,6 +2039,17 @@ static void __virtio_queue_reset(VirtIODevice *vdev,= uint32_t i) virtio_virtqueue_reset_region_cache(&vdev->vq[i]); } =20 +void virtio_queue_reset(VirtIODevice *vdev, uint32_t queue_index) +{ + VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); + + if (k->queue_reset) { + k->queue_reset(vdev, queue_index); + } + + __virtio_queue_reset(vdev, queue_index); +} + void virtio_reset(void *opaque) { VirtIODevice *vdev =3D opaque; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index db1c0ddf6b..879394299b 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -130,6 +130,7 @@ struct VirtioDeviceClass { void (*set_config)(VirtIODevice *vdev, const uint8_t *config); void (*reset)(VirtIODevice *vdev); void (*set_status)(VirtIODevice *vdev, uint8_t val); + void (*queue_reset)(VirtIODevice *vdev, uint32_t queue_index); /* For transitional devices, this is a bitmap of features * that are only exposed on the legacy interface but not * the modern one. @@ -268,6 +269,7 @@ int virtio_queue_set_host_notifier_mr(VirtIODevice *vde= v, int n, MemoryRegion *mr, bool assign); int virtio_set_status(VirtIODevice *vdev, uint8_t val); void virtio_reset(void *opaque); +void virtio_queue_reset(VirtIODevice *vdev, uint32_t queue_index); void virtio_update_irq(VirtIODevice *vdev); int virtio_set_features(VirtIODevice *vdev, uint64_t val); =20 --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612148282803.8660230657117; Mon, 15 Aug 2022 18:09:08 -0700 (PDT) Received: from localhost ([::1]:60098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNl4s-0002r3-Nr for importer@patchew.org; Mon, 15 Aug 2022 21:09:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2k-0008TV-Oh for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:54 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:38613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2g-00005F-Q0 for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:54 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNhloM_1660612001) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:41 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R111e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045168; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNhloM_1660612001; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 04/24] virtio: introduce virtio_queue_enable() Date: Tue, 16 Aug 2022 09:06:16 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.132; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-132.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612149124100002 Content-Type: text/plain; charset="utf-8" Introduce the interface queue_enable() in VirtioDeviceClass and the fucntion virtio_queue_enable() in virtio, it can be called when VIRTIO_PCI_COMMON_Q_ENABLE is written and related virtqueue can be started. It only supports the devices of virtio 1 or later. The not-supported devices can only start the virtqueue when DRIVER_OK. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- hw/virtio/virtio.c | 14 ++++++++++++++ include/hw/virtio/virtio.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 0e9d41366f..141f18c633 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2050,6 +2050,20 @@ void virtio_queue_reset(VirtIODevice *vdev, uint32_t= queue_index) __virtio_queue_reset(vdev, queue_index); } =20 +void virtio_queue_enable(VirtIODevice *vdev, uint32_t queue_index) +{ + VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); + + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { + error_report("queue_enable is only suppported in devices of virtio= " + "1.0 or later."); + } + + if (k->queue_enable) { + k->queue_enable(vdev, queue_index); + } +} + void virtio_reset(void *opaque) { VirtIODevice *vdev =3D opaque; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 879394299b..085997d8f3 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -131,6 +131,7 @@ struct VirtioDeviceClass { void (*reset)(VirtIODevice *vdev); void (*set_status)(VirtIODevice *vdev, uint8_t val); void (*queue_reset)(VirtIODevice *vdev, uint32_t queue_index); + void (*queue_enable)(VirtIODevice *vdev, uint32_t queue_index); /* For transitional devices, this is a bitmap of features * that are only exposed on the legacy interface but not * the modern one. @@ -270,6 +271,7 @@ int virtio_queue_set_host_notifier_mr(VirtIODevice *vde= v, int n, int virtio_set_status(VirtIODevice *vdev, uint8_t val); void virtio_reset(void *opaque); void virtio_queue_reset(VirtIODevice *vdev, uint32_t queue_index); +void virtio_queue_enable(VirtIODevice *vdev, uint32_t queue_index); void virtio_update_irq(VirtIODevice *vdev); int virtio_set_features(VirtIODevice *vdev, uint64_t val); =20 --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612489178526.0651765379133; Mon, 15 Aug 2022 18:14:49 -0700 (PDT) Received: from localhost ([::1]:60740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlAO-0005CL-58 for importer@patchew.org; Mon, 15 Aug 2022 21:14:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2m-0008Ua-0C for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:56 -0400 Received: from out199-9.us.a.mail.aliyun.com ([47.90.199.9]:56171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2i-00005V-1d for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:55 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNhloe_1660612002) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:42 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R231e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045170; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNhloe_1660612002; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 05/24] virtio: core: vq reset feature negotation support Date: Tue, 16 Aug 2022 09:06:17 +0800 Message-Id: <932993943b00e0a0567a7a78c7f92c97bb105d58.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=47.90.199.9; envelope-from=kangjie.xu@linux.alibaba.com; helo=out199-9.us.a.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612491458100001 Content-Type: text/plain; charset="utf-8" A a new command line parameter "queue_reset" is added. Meanwhile, the vq reset feature is disabled for pre-7.1 machines. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/core/machine.c | 1 + include/hw/virtio/virtio.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index a673302cce..8b22b4647f 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -43,6 +43,7 @@ GlobalProperty hw_compat_7_0[] =3D { { "arm-gicv3-common", "force-8-bit-prio", "on" }, { "nvme-ns", "eui64-default", "on"}, + { "virtio-device", "queue_reset", "false" }, }; const size_t hw_compat_7_0_len =3D G_N_ELEMENTS(hw_compat_7_0); =20 diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 085997d8f3..ed3ecbef80 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -295,7 +295,9 @@ typedef struct VirtIORNGConf VirtIORNGConf; DEFINE_PROP_BIT64("iommu_platform", _state, _field, \ VIRTIO_F_IOMMU_PLATFORM, false), \ DEFINE_PROP_BIT64("packed", _state, _field, \ - VIRTIO_F_RING_PACKED, false) + VIRTIO_F_RING_PACKED, false), \ + DEFINE_PROP_BIT64("queue_reset", _state, _field, \ + VIRTIO_F_RING_RESET, true) =20 hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n); bool virtio_queue_enabled_legacy(VirtIODevice *vdev, int n); --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612313260229.3820333732391; Mon, 15 Aug 2022 18:11:53 -0700 (PDT) Received: from localhost ([::1]:37980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNl7V-000081-EQ for importer@patchew.org; Mon, 15 Aug 2022 21:11:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2k-0008TX-Np for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:54 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:40461) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2h-00005M-Bk for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:54 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNrTgY_1660612003) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:43 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R121e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045192; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNrTgY_1660612003; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 06/24] virtio-pci: support queue reset Date: Tue, 16 Aug 2022 09:06:18 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.57; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-57.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612314001100003 Content-Type: text/plain; charset="utf-8" From: Xuan Zhuo PCI devices support vq reset. Based on this function, the driver can adjust the size of the ring, and quickly recycle the buffer in the ring. The migration of the virtio devices will not happen during a reset operation. This is becuase the global iothread lock is held. Migration thread also needs the lock. As a result, we do not need to migrate the reset state of VirtIOPCIQueue. Signed-off-by: Xuan Zhuo Signed-off-by: Kangjie Xu --- hw/virtio/virtio-pci.c | 19 +++++++++++++++++++ include/hw/virtio/virtio-pci.h | 1 + 2 files changed, 20 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 45327f0b31..ec8e92052f 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1246,6 +1246,9 @@ static uint64_t virtio_pci_common_read(void *opaque, = hwaddr addr, case VIRTIO_PCI_COMMON_Q_USEDHI: val =3D proxy->vqs[vdev->queue_sel].used[1]; break; + case VIRTIO_PCI_COMMON_Q_RESET: + val =3D proxy->vqs[vdev->queue_sel].reset; + break; default: val =3D 0; } @@ -1333,6 +1336,7 @@ static void virtio_pci_common_write(void *opaque, hwa= ddr addr, ((uint64_t)proxy->vqs[vdev->queue_sel].used[1]) << = 32 | proxy->vqs[vdev->queue_sel].used[0]); proxy->vqs[vdev->queue_sel].enabled =3D 1; + proxy->vqs[vdev->queue_sel].reset =3D 0; } else { virtio_error(vdev, "wrong value for queue_enable %"PRIx64, val= ); } @@ -1355,6 +1359,20 @@ static void virtio_pci_common_write(void *opaque, hw= addr addr, case VIRTIO_PCI_COMMON_Q_USEDHI: proxy->vqs[vdev->queue_sel].used[1] =3D val; break; + case VIRTIO_PCI_COMMON_Q_RESET: + if (val =3D=3D 1) { + /* + * With the global iothread lock taken, the migration will not + * happen until the virtqueue reset is done. + */ + proxy->vqs[vdev->queue_sel].reset =3D 1; + + virtio_queue_reset(vdev, vdev->queue_sel); + + proxy->vqs[vdev->queue_sel].reset =3D 0; + proxy->vqs[vdev->queue_sel].enabled =3D 0; + } + break; default: break; } @@ -1950,6 +1968,7 @@ static void virtio_pci_reset(DeviceState *qdev) =20 for (i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { proxy->vqs[i].enabled =3D 0; + proxy->vqs[i].reset =3D 0; proxy->vqs[i].num =3D 0; proxy->vqs[i].desc[0] =3D proxy->vqs[i].desc[1] =3D 0; proxy->vqs[i].avail[0] =3D proxy->vqs[i].avail[1] =3D 0; diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index 2446dcd9ae..e9290e2b94 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -117,6 +117,7 @@ typedef struct VirtIOPCIRegion { typedef struct VirtIOPCIQueue { uint16_t num; bool enabled; + bool reset; uint32_t desc[2]; uint32_t avail[2]; uint32_t used[2]; --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612147069294.58701903183066; Mon, 15 Aug 2022 18:09:07 -0700 (PDT) Received: from localhost ([::1]:60094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNl4r-0002ov-Ow for importer@patchew.org; Mon, 15 Aug 2022 21:09:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2k-0008TT-LL for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:54 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:47642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2h-00005Z-RS for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:53 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNIK7i_1660612004) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:44 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R801e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045168; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNIK7i_1660612004; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 07/24] virtio-pci: support queue enable Date: Tue, 16 Aug 2022 09:06:19 +0800 Message-Id: <6dda660c634b2a35c3dea46a98e63fb2ef3a36c9.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.133; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-133.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612149117100001 Content-Type: text/plain; charset="utf-8" PCI devices support vq enable. Based on this function, the driver can re-enable the virtqueue after the virtqueue is reset. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/virtio/virtio-pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index ec8e92052f..3d560e45ad 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1335,6 +1335,7 @@ static void virtio_pci_common_write(void *opaque, hwa= ddr addr, proxy->vqs[vdev->queue_sel].avail[0], ((uint64_t)proxy->vqs[vdev->queue_sel].used[1]) << = 32 | proxy->vqs[vdev->queue_sel].used[0]); + virtio_queue_enable(vdev, vdev->queue_sel); proxy->vqs[vdev->queue_sel].enabled =3D 1; proxy->vqs[vdev->queue_sel].reset =3D 0; } else { --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612477743266.64347723611945; Mon, 15 Aug 2022 18:14:37 -0700 (PDT) Received: from localhost ([::1]:34982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlAC-00052x-8L for importer@patchew.org; Mon, 15 Aug 2022 21:14:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2l-0008UB-Dh for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:55 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:48451) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2h-00005h-Ug for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:55 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNkO1-_1660612005) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:45 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R181e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045170; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNkO1-_1660612005; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 08/24] vhost: extract the logic of unmapping the vrings and desc Date: Tue, 16 Aug 2022 09:06:20 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.57; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-57.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612479123100001 Content-Type: text/plain; charset="utf-8" Introduce vhost_virtqueue_unmap() to ummap the vrings and desc of a virtqueue. The function will be used later. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- hw/virtio/vhost.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 0827d631c0..e467dfc7bc 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1197,6 +1197,19 @@ fail_alloc_desc: return r; } =20 +static void vhost_virtqueue_unmap(struct vhost_dev *dev, + struct VirtIODevice *vdev, + struct vhost_virtqueue *vq, + unsigned idx) +{ + vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx= ), + 1, virtio_queue_get_used_size(vdev, idx)); + vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, i= dx), + 0, virtio_queue_get_avail_size(vdev, idx)); + vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx= ), + 0, virtio_queue_get_desc_size(vdev, idx)); +} + static void vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, @@ -1235,12 +1248,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *d= ev, vhost_vq_index); } =20 - vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx= ), - 1, virtio_queue_get_used_size(vdev, idx)); - vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, i= dx), - 0, virtio_queue_get_avail_size(vdev, idx)); - vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx= ), - 0, virtio_queue_get_desc_size(vdev, idx)); + vhost_virtqueue_unmap(dev, vdev, vq, idx); } =20 static void vhost_eventfd_add(MemoryListener *listener, --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16606126997901011.856805110443; Mon, 15 Aug 2022 18:18:19 -0700 (PDT) Received: from localhost ([::1]:43360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlDm-0001A3-LM for importer@patchew.org; Mon, 15 Aug 2022 21:18:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2m-0008Ug-3O for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:56 -0400 Received: from out199-5.us.a.mail.aliyun.com ([47.90.199.5]:21047) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2i-00005o-DR for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:55 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNIK85_1660612006) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:46 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R111e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046051; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNIK85_1660612006; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 09/24] vhost: introduce vhost_dev_virtqueue_stop() Date: Tue, 16 Aug 2022 09:06:21 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=47.90.199.5; envelope-from=kangjie.xu@linux.alibaba.com; helo=out199-5.us.a.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612700401100003 Content-Type: text/plain; charset="utf-8" Introduce vhost_dev_virtqueue_stop(), which can ummap the vrings and the desc of it. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/virtio/vhost.c | 9 +++++++++ include/hw/virtio/vhost.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index e467dfc7bc..1bca9ff48d 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1904,3 +1904,12 @@ int vhost_net_set_backend(struct vhost_dev *hdev, =20 return -ENOSYS; } + +void vhost_dev_virtqueue_stop(struct vhost_dev *hdev, VirtIODevice *vdev, + int idx) +{ + vhost_virtqueue_unmap(hdev, + vdev, + hdev->vqs + idx, + idx); +} diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index a346f23d13..574888440c 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -288,4 +288,7 @@ int vhost_dev_set_inflight(struct vhost_dev *dev, struct vhost_inflight *inflight); int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size, struct vhost_inflight *inflight); + +void vhost_dev_virtqueue_stop(struct vhost_dev *hdev, VirtIODevice *vdev, + int idx); #endif --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612700549316.19367976683725; Mon, 15 Aug 2022 18:18:20 -0700 (PDT) Received: from localhost ([::1]:43362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlDn-0001C8-GS for importer@patchew.org; Mon, 15 Aug 2022 21:18:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2l-0008UW-QN for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:55 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:45382) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2i-00005y-9N for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:55 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNkO1U_1660612007) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:47 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R121e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046050; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNkO1U_1660612007; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 10/24] vhost: introduce vhost_dev_virtqueue_restart() Date: Tue, 16 Aug 2022 09:06:22 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.56; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-56.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612702070100005 Content-Type: text/plain; charset="utf-8" Introduce vhost_dev_virtqueue_restart(), which can restart the virtqueue when the vhost has already started running. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/virtio/vhost.c | 13 +++++++++++++ include/hw/virtio/vhost.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1bca9ff48d..fc3f550c76 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1913,3 +1913,16 @@ void vhost_dev_virtqueue_stop(struct vhost_dev *hdev= , VirtIODevice *vdev, hdev->vqs + idx, idx); } + +int vhost_dev_virtqueue_restart(struct vhost_dev *hdev, VirtIODevice *vdev, + int idx) +{ + const VhostOps *vhost_ops =3D hdev->vhost_ops; + + assert(vhost_ops); + + return vhost_virtqueue_start(hdev, + vdev, + hdev->vqs + idx, + hdev->vq_index + idx); +} diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 574888440c..b3394b6348 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -291,4 +291,6 @@ int vhost_dev_get_inflight(struct vhost_dev *dev, uint1= 6_t queue_size, =20 void vhost_dev_virtqueue_stop(struct vhost_dev *hdev, VirtIODevice *vdev, int idx); +int vhost_dev_virtqueue_restart(struct vhost_dev *hdev, VirtIODevice *vdev, + int idx); #endif --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612856252612.0660126464414; Mon, 15 Aug 2022 18:20:56 -0700 (PDT) Received: from localhost ([::1]:33486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlGI-0005ML-VA for importer@patchew.org; Mon, 15 Aug 2022 21:20:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2m-0008Um-6v for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:56 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:48102) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2j-000063-Ld for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:55 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNIK8Q_1660612008) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:48 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R961e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045192; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNIK8Q_1660612008; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 11/24] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_stop() Date: Tue, 16 Aug 2022 09:06:23 +0800 Message-Id: <9f5f233aaef3096fa1715095f3c436bb3c855fe5.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.133; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-133.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612857927100001 Content-Type: text/plain; charset="utf-8" Introduce vhost_virtqueue_stop(), which can reset the virtqueue in the device. Then it will unmap vrings and the desc of the virtqueue. This patch only considers the case for vhost-kernel, when NetClientDriver is NET_CLIENT_DRIVER_TAP. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/vhost_net.c | 21 +++++++++++++++++++++ include/net/vhost_net.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index ccac5b7a64..aa60dd901c 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -514,3 +514,24 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t = mtu) =20 return vhost_ops->vhost_net_set_mtu(&net->dev, mtu); } + +void vhost_net_virtqueue_stop(VirtIODevice *vdev, NetClientState *nc, + int vq_index) +{ + VHostNetState *net =3D get_vhost_net(nc->peer); + const VhostOps *vhost_ops =3D net->dev.vhost_ops; + struct vhost_vring_file file =3D { .fd =3D -1 }; + int idx; + + assert(vhost_ops); + + idx =3D vhost_ops->vhost_get_vq_index(&net->dev, vq_index); + + if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP) { + file.index =3D idx; + int r =3D vhost_net_set_backend(&net->dev, &file); + assert(r >=3D 0); + } + + vhost_dev_virtqueue_stop(&net->dev, vdev, idx); +} diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 387e913e4e..9b3aaf3814 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -48,4 +48,6 @@ uint64_t vhost_net_get_acked_features(VHostNetState *net); =20 int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu); =20 +void vhost_net_virtqueue_stop(VirtIODevice *vdev, NetClientState *nc, + int vq_index); #endif --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612698855216.9508385226752; Mon, 15 Aug 2022 18:18:18 -0700 (PDT) Received: from localhost ([::1]:43358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlDl-000115-GN for importer@patchew.org; Mon, 15 Aug 2022 21:18:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2m-0008VS-VY for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:57 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:33179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2k-00006E-OT for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:56 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNo4SP_1660612009) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:49 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R131e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045170; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNo4SP_1660612009; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 12/24] vhost-net: vhost-kernel: introduce vhost_net_virtqueue_restart() Date: Tue, 16 Aug 2022 09:06:24 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.44; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-44.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612700173100001 Content-Type: text/plain; charset="utf-8" Introduce vhost_net_virtqueue_restart(), which can restart the virtqueue when the vhost net started running before. If it fails to restart the virtqueue, the device will be stopped. This patch only considers the case for vhost-kernel, when NetClientDriver is NET_CLIENT_DRIVER_TAP. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/vhost_net.c | 48 +++++++++++++++++++++++++++++++++++++++++ include/net/vhost_net.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index aa60dd901c..2ab67e875e 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -535,3 +535,51 @@ void vhost_net_virtqueue_stop(VirtIODevice *vdev, NetC= lientState *nc, =20 vhost_dev_virtqueue_stop(&net->dev, vdev, idx); } + +int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc, + int vq_index) +{ + VHostNetState *net =3D get_vhost_net(nc->peer); + const VhostOps *vhost_ops =3D net->dev.vhost_ops; + struct vhost_vring_file file =3D { }; + int idx, r; + + if (!net->dev.started) { + return 0; + } + + assert(vhost_ops); + + idx =3D vhost_ops->vhost_get_vq_index(&net->dev, vq_index); + + r =3D vhost_dev_virtqueue_restart(&net->dev, vdev, idx); + if (r < 0) { + goto err_start; + } + + if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP) { + file.index =3D idx; + file.fd =3D net->backend; + r =3D vhost_net_set_backend(&net->dev, &file); + if (r < 0) { + r =3D -errno; + goto err_start; + } + } + + return 0; + +err_start: + error_report("Error when restarting the queue."); + + if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP) { + file.fd =3D -1; + file.index =3D idx; + int r =3D vhost_net_set_backend(&net->dev, &file); + assert(r >=3D 0); + } + + vhost_dev_stop(&net->dev, vdev); + + return r; +} diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 9b3aaf3814..e11a297380 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -50,4 +50,6 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu= ); =20 void vhost_net_virtqueue_stop(VirtIODevice *vdev, NetClientState *nc, int vq_index); +int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc, + int vq_index); #endif --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612152339501.9374184260016; Mon, 15 Aug 2022 18:09:12 -0700 (PDT) Received: from localhost ([::1]:46040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNl4x-000391-7y for importer@patchew.org; Mon, 15 Aug 2022 21:09:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2n-0008Vg-51 for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:57 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:35375) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2l-00006K-Eb for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:56 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNo4Sd_1660612010) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:50 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R541e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045176; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNo4Sd_1660612010; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 13/24] docs: vhost-user: add VHOST_USER_RESET_VRING message Date: Tue, 16 Aug 2022 09:06:25 +0800 Message-Id: <1f8fb06ed59583a9b5aedac1d7c6fd5fd09257b6.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.132; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-132.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612153260100001 Content-Type: text/plain; charset="utf-8" To support the reset operation for an individual virtqueue, we introduce a new message VHOST_USER_RESET_VRING. This message is submitted by the front-end to reset an individual virtqueue to initial states in the back-end. The reply is needed to ensure that the reset operation is complete. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- docs/interop/vhost-user.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 3f18ab424e..ce7991b9d3 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -1422,6 +1422,16 @@ Front-end message types query the back-end for its device status as defined in the Virtio specification. =20 +``VHOST_USER_RESET_VRING`` + :id: 41 + :equivalent ioctl: N/A + :request payload: vring state description + :reply payload: ``u64`` + + When the feature ``VIRTIO_F_RING_RESET`` feature has been successfully + negotiated, this message is submitted by the front-end to reset an + individual virtqueue to initial states in the back-end. It will ask + for a reply to ensure the virtqueue is successfully reset in the back-en= d. =20 Back-end message types ---------------------- --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612966600253.09623699992085; Mon, 15 Aug 2022 18:22:46 -0700 (PDT) Received: from localhost ([::1]:46656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlI5-0000fF-Ky for importer@patchew.org; Mon, 15 Aug 2022 21:22:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2n-000075-VM for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:58 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:49863) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2l-00007o-Vb for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:57 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNmF1w_1660612011) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:51 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R451e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045170; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNmF1w_1660612011; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 14/24] vhost-user: introduce vhost_reset_vring() interface Date: Tue, 16 Aug 2022 09:06:26 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.42; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-42.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612967934100001 Content-Type: text/plain; charset="utf-8" Introduce the interface vhost_reset_vring(). The interface is a wrapper to send a VHOST_USER_RESET_VRING message to the back-end. It will reset an individual vring in the back-end. Meanwhile, it will wait for a reply to ensure the reset has been completed. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/virtio/vhost-user.c | 41 +++++++++++++++++++++++++++++++ include/hw/virtio/vhost-backend.h | 3 +++ 2 files changed, 44 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 75b8df21a4..56033f7a92 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -126,6 +126,7 @@ typedef enum VhostUserRequest { VHOST_USER_GET_MAX_MEM_SLOTS =3D 36, VHOST_USER_ADD_MEM_REG =3D 37, VHOST_USER_REM_MEM_REG =3D 38, + VHOST_USER_RESET_VRING =3D 41, VHOST_USER_MAX } VhostUserRequest; =20 @@ -1498,6 +1499,45 @@ static int vhost_user_get_max_memslots(struct vhost_= dev *dev, return 0; } =20 +static int vhost_user_reset_vring(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + int ret; + VhostUserMsg msg =3D { + .hdr.request =3D VHOST_USER_RESET_VRING, + .hdr.flags =3D VHOST_USER_VERSION, + .payload.state =3D *ring, + .hdr.size =3D sizeof(msg.payload.state), + }; + + if (!virtio_has_feature(dev->acked_features, VIRTIO_F_RING_RESET)) { + return -ENOTSUP; + } + + ret =3D vhost_user_write(dev, &msg, NULL, 0); + if (ret < 0) { + return ret; + } + + ret =3D vhost_user_read(dev, &msg); + if (ret < 0) { + return ret; + } + + if (msg.hdr.request !=3D VHOST_USER_RESET_VRING) { + error_report("Received unexpected msg type. Expected %d received %= d", + VHOST_USER_RESET_VRING, msg.hdr.request); + return -EPROTO; + } + + if (msg.hdr.size !=3D sizeof(msg.payload.state)) { + error_report("Received bad msg size."); + return -EPROTO; + } + + return 0; +} + static int vhost_user_reset_device(struct vhost_dev *dev) { VhostUserMsg msg =3D { @@ -2625,6 +2665,7 @@ const VhostOps user_ops =3D { .vhost_set_features =3D vhost_user_set_features, .vhost_get_features =3D vhost_user_get_features, .vhost_set_owner =3D vhost_user_set_owner, + .vhost_reset_vring =3D vhost_user_reset_vring, .vhost_reset_device =3D vhost_user_reset_device, .vhost_get_vq_index =3D vhost_user_get_vq_index, .vhost_set_vring_enable =3D vhost_user_set_vring_enable, diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index eab46d7f0b..f23bf71a8d 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -79,6 +79,8 @@ typedef int (*vhost_get_features_op)(struct vhost_dev *de= v, uint64_t *features); typedef int (*vhost_set_backend_cap_op)(struct vhost_dev *dev); typedef int (*vhost_set_owner_op)(struct vhost_dev *dev); +typedef int (*vhost_reset_vring_op)(struct vhost_dev *dev, + struct vhost_vring_state *ring); typedef int (*vhost_reset_device_op)(struct vhost_dev *dev); typedef int (*vhost_get_vq_index_op)(struct vhost_dev *dev, int idx); typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev, @@ -154,6 +156,7 @@ typedef struct VhostOps { vhost_set_backend_cap_op vhost_set_backend_cap; vhost_set_owner_op vhost_set_owner; vhost_reset_device_op vhost_reset_device; + vhost_reset_vring_op vhost_reset_vring; vhost_get_vq_index_op vhost_get_vq_index; vhost_set_vring_enable_op vhost_set_vring_enable; vhost_requires_shm_log_op vhost_requires_shm_log; --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612900199952.5524955712742; Mon, 15 Aug 2022 18:21:40 -0700 (PDT) Received: from localhost ([::1]:37524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlH1-0006p6-7f for importer@patchew.org; Mon, 15 Aug 2022 21:21:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2q-0000Ay-SG for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:00 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:53003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2n-000084-B6 for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:59 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNo4T1_1660612012) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:52 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R161e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046050; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNo4T1_1660612012; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 15/24] vhost-user: add op to enable or disable a single vring Date: Tue, 16 Aug 2022 09:06:27 +0800 Message-Id: <9507fa8179afe9d02dfa03a3dbf6424cd5eba437.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.45; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-45.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612901888100001 Content-Type: text/plain; charset="utf-8" The interface to set enable status for a single vring is lacked in VhostOps, since the vhost_set_vring_enable_op will manipulate all virtqueues in a device. Resetting a single vq will rely on this interface. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/virtio/vhost-user.c | 26 +++++++++++++++++++------- include/hw/virtio/vhost-backend.h | 3 +++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 56033f7a92..8307976cda 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1199,6 +1199,22 @@ static int vhost_user_set_vring_base(struct vhost_de= v *dev, return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring); } =20 +static int vhost_user_set_single_vring_enable(struct vhost_dev *dev, + int index, + int enable) +{ + if (index < dev->vq_index || index >=3D dev->vq_index + dev->nvqs) { + return -EINVAL; + } + + struct vhost_vring_state state =3D { + .index =3D index, + .num =3D enable, + }; + + return vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state); +} + static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable) { int i; @@ -1208,13 +1224,8 @@ static int vhost_user_set_vring_enable(struct vhost_= dev *dev, int enable) } =20 for (i =3D 0; i < dev->nvqs; ++i) { - int ret; - struct vhost_vring_state state =3D { - .index =3D dev->vq_index + i, - .num =3D enable, - }; - - ret =3D vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state); + int ret =3D vhost_user_set_single_vring_enable(dev, dev->vq_index = + i, + enable); if (ret < 0) { /* * Restoring the previous state is likely infeasible, as well = as @@ -2668,6 +2679,7 @@ const VhostOps user_ops =3D { .vhost_reset_vring =3D vhost_user_reset_vring, .vhost_reset_device =3D vhost_user_reset_device, .vhost_get_vq_index =3D vhost_user_get_vq_index, + .vhost_set_single_vring_enable =3D vhost_user_set_single_vring_ena= ble, .vhost_set_vring_enable =3D vhost_user_set_vring_enable, .vhost_requires_shm_log =3D vhost_user_requires_shm_log, .vhost_migration_done =3D vhost_user_migration_done, diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index f23bf71a8d..38f6b752ff 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -83,6 +83,8 @@ typedef int (*vhost_reset_vring_op)(struct vhost_dev *dev, struct vhost_vring_state *ring); typedef int (*vhost_reset_device_op)(struct vhost_dev *dev); typedef int (*vhost_get_vq_index_op)(struct vhost_dev *dev, int idx); +typedef int (*vhost_set_single_vring_enable_op)(struct vhost_dev *dev, + int index, int enable); typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev, int enable); typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev); @@ -158,6 +160,7 @@ typedef struct VhostOps { vhost_reset_device_op vhost_reset_device; vhost_reset_vring_op vhost_reset_vring; vhost_get_vq_index_op vhost_get_vq_index; + vhost_set_single_vring_enable_op vhost_set_single_vring_enable; vhost_set_vring_enable_op vhost_set_vring_enable; vhost_requires_shm_log_op vhost_requires_shm_log; vhost_migration_done_op vhost_migration_done; --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660613078684583.4533352033518; Mon, 15 Aug 2022 18:24:38 -0700 (PDT) Received: from localhost ([::1]:38402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlJt-0003Uw-ND for importer@patchew.org; Mon, 15 Aug 2022 21:24:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2q-0000B7-Ty for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:02 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:44108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2o-00008i-0Q for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:06:59 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNhlsv_1660612013) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:53 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R191e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045192; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNhlsv_1660612013; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 16/24] vhost: vhost-user: update vhost_dev_virtqueue_stop() Date: Tue, 16 Aug 2022 09:06:28 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.44; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-44.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660613080466100005 Content-Type: text/plain; charset="utf-8" Update vhost_dev_virtqueue_stop() for vhost-user scenario. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/virtio/vhost.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index fc3f550c76..a0d6824353 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1908,10 +1908,29 @@ int vhost_net_set_backend(struct vhost_dev *hdev, void vhost_dev_virtqueue_stop(struct vhost_dev *hdev, VirtIODevice *vdev, int idx) { + const VhostOps *vhost_ops =3D hdev->vhost_ops; + struct vhost_vring_state state; + int r; + + assert(vhost_ops); + + if (vhost_ops->vhost_reset_vring) { + state.index =3D hdev->vq_index + idx; + r =3D vhost_ops->vhost_reset_vring(hdev, &state); + if (r < 0) { + goto err_queue_reset; + } + } + vhost_virtqueue_unmap(hdev, vdev, hdev->vqs + idx, idx); + + return; + +err_queue_reset: + error_report("Error when stopping the qeuue."); } =20 int vhost_dev_virtqueue_restart(struct vhost_dev *hdev, VirtIODevice *vdev, --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612856304255.7804047513656; Mon, 15 Aug 2022 18:20:56 -0700 (PDT) Received: from localhost ([::1]:33488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlGI-0005Oo-VO for importer@patchew.org; Mon, 15 Aug 2022 21:20:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2u-0000E4-Ih for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:06 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:36721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2p-00009A-DE for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:01 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNIK9b_1660612014) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:54 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R241e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045176; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNIK9b_1660612014; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 17/24] vhost: vhost-user: update vhost_dev_virtqueue_restart() Date: Tue, 16 Aug 2022 09:06:29 +0800 Message-Id: <8d278f0247085457582a367deb13431c943b8372.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.43; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-43.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612858058100003 Content-Type: text/plain; charset="utf-8" Update vhost_dev_virtqueue_restart() for vhost-user scenario. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/virtio/vhost.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index a0d6824353..bd90cfe13a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1937,11 +1937,29 @@ int vhost_dev_virtqueue_restart(struct vhost_dev *h= dev, VirtIODevice *vdev, int idx) { const VhostOps *vhost_ops =3D hdev->vhost_ops; + int r; =20 assert(vhost_ops); =20 - return vhost_virtqueue_start(hdev, - vdev, - hdev->vqs + idx, - hdev->vq_index + idx); + r =3D vhost_virtqueue_start(hdev, + vdev, + hdev->vqs + idx, + hdev->vq_index + idx); + if (r < 0) { + goto err_start; + } + + if (vhost_ops->vhost_set_single_vring_enable) { + r =3D vhost_ops->vhost_set_single_vring_enable(hdev, + hdev->vq_index + idx, + 1); + if (r < 0) { + goto err_start; + } + } + + return 0; + +err_start: + return r; } --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660613168192281.31460702469747; Mon, 15 Aug 2022 18:26:08 -0700 (PDT) Received: from localhost ([::1]:59510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlLL-0006Mq-4U for importer@patchew.org; Mon, 15 Aug 2022 21:26:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2w-0000FA-Ew for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:06 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:51786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2q-00009U-Ru for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:05 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNo4Tt_1660612014) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:55 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R351e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045170; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNo4Tt_1660612014; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 18/24] vhost-net: vhost-user: update vhost_net_virtqueue_stop() Date: Tue, 16 Aug 2022 09:06:30 +0800 Message-Id: <303811ffeac48647ac4c81eeec542292e8f67a0e.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.133; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-133.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660613169402100001 Content-Type: text/plain; charset="utf-8" Update vhost_net_virtqueue_stop() for vhost-user scenario. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/vhost_net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 2ab67e875e..c0d408f3b4 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -533,6 +533,10 @@ void vhost_net_virtqueue_stop(VirtIODevice *vdev, NetC= lientState *nc, assert(r >=3D 0); } =20 + if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER) { + idx =3D idx - net->dev.vq_index; + } + vhost_dev_virtqueue_stop(&net->dev, vdev, idx); } =20 --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166061335637524.581856550937005; Mon, 15 Aug 2022 18:29:16 -0700 (PDT) Received: from localhost ([::1]:35306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlOM-0002wX-W1 for importer@patchew.org; Mon, 15 Aug 2022 21:29:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2y-0000KX-CZ for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:09 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:34100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2s-00009c-Nu for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:06 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNrTmZ_1660612015) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:56 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R201e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045192; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNrTmZ_1660612015; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 19/24] vhost-net: vhost-user: update vhost_net_virtqueue_restart() Date: Tue, 16 Aug 2022 09:06:31 +0800 Message-Id: <73f25e2ffde00e25535902ba4bf7b92097f51d4a.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.57; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-57.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660613358208100001 Content-Type: text/plain; charset="utf-8" Update vhost_net_virtqueue_restart() for vhost-user scenario. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/vhost_net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index c0d408f3b4..778081e54a 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -556,6 +556,10 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, Ne= tClientState *nc, =20 idx =3D vhost_ops->vhost_get_vq_index(&net->dev, vq_index); =20 + if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER) { + idx =3D idx - net->dev.vq_index; + } + r =3D vhost_dev_virtqueue_restart(&net->dev, vdev, idx); if (r < 0) { goto err_start; --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660613266848437.89297798519465; Mon, 15 Aug 2022 18:27:46 -0700 (PDT) Received: from localhost ([::1]:59098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlMu-0001Fg-Rk for importer@patchew.org; Mon, 15 Aug 2022 21:27:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2w-0000FB-Fh for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:06 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:45330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2t-00009l-Op for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:05 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNmF3K_1660612017) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:57 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R161e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046059; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNmF3K_1660612017; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 20/24] virtio-net: introduce flush_or_purge_queued_packets() Date: Tue, 16 Aug 2022 09:06:32 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.44; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-44.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660613267722100001 Content-Type: text/plain; charset="utf-8" Introduce the fucntion flush_or_purge_queued_packets(), it will be used in device reset and virtqueue reset. Therefore, we extract the common logic as a new function. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/virtio-net.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index dd0d056fde..27b59c0ad6 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -118,6 +118,16 @@ static int vq2q(int queue_index) return queue_index / 2; } =20 +static void flush_or_purge_queued_packets(NetClientState *nc) +{ + if (!nc->peer) { + return; + } + + qemu_flush_or_purge_queued_packets(nc->peer, true); + assert(!virtio_net_get_subqueue(nc)->async_tx.elem); +} + /* TODO * - we could suppress RX interrupt if we were so inclined. */ @@ -560,12 +570,7 @@ static void virtio_net_reset(VirtIODevice *vdev) =20 /* Flush any async TX */ for (i =3D 0; i < n->max_queue_pairs; i++) { - NetClientState *nc =3D qemu_get_subqueue(n->nic, i); - - if (nc->peer) { - qemu_flush_or_purge_queued_packets(nc->peer, true); - assert(!virtio_net_get_subqueue(nc)->async_tx.elem); - } + flush_or_purge_queued_packets(qemu_get_subqueue(n->nic, i)); } } =20 --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660613107887414.4225453234686; Mon, 15 Aug 2022 18:25:07 -0700 (PDT) Received: from localhost ([::1]:58042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlKM-0004Kp-P7 for importer@patchew.org; Mon, 15 Aug 2022 21:25:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2y-0000Kg-DT for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:09 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:40563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2u-00009z-Dx for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:07 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNhltz_1660612018) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:58 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R121e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045176; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNhltz_1660612018; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 21/24] virtio-net: support queue reset Date: Tue, 16 Aug 2022 09:06:33 +0800 Message-Id: <58daee15b4c2247c7a31e56ce3e99e33888c1484.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.45; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-45.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660613108967100001 Content-Type: text/plain; charset="utf-8" From: Xuan Zhuo virtio-net, vhost-kernel, vhost-user implement queue reset. Queued packets in the corresponding queue pair are flushed or purged. Signed-off-by: Xuan Zhuo Signed-off-by: Kangjie Xu --- hw/net/virtio-net.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 27b59c0ad6..e2989487ec 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -540,6 +540,24 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClie= ntState *nc) return info; } =20 +static void virtio_net_queue_reset(VirtIODevice *vdev, uint32_t queue_inde= x) +{ + VirtIONet *n =3D VIRTIO_NET(vdev); + NetClientState *nc =3D qemu_get_subqueue(n->nic, vq2q(queue_index)); + + if (!nc->peer) { + return; + } + + if (get_vhost_net(nc->peer) && + ((nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_TAP) || + (nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER))) { + vhost_net_virtqueue_stop(vdev, nc, queue_index); + } + + flush_or_purge_queued_packets(nc); +} + static void virtio_net_reset(VirtIODevice *vdev) { VirtIONet *n =3D VIRTIO_NET(vdev); @@ -3784,6 +3802,7 @@ static void virtio_net_class_init(ObjectClass *klass,= void *data) vdc->set_features =3D virtio_net_set_features; vdc->bad_features =3D virtio_net_bad_features; vdc->reset =3D virtio_net_reset; + vdc->queue_reset =3D virtio_net_queue_reset; vdc->set_status =3D virtio_net_set_status; vdc->guest_notifier_mask =3D virtio_net_guest_notifier_mask; vdc->guest_notifier_pending =3D virtio_net_guest_notifier_pending; --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612990407460.75143971492344; Mon, 15 Aug 2022 18:23:10 -0700 (PDT) Received: from localhost ([::1]:34048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlIT-0001Uy-Ex for importer@patchew.org; Mon, 15 Aug 2022 21:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2y-0000Kd-Cq for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:09 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:59127) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2u-0000A0-IU for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:07 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNo4Uh_1660612019) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:06:59 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R151e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045168; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNo4Uh_1660612019; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 22/24] virtio-net: support queue_enable Date: Tue, 16 Aug 2022 09:06:34 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.43; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-43.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612991974100001 Content-Type: text/plain; charset="utf-8" virtio-net: support queue_enable for vhost Support queue_enable in vhost scenario. It can be called when a vq reset operation is performed and the vq will be restared. It should be noted that we can restart the vq when the vhost has already started. When launching a new vhost-user device, the vhost is not started and all vqs are not initalized until VIRTIO_PCI_COMMON_STATUS is written. Thus, we should use vhost_started to differentiate the two cases: vq reset and device start. Currently it only supports vhost-user and vhost-kernel. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/virtio-net.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index e2989487ec..ba216f7b84 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -558,6 +558,27 @@ static void virtio_net_queue_reset(VirtIODevice *vdev,= uint32_t queue_index) flush_or_purge_queued_packets(nc); } =20 +static void virtio_net_queue_enable(VirtIODevice *vdev, uint32_t queue_ind= ex) +{ + VirtIONet *n =3D VIRTIO_NET(vdev); + NetClientState *nc =3D qemu_get_subqueue(n->nic, vq2q(queue_index)); + int r; + + if (!nc->peer || !vdev->vhost_started) { + return; + } + + if (get_vhost_net(nc->peer) && + ((nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_TAP) || + (nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER))) { + r =3D vhost_net_virtqueue_restart(vdev, nc, queue_index); + if (r < 0) { + error_report("unable to restart vhost net virtqueue: %d, " + "when resetting the queue", queue_index); + } + } +} + static void virtio_net_reset(VirtIODevice *vdev) { VirtIONet *n =3D VIRTIO_NET(vdev); @@ -3803,6 +3824,7 @@ static void virtio_net_class_init(ObjectClass *klass,= void *data) vdc->bad_features =3D virtio_net_bad_features; vdc->reset =3D virtio_net_reset; vdc->queue_reset =3D virtio_net_queue_reset; + vdc->queue_enable =3D virtio_net_queue_enable; vdc->set_status =3D virtio_net_set_status; vdc->guest_notifier_mask =3D virtio_net_guest_notifier_mask; vdc->guest_notifier_pending =3D virtio_net_guest_notifier_pending; --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660612334431554.979274804392; Mon, 15 Aug 2022 18:12:14 -0700 (PDT) Received: from localhost ([::1]:33478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNl7s-0000Rf-FQ for importer@patchew.org; Mon, 15 Aug 2022 21:12:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2z-0000L7-Iu for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:10 -0400 Received: from out199-14.us.a.mail.aliyun.com ([47.90.199.14]:58311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2w-0000A5-Es for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:09 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNhluE_1660612020) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:07:00 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R111e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045170; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNhluE_1660612020; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 23/24] vhost: vhost-kernel: enable vq reset feature Date: Tue, 16 Aug 2022 09:06:35 +0800 Message-Id: <69b0a5d0ff909969a2363fdab47c9a0a416e073f.1660611460.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=47.90.199.14; envelope-from=kangjie.xu@linux.alibaba.com; helo=out199-14.us.a.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660612336371100001 Content-Type: text/plain; charset="utf-8" Add virtqueue reset feature for vhost-kernel. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/vhost_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 778081e54a..9ea160e4e9 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -46,6 +46,7 @@ static const int kernel_feature_bits[] =3D { VIRTIO_NET_F_MTU, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, + VIRTIO_F_RING_RESET, VIRTIO_NET_F_HASH_REPORT, VHOST_INVALID_FEATURE_BIT }; --=20 2.32.0 From nobody Sun Apr 28 18:53:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=linux.alibaba.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660613209229694.7941249245097; Mon, 15 Aug 2022 18:26:49 -0700 (PDT) Received: from localhost ([::1]:58702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNlM0-0007Q2-8R for importer@patchew.org; Mon, 15 Aug 2022 21:26:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2z-0000Kq-Fj for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:10 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:39037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNl2w-0000AA-DW for qemu-devel@nongnu.org; Mon, 15 Aug 2022 21:07:09 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VMNkO52_1660612021) by smtp.aliyun-inc.com; Tue, 16 Aug 2022 09:07:01 +0800 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R191e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045192; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=9; SR=0; TI=SMTPD_---0VMNkO52_1660612021; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, eduardo@habkost.net, marcel.apfelbaum@gmail.com, f4bug@amsat.org, wangyanan55@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 24/24] vhost: vhost-user: enable vq reset feature Date: Tue, 16 Aug 2022 09:06:36 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.124.30.54; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-54.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" X-ZM-MESSAGEID: 1660613209635100001 Content-Type: text/plain; charset="utf-8" Add virtqueue reset feature for vhost-user. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/vhost_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 9ea160e4e9..5bc89f2842 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -74,6 +74,7 @@ static const int user_feature_bits[] =3D { VIRTIO_NET_F_MTU, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, + VIRTIO_F_RING_RESET, VIRTIO_NET_F_RSS, VIRTIO_NET_F_HASH_REPORT, =20 --=20 2.32.0