From nobody Mon Feb 9 19:11:05 2026 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 1658153752544780.5367312141269; Mon, 18 Jul 2022 07:15:52 -0700 (PDT) Received: from localhost ([::1]:39160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDRXL-00037C-HK for importer@patchew.org; Mon, 18 Jul 2022 10:15:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDOpo-0007YC-3S for qemu-devel@nongnu.org; Mon, 18 Jul 2022 07:22:44 -0400 Received: from out199-1.us.a.mail.aliyun.com ([47.90.199.1]:47339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDOpi-0000jM-9K for qemu-devel@nongnu.org; Mon, 18 Jul 2022 07:22:43 -0400 Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VJioD8Z_1658143047) by smtp.aliyun-inc.com; Mon, 18 Jul 2022 19:17:27 +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=e01e04400; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=5; SR=0; TI=SMTPD_---0VJioD8Z_1658143047; From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH 14/16] virtio-net: support queue_enable for vhost-user Date: Mon, 18 Jul 2022 19:17:11 +0800 Message-Id: <591635c6dfa81b8310ae38e56916aa6f3842fc58.1658141552.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.1; envelope-from=kangjie.xu@linux.alibaba.com; helo=out199-1.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-Mailman-Approved-At: Mon, 18 Jul 2022 09:49:05 -0400 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: 1658153753315100001 Content-Type: text/plain; charset="utf-8" Support queue enable in vhost-user scenario. It will 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. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/virtio-net.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 8396e21a67..2c26e2ef73 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -544,6 +544,25 @@ static void virtio_net_queue_reset(VirtIODevice *vdev,= uint32_t queue_index) assert(!virtio_net_get_subqueue(nc)->async_tx.elem); } =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 (nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER) { + r =3D vhost_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); @@ -3781,6 +3800,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