Skip to contentSkip to conversation

Vhost-vdpa Shadow Virtqueue Offloads support

PATCH Superseded Hawkins Jiawei 3 participants 17 messages Jun 1, 2023 – Jun 2, 2023 Networking

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Vhost-vdpa Shadow Virtqueue Offloads support

This series enables shadowed CVQ to intercept Offloads commands through shadowed CVQ, update the virtio NIC device model so qemu send it in a migration, and the restore of that Offloads state in the destination.

Changelog
=========
v3:
- refactor the commit message in patch
"virtio-net: expose virtio_net_supported_guest_offloads()"

v2: https://lists.nongnu.org/archive/html/qemu-devel/2023-06/msg00044.html

v1: https://lists.nongnu.org/archive/html/qemu-devel/2023-05/msg07198.html

Hawkins Jiawei (6):
include/hw/virtio: make some VirtIODevice const
vdpa: reuse virtio_vdev_has_feature() hw/net/virtio-net: make some VirtIONet const
virtio-net: expose virtio_net_supported_guest_offloads()
vdpa: Add vhost_vdpa_net_load_offloads()
vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ

 hw/net/virtio-net.c            |  2 +-
 include/hw/virtio/virtio-net.h |  1 +
 include/hw/virtio/virtio.h     |  2 +-
 net/vhost-vdpa.c               | 45 +++++++++++++++++++++++++++++++---
 4 files changed, 44 insertions(+), 6 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/6 include/hw/virtio: make some VirtIODevice const

The VirtIODevice structure is not modified in virtio_vdev_has_feature(). Therefore, make it const to allow this function to accept const variables.

---
 include/hw/virtio/virtio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/virtio/virtio.h +1 -1
index af86ed7249..0492d26900 100644
@@ -402,7 +402,7 @@ static inline bool virtio_has_feature(uint64_t features, unsigned int fbit)
     return !!(features & (1ULL << fbit));
 }
 
