From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630660492907691.1731485525537; Fri, 3 Sep 2021 02:14:52 -0700 (PDT) Received: from localhost ([::1]:34862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5Hf-0000Sb-Sy for importer@patchew.org; Fri, 03 Sep 2021 05:14:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Dl-0008SX-F7 for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:10:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Dj-0002qd-RG for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:10:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-DtUvr8O-MlqTo1DK4NSnyA-1; Fri, 03 Sep 2021 05:10:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BAFB21854E20; Fri, 3 Sep 2021 09:10:44 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0318B60BF1; Fri, 3 Sep 2021 09:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660247; 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=issEgdO59vpdtpL/180mO9y40CxUKVIpfJW3AEPaFqc=; b=e7MCdmc6DybPAgNr4vwt3s3ss+YGDXI77jvok+k3Goqvd64cpqzNSo+BYr6+5/71FrUS6p Y3ZJpsOvrPEZXEjjfuuWWBhOu3FSF8ZpE899u+y+JZpqVyEhnBmpUOqEvk/CfZ/gyOuZTu 0Yyc7o7mpa96e1a+hE2kGUvLyqIyqnU= X-MC-Unique: DtUvr8O-MlqTo1DK4NSnyA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 01/21] vhost-vdpa: remove unused variable "acked_features" Date: Fri, 3 Sep 2021 17:10:11 +0800 Message-Id: <20210903091031.47303-2-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630660493685100001 Content-Type: text/plain; charset="utf-8" "acked_features" is unused, let's remove that. Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 19187dce8c..72829884d7 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -29,7 +29,6 @@ typedef struct VhostVDPAState { NetClientState nc; struct vhost_vdpa vhost_vdpa; VHostNetState *vhost_net; - uint64_t acked_features; bool started; } VhostVDPAState; =20 --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630660955346534.0523757838823; Fri, 3 Sep 2021 02:22:35 -0700 (PDT) Received: from localhost ([::1]:59906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5P8-0000wk-By for importer@patchew.org; Fri, 03 Sep 2021 05:22:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Do-00009v-Mi for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:10:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Dn-0002tK-8m for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:10:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-M4IWC7I-M4S7FnhNLLUqDg-1; Fri, 03 Sep 2021 05:10:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D275107ACC7; Fri, 3 Sep 2021 09:10:48 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 492F360C82; Fri, 3 Sep 2021 09:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660250; 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=xrr3iQV6wlQuzL+xUxPufyYtWEiKV0Pzgl194nsHf7k=; b=annUiyp+nNMGpeIMOcraR7r2mnuZGX8latX8j4gJz+Sb7JFzKe/SiMLT7x5acAKAWOmx/e wqEYn8BFy+IFmgCzkLG3vapLCnJgYhcIl4mdTADG3U+tkCQe4gPVCrBQ79whW+NytVeY+B I0iwY3H79EjQnbSLvFcIDWkF2rujHTA= X-MC-Unique: M4IWC7I-M4S7FnhNLLUqDg-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 02/21] vhost-vdpa: correctly return err in vhost_vdpa_set_backend_cap() Date: Fri, 3 Sep 2021 17:10:12 +0800 Message-Id: <20210903091031.47303-3-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630660957032100001 Content-Type: text/plain; charset="utf-8" We should return error code instead of zero, otherwise there's no way for the caller to detect the failure. Signed-off-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 4fa414feea..579f515e65 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -432,13 +432,13 @@ static int vhost_vdpa_set_backend_cap(struct vhost_de= v *dev) int r; =20 if (vhost_vdpa_call(dev, VHOST_GET_BACKEND_FEATURES, &features)) { - return 0; + return -EFAULT; } =20 features &=3D f; r =3D vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features); if (r) { - return 0; + return -EFAULT; } =20 dev->backend_cap =3D features; --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163066118364811.842399104199217; Fri, 3 Sep 2021 02:26:23 -0700 (PDT) Received: from localhost ([::1]:43490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5So-0000Wn-K4 for importer@patchew.org; Fri, 03 Sep 2021 05:26:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Dr-0000Ig-DM for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:10:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Dp-0002vm-Vx for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:10:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-Y_AygnnsM0OIHieMSKzZ3A-1; Fri, 03 Sep 2021 05:10:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 61A3410054F6; Fri, 3 Sep 2021 09:10:51 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F84760BF1; Fri, 3 Sep 2021 09:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660253; 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=LzxREhYWrIjUvrA12/nN75J2mhKSpdXgrI2tPCRtFck=; b=E+qWmEDAEbwnLUx4UV1b0CcIfqn/18TEbwyzaBCexl7vCBhU3XqnbU/kVHhB8MoFHhggQP 5kWAyLZd8ms8mbI4ioD/3iOhy9gcX36o8prum9h9zq+TxiV+vhmkXbo0tRPPJYpIHg5BkJ bhDI4QXwHFeuzllNH7oxn1WpDK18Ol4= X-MC-Unique: Y_AygnnsM0OIHieMSKzZ3A-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 03/21] vhost_net: remove the meaningless assignment in vhost_net_start_one() Date: Fri, 3 Sep 2021 17:10:13 +0800 Message-Id: <20210903091031.47303-4-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661184307100001 Content-Type: text/plain; charset="utf-8" The nvqs and vqs have been initialized during vhost_net_init() and are not expected to change during the life cycle of vhost_net structure. So this patch removes the meaningless assignment. Reviewed-by: Eli Cohen Signed-off-by: Jason Wang --- hw/net/vhost_net.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 10a7780a13..6ed0c39836 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -242,9 +242,6 @@ static int vhost_net_start_one(struct vhost_net *net, struct vhost_vring_file file =3D { }; int r; =20 - net->dev.nvqs =3D 2; - net->dev.vqs =3D net->vqs; - r =3D vhost_dev_enable_notifiers(&net->dev, dev); if (r < 0) { goto fail_notifiers; --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661128336843.3928511785963; Fri, 3 Sep 2021 02:25:28 -0700 (PDT) Received: from localhost ([::1]:39974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5Ru-0006VS-5C for importer@patchew.org; Fri, 03 Sep 2021 05:25:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Dv-0000VC-4B for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:10:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Dt-0002yo-MS for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:10:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-287-QsAz8l9APmCx0cDDa56wLA-1; Fri, 03 Sep 2021 05:10:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CDAFE107ACE4; Fri, 3 Sep 2021 09:10:54 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9F3B60BF1; Fri, 3 Sep 2021 09:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660257; 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=ibCr8vd06DJKOkwMQbC7aBA52904lLg9l7HpWhQi9AY=; b=AUMitKuXEkGOiljrUCDJ3EKep4jakqmd0URLc/OfLHTEmoTMAwb6d1CBYR98zPzkyibsMo pzw3AFv7oZRlJmtN3M4IYKAIUYjrP9NKtuf9LMVbjVSz0eWG4DQsf5bBWucaNv4z9TD0Bg IAVKO3lLgOanikR9NtVLwY5uLBQy/us= X-MC-Unique: QsAz8l9APmCx0cDDa56wLA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 04/21] vhost: use unsigned int for nvqs Date: Fri, 3 Sep 2021 17:10:14 +0800 Message-Id: <20210903091031.47303-5-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661129105100001 Content-Type: text/plain; charset="utf-8" Switch to use unsigned int for nvqs since it's not expected to be negative. Reviewed-by: Eli Cohen Signed-off-by: Jason Wang --- include/hw/virtio/vhost.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 045d0fd9f2..1222b21b94 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -71,7 +71,7 @@ struct vhost_dev { int n_tmp_sections; MemoryRegionSection *tmp_sections; struct vhost_virtqueue *vqs; - int nvqs; + unsigned int nvqs; /* the first virtqueue which would be used by this vhost dev */ int vq_index; /* if non-zero, minimum required value for max_queues */ --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661232110475.2308004839533; Fri, 3 Sep 2021 02:27:12 -0700 (PDT) Received: from localhost ([::1]:47352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5Tb-000370-4w for importer@patchew.org; Fri, 03 Sep 2021 05:27:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5E2-0000wB-SM for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55468) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5E1-00033R-7J for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:06 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-38-y0bvp9rsMBuOiJGm3928jA-1; Fri, 03 Sep 2021 05:11:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63B35835DE1; Fri, 3 Sep 2021 09:11:02 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57EE560BF1; Fri, 3 Sep 2021 09:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660264; 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=wCGH0HFb2ZDk3oTS+UwDghALPfMJPeJDR24dam/uXHk=; b=HSVT0uIQS9keoIq/VE93ZwudzLqUorrAjlJze50taZuxtn6W3tdlBRXHpGCyswZRTmaW7k qB8bRUZgXkg+ak+3ZxEpxg2Ctuoj3zUijanBvLo3E/gf68zg/K3RteaQARaJUTAoXN6Xc+ pr8X16nsqoAd17pU8lavs777DRAcBys= X-MC-Unique: y0bvp9rsMBuOiJGm3928jA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 05/21] vhost_net: do not assume nvqs is always 2 Date: Fri, 3 Sep 2021 17:10:15 +0800 Message-Id: <20210903091031.47303-6-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lulu@redhat.com, gdawar@xilinx.com, eperezma@redhat.com, elic@nvidia.com, lingshan.zhu@intel.com, Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661232756100001 Content-Type: text/plain; charset="utf-8" This patch switches to initialize dev.nvqs from the VhostNetOptions instead of assuming it was 2. This is useful for implementing control virtqueue support which will be a single vhost_net structure with a single cvq. Note that nvqs is still set to 2 for all users and this patch does not change functionality. Reviewed-by: Stefano Garzarella Reviewed-by: Eli Cohen Signed-off-by: Jason Wang --- hw/net/vhost_net.c | 2 +- include/net/vhost_net.h | 1 + net/tap.c | 1 + net/vhost-user.c | 1 + net/vhost-vdpa.c | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 6ed0c39836..386ec2eaa2 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -165,9 +165,9 @@ struct vhost_net *vhost_net_init(VhostNetOptions *optio= ns) goto fail; } net->nc =3D options->net_backend; + net->dev.nvqs =3D options->nvqs; =20 net->dev.max_queues =3D 1; - net->dev.nvqs =3D 2; net->dev.vqs =3D net->vqs; =20 if (backend_kernel) { diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 172b0051d8..fba40cf695 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -14,6 +14,7 @@ typedef struct VhostNetOptions { VhostBackendType backend_type; NetClientState *net_backend; uint32_t busyloop_timeout; + unsigned int nvqs; void *opaque; } VhostNetOptions; =20 diff --git a/net/tap.c b/net/tap.c index f5686bbf77..f716be3e3f 100644 --- a/net/tap.c +++ b/net/tap.c @@ -749,6 +749,7 @@ static void net_init_tap_one(const NetdevTapOptions *ta= p, NetClientState *peer, qemu_set_nonblock(vhostfd); } options.opaque =3D (void *)(uintptr_t)vhostfd; + options.nvqs =3D 2; =20 s->vhost_net =3D vhost_net_init(&options); if (!s->vhost_net) { diff --git a/net/vhost-user.c b/net/vhost-user.c index 6adfcd623a..4a939124d2 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -85,6 +85,7 @@ static int vhost_user_start(int queues, NetClientState *n= cs[], options.net_backend =3D ncs[i]; options.opaque =3D be; options.busyloop_timeout =3D 0; + options.nvqs =3D 2; net =3D vhost_net_init(&options); if (!net) { error_report("failed to init vhost_net for queue %d", i); diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 72829884d7..395117debd 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -104,6 +104,7 @@ static int vhost_vdpa_add(NetClientState *ncs, void *be) options.net_backend =3D ncs; options.opaque =3D be; options.busyloop_timeout =3D 0; + options.nvqs =3D 2; =20 net =3D vhost_net_init(&options); if (!net) { --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16306606770581011.6912623914684; Fri, 3 Sep 2021 02:17:57 -0700 (PDT) Received: from localhost ([::1]:43190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5Kd-0006Fb-Vp for importer@patchew.org; Fri, 03 Sep 2021 05:17:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5E8-0001Gs-2i for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5E6-00037e-Ig for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:11 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-237-HMteJurGOjynZvb8JOziRA-1; Fri, 03 Sep 2021 05:11:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A80B0100670B; Fri, 3 Sep 2021 09:11:05 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id E56DE60BF1; Fri, 3 Sep 2021 09:11:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660270; 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=jk9s+ZB/7Z47crrBJJpqNT4+zdFPnTmPiGioaBJ3Ls0=; b=BbcpRwZaBsHw9XBfMnnzxL7WTkq8ETAKgbbLOq3jSlma3Gvn6J6OevZO1m6WKHOfk446CC J59CluyK8cww8DZrILi6P0ufxtbsoLSkXLqmDRQzhXfOw3lSEZjyaVvy1WahyXzCmGOwbZ 1aLg6AutBG097uIE+GrBdPfX6l3DWVU= X-MC-Unique: HMteJurGOjynZvb8JOziRA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 06/21] vhost-vdpa: remove the unnecessary check in vhost_vdpa_add() Date: Fri, 3 Sep 2021 17:10:16 +0800 Message-Id: <20210903091031.47303-7-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630660678091100001 Content-Type: text/plain; charset="utf-8" The VhostVDPAState is just allocated by qemu_new_net_client() via g_malloc0() in net_vhost_vdpa_init(). So s->vhost_net is NULL for sure, let's remove this unnecessary check in vhost_vdpa_add(). Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 395117debd..5c09cacd5a 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -111,10 +111,6 @@ static int vhost_vdpa_add(NetClientState *ncs, void *b= e) error_report("failed to init vhost_net for queue"); goto err; } - if (s->vhost_net) { - vhost_net_cleanup(s->vhost_net); - g_free(s->vhost_net); - } s->vhost_net =3D net; ret =3D vhost_vdpa_net_check_device_id(net); if (ret) { --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630660379468771.9826962607507; Fri, 3 Sep 2021 02:12:59 -0700 (PDT) Received: from localhost ([::1]:56502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5Fq-0004Mp-FI for importer@patchew.org; Fri, 03 Sep 2021 05:12:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5EE-0001d3-Qs for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32913) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5ED-0003DC-D0 for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-421-PNUdwOrbOzyQJI5_fIbU8A-1; Fri, 03 Sep 2021 05:11:16 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E23710054F6; Fri, 3 Sep 2021 09:11:14 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3630260BF1; Fri, 3 Sep 2021 09:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660276; 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=64erj3ykZlts4/Rl/kgztxwDq2hi6anrP/1lxJeM+64=; b=b3/otzIU1hl9goUgKFACnwVryh9B8DY0D/iNhNlOOG7Qdl11fo9nZ/teARX8AQ5opIWa0Z xvHuVQt0KEvkusa7D3gBqabS7PfUdwLbiJwX93tCaAyhBZXiJfYtzFR7y+zjnYp4W6kf2w 8jya4N+Z+01xou3ky1Hy3Cglq2iAXQ8= X-MC-Unique: PNUdwOrbOzyQJI5_fIbU8A-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 07/21] vhost-vdpa: don't cleanup twice in vhost_vdpa_add() Date: Fri, 3 Sep 2021 17:10:17 +0800 Message-Id: <20210903091031.47303-8-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lulu@redhat.com, gdawar@xilinx.com, eperezma@redhat.com, elic@nvidia.com, lingshan.zhu@intel.com, Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630660380548100001 Content-Type: text/plain; charset="utf-8" The previous vhost_net_cleanup is sufficient for freeing, calling vhost_vdpa_del() in this case will lead an extra round of free. Note that this kind of "double free" is safe since vhost_dev_cleanup() zero the whole structure. Reviewed-by: Stefano Garzarella Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 5c09cacd5a..3213e69d63 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -81,16 +81,6 @@ static int vhost_vdpa_net_check_device_id(struct vhost_n= et *net) return ret; } =20 -static void vhost_vdpa_del(NetClientState *ncs) -{ - VhostVDPAState *s; - assert(ncs->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); - s =3D DO_UPCAST(VhostVDPAState, nc, ncs); - if (s->vhost_net) { - vhost_net_cleanup(s->vhost_net); - } -} - static int vhost_vdpa_add(NetClientState *ncs, void *be) { VhostNetOptions options; @@ -121,7 +111,6 @@ err: if (net) { vhost_net_cleanup(net); } - vhost_vdpa_del(ncs); return -1; } =20 --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661327774451.3436755079214; Fri, 3 Sep 2021 02:28:47 -0700 (PDT) Received: from localhost ([::1]:53880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5V8-0007Nu-Cc for importer@patchew.org; Fri, 03 Sep 2021 05:28:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5EL-0001vW-1s for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5EJ-0003IG-Jt for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-50-V-zS2TTuObmkzdC4-KPLTA-1; Fri, 03 Sep 2021 05:11:22 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00A0C835DE0; Fri, 3 Sep 2021 09:11:21 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3C5A610F0; Fri, 3 Sep 2021 09:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660283; 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=Xg9ERNG8oJn46YqK2OO1OnloZ3JphlNPG4Ne2I5BLZI=; b=DmT8LctHs0HqAbNe6G0CIplm1vivowzllT2A1/sJww21Lzh3UB4BsCINQHZxbhwLu2WYjw SIrpexV1/hHdieG1ZyChlh3b3KkaBJf//hZpJ7DbXlD3eLsosT9riTRA97uz/qFNhiNYjG 1qtzc3FfvgQa5RFu+sY3Lh2VIhDNNY4= X-MC-Unique: V-zS2TTuObmkzdC4-KPLTA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 08/21] vhost-vdpa: fix leaking of vhost_net in vhost_vdpa_add() Date: Fri, 3 Sep 2021 17:10:18 +0800 Message-Id: <20210903091031.47303-9-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lulu@redhat.com, gdawar@xilinx.com, eperezma@redhat.com, elic@nvidia.com, lingshan.zhu@intel.com, Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661329504100003 Content-Type: text/plain; charset="utf-8" Fixes: 1e0a84ea49b68 ("vhost-vdpa: introduce vhost-vdpa net client") Reviewed-by: Stefano Garzarella Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 3213e69d63..b43df00a85 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -110,6 +110,7 @@ static int vhost_vdpa_add(NetClientState *ncs, void *be) err: if (net) { vhost_net_cleanup(net); + g_free(net); } return -1; } --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630660854500508.1056230180045; Fri, 3 Sep 2021 02:20:54 -0700 (PDT) Received: from localhost ([::1]:55924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5NV-0006ZZ-Gd for importer@patchew.org; Fri, 03 Sep 2021 05:20:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5EP-0002Be-PV for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39321) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5EO-0003Lu-4m for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-E2vMWTaRODilLfzMPEGvQw-1; Fri, 03 Sep 2021 05:11:26 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B882835DE0; Fri, 3 Sep 2021 09:11:25 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8309D60BF1; Fri, 3 Sep 2021 09:11:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660287; 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=8hpFXlvmqB+X7JJ7ue28fYd73011gRIYj1+hMH0Qieo=; b=gVeV8EAtxA2kZs8tz5KwLXooc5cf3TtorSaGRVH9F0xRopuCrp88oNF12hK/cXocV3LpZu moVM18nAY0FvMvgOGLklzlapB0yd/GJn1aLsvgs1DnxZ5C/Cppl8D5v2D55WJjgHjivgYR dZKStbQvM8DG37aS/dCAl/lCc7el+A4= X-MC-Unique: E2vMWTaRODilLfzMPEGvQw-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 09/21] vhost-vdpa: tweak the error label in vhost_vdpa_add() Date: Fri, 3 Sep 2021 17:10:19 +0800 Message-Id: <20210903091031.47303-10-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630660855965100001 Content-Type: text/plain; charset="utf-8" Introduce new error label to avoid the unnecessary checking of net pointer. Fixes: 1e0a84ea49b68 ("vhost-vdpa: introduce vhost-vdpa net client") Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index b43df00a85..99327d17b4 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -99,19 +99,18 @@ static int vhost_vdpa_add(NetClientState *ncs, void *be) net =3D vhost_net_init(&options); if (!net) { error_report("failed to init vhost_net for queue"); - goto err; + goto err_init; } s->vhost_net =3D net; ret =3D vhost_vdpa_net_check_device_id(net); if (ret) { - goto err; + goto err_check; } return 0; -err: - if (net) { - vhost_net_cleanup(net); - g_free(net); - } +err_check: + vhost_net_cleanup(net); + g_free(net); +err_init: return -1; } =20 --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661488556672.1564031400521; Fri, 3 Sep 2021 02:31:28 -0700 (PDT) Received: from localhost ([::1]:60112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5Xj-0003N0-I9 for importer@patchew.org; Fri, 03 Sep 2021 05:31:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5EV-0002WI-MN for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40032) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5ET-0003QK-Sx for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:35 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-219--1NOy3i1MWuj4vnSWOZxTA-1; Fri, 03 Sep 2021 05:11:32 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39498835DE0; Fri, 3 Sep 2021 09:11:31 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEBF260BF1; Fri, 3 Sep 2021 09:11:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660293; 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=mzLf0auC+j4eXJaf7dJ/qxEgaQwsUXek6YlR7iaIGaY=; b=WW9knFUeJIPAJP8p3pCkyu+b+aEGNgITn+TnDqwhy6O0s38Aw3Yr5OHiMkwyYTpLKXbcXr jYsCvL9olhqodaUNcYlDEGcpYfA2u2Yg88zit2OtxoEsvtrE96a/hkOn6ZNyoNtOyJgn+Y 0WTlIN7SbSj8WDELEq249461gypiFto= X-MC-Unique: -1NOy3i1MWuj4vnSWOZxTA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 10/21] vhost-vdpa: fix the wrong assertion in vhost_vdpa_init() Date: Fri, 3 Sep 2021 17:10:20 +0800 Message-Id: <20210903091031.47303-11-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lulu@redhat.com, gdawar@xilinx.com, eperezma@redhat.com, elic@nvidia.com, lingshan.zhu@intel.com, Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661489315100001 Content-Type: text/plain; charset="utf-8" Vhost_vdpa_add() can fail for various reasons, so the assertion of the succeed is wrong. Instead, we should free the NetClientState and propagate the error to the caller Reviewed-by: Stefano Garzarella Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 99327d17b4..d02cad9855 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -173,7 +173,10 @@ static int net_vhost_vdpa_init(NetClientState *peer, c= onst char *device, } s->vhost_vdpa.device_fd =3D vdpa_device_fd; ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa); - assert(s->vhost_net); + if (ret) { + qemu_close(vdpa_device_fd); + qemu_del_net_client(nc); + } return ret; } =20 --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661275804130.0294200329846; Fri, 3 Sep 2021 02:27:55 -0700 (PDT) Received: from localhost ([::1]:50072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5UI-0004st-Ck for importer@patchew.org; Fri, 03 Sep 2021 05:27:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Eb-0002nL-8U for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32508) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5EZ-0003Vx-Nf for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:40 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-535-1wzik7f1ODapUtYS4bCzqA-1; Fri, 03 Sep 2021 05:11:38 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE1DB1854E20; Fri, 3 Sep 2021 09:11:36 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCE2A60BF1; Fri, 3 Sep 2021 09:11:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660299; 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=EHTcEK48zuoDSC0sxFEgTWCHyi1if47tYVQvwiOkPMQ=; b=GjKmUyAO7bpkqCcKKU06lQG+FgdSaCYX6YzVdsgNJwtXBLVs+PMMKxe2wodZ5SJ2DVzGAt Y4FiJ7kZGGE8hmiWXdx66up8YG3Xgx2e4VCtOXCXgqcq0CCXVqf/fs0PnyCZBa5X19DfQe nOetrWyR4iInsKctZ7irtZbZblsKofo= X-MC-Unique: 1wzik7f1ODapUtYS4bCzqA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 11/21] vhost-vdpa: remove the unncessary queue_index assignment Date: Fri, 3 Sep 2021 17:10:21 +0800 Message-Id: <20210903091031.47303-12-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lulu@redhat.com, gdawar@xilinx.com, eperezma@redhat.com, elic@nvidia.com, lingshan.zhu@intel.com, Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661277148100001 Content-Type: text/plain; charset="utf-8" The queue_index of NetClientState should be assigned in set_netdev() afterwards, so trying to net_vhost_vdpa_init() is meaningless. This patch removes this. Reviewed-by: Stefano Garzarella Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index d02cad9855..912686457c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -165,7 +165,6 @@ static int net_vhost_vdpa_init(NetClientState *peer, co= nst char *device, assert(name); nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA); - nc->queue_index =3D 0; s =3D DO_UPCAST(VhostVDPAState, nc, nc); vdpa_device_fd =3D qemu_open_old(vhostdev, O_RDWR); if (vdpa_device_fd =3D=3D -1) { --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661383333490.8121593238021; Fri, 3 Sep 2021 02:29:43 -0700 (PDT) Received: from localhost ([::1]:56456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5W2-0000kA-4t for importer@patchew.org; Fri, 03 Sep 2021 05:29:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Eh-000323-F6 for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Ef-0003aW-Ry for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-153-S2a8u1l7M0KQtbYPg1KrOA-1; Fri, 03 Sep 2021 05:11:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 254951854E20; Fri, 3 Sep 2021 09:11:43 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 260CC60BF1; Fri, 3 Sep 2021 09:11:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660305; 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=oznsK4TYWyVPd+Wvkh0qoOvkqDiKzoLreIhBVUPJ29U=; b=ZnkorJvKNR7DXZcQbUv7TfrcwxjteyPJwaBZpJkX24qZQxdgjSLsk61HX6ssMu9oSMWUOi MWnwT6N7Xb86gkNBwGJM3xCcnLgKv622h4IFkOCeCkf6IJW/vNjT99/Bk16UZhFwHtRtv+ MhTM96jWPuFnnChPLg7XYVNuqrSnFPA= X-MC-Unique: S2a8u1l7M0KQtbYPg1KrOA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 12/21] vhost-vdpa: open device fd in net_init_vhost_vdpa() Date: Fri, 3 Sep 2021 17:10:22 +0800 Message-Id: <20210903091031.47303-13-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lulu@redhat.com, gdawar@xilinx.com, eperezma@redhat.com, elic@nvidia.com, lingshan.zhu@intel.com, Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661385246100001 Content-Type: text/plain; charset="utf-8" This path switches to open device fd in net_init_vhost_vpda(). This is used to prepare for the multiqueue support. Reviewed-by: Stefano Garzarella Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 912686457c..73d29a74ef 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -156,24 +156,19 @@ static NetClientInfo net_vhost_vdpa_info =3D { }; =20 static int net_vhost_vdpa_init(NetClientState *peer, const char *device, - const char *name, const char *vhostdev) + const char *name, int vdpa_device_fd) { NetClientState *nc =3D NULL; VhostVDPAState *s; - int vdpa_device_fd =3D -1; int ret =3D 0; assert(name); nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA); s =3D DO_UPCAST(VhostVDPAState, nc, nc); - vdpa_device_fd =3D qemu_open_old(vhostdev, O_RDWR); - if (vdpa_device_fd =3D=3D -1) { - return -errno; - } + s->vhost_vdpa.device_fd =3D vdpa_device_fd; ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa); if (ret) { - qemu_close(vdpa_device_fd); qemu_del_net_client(nc); } return ret; @@ -201,6 +196,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, NetClientState *peer, Error **errp) { const NetdevVhostVDPAOptions *opts; + int vdpa_device_fd, ret; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -209,5 +205,16 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, (char *)name, errp)) { return -1; } - return net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, opts->vhostdev= ); + + vdpa_device_fd =3D qemu_open_old(opts->vhostdev, O_RDWR); + if (vdpa_device_fd =3D=3D -1) { + return -errno; + } + + ret =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_f= d); + if (ret) { + qemu_close(vdpa_device_fd); + } + + return ret; } --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661639688481.58514204640915; Fri, 3 Sep 2021 02:33:59 -0700 (PDT) Received: from localhost ([::1]:38136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5aA-0007mR-H1 for importer@patchew.org; Fri, 03 Sep 2021 05:33:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Eq-00035R-73 for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5El-0003eZ-Vp for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:11:54 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-329-V2o_8xIdP-SoFlTOXygleg-1; Fri, 03 Sep 2021 05:11:50 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E748A1854E20; Fri, 3 Sep 2021 09:11:48 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id A890B60BF1; Fri, 3 Sep 2021 09:11:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660311; 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=GvF+X46kEoC49WaueVhaxZbp1HNsn6GPfIHP+JdTxfI=; b=M2a6UdyRcayZBiaLZwZJ6ocjh7Adkqi8cJLYITP0C3xJkp6B3ubbz4JPwKgbTgp769pJga k7qh1nfYRky8AMmvZxeHb3J1sLA3l62Crhx59TL7yyyofyECIKKdTqVOhsDxGJPu3BiqjE fqSfN1HAX9zrppHxnbCl+6Y5jVRaYdo= X-MC-Unique: V2o_8xIdP-SoFlTOXygleg-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 13/21] vhost-vdpa: classify one time request Date: Fri, 3 Sep 2021 17:10:23 +0800 Message-Id: <20210903091031.47303-14-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661640190100001 Content-Type: text/plain; charset="utf-8" Vhost-vdpa uses one device multiqueue queue (pairs) model. So we need to classify the one time request (e.g SET_OWNER) and make sure those request were only called once per device. This is used for multiqueue support. Signed-off-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 52 ++++++++++++++++++++++++++++++---- include/hw/virtio/vhost-vdpa.h | 1 + 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 579f515e65..42c66de791 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -267,6 +267,13 @@ static void vhost_vdpa_add_status(struct vhost_dev *de= v, uint8_t status) vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &s); } =20 +static bool vhost_vdpa_one_time_request(struct vhost_dev *dev) +{ + struct vhost_vdpa *v =3D dev->opaque; + + return v->index !=3D 0; +} + static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **er= rp) { struct vhost_vdpa *v; @@ -279,6 +286,10 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void= *opaque, Error **errp) v->listener =3D vhost_vdpa_memory_listener; v->msg_type =3D VHOST_IOTLB_MSG_V2; =20 + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER); =20 @@ -389,6 +400,10 @@ static int vhost_vdpa_memslots_limit(struct vhost_dev = *dev) static int vhost_vdpa_set_mem_table(struct vhost_dev *dev, struct vhost_memory *mem) { + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + trace_vhost_vdpa_set_mem_table(dev, mem->nregions, mem->padding); if (trace_event_get_state_backends(TRACE_VHOST_VDPA_SET_MEM_TABLE) && trace_event_get_state_backends(TRACE_VHOST_VDPA_DUMP_REGIONS)) { @@ -412,6 +427,11 @@ static int vhost_vdpa_set_features(struct vhost_dev *d= ev, uint64_t features) { int ret; + + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + trace_vhost_vdpa_set_features(dev, features); ret =3D vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features); uint8_t status =3D 0; @@ -436,9 +456,12 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev= *dev) } =20 features &=3D f; - r =3D vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features); - if (r) { - return -EFAULT; + + if (vhost_vdpa_one_time_request(dev)) { + r =3D vhost_vdpa_call(dev, VHOST_SET_BACKEND_FEATURES, &features); + if (r) { + return -EFAULT; + } } =20 dev->backend_cap =3D features; @@ -547,11 +570,21 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev= , bool started) { struct vhost_vdpa *v =3D dev->opaque; trace_vhost_vdpa_dev_start(dev, started); + if (started) { - uint8_t status =3D 0; - memory_listener_register(&v->listener, &address_space_memory); vhost_vdpa_host_notifiers_init(dev); vhost_vdpa_set_vring_ready(dev); + } else { + vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); + } + + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + + if (started) { + uint8_t status =3D 0; + memory_listener_register(&v->listener, &address_space_memory); vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &status); =20 @@ -560,7 +593,6 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, = bool started) vhost_vdpa_reset_device(dev); vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER); - vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); memory_listener_unregister(&v->listener); =20 return 0; @@ -570,6 +602,10 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev,= bool started) static int vhost_vdpa_set_log_base(struct vhost_dev *dev, uint64_t base, struct vhost_log *log) { + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + trace_vhost_vdpa_set_log_base(dev, base, log->size, log->refcnt, log->= fd, log->log); return vhost_vdpa_call(dev, VHOST_SET_LOG_BASE, &base); @@ -635,6 +671,10 @@ static int vhost_vdpa_get_features(struct vhost_dev *d= ev, =20 static int vhost_vdpa_set_owner(struct vhost_dev *dev) { + if (vhost_vdpa_one_time_request(dev)) { + return 0; + } + trace_vhost_vdpa_set_owner(dev); return vhost_vdpa_call(dev, VHOST_SET_OWNER, NULL); } diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 9188226d8b..e98e327f12 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -21,6 +21,7 @@ typedef struct VhostVDPAHostNotifier { =20 typedef struct vhost_vdpa { int device_fd; + int index; uint32_t msg_type; MemoryListener listener; struct vhost_dev *dev; --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630660515046982.8862875957426; Fri, 3 Sep 2021 02:15:15 -0700 (PDT) Received: from localhost ([::1]:36598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5I1-0001er-VR for importer@patchew.org; Fri, 03 Sep 2021 05:15:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Ew-00039d-BG for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5Et-0003nk-Dl for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-578-irmSvD9AMt6ZoBIUeyTypg-1; Fri, 03 Sep 2021 05:11:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7C6F91006C85; Fri, 3 Sep 2021 09:11:56 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 247D660C81; Fri, 3 Sep 2021 09:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660318; 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=fNv1OIFwGBQz2dNcpkq4b5eWPX64C5nT3coNSNRCRvo=; b=F3qM9HutvSolL6ax6dLOQoJ1Rn43RtQ+0sZ86e0XZ9Q7Fsk/uAlEz4YFCsrdNTEzfOGNF4 oNn04fttxA7OmuG2tJeJdLdTP0Ciq1dWjNC2gYgGD9vxCD9C3Y2g7gi0/gw9+QN/saLEst u58i9Il6icge+YUU3ZUd9nZSEIDHN6I= X-MC-Unique: irmSvD9AMt6ZoBIUeyTypg-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 14/21] vhost-vdpa: prepare for the multiqueue support Date: Fri, 3 Sep 2021 17:10:24 +0800 Message-Id: <20210903091031.47303-15-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630660515939100003 Content-Type: text/plain; charset="utf-8" Unlike vhost-kernel, vhost-vdpa adapts a single device multiqueue model. So we need to simply use virtqueue index as the vhost virtqueue index. This is a must for multiqueue to work for vhost-vdpa. Signed-off-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 42c66de791..94eb9d4069 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -492,8 +492,8 @@ static int vhost_vdpa_get_vq_index(struct vhost_dev *de= v, int idx) { assert(idx >=3D dev->vq_index && idx < dev->vq_index + dev->nvqs); =20 - trace_vhost_vdpa_get_vq_index(dev, idx, idx - dev->vq_index); - return idx - dev->vq_index; + trace_vhost_vdpa_get_vq_index(dev, idx, idx); + return idx; } =20 static int vhost_vdpa_set_vring_ready(struct vhost_dev *dev) --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661193297760.6158427050727; Fri, 3 Sep 2021 02:26:33 -0700 (PDT) Received: from localhost ([::1]:44288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5Sy-000156-AI for importer@patchew.org; Fri, 03 Sep 2021 05:26:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5F3-0003dh-Qk for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5F1-0003uY-1D for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-x_k5edyVPk2iN0uKmK32dQ-1; Fri, 03 Sep 2021 05:12:04 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC5F91006C85; Fri, 3 Sep 2021 09:12:03 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB3A260C82; Fri, 3 Sep 2021 09:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660326; 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=R1/6pHZQ4emycHVhbShAHOx0byuaff7/lKKi81qIo68=; b=V6KYh9MC9D7A+8EaZrhuy1z4u0fSy53dQ0sxRsSoOifbfuE43NBfKnVJR6c2O0jniA9O/e ZFYl8isazTiTOedV2Mm0h+PY+sEeU97loD2CEkFarhnoOyl5lbMY75Owv664tTvdpCihKy 4y+I0H/lSxXrThqRps3b1ziQcbWFTiM= X-MC-Unique: x_k5edyVPk2iN0uKmK32dQ-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 15/21] vhost-vdpa: let net_vhost_vdpa_init() returns NetClientState * Date: Fri, 3 Sep 2021 17:10:25 +0800 Message-Id: <20210903091031.47303-16-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661195105100003 Content-Type: text/plain; charset="utf-8" This patch switches to let net_vhost_vdpa_init() to return NetClientState *. This is used for the callers to allocate multiqueue NetClientState for multiqueue support. Signed-off-by: Jason Wang --- net/vhost-vdpa.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 73d29a74ef..834dab28dd 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -155,8 +155,10 @@ static NetClientInfo net_vhost_vdpa_info =3D { .has_ufo =3D vhost_vdpa_has_ufo, }; =20 -static int net_vhost_vdpa_init(NetClientState *peer, const char *device, - const char *name, int vdpa_device_fd) +static NetClientState *net_vhost_vdpa_init(NetClientState *peer, + const char *device, + const char *name, + int vdpa_device_fd) { NetClientState *nc =3D NULL; VhostVDPAState *s; @@ -170,8 +172,9 @@ static int net_vhost_vdpa_init(NetClientState *peer, co= nst char *device, ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa); if (ret) { qemu_del_net_client(nc); + return NULL; } - return ret; + return nc; } =20 static int net_vhost_check_net(void *opaque, QemuOpts *opts, Error **errp) @@ -196,7 +199,8 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, NetClientState *peer, Error **errp) { const NetdevVhostVDPAOptions *opts; - int vdpa_device_fd, ret; + int vdpa_device_fd; + NetClientState *nc; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -211,10 +215,11 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, return -errno; } =20 - ret =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_f= d); - if (ret) { + nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd= ); + if (!nc) { qemu_close(vdpa_device_fd); + return -1; } =20 - return ret; + return 0; } --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661834526843.380491473317; Fri, 3 Sep 2021 02:37:14 -0700 (PDT) Received: from localhost ([::1]:49314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5dJ-00079H-J6 for importer@patchew.org; Fri, 03 Sep 2021 05:37:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5FB-00045n-2X for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5F7-0003zk-LC for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-257-E4zEjB8bOtCL0X8vEwciJg-1; Fri, 03 Sep 2021 05:12:12 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74C931854E26; Fri, 3 Sep 2021 09:12:09 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A7E160C81; Fri, 3 Sep 2021 09:12:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660333; 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=AN9MvBB/2SAN5dBYgsgpRwPgatjvg7plur/HtJIJRaM=; b=Cne09FlkW2g8NGm/iWyHGZfkYJLo12LycdCeA/HR16mrooQ++neo7nSyHAKOVoshregXaq vOVH4aR/y7YsconJA6I0HJxxqcW7WvDRa/yqjqyAkn9T4FZxb3dTujXHCSl7aUTZe/mCnU CdxKisu5Vj8r5lyG00N27SEds6vzvLU= X-MC-Unique: E4zEjB8bOtCL0X8vEwciJg-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 16/21] net: introduce control client Date: Fri, 3 Sep 2021 17:10:26 +0800 Message-Id: <20210903091031.47303-17-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661835801100001 Content-Type: text/plain; charset="utf-8" This patch introduces a boolean for the device has control queue which can accepts control command via network queue. The first user would be the control virtqueue support for vhost. Signed-off-by: Jason Wang --- include/net/net.h | 5 +++++ net/net.c | 24 +++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 5d1508081f..4f400b8a09 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -103,6 +103,7 @@ struct NetClientState { int vnet_hdr_len; bool is_netdev; bool do_not_pad; /* do not pad to the minimum ethernet frame length */ + bool is_datapath; QTAILQ_HEAD(, NetFilterState) filters; }; =20 @@ -134,6 +135,10 @@ NetClientState *qemu_new_net_client(NetClientInfo *inf= o, NetClientState *peer, const char *model, const char *name); +NetClientState *qemu_new_net_control_client(NetClientInfo *info, + NetClientState *peer, + const char *model, + const char *name); NICState *qemu_new_nic(NetClientInfo *info, NICConf *conf, const char *model, diff --git a/net/net.c b/net/net.c index 52c99196c6..f0d14dbfc1 100644 --- a/net/net.c +++ b/net/net.c @@ -239,7 +239,8 @@ static void qemu_net_client_setup(NetClientState *nc, NetClientState *peer, const char *model, const char *name, - NetClientDestructor *destructor) + NetClientDestructor *destructor, + bool is_datapath) { nc->info =3D info; nc->model =3D g_strdup(model); @@ -258,6 +259,7 @@ static void qemu_net_client_setup(NetClientState *nc, =20 nc->incoming_queue =3D qemu_new_net_queue(qemu_deliver_packet_iov, nc); nc->destructor =3D destructor; + nc->is_datapath =3D is_datapath; QTAILQ_INIT(&nc->filters); } =20 @@ -272,7 +274,23 @@ NetClientState *qemu_new_net_client(NetClientInfo *inf= o, =20 nc =3D g_malloc0(info->size); qemu_net_client_setup(nc, info, peer, model, name, - qemu_net_client_destructor); + qemu_net_client_destructor, true); + + return nc; +} + +NetClientState *qemu_new_net_control_client(NetClientInfo *info, + NetClientState *peer, + const char *model, + const char *name) +{ + NetClientState *nc; + + assert(info->size >=3D sizeof(NetClientState)); + + nc =3D g_malloc0(info->size); + qemu_net_client_setup(nc, info, peer, model, name, + qemu_net_client_destructor, false); =20 return nc; } @@ -297,7 +315,7 @@ NICState *qemu_new_nic(NetClientInfo *info, =20 for (i =3D 0; i < queues; i++) { qemu_net_client_setup(&nic->ncs[i], info, peers[i], model, name, - NULL); + NULL, true); nic->ncs[i].queue_index =3D i; } =20 --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661063264115.8813107547461; Fri, 3 Sep 2021 02:24:23 -0700 (PDT) Received: from localhost ([::1]:36156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5Qs-0003vP-5J for importer@patchew.org; Fri, 03 Sep 2021 05:24:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5FC-0004CD-Hc for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30865) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5F9-000412-OQ for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-369-UkAeVUgVNw69gU_5V6t0AA-1; Fri, 03 Sep 2021 05:12:13 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A960E512C; Fri, 3 Sep 2021 09:12:12 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2C1861093; Fri, 3 Sep 2021 09:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660335; 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=5wGFAQjeLmwsYhyPv3tJuebpW7JWWB/TgtneXPUrOHk=; b=YbqWxY/l2V31HHGqR1mrHlCNrA/ZN9LIZRtYNvTZc+v8rWSnJT0lCJK/xL1NgWnX9zeHuu ETsJKHCTWXvfWJP/eaS4IiLSiPS1Tb70QgdvtrQBIZhmlkocE7ffJANY1+epx24BiK/uGU 1DePSr9dch1qbU8eAcYi8T7XOOBzaRI= X-MC-Unique: UkAeVUgVNw69gU_5V6t0AA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 17/21] vhost-net: control virtqueue support Date: Fri, 3 Sep 2021 17:10:27 +0800 Message-Id: <20210903091031.47303-18-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661065238100001 Content-Type: text/plain; charset="utf-8" We assume there's no cvq in the past, this is not true when we need control virtqueue support for vhost-user backends. So this patch implements the control virtqueue support for vhost-net. As datapath, the control virtqueue is also required to be coupled with the NetClientState. The vhost_net_start/stop() are tweaked to accept the number of datapath queue pairs plus the the number of control virtqueue for us to start and stop the vhost device. Signed-off-by: Jason Wang --- hw/net/vhost_net.c | 43 ++++++++++++++++++++++++++++++----------- hw/net/virtio-net.c | 4 ++-- include/net/vhost_net.h | 6 ++++-- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 386ec2eaa2..7e0b60b4d9 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -315,11 +315,14 @@ static void vhost_net_stop_one(struct vhost_net *net, } =20 int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, - int total_queues) + int data_qps, int cvq) { BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(dev))); VirtioBusState *vbus =3D VIRTIO_BUS(qbus); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(vbus); + int total_notifiers =3D data_qps * 2 + cvq; + VirtIONet *n =3D VIRTIO_NET(dev); + int nvhosts =3D data_qps + cvq; struct vhost_net *net; int r, e, i; NetClientState *peer; @@ -329,9 +332,14 @@ int vhost_net_start(VirtIODevice *dev, NetClientState = *ncs, return -ENOSYS; } =20 - for (i =3D 0; i < total_queues; i++) { + for (i =3D 0; i < nvhosts; i++) { + + if (i < data_qps) { + peer =3D qemu_get_peer(ncs, i); + } else { /* Control Virtqueue */ + peer =3D qemu_get_peer(ncs, n->max_queues); + } =20 - peer =3D qemu_get_peer(ncs, i); net =3D get_vhost_net(peer); vhost_net_set_vq_index(net, i * 2); =20 @@ -344,14 +352,18 @@ int vhost_net_start(VirtIODevice *dev, NetClientState= *ncs, } } =20 - r =3D k->set_guest_notifiers(qbus->parent, total_queues * 2, true); + r =3D k->set_guest_notifiers(qbus->parent, total_notifiers, true); if (r < 0) { error_report("Error binding guest notifier: %d", -r); goto err; } =20 - for (i =3D 0; i < total_queues; i++) { - peer =3D qemu_get_peer(ncs, i); + for (i =3D 0; i < nvhosts; i++) { + if (i < data_qps) { + peer =3D qemu_get_peer(ncs, i); + } else { + peer =3D qemu_get_peer(ncs, n->max_queues); + } r =3D vhost_net_start_one(get_vhost_net(peer), dev); =20 if (r < 0) { @@ -375,7 +387,7 @@ err_start: peer =3D qemu_get_peer(ncs , i); vhost_net_stop_one(get_vhost_net(peer), dev); } - e =3D k->set_guest_notifiers(qbus->parent, total_queues * 2, false); + e =3D k->set_guest_notifiers(qbus->parent, total_notifiers, false); if (e < 0) { fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", e); fflush(stderr); @@ -385,18 +397,27 @@ err: } =20 void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, - int total_queues) + int data_qps, int cvq) { BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(dev))); VirtioBusState *vbus =3D VIRTIO_BUS(qbus); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(vbus); + VirtIONet *n =3D VIRTIO_NET(dev); + NetClientState *peer; + int total_notifiers =3D data_qps * 2 + cvq; + int nvhosts =3D data_qps + cvq; int i, r; =20 - for (i =3D 0; i < total_queues; i++) { - vhost_net_stop_one(get_vhost_net(ncs[i].peer), dev); + for (i =3D 0; i < nvhosts; i++) { + if (i < data_qps) { + peer =3D qemu_get_peer(ncs, i); + } else { + peer =3D qemu_get_peer(ncs, n->max_queues); + } + vhost_net_stop_one(get_vhost_net(peer), dev); } =20 - r =3D k->set_guest_notifiers(qbus->parent, total_queues * 2, false); + r =3D k->set_guest_notifiers(qbus->parent, total_notifiers, false); if (r < 0) { fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", r); fflush(stderr); diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 16d20cdee5..8fccbaa44c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -285,14 +285,14 @@ static void virtio_net_vhost_status(VirtIONet *n, uin= t8_t status) } =20 n->vhost_started =3D 1; - r =3D vhost_net_start(vdev, n->nic->ncs, queues); + r =3D vhost_net_start(vdev, n->nic->ncs, queues, 0); if (r < 0) { error_report("unable to start vhost net: %d: " "falling back on userspace virtio", -r); n->vhost_started =3D 0; } } else { - vhost_net_stop(vdev, n->nic->ncs, queues); + vhost_net_stop(vdev, n->nic->ncs, queues, 0); n->vhost_started =3D 0; } } diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index fba40cf695..e656e38af9 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -21,8 +21,10 @@ typedef struct VhostNetOptions { uint64_t vhost_net_get_max_queues(VHostNetState *net); struct vhost_net *vhost_net_init(VhostNetOptions *options); =20 -int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, int total_queu= es); -void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, int total_queu= es); +int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, + int data_qps, int cvq); +void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, + int data_qps, int cvq); =20 void vhost_net_cleanup(VHostNetState *net); =20 --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661786947216.26009725871847; Fri, 3 Sep 2021 02:36:26 -0700 (PDT) Received: from localhost ([::1]:46728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5cX-0005O9-V6 for importer@patchew.org; Fri, 03 Sep 2021 05:36:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5FH-0004Tu-5n for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33283) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5FE-00045A-Ch for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-173-PgRV4NB1MX2-M6u5WYz4kA-1; Fri, 03 Sep 2021 05:12:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 643AD801AC3; Fri, 3 Sep 2021 09:12:16 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6111F60C81; Fri, 3 Sep 2021 09:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660339; 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=TgyolSwUMOfR0Cfa2823/6Z7LLy13IfjDDNIRDFzPzA=; b=iwNbY4Gn2Lko8stGxHto6niXpLBLJHEvykEZKRiKNE6U9LN8bGFbhCDqkoQtcP0T1dDqqp divJ7iIQiwbFr/vNy8vaV4CUp5n+EP7SxlJEFF/8k8SIFbMZz9Uzi97IbBk4413m8IwA2p w3CMrUV04184n4MYrEE9i3p6DGPq1EM= X-MC-Unique: PgRV4NB1MX2-M6u5WYz4kA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 18/21] virito-net: use "qps" instead of "queues" when possible Date: Fri, 3 Sep 2021 17:10:28 +0800 Message-Id: <20210903091031.47303-19-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661789014100001 Content-Type: text/plain; charset="utf-8" Most of the time, "queues" really means queue pairs. So this patch switch to use "qps" to avoid confusion. Signed-off-by: Jason Wang --- hw/net/vhost_net.c | 6 +- hw/net/virtio-net.c | 150 ++++++++++++++++----------------- include/hw/virtio/virtio-net.h | 4 +- 3 files changed, 80 insertions(+), 80 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 7e0b60b4d9..b40fdfa625 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -337,7 +337,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, if (i < data_qps) { peer =3D qemu_get_peer(ncs, i); } else { /* Control Virtqueue */ - peer =3D qemu_get_peer(ncs, n->max_queues); + peer =3D qemu_get_peer(ncs, n->max_qps); } =20 net =3D get_vhost_net(peer); @@ -362,7 +362,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, if (i < data_qps) { peer =3D qemu_get_peer(ncs, i); } else { - peer =3D qemu_get_peer(ncs, n->max_queues); + peer =3D qemu_get_peer(ncs, n->max_qps); } r =3D vhost_net_start_one(get_vhost_net(peer), dev); =20 @@ -412,7 +412,7 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *= ncs, if (i < data_qps) { peer =3D qemu_get_peer(ncs, i); } else { - peer =3D qemu_get_peer(ncs, n->max_queues); + peer =3D qemu_get_peer(ncs, n->max_qps); } vhost_net_stop_one(get_vhost_net(peer), dev); } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 8fccbaa44c..0a5d9862ec 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -54,7 +54,7 @@ #define VIRTIO_NET_RX_QUEUE_DEFAULT_SIZE 256 #define VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE 256 =20 -/* for now, only allow larger queues; with virtio-1, guest can downsize */ +/* for now, only allow larger qps; with virtio-1, guest can downsize */ #define VIRTIO_NET_RX_QUEUE_MIN_SIZE VIRTIO_NET_RX_QUEUE_DEFAULT_SIZE #define VIRTIO_NET_TX_QUEUE_MIN_SIZE VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE =20 @@ -131,7 +131,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, u= int8_t *config) int ret =3D 0; memset(&netcfg, 0 , sizeof(struct virtio_net_config)); virtio_stw_p(vdev, &netcfg.status, n->status); - virtio_stw_p(vdev, &netcfg.max_virtqueue_pairs, n->max_queues); + virtio_stw_p(vdev, &netcfg.max_virtqueue_pairs, n->max_qps); virtio_stw_p(vdev, &netcfg.mtu, n->net_conf.mtu); memcpy(netcfg.mac, n->mac, ETH_ALEN); virtio_stl_p(vdev, &netcfg.speed, n->net_conf.speed); @@ -243,7 +243,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8= _t status) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); NetClientState *nc =3D qemu_get_queue(n->nic); - int queues =3D n->multiqueue ? n->max_queues : 1; + int qps =3D n->multiqueue ? n->max_qps : 1; =20 if (!get_vhost_net(nc->peer)) { return; @@ -266,7 +266,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8= _t status) /* Any packets outstanding? Purge them to avoid touching rings * when vhost is running. */ - for (i =3D 0; i < queues; i++) { + for (i =3D 0; i < qps; i++) { NetClientState *qnc =3D qemu_get_subqueue(n->nic, i); =20 /* Purge both directions: TX and RX. */ @@ -285,14 +285,14 @@ static void virtio_net_vhost_status(VirtIONet *n, uin= t8_t status) } =20 n->vhost_started =3D 1; - r =3D vhost_net_start(vdev, n->nic->ncs, queues, 0); + r =3D vhost_net_start(vdev, n->nic->ncs, qps, 0); if (r < 0) { error_report("unable to start vhost net: %d: " "falling back on userspace virtio", -r); n->vhost_started =3D 0; } } else { - vhost_net_stop(vdev, n->nic->ncs, queues, 0); + vhost_net_stop(vdev, n->nic->ncs, qps, 0); n->vhost_started =3D 0; } } @@ -309,11 +309,11 @@ static int virtio_net_set_vnet_endian_one(VirtIODevic= e *vdev, } =20 static bool virtio_net_set_vnet_endian(VirtIODevice *vdev, NetClientState = *ncs, - int queues, bool enable) + int qps, bool enable) { int i; =20 - for (i =3D 0; i < queues; i++) { + for (i =3D 0; i < qps; i++) { if (virtio_net_set_vnet_endian_one(vdev, ncs[i].peer, enable) < 0 = && enable) { while (--i >=3D 0) { @@ -330,7 +330,7 @@ static bool virtio_net_set_vnet_endian(VirtIODevice *vd= ev, NetClientState *ncs, static void virtio_net_vnet_endian_status(VirtIONet *n, uint8_t status) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); - int queues =3D n->multiqueue ? n->max_queues : 1; + int qps =3D n->multiqueue ? n->max_qps : 1; =20 if (virtio_net_started(n, status)) { /* Before using the device, we tell the network backend about the @@ -339,14 +339,14 @@ static void virtio_net_vnet_endian_status(VirtIONet *= n, uint8_t status) * virtio-net code. */ n->needs_vnet_hdr_swap =3D virtio_net_set_vnet_endian(vdev, n->nic= ->ncs, - queues, true); + qps, true); } else if (virtio_net_started(n, vdev->status)) { /* After using the device, we need to reset the network backend to * the default (guest native endianness), otherwise the guest may * lose network connectivity if it is rebooted into a different * endianness. */ - virtio_net_set_vnet_endian(vdev, n->nic->ncs, queues, false); + virtio_net_set_vnet_endian(vdev, n->nic->ncs, qps, false); } } =20 @@ -368,12 +368,12 @@ static void virtio_net_set_status(struct VirtIODevice= *vdev, uint8_t status) virtio_net_vnet_endian_status(n, status); virtio_net_vhost_status(n, status); =20 - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_qps; i++) { NetClientState *ncs =3D qemu_get_subqueue(n->nic, i); bool queue_started; q =3D &n->vqs[i]; =20 - if ((!n->multiqueue && i !=3D 0) || i >=3D n->curr_queues) { + if ((!n->multiqueue && i !=3D 0) || i >=3D n->curr_qps) { queue_status =3D 0; } else { queue_status =3D status; @@ -540,7 +540,7 @@ static void virtio_net_reset(VirtIODevice *vdev) n->nouni =3D 0; n->nobcast =3D 0; /* multiqueue is disabled by default */ - n->curr_queues =3D 1; + n->curr_qps =3D 1; timer_del(n->announce_timer.tm); n->announce_timer.round =3D 0; n->status &=3D ~VIRTIO_NET_S_ANNOUNCE; @@ -556,7 +556,7 @@ static void virtio_net_reset(VirtIODevice *vdev) memset(n->vlans, 0, MAX_VLAN >> 3); =20 /* Flush any async TX */ - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_qps; i++) { NetClientState *nc =3D qemu_get_subqueue(n->nic, i); =20 if (nc->peer) { @@ -610,7 +610,7 @@ static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, in= t mergeable_rx_bufs, sizeof(struct virtio_net_hdr); } =20 - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_qps; i++) { nc =3D qemu_get_subqueue(n->nic, i); =20 if (peer_has_vnet_hdr(n) && @@ -655,7 +655,7 @@ static int peer_attach(VirtIONet *n, int index) return 0; } =20 - if (n->max_queues =3D=3D 1) { + if (n->max_qps =3D=3D 1) { return 0; } =20 @@ -681,7 +681,7 @@ static int peer_detach(VirtIONet *n, int index) return tap_disable(nc->peer); } =20 -static void virtio_net_set_queues(VirtIONet *n) +static void virtio_net_set_qps(VirtIONet *n) { int i; int r; @@ -690,8 +690,8 @@ static void virtio_net_set_queues(VirtIONet *n) return; } =20 - for (i =3D 0; i < n->max_queues; i++) { - if (i < n->curr_queues) { + for (i =3D 0; i < n->max_qps; i++) { + if (i < n->curr_qps) { r =3D peer_attach(n, i); assert(!r); } else { @@ -920,7 +920,7 @@ static void virtio_net_set_features(VirtIODevice *vdev,= uint64_t features) virtio_net_apply_guest_offloads(n); } =20 - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_qps; i++) { NetClientState *nc =3D qemu_get_subqueue(n->nic, i); =20 if (!get_vhost_net(nc->peer)) { @@ -1247,7 +1247,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, VirtIODevice *vdev =3D VIRTIO_DEVICE(n); struct virtio_net_rss_config cfg; size_t s, offset =3D 0, size_get; - uint16_t queues, i; + uint16_t qps, i; struct { uint16_t us; uint8_t b; @@ -1289,7 +1289,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, } n->rss_data.default_queue =3D do_rss ? virtio_lduw_p(vdev, &cfg.unclassified_queue) : 0; - if (n->rss_data.default_queue >=3D n->max_queues) { + if (n->rss_data.default_queue >=3D n->max_qps) { err_msg =3D "Invalid default queue"; err_value =3D n->rss_data.default_queue; goto error; @@ -1318,14 +1318,14 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, size_get =3D sizeof(temp); s =3D iov_to_buf(iov, iov_cnt, offset, &temp, size_get); if (s !=3D size_get) { - err_msg =3D "Can't get queues"; + err_msg =3D "Can't get qps"; err_value =3D (uint32_t)s; goto error; } - queues =3D do_rss ? virtio_lduw_p(vdev, &temp.us) : n->curr_queues; - if (queues =3D=3D 0 || queues > n->max_queues) { - err_msg =3D "Invalid number of queues"; - err_value =3D queues; + qps =3D do_rss ? virtio_lduw_p(vdev, &temp.us) : n->curr_qps; + if (qps =3D=3D 0 || qps > n->max_qps) { + err_msg =3D "Invalid number of qps"; + err_value =3D qps; goto error; } if (temp.b > VIRTIO_NET_RSS_MAX_KEY_SIZE) { @@ -1340,7 +1340,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, } if (!temp.b && !n->rss_data.hash_types) { virtio_net_disable_rss(n); - return queues; + return qps; } offset +=3D size_get; size_get =3D temp.b; @@ -1373,7 +1373,7 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, trace_virtio_net_rss_enable(n->rss_data.hash_types, n->rss_data.indirections_len, temp.b); - return queues; + return qps; error: trace_virtio_net_rss_error(err_msg, err_value); virtio_net_disable_rss(n); @@ -1384,15 +1384,15 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8= _t cmd, struct iovec *iov, unsigned int iov_cnt) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); - uint16_t queues; + uint16_t qps; =20 virtio_net_disable_rss(n); if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_HASH_CONFIG) { - queues =3D virtio_net_handle_rss(n, iov, iov_cnt, false); - return queues ? VIRTIO_NET_OK : VIRTIO_NET_ERR; + qps =3D virtio_net_handle_rss(n, iov, iov_cnt, false); + return qps ? VIRTIO_NET_OK : VIRTIO_NET_ERR; } if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_RSS_CONFIG) { - queues =3D virtio_net_handle_rss(n, iov, iov_cnt, true); + qps =3D virtio_net_handle_rss(n, iov, iov_cnt, true); } else if (cmd =3D=3D VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET) { struct virtio_net_ctrl_mq mq; size_t s; @@ -1403,24 +1403,24 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8= _t cmd, if (s !=3D sizeof(mq)) { return VIRTIO_NET_ERR; } - queues =3D virtio_lduw_p(vdev, &mq.virtqueue_pairs); + qps =3D virtio_lduw_p(vdev, &mq.virtqueue_pairs); =20 } else { return VIRTIO_NET_ERR; } =20 - if (queues < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN || - queues > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX || - queues > n->max_queues || + if (qps < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN || + qps > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX || + qps > n->max_qps || !n->multiqueue) { return VIRTIO_NET_ERR; } =20 - n->curr_queues =3D queues; - /* stop the backend before changing the number of queues to avoid hand= ling a + n->curr_qps =3D qps; + /* stop the backend before changing the number of qps to avoid handlin= g a * disabled queue */ virtio_net_set_status(vdev, vdev->status); - virtio_net_set_queues(n); + virtio_net_set_qps(n); =20 return VIRTIO_NET_OK; } @@ -1498,7 +1498,7 @@ static bool virtio_net_can_receive(NetClientState *nc) return false; } =20 - if (nc->queue_index >=3D n->curr_queues) { + if (nc->queue_index >=3D n->curr_qps) { return false; } =20 @@ -2753,11 +2753,11 @@ static void virtio_net_del_queue(VirtIONet *n, int = index) virtio_del_queue(vdev, index * 2 + 1); } =20 -static void virtio_net_change_num_queues(VirtIONet *n, int new_max_queues) +static void virtio_net_change_num_qps(VirtIONet *n, int new_max_qps) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); int old_num_queues =3D virtio_get_num_queues(vdev); - int new_num_queues =3D new_max_queues * 2 + 1; + int new_num_queues =3D new_max_qps * 2 + 1; int i; =20 assert(old_num_queues >=3D 3); @@ -2790,12 +2790,12 @@ static void virtio_net_change_num_queues(VirtIONet = *n, int new_max_queues) =20 static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue) { - int max =3D multiqueue ? n->max_queues : 1; + int max =3D multiqueue ? n->max_qps : 1; =20 n->multiqueue =3D multiqueue; - virtio_net_change_num_queues(n, max); + virtio_net_change_num_qps(n, max); =20 - virtio_net_set_queues(n); + virtio_net_set_qps(n); } =20 static int virtio_net_post_load_device(void *opaque, int version_id) @@ -2828,7 +2828,7 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) */ n->saved_guest_offloads =3D n->curr_guest_offloads; =20 - virtio_net_set_queues(n); + virtio_net_set_qps(n); =20 /* Find the first multicast entry in the saved MAC filter */ for (i =3D 0; i < n->mac_table.in_use; i++) { @@ -2841,7 +2841,7 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) /* nc.link_down can't be migrated, so infer link_down according * to link status bit in n->status */ link_down =3D (n->status & VIRTIO_NET_S_LINK_UP) =3D=3D 0; - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_qps; i++) { qemu_get_subqueue(n->nic, i)->link_down =3D link_down; } =20 @@ -2906,9 +2906,9 @@ static const VMStateDescription vmstate_virtio_net_qu= eue_tx_waiting =3D { }, }; =20 -static bool max_queues_gt_1(void *opaque, int version_id) +static bool max_qps_gt_1(void *opaque, int version_id) { - return VIRTIO_NET(opaque)->max_queues > 1; + return VIRTIO_NET(opaque)->max_qps > 1; } =20 static bool has_ctrl_guest_offloads(void *opaque, int version_id) @@ -2933,13 +2933,13 @@ static bool mac_table_doesnt_fit(void *opaque, int = version_id) struct VirtIONetMigTmp { VirtIONet *parent; VirtIONetQueue *vqs_1; - uint16_t curr_queues_1; + uint16_t curr_qps_1; uint8_t has_ufo; uint32_t has_vnet_hdr; }; =20 /* The 2nd and subsequent tx_waiting flags are loaded later than - * the 1st entry in the queues and only if there's more than one + * the 1st entry in the qps and only if there's more than one * entry. We use the tmp mechanism to calculate a temporary * pointer and count and also validate the count. */ @@ -2949,9 +2949,9 @@ static int virtio_net_tx_waiting_pre_save(void *opaqu= e) struct VirtIONetMigTmp *tmp =3D opaque; =20 tmp->vqs_1 =3D tmp->parent->vqs + 1; - tmp->curr_queues_1 =3D tmp->parent->curr_queues - 1; - if (tmp->parent->curr_queues =3D=3D 0) { - tmp->curr_queues_1 =3D 0; + tmp->curr_qps_1 =3D tmp->parent->curr_qps - 1; + if (tmp->parent->curr_qps =3D=3D 0) { + tmp->curr_qps_1 =3D 0; } =20 return 0; @@ -2964,9 +2964,9 @@ static int virtio_net_tx_waiting_pre_load(void *opaqu= e) /* Reuse the pointer setup from save */ virtio_net_tx_waiting_pre_save(opaque); =20 - if (tmp->parent->curr_queues > tmp->parent->max_queues) { - error_report("virtio-net: curr_queues %x > max_queues %x", - tmp->parent->curr_queues, tmp->parent->max_queues); + if (tmp->parent->curr_qps > tmp->parent->max_qps) { + error_report("virtio-net: curr_qps %x > max_qps %x", + tmp->parent->curr_qps, tmp->parent->max_qps); =20 return -EINVAL; } @@ -2980,7 +2980,7 @@ static const VMStateDescription vmstate_virtio_net_tx= _waiting =3D { .pre_save =3D virtio_net_tx_waiting_pre_save, .fields =3D (VMStateField[]) { VMSTATE_STRUCT_VARRAY_POINTER_UINT16(vqs_1, struct VirtIONetMigTmp, - curr_queues_1, + curr_qps_1, vmstate_virtio_net_queue_tx_waiting, struct VirtIONetQueue), VMSTATE_END_OF_LIST() @@ -3122,9 +3122,9 @@ static const VMStateDescription vmstate_virtio_net_de= vice =3D { VMSTATE_UINT8(nobcast, VirtIONet), VMSTATE_WITH_TMP(VirtIONet, struct VirtIONetMigTmp, vmstate_virtio_net_has_ufo), - VMSTATE_SINGLE_TEST(max_queues, VirtIONet, max_queues_gt_1, 0, + VMSTATE_SINGLE_TEST(max_qps, VirtIONet, max_qps_gt_1, 0, vmstate_info_uint16_equal, uint16_t), - VMSTATE_UINT16_TEST(curr_queues, VirtIONet, max_queues_gt_1), + VMSTATE_UINT16_TEST(curr_qps, VirtIONet, max_qps_gt_1), VMSTATE_WITH_TMP(VirtIONet, struct VirtIONetMigTmp, vmstate_virtio_net_tx_waiting), VMSTATE_UINT64_TEST(curr_guest_offloads, VirtIONet, @@ -3368,16 +3368,16 @@ static void virtio_net_device_realize(DeviceState *= dev, Error **errp) return; } =20 - n->max_queues =3D MAX(n->nic_conf.peers.queues, 1); - if (n->max_queues * 2 + 1 > VIRTIO_QUEUE_MAX) { - error_setg(errp, "Invalid number of queues (=3D %" PRIu32 "), " + n->max_qps =3D MAX(n->nic_conf.peers.queues, 1); + if (n->max_qps * 2 + 1 > VIRTIO_QUEUE_MAX) { + error_setg(errp, "Invalid number of qps (=3D %" PRIu32 "), " "must be a positive integer less than %d.", - n->max_queues, (VIRTIO_QUEUE_MAX - 1) / 2); + n->max_qps, (VIRTIO_QUEUE_MAX - 1) / 2); virtio_cleanup(vdev); return; } - n->vqs =3D g_malloc0(sizeof(VirtIONetQueue) * n->max_queues); - n->curr_queues =3D 1; + n->vqs =3D g_malloc0(sizeof(VirtIONetQueue) * n->max_qps); + n->curr_qps =3D 1; n->tx_timeout =3D n->net_conf.txtimer; =20 if (n->net_conf.tx && strcmp(n->net_conf.tx, "timer") @@ -3391,7 +3391,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) n->net_conf.tx_queue_size =3D MIN(virtio_net_max_tx_queue_size(n), n->net_conf.tx_queue_size); =20 - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_qps; i++) { virtio_net_add_queue(n, i); } =20 @@ -3415,13 +3415,13 @@ static void virtio_net_device_realize(DeviceState *= dev, Error **errp) object_get_typename(OBJECT(dev)), dev->id, n= ); } =20 - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_qps; i++) { n->nic->ncs[i].do_not_pad =3D true; } =20 peer_test_vnet_hdr(n); if (peer_has_vnet_hdr(n)) { - for (i =3D 0; i < n->max_queues; i++) { + for (i =3D 0; i < n->max_qps; i++) { qemu_using_vnet_hdr(qemu_get_subqueue(n->nic, i)->peer, true); } n->host_hdr_len =3D sizeof(struct virtio_net_hdr); @@ -3463,7 +3463,7 @@ static void virtio_net_device_unrealize(DeviceState *= dev) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIONet *n =3D VIRTIO_NET(dev); - int i, max_queues; + int i, max_qps; =20 if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { virtio_net_unload_ebpf(n); @@ -3485,12 +3485,12 @@ static void virtio_net_device_unrealize(DeviceState= *dev) remove_migration_state_change_notifier(&n->migration_state); } =20 - max_queues =3D n->multiqueue ? n->max_queues : 1; - for (i =3D 0; i < max_queues; i++) { + max_qps =3D n->multiqueue ? n->max_qps : 1; + for (i =3D 0; i < max_qps; i++) { virtio_net_del_queue(n, i); } /* delete also control vq */ - virtio_del_queue(vdev, max_queues * 2); + virtio_del_queue(vdev, max_qps * 2); qemu_announce_timer_del(&n->announce_timer, false); g_free(n->vqs); qemu_del_nic(n->nic); diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 824a69c23f..a9b6dc252e 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -194,8 +194,8 @@ struct VirtIONet { NICConf nic_conf; DeviceState *qdev; int multiqueue; - uint16_t max_queues; - uint16_t curr_queues; + uint16_t max_qps; + uint16_t curr_qps; size_t config_size; char *netclient_name; char *netclient_type; --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661395914213.15303005654084; Fri, 3 Sep 2021 02:29:55 -0700 (PDT) Received: from localhost ([::1]:57506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5WE-0001Tm-Q3 for importer@patchew.org; Fri, 03 Sep 2021 05:29:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5FN-0004o7-1x for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5FL-0004AJ-EO for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:28 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-zaBe_zXdMaOZpt57WTo5-w-1; Fri, 03 Sep 2021 05:12:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2809835DE1; Fri, 3 Sep 2021 09:12:22 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id F18BB60BF1; Fri, 3 Sep 2021 09:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660346; 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=3f5INE47KNhTSo1boCb7iesH4337he178Mtn3zDYbBU=; b=Xw8qvcg8nGwPN620CzqL+xlcn5VvDnq+IoLwSmCTPquLBO9Ruhda9TSgbS1AnGQYaEcik8 nYnftc0ZC2yt1Z8O9ds0b7Cct5aDUIRIFdcOQvDSTRAA500dEtaAAz+fLLX3SM1FJ1BUgW bijamRZzDtJiuMgQFEodjj71fJc+Q7U= X-MC-Unique: zaBe_zXdMaOZpt57WTo5-w-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 19/21] vhost: record the last virtqueue index for the virtio device Date: Fri, 3 Sep 2021 17:10:29 +0800 Message-Id: <20210903091031.47303-20-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661396373100001 Content-Type: text/plain; charset="utf-8" This patch introduces a new field in the vhost_dev structure to record the last virtqueue index for the virtio device. This will be useful for the vhost backends with 1:N model to start or stop the device after all the vhost_dev structures were started or stopped. Signed-off-by: Jason Wang --- hw/net/vhost_net.c | 12 +++++++++--- include/hw/virtio/vhost.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index b40fdfa625..a552be7380 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -231,9 +231,11 @@ fail: return NULL; } =20 -static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index) +static void vhost_net_set_vq_index(struct vhost_net *net, int vq_index, + int last_index) { net->dev.vq_index =3D vq_index; + net->dev.last_index =3D last_index; } =20 static int vhost_net_start_one(struct vhost_net *net, @@ -324,9 +326,13 @@ int vhost_net_start(VirtIODevice *dev, NetClientState = *ncs, VirtIONet *n =3D VIRTIO_NET(dev); int nvhosts =3D data_qps + cvq; struct vhost_net *net; - int r, e, i; + int r, e, i, last_index =3D data_qps * 2; NetClientState *peer; =20 + if (!cvq) { + last_index -=3D 1; + } + if (!k->set_guest_notifiers) { error_report("binding does not support guest notifiers"); return -ENOSYS; @@ -341,7 +347,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *= ncs, } =20 net =3D get_vhost_net(peer); - vhost_net_set_vq_index(net, i * 2); + vhost_net_set_vq_index(net, i * 2, last_index); =20 /* Suppress the masking guest notifiers on vhost user * because vhost user doesn't interrupt masking/unmasking diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 1222b21b94..6684bde33d 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -74,6 +74,8 @@ struct vhost_dev { unsigned int nvqs; /* the first virtqueue which would be used by this vhost dev */ int vq_index; + /* the last vq index for the virtio device (not vhost) */ + int last_index; /* if non-zero, minimum required value for max_queues */ int num_queues; uint64_t features; --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630661968385602.0660862971429; Fri, 3 Sep 2021 02:39:28 -0700 (PDT) Received: from localhost ([::1]:55406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5fM-0002vS-Cs for importer@patchew.org; Fri, 03 Sep 2021 05:39:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5FR-0004w0-4Z for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23323) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5FO-0004CJ-58 for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:32 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-ibz4Gfx6PsqHpDjkwxQdkA-1; Fri, 03 Sep 2021 05:12:28 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 921461854E20; Fri, 3 Sep 2021 09:12:26 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91AB860BF1; Fri, 3 Sep 2021 09:12:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660349; 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=HcrbamXvwR0Mw6piP+Isi2B6dsNimlUTkmbQnwSM68M=; b=WSrBh6hAMwFkKiyMQUhuPR23jqtXP1r126thq2l7/ZfiVAfQUx2ZpnK7MEpsX5Tll7uL9A 2NubdOxUrpcw5J2Ve8rddTvNPl/6/tkui4Gl3n/9Tu143z1quA58MJD0OBFZuS7Uii5OjN LKMeyXYcQA3bjdVRLnbIw8xtiKmRMuQ= X-MC-Unique: ibz4Gfx6PsqHpDjkwxQdkA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 20/21] virtio-net: vhost control virtqueue support Date: Fri, 3 Sep 2021 17:10:30 +0800 Message-Id: <20210903091031.47303-21-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630661971447100001 Content-Type: text/plain; charset="utf-8" This patch implements the control virtqueue support for vhost. This requires virtio-net to figure out the datapath queue pairs and control virtqueue via is_datapath and pass the number of those two types of virtqueues to vhost_net_start()/vhost_net_stop(). Signed-off-by: Jason Wang --- hw/net/virtio-net.c | 21 ++++++++++++++++++--- include/hw/virtio/virtio-net.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 0a5d9862ec..2523157177 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -244,6 +244,7 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8= _t status) VirtIODevice *vdev =3D VIRTIO_DEVICE(n); NetClientState *nc =3D qemu_get_queue(n->nic); int qps =3D n->multiqueue ? n->max_qps : 1; + int cvq =3D n->max_ncs - n->max_qps; =20 if (!get_vhost_net(nc->peer)) { return; @@ -285,14 +286,14 @@ static void virtio_net_vhost_status(VirtIONet *n, uin= t8_t status) } =20 n->vhost_started =3D 1; - r =3D vhost_net_start(vdev, n->nic->ncs, qps, 0); + r =3D vhost_net_start(vdev, n->nic->ncs, qps, cvq); if (r < 0) { error_report("unable to start vhost net: %d: " "falling back on userspace virtio", -r); n->vhost_started =3D 0; } } else { - vhost_net_stop(vdev, n->nic->ncs, qps, 0); + vhost_net_stop(vdev, n->nic->ncs, qps, cvq); n->vhost_started =3D 0; } } @@ -3368,7 +3369,21 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) return; } =20 - n->max_qps =3D MAX(n->nic_conf.peers.queues, 1); + n->max_ncs =3D MAX(n->nic_conf.peers.queues, 1); + + /* + * Figure out the datapath queue pairs since the backend could + * provide control queue via peers as well. + */ + if (n->nic_conf.peers.queues) { + for (i =3D 0; i < n->max_ncs; i++) { + if (n->nic_conf.peers.ncs[i]->is_datapath) { + ++n->max_qps; + } + } + } + n->max_qps =3D MAX(n->max_qps, 1); + if (n->max_qps * 2 + 1 > VIRTIO_QUEUE_MAX) { error_setg(errp, "Invalid number of qps (=3D %" PRIu32 "), " "must be a positive integer less than %d.", diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index a9b6dc252e..ed4659c189 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -194,6 +194,7 @@ struct VirtIONet { NICConf nic_conf; DeviceState *qdev; int multiqueue; + uint16_t max_ncs; uint16_t max_qps; uint16_t curr_qps; size_t config_size; --=20 2.25.1 From nobody Fri May 3 15:15:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630662080517360.83045799138176; Fri, 3 Sep 2021 02:41:20 -0700 (PDT) Received: from localhost ([::1]:59762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5hH-0005yb-F7 for importer@patchew.org; Fri, 03 Sep 2021 05:41:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5FT-0004xy-3j for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM5FQ-0004Ej-Ss for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:12:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-P39wepSVO5qS09zx_I2vqA-1; Fri, 03 Sep 2021 05:12:31 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EDB48835DE2; Fri, 3 Sep 2021 09:12:29 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-217.pek2.redhat.com [10.72.13.217]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2404F60E3A; Fri, 3 Sep 2021 09:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630660352; 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=4VQGWu4X7PHLx6gdBaS1Zs0+3I9XrQO8UgGJuvSkFI4=; b=h3pKDtYifCplvE+OlxNLxs3krRhUS9a4MI4ZmkN171wd6SQElsQ1ktU/JHBuYDkAWFT4nL Hbsp3nap9LHz92q8+Vt8E6JFC9evJXzquTgdIoIpvOhDTl0Z7o9oi4J7rtEYZcW4I0kAc/ DnXJyDdn3EmkU0thBSIueHvL2h9X/2E= X-MC-Unique: P39wepSVO5qS09zx_I2vqA-1 From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org Subject: [PATCH V2 21/21] vhost-vdpa: multiqueue support Date: Fri, 3 Sep 2021 17:10:31 +0800 Message-Id: <20210903091031.47303-22-jasowang@redhat.com> In-Reply-To: <20210903091031.47303-1-jasowang@redhat.com> References: <20210903091031.47303-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eperezma@redhat.com, elic@nvidia.com, gdawar@xilinx.com, lingshan.zhu@intel.com, lulu@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630662082523100001 Content-Type: text/plain; charset="utf-8" This patch implements the multiqueue support for vhost-vdpa. This is done simply by reading the number of queue pairs from the config space and initialize the datapath and control path net client. Signed-off-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 2 +- net/vhost-vdpa.c | 104 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 96 insertions(+), 10 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 94eb9d4069..b5df7594ff 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -578,7 +578,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev, = bool started) vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); } =20 - if (vhost_vdpa_one_time_request(dev)) { + if (dev->vq_index + dev->nvqs !=3D dev->last_index) { return 0; } =20 diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 834dab28dd..63cb83d6f4 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -18,6 +18,7 @@ #include "qemu/error-report.h" #include "qemu/option.h" #include "qapi/error.h" +#include #include #include #include "standard-headers/linux/virtio_net.h" @@ -51,6 +52,14 @@ const int vdpa_feature_bits[] =3D { VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_MTU, + VIRTIO_NET_F_CTRL_RX, + VIRTIO_NET_F_CTRL_RX_EXTRA, + VIRTIO_NET_F_CTRL_VLAN, + VIRTIO_NET_F_GUEST_ANNOUNCE, + VIRTIO_NET_F_CTRL_MAC_ADDR, + VIRTIO_NET_F_RSS, + VIRTIO_NET_F_MQ, + VIRTIO_NET_F_CTRL_VQ, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, VIRTIO_NET_F_RSS, @@ -81,7 +90,8 @@ static int vhost_vdpa_net_check_device_id(struct vhost_ne= t *net) return ret; } =20 -static int vhost_vdpa_add(NetClientState *ncs, void *be) +static int vhost_vdpa_add(NetClientState *ncs, void *be, int qp_index, + int nvqs) { VhostNetOptions options; struct vhost_net *net =3D NULL; @@ -94,7 +104,7 @@ static int vhost_vdpa_add(NetClientState *ncs, void *be) options.net_backend =3D ncs; options.opaque =3D be; options.busyloop_timeout =3D 0; - options.nvqs =3D 2; + options.nvqs =3D nvqs; =20 net =3D vhost_net_init(&options); if (!net) { @@ -158,18 +168,28 @@ static NetClientInfo net_vhost_vdpa_info =3D { static NetClientState *net_vhost_vdpa_init(NetClientState *peer, const char *device, const char *name, - int vdpa_device_fd) + int vdpa_device_fd, + int qp_index, + int nvqs, + bool is_datapath) { NetClientState *nc =3D NULL; VhostVDPAState *s; int ret =3D 0; assert(name); - nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); + if (is_datapath) { + nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, + name); + } else { + nc =3D qemu_new_net_control_client(&net_vhost_vdpa_info, peer, + device, name); + } snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA); s =3D DO_UPCAST(VhostVDPAState, nc, nc); =20 s->vhost_vdpa.device_fd =3D vdpa_device_fd; - ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa); + s->vhost_vdpa.index =3D qp_index; + ret =3D vhost_vdpa_add(nc, (void *)&s->vhost_vdpa, qp_index, nvqs); if (ret) { qemu_del_net_client(nc); return NULL; @@ -195,12 +215,52 @@ static int net_vhost_check_net(void *opaque, QemuOpts= *opts, Error **errp) return 0; } =20 +static int vhost_vdpa_get_max_qps(int fd, int *has_cvq, Error **errp) +{ + unsigned long config_size =3D offsetof(struct vhost_vdpa_config, buf); + struct vhost_vdpa_config *config; + __virtio16 *max_qps; + uint64_t features; + int ret; + + ret =3D ioctl(fd, VHOST_GET_FEATURES, &features); + if (ret) { + error_setg(errp, "Fail to query features from vhost-vDPA device"); + return ret; + } + + if (features & (1 << VIRTIO_NET_F_CTRL_VQ)) { + *has_cvq =3D 1; + } else { + *has_cvq =3D 0; + } + + if (features & (1 << VIRTIO_NET_F_MQ)) { + config =3D g_malloc0(config_size + sizeof(*max_qps)); + config->off =3D offsetof(struct virtio_net_config, max_virtqueue_p= airs); + config->len =3D sizeof(*max_qps); + + ret =3D ioctl(fd, VHOST_VDPA_GET_CONFIG, config); + if (ret) { + error_setg(errp, "Fail to get config from vhost-vDPA device"); + return -ret; + } + + max_qps =3D (__virtio16 *)&config->buf; + + return lduw_le_p(max_qps); + } + + return 1; +} + int net_init_vhost_vdpa(const Netdev *netdev, const char *name, NetClientState *peer, Error **errp) { const NetdevVhostVDPAOptions *opts; int vdpa_device_fd; - NetClientState *nc; + NetClientState **ncs, *nc; + int qps, i, has_cvq =3D 0; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -215,11 +275,37 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, return -errno; } =20 - nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd= ); - if (!nc) { + qps =3D vhost_vdpa_get_max_qps(vdpa_device_fd, &has_cvq, errp); + if (qps < 0) { qemu_close(vdpa_device_fd); - return -1; + return qps; + } + + ncs =3D g_malloc0(sizeof(*ncs) * qps); + + for (i =3D 0; i < qps; i++) { + ncs[i] =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, + vdpa_device_fd, i, 2, true); + if (!ncs[i]) + goto err; + } + + if (has_cvq) { + nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, + vdpa_device_fd, i, 1, false); + if (!nc) + goto err; } =20 + g_free(ncs); return 0; + +err: + if (i) { + qemu_del_net_client(ncs[0]); + } + qemu_close(vdpa_device_fd); + g_free(ncs); + + return -1; } --=20 2.25.1