qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC 2/8] vdpa: Extract get_backend_features from vhost_vdpa_get_as_num


From: Eugenio Pérez
Subject: [RFC 2/8] vdpa: Extract get_backend_features from vhost_vdpa_get_as_num
Date: Wed, 10 Aug 2022 20:42:14 +0200

The series reuses it to check for SUSPEND feature bit.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 net/vhost-vdpa.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 11241ebac4..85b10799bd 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -602,9 +602,17 @@ static const VhostShadowVirtqueueOps 
vhost_vdpa_net_svq_ops = {
     .avail_handler = vhost_vdpa_net_handle_ctrl_avail,
 };
 
-static uint32_t vhost_vdpa_get_as_num(int vdpa_device_fd)
+static uint64_t vhost_vdpa_get_backend_features(int fd)
 {
     uint64_t features;
+
+    /* No need to treat the error, only to know there is one */
+    int ret = ioctl(fd, VHOST_GET_BACKEND_FEATURES, &features);
+    return ret < 0 ? 0 : features;
+}
+
+static uint32_t vhost_vdpa_get_as_num(int vdpa_device_fd, uint64_t features)
+{
     unsigned num_as;
     int r;
 
@@ -733,7 +741,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char 
*name,
                         NetClientState *peer, Error **errp)
 {
     const NetdevVhostVDPAOptions *opts;
-    uint64_t features;
+    uint64_t features, backend_features;
     int vdpa_device_fd;
     g_autofree NetClientState **ncs = NULL;
     g_autoptr(VhostIOVATree) iova_tree = NULL;
@@ -765,9 +773,10 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char 
*name,
         goto err;
     }
 
+    backend_features = vhost_vdpa_get_backend_features(vdpa_device_fd);
     svq_cvq = opts->x_svq;
     if (has_cvq && !opts->x_svq) {
-        num_as = vhost_vdpa_get_as_num(vdpa_device_fd);
+        num_as = vhost_vdpa_get_as_num(vdpa_device_fd, backend_features);
         svq_cvq = num_as > 1;
     }
 
-- 
2.31.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]