-static inline bool virtio_vdev_has_feature(VirtIODevice *vdev,
+static inline bool virtio_vdev_has_feature(const VirtIODevice *vdev,
                                            unsigned int fbit)
 {
     return virtio_has_feature(vdev->guest_features, fbit);
Signature · 1 line
2.25.1
Reviewed-by on v3 1/6
#2 lore raw

Re: [PATCH v3 1/6] include/hw/virtio: make some VirtIODevice const

Quoted 6 lines · Hawkins Jiawei

The VirtIODevice structure is not modified in virtio_vdev_has_feature(). Therefore, make it const to allow this function to accept const variables.

Quoted 20 lines
---
 include/hw/virtio/virtio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/hw/virtio/virtio.h +1 -2
index af86ed7249..0492d26900 100644
@@ -402,7 +402,7 @@ static inline bool virtio_has_feature(uint64_t features, unsigned int fbit)
     return !!(features & (1ULL << fbit));
 }
 
-static inline bool virtio_vdev_has_feature(VirtIODevice *vdev,
+static inline bool virtio_vdev_has_feature(const VirtIODevice *vdev,
                                            unsigned int fbit)
 {
     return virtio_has_feature(vdev->guest_features, fbit);
--

2.25.1

#3 lore raw

PATCH v3 2/6 vdpa: reuse virtio_vdev_has_feature()

In reply to Hawkins Jiawei

We can use virtio_vdev_has_feature() instead of manually accessing the features.

---
 net/vhost-vdpa.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
net/vhost-vdpa.c +2 -4
index 37cdc84562..e907a3c792 100644
@@ -643,8 +643,7 @@ static ssize_t vhost_vdpa_net_load_cmd(VhostVDPAState *s, uint8_t class,
 
 static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n)
 {
-    uint64_t features = n->parent_obj.guest_features;
-    if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) {
+    if (virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_MAC_ADDR)) {
         ssize_t dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_MAC,
                                                   VIRTIO_NET_CTRL_MAC_ADDR_SET,
                                                   n->mac, sizeof(n->mac));
@@ -662,10 +661,9 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,
                                   const VirtIONet *n)
 {
     struct virtio_net_ctrl_mq mq;
-    uint64_t features = n->parent_obj.guest_features;
     ssize_t dev_written;
 
-    if (!(features & BIT_ULL(VIRTIO_NET_F_MQ))) {
+    if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_MQ)) {
         return 0;
     }
 
Signature · 1 line
2.25.1
Acked-by on v3 2/6
#4 lore raw

Re: [PATCH v3 2/6] vdpa: reuse virtio_vdev_has_feature()

Quoted 5 lines · Hawkins Jiawei

We can use virtio_vdev_has_feature() instead of manually accessing the features.

Quoted 33 lines
---
 net/vhost-vdpa.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
net/vhost-vdpa.c +2 -5
index 37cdc84562..e907a3c792 100644
@@ -643,8 +643,7 @@ static ssize_t vhost_vdpa_net_load_cmd(VhostVDPAState *s, uint8_t class,
 
 static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n)
 {
-    uint64_t features = n->parent_obj.guest_features;
-    if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) {
+    if (virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_MAC_ADDR)) {
         ssize_t dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_MAC,
                                                   VIRTIO_NET_CTRL_MAC_ADDR_SET,
                                                   n->mac, sizeof(n->mac));
@@ -662,10 +661,9 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,
                                   const VirtIONet *n)
 {
     struct virtio_net_ctrl_mq mq;
-    uint64_t features = n->parent_obj.guest_features;
     ssize_t dev_written;
 
-    if (!(features & BIT_ULL(VIRTIO_NET_F_MQ))) {
+    if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_MQ)) {
         return 0;
     }
 
--

2.25.1

#5 lore raw

PATCH v3 3/6 hw/net/virtio-net: make some VirtIONet const

In reply to Hawkins Jiawei

The VirtIONet structure is not modified in virtio_net_supported_guest_offloads(). Therefore, make it const to allow this function to accept const variables.

---
 hw/net/virtio-net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/virtio-net.c +1 -1
index 6df6b7329d..7b27dad6c4 100644
@@ -874,7 +874,7 @@ static uint64_t virtio_net_guest_offloads_by_features(uint32_t features)
     return guest_offloads_mask & features;
 }
 
-static inline uint64_t virtio_net_supported_guest_offloads(VirtIONet *n)
+static inline uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
     return virtio_net_guest_offloads_by_features(vdev->guest_features);
Signature · 1 line
2.25.1
Reviewed-by on v3 3/6
#6 lore raw

Re: [PATCH v3 3/6] hw/net/virtio-net: make some VirtIONet const

Quoted 7 lines · Hawkins Jiawei

The VirtIONet structure is not modified in virtio_net_supported_guest_offloads(). Therefore, make it const to allow this function to accept const variables.

Quoted 20 lines
---
 hw/net/virtio-net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/virtio-net.c +1 -2
index 6df6b7329d..7b27dad6c4 100644
@@ -874,7 +874,7 @@ static uint64_t virtio_net_guest_offloads_by_features(uint32_t features)
     return guest_offloads_mask & features;
 }
 
-static inline uint64_t virtio_net_supported_guest_offloads(VirtIONet *n)
+static inline uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
     return virtio_net_guest_offloads_by_features(vdev->guest_features);
--

2.25.1

#7 lore raw

PATCH v3 4/6 virtio-net: expose virtio_net_supported_guest_offloads()

In reply to Hawkins Jiawei

To support restoring offloads state in vdpa, need to expose the function virtio_net_supported_guest_offloads(). QEMU uses this function to get the guest supported offloads and no needs to send the corresponding CVQ command if guest enables all supported features.

---
 hw/net/virtio-net.c            | 2 +-
 include/hw/virtio/virtio-net.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +1 -1
index 7b27dad6c4..7e8897a8bc 100644
@@ -874,7 +874,7 @@ static uint64_t virtio_net_guest_offloads_by_features(uint32_t features)
     return guest_offloads_mask & features;
 }
 
-static inline uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n)
+uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
     return virtio_net_guest_offloads_by_features(vdev->guest_features);
