From patchwork Wed Oct 19 12:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13011718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4619C433FE for ; Wed, 19 Oct 2022 13:04:19 +0000 (UTC) Received: from localhost ([::1]:40162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol8k6-00033X-O0 for qemu-devel@archiver.kernel.org; Wed, 19 Oct 2022 09:04:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yj-00069W-UH for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yh-0002H9-4j for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666183950; 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=HQqvvXt2mnDRPwk4MtdkOd7P1aVjVbus7fcouF/Xkqk=; b=PUfhklVD88cJrWUFiKhKVUJbG+os4b63jnzv6bwZ6Y10o38/puBi3WtVOpVjVqP0Glqpyi ZEIKYT/OzQlKSxGZYrYS85lXxM1iUfPXJ4BwleMB4GLt8OWXUMAO/5gqEvJdmHlu90Fx1+ Pbn95bZx40pFUFk2XN4gfs9MFvrIDqo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-343-lK_47yIgOyeIbFsMlW1N5A-1; Wed, 19 Oct 2022 08:52:21 -0400 X-MC-Unique: lK_47yIgOyeIbFsMlW1N5A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 81C9385A59D; Wed, 19 Oct 2022 12:52:20 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2936D4081B60; Wed, 19 Oct 2022 12:52:18 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Zhu Lingshan , Harpreet Singh Anand , Stefano Garzarella , Si-Wei Liu , Jason Wang , "Michael S. Tsirkin" , Cindy Lu , Laurent Vivier , Eli Cohen , Liuxiangdong , Parav Pandit , Gautam Dawar Subject: [RFC PATCH v2 1/8] vdpa: Delete duplicated vdpa_feature_bits entry Date: Wed, 19 Oct 2022 14:52:03 +0200 Message-Id: <20221019125210.226291-2-eperezma@redhat.com> In-Reply-To: <20221019125210.226291-1-eperezma@redhat.com> References: <20221019125210.226291-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.256, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This entry was duplicated on referenced commit. Removing it. Fixes: 402378407dbd ("vhost-vdpa: multiqueue support") Signed-off-by: Eugenio Pérez Acked-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 4bc3fd01a8..eebf29f5c1 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -63,7 +63,6 @@ const int vdpa_feature_bits[] = { 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, From patchwork Wed Oct 19 12:52:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13011757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DA86C433FE for ; Wed, 19 Oct 2022 13:29:04 +0000 (UTC) Received: from localhost ([::1]:60800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol981-0004as-TG for qemu-devel@archiver.kernel.org; Wed, 19 Oct 2022 09:29:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yh-00060M-JC for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Ye-0002Gr-QQ for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666183948; 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=ab7dW9paGVspfEgQ6PmFdF3QH0gPQPtXGHDenD+bubo=; b=hWBRai7ou2ATqrk7RfF8lDDVehQgzqyxM+9q7DqBxDLMZsYh+HXPmqy/VqMRpUxtDLs8oq ZXImmlODW0838pZnTdXod9120/i1t4oBA82mjoqg+8gGwfUBvPsHm/lQMwCphwUMjxGgiC 8eDqJjTqac5L1uyuK7Jf4BeKmgGMqWg= 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-187-WuMrbfaCN9ihBMX2NbPr0A-1; Wed, 19 Oct 2022 08:52:23 -0400 X-MC-Unique: WuMrbfaCN9ihBMX2NbPr0A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2DA192932480; Wed, 19 Oct 2022 12:52:23 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCFFC4081B60; Wed, 19 Oct 2022 12:52:20 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Zhu Lingshan , Harpreet Singh Anand , Stefano Garzarella , Si-Wei Liu , Jason Wang , "Michael S. Tsirkin" , Cindy Lu , Laurent Vivier , Eli Cohen , Liuxiangdong , Parav Pandit , Gautam Dawar Subject: [RFC PATCH v2 2/8] vdpa: Save emulated features list in vhost_vdpa Date: Wed, 19 Oct 2022 14:52:04 +0200 Message-Id: <20221019125210.226291-3-eperezma@redhat.com> In-Reply-To: <20221019125210.226291-1-eperezma@redhat.com> References: <20221019125210.226291-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.256, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" At this moment only _F_LOG is added there. However future patches add features that depend on the kind of device. In particular, only net devices can add VIRTIO_F_GUEST_ANNOUNCE. So let's allow vhost_vdpa creator to set custom emulated device features. Signed-off-by: Eugenio Pérez --- include/hw/virtio/vhost-vdpa.h | 2 ++ hw/virtio/vhost-vdpa.c | 8 ++++---- net/vhost-vdpa.c | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 1111d85643..50083e1e3b 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -31,6 +31,8 @@ typedef struct vhost_vdpa { bool iotlb_batch_begin_sent; MemoryListener listener; struct vhost_vdpa_iova_range iova_range; + /* VirtIO device features that can be emulated by qemu */ + uint64_t added_features; uint64_t acked_features; bool shadow_vqs_enabled; /* IOVA mapping used by the Shadow Virtqueue */ diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 7468e44b87..ddb5e29288 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -660,8 +660,8 @@ static int vhost_vdpa_set_features(struct vhost_dev *dev, v->acked_features = features; - /* We must not ack _F_LOG if SVQ is enabled */ - features &= ~BIT_ULL(VHOST_F_LOG_ALL); + /* Do not ack features emulated by qemu */ + features &= ~v->added_features; } trace_vhost_vdpa_set_features(dev, features); @@ -1244,8 +1244,8 @@ static int vhost_vdpa_get_features(struct vhost_dev *dev, int ret = vhost_vdpa_get_dev_features(dev, features); if (ret == 0 && v->shadow_vqs_enabled) { - /* Add SVQ logging capabilities */ - *features |= BIT_ULL(VHOST_F_LOG_ALL); + /* Add emulated capabilities */ + *features |= v->added_features; } return ret; diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index eebf29f5c1..3803452800 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -599,6 +599,10 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer, s->vhost_vdpa.index = queue_pair_index; s->vhost_vdpa.shadow_vqs_enabled = svq; s->vhost_vdpa.iova_tree = iova_tree; + if (svq) { + /* Add SVQ logging capabilities */ + s->vhost_vdpa.added_features |= BIT_ULL(VHOST_F_LOG_ALL); + } if (!is_datapath) { s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(), vhost_vdpa_net_cvq_cmd_page_len()); From patchwork Wed Oct 19 12:52:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13011712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 80FC9C4332F for ; Wed, 19 Oct 2022 13:03:23 +0000 (UTC) Received: from localhost ([::1]:36148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol8jC-0002S7-7f for qemu-devel@archiver.kernel.org; Wed, 19 Oct 2022 09:03:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yj-00068g-NU for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yg-0002H5-Ra for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666183950; 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=7QrYOKz2aeFipRQ6UbtRS6WhcLuSCDEKhE969yrivaY=; b=fdM4DFAa/Rq2nqHiIWX0clPYX1yeip6lwH1ZRjjvNDQ9AkLIkQiNbxemk2Rv7kGwtab9WY krHRE1cAuYMqMQ0VSxufd8000Lbp42HnAK/YDqCybuWerZI/0x2ydR4FPekOys9WnUChi6 GnNTlBiUad51C8MuAipNSHXJ41zSS6w= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-194-uyE7YLjFOsqusc_46M0cXg-1; Wed, 19 Oct 2022 08:52:26 -0400 X-MC-Unique: uyE7YLjFOsqusc_46M0cXg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C4CC8185A7AD; Wed, 19 Oct 2022 12:52:25 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 757714081B60; Wed, 19 Oct 2022 12:52:23 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Zhu Lingshan , Harpreet Singh Anand , Stefano Garzarella , Si-Wei Liu , Jason Wang , "Michael S. Tsirkin" , Cindy Lu , Laurent Vivier , Eli Cohen , Liuxiangdong , Parav Pandit , Gautam Dawar Subject: [RFC PATCH v2 3/8] vhost_net: Emulate link state up if backend doesn't expose it Date: Wed, 19 Oct 2022 14:52:05 +0200 Message-Id: <20221019125210.226291-4-eperezma@redhat.com> In-Reply-To: <20221019125210.226291-1-eperezma@redhat.com> References: <20221019125210.226291-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.256, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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érez --- hw/net/vhost_net.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index d28f8b974b..5660606c1d 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -117,7 +117,32 @@ uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) int vhost_net_get_config(struct vhost_net *net, uint8_t *config, uint32_t config_len) { - return vhost_dev_get_config(&net->dev, config, config_len, NULL); + VirtIODevice *vdev; + int r = vhost_dev_get_config(&net->dev, config, config_len, NULL); + + if (unlikely(r != 0)) { + return r; + } + + if (config_len < endof(struct virtio_net_config, status)) { + return 0; + } + + /* + * TODO: Perform this only if vhost_vdpa. + */ + vdev = net->dev.vdev; + if (!vdev) { + /* Device is starting */ + return 0; + } + + if ((net->dev.acked_features & BIT_ULL(VIRTIO_NET_F_STATUS)) && + !(net->dev.features & BIT_ULL(VIRTIO_NET_F_STATUS))) { + ((struct virtio_net_config *)config)->status |= VIRTIO_NET_S_LINK_UP; + } + + return 0; } int vhost_net_set_config(struct vhost_net *net, const uint8_t *data, uint32_t offset, uint32_t size, uint32_t flags) From patchwork Wed Oct 19 12:52:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13011713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E525FC433FE for ; Wed, 19 Oct 2022 13:03:27 +0000 (UTC) Received: from localhost ([::1]:36154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol8jG-0002TT-Ov for qemu-devel@archiver.kernel.org; Wed, 19 Oct 2022 09:03:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Z1-0006WF-Oe for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38023) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Ym-0002Hf-DS for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666183954; 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=SoTz4WrSj/6TG264UMdH3uDpSJqGlI8R2/aF+QLXIAc=; b=jLdjtrxGSaQK2XsjCmN58zByY4+hHJYHNd/y3uIlH4BwUozBsiP+aubsYE9txmeKcqFNaz 1Jg4Kj/KWyzSBByQU0yudoTvnAKxZWElBAEuuTF92P0NRi5ay4XM5SypYf3Ds4RPWl2M1s qFbS9ymOq7YuGTV1fcSJhVXzTzOncZo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-0lIn7BriPhCe4vF0G8BOxQ-1; Wed, 19 Oct 2022 08:52:28 -0400 X-MC-Unique: 0lIn7BriPhCe4vF0G8BOxQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B822857FB0; Wed, 19 Oct 2022 12:52:28 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16E664081B60; Wed, 19 Oct 2022 12:52:25 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Zhu Lingshan , Harpreet Singh Anand , Stefano Garzarella , Si-Wei Liu , Jason Wang , "Michael S. Tsirkin" , Cindy Lu , Laurent Vivier , Eli Cohen , Liuxiangdong , Parav Pandit , Gautam Dawar Subject: [RFC PATCH v2 4/8] vdpa: Expose VIRTIO_NET_F_STATUS unconditionally Date: Wed, 19 Oct 2022 14:52:06 +0200 Message-Id: <20221019125210.226291-5-eperezma@redhat.com> In-Reply-To: <20221019125210.226291-1-eperezma@redhat.com> References: <20221019125210.226291-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Now that qemu can handle and emulate it if the vdpa backend does not support it we can offer it always. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 3803452800..fca21d5b79 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -602,6 +602,9 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer, if (svq) { /* Add SVQ logging capabilities */ s->vhost_vdpa.added_features |= BIT_ULL(VHOST_F_LOG_ALL); + + /* VIRTIO_NET_F_STATUS is mandatory for _F_GUEST_ANNOUNCE. */ + s->vhost_vdpa.added_features |= BIT_ULL(VIRTIO_NET_F_STATUS); } if (!is_datapath) { s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(), From patchwork Wed Oct 19 12:52:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13011739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0007CC4332F for ; Wed, 19 Oct 2022 13:17:39 +0000 (UTC) Received: from localhost ([::1]:44148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol8x0-0007gy-LZ for qemu-devel@archiver.kernel.org; Wed, 19 Oct 2022 09:17:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yp-0006LQ-3s for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28618) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yn-0002Hl-F6 for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666183955; 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=WUoMSiMZQmcCwuUwdcYUEB/TvyEqvIQErNRynamLkig=; b=B46f6UCLJCOWyBL5wp8q5kqFgneQGbIoLjTiqqT4U4KMdzqVrYE+03HiSltG6T6UPPSHAY NAKICwl+/IOUPmKYrVdpwG5/2NQbR7HAO3LdtBe/kDPRbRWU60wxp2l8aEWy3S2Gj7l19h jRIfOEv4WHwZKDa3MbjU0ysE0m6eJuM= 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-222-n5Tms6KzObyeMKtJsu4qHg-1; Wed, 19 Oct 2022 08:52:31 -0400 X-MC-Unique: n5Tms6KzObyeMKtJsu4qHg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 182982932488; Wed, 19 Oct 2022 12:52:31 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3CC34081B60; Wed, 19 Oct 2022 12:52:28 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Zhu Lingshan , Harpreet Singh Anand , Stefano Garzarella , Si-Wei Liu , Jason Wang , "Michael S. Tsirkin" , Cindy Lu , Laurent Vivier , Eli Cohen , Liuxiangdong , Parav Pandit , Gautam Dawar Subject: [RFC PATCH v2 5/8] vdpa: Remove shadow CVQ command check Date: Wed, 19 Oct 2022 14:52:07 +0200 Message-Id: <20221019125210.226291-6-eperezma@redhat.com> In-Reply-To: <20221019125210.226291-1-eperezma@redhat.com> References: <20221019125210.226291-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.256, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The guest will see undefined behavior if it issue not negotiate commands, bit it is expected somehow. Simplify code deleting this check. Signed-off-by: Eugenio Pérez Acked-by: Jason Wang --- net/vhost-vdpa.c | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index fca21d5b79..3374c21b4d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -461,48 +461,6 @@ static NetClientInfo net_vhost_vdpa_cvq_info = { .check_peer_type = vhost_vdpa_check_peer_type, }; -/** - * Do not forward commands not supported by SVQ. Otherwise, the device could - * accept it and qemu would not know how to update the device model. - */ -static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len) -{ - struct virtio_net_ctrl_hdr ctrl; - - if (unlikely(len < sizeof(ctrl))) { - qemu_log_mask(LOG_GUEST_ERROR, - "%s: invalid legnth of out buffer %zu\n", __func__, len); - return false; - } - - memcpy(&ctrl, out_buf, sizeof(ctrl)); - switch (ctrl.class) { - case VIRTIO_NET_CTRL_MAC: - switch (ctrl.cmd) { - case VIRTIO_NET_CTRL_MAC_ADDR_SET: - return true; - default: - qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid mac cmd %u\n", - __func__, ctrl.cmd); - }; - break; - case VIRTIO_NET_CTRL_MQ: - switch (ctrl.cmd) { - case VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET: - return true; - default: - qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid mq cmd %u\n", - __func__, ctrl.cmd); - }; - break; - default: - qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid control class %u\n", - __func__, ctrl.class); - }; - - return false; -} - /** * Validate and copy control virtqueue commands. * @@ -526,16 +484,10 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq, .iov_len = sizeof(status), }; ssize_t dev_written = -EINVAL; - bool ok; out.iov_len = iov_to_buf(elem->out_sg, elem->out_num, 0, s->cvq_cmd_out_buffer, vhost_vdpa_net_cvq_cmd_len()); - ok = vhost_vdpa_net_cvq_validate_cmd(s->cvq_cmd_out_buffer, out.iov_len); - if (unlikely(!ok)) { - goto out; - } - dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status)); if (unlikely(dev_written < 0)) { goto out; From patchwork Wed Oct 19 12:52:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13011721 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B970AC4332F for ; Wed, 19 Oct 2022 13:06:30 +0000 (UTC) Received: from localhost ([::1]:35018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol8mD-0006dE-Ov for qemu-devel@archiver.kernel.org; Wed, 19 Oct 2022 09:06:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yp-0006LT-Eb for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yo-0002Hx-1j for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666183957; 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=TVL69tt3U4Sp+yF4eyxZwls4Hc0ZvfnFa/OTrYDffMU=; b=gT+i8fPvhv2V7Dd2uTg/wsglrpAKgIH7dFpptPirCYFN4gfsujyCufbCF9n+fwxQ/h2o4k 9zKjv7/Pcbk28f47V8iZptN7XWqRvHrbYr87pywC1QWZJx++Eujw+7CCv1agWJMlvV6Egj Aga1U0ENUwuREbzRpcY5/qYRIoJiW4k= 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-357-s0Gxk_CsM5OwAtx0qCATyQ-1; Wed, 19 Oct 2022 08:52:34 -0400 X-MC-Unique: s0Gxk_CsM5OwAtx0qCATyQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B7B0129DD9B8; Wed, 19 Oct 2022 12:52:33 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60E6E4081B60; Wed, 19 Oct 2022 12:52:31 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Zhu Lingshan , Harpreet Singh Anand , Stefano Garzarella , Si-Wei Liu , Jason Wang , "Michael S. Tsirkin" , Cindy Lu , Laurent Vivier , Eli Cohen , Liuxiangdong , Parav Pandit , Gautam Dawar Subject: [RFC PATCH v2 6/8] vdpa: handle VIRTIO_NET_CTRL_ANNOUNCE in vhost_vdpa_net_handle_ctrl_avail Date: Wed, 19 Oct 2022 14:52:08 +0200 Message-Id: <20221019125210.226291-7-eperezma@redhat.com> In-Reply-To: <20221019125210.226291-1-eperezma@redhat.com> References: <20221019125210.226291-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.256, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Since this capability is emulated by qemu shadowed CVQ cannot forward it to the device. Process all that command within qemu. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 3374c21b4d..5fda405a66 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -488,9 +488,18 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq, out.iov_len = iov_to_buf(elem->out_sg, elem->out_num, 0, s->cvq_cmd_out_buffer, vhost_vdpa_net_cvq_cmd_len()); - dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status)); - if (unlikely(dev_written < 0)) { - goto out; + if (*(uint8_t *)s->cvq_cmd_out_buffer == VIRTIO_NET_CTRL_ANNOUNCE) { + /* + * Guest announce capability is emulated by qemu, so dont forward to + * the device. + */ + dev_written = sizeof(status); + *s->status = VIRTIO_NET_OK; + } else { + dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status)); + if (unlikely(dev_written < 0)) { + goto out; + } } if (unlikely(dev_written < sizeof(status))) { From patchwork Wed Oct 19 12:52:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13011710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BEAD4C4332F for ; Wed, 19 Oct 2022 13:02:28 +0000 (UTC) Received: from localhost ([::1]:36130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol8iJ-0002OY-Qe for qemu-devel@archiver.kernel.org; Wed, 19 Oct 2022 09:02:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yt-0006Q5-3a for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39240) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yr-0002Ik-KA for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666183961; 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=dlLuvcUarN69elwvHlh5K3FVhKPGqTSF12DmuECjccc=; b=LI5qzVAlNHLD3dpwzHs/kZnrSN/JthJW7QytfulsAzAXn/tC/+bfTrYltcfCyKV2TSc9PW KAO7xEDSoRPaw+qXPb65yN5hDyRbntsXj31VveeCcnsQT8oyjmvdS8ALtFNlV35pEyEm/U bxNojkIwv/4qsBL0g93E3rEDpJtBvBU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-614-2nC0wrjFO5eWouTBEBDN_Q-1; Wed, 19 Oct 2022 08:52:36 -0400 X-MC-Unique: 2nC0wrjFO5eWouTBEBDN_Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 58EE3185A79C; Wed, 19 Oct 2022 12:52:36 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BD744081B60; Wed, 19 Oct 2022 12:52:33 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Zhu Lingshan , Harpreet Singh Anand , Stefano Garzarella , Si-Wei Liu , Jason Wang , "Michael S. Tsirkin" , Cindy Lu , Laurent Vivier , Eli Cohen , Liuxiangdong , Parav Pandit , Gautam Dawar Subject: [RFC PATCH v2 7/8] vhost_net: return VIRTIO_NET_S_ANNOUNCE is device model has it set Date: Wed, 19 Oct 2022 14:52:09 +0200 Message-Id: <20221019125210.226291-8-eperezma@redhat.com> In-Reply-To: <20221019125210.226291-1-eperezma@redhat.com> References: <20221019125210.226291-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.256, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Temporal, as this affects other vhost backends and we must check status feature first. Signed-off-by: Eugenio Pérez --- hw/net/vhost_net.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 5660606c1d..300f370e2a 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -118,6 +118,7 @@ int vhost_net_get_config(struct vhost_net *net, uint8_t *config, uint32_t config_len) { VirtIODevice *vdev; + VirtIONet *n; int r = vhost_dev_get_config(&net->dev, config, config_len, NULL); if (unlikely(r != 0)) { @@ -142,6 +143,13 @@ int vhost_net_get_config(struct vhost_net *net, uint8_t *config, ((struct virtio_net_config *)config)->status |= VIRTIO_NET_S_LINK_UP; } + if (!(net->dev.acked_features & BIT_ULL(VIRTIO_NET_F_GUEST_ANNOUNCE))) { + return 0; + } + + n = VIRTIO_NET(vdev); + ((struct virtio_net_config *)config)->status |= + (n->status & VIRTIO_NET_S_ANNOUNCE); return 0; } int vhost_net_set_config(struct vhost_net *net, const uint8_t *data, From patchwork Wed Oct 19 12:52:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 13011732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98EA4C4332F for ; Wed, 19 Oct 2022 13:12:36 +0000 (UTC) Received: from localhost ([::1]:48686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol8s6-00023w-40 for qemu-devel@archiver.kernel.org; Wed, 19 Oct 2022 09:12:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yw-0006Qu-3s for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29873) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol8Yu-0002Jl-OA for qemu-devel@nongnu.org; Wed, 19 Oct 2022 08:52:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666183964; 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=F5A6Wz4vTjMQXnGigxrbVFmdXH778LWcKk1IV3D0UUo=; b=SzJoOJOZWzK57tUPDS53LLdlvkPwYu2zI+Lp8Eu0O1BGJigBYbiD7rZAMtZFBhRIOrL8x9 kmVTORThY/M2Z3Ww5XFkR20uWVhanzRzb1/nOcmlVveUeNQhKSiac5vuHd/bH/n7poD2fi PJBEpVno56ogdbOtksqwHfAyH8O/Usg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-e_O3ih92NVGFsrAf8InYYA-1; Wed, 19 Oct 2022 08:52:40 -0400 X-MC-Unique: e_O3ih92NVGFsrAf8InYYA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C92587B2A2; Wed, 19 Oct 2022 12:52:40 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id A17724081B61; Wed, 19 Oct 2022 12:52:36 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Zhu Lingshan , Harpreet Singh Anand , Stefano Garzarella , Si-Wei Liu , Jason Wang , "Michael S. Tsirkin" , Cindy Lu , Laurent Vivier , Eli Cohen , Liuxiangdong , Parav Pandit , Gautam Dawar Subject: [RFC PATCH v2 8/8] vdpa: Offer VIRTIO_NET_F_GUEST_ANNOUNCE feature if SVQ is enabled Date: Wed, 19 Oct 2022 14:52:10 +0200 Message-Id: <20221019125210.226291-9-eperezma@redhat.com> In-Reply-To: <20221019125210.226291-1-eperezma@redhat.com> References: <20221019125210.226291-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.256, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" So qemu emulates it in case the device does not support it. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 5fda405a66..64442e8455 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -566,6 +566,9 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer, /* VIRTIO_NET_F_STATUS is mandatory for _F_GUEST_ANNOUNCE. */ s->vhost_vdpa.added_features |= BIT_ULL(VIRTIO_NET_F_STATUS); + + /* We can emulate guest announce shadowing CVQ */ + s->vhost_vdpa.added_features |= BIT_ULL(VIRTIO_NET_F_GUEST_ANNOUNCE); } if (!is_datapath) { s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),