qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support
@ 2023-06-01  8:28 Hawkins Jiawei
  2023-06-01  8:48 ` [PATCH v2 1/6] include/hw/virtio: make some VirtIODevice const Hawkins Jiawei
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Hawkins Jiawei @ 2023-06-01  8:28 UTC (permalink / raw)
  To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149

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
=========
v2:
  - make some function arguments const
  - reuse virtio_vdev_has_feature() suggested by Eugenio and Jason
  - avoid sending CVQ command in default state suggested by Eugenio

v1: https://lore.kernel.org/all/cover.1685359572.git.yin31149@gmail.com/

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



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/6] include/hw/virtio: make some VirtIODevice const
  2023-06-01  8:28 [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
@ 2023-06-01  8:48 ` Hawkins Jiawei
  2023-06-01  8:48 ` [PATCH v2 2/6] vdpa: reuse virtio_vdev_has_feature() Hawkins Jiawei
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Hawkins Jiawei @ 2023-06-01  8:48 UTC (permalink / raw)
  To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149

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

Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
---
 include/hw/virtio/virtio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index af86ed7249..0492d26900 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -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



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/6] vdpa: reuse virtio_vdev_has_feature()
  2023-06-01  8:28 [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
  2023-06-01  8:48 ` [PATCH v2 1/6] include/hw/virtio: make some VirtIODevice const Hawkins Jiawei
