thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ed5979
From 2b8e3409edb8a17d89c3829cfa3d92bdfdd43c53 Mon Sep 17 00:00:00 2001
ed5979
From: Cindy Lu <lulu@redhat.com>
ed5979
Date: Thu, 22 Dec 2022 15:04:49 +0800
ed5979
Subject: [PATCH 08/31] virtio-net: add support for configure interrupt
ed5979
MIME-Version: 1.0
ed5979
Content-Type: text/plain; charset=UTF-8
ed5979
Content-Transfer-Encoding: 8bit
ed5979
ed5979
RH-Author: Cindy Lu <lulu@redhat.com>
ed5979
RH-MergeRequest: 132: vhost-vdpa: support config interrupt in vhost-vdpa
ed5979
RH-Bugzilla: 1905805
ed5979
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
ed5979
RH-Acked-by: Eugenio PĂ©rez <eperezma@redhat.com>
ed5979
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
ed5979
RH-Commit: [8/10] 1b125169bea6c81c508b154fa1bae68af153b312 (lulu6/qemu-kvm3)
ed5979
ed5979
https://bugzilla.redhat.com/show_bug.cgi?id=1905805
ed5979
Add functions to support configure interrupt in virtio_net
ed5979
Add the functions to support vhost_net_config_pending
ed5979
and vhost_net_config_mask.
ed5979
ed5979
Signed-off-by: Cindy Lu <lulu@redhat.com>
ed5979
Message-Id: <20221222070451.936503-9-lulu@redhat.com>
ed5979
Acked-by: Jason Wang <jasowang@redhat.com>
ed5979
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
ed5979
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
ed5979
(cherry picked from commit 8aab0d1dbe90c7b5ac6672a1a09b0578178f5f4c)
ed5979
Signed-off-by: Cindy Lu <lulu@redhat.com>
ed5979
---
ed5979
 hw/net/vhost_net-stub.c | 9 +++++++++
ed5979
 hw/net/vhost_net.c      | 9 +++++++++
ed5979
 hw/net/virtio-net.c     | 4 ++--
ed5979
 include/net/vhost_net.h | 2 ++
ed5979
 4 files changed, 22 insertions(+), 2 deletions(-)
ed5979
ed5979
diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c
ed5979
index 9f7daae99c..c36f258201 100644
ed5979
--- a/hw/net/vhost_net-stub.c
ed5979
+++ b/hw/net/vhost_net-stub.c
ed5979
@@ -82,6 +82,15 @@ void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
ed5979
 {
ed5979
 }
ed5979
 
ed5979
+bool vhost_net_config_pending(VHostNetState *net)
ed5979
+{
ed5979
+    return false;
ed5979
+}
ed5979
+
ed5979
+void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask)
ed5979
+{
ed5979
+}
ed5979
+
ed5979
 int vhost_net_notify_migration_done(struct vhost_net *net, char* mac_addr)
ed5979
 {
ed5979
     return -1;
ed5979
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
ed5979
index 043058ff43..6a55f5a473 100644
ed5979
--- a/hw/net/vhost_net.c
ed5979
+++ b/hw/net/vhost_net.c
ed5979
@@ -478,6 +478,15 @@ void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
ed5979
     vhost_virtqueue_mask(&net->dev, dev, idx, mask);
ed5979
 }
ed5979
 
ed5979
+bool vhost_net_config_pending(VHostNetState *net)
ed5979
+{
ed5979
+    return vhost_config_pending(&net->dev);
ed5979
+}
ed5979
+
ed5979
+void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask)
ed5979
+{
ed5979
+    vhost_config_mask(&net->dev, dev, mask);
ed5979
+}
ed5979
 VHostNetState *get_vhost_net(NetClientState *nc)
ed5979
 {
ed5979
     VHostNetState *vhost_net = 0;
ed5979
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
ed5979
index bee35d6f9f..ec974f7a76 100644
ed5979
--- a/hw/net/virtio-net.c
ed5979
+++ b/hw/net/virtio-net.c
ed5979
@@ -3323,7 +3323,7 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
ed5979
      */
ed5979
 
ed5979
     if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
-        return false;
ed5979
+        return vhost_net_config_pending(get_vhost_net(nc->peer));
ed5979
     }
ed5979
     return vhost_net_virtqueue_pending(get_vhost_net(nc->peer), idx);
ed5979
 }
ed5979
@@ -3355,9 +3355,9 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
ed5979
      */
ed5979
 
ed5979
     if (idx == VIRTIO_CONFIG_IRQ_IDX) {
ed5979
+        vhost_net_config_mask(get_vhost_net(nc->peer), vdev, mask);
ed5979
         return;
ed5979
     }
ed5979
-
ed5979
     vhost_net_virtqueue_mask(get_vhost_net(nc->peer), vdev, idx, mask);
ed5979
 }
ed5979
 
ed5979
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
ed5979
index 40b9a40074..dbbd0dc04e 100644
ed5979
--- a/include/net/vhost_net.h
ed5979
+++ b/include/net/vhost_net.h
ed5979
@@ -39,6 +39,8 @@ int vhost_net_set_config(struct vhost_net *net, const uint8_t *data,
ed5979
 bool vhost_net_virtqueue_pending(VHostNetState *net, int n);
ed5979
 void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
ed5979
                               int idx, bool mask);
ed5979
+bool vhost_net_config_pending(VHostNetState *net);
ed5979
+void vhost_net_config_mask(VHostNetState *net, VirtIODevice *dev, bool mask);
ed5979
 int vhost_net_notify_migration_done(VHostNetState *net, char* mac_addr);
ed5979
 VHostNetState *get_vhost_net(NetClientState *nc);
ed5979
 
ed5979
-- 
ed5979
2.31.1
ed5979