ed5979
From b71724e94c94acd6e09fed2b47be2901799c2353 Mon Sep 17 00:00:00 2001
ed5979
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
ed5979
Date: Wed, 21 Dec 2022 12:50:14 +0100
ed5979
Subject: [PATCH 3/9] vdpa: handle VIRTIO_NET_CTRL_ANNOUNCE in
ed5979
 vhost_vdpa_net_handle_ctrl_avail
ed5979
MIME-Version: 1.0
ed5979
Content-Type: text/plain; charset=UTF-8
ed5979
Content-Transfer-Encoding: 8bit
ed5979
ed5979
RH-Author: Eugenio Pérez <eperezma@redhat.com>
ed5979
RH-MergeRequest: 137: vDPA net SVQ guest announce support
ed5979
RH-Bugzilla: 2141088
ed5979
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
ed5979
RH-Acked-by: Cindy Lu <lulu@redhat.com>
ed5979
RH-Acked-by: Jason Wang <jasowang@redhat.com>
ed5979
RH-Commit: [3/4] c4ef5b62a5d41911565b8960a88bb48d746ff6c7 (eperezmartin/qemu-kvm)
ed5979
ed5979
Since this capability is emulated by qemu shadowed CVQ cannot forward it
ed5979
to the device. Process all that command within qemu.
ed5979
ed5979
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
ed5979
Message-Id: <20221221115015.1400889-4-eperezma@redhat.com>
ed5979
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
ed5979
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
ed5979
Acked-by: Jason Wang <jasowang@redhat.com>
ed5979
(cherry picked from commit 3f9a3eeb7ca6acd899e2205a9118928b4cd94e47)
ed5979
---
ed5979
 net/vhost-vdpa.c | 15 ++++++++++++---
ed5979
 1 file changed, 12 insertions(+), 3 deletions(-)
ed5979
ed5979
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
ed5979
index 2b4b85d8f8..52ef9cb3a2 100644
ed5979
--- a/net/vhost-vdpa.c
ed5979
+++ b/net/vhost-vdpa.c
ed5979
@@ -489,9 +489,18 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
ed5979
     out.iov_len = iov_to_buf(elem->out_sg, elem->out_num, 0,
ed5979
                              s->cvq_cmd_out_buffer,
ed5979
                              vhost_vdpa_net_cvq_cmd_len());
ed5979
-    dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
ed5979
-    if (unlikely(dev_written < 0)) {
ed5979
-        goto out;
ed5979
+    if (*(uint8_t *)s->cvq_cmd_out_buffer == VIRTIO_NET_CTRL_ANNOUNCE) {
ed5979
+        /*
ed5979
+         * Guest announce capability is emulated by qemu, so don't forward to
ed5979
+         * the device.
ed5979
+         */
ed5979
+        dev_written = sizeof(status);
ed5979
+        *s->status = VIRTIO_NET_OK;
ed5979
+    } else {
ed5979
+        dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status));
ed5979
+        if (unlikely(dev_written < 0)) {
ed5979
+            goto out;
ed5979
+        }
ed5979
     }
ed5979
 
ed5979
     if (unlikely(dev_written < sizeof(status))) {
ed5979
-- 
ed5979
2.31.1
ed5979