From nobody Mon Feb 9 16:01:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1670260244; cv=none; d=zohomail.com; s=zohoarc; b=cE37B4AgTGWAemx3X3amNkPX22gF1gdIyTA+qZcGiePensSyOFqir8O7vEAA/mOhESaU8bV0WNbPQoVvsSX5Vn5b9ZVOE0JnY8H2mMKTw6WeIljwWYv+SakW4Wj4oiQhYIjsBq2JuFfUGafDoZ3pf9gwHTduNIDjMELlLtI6peQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670260244; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r4aycp4adEJGmL77aJql7l+0FzaWMcJzSCjVB4Nz7k4=; b=MH+8qggsLH0zVIgOJLPRH78Bb5GaSORjJ89lpcia5iYx8Bofh1mALmN08tyxCtsM2dAARkPWw+vzdDme+JyermDWdmqr/BYmDdc5FWFvnqlJtH4jHHKc1ZfaMhywkuGQ5pLTrZN6+UL8bEUOwT+zVab8zmMbDEdUO1Ul1CdoU6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1670260244396524.9000885332056; Mon, 5 Dec 2022 09:10:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2Euu-00013C-Ax; Mon, 05 Dec 2022 12:06:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2EuK-0000gE-Hc for qemu-devel@nongnu.org; Mon, 05 Dec 2022 12:05:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2EuJ-0002zH-0j for qemu-devel@nongnu.org; Mon, 05 Dec 2022 12:05:32 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-163--MmRbQAjN-G9YZ8ZNzlS8A-1; Mon, 05 Dec 2022 12:05:25 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A8C7838164C3; Mon, 5 Dec 2022 17:05:23 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.167]) by smtp.corp.redhat.com (Postfix) with ESMTP id E56BFC15BA8; Mon, 5 Dec 2022 17:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670259930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r4aycp4adEJGmL77aJql7l+0FzaWMcJzSCjVB4Nz7k4=; b=dlN+xdNVHXu0QNDgj1dhrtSm+795/jZpEm2NeRlGxVDAAUGrF+EZlFZhkfSX3/PVP41wFS g5cZQQwG+oZyEKguF5af0YUo999taRmkfSm9St0kf5imn4LYEB2XLGgebwobuAQGllANOj zbc86ggi4Kn074wyx5UExNJkbcCZ/TE= X-MC-Unique: -MmRbQAjN-G9YZ8ZNzlS8A-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Liuxiangdong , Stefan Hajnoczi , Jason Wang , Harpreet Singh Anand , Gautam Dawar , Zhu Lingshan , Cindy Lu , Si-Wei Liu , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , Laurent Vivier , Eli Cohen , Stefano Garzarella , Juan Quintela , Parav Pandit Subject: [RFC PATCH for 8.0 13/13] vdpa: Recover inflight descriptors Date: Mon, 5 Dec 2022 18:04:36 +0100 Message-Id: <20221205170436.2977336-14-eperezma@redhat.com> In-Reply-To: <20221205170436.2977336-1-eperezma@redhat.com> References: <20221205170436.2977336-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1670260245471100001 Finally recover the inflight descriptors at vhost_net_start. TODO: Abstract it properly instead of using SVQ directly. Signed-off-by: Eugenio P=C3=A9rez --- hw/net/vhost_net.c | 34 ++++++++++++++++++++++++++++++++++ hw/virtio/vhost-vdpa.c | 11 ----------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 480f4ac0a1..9a49046c53 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -428,6 +428,40 @@ int vhost_net_start(VirtIODevice *dev, NetClientState = *ncs, } } =20 + for (i =3D 0; i < data_queue_pairs; i++) { + struct vhost_vdpa *v; + + peer =3D qemu_get_peer(ncs, i); + if (peer->info->type !=3D NET_CLIENT_DRIVER_VHOST_VDPA) { + continue; + } + net =3D get_vhost_net(peer); + v =3D net->dev.opaque; + + if (!v->shadow_vqs_enabled) { + return 0; + } + + for (size_t i =3D 0; i < v->dev->nvqs; ++i) { + VirtIONetQueue *q =3D &n->vqs[(i + v->dev->vq_index) / 2]; + size_t num =3D i % 2 ? q->tx_inflight_num : q->rx_inflight_num; + g_autofree VirtQueueElement **inflight =3D NULL; + + assert(v->dev->vq_index % 2 =3D=3D 0); + inflight =3D g_steal_pointer(i % 2 ? &q->tx_inflight + : &q->rx_inflight); + for (size_t j =3D 0; j < num; ++j) { + int r; + + r =3D vhost_svq_add_element(g_ptr_array_index(v->shadow_vq= s, i), + inflight[j]); + + /* TODO: Proper error handling */ + assert(r =3D=3D 0); + } + } + } + return 0; =20 err_start: diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 7468e44b87..c54cb82cb5 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1167,18 +1167,7 @@ static int vhost_vdpa_set_vring_base(struct vhost_de= v *dev, struct vhost_vring_state *ring) { struct vhost_vdpa *v =3D dev->opaque; - VirtQueue *vq =3D virtio_get_queue(dev->vdev, ring->index); =20 - /* - * vhost-vdpa devices does not support in-flight requests. Set all of = them - * as available. - * - * TODO: This is ok for networking, but other kinds of devices might - * have problems with these retransmissions. - */ - while (virtqueue_rewind(vq, 1)) { - continue; - } if (v->shadow_vqs_enabled) { /* * Device vring base was set at device start. SVQ base is handled = by --=20 2.31.1