qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Yuri Benditovich <yuri.benditovich@daynix.com>
Cc: eduardo@habkost.net, marcel.apfelbaum@gmail.com,
	philmd@linaro.org, wangyanan55@huawei.com,
	dmitry.fleytman@gmail.com, akihiko.odaki@daynix.com,
	jasowang@redhat.com, sriram.yagnaraman@est.tech, mst@redhat.com,
	sw@weilnetz.de, qemu-devel@nongnu.org, yan@daynix.com,
	"Fabiano Rosas" <farosas@suse.de>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>
Subject: Re: [PATCH v2 4/4] virtio-net: Add support for USO features
Date: Thu, 25 Jul 2024 18:18:20 -0400	[thread overview]
Message-ID: <ZqLPLBnbfD5r6z7D@x1n> (raw)
In-Reply-To: <20230731223148.1002258-5-yuri.benditovich@daynix.com>

On Tue, Aug 01, 2023 at 01:31:48AM +0300, Yuri Benditovich wrote:
> USO features of virtio-net device depend on kernel ability
> to support them, for backward compatibility by default the
> features are disabled on 8.0 and earlier.
> 
> Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
> Signed-off-by: Andrew Melnychecnko <andrew@daynix.com>

Looks like this patch broke migration when the VM starts on a host that has
USO supported, to another host that doesn't..

Yuri, would it be possible we always keep all the USO* features off by
default (so this feature bit never affects migration ABI), but then:

  - only enable them when the user specified ON

  - meanwhile, if detecting host feature doesn't support USO*, it could
    fail qemu from boot, rather than silently turning it from ON->OFF

?

Silently flipping the bit may cause migration issues like this.

Or any suggestion on how to fix migration?

Thanks,

> ---
>  hw/core/machine.c   |  4 ++++
>  hw/net/virtio-net.c | 31 +++++++++++++++++++++++++++++--
>  2 files changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index f0d35c6401..a725e76738 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -38,10 +38,14 @@
>  #include "exec/confidential-guest-support.h"
>  #include "hw/virtio/virtio.h"
>  #include "hw/virtio/virtio-pci.h"
> +#include "hw/virtio/virtio-net.h"
>  
>  GlobalProperty hw_compat_8_0[] = {
>      { "migration", "multifd-flush-after-each-section", "on"},
>      { TYPE_PCI_DEVICE, "x-pcie-ari-nextfn-1", "on" },
> +    { TYPE_VIRTIO_NET, "host_uso", "off"},
> +    { TYPE_VIRTIO_NET, "guest_uso4", "off"},
> +    { TYPE_VIRTIO_NET, "guest_uso6", "off"},
>  };
>  const size_t hw_compat_8_0_len = G_N_ELEMENTS(hw_compat_8_0);
>  
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index d2311e7d6e..bd0ead94fe 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -659,6 +659,15 @@ static int peer_has_ufo(VirtIONet *n)
>      return n->has_ufo;
>  }
>  
> +static int peer_has_uso(VirtIONet *n)
> +{
> +    if (!peer_has_vnet_hdr(n)) {
> +        return 0;
> +    }
> +
> +    return qemu_has_uso(qemu_get_queue(n->nic)->peer);
> +}
> +
>  static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs,
>                                         int version_1, int hash_report)
>  {
> @@ -796,6 +805,10 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
>          virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO6);
>          virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ECN);
>  
> +        virtio_clear_feature(&features, VIRTIO_NET_F_HOST_USO);
> +        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO4);
> +        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO6);
> +
>          virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT);
>      }
>  
> @@ -804,6 +817,12 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
>          virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO);
>      }
>  
> +    if (!peer_has_uso(n)) {
> +        virtio_clear_feature(&features, VIRTIO_NET_F_HOST_USO);
> +        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO4);
> +        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO6);
> +    }
> +
>      if (!get_vhost_net(nc->peer)) {
>          return features;
>      }
> @@ -864,14 +883,16 @@ static void virtio_net_apply_guest_offloads(VirtIONet *n)
>              !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO6)));
>  }
>  
> -static uint64_t virtio_net_guest_offloads_by_features(uint32_t features)
> +static uint64_t virtio_net_guest_offloads_by_features(uint64_t features)
>  {
>      static const uint64_t guest_offloads_mask =
>          (1ULL << VIRTIO_NET_F_GUEST_CSUM) |
>          (1ULL << VIRTIO_NET_F_GUEST_TSO4) |
>          (1ULL << VIRTIO_NET_F_GUEST_TSO6) |
>          (1ULL << VIRTIO_NET_F_GUEST_ECN)  |
> -        (1ULL << VIRTIO_NET_F_GUEST_UFO);
> +        (1ULL << VIRTIO_NET_F_GUEST_UFO)  |
> +        (1ULL << VIRTIO_NET_F_GUEST_USO4) |
> +        (1ULL << VIRTIO_NET_F_GUEST_USO6);
>  
>      return guest_offloads_mask & features;
>  }
> @@ -3924,6 +3945,12 @@ static Property virtio_net_properties[] = {
>      DEFINE_PROP_INT32("speed", VirtIONet, net_conf.speed, SPEED_UNKNOWN),
>      DEFINE_PROP_STRING("duplex", VirtIONet, net_conf.duplex_str),
>      DEFINE_PROP_BOOL("failover", VirtIONet, failover, false),
> +    DEFINE_PROP_BIT64("guest_uso4", VirtIONet, host_features,
> +                      VIRTIO_NET_F_GUEST_USO4, true),
> +    DEFINE_PROP_BIT64("guest_uso6", VirtIONet, host_features,
> +                      VIRTIO_NET_F_GUEST_USO6, true),
> +    DEFINE_PROP_BIT64("host_uso", VirtIONet, host_features,
> +                      VIRTIO_NET_F_HOST_USO, true),
>      DEFINE_PROP_END_OF_LIST(),
>  };
>  
> -- 
> 2.34.3
> 
> 