include/hw/virtio/virtio-net.h +1 -0
index ef234ffe7e..5f5dcb4572 100644
@@ -227,5 +227,6 @@ size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
                                   unsigned out_num);
 void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
                                    const char *type);
+uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n);
 
 #endif
Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH v3 4/6] virtio-net: expose virtio_net_supported_guest_offloads()

Quoted 5 lines · Hawkins Jiawei

To support restoring offloads state in vdpa, need to expose the function virtio_net_supported_guest_offloads(). QEMU uses this function to get the guest supported offloads and no needs to send the corresponding CVQ command if guest

doesn't need to send?

Quoted 2 lines

enables all supported features.

Good! I'd add the same message as the next patch's comment, to signal it is because the device has already enabled by default:

+         * According to VirtIO standard, "Upon feature negotiation
+         * corresponding offload gets enabled to preserve
+         * backward compatibility."
+         * So we do not need to send this CVQ command if the guest
+         * also enables all supported offloads.

Thanks!

Quoted 33 lines
---
 hw/net/virtio-net.c            | 2 +-
 include/hw/virtio/virtio-net.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +1 -1
index 7b27dad6c4..7e8897a8bc 100644
@@ -874,7 +874,7 @@ static uint64_t virtio_net_guest_offloads_by_features(uint32_t features)
     return guest_offloads_mask & features;
 }
 
-static inline uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n)
+uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
     return virtio_net_guest_offloads_by_features(vdev->guest_features);
include/hw/virtio/virtio-net.h +1 -1
index ef234ffe7e..5f5dcb4572 100644
@@ -227,5 +227,6 @@ size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
                                   unsigned out_num);
 void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
                                    const char *type);
+uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n);
 
 #endif
--

2.25.1

#9 lore raw

Re: [PATCH v3 4/6] virtio-net: expose virtio_net_supported_guest_offloads()

Quoted 8 lines · Eugenio Perez Martin
Quoted 5 lines · Hawkins Jiawei

To support restoring offloads state in vdpa, need to expose the function virtio_net_supported_guest_offloads(). QEMU uses this function to get the guest supported offloads and no needs to send the corresponding CVQ command if guest

doesn't need to send?

I will correct it in the v4 patch.

Review

Quoted 12 lines
Quoted 3 lines

enables all supported features.

Good! I'd add the same message as the next patch's comment, to signal it is because the device has already enabled by default:

(quoted diff) +5 -0
+         * According to VirtIO standard, "Upon feature negotiation
+         * corresponding offload gets enabled to preserve
+         * backward compatibility."
+         * So we do not need to send this CVQ command if the guest
+         * also enables all supported offloads.

I will add these messages in the v4 patch.

Thanks!

Quoted 38 lines

Thanks!

Quoted 33 lines
---
  hw/net/virtio-net.c            | 2 +-
  include/hw/virtio/virtio-net.h | 1 +
  2 files changed, 2 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +1 -1
index 7b27dad6c4..7e8897a8bc 100644
@@ -874,7 +874,7 @@ static uint64_t virtio_net_guest_offloads_by_features(uint32_t features)
      return guest_offloads_mask & features;
  }
 
-static inline uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n)
+uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n)
  {
      VirtIODevice *vdev = VIRTIO_DEVICE(n);
      return virtio_net_guest_offloads_by_features(vdev->guest_features);
include/hw/virtio/virtio-net.h +1 -1
index ef234ffe7e..5f5dcb4572 100644
@@ -227,5 +227,6 @@ size_t virtio_net_handle_ctrl_iov(VirtIODevice *vdev,
                                    unsigned out_num);
  void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
                                     const char *type);
+uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n);
 
  #endif
--

2.25.1

#10 lore raw

PATCH v3 5/6 vdpa: Add vhost_vdpa_net_load_offloads()

In reply to Hawkins Jiawei

This patch introduces vhost_vdpa_net_load_offloads() to restore offloads state at device's startup.

---
 net/vhost-vdpa.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
net/vhost-vdpa.c +38 -0
index e907a3c792..0e647886d1 100644
@@ -678,6 +678,40 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,
     return *s->status != VIRTIO_NET_OK;
 }
 
