* [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support
@ 2023-06-01 13:48 Hawkins Jiawei
2023-06-01 13:48 ` [PATCH v3 1/6] include/hw/virtio: make some VirtIODevice const Hawkins Jiawei
` (6 more replies)
0 siblings, 7 replies; 17+ messages in thread
From: Hawkins Jiawei @ 2023-06-01 13:48 UTC (permalink / raw)
To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149, 18801353760
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
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 1/6] include/hw/virtio: make some VirtIODevice const
2023-06-01 13:48 [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
@ 2023-06-01 13:48 ` Hawkins Jiawei
2023-06-01 14:14 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 2/6] vdpa: reuse virtio_vdev_has_feature() Hawkins Jiawei
` (5 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Hawkins Jiawei @ 2023-06-01 13:48 UTC (permalink / raw)
To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149, 18801353760
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] 17+ messages in thread
* [PATCH v3 2/6] vdpa: reuse virtio_vdev_has_feature()
2023-06-01 13:48 [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
2023-06-01 13:48 ` [PATCH v3 1/6] include/hw/virtio: make some VirtIODevice const Hawkins Jiawei
@ 2023-06-01 13:48 ` Hawkins Jiawei
2023-06-01 14:14 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 3/6] hw/net/virtio-net: make some VirtIONet const Hawkins Jiawei
` (4 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Hawkins Jiawei @ 2023-06-01 13:48 UTC (permalink / raw)
To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149, 18801353760
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] 17+ messages in thread
* [PATCH v3 3/6] hw/net/virtio-net: make some VirtIONet const
2023-06-01 13:48 [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
2023-06-01 13:48 ` [PATCH v3 1/6] include/hw/virtio: make some VirtIODevice const Hawkins Jiawei
2023-06-01 13:48 ` [PATCH v3 2/6] vdpa: reuse virtio_vdev_has_feature() Hawkins Jiawei
@ 2023-06-01 13:48 ` Hawkins Jiawei
2023-06-01 14:15 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 4/6] virtio-net: expose virtio_net_supported_guest_offloads() Hawkins Jiawei
` (3 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Hawkins Jiawei @ 2023-06-01 13:48 UTC (permalink / raw)
To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149, 18801353760
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] 17+ messages in thread
* [PATCH v3 4/6] virtio-net: expose virtio_net_supported_guest_offloads()
2023-06-01 13:48 [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
` (2 preceding siblings ...)
2023-06-01 13:48 ` [PATCH v3 3/6] hw/net/virtio-net: make some VirtIONet const Hawkins Jiawei
@ 2023-06-01 13:48 ` Hawkins Jiawei
2023-06-01 14:37 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads() Hawkins Jiawei
` (2 subsequent siblings)
6 siblings, 1 reply; 17+ messages in thread
From: Hawkins Jiawei @ 2023-06-01 13:48 UTC (permalink / raw)
To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149, 18801353760
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.
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] 17+ messages in thread
* [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads()
2023-06-01 13:48 [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
` (3 preceding siblings ...)
2023-06-01 13:48 ` [PATCH v3 4/6] virtio-net: expose virtio_net_supported_guest_offloads() Hawkins Jiawei
@ 2023-06-01 13:48 ` Hawkins Jiawei
2023-06-01 14:12 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ Hawkins Jiawei
2023-06-02 11:25 ` [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Lei Yang
6 siblings, 1 reply; 17+ messages in thread
From: Hawkins Jiawei @ 2023-06-01 13:48 UTC (permalink / raw)
To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149, 18801353760
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] 17+ messages in thread
* [PATCH v3 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ
2023-06-01 13:48 [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
` (4 preceding siblings ...)
2023-06-01 13:48 ` [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads() Hawkins Jiawei
@ 2023-06-01 13:48 ` Hawkins Jiawei
2023-06-01 14:18 ` Eugenio Perez Martin
2023-06-02 11:25 ` [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Lei Yang
6 siblings, 1 reply; 17+ messages in thread
From: Hawkins Jiawei @ 2023-06-01 13:48 UTC (permalink / raw)
To: jasowang, mst, eperezma; +Cc: qemu-devel, yin31149, 18801353760
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] 17+ messages in thread
* Re: [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads()
2023-06-01 13:48 ` [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads() Hawkins Jiawei
@ 2023-06-01 14:12 ` Eugenio Perez Martin
2023-06-02 7:30 ` Hawkins Jiawei
0 siblings, 1 reply; 17+ messages in thread
From: Eugenio Perez Martin @ 2023-06-01 14:12 UTC (permalink / raw)
To: Hawkins Jiawei; +Cc: jasowang, mst, qemu-devel, 18801353760
On Thu, Jun 1, 2023 at 3:49 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> 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);
n->curr_guest_offloads is already stored in CPU order, we should only
byte-swap it by the time of sending.
Thanks!
> +
> + 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 [flat|nested] 17+ messages in thread
* Re: [PATCH v3 1/6] include/hw/virtio: make some VirtIODevice const
2023-06-01 13:48 ` [PATCH v3 1/6] include/hw/virtio: make some VirtIODevice const Hawkins Jiawei
@ 2023-06-01 14:14 ` Eugenio Perez Martin
0 siblings, 0 replies; 17+ messages in thread
From: Eugenio Perez Martin @ 2023-06-01 14:14 UTC (permalink / raw)
To: Hawkins Jiawei; +Cc: jasowang, mst, qemu-devel, 18801353760
On Thu, Jun 1, 2023 at 3:49 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> 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>
Reviewed-by: Eugenio Pérez Martin <eperezma@redhat.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 [flat|nested] 17+ messages in thread
* Re: [PATCH v3 2/6] vdpa: reuse virtio_vdev_has_feature()
2023-06-01 13:48 ` [PATCH v3 2/6] vdpa: reuse virtio_vdev_has_feature() Hawkins Jiawei
@ 2023-06-01 14:14 ` Eugenio Perez Martin
0 siblings, 0 replies; 17+ messages in thread
From: Eugenio Perez Martin @ 2023-06-01 14:14 UTC (permalink / raw)
To: Hawkins Jiawei; +Cc: jasowang, mst, qemu-devel, 18801353760
On Thu, Jun 1, 2023 at 3:49 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> We can use virtio_vdev_has_feature() instead of manually
> accessing the features.
>
> Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
Acked-by: Eugenio Pérez <eperezma@redhat.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 [flat|nested] 17+ messages in thread
* Re: [PATCH v3 3/6] hw/net/virtio-net: make some VirtIONet const
2023-06-01 13:48 ` [PATCH v3 3/6] hw/net/virtio-net: make some VirtIONet const Hawkins Jiawei
@ 2023-06-01 14:15 ` Eugenio Perez Martin
0 siblings, 0 replies; 17+ messages in thread
From: Eugenio Perez Martin @ 2023-06-01 14:15 UTC (permalink / raw)
To: Hawkins Jiawei; +Cc: jasowang, mst, qemu-devel, 18801353760
On Thu, Jun 1, 2023 at 3:49 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> 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>
Reviewed-by: Eugenio Pérez <eperezma@redhat.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 [flat|nested] 17+ messages in thread
* Re: [PATCH v3 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ
2023-06-01 13:48 ` [PATCH v3 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ Hawkins Jiawei
@ 2023-06-01 14:18 ` Eugenio Perez Martin
0 siblings, 0 replies; 17+ messages in thread
From: Eugenio Perez Martin @ 2023-06-01 14:18 UTC (permalink / raw)
To: Hawkins Jiawei; +Cc: jasowang, mst, qemu-devel, 18801353760
On Thu, Jun 1, 2023 at 3:50 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> 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>
Acked-by: Eugenio Pérez <eperezma@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 [flat|nested] 17+ messages in thread
* Re: [PATCH v3 4/6] virtio-net: expose virtio_net_supported_guest_offloads()
2023-06-01 13:48 ` [PATCH v3 4/6] virtio-net: expose virtio_net_supported_guest_offloads() Hawkins Jiawei
@ 2023-06-01 14:37 ` Eugenio Perez Martin
2023-06-02 5:59 ` Hawkins Jiawei
0 siblings, 1 reply; 17+ messages in thread
From: Eugenio Perez Martin @ 2023-06-01 14:37 UTC (permalink / raw)
To: Hawkins Jiawei; +Cc: jasowang, mst, qemu-devel, 18801353760
On Thu, Jun 1, 2023 at 3:49 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>
> 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?
> 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!
> 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] 17+ messages in thread
* Re: [PATCH v3 4/6] virtio-net: expose virtio_net_supported_guest_offloads()
2023-06-01 14:37 ` Eugenio Perez Martin
@ 2023-06-02 5:59 ` Hawkins Jiawei
0 siblings, 0 replies; 17+ messages in thread
From: Hawkins Jiawei @ 2023-06-02 5:59 UTC (permalink / raw)
To: Eugenio Perez Martin; +Cc: jasowang, mst, qemu-devel, 18801353760
On 2023/6/1 22:37, Eugenio Perez Martin wrote:
> On Thu, Jun 1, 2023 at 3:49 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>>
>> 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.
>
>> 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.
I will add these messages in the v4 patch.
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] 17+ messages in thread
* Re: [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads()
2023-06-01 14:12 ` Eugenio Perez Martin
@ 2023-06-02 7:30 ` Hawkins Jiawei
0 siblings, 0 replies; 17+ messages in thread
From: Hawkins Jiawei @ 2023-06-02 7:30 UTC (permalink / raw)
To: Eugenio Perez Martin; +Cc: jasowang, mst, qemu-devel, 18801353760
On 2023/6/1 22:12, Eugenio Perez Martin wrote:
> On Thu, Jun 1, 2023 at 3:49 PM Hawkins Jiawei <yin31149@gmail.com> wrote:
>>
>> 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);
>
> 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!
>
> Thanks!
>
>> +
>> + 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 [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support
2023-06-01 13:48 [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
` (5 preceding siblings ...)
2023-06-01 13:48 ` [PATCH v3 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ Hawkins Jiawei
@ 2023-06-02 11:25 ` Lei Yang
2023-06-02 12:05 ` Hawkins Jiawei
6 siblings, 1 reply; 17+ messages in thread
From: Lei Yang @ 2023-06-02 11:25 UTC (permalink / raw)
To: Hawkins Jiawei; +Cc: jasowang, mst, eperezma, qemu-devel, 18801353760
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 \
Tested-by: Lei Yang <leiyang@redhat.com>
On Thu, Jun 1, 2023 at 9:49 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
> =========
> 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
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support
2023-06-02 11:25 ` [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Lei Yang
@ 2023-06-02 12:05 ` Hawkins Jiawei
0 siblings, 0 replies; 17+ messages in thread
From: Hawkins Jiawei @ 2023-06-02 12:05 UTC (permalink / raw)
To: Lei Yang; +Cc: jasowang, mst, eperezma, qemu-devel, 18801353760
On Fri, 2 Jun 2023 at 19:26, Lei Yang <leiyang@redhat.com> wrote:
>
> 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 \
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!
>
> Tested-by: Lei Yang <leiyang@redhat.com>
>
>
>
>
> On Thu, Jun 1, 2023 at 9:49 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
> > =========
> > 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
> >
> >
>
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2023-06-02 12:06 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01 13:48 [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Hawkins Jiawei
2023-06-01 13:48 ` [PATCH v3 1/6] include/hw/virtio: make some VirtIODevice const Hawkins Jiawei
2023-06-01 14:14 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 2/6] vdpa: reuse virtio_vdev_has_feature() Hawkins Jiawei
2023-06-01 14:14 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 3/6] hw/net/virtio-net: make some VirtIONet const Hawkins Jiawei
2023-06-01 14:15 ` Eugenio Perez Martin
2023-06-01 13:48 ` [PATCH v3 4/6] virtio-net: expose virtio_net_supported_guest_offloads() Hawkins Jiawei
2023-06-01 14:37 ` Eugenio Perez Martin
2023-06-02 5:59 ` Hawkins Jiawei
2023-06-01 13:48 ` [PATCH v3 5/6] vdpa: Add vhost_vdpa_net_load_offloads() Hawkins Jiawei
2023-06-01 14:12 ` Eugenio Perez Martin
2023-06-02 7:30 ` Hawkins Jiawei
2023-06-01 13:48 ` [PATCH v3 6/6] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ Hawkins Jiawei
2023-06-01 14:18 ` Eugenio Perez Martin
2023-06-02 11:25 ` [PATCH v3 0/6] Vhost-vdpa Shadow Virtqueue Offloads support Lei Yang
2023-06-02 12:05 ` 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).