[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 41/53] vdpa: Add vhost_vdpa_net_load_offloads()
From: |
Michael S. Tsirkin |
Subject: |
[PULL 41/53] vdpa: Add vhost_vdpa_net_load_offloads() |
Date: |
Mon, 26 Jun 2023 08:29:51 -0400 |
From: Hawkins Jiawei <yin31149@gmail.com>
This patch introduces vhost_vdpa_net_load_offloads() to
restore offloads state at device's startup.
Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
Message-Id:
<7e2b5cad9c48c917df53d80dec27dbfeb513e1a3.1685704856.git.yin31149@gmail.com>
Tested-by: Lei Yang <leiyang@redhat.com>
Reviewed-by: Eugenio Pérez <eperezma@redhat.com>
Tested-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
net/vhost-vdpa.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index c3ef0139a6..99d0445d90 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -664,6 +664,44 @@ 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;
+ }
+
+ if (n->curr_guest_offloads == virtio_net_supported_guest_offloads(n)) {
+ /*
+ * According to VirtIO standard, "Upon feature negotiation
+ * corresponding offload gets enabled to preserve
+ * backward compatibility.".
+ *
+ * Therefore, there is no need to send this CVQ command if the
+ * driver also enables all supported offloads, which aligns with
+ * the device's defaults.
+ *
+ * Note that the device's defaults can mismatch the driver's
+ * configuration only at live migration.
+ */
+ return 0;
+ }
+
+ offloads = cpu_to_le64(n->curr_guest_offloads);
+ 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);
@@ -686,6 +724,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;
}
--
MST
- [PULL 37/53] include/hw/virtio: make some VirtIODevice const, (continued)
- [PULL 37/53] include/hw/virtio: make some VirtIODevice const, Michael S. Tsirkin, 2023/06/26
- [PULL 21/53] hw/virtio: Remove unnecessary 'virtio-access.h' header, Michael S. Tsirkin, 2023/06/26
- [PULL 26/53] virtio-mem: Simplify bitmap handling and virtio_mem_set_block_state(), Michael S. Tsirkin, 2023/06/26
- [PULL 28/53] vdpa: move CVQ isolation check to net_init_vhost_vdpa, Michael S. Tsirkin, 2023/06/26
- [PULL 29/53] cryptodev: fix memory leak during stats query, Michael S. Tsirkin, 2023/06/26
- [PULL 31/53] hw/i386/pc: Default to use SMBIOS 3.0 for newer machine models, Michael S. Tsirkin, 2023/06/26
- [PULL 17/53] hw/virtio: Introduce VHOST_VSOCK_COMMON symbol in Kconfig, Michael S. Tsirkin, 2023/06/26
- [PULL 19/53] hw/virtio/vhost-vsock: Include missing 'virtio/virtio-bus.h' header, Michael S. Tsirkin, 2023/06/26
- [PULL 33/53] pc: q35: Bump max_cpus to 1024, Michael S. Tsirkin, 2023/06/26
- [PULL 41/53] vdpa: Add vhost_vdpa_net_load_offloads(),
Michael S. Tsirkin <=
- [PULL 42/53] vdpa: Allow VIRTIO_NET_F_CTRL_GUEST_OFFLOADS in SVQ, Michael S. Tsirkin, 2023/06/26
- [PULL 48/53] vhost-user: fully use new backend/frontend naming, Michael S. Tsirkin, 2023/06/26
- [PULL 51/53] intel_iommu: Fix address space unmap, Michael S. Tsirkin, 2023/06/26
- [PULL 34/53] vdpa: do not block migration if device has cvq and x-svq=on, Michael S. Tsirkin, 2023/06/26
- [PULL 39/53] hw/net/virtio-net: make some VirtIONet const, Michael S. Tsirkin, 2023/06/26
- [PULL 40/53] virtio-net: expose virtio_net_supported_guest_offloads(), Michael S. Tsirkin, 2023/06/26
- [PULL 46/53] hw/i386/pc: Clean up pc_machine_initfn, Michael S. Tsirkin, 2023/06/26
- [PULL 52/53] vhost_net: add an assertion for TAP client backends, Michael S. Tsirkin, 2023/06/26