From nobody Thu May 2 14:17:50 2024 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=1660157679; cv=none; d=zohomail.com; s=zohoarc; b=ZkJ5Hfo1ibXseYB2NblVU8ydq7VA/Wu+8Jjdjc7xZaDJ9xnL4jg12LcMahmNGT0vwkpCnyu0UshvhMszMoN4jKS1S8D26A0kmf4yFnL+q6G0Z63si6aq/W1lxGL4gf4UeOCtv7itMh1Tc34ke7z+3z+CAuNNBJbgfrYnPGzz56k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660157679; h=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=u8z3qhSzG4xe38qyIY4qics2r2QDCs0AchsGOJ8UEk8=; b=Lo9WRGYG5z5yu4aLlzGZ3p2E9zjxC66+ndUkAqYSi6artXDhACv+7UWETXrCpQuLRmk17DJ9ukjzDYIXpkU88h7ndPnL5Y61t5XrjWDrzZ1KAeZttEarNKoj7a0TYakabce+diTzA9SJfggdDLu1SgrzoM+7tP/WNWkKWREWsbs= 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 1660157679840191.1416541898792; Wed, 10 Aug 2022 11:54:39 -0700 (PDT) Received: from localhost ([::1]:57486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqqk-0002MB-Mg for importer@patchew.org; Wed, 10 Aug 2022 14:54:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfE-00027c-SS for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfB-0006h5-6Q for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:42 -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-256-3kDloFI2NymFQY74KhmyfQ-1; Wed, 10 Aug 2022 14:42:29 -0400 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 5E1193C10237; Wed, 10 Aug 2022 18:42:28 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA831C15BA3; Wed, 10 Aug 2022 18:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u8z3qhSzG4xe38qyIY4qics2r2QDCs0AchsGOJ8UEk8=; b=gJ7Jh5x+CxlwhH44fGwIhhkTpMwhqBS8v/0FXpEu26DO25ZIBpcRai5O7ELPbqHk+tTmnD Ee26DTzVPJ0Xw97bcAgxKXLD/xTDcjfl5EXLf/2Oiu2k1Qowd90ysZ+jk2HcbyaSuDEI8V dLZCNOhFmR5h3y5d8oUgVs4Zs3QO3B0= X-MC-Unique: 3kDloFI2NymFQY74KhmyfQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 1/8] [NOTMERGE] Update linux headers Date: Wed, 10 Aug 2022 20:42:13 +0200 Message-Id: <20220810184220.2362292-2-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 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.133.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660157681817100003 Content-Type: text/plain; charset="utf-8" Add _F_SUSPEND and suspend ioctl. TODO: This is still not merged in Linux upstream, so it may change. --- include/standard-headers/linux/vhost_types.h | 3 +++ linux-headers/linux/vhost.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/include/standard-headers/linux/vhost_types.h b/include/standar= d-headers/linux/vhost_types.h index ce78551b0f..c93ed1b920 100644 --- a/include/standard-headers/linux/vhost_types.h +++ b/include/standard-headers/linux/vhost_types.h @@ -161,5 +161,8 @@ struct vhost_vdpa_iova_range { * message */ #define VHOST_BACKEND_F_IOTLB_ASID 0x3 +/* Stop device from processing virtqueue buffers */ +#define VHOST_BACKEND_F_SUSPEND 0x4 + =20 #endif diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index cab645d4a6..f3f5bea3cb 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -171,4 +171,7 @@ #define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, \ struct vhost_vring_state) =20 +/* Stop or resume a device so it does not process virtqueue requests anymo= re */ +#define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) + #endif --=20 2.31.1 From nobody Thu May 2 14:17:50 2024 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=1660157235; cv=none; d=zohomail.com; s=zohoarc; b=dsGuM5SG6WIFpSXKBuh9Iu+VMjvpZiJTBB2HaujgmKSOBsDXQGLxpg0qg5MaJe7HqnlUuvMz/ZvqkoAwNCKCtFEhrJaNiR7Or9uisBNtY/+nVBiIlG59B2CJgbKQ0StDmpvyVDhvqqtYWrE9E0gGhzNeaRXlGKPLz3a4BgLPrBI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660157235; 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=GVnZ2eKVmApuP3yb5NRmJJpEHJ0ByEkMjNlf+83PBe4=; b=X8YzU9EC7fpzLAiEIxLsx9dH7h+X5EV2OVntRyxzfKyPHAzaA6ScUGcFkQWLAQ5hQZh9wi2kALiF+IUa3OXPWp6PePETH92PlZ6HzUCe7BzaWC2M6NtR3BD9UsLEplcVL4dllheoGTbF7UJOThZEWDg//l9u81dABna2+FazjaY= 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 1660157235949499.7657029923969; Wed, 10 Aug 2022 11:47:15 -0700 (PDT) Received: from localhost ([::1]:49232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqja-0004q7-NY for importer@patchew.org; Wed, 10 Aug 2022 14:47:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfF-00028v-EG for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25277) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfB-0006h9-G3 for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:44 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-228-UZG9jtC1PJi8mjVY-bAVRg-1; Wed, 10 Aug 2022 14:42:31 -0400 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 437E7804196; Wed, 10 Aug 2022 18:42:31 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6DD7C15BA3; Wed, 10 Aug 2022 18:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156954; 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=GVnZ2eKVmApuP3yb5NRmJJpEHJ0ByEkMjNlf+83PBe4=; b=BqvoDfe/24qBefcCzmQGbRPcxXGTPG+jBASrFapC6LlIcJLWdzVKNNTujTh8RpUma89Pyq nAu4tNgpfUUW6U6GFTEiMalJNEFYMsp5Dt6ORBSxWUyjKKe+rHtei1T4dIRqT+36v9rvxe eHfZwVhL7AWKbWdmV52RuaOlblc1yqM= X-MC-Unique: UZG9jtC1PJi8mjVY-bAVRg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 2/8] vdpa: Extract get_backend_features from vhost_vdpa_get_as_num Date: Wed, 10 Aug 2022 20:42:14 +0200 Message-Id: <20220810184220.2362292-3-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 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.133.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660157236353100003 The series reuses it to check for SUSPEND feature bit. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 11241ebac4..85b10799bd 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -602,9 +602,17 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_sv= q_ops =3D { .avail_handler =3D vhost_vdpa_net_handle_ctrl_avail, }; =20 -static uint32_t vhost_vdpa_get_as_num(int vdpa_device_fd) +static uint64_t vhost_vdpa_get_backend_features(int fd) { uint64_t features; + + /* No need to treat the error, only to know there is one */ + int ret =3D ioctl(fd, VHOST_GET_BACKEND_FEATURES, &features); + return ret < 0 ? 0 : features; +} + +static uint32_t vhost_vdpa_get_as_num(int vdpa_device_fd, uint64_t feature= s) +{ unsigned num_as; int r; =20 @@ -733,7 +741,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, NetClientState *peer, Error **errp) { const NetdevVhostVDPAOptions *opts; - uint64_t features; + uint64_t features, backend_features; int vdpa_device_fd; g_autofree NetClientState **ncs =3D NULL; g_autoptr(VhostIOVATree) iova_tree =3D NULL; @@ -765,9 +773,10 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, goto err; } =20 + backend_features =3D vhost_vdpa_get_backend_features(vdpa_device_fd); svq_cvq =3D opts->x_svq; if (has_cvq && !opts->x_svq) { - num_as =3D vhost_vdpa_get_as_num(vdpa_device_fd); + num_as =3D vhost_vdpa_get_as_num(vdpa_device_fd, backend_features); svq_cvq =3D num_as > 1; } =20 --=20 2.31.1 From nobody Thu May 2 14:17:50 2024 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=1660157679; cv=none; d=zohomail.com; s=zohoarc; b=AMMOUDFgT8kEUhfp8Zp9moLXG51kiGDFQasA088AYTHE80+j5Uhnj+ilg8HQB+sBCdBKEOD6+1UQns4Wguqj7N/xN0r9expDm7IFXa9fyLIyIIQQvqXlqxmbI9ih5WC7cyz0l0y8bTKTcjT1m+iF7VKzW8H87FYPFFkrAkve6Rg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660157679; 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=kTgbAuKIFtbiTbct78PH3a5nyxF/B2YC+cxL9w/h+/A=; b=gen8g3P5hsB/zKvmNOBIWNMCkBX683GJ0D2/1uYcKjuyXPO4rgLCCVyW7yAoVl0TGsZlYl/ugirTDzzwmipVnFIzLfWg57EtCPFTm54AmKFjYPxvgS5+obgZ3MYvc8M/TZGLHZY2RXJpx30R6MZjNWGujtJJGSi8mkImNk2UniE= 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 1660157679600999.3111387362391; Wed, 10 Aug 2022 11:54:39 -0700 (PDT) Received: from localhost ([::1]:57566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqqj-0002PY-As for importer@patchew.org; Wed, 10 Aug 2022 14:54:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfG-00028u-FM for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfB-0006hD-6c for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:44 -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-674-1R6qhDMSNDmCdJcEso_lzA-1; Wed, 10 Aug 2022 14:42:34 -0400 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 2674D29DD99A; Wed, 10 Aug 2022 18:42:34 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84C56C15BA3; Wed, 10 Aug 2022 18:42:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156956; 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=kTgbAuKIFtbiTbct78PH3a5nyxF/B2YC+cxL9w/h+/A=; b=a5d2jHuhAjq6UNSgjwcjWn9vFW7BsMwt5vS7XuLkgdZ4w8ZIZBDN7jcmUuM28s6/nurUS5 2XmD9ejRphkN460/rUTW52utnFhWAZ7/aCvRz/sXHWvLEvlKrCDHSnCujNkPdIJHaODtz4 nBRV7c4b0Yd7i1lIbv09335l/ZEH/7c= X-MC-Unique: 1R6qhDMSNDmCdJcEso_lzA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 3/8] vhost: expose memory listener priority Date: Wed, 10 Aug 2022 20:42:15 +0200 Message-Id: <20220810184220.2362292-4-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 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.133.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660157680019100001 We need to perform changes to vhost_vdpa devices before the memory listener inform them about the migration. Otherwise, it will reach them with no SVQ enabled and it cannot be guaranteed that it will be enabled afterwards. Expose the vhost memory listener priority so we can assign a lower one to net/vhost-vdpa one. Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/vhost.h | 2 ++ hw/virtio/vhost.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index a346f23d13..ccd6cc5549 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -104,6 +104,8 @@ struct vhost_dev { const VhostDevConfigOps *config_ops; }; =20 +#define VHOST_DEV_MEMORY_LISTENER_PRIORITY 10 + extern const VhostOps kernel_ops; extern const VhostOps user_ops; extern const VhostOps vdpa_ops; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 0827d631c0..a1e822b871 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1411,7 +1411,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, .log_global_stop =3D vhost_log_global_stop, .eventfd_add =3D vhost_eventfd_add, .eventfd_del =3D vhost_eventfd_del, - .priority =3D 10 + .priority =3D VHOST_DEV_MEMORY_LISTENER_PRIORITY }; =20 hdev->iommu_listener =3D (MemoryListener) { --=20 2.31.1 From nobody Thu May 2 14:17:50 2024 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=1660157227; cv=none; d=zohomail.com; s=zohoarc; b=PwbyQkMVYeJhw4nPJoAfzb+eQMXLC/ULBfDzv6kZwf70og5u/14JOM1C/MphqbHv4mR//xIJyAD3KKtlxXFI+pbT1uF2l87/+Td1IIVvRf1Nr3oZI5PI9wZnstqB9npD4ZIKOE9aQ1/yVEPgeq1Ctox80kc8tFUKs80x/TRI/qY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660157227; 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=JIy294Nk8MMn2A5k68elxAY+jDuXdJrJI/yT3QsTNOo=; b=CQszRkdGZaV1cIckOI55WkhXE/D3ggauMSLa2SCvHNZZvdkqZF4YUfRCb808ZqmTlNEP1Oxz+lQqtzd5U8gj3McuN2QYK8Eyn11IstrLRiMmfIY0unLFuKvzW1VzRZJLA7qUhlMYJFol8j/WCvxQhhRAyp/Izab5YEtHXVEmJ/g= 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 1660157227076123.42782031300476; Wed, 10 Aug 2022 11:47:07 -0700 (PDT) Received: from localhost ([::1]:49226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqjP-0004px-Ll for importer@patchew.org; Wed, 10 Aug 2022 14:47:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfG-00028w-Gi for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21300) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfC-0006iZ-1K for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:44 -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-616-j1rJP7exM_uCUuxEyiNgfA-1; Wed, 10 Aug 2022 14:42:37 -0400 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 EFD253800C34; Wed, 10 Aug 2022 18:42:36 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 690B0C15BA3; Wed, 10 Aug 2022 18:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156961; 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=JIy294Nk8MMn2A5k68elxAY+jDuXdJrJI/yT3QsTNOo=; b=S8w6MCj0IIaGRJI3drYS2NwRdkvx4uBIOAhsPqot0ZZETD25vnwkKKT4UmQUU9Lnm2zkta sR6LH9PrEEHBlJhN9cyb+vYH3E84IQvc9Z2RokrTFpidcZUbx8qoBP0pXZIyVZz87dBce0 9T+EEtyz+8ArcpvZk5bTKQBlErZbUJg= X-MC-Unique: j1rJP7exM_uCUuxEyiNgfA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 4/8] vdpa: Add log_enabled to VhostVDPAState Date: Wed, 10 Aug 2022 20:42:16 +0200 Message-Id: <20220810184220.2362292-5-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 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.133.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660157228481100001 This enables VhostVDPAState to track the logging of the memory. It cannot be merged with s->always_svq because always_svq is immutable from the moment the device is parsed, and log_enabled must be enabled or disabled depending on the log state. Apart from that, they will affect the same to vhost vdpa device, enabling the shadow virtqueue unconditionally. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 85b10799bd..a035c89c34 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -42,6 +42,10 @@ typedef struct VhostVDPAState { =20 /* The device always have SVQ enabled */ bool always_svq; + + /* Device log enabled */ + bool log_enabled; + bool started; } VhostVDPAState; =20 @@ -346,15 +350,15 @@ static int vhost_vdpa_net_cvq_start(NetClientState *n= c) cvq_group.index =3D v->dev->vq_index_end - 1; =20 /* Default values */ - v->listener_shadow_vq =3D s->always_svq; - v->shadow_vqs_enabled =3D s->always_svq; + v->listener_shadow_vq =3D s->always_svq || s->log_enabled; + v->shadow_vqs_enabled =3D s->always_svq || s->log_enabled; s->vhost_vdpa.address_space_id =3D VHOST_VDPA_NET_CVQ_PASSTHROUGH; =20 if (s->address_space_num < 2) { return 0; } =20 - if (s->always_svq) { + if (s->always_svq || s->log_enabled) { goto out; } =20 --=20 2.31.1 From nobody Thu May 2 14:17:50 2024 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=1660157235; cv=none; d=zohomail.com; s=zohoarc; b=M8qNYtDVIrrNc7JLKyWdVxqQMQDzc6cDOI4IpeaUOKKtp5S9x+irmBlv4x4yfJn8a46ZpF7n3CNMrspjs+zVhWTV3vlymDrefHRnxYGs20zCzNKn4CNmvCj+QQ2YKPxjFvSuX5SMQrIRh5eHAmfAy1bk/I5hPgQoURMAYeRYEzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660157235; 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=sdWfPImGYnxmxXNlua6fqa5IUyRe5dPjNA7afa0LHj0=; b=DFgQFv7S3DSusp4FcljqxJBQToyGgk+57fYdU8zeaPgz0Q0ahiKfpgOSsGlFZ5Q3DucXtv2UfHZRkY29nnEc4NC+dVmpQsCEXE42ADSMA80FvgQdoLXHhC8bUPLru4AlumfgPaw7RrncdtMSa7ChkUq/AqxF4/gRQlm9k0qtuJ4= 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 1660157235702117.95674310076174; Wed, 10 Aug 2022 11:47:15 -0700 (PDT) Received: from localhost ([::1]:49204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqjV-0004or-DI for importer@patchew.org; Wed, 10 Aug 2022 14:47:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfG-00028x-NO for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44647) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfF-0006kT-6C for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:46 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-Rtw7x0VwPtOmWZbn4LnDyA-1; Wed, 10 Aug 2022 14:42:40 -0400 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 CEFC385A58F; Wed, 10 Aug 2022 18:42:39 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4021BC15BA3; Wed, 10 Aug 2022 18:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156964; 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=sdWfPImGYnxmxXNlua6fqa5IUyRe5dPjNA7afa0LHj0=; b=DWmnwvVKcyp45g8KloH5C7MpZojfWEC7/yHaZe4uVHxw1nj5XRhXO1e6oRSii9821E55YL mxtkGkYNx7FYvbgmETJD7OTx1D0O+xf31XWbFEmG8Oa/04khDcaOgxzjFIoNFbz7NiGQdw ag92OY/XYOb1WkSIDfH5dcHJq1vTU9w= X-MC-Unique: Rtw7x0VwPtOmWZbn4LnDyA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 5/8] vdpa: Add vdpa memory listener Date: Wed, 10 Aug 2022 20:42:17 +0200 Message-Id: <20220810184220.2362292-6-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660157236304100001 This enable net/vdpa to restart the full device when a migration is started or stopped. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index a035c89c34..4c6947feb8 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -21,6 +21,7 @@ #include "qemu/memalign.h" #include "qemu/option.h" #include "qapi/error.h" +#include "exec/address-spaces.h" #include #include #include @@ -32,6 +33,8 @@ typedef struct VhostVDPAState { NetClientState nc; struct vhost_vdpa vhost_vdpa; + MemoryListener memory_listener; + VHostNetState *vhost_net; =20 /* Control commands shadow buffers */ @@ -110,6 +113,16 @@ static const uint64_t vdpa_svq_device_features =3D #define VHOST_VDPA_NET_CVQ_PASSTHROUGH 0 #define VHOST_VDPA_NET_CVQ_ASID 1 =20 +/* + * Vdpa memory listener must run before vhost one, so vhost_vdpa does not = get + * _F_LOG_ALL without SVQ. + */ +#define VHOST_VDPA_NET_MEMORY_LISTENER_PRIORITY \ + (VHOST_DEV_MEMORY_LISTENER_PRIORITY= - 1) +/* Check for underflow */ +QEMU_BUILD_BUG_ON(VHOST_DEV_MEMORY_LISTENER_PRIORITY < + VHOST_VDPA_NET_MEMORY_LISTENER_PRIORITY); + VHostNetState *vhost_vdpa_get_vhost_net(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); @@ -172,6 +185,9 @@ static void vhost_vdpa_cleanup(NetClientState *nc) =20 qemu_vfree(s->cvq_cmd_out_buffer); qemu_vfree(s->cvq_cmd_in_buffer); + if (dev->vq_index =3D=3D 0) { + memory_listener_unregister(&s->memory_listener); + } if (dev->vq_index + dev->nvqs =3D=3D dev->vq_index_end) { g_clear_pointer(&s->vhost_vdpa.iova_tree, vhost_iova_tree_delete); } @@ -224,6 +240,69 @@ static ssize_t vhost_vdpa_receive(NetClientState *nc, = const uint8_t *buf, return 0; } =20 +static void vhost_vdpa_net_log_global_enable(MemoryListener *listener, + bool enable) +{ + VhostVDPAState *s =3D container_of(listener, VhostVDPAState, + memory_listener); + struct vhost_vdpa *v =3D &s->vhost_vdpa; + VirtIONet *n; + VirtIODevice *vdev; + int data_queue_pairs, cvq, r; + NetClientState *peer; + + if (s->always_svq || s->log_enabled =3D=3D enable) { + return; + } + + s->log_enabled =3D enable; + vdev =3D v->dev->vdev; + n =3D VIRTIO_NET(vdev); + if (!n->vhost_started) { + return; + } + + if (enable) { + ioctl(v->device_fd, VHOST_VDPA_SUSPEND); + } + data_queue_pairs =3D n->multiqueue ? n->max_queue_pairs : 1; + cvq =3D virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) ? + n->max_ncs - n->max_queue_pairs : 0; + vhost_net_stop(vdev, n->nic->ncs, data_queue_pairs, cvq); + + peer =3D s->nc.peer; + for (int i =3D 0; i < data_queue_pairs + cvq; i++) { + VhostVDPAState *vdpa_state; + NetClientState *nc; + + if (i < data_queue_pairs) { + nc =3D qemu_get_peer(peer, i); + } else { + nc =3D qemu_get_peer(peer, n->max_queue_pairs); + } + + vdpa_state =3D DO_UPCAST(VhostVDPAState, nc, nc); + vdpa_state->vhost_vdpa.listener_shadow_vq =3D enable; + vdpa_state->vhost_vdpa.shadow_vqs_enabled =3D enable; + vdpa_state->log_enabled =3D enable; + } + + r =3D vhost_net_start(vdev, n->nic->ncs, data_queue_pairs, cvq); + if (unlikely(r < 0)) { + error_report("unable to start vhost net: %s(%d)", g_strerror(-r), = -r); + } +} + +static void vhost_vdpa_net_log_global_start(MemoryListener *listener) +{ + vhost_vdpa_net_log_global_enable(listener, true); +} + +static void vhost_vdpa_net_log_global_stop(MemoryListener *listener) +{ + vhost_vdpa_net_log_global_enable(listener, false); +} + static NetClientInfo net_vhost_vdpa_info =3D { .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, .size =3D sizeof(VhostVDPAState), @@ -413,6 +492,7 @@ static void vhost_vdpa_net_cvq_stop(NetClientState *nc) =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 + memory_listener_unregister(&s->memory_listener); if (s->vhost_vdpa.shadow_vqs_enabled) { vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_out_buffer); vhost_vdpa_cvq_unmap_buf(&s->vhost_vdpa, s->cvq_cmd_in_buffer); @@ -671,6 +751,13 @@ static NetClientState *net_vhost_vdpa_init(NetClientSt= ate *peer, s->vhost_vdpa.shadow_vqs_enabled =3D svq; s->vhost_vdpa.listener_shadow_vq =3D svq; s->vhost_vdpa.iova_tree =3D iova_tree; + if (queue_pair_index =3D=3D 0) { + s->memory_listener =3D (MemoryListener) { + .log_global_start =3D vhost_vdpa_net_log_global_start, + .log_global_stop =3D vhost_vdpa_net_log_global_stop, + }; + memory_listener_register(&s->memory_listener, &address_space_memor= y); + } if (!is_datapath) { s->cvq_cmd_out_buffer =3D qemu_memalign(qemu_real_host_page_size(), vhost_vdpa_net_cvq_cmd_page_le= n()); --=20 2.31.1 From nobody Thu May 2 14:17:50 2024 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=1660157943; cv=none; d=zohomail.com; s=zohoarc; b=dR0zn4x5HuZN8z3uU6o8ksFyIpZEEhMYx/zuCwHZI/Yn4vwGBV7wuKO6oNXn8GRguueXlJ3R3MOfCZIiN5lN+sZGTpVOxuTLxdzmz5rlX9F7PCsLHSkZGZvak4wddsMRMOlO9/pr5NegNE5w0cPFAw3maIAO7UzkdfIQcZ1OlEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660157943; 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=1mVJ38EwGXY+QEpr9DKXujdIXKFlc84PBGl+acvszhU=; b=GBcaScsBOfjSfUUK/F+C+kFeSxV94mvR2k18zS2gHmpw293xQZSQwArhd/irtiLiy5TU3dUutuxm7m5PM72nPKUwt0byfpvDgFqWN4KXyBecPrBp69oXlfPJZTvRVz0kKcKcjoJQTN2792I/w0oNfTiOWp+qDiIb11+gwsXGny4= 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 166015794369251.41284069851281; Wed, 10 Aug 2022 11:59:03 -0700 (PDT) Received: from localhost ([::1]:36952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLquz-0007jM-L0 for importer@patchew.org; Wed, 10 Aug 2022 14:59:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfI-00029Y-8n for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfG-0006mC-Ta for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:48 -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-314--aoavij5NHCX3WWFdp4PfQ-1; Wed, 10 Aug 2022 14:42:43 -0400 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 C4A8C3C0ED69; Wed, 10 Aug 2022 18:42:42 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C43DC15BA3; Wed, 10 Aug 2022 18:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156966; 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=1mVJ38EwGXY+QEpr9DKXujdIXKFlc84PBGl+acvszhU=; b=izFpp5Fs1hAE34535p8I41DRzM2Z1rkuHZDgZtxxRzxaPx2NhQxDARkW7vTTiYJcJflbG3 F6uPCLuG4CI2ltmhfg7sbhzXAAHB7fAtkm7whYRCa+RbDnsnFomUNZkrlggS9MX5wRAg+Z zlUz2dj9VM1VWXxkYGCq0Ts/OHWKdpg= X-MC-Unique: -aoavij5NHCX3WWFdp4PfQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 6/8] vdpa: Negotiate _F_SUSPEND feature Date: Wed, 10 Aug 2022 20:42:18 +0200 Message-Id: <20220810184220.2362292-7-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 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.133.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660157945768100001 This is needed for qemu to know it can suspend the device to retrieve its status and enable SVQ with it, so all the process is transparent to the guest. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 3607983422..d750d9cec1 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -679,7 +679,8 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev = *dev) uint64_t features; uint64_t f =3D 0x1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2 | 0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH | - 0x1ULL << VHOST_BACKEND_F_IOTLB_ASID; + 0x1ULL << VHOST_BACKEND_F_IOTLB_ASID | + 0x1ULL << VHOST_BACKEND_F_SUSPEND; int r; =20 if (vhost_vdpa_call(dev, VHOST_GET_BACKEND_FEATURES, &features)) { --=20 2.31.1 From nobody Thu May 2 14:17:50 2024 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=1660157667; cv=none; d=zohomail.com; s=zohoarc; b=V6jyS142dMBVTgKH0kjQ8hJyMuwLZ9N0iRvPHvD423kRS4wCQyJ9kLZyBTp3EewDFqKD3+CAOjktK7gZpurmdozLR4lFvnJYfH8OjPyhlz5K9z5N8rUFL9vvKnD6HbPyfCBUDr1WpxJR3KjlkgdslsJ0WqjQSfOIpZSEdaSxTZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660157667; 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=0D0uPqxFiZAmKNPRxQy9w0W+GrBjiwe7DR8oCJ3dPlc=; b=IapsvMJ25p2UkPqJeRLBSJ+mRKVi+PCBzjcHks5AyJUEZy/BuvqxmDhCrhRy+XUxI8tDYcRrHxFrQBC2GaP6gtBT8bWllqS0SHsP1UHXkerKyKHmFVjKfLC15CEp8IDHKN22xdXrclMSOZwb0S09DHeCjj7hcTj80Dh7fmfzm90= 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 1660157667225249.38587203345776; Wed, 10 Aug 2022 11:54:27 -0700 (PDT) Received: from localhost ([::1]:57468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqqX-0002LS-OF for importer@patchew.org; Wed, 10 Aug 2022 14:54:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfM-00029o-Uu for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfL-0006nd-He for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:52 -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-160-E4v9qChnNQu5mI8Nj3A0Qw-1; Wed, 10 Aug 2022 14:42:46 -0400 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 9BF163C0F39B; Wed, 10 Aug 2022 18:42:45 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13377C15BA3; Wed, 10 Aug 2022 18:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156971; 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=0D0uPqxFiZAmKNPRxQy9w0W+GrBjiwe7DR8oCJ3dPlc=; b=RSp41mJodcpbecevie36kvDaLNR587WWw+hJn2eGBN73P1iPTEX+TFAcxbYUN8A8eXwQlK ffympc6GfJXcus5+jjh9/3W+p/5no3fNxvVyGUAj66R7lriLUNynESZD9tavtSEJE6haBa EuYwIfo5qgCEg1XdDNaMpkR5JfHBt4Q= X-MC-Unique: E4v9qChnNQu5mI8Nj3A0Qw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 7/8] vdpa: Add feature_log member to vhost_vdpa Date: Wed, 10 Aug 2022 20:42:19 +0200 Message-Id: <20220810184220.2362292-8-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 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.133.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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660157671038100001 This way device's vhost_vdpa can make the choice about exposing or not the _F_LOG feature. At the moment is always false. Signed-off-by: Eugenio P=C3=A9rez --- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 0c3ed2d69b..b09eae133a 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -33,6 +33,7 @@ typedef struct vhost_vdpa { MemoryListener listener; struct vhost_vdpa_iova_range iova_range; uint64_t acked_features; + bool feature_log; bool shadow_vqs_enabled; /* The listener must send iova tree addresses, not GPA */ bool listener_shadow_vq; diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index d750d9cec1..17513ee820 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1246,7 +1246,7 @@ static int vhost_vdpa_get_features(struct vhost_dev *= dev, struct vhost_vdpa *v =3D dev->opaque; int ret =3D vhost_vdpa_get_dev_features(dev, features); =20 - if (ret =3D=3D 0 && v->shadow_vqs_enabled) { + if (ret =3D=3D 0 && (v->shadow_vqs_enabled || v->feature_log)) { /* Add SVQ logging capabilities */ *features |=3D BIT_ULL(VHOST_F_LOG_ALL); } --=20 2.31.1 From nobody Thu May 2 14:17:50 2024 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=1660157946; cv=none; d=zohomail.com; s=zohoarc; b=WIznnJUEF8CFdCMYBis8PoSgfV8Xlcw55YcLbhESRnEbU99dguqkXxJewai10cMo2q6ORjxmCPPWbm04Lejra64fvYnbXGWChAjKmmitHgu98Cu/EdKXO1cAR9ZEQhby1U2lJn7Gw5bZClYKIyLNCB2eTwgEqR9vrybnFBiF9PM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660157946; 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=oeyBAG6aT1XeG4X0sacNDdNhmDyM8S/qNFDxSwuCWuI=; b=TWFlPr8yZkt0P9eyjZQ7fLVCmVsjNULLvl1Ror9RqP4K8J79r2/rwIp+xGJbK932GspQlkyADjYLCVsZhrKwfmwksw7uaNlZbkLeB6a9y+G3uWXEXoeAYZRyPqdQC3K4Y3VWTImOiqbofcsGU56wt16bTDeH89glPUu0xNJZjZg= 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 1660157946364243.9784837924193; Wed, 10 Aug 2022 11:59:06 -0700 (PDT) Received: from localhost ([::1]:36954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLqv1-0007jV-QV for importer@patchew.org; Wed, 10 Aug 2022 14:59:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfO-0002AR-BI for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLqfM-0006nk-Pw for qemu-devel@nongnu.org; Wed, 10 Aug 2022 14:42:54 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-675-tgNjXTU-P-qyKAFHqDjcZQ-1; Wed, 10 Aug 2022 14:42:49 -0400 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 6FA498039A1; Wed, 10 Aug 2022 18:42:48 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDC52C15BA4; Wed, 10 Aug 2022 18:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660156972; 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=oeyBAG6aT1XeG4X0sacNDdNhmDyM8S/qNFDxSwuCWuI=; b=GhKqYMgFODaIliJHlemk+eMKuZeDNsHhDMqRY+Z5AFIL54myc8Pa6vSlBnmsgkL1owxi+K lJjuf2BdbUbWmFph5yAMWdyM52RQcQkiVZwkqAkcum4cXM3eETs87SZyqyke7AhvbGe1xs 1L7muRWXC+m4M0VJur6vvcCxC3cQqrg= X-MC-Unique: tgNjXTU-P-qyKAFHqDjcZQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Gonglei (Arei)" , Cindy Lu , Laurent Vivier , Stefan Hajnoczi , Parav Pandit , Zhu Lingshan , Gautam Dawar , Liuxiangdong , Jason Wang , Cornelia Huck , Eli Cohen , Stefano Garzarella , "Michael S. Tsirkin" , Harpreet Singh Anand Subject: [RFC 8/8] vdpa: Conditionally expose _F_LOG in vhost_net devices Date: Wed, 10 Aug 2022 20:42:20 +0200 Message-Id: <20220810184220.2362292-9-eperezma@redhat.com> In-Reply-To: <20220810184220.2362292-1-eperezma@redhat.com> References: <20220810184220.2362292-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660157947657100003 Vhost-vdpa networking devices need to met a few conditions to be migratable. If SVQ is not enabled from the beginnig, to suspend the device to retrieve the vq state is the first requirement. However, qemu also needs to be able to intercept SVQ from the beginning. To be able to do so, the vdpa device needs to expose certains features. Expose _F_LOG only if all of these are met. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 4c6947feb8..73c27cd315 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -49,6 +49,9 @@ typedef struct VhostVDPAState { /* Device log enabled */ bool log_enabled; =20 + /* Device can suspend */ + bool feature_suspend; + bool started; } VhostVDPAState; =20 @@ -431,6 +434,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) /* Default values */ v->listener_shadow_vq =3D s->always_svq || s->log_enabled; v->shadow_vqs_enabled =3D s->always_svq || s->log_enabled; + v->feature_log =3D s->always_svq || s->log_enabled; s->vhost_vdpa.address_space_id =3D VHOST_VDPA_NET_CVQ_PASSTHROUGH; =20 if (s->address_space_num < 2) { @@ -455,6 +459,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) if (unlikely(vq_group.num =3D=3D cvq_group.num)) { warn_report("CVQ %u group is the same as VQ %u one (%u)", cvq_group.index, vq_group.index, cvq_group.num); + v->feature_log =3D false; return 0; } } @@ -464,6 +469,7 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) if (r =3D=3D 0) { v->shadow_vqs_enabled =3D true; s->vhost_vdpa.address_space_id =3D VHOST_VDPA_NET_CVQ_ASID; + v->feature_log =3D s->feature_suspend; } =20 out: @@ -728,6 +734,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, unsigned nas, bool is_datapath, bool svq, + bool feature_suspend, VhostIOVATree *iova_tree) { NetClientState *nc =3D NULL; @@ -748,9 +755,11 @@ static NetClientState *net_vhost_vdpa_init(NetClientSt= ate *peer, s->vhost_vdpa.device_fd =3D vdpa_device_fd; s->vhost_vdpa.index =3D queue_pair_index; s->always_svq =3D svq; + s->feature_suspend =3D feature_suspend; s->vhost_vdpa.shadow_vqs_enabled =3D svq; s->vhost_vdpa.listener_shadow_vq =3D svq; s->vhost_vdpa.iova_tree =3D iova_tree; + s->vhost_vdpa.feature_log =3D feature_suspend; if (queue_pair_index =3D=3D 0) { s->memory_listener =3D (MemoryListener) { .log_global_start =3D vhost_vdpa_net_log_global_start, @@ -839,7 +848,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, NetClientState *nc; int queue_pairs, r, i =3D 0, has_cvq =3D 0; unsigned num_as =3D 1; - bool svq_cvq; + bool svq_cvq, feature_suspend; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -892,10 +901,11 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, =20 ncs =3D g_malloc0(sizeof(*ncs) * queue_pairs); =20 + feature_suspend =3D backend_features & BIT_ULL(VHOST_BACKEND_F_SUSPEND= ); for (i =3D 0; i < queue_pairs; i++) { ncs[i] =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 2, num_as, true, - opts->x_svq, iova_tree); + opts->x_svq, feature_suspend, iova_tr= ee); if (!ncs[i]) goto err; } @@ -903,7 +913,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, if (has_cvq) { nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 1, num_as, false, - opts->x_svq, iova_tree); + opts->x_svq, feature_suspend, iova_tree); if (!nc) goto err; } --=20 2.31.1