-- 
Peter Xu



  parent reply	other threads:[~2024-07-25 22:19 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-31 22:31 [PATCH v2 0/4] virtio-net: add USO feature (UDP segmentation offload) Yuri Benditovich
2023-07-31 22:31 ` [PATCH v2 1/4] tap: Add USO support to tap device Yuri Benditovich
2023-07-31 22:31 ` [PATCH v2 2/4] tap: Add check for USO features Yuri Benditovich
2023-07-31 22:31 ` [PATCH v2 3/4] virtio-net: Add USO flags to vhost support Yuri Benditovich
2023-07-31 22:31 ` [PATCH v2 4/4] virtio-net: Add support for USO features Yuri Benditovich
2023-08-02  5:17   ` Akihiko Odaki
2024-07-25 22:18   ` Peter Xu [this message]
2024-07-26  2:12     ` Jason Wang
2024-07-26 15:01       ` Peter Xu
2024-07-26  6:08     ` Michael S. Tsirkin
2024-07-26  7:03       ` Thomas Huth
2024-07-26  7:25         ` Michael S. Tsirkin
2024-07-26 11:32           ` Peter Xu
2024-07-26 17:39           ` Thomas Huth
2024-07-26 20:55             ` Peter Xu
2024-08-01  5:41             ` Michael S. Tsirkin
2024-07-26  8:48         ` Daniel P. Berrangé
2024-07-26 14:43           ` Peter Xu
2024-07-26 15:17             ` Daniel P. Berrangé
2024-07-26 20:47               ` Peter Xu
2024-07-28 15:18                 ` Akihiko Odaki
2024-07-29  3:50                   ` Jason Wang
2024-07-29  4:45                     ` Akihiko Odaki
2024-07-29 14:29                       ` Peter Xu
2024-07-29 16:43                         ` Akihiko Odaki
2024-07-30  2:04                           ` Jason Wang
2024-07-30  2:57                             ` Akihiko Odaki
2024-07-30  3:03                               ` Jason Wang
2024-07-30  3:11                                 ` Akihiko Odaki
2024-07-30  3:17                                   ` Jason Wang
2024-07-30  3:28                                     ` Akihiko Odaki
2024-07-30  3:45                                       ` Jason Wang
2024-07-30 10:23                                         ` Akihiko Odaki
2024-07-30 11:52                                           ` Yuri Benditovich
2024-07-31  2:05                                           ` Jason Wang
2024-07-29 15:58                 ` Daniel P. Berrangé
2024-07-29 17:00                   ` Peter Xu
2024-07-29 17:23                     ` Akihiko Odaki
2024-07-30 18:02                       ` Peter Xu
2024-07-29 17:26                     ` Daniel P. Berrangé
2024-07-30 18:13                       ` Peter Xu
2024-07-30 18:46                         ` Daniel P. Berrangé
2024-07-30 19:11                           ` Peter Xu
2024-07-30 19:22                             ` Michael S. Tsirkin
2024-07-30 20:03                               ` Peter Xu
2024-07-30 21:32                                 ` Michael S. Tsirkin
2024-07-30 22:01                                   ` Peter Xu
2024-07-31  2:01                                   ` Jason Wang
2024-07-31  7:04                                   ` Daniel P. Berrangé
2024-07-31  7:41                                     ` Michael S. Tsirkin
2024-07-31 12:57                                       ` Peter Xu
2024-08-01  2:28                                         ` Jason Wang
2024-08-01  5:28                                           ` Akihiko Odaki
2024-08-01  5:34                                         ` Michael S. Tsirkin
2024-08-01  5:51                                         ` Michael S. Tsirkin
2024-08-01 15:36                                           ` Peter Xu
2024-08-01 15:39                                             ` Michael S. Tsirkin
2024-08-01 15:45                                           ` Daniel P. Berrangé
2024-08-01 15:50                                             ` Michael S. Tsirkin
2024-08-01 15:58                                               ` Daniel P. Berrangé
2024-08-01  5:05                             ` Akihiko Odaki
2024-08-01 15:13                               ` Peter Xu
2024-08-01 15:15                                 ` Michael S. Tsirkin
2024-08-01 15:25                                   ` Daniel P. Berrangé
2024-08-02  4:30                                 ` Akihiko Odaki
2024-08-02 13:21                                   ` Michael S. Tsirkin
2024-08-02 15:05                                   ` Peter Xu
2024-08-02 15:54                                     ` Akihiko Odaki
2024-08-02 16:26                                       ` Peter Xu
2024-08-02 16:40                                         ` Michael S. Tsirkin
2024-08-02 20:56                                           ` Peter Xu
2024-08-04  6:49                                         ` Akihiko Odaki
2024-08-04 13:08                                           ` Peter Xu
2024-08-04 13:41                                             ` Michael S. Tsirkin
2024-08-05  7:27                                             ` Akihiko Odaki
2024-08-06 20:41                                               ` Peter Xu
2024-08-08 11:43                                                 ` Akihiko Odaki
2024-08-08 13:55                                                   ` Peter Xu
2024-08-08 14:45                                                     ` Michael S. Tsirkin
2024-08-09 10:28                                                     ` Akihiko Odaki
2024-08-05  7:30                                           ` Michael S. Tsirkin
2024-08-05  7:53                                             ` Akihiko Odaki
2024-08-05  8:23                                               ` Michael S. Tsirkin
2024-08-05  9:37                                                 ` Akihiko Odaki
2024-08-05 10:08                                                   ` Michael S. Tsirkin
2024-08-06  7:35                                                     ` Akihiko Odaki
2024-08-06 13:29                                                       ` Michael S. Tsirkin
2024-08-08 10:52                                                         ` Akihiko Odaki
2024-08-08 10:54                                                           ` Michael S. Tsirkin
2024-08-08 11:03                                                             ` Akihiko Odaki
2024-08-08 11:12                                                               ` Michael S. Tsirkin
2024-08-08 11:32                                                                 ` Akihiko Odaki
2024-08-08 14:21                                                                   ` Peter Xu
2024-08-08 14:15                                                                 ` Peter Xu
2024-08-08 14:47                                                                   ` Michael S. Tsirkin
2024-08-08 15:25                                                                     ` Peter Xu
2024-08-09 12:50                                                                       ` Fabiano Rosas
2024-08-18  5:04                                                                         ` Akihiko Odaki
2024-08-18  7:03                                                                           ` Michael S. Tsirkin
2024-08-19  4:27                                                                             ` Akihiko Odaki
2024-08-11  7:35                                                                       ` Michael S. Tsirkin
2024-08-18  5:09                                                                       ` Akihiko Odaki
2024-07-29 17:02                   ` Akihiko Odaki
2024-08-01  5:38                     ` Michael S. Tsirkin
2024-07-29  3:52       ` Jason Wang
2023-08-09 20:21 ` [PATCH v2 0/4] virtio-net: add USO feature (UDP segmentation offload) Yuri Benditovich
2023-08-10  3:14   ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZqLPLBnbfD5r6z7D@x1n \
    --to=peterx@redhat.com \
    --cc=akihiko.odaki@daynix.com \
    --cc=berrange@redhat.com \
    --cc=dmitry.fleytman@gmail.com \
    --cc=eduardo@habkost.net \
    --cc=farosas@suse.de \
    --cc=jasowang@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sriram.yagnaraman@est.tech \
    --cc=sw@weilnetz.de \
    --cc=thuth@redhat.com \
    --cc=wangyanan55@huawei.com \
    --cc=yan@daynix.com \
    --cc=yuri.benditovich@daynix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).