586cba
From 6a6999311742b6dccdfce09f30742a63d72d1bd7 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:30 +0200
586cba
Subject: [PATCH 15/23] vhost_net: Add NetClientInfo start 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: [14/21] df6a96ae3aec02ecae793bdbd8e9c2fcfac7871a (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 used by the backend to perform actions before the device is
586cba
started.
586cba
586cba
In particular, vdpa net use it to map CVQ buffers to the device, so it
586cba
can send control commands using them.
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 80bda0e674fd0b439ac627ab7ecdbd4a1b46d525)
586cba
---
586cba
 hw/net/vhost_net.c | 7 +++++++
586cba
 include/net/net.h  | 2 ++
586cba
 2 files changed, 9 insertions(+)
586cba
586cba
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
586cba
index d6d7c51f62..1005f9d8e6 100644
586cba
--- a/hw/net/vhost_net.c
586cba
+++ b/hw/net/vhost_net.c
586cba
@@ -244,6 +244,13 @@ static int vhost_net_start_one(struct vhost_net *net,
586cba
     struct vhost_vring_file file = { };
586cba
     int r;
586cba
 
586cba
+    if (net->nc->info->start) {
586cba
+        r = net->nc->info->start(net->nc);
586cba
+        if (r < 0) {
586cba
+            return r;
586cba
+        }
586cba
+    }
586cba
+
586cba
     r = vhost_dev_enable_notifiers(&net->dev, dev);
586cba
     if (r < 0) {
586cba
         goto fail_notifiers;
586cba
diff --git a/include/net/net.h b/include/net/net.h
586cba
index 523136c7ac..ad9e80083a 100644
586cba
--- a/include/net/net.h
586cba
+++ b/include/net/net.h
586cba
@@ -44,6 +44,7 @@ typedef struct NICConf {
586cba
 
586cba
 typedef void (NetPoll)(NetClientState *, bool enable);
586cba
 typedef bool (NetCanReceive)(NetClientState *);
586cba
+typedef int (NetStart)(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
@@ -71,6 +72,7 @@ typedef struct NetClientInfo {
586cba
     NetReceive *receive_raw;
586cba
     NetReceiveIOV *receive_iov;
586cba
     NetCanReceive *can_receive;
586cba
+    NetStart *start;
586cba
     NetCleanup *cleanup;
586cba
     LinkStatusChanged *link_status_changed;
586cba
     QueryRxFilter *query_rx_filter;
586cba
-- 
586cba
2.31.1
586cba