@ 2023-06-01  8:48 ` Hawkins Jiawei
  2023-06-01  8:48 ` [PATCH v2 3/6] hw/net/virtio-net: make some VirtIONet const Hawkins Jiawei
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Hawkins Jiawei @ 2023-06-01  8:48 UTC (permalink / raw)
  To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149

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

Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
---
 net/vhost-vdpa.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 37cdc84562..e907a3c792 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -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



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 3/6] hw/net/virtio-net: make some VirtIONet const
  2023-06-01  8:28 [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
  2023-06-01  8:48 ` [PATCH v2 1/6] include/hw/virtio: make some VirtIODevice const Hawkins Jiawei
  2023-06-01  8:48 ` [PATCH v2 2/6] vdpa: reuse virtio_vdev_has_feature() Hawkins Jiawei
@ 2023-06-01  8:48 ` Hawkins Jiawei
  2023-06-01  8:48 ` [PATCH v2 4/6] virtio-net: expose virtio_net_supported_guest_offloads() Hawkins Jiawei
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Hawkins Jiawei @ 2023-06-01  8:48 UTC (permalink / raw)
  To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149

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

Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
---
 hw/net/virtio-net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 6df6b7329d..7b27dad6c4 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -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



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 4/6] virtio-net: expose virtio_net_supported_guest_offloads()
  2023-06-01  8:28 [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
                   ` (2 preceding siblings ...)
  2023-06-01  8:48 ` [PATCH v2 3/6] hw/net/virtio-net: make some VirtIONet const Hawkins Jiawei
@ 2023-06-01  8:48 ` Hawkins Jiawei
  2023-06-01  9:05   ` Hawkins Jiawei
  2023-06-01  8:48 ` [PATCH v2 5/6] vdpa: Add vhost_vdpa_net_load_offloads() Hawkins Jiawei
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Hawkins Jiawei @ 2023-06-01  8:48 UTC (permalink / raw)
  To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149

To support restoring offloads state in vdpa, need to expose
the function virtio_net_supported_guest_offloads(), then vdpa
uses this function to get the guest supported offloads.

Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
---
 hw/net/virtio-net.c            | 2 +-
 include/hw/virtio/virtio-net.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 7b27dad6c4..7e8897a8bc 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -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);
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index ef234ffe7e..5f5dcb4572 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -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



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 5/6] vdpa: Add vhost_vdpa_net_load_offloads()
  2023-06-01  8:28 [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
                   ` (3 preceding siblings ...)
  2023-06-01  8:48 ` [PATCH v2 4/6] virtio-net: expose virtio_net_supported_guest_offloads() Hawkins Jiawei
@ 2023-06-01  8:48 ` Hawkins Jiawei
  2023-06-01  8:48 ` [PATCH v2 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ Hawkins Jiawei
  2023-06-01  9:56 ` [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Lei Yang
  6 siblings, 0 replies; 13+ messages in thread
From: Hawkins Jiawei @ 2023-06-01  8:48 UTC (permalink / raw)
  To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149

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

Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
---
 net/vhost-vdpa.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index e907a3c792..0e647886d1 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -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;
 }
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ
  2023-06-01  8:28 [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
                   ` (4 preceding siblings ...)
  2023-06-01  8:48 ` [PATCH v2 5/6] vdpa: Add vhost_vdpa_net_load_offloads() Hawkins Jiawei
@ 2023-06-01  8:48 ` Hawkins Jiawei
  2023-06-01  9:56 ` [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Lei Yang
  6 siblings, 0 replies; 13+ messages in thread
From: Hawkins Jiawei @ 2023-06-01  8:48 UTC (permalink / raw)
  To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149

Enable SVQ with VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature.

Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
Acked-by: Jason Wang <jasowang@redhat.com>
---
 net/vhost-vdpa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 0e647886d1..4cc24a2997 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -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



^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/6] virtio-net: expose virtio_net_supported_guest_offloads()
  2023-06-01  8:48 ` [PATCH v2 4/6] virtio-net: expose virtio_net_supported_guest_offloads() Hawkins Jiawei
@ 2023-06-01  9:05   ` Hawkins Jiawei
  2023-06-01 13:43     ` Eugenio Perez Martin
  0 siblings, 1 reply; 13+ messages in thread
From: Hawkins Jiawei @ 2023-06-01  9:05 UTC (permalink / raw)
  To: jasowang, mst, eperezma; +Cc: qemu-devel

On Thu, 1 Jun 2023 at 16:48, Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> To support restoring offloads state in vdpa, need to expose
> the function virtio_net_supported_guest_offloads(), then vdpa
> uses this function to get the guest supported offloads.

Here it should be changed to "then QEMU uses this function
to get the guest supported offloads.". I will correct the commit
message in the v3 patch.

Thanks!

>
> Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
> ---
>  hw/net/virtio-net.c            | 2 +-
>  include/hw/virtio/virtio-net.h | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 7b27dad6c4..7e8897a8bc 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -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);
> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> index ef234ffe7e..5f5dcb4572 100644
> --- a/include/hw/virtio/virtio-net.h
> +++ b/include/hw/virtio/virtio-net.h
> @@ -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
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support
  2023-06-01  8:28 [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
                   ` (5 preceding siblings ...)
  2023-06-01  8:48 ` [PATCH v2 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ Hawkins Jiawei
@ 2023-06-01  9:56 ` Lei Yang
  2023-06-01 13:41   ` Hawkins Jiawei
  6 siblings, 1 reply; 13+ messages in thread
From: Lei Yang @ 2023-06-01  9:56 UTC (permalink / raw)
  To: Hawkins Jiawei; +Cc: jasowang, mst, eperezma, qemu-devel

I'm a QE responsible for vhost_vdpa parts. Could you please provide me
with the test steps for this series? I can test it in my environment
and update the test results.





On Thu, Jun 1, 2023 at 4:29 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> 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
> =========
> v2:
>   - make some function arguments const
>   - reuse virtio_vdev_has_feature() suggested by Eugenio and Jason
>   - avoid sending CVQ command in default state suggested by Eugenio
>
> v1: https://lore.kernel.org/all/cover.1685359572.git.yin31149@gmail.com/
>
> 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
>
>



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support
  2023-06-01  9:56 ` [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Lei Yang
@ 2023-06-01 13:41   ` Hawkins Jiawei
  0 siblings, 0 replies; 13+ messages in thread
From: Hawkins Jiawei @ 2023-06-01 13:41 UTC (permalink / raw)
  To: Lei Yang; +Cc: jasowang, mst, eperezma, qemu-devel

On 2023/6/1 17:56, Lei Yang wrote:
> I'm a QE responsible for vhost_vdpa parts. Could you please provide me
> with the test steps for this series? I can test it in my environment
> and update the test results.
>

Hi Lei,

I am not sure if these are enough, but you can test it like this:

1. you can merge these patches into the latest master branch and compile the
source. It should not trigger any error or warning.

2. start QEMU with the vdpa device and enable the ctrl_guest_offloads
feature on. The command line should like the following:
        -netdev type=vhost-vdpa,id=vdpa0,vhostdev=/dev/vhost-vdpa-0,x-svq=true \
        -device virtio-net-pci,netdev=vdpa0,ctrl_guest_offloads=on,...

It should also not trigger any error or warning. Without this series,
QEMU should fail with "vdpa svq does not work with features 4" error.

Regarding migration, it seems that testing it is not feasible at the
moment due to the migration blocker.

And you can test on my v3 patch, I will send the v3 patch to the mailing
lists later.

Thank you for your efforts!


>
>
>
>
> On Thu, Jun 1, 2023 at 4:29 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>>
>> 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
>> =========
>> v2:
>>    - make some function arguments const
>>    - reuse virtio_vdev_has_feature() suggested by Eugenio and Jason
>>    - avoid sending CVQ command in default state suggested by Eugenio
>>
>> v1: https://lore.kernel.org/all/cover.1685359572.git.yin31149@gmail.com/
>>
>> 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
>>
>>
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/6] virtio-net: expose virtio_net_supported_guest_offloads()
  2023-06-01  9:05   ` Hawkins Jiawei
@ 2023-06-01 13:43     ` Eugenio Perez Martin
  2023-06-01 13:58       ` Hawkins Jiawei
  0 siblings, 1 reply; 13+ messages in thread
From: Eugenio Perez Martin @ 2023-06-01 13:43 UTC (permalink / raw)
  To: Hawkins Jiawei; +Cc: jasowang, mst, qemu-devel

On Thu, Jun 1, 2023 at 11:05 AM Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> On Thu, 1 Jun 2023 at 16:48, Hawkins Jiawei <yin31149@gmail.com> wrote:
> >
> > To support restoring offloads state in vdpa, need to expose
> > the function virtio_net_supported_guest_offloads(), then vdpa
> > uses this function to get the guest supported offloads.
>
> Here it should be changed to "then QEMU uses this function
> to get the guest supported offloads.". I will correct the commit
> message in the v3 patch.
>

Maybe "to get the device supported offloads allow qemu to know the
defaults, so it can skip the control message sending if they match
with the driver's configuration"?

We can also add "This will be the default at guest's startup, these
values can mismatch only at live migration".

What do you think?

Thanks!

> Thanks!
>
> >
> > Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
> > ---
> >  hw/net/virtio-net.c            | 2 +-
> >  include/hw/virtio/virtio-net.h | 1 +
> >  2 files changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index 7b27dad6c4..7e8897a8bc 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -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);
> > diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> > index ef234ffe7e..5f5dcb4572 100644
> > --- a/include/hw/virtio/virtio-net.h
> > +++ b/include/hw/virtio/virtio-net.h
> > @@ -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
> >
>



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/6] virtio-net: expose virtio_net_supported_guest_offloads()
  2023-06-01 13:43     ` Eugenio Perez Martin
@ 2023-06-01 13:58       ` Hawkins Jiawei
  2023-06-01 14:37         ` Eugenio Perez Martin
  0 siblings, 1 reply; 13+ messages in thread
From: Hawkins Jiawei @ 2023-06-01 13:58 UTC (permalink / raw)
  To: Eugenio Perez Martin; +Cc: jasowang, mst, qemu-devel

On 2023/6/1 21:43, Eugenio Perez Martin wrote:
> On Thu, Jun 1, 2023 at 11:05 AM Hawkins Jiawei <yin31149@gmail.com> wrote:
>>
>> On Thu, 1 Jun 2023 at 16:48, Hawkins Jiawei <yin31149@gmail.com> wrote:
>>>
>>> To support restoring offloads state in vdpa, need to expose
>>> the function virtio_net_supported_guest_offloads(), then vdpa
>>> uses this function to get the guest supported offloads.
>>
>> Here it should be changed to "then QEMU uses this function
>> to get the guest supported offloads.". I will correct the commit
>> message in the v3 patch.
>>
>
> Maybe "to get the device supported offloads allow qemu to know the
> defaults, so it can skip the control message sending if they match
> with the driver's configuration"?
>
> We can also add "This will be the default at guest's startup, these
> values can mismatch only at live migration".

Hi Eugenio,

I sent the v3 patch before seeing this email:(.

I refactor the commit message to
"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." in v3 patch.

Do you think there is still some refactoring needed here?

Thanks!


>
> What do you think?
>
> Thanks!
>
>> Thanks!
>>
>>>
>>> Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
>>> ---
>>>   hw/net/virtio-net.c            | 2 +-
>>>   include/hw/virtio/virtio-net.h | 1 +
>>>   2 files changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
>>> index 7b27dad6c4..7e8897a8bc 100644
>>> --- a/hw/net/virtio-net.c
>>> +++ b/hw/net/virtio-net.c
>>> @@ -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);
>>> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
>>> index ef234ffe7e..5f5dcb4572 100644
>>> --- a/include/hw/virtio/virtio-net.h
>>> +++ b/include/hw/virtio/virtio-net.h
>>> @@ -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
>>>
>>
>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/6] virtio-net: expose virtio_net_supported_guest_offloads()
  2023-06-01 13:58       ` Hawkins Jiawei
@ 2023-06-01 14:37         ` Eugenio Perez Martin
  0 siblings, 0 replies; 13+ messages in thread
From: Eugenio Perez Martin @ 2023-06-01 14:37 UTC (permalink / raw)
  To: Hawkins Jiawei; +Cc: jasowang, mst, qemu-devel

On Thu, Jun 1, 2023 at 3:59 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> On 2023/6/1 21:43, Eugenio Perez Martin wrote:
> > On Thu, Jun 1, 2023 at 11:05 AM Hawkins Jiawei <yin31149@gmail.com> wrote:
> >>
> >> On Thu, 1 Jun 2023 at 16:48, Hawkins Jiawei <yin31149@gmail.com> wrote:
> >>>
> >>> To support restoring offloads state in vdpa, need to expose
> >>> the function virtio_net_supported_guest_offloads(), then vdpa
> >>> uses this function to get the guest supported offloads.
> >>
> >> Here it should be changed to "then QEMU uses this function
> >> to get the guest supported offloads.". I will correct the commit
> >> message in the v3 patch.
> >>
> >
> > Maybe "to get the device supported offloads allow qemu to know the
> > defaults, so it can skip the control message sending if they match
> > with the driver's configuration"?
> >
> > We can also add "This will be the default at guest's startup, these
> > values can mismatch only at live migration".
>
> Hi Eugenio,
>
> I sent the v3 patch before seeing this email:(.
>

Moving the discussion to v3 then :).

Thanks!

> I refactor the commit message to
> "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." in v3 patch.
>
> Do you think there is still some refactoring needed here?
>
> Thanks!
>
>
> >
> > What do you think?
> >
> > Thanks!
> >
> >> Thanks!
> >>
> >>>
> >>> Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
> >>> ---
> >>>   hw/net/virtio-net.c            | 2 +-
> >>>   include/hw/virtio/virtio-net.h | 1 +
> >>>   2 files changed, 2 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> >>> index 7b27dad6c4..7e8897a8bc 100644
> >>> --- a/hw/net/virtio-net.c
> >>> +++ b/hw/net/virtio-net.c
> >>> @@ -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);
> >>> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> >>> index ef234ffe7e..5f5dcb4572 100644
> >>> --- a/include/hw/virtio/virtio-net.h
> >>> +++ b/include/hw/virtio/virtio-net.h
> >>> @@ -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
> >>>
> >>
> >
>



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-06-01 14:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01  8:28 [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
2023-06-01  8:48 ` [PATCH v2 1/6] include/hw/virtio: make some VirtIODevice const Hawkins Jiawei
2023-06-01  8:48 ` [PATCH v2 2/6] vdpa: reuse virtio_vdev_has_feature() Hawkins Jiawei
2023-06-01  8:48 ` [PATCH v2 3/6] hw/net/virtio-net: make some VirtIONet const Hawkins Jiawei
2023-06-01  8:48 ` [PATCH v2 4/6] virtio-net: expose virtio_net_supported_guest_offloads() Hawkins Jiawei
2023-06-01  9:05   ` Hawkins Jiawei
2023-06-01 13:43     ` Eugenio Perez Martin
2023-06-01 13:58       ` Hawkins Jiawei
2023-06-01 14:37         ` Eugenio Perez Martin
2023-06-01  8:48 ` [PATCH v2 5/6] vdpa: Add vhost_vdpa_net_load_offloads() Hawkins Jiawei
2023-06-01  8:48 ` [PATCH v2 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ Hawkins Jiawei
2023-06-01  9:56 ` [PATCH v2 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Lei Yang
2023-06-01 13:41   ` Hawkins Jiawei

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).