From nobody Thu Oct 30 18:35:16 2025 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=1647279977; cv=none; d=zohomail.com; s=zohoarc; b=CHr2/fGWlBgc4+rSnWsKVA5FZ2vxH9sa/V8JSWATIZL9870bgAOHx072HJh4NwNeeYA9mhAtZL1iN6+EDRQGf+zxNd4YPu7zdQ3fAilBcBQigGTCaCQoJsy8IEre5vGUS2ee7MGK9E/dVi5Qx+ueamd1KNQ26iiCsvbJ7NoWfvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647279977; 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=a14QYI742zsn+kZZ3QWn225DvimwAo3Em4vVOBdC/lU=; b=nFFwWkmi2KlJwDZTrHaKcVcKYPZH466H5sYlV+7OWwxZJeAPhgWAACIkN7DVRodehDRkd+sqWB8vvMnY9HVgGfLtbDoZSq+4W5Beo1yUfZakRmjBT4yGvKngBzV6vCQopZB54Tzhw0KzZGzryxtPjlWayfdfXRPiI//OzG6sdho= 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 1647279977930195.19152582182323; Mon, 14 Mar 2022 10:46:17 -0700 (PDT) Received: from localhost ([::1]:36306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTolp-0008Kc-2I for importer@patchew.org; Mon, 14 Mar 2022 13:46:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTobN-0005l3-Lx for qemu-devel@nongnu.org; Mon, 14 Mar 2022 13:35:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60215) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTobI-0007fj-HW for qemu-devel@nongnu.org; Mon, 14 Mar 2022 13:35:24 -0400 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-235-Hk2uwjcDNzm3YIT1y8bXcg-1; Mon, 14 Mar 2022 13:35:06 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B7AC38035A1 for ; Mon, 14 Mar 2022 17:35:06 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.194.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25A774B8D5A; Mon, 14 Mar 2022 17:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647279307; 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=a14QYI742zsn+kZZ3QWn225DvimwAo3Em4vVOBdC/lU=; b=diQba7tLKRT8X6JMATMLj2LtqAJRPxmcjdQpwwpmKsuS2EtilSMV6kC9UxDODz75Qzczkj l47qyfnIJqOgRK2nS4D0SExu+0Ty7Jw6AljfNsMCBB5nVyQpmff21XLK5Bwq9GcGdDURDC 7Yh67QkpAUAV7CogpBfki28Aak58uGg= X-MC-Unique: Hk2uwjcDNzm3YIT1y8bXcg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Subject: [PATCH v6 06/15] vdpa: adapt vhost_ops callbacks to svq Date: Mon, 14 Mar 2022 18:34:46 +0100 Message-Id: <20220314173455.200342-7-eperezma@redhat.com> In-Reply-To: <20220314173455.200342-1-eperezma@redhat.com> References: <20220314173455.200342-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1647279979906100001 First half of the buffers forwarding part, preparing vhost-vdpa callbacks to SVQ to offer it. QEMU cannot enable it at this moment, so this is effectively dead code at the moment, but it helps to reduce patch size. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-vdpa.c | 48 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 4e1deb3d04..3e2c181d2b 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -733,6 +733,13 @@ static int vhost_vdpa_get_config(struct vhost_dev *dev= , uint8_t *config, return ret; } =20 +static int vhost_vdpa_set_dev_vring_base(struct vhost_dev *dev, + struct vhost_vring_state *ring) +{ + trace_vhost_vdpa_set_vring_base(dev, ring->index, ring->num); + return vhost_vdpa_call(dev, VHOST_SET_VRING_BASE, ring); +} + static int vhost_vdpa_set_vring_dev_kick(struct vhost_dev *dev, struct vhost_vring_file *file) { @@ -747,6 +754,18 @@ static int vhost_vdpa_set_vring_dev_call(struct vhost_= dev *dev, return vhost_vdpa_call(dev, VHOST_SET_VRING_CALL, file); } =20 +static int vhost_vdpa_set_vring_dev_addr(struct vhost_dev *dev, + struct vhost_vring_addr *addr) +{ + trace_vhost_vdpa_set_vring_addr(dev, addr->index, addr->flags, + addr->desc_user_addr, addr->used_user_addr, + addr->avail_user_addr, + addr->log_guest_addr); + + return vhost_vdpa_call(dev, VHOST_SET_VRING_ADDR, addr); + +} + /** * Set the shadow virtqueue descriptors to the device * @@ -856,11 +875,17 @@ static int vhost_vdpa_set_log_base(struct vhost_dev *= dev, uint64_t base, static int vhost_vdpa_set_vring_addr(struct vhost_dev *dev, struct vhost_vring_addr *addr) { - trace_vhost_vdpa_set_vring_addr(dev, addr->index, addr->flags, - addr->desc_user_addr, addr->used_user_= addr, - addr->avail_user_addr, - addr->log_guest_addr); - return vhost_vdpa_call(dev, VHOST_SET_VRING_ADDR, addr); + struct vhost_vdpa *v =3D dev->opaque; + + if (v->shadow_vqs_enabled) { + /* + * Device vring addr was set at device start. SVQ base is handled = by + * VirtQueue code. + */ + return 0; + } + + return vhost_vdpa_set_vring_dev_addr(dev, addr); } =20 static int vhost_vdpa_set_vring_num(struct vhost_dev *dev, @@ -873,8 +898,17 @@ static int vhost_vdpa_set_vring_num(struct vhost_dev *= dev, static int vhost_vdpa_set_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { - trace_vhost_vdpa_set_vring_base(dev, ring->index, ring->num); - return vhost_vdpa_call(dev, VHOST_SET_VRING_BASE, ring); + struct vhost_vdpa *v =3D dev->opaque; + + if (v->shadow_vqs_enabled) { + /* + * Device vring base was set at device start. SVQ base is handled = by + * VirtQueue code. + */ + return 0; + } + + return vhost_vdpa_set_dev_vring_base(dev, ring); } =20 static int vhost_vdpa_get_vring_base(struct vhost_dev *dev, --=20 2.27.0