ed5979
From 0f3a28e1e128754184c4af6a578f27e16c6a61d5 Mon Sep 17 00:00:00 2001
ed5979
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
ed5979
Date: Thu, 15 Dec 2022 12:31:37 +0100
ed5979
Subject: [PATCH 05/14] vdpa: add vhost_vdpa_net_valid_svq_features
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: 136: vDPA ASID support in Qemu
ed5979
RH-Bugzilla: 2104412
ed5979
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
ed5979
RH-Acked-by: Cindy Lu <lulu@redhat.com>
ed5979
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
ed5979
RH-Commit: [5/13] 0b27e04f178ec73cb800f4fb05c17a92576142e4 (eperezmartin/qemu-kvm)
ed5979
ed5979
It will be reused at vdpa device start so let's extract in its own
ed5979
function.
ed5979
ed5979
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
ed5979
Acked-by: Jason Wang <jasowang@redhat.com>
ed5979
Message-Id: <20221215113144.322011-6-eperezma@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 36e4647247f200b6fa4d2f656133f567036e8a85)
ed5979
---
ed5979
 net/vhost-vdpa.c | 26 +++++++++++++++++---------
ed5979
 1 file changed, 17 insertions(+), 9 deletions(-)
ed5979
ed5979
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
ed5979
index b06540ac89..16a5ebe2dd 100644
ed5979
--- a/net/vhost-vdpa.c
ed5979
+++ b/net/vhost-vdpa.c
ed5979
@@ -106,6 +106,22 @@ VHostNetState *vhost_vdpa_get_vhost_net(NetClientState *nc)
ed5979
     return s->vhost_net;
ed5979
 }
ed5979
 
ed5979
+static bool vhost_vdpa_net_valid_svq_features(uint64_t features, Error **errp)
ed5979
+{
ed5979
+    uint64_t invalid_dev_features =
ed5979
+        features & ~vdpa_svq_device_features &
ed5979
+        /* Transport are all accepted at this point */
ed5979
+        ~MAKE_64BIT_MASK(VIRTIO_TRANSPORT_F_START,
ed5979
+                         VIRTIO_TRANSPORT_F_END - VIRTIO_TRANSPORT_F_START);
ed5979
+
ed5979
+    if (invalid_dev_features) {
ed5979
+        error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64,
ed5979
+                   invalid_dev_features);
ed5979
+    }
ed5979
+
ed5979
+    return !invalid_dev_features;
ed5979
+}
ed5979
+
ed5979
 static int vhost_vdpa_net_check_device_id(struct vhost_net *net)
ed5979
 {
ed5979
     uint32_t device_id;
ed5979
@@ -684,15 +700,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
ed5979
     if (opts->x_svq) {
ed5979
         struct vhost_vdpa_iova_range iova_range;
ed5979
 
ed5979
-        uint64_t invalid_dev_features =
ed5979
-            features & ~vdpa_svq_device_features &
ed5979
-            /* Transport are all accepted at this point */
ed5979
-            ~MAKE_64BIT_MASK(VIRTIO_TRANSPORT_F_START,
ed5979
-                             VIRTIO_TRANSPORT_F_END - VIRTIO_TRANSPORT_F_START);
ed5979
-
ed5979
-        if (invalid_dev_features) {
ed5979
-            error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64,
ed5979
-                       invalid_dev_features);
ed5979
+        if (!vhost_vdpa_net_valid_svq_features(features, errp)) {
ed5979
             goto err_svq;
ed5979
         }
ed5979
 
ed5979
-- 
ed5979
2.31.1
ed5979