586cba
From effd0ed379deb43bb850f1aeff24fa85935d7f52 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:31 +0200
586cba
Subject: [PATCH 16/23] vhost_net: Add NetClientInfo stop callback
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: [15/21] 9f8a3e9bfb0d21fa0479f54a7a17cb738aa46359 (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
Used by the backend to perform actions after the device is stopped.
586cba
586cba
In particular, vdpa net use it to unmap CVQ buffers to the device,
586cba
cleaning the actions performed in prepare().
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 c6544e2331d721627fa7356da3592bcb46340f1b)
586cba
---
586cba
 hw/net/vhost_net.c | 3 +++
586cba
 include/net/net.h  | 2 ++
586cba
 2 files changed, 5 insertions(+)
586cba
586cba
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
586cba
index 1005f9d8e6..275ece5324 100644
586cba
--- a/hw/net/vhost_net.c
586cba
+++ b/hw/net/vhost_net.c
586cba
@@ -320,6 +320,9 @@ static void vhost_net_stop_one(struct vhost_net *net,
586cba
         net->nc->info->poll(net->nc, true);
586cba
     }
586cba
     vhost_dev_stop(&net->dev, dev);
586cba
+    if (net->nc->info->stop) {
586cba
+        net->nc->info->stop(net->nc);
586cba
+    }
586cba
     vhost_dev_disable_notifiers(&net->dev, dev);
586cba
 }
586cba
 
586cba
diff --git a/include/net/net.h b/include/net/net.h
586cba
index ad9e80083a..476ad45b9a 100644
586cba
--- a/include/net/net.h
586cba
+++ b/include/net/net.h
586cba
@@ -45,6 +45,7 @@ typedef struct NICConf {
586cba
 typedef void (NetPoll)(NetClientState *, bool enable);
586cba
 typedef bool (NetCanReceive)(NetClientState *);
586cba
 typedef int (NetStart)(NetClientState *);
586cba
+typedef void (NetStop)(NetClientState *);
586cba
 typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t);
586cba
 typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int);
586cba
 typedef void (NetCleanup) (NetClientState *);
586cba
@@ -73,6 +74,7 @@ typedef struct NetClientInfo {
586cba
     NetReceiveIOV *receive_iov;
586cba
     NetCanReceive *can_receive;
586cba
     NetStart *start;
586cba
+    NetStop *stop;
586cba
     NetCleanup *cleanup;
586cba
     LinkStatusChanged *link_status_changed;
586cba
     QueryRxFilter *query_rx_filter;
586cba
-- 
586cba
2.31.1
586cba