+static int vhost_vdpa_net_load_offloads(VhostVDPAState *s,
+                                        const VirtIONet *n)
+{
+    uint64_t offloads;
+    ssize_t dev_written;
+
+    if (!virtio_vdev_has_feature(&n->parent_obj,
+                                 VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
+        return 0;
+    }
+
+    offloads = cpu_to_le64(n->curr_guest_offloads);
+
+    if (offloads == virtio_net_supported_guest_offloads(n)) {
+        /*
+         * According to VirtIO standard, "Upon feature negotiation
+         * corresponding offload gets enabled to preserve
+         * backward compatibility."
+         * So we do not need to send this CVQ command if the guest
+         * also enables all supported offloads.
+         */
+        return 0;
+    }
+
+    dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_GUEST_OFFLOADS,
+                                          VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET,
+                                          &offloads, sizeof(offloads));
+    if (unlikely(dev_written < 0)) {
+        return dev_written;
+    }
+
+    return *s->status != VIRTIO_NET_OK;
+}
+
 static int vhost_vdpa_net_load(NetClientState *nc)
 {
     VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
@@ -700,6 +734,10 @@ static int vhost_vdpa_net_load(NetClientState *nc)
     if (unlikely(r)) {
         return r;
     }
+    r = vhost_vdpa_net_load_offloads(s, n);
+    if (unlikely(r)) {
+        return r;
+    }
 
     return 0;
 }
Signature · 1 line
2.25.1
#11 lore raw

Re: [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads()

Quoted 19 lines · Hawkins Jiawei

This patch introduces vhost_vdpa_net_load_offloads() to restore offloads state at device's startup.

---
 net/vhost-vdpa.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
net/vhost-vdpa.c +2 -0
index e907a3c792..0e647886d1 100644
@@ -678,6 +678,40 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,
     return *s->status != VIRTIO_NET_OK;
 }
 
+static int vhost_vdpa_net_load_offloads(VhostVDPAState *s,
+                                        const VirtIONet *n)

net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 692

Quoted 10 lines
net/vhost-vdpa.c +10 -0
+{
+    uint64_t offloads;
+    ssize_t dev_written;
+
+    if (!virtio_vdev_has_feature(&n->parent_obj,
+                                 VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
+        return 0;
+    }
+
+    offloads = cpu_to_le64(n->curr_guest_offloads);

n->curr_guest_offloads is already stored in CPU order, we should only byte-swap it by the time of sending.

Thanks!

Quoted 39 lines
net/vhost-vdpa.c +26 -1
+
+    if (offloads == virtio_net_supported_guest_offloads(n)) {
+        /*
+         * According to VirtIO standard, "Upon feature negotiation
+         * corresponding offload gets enabled to preserve
+         * backward compatibility."
+         * So we do not need to send this CVQ command if the guest
+         * also enables all supported offloads.
+         */
+        return 0;
+    }
+
+    dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_GUEST_OFFLOADS,
+                                          VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET,
+                                          &offloads, sizeof(offloads));
+    if (unlikely(dev_written < 0)) {
+        return dev_written;
+    }
+
+    return *s->status != VIRTIO_NET_OK;
+}
+
 static int vhost_vdpa_net_load(NetClientState *nc)
 {
     VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
@@ -700,6 +734,10 @@ static int vhost_vdpa_net_load(NetClientState *nc)
     if (unlikely(r)) {
         return r;
     }
+    r = vhost_vdpa_net_load_offloads(s, n);
+    if (unlikely(r)) {
+        return r;
+    }
 
     return 0;
 }
--

2.25.1

#12 lore raw

Re: [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads()

Quoted 18 lines · Eugenio Perez Martin
Quoted 17 lines · Hawkins Jiawei

This patch introduces vhost_vdpa_net_load_offloads() to restore offloads state at device's startup.

---
  net/vhost-vdpa.c | 38 ++++++++++++++++++++++++++++++++++++++
  1 file changed, 38 insertions(+)
net/vhost-vdpa.c +0 -0
index e907a3c792..0e647886d1 100644
@@ -678,6 +678,40 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s,
      return *s->status != VIRTIO_NET_OK;
  }
 
