From nobody Sat May 18 04:46:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666970462; cv=none; d=zohomail.com; s=zohoarc; b=hMR12OrXeHMZC48hBzUCI5q2UttnKHeQnrHSiwA2FXiFNqTvVb1j51WLYJcgumFTa9WeSAKiEpefXGI7pW0IzdWDqlv4Z4zib6jt8Dd3eRBUxnJG5v1pNt4e788x2RQ1L6XS4GW0nVhGCqCf1V6nLpKPEBRLJLpspWc/XWKMyMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666970462; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pJWfwax7YNhnZW1GKWA5XmDSDsYcoKbWEEwQ6CZiLUA=; b=lC0cEzXTjRvvqnxt+jQLwXxnztKOPFHhJ0CABMGZYxHJsJ34FCli2pABizgtC32uX4Jc0u7Lr54gl8HNed3YQQkC/Cf0+raaN/f46Cl/68IEXEqYBZkzkYvAHxk9y81x4XRyPJrGVVl02xvWSIsbuPHZHhxnKGinS9uZ2UKfG7Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666970462543834.5782078735788; Fri, 28 Oct 2022 08:21:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooR8u-0003l6-JX; Fri, 28 Oct 2022 11:19:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooR8t-0003kr-82 for qemu-devel@nongnu.org; Fri, 28 Oct 2022 11:19:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooR8r-0003r4-Fg for qemu-devel@nongnu.org; Fri, 28 Oct 2022 11:19:30 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-62-vsUYLMDDMxKIg5qZXHMn5g-1; Fri, 28 Oct 2022 11:19:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E935C3C1023F; Fri, 28 Oct 2022 15:19:25 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id B87D52024CBF; Fri, 28 Oct 2022 15:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666970368; 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=pJWfwax7YNhnZW1GKWA5XmDSDsYcoKbWEEwQ6CZiLUA=; b=cxumqir69detqu4YaXJXaNHpFlnM/Vz8Ij9NYHGkOwzLB+OJXrZo0VLEjxwjjHuCaDvriM FGXPnQ7MjdtGfLdla+cdoDsgqQFiI16OQc5YJmRaeBAygMbYfQ6jXto88XaMDJdF8LP+4X xdytlC37ro9Baopk+Or90XfqHEEKrRI= X-MC-Unique: vsUYLMDDMxKIg5qZXHMn5g-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , Zhu Lingshan , Stefano Garzarella , Gautam Dawar , Eli Cohen , Parav Pandit , Jason Wang , Si-Wei Liu , "Michael S. Tsirkin" , Liuxiangdong , Laurent Vivier Subject: [PATCH v2 1/3] virtio_net: Modify virtio_net_get_config to early return Date: Fri, 28 Oct 2022 17:19:15 +0200 Message-Id: <20221028151917.260038-2-eperezma@redhat.com> In-Reply-To: <20221028151917.260038-1-eperezma@redhat.com> References: <20221028151917.260038-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.516, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666970463355100001 Next patches introduce more code on vhost-vdpa branch, with already have too much indentation. Signed-off-by: Eugenio P=C3=A9rez Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index e9f696b4cf..56ff219196 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -158,20 +158,22 @@ static void virtio_net_get_config(VirtIODevice *vdev,= uint8_t *config) if (nc->peer && nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VD= PA) { ret =3D vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&= netcfg, n->config_size); - if (ret !=3D -1) { - /* - * Some NIC/kernel combinations present 0 as the mac address. = As - * that is not a legal address, try to proceed with the - * address from the QEMU command line in the hope that the - * address has been configured correctly elsewhere - just not - * reported by the device. - */ - if (memcmp(&netcfg.mac, &zero, sizeof(zero)) =3D=3D 0) { - info_report("Zero hardware mac address detected. Ignoring.= "); - memcpy(netcfg.mac, n->mac, ETH_ALEN); - } - memcpy(config, &netcfg, n->config_size); + if (ret =3D=3D -1) { + return; } + + /* + * Some NIC/kernel combinations present 0 as the mac address. As = that + * is not a legal address, try to proceed with the address from the + * QEMU command line in the hope that the address has been configu= red + * correctly elsewhere - just not reported by the device. + */ + if (memcmp(&netcfg.mac, &zero, sizeof(zero)) =3D=3D 0) { + info_report("Zero hardware mac address detected. Ignoring."); + memcpy(netcfg.mac, n->mac, ETH_ALEN); + } + + memcpy(config, &netcfg, n->config_size); } } =20 --=20 2.31.1 From nobody Sat May 18 04:46:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666970444; cv=none; d=zohomail.com; s=zohoarc; b=jBDKOWsweTX3nh/aAOEvz1InnHmSLrIyvB/N3WCmEvcA9ObGCXsikovdnkCyfsr3afqHPQWX/AyUXIpXobDXkHVqdZMTVEh+uf/tRAenApzoXbtrpSFNd42hbxXxZxFo8DK/lp8L0nCxm3kXWdXLmzE+stNjvzh47Ua21doyy7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666970444; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=x3c0NH+cwMHbx78oOj/9GAlwf5kvmomFCCYkkshSQzk=; b=XVXfoCHWnLjeFSR3fBxN5mBUmh2eBYJWUynx2Yy3QSUNpSOsDQgm7i6jPy/Xw0yP+VHS2CpR5FmOxblk3wPuXjo2oSqF3wTxVZyqR2iplb0McMHBVURAcIWfxey8Ds7k4yjLJIqAsF/2o7C78wgv+15Hmwyh6AqYfq4WCGte6uc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666970444162271.232348972183; Fri, 28 Oct 2022 08:20:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooR8y-0003m7-Ph; Fri, 28 Oct 2022 11:19:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooR8w-0003le-V2 for qemu-devel@nongnu.org; Fri, 28 Oct 2022 11:19:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooR8v-0003tk-Fj for qemu-devel@nongnu.org; Fri, 28 Oct 2022 11:19:34 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-402-l5PhqeLoOIO1q2c9nRT_4w-1; Fri, 28 Oct 2022 11:19:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 91B2438145A3; Fri, 28 Oct 2022 15:19:28 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A06220290A5; Fri, 28 Oct 2022 15:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666970373; 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=x3c0NH+cwMHbx78oOj/9GAlwf5kvmomFCCYkkshSQzk=; b=XCI8t0mBL6pWAltKZ9jNX3ymaCDyZpybJCL9jWilB49Fq5t1WAZjrChsherzyB79cygvRR EvNcT46PFvhDmzK62EVJ2LyUx099rwybB4zWssBUSB2IfkAjGZA0NVjQrBN/gG/Zp8a8NM PFV8sE6cWa8SA/yVUh/ouLjgGIhIH18= X-MC-Unique: l5PhqeLoOIO1q2c9nRT_4w-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , Zhu Lingshan , Stefano Garzarella , Gautam Dawar , Eli Cohen , Parav Pandit , Jason Wang , Si-Wei Liu , "Michael S. Tsirkin" , Liuxiangdong , Laurent Vivier Subject: [PATCH v2 2/3] virtio_net: Handle _F_STATUS emulation in virtio_net_get_config Date: Fri, 28 Oct 2022 17:19:16 +0200 Message-Id: <20221028151917.260038-3-eperezma@redhat.com> In-Reply-To: <20221028151917.260038-1-eperezma@redhat.com> References: <20221028151917.260038-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.516, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666970445437100003 At this moment this code path is not reached, but vdpa devices can offer VIRTIO_NET_F_STATUS unconditionally. While the guest must assume that link is always up by the standard, qemu will set the status bit to 1 always in this case. This makes little use by itself, but VIRTIO_NET_F_STATUS is needed for the guest to read status bit VIRTIO_NET_F_GUEST_ANNOUNCE, used by feature VIRTIO_NET_F_GUEST_ANNOUNCE. So qemu must emulate status feature in case it needs to emulate the guest announce feature. Signed-off-by: Eugenio P=C3=A9rez Reviewed-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 56ff219196..6d4d75615b 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -156,8 +156,9 @@ static void virtio_net_get_config(VirtIODevice *vdev, u= int8_t *config) * disconnect/reconnect a VDPA peer. */ if (nc->peer && nc->peer->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VD= PA) { - ret =3D vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&= netcfg, - n->config_size); + struct vhost_net *net =3D get_vhost_net(nc->peer); + + ret =3D vhost_net_get_config(net, (uint8_t *)&netcfg, n->config_si= ze); if (ret =3D=3D -1) { return; } @@ -173,6 +174,12 @@ static void virtio_net_get_config(VirtIODevice *vdev, = uint8_t *config) memcpy(netcfg.mac, n->mac, ETH_ALEN); } =20 + if (vdev->guest_features & BIT_ULL(VIRTIO_NET_F_STATUS) && + !(net->dev.features & BIT_ULL(VIRTIO_NET_F_STATUS))) { + /* Emulating link up in qemu */ + netcfg.status |=3D virtio_tswap16(vdev, VIRTIO_NET_S_LINK_UP); + } + memcpy(config, &netcfg, n->config_size); } } --=20 2.31.1 From nobody Sat May 18 04:46:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666970449; cv=none; d=zohomail.com; s=zohoarc; b=hMRSGBIt296DeVUhEfKLDYsdipBiqEIvDxF0/2xo25zViY+OBB+01G+1GXnCE+2A7FVXZQy1h12o8wnm4X8MAHu0yTPVjSUQnK5WpatOjGvuQ2njfV+pc8ftlktyUN/OzWEiJ5fXRuscWgJkvNuRgibjo/ctVY7zv5gvWpopumY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666970449; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8XFpQgy7hEPyzc0f/MlRMqPAoore8UmDwJSQHnHIKBk=; b=ZbeUEngXmzgCGhuqwAR2aUvK1C2uxGSO8zjjJhTf9eHWrTsni8mXLK2ZbVtETD3EkogipINYJ6l+TndvK2Xdjke+sdpLLrBl+ZCZlgm0OCneYHVFTfYjunvhWjTREG6IZeb/BLcgrFfetVpI3lkACpPDWg839Ad5dHowKCPRiwE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166697044940251.80843067033538; Fri, 28 Oct 2022 08:20:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooR90-0003mU-DN; Fri, 28 Oct 2022 11:19:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooR8z-0003mM-HP for qemu-devel@nongnu.org; Fri, 28 Oct 2022 11:19:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooR8y-0003uL-77 for qemu-devel@nongnu.org; Fri, 28 Oct 2022 11:19:37 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-451-Qh_pUAB5PQy2_G7nDPWSWw-1; Fri, 28 Oct 2022 11:19:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1128638145A0; Fri, 28 Oct 2022 15:19:31 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id D59622022EA2; Fri, 28 Oct 2022 15:19:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666970375; 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=8XFpQgy7hEPyzc0f/MlRMqPAoore8UmDwJSQHnHIKBk=; b=ZgPCStDpqxchEbhFiYSko/rh2ktvI7J9LmHwKztDYqb4ZFd7Q6o3V4LyZ9knNcFOx6xmjG GpZypZBxHbDEITG4cpwwrNDkZpAZ11yqvPuiOgdbDOjVDLCR4Jo8NunLiXvWejDQks4FLz LMGN513qnryZMWuhTXwBc5HdaQQ2Z7Y= X-MC-Unique: Qh_pUAB5PQy2_G7nDPWSWw-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Harpreet Singh Anand , Zhu Lingshan , Stefano Garzarella , Gautam Dawar , Eli Cohen , Parav Pandit , Jason Wang , Si-Wei Liu , "Michael S. Tsirkin" , Liuxiangdong , Laurent Vivier Subject: [PATCH v2 3/3] vhost_vdpa: move VIRTIO_NET_F_STATUS handling to vhost_net Date: Fri, 28 Oct 2022 17:19:17 +0200 Message-Id: <20221028151917.260038-4-eperezma@redhat.com> In-Reply-To: <20221028151917.260038-1-eperezma@redhat.com> References: <20221028151917.260038-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.516, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666970451619100003 Since it is emulated on all vhost backends it makes sense to move it. Although this feature can be emulated by qemu it benefits from information from the device. Ack it as long as the guest ack it. Signed-off-by: Eugenio P=C3=A9rez Reviewed-by: Michael S. Tsirkin --- hw/net/vhost_net.c | 13 +++++++++++++ net/vhost-vdpa.c | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index d28f8b974b..b533744211 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -127,8 +127,21 @@ int vhost_net_set_config(struct vhost_net *net, const = uint8_t *data, =20 void vhost_net_ack_features(struct vhost_net *net, uint64_t features) { + static const int status_feature_bit[] =3D { + VIRTIO_NET_F_STATUS, + VHOST_INVALID_FEATURE_BIT, + }; + net->dev.acked_features =3D net->dev.backend_features; vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), feature= s); + if (net->dev.features & BIT_ULL(VIRTIO_NET_F_STATUS)) { + /* + * If device support _F_STATUS qemu should ack it so it reports li= nk + * status changes. If not supported qemu emulates it reporting an + * always up link. + */ + vhost_ack_features(&net->dev, status_feature_bit, features); + } } =20 uint64_t vhost_net_get_max_queues(VHostNetState *net) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 6d64000202..854b27186c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -72,7 +72,6 @@ const int vdpa_feature_bits[] =3D { VIRTIO_NET_F_RSS, VIRTIO_NET_F_HASH_REPORT, VIRTIO_NET_F_GUEST_ANNOUNCE, - VIRTIO_NET_F_STATUS, VHOST_INVALID_FEATURE_BIT }; =20 --=20 2.31.1