thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ed5979
From 760169d538a4e6ba61006f6796cd55af967a7f1e 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:38 +0100
ed5979
Subject: [PATCH 06/14] vdpa: request iova_range only once
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: [6/13] 2a8ae2f46ae88f01c5535038f38cb7895098b610 (eperezmartin/qemu-kvm)
ed5979
ed5979
Currently iova range is requested once per queue pair in the case of
ed5979
net. Reduce the number of ioctls asking it once at initialization and
ed5979
reusing that value for each vhost_vdpa.
ed5979
ed5979
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
ed5979
Message-Id: <20221215113144.322011-7-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 <jasonwang@redhat.com>
ed5979
(cherry picked from commit a585fad26b2e6ccca156d9e65158ad1c5efd268d)
ed5979
---
ed5979
 hw/virtio/vhost-vdpa.c | 15 ---------------
ed5979
 net/vhost-vdpa.c       | 27 ++++++++++++++-------------
ed5979
 2 files changed, 14 insertions(+), 28 deletions(-)
ed5979
ed5979
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
ed5979
index e65603022f..9e7cbf1776 100644
ed5979
--- a/hw/virtio/vhost-vdpa.c
ed5979
+++ b/hw/virtio/vhost-vdpa.c
ed5979
@@ -365,19 +365,6 @@ static int vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status)
ed5979
     return 0;
ed5979
 }
ed5979
 
ed5979
-static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v)
ed5979
-{
ed5979
-    int ret = vhost_vdpa_call(v->dev, VHOST_VDPA_GET_IOVA_RANGE,
ed5979
-                              &v->iova_range);
ed5979
-    if (ret != 0) {
ed5979
-        v->iova_range.first = 0;
ed5979
-        v->iova_range.last = UINT64_MAX;
ed5979
-    }
ed5979
-
ed5979
-    trace_vhost_vdpa_get_iova_range(v->dev, v->iova_range.first,
ed5979
-                                    v->iova_range.last);
ed5979
-}
ed5979
-
ed5979
 /*
ed5979
  * The use of this function is for requests that only need to be
ed5979
  * applied once. Typically such request occurs at the beginning
ed5979
@@ -465,8 +452,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
ed5979
         goto err;
ed5979
     }
ed5979
 
ed5979
-    vhost_vdpa_get_iova_range(v);
ed5979
-
ed5979
     if (!vhost_vdpa_first_dev(dev)) {
ed5979
         return 0;
ed5979
     }
ed5979
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
ed5979
index 16a5ebe2dd..8d3ed095d0 100644
ed5979
--- a/net/vhost-vdpa.c
ed5979
+++ b/net/vhost-vdpa.c
ed5979
@@ -549,14 +549,15 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = {
ed5979
 };
ed5979
 
ed5979
 static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
ed5979
-                                           const char *device,
ed5979
-                                           const char *name,
ed5979
-                                           int vdpa_device_fd,
ed5979
-                                           int queue_pair_index,
ed5979
-                                           int nvqs,
ed5979
-                                           bool is_datapath,
ed5979
-                                           bool svq,
ed5979
-                                           VhostIOVATree *iova_tree)
ed5979
+                                       const char *device,
ed5979
+                                       const char *name,
ed5979
+                                       int vdpa_device_fd,
ed5979
+                                       int queue_pair_index,
ed5979
+                                       int nvqs,
ed5979
+                                       bool is_datapath,
ed5979
+                                       bool svq,
ed5979
+                                       struct vhost_vdpa_iova_range iova_range,
ed5979
+                                       VhostIOVATree *iova_tree)
ed5979
 {
ed5979
     NetClientState *nc = NULL;
ed5979
     VhostVDPAState *s;
ed5979
@@ -575,6 +576,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
ed5979
     s->vhost_vdpa.device_fd = vdpa_device_fd;
ed5979
     s->vhost_vdpa.index = queue_pair_index;
ed5979
     s->vhost_vdpa.shadow_vqs_enabled = svq;
ed5979
+    s->vhost_vdpa.iova_range = iova_range;
ed5979
     s->vhost_vdpa.iova_tree = iova_tree;
ed5979
     if (!is_datapath) {
ed5979
         s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
ed5979
@@ -654,6 +656,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
ed5979
     int vdpa_device_fd;
ed5979
     g_autofree NetClientState **ncs = NULL;
ed5979
     g_autoptr(VhostIOVATree) iova_tree = NULL;
ed5979
+    struct vhost_vdpa_iova_range iova_range;
ed5979
     NetClientState *nc;
ed5979
     int queue_pairs, r, i = 0, has_cvq = 0;
ed5979
 
ed5979
@@ -697,14 +700,12 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
ed5979
         return queue_pairs;
ed5979
     }
ed5979
 
ed5979
+    vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
ed5979
     if (opts->x_svq) {
ed5979
-        struct vhost_vdpa_iova_range iova_range;
ed5979
-
ed5979
         if (!vhost_vdpa_net_valid_svq_features(features, errp)) {
ed5979
             goto err_svq;
ed5979
         }
ed5979
 
ed5979
-        vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
ed5979
         iova_tree = vhost_iova_tree_new(iova_range.first, iova_range.last);
ed5979
     }
ed5979
 
ed5979
@@ -713,7 +714,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
ed5979
     for (i = 0; i < queue_pairs; i++) {
ed5979
         ncs[i] = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
ed5979
                                      vdpa_device_fd, i, 2, true, opts->x_svq,
ed5979
-                                     iova_tree);
ed5979
+                                     iova_range, iova_tree);
ed5979
         if (!ncs[i])
ed5979
             goto err;
ed5979
     }
ed5979
@@ -721,7 +722,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
ed5979
     if (has_cvq) {
ed5979
         nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
ed5979
                                  vdpa_device_fd, i, 1, false,
ed5979
-                                 opts->x_svq, iova_tree);
ed5979
+                                 opts->x_svq, iova_range, iova_tree);
ed5979
         if (!nc)
ed5979
             goto err;
ed5979
     }
ed5979
-- 
ed5979
2.31.1
ed5979