Quoted 15 lines

net/vhost-vdpa.c static int vhost_vdpa_net_load_mq(VhostVDPAState *s, · line 692

Quoted 12 lines
net/vhost-vdpa.c +12 -0
+static int vhost_vdpa_net_load_offloads(VhostVDPAState *s,
+                                        const VirtIONet *n)
+{
+    uint64_t offloads;
+    ssize_t dev_written;
+
+    if (!virtio_vdev_has_feature(&n->parent_obj,
+                                 VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
+        return 0;
+    }
+
+    offloads = cpu_to_le64(n->curr_guest_offloads);

n->curr_guest_offloads is already stored in CPU order, we should only byte-swap it by the time of sending.

Yes, you are right.

I will correct it in the v4 patch.

Thanks!

Quoted 43 lines

Thanks!

Quoted 39 lines
net/vhost-vdpa.c +26 -1
+
+    if (offloads == virtio_net_supported_guest_offloads(n)) {
+        /*
+         * According to VirtIO standard, "Upon feature negotiation
+         * corresponding offload gets enabled to preserve
+         * backward compatibility."
+         * So we do not need to send this CVQ command if the guest
+         * also enables all supported offloads.
+         */
+        return 0;
+    }
+
+    dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_GUEST_OFFLOADS,
+                                          VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET,
+                                          &offloads, sizeof(offloads));
+    if (unlikely(dev_written < 0)) {
+        return dev_written;
+    }
+
+    return *s->status != VIRTIO_NET_OK;
+}
+
  static int vhost_vdpa_net_load(NetClientState *nc)
  {
      VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
@@ -700,6 +734,10 @@ static int vhost_vdpa_net_load(NetClientState *nc)
      if (unlikely(r)) {
          return r;
      }
+    r = vhost_vdpa_net_load_offloads(s, n);
+    if (unlikely(r)) {
+        return r;
+    }
 
      return 0;
  }
--

2.25.1

#13 lore raw

PATCH v3 6/6 vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ

In reply to Hawkins Jiawei

Enable SVQ with VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature.

---
 net/vhost-vdpa.c | 1 +
 1 file changed, 1 insertion(+)
net/vhost-vdpa.c +1 -0
index 0e647886d1..4cc24a2997 100644
@@ -85,6 +85,7 @@ const int vdpa_feature_bits[] = {
 static const uint64_t vdpa_svq_device_features =
     BIT_ULL(VIRTIO_NET_F_CSUM) |
     BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) |
+    BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) |
     BIT_ULL(VIRTIO_NET_F_MTU) |
     BIT_ULL(VIRTIO_NET_F_MAC) |
     BIT_ULL(VIRTIO_NET_F_GUEST_TSO4) |
Signature · 1 line
2.25.1
Acked-by on v3 6/6
#14 lore raw

Re: [PATCH v3 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ

Quoted 5 lines · Hawkins Jiawei

Enable SVQ with VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature.

Quoted 19 lines
---
 net/vhost-vdpa.c | 1 +
 1 file changed, 1 insertion(+)
net/vhost-vdpa.c +1 -1
index 0e647886d1..4cc24a2997 100644
@@ -85,6 +85,7 @@ const int vdpa_feature_bits[] = {
 static const uint64_t vdpa_svq_device_features =
     BIT_ULL(VIRTIO_NET_F_CSUM) |
     BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) |
+    BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) |
     BIT_ULL(VIRTIO_NET_F_MTU) |
     BIT_ULL(VIRTIO_NET_F_MAC) |
     BIT_ULL(VIRTIO_NET_F_GUEST_TSO4) |
--

2.25.1

Tested-by on the v3 series
#15 lore raw
In reply to Hawkins Jiawei

Hello Hawkins

QE based on the qemu command line [1] to test this series with the following scenarios: reboot,shutdown,hotplug/unplug,ping, and offloads(tx,sg,tso,gso,gro), everything is working fine. It's just that even without applying your patch to test offload there is no error like "vdpa svq is not available for feature 4".

