All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org
Cc: Yuri Benditovich <yuri.benditovich@daynix.com>,
	Andrew Melnychecnko <andrew@daynix.com>,
	Jason Wang <jasowang@redhat.com>
Subject: [PULL 04/17] virtio-net: Add support for USO features
Date: Fri,  8 Sep 2023 14:44:54 +0800	[thread overview]
Message-ID: <20230908064507.14596-5-jasowang@redhat.com> (raw)
In-Reply-To: <20230908064507.14596-1-jasowang@redhat.com>

From: Yuri Benditovich <yuri.benditovich@daynix.com>

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>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 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 da699cf..230aab8 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -38,6 +38,7 @@
 #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_1[] = {};
 const size_t hw_compat_8_1_len = G_N_ELEMENTS(hw_compat_8_1);
@@ -45,6 +46,9 @@ const size_t hw_compat_8_1_len = G_N_ELEMENTS(hw_compat_8_1);
 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 d2311e7..bd0ead9 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.7.4



  parent reply	other threads:[~2023-09-08  6:47 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08  6:44 [PULL 00/17] Net patches Jason Wang
2023-09-08  6:44 ` [PULL 01/17] tap: Add USO support to tap device Jason Wang
2023-09-08  6:44 ` [PULL 02/17] tap: Add check for USO features Jason Wang
2023-09-08  6:44 ` [PULL 03/17] virtio-net: Add USO flags to vhost support Jason Wang
2023-09-08  6:44 ` Jason Wang [this message]
2023-09-08  6:44 ` [PULL 05/17] igb: remove TCP ACK detection Jason Wang
2023-09-08  6:44 ` [PULL 06/17] igb: rename E1000E_RingInfo_st Jason Wang
2023-09-08  6:44 ` [PULL 07/17] igb: RX descriptors guest writting refactoring Jason Wang
2023-09-08  6:44 ` [PULL 08/17] igb: RX payload " Jason Wang
2023-09-08  6:44 ` [PULL 09/17] igb: add IPv6 extended headers traffic detection Jason Wang
2023-09-08  6:45 ` [PULL 10/17] igb: packet-split descriptors support Jason Wang
2023-09-08  6:45 ` [PULL 11/17] e1000e: rename e1000e_ba_state and e1000e_write_hdr_to_rx_buffers Jason Wang
2023-09-08  6:45 ` [PULL 12/17] net: add initial support for AF_XDP network backend Jason Wang
2023-09-08 11:48   ` Daniel P. Berrangé
2023-09-08 11:55     ` Ilya Maximets
2023-09-08  6:45 ` [PULL 13/17] ebpf: Added eBPF map update through mmap Jason Wang
2023-09-08  6:45 ` [PULL 14/17] ebpf: Added eBPF initialization by fds Jason Wang
2023-09-08  6:45 ` [PULL 15/17] virtio-net: Added property to load eBPF RSS with fds Jason Wang
2023-09-08  6:45 ` [PULL 16/17] qmp: Added new command to retrieve eBPF blob Jason Wang
2023-09-08  6:45 ` [PULL 17/17] ebpf: Updated eBPF program and skeleton Jason Wang
2023-09-08 11:19 ` [PULL 00/17] Net patches Stefan Hajnoczi
2023-09-08 11:34   ` Ilya Maximets
2023-09-08 11:49     ` Daniel P. Berrangé
2023-09-08 12:00       ` Ilya Maximets
2023-09-08 12:15         ` Daniel P. Berrangé
2023-09-08 14:06           ` Ilya Maximets
2023-09-08 14:15             ` Daniel P. Berrangé
2023-09-13 18:46               ` Ilya Maximets
2023-09-14  8:13                 ` Daniel P. Berrangé
2023-09-18 19:36                   ` Ilya Maximets
2023-09-19  8:40                     ` Daniel P. Berrangé
2023-09-19  9:39                       ` Ilya Maximets
2023-09-19 10:03                         ` Daniel P. Berrangé

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=20230908064507.14596-5-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=andrew@daynix.com \
    --cc=qemu-devel@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.