|
|
586cba |
From e1f9986cf77e4b2f16aca7b2523bc75bae0c4d3c Mon Sep 17 00:00:00 2001
|
|
|
586cba |
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
|
|
|
586cba |
Date: Tue, 23 Aug 2022 20:30:36 +0200
|
|
|
586cba |
Subject: [PATCH 21/23] vdpa: Add virtio-net mac address via CVQ at start
|
|
|
586cba |
MIME-Version: 1.0
|
|
|
586cba |
Content-Type: text/plain; charset=UTF-8
|
|
|
586cba |
Content-Transfer-Encoding: 8bit
|
|
|
586cba |
|
|
|
586cba |
RH-Author: Eugenio Pérez <eperezma@redhat.com>
|
|
|
586cba |
RH-MergeRequest: 116: vdpa: Restore device state on destination
|
|
|
586cba |
RH-Bugzilla: 2114060
|
|
|
586cba |
RH-Acked-by: Cindy Lu <lulu@redhat.com>
|
|
|
586cba |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
586cba |
RH-Commit: [20/21] a7920816d5faf7a0cfbb7c2731a48ddfc456b8d4 (eperezmartin/qemu-kvm)
|
|
|
586cba |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2114060
|
|
|
586cba |
Upstream status: git@github.com:jasowang/qemu.git net-next
|
|
|
586cba |
|
|
|
586cba |
This is needed so the destination vdpa device see the same state a the
|
|
|
586cba |
guest set in the source.
|
|
|
586cba |
|
|
|
586cba |
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
|
|
586cba |
Acked-by: Jason Wang <jasowang@redhat.com>
|
|
|
586cba |
Signed-off-by: Jason Wang <jasowang@redhat.com>
|
|
|
586cba |
(cherry picked from commit f34cd09b13855657a0d49c5ea6a1e37ba9dc2334)
|
|
|
586cba |
---
|
|
|
586cba |
net/vhost-vdpa.c | 40 ++++++++++++++++++++++++++++++++++++++++
|
|
|
586cba |
1 file changed, 40 insertions(+)
|
|
|
586cba |
|
|
|
586cba |
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
|
|
|
586cba |
index f09f044ec1..79ebda7de1 100644
|
|
|
586cba |
--- a/net/vhost-vdpa.c
|
|
|
586cba |
+++ b/net/vhost-vdpa.c
|
|
|
586cba |
@@ -363,11 +363,51 @@ static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s, size_t out_len,
|
|
|
586cba |
return vhost_svq_poll(svq);
|
|
|
586cba |
}
|
|
|
586cba |
|
|
|
586cba |
+static int vhost_vdpa_net_load(NetClientState *nc)
|
|
|
586cba |
+{
|
|
|
586cba |
+ VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
|
|
|
586cba |
+ const struct vhost_vdpa *v = &s->vhost_vdpa;
|
|
|
586cba |
+ const VirtIONet *n;
|
|
|
586cba |
+ uint64_t features;
|
|
|
586cba |
+
|
|
|
586cba |
+ assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
|
|
|
586cba |
+
|
|
|
586cba |
+ if (!v->shadow_vqs_enabled) {
|
|
|
586cba |
+ return 0;
|
|
|
586cba |
+ }
|
|
|
586cba |
+
|
|
|
586cba |
+ n = VIRTIO_NET(v->dev->vdev);
|
|
|
586cba |
+ features = n->parent_obj.guest_features;
|
|
|
586cba |
+ if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) {
|
|
|
586cba |
+ const struct virtio_net_ctrl_hdr ctrl = {
|
|
|
586cba |
+ .class = VIRTIO_NET_CTRL_MAC,
|
|
|
586cba |
+ .cmd = VIRTIO_NET_CTRL_MAC_ADDR_SET,
|
|
|
586cba |
+ };
|
|
|
586cba |
+ char *cursor = s->cvq_cmd_out_buffer;
|
|
|
586cba |
+ ssize_t dev_written;
|
|
|
586cba |
+
|
|
|
586cba |
+ memcpy(cursor, &ctrl, sizeof(ctrl));
|
|
|
586cba |
+ cursor += sizeof(ctrl);
|
|
|
586cba |
+ memcpy(cursor, n->mac, sizeof(n->mac));
|
|
|
586cba |
+
|
|
|
586cba |
+ dev_written = vhost_vdpa_net_cvq_add(s, sizeof(ctrl) + sizeof(n->mac),
|
|
|
586cba |
+ sizeof(virtio_net_ctrl_ack));
|
|
|
586cba |
+ if (unlikely(dev_written < 0)) {
|
|
|
586cba |
+ return dev_written;
|
|
|
586cba |
+ }
|
|
|
586cba |
+
|
|
|
586cba |
+ return *((virtio_net_ctrl_ack *)s->cvq_cmd_in_buffer) != VIRTIO_NET_OK;
|
|
|
586cba |
+ }
|
|
|
586cba |
+
|
|
|
586cba |
+ return 0;
|
|
|
586cba |
+}
|
|
|
586cba |
+
|
|
|
586cba |
static NetClientInfo net_vhost_vdpa_cvq_info = {
|
|
|
586cba |
.type = NET_CLIENT_DRIVER_VHOST_VDPA,
|
|
|
586cba |
.size = sizeof(VhostVDPAState),
|
|
|
586cba |
.receive = vhost_vdpa_receive,
|
|
|
586cba |
.start = vhost_vdpa_net_cvq_start,
|
|
|
586cba |
+ .load = vhost_vdpa_net_load,
|
|
|
586cba |
.stop = vhost_vdpa_net_cvq_stop,
|
|
|
586cba |
.cleanup = vhost_vdpa_cleanup,
|
|
|
586cba |
.has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
|
|
|
586cba |
--
|
|
|
586cba |
2.31.1
|
|
|
586cba |
|