[1] -device '{"driver": "virtio-net-pci", "mac": "00:11:22:33:44:00", "id": "net0", "netdev": "hostnet0", "ctrl_guest_offloads": true, "bus": "pcie-root-port-3", "addr": "0x0"}' \
-netdev vhost-vdpa,id=hostnet0,vhostdev=/dev/vhost-vdpa-0,x-svq=on \

Quoted 34 lines · Hawkins Jiawei

This series enables shadowed CVQ to intercept Offloads commands through shadowed CVQ, update the virtio NIC device model so qemu send it in a migration, and the restore of that Offloads state in the destination.

Changelog
=========
v3:
- refactor the commit message in patch
"virtio-net: expose virtio_net_supported_guest_offloads()"

v2: https://lists.nongnu.org/archive/html/qemu-devel/2023-06/msg00044.html

v1: https://lists.nongnu.org/archive/html/qemu-devel/2023-05/msg07198.html

Hawkins Jiawei (6):
include/hw/virtio: make some VirtIODevice const
vdpa: reuse virtio_vdev_has_feature() hw/net/virtio-net: make some VirtIONet const
virtio-net: expose virtio_net_supported_guest_offloads()
vdpa: Add vhost_vdpa_net_load_offloads()
vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ

 hw/net/virtio-net.c            |  2 +-
 include/hw/virtio/virtio-net.h |  1 +
 include/hw/virtio/virtio.h     |  2 +-
 net/vhost-vdpa.c               | 45 +++++++++++++++++++++++++++++++---
 4 files changed, 44 insertions(+), 6 deletions(-)

--
2.25.1

#16 lore raw
Quoted 9 lines · Lei Yang

Hello Hawkins

QE based on the qemu command line [1] to test this series with the following scenarios: reboot,shutdown,hotplug/unplug,ping, and offloads(tx,sg,tso,gso,gro), everything is working fine. It's just that even without applying your patch to test offload there is no error like "vdpa svq is not available for feature 4".

Quoted 4 lines

[1] -device '{"driver": "virtio-net-pci", "mac": "00:11:22:33:44:00", "id": "net0", "netdev": "hostnet0", "ctrl_guest_offloads": true, "bus": "pcie-root-port-3", "addr": "0x0"}' \
-netdev vhost-vdpa,id=hostnet0,vhostdev=/dev/vhost-vdpa-0,x-svq=on \

Hi Lei,

Thanks for your efforts.

However, I noticed a small correction. In the argument '-netdev', the value of member 'x-svq' should be 'true' instead of 'on'.

I have tested these patches using a vp-vdpa device, and without them, I encountered an error "vpda svq is not available for feature 4" while trying to start QEMU. With these patches applied, everything works perfectly.

Thanks!

Quoted 42 lines
Quoted 34 lines · Hawkins Jiawei

This series enables shadowed CVQ to intercept Offloads commands through shadowed CVQ, update the virtio NIC device model so qemu send it in a migration, and the restore of that Offloads state in the destination.

Changelog
=========
v3:
- refactor the commit message in patch
"virtio-net: expose virtio_net_supported_guest_offloads()"

v2: https://lists.nongnu.org/archive/html/qemu-devel/2023-06/msg00044.html

v1: https://lists.nongnu.org/archive/html/qemu-devel/2023-05/msg07198.html

Hawkins Jiawei (6):
include/hw/virtio: make some VirtIODevice const
vdpa: reuse virtio_vdev_has_feature() hw/net/virtio-net: make some VirtIONet const
virtio-net: expose virtio_net_supported_guest_offloads()
vdpa: Add vhost_vdpa_net_load_offloads()
vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ

 hw/net/virtio-net.c            |  2 +-
 include/hw/virtio/virtio-net.h |  1 +
 include/hw/virtio/virtio.h     |  2 +-
 net/vhost-vdpa.c               | 45 +++++++++++++++++++++++++++++++---
 4 files changed, 44 insertions(+), 6 deletions(-)

--
2.25.1