thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
7f1c5b
From 760169d538a4e6ba61006f6796cd55af967a7f1e Mon Sep 17 00:00:00 2001
7f1c5b
From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= <eperezma@redhat.com>
7f1c5b
Date: Thu, 15 Dec 2022 12:31:38 +0100
7f1c5b
Subject: [PATCH 06/14] vdpa: request iova_range only once
7f1c5b
MIME-Version: 1.0
7f1c5b
Content-Type: text/plain; charset=UTF-8
7f1c5b
Content-Transfer-Encoding: 8bit
7f1c5b
7f1c5b
RH-Author: Eugenio Pérez <eperezma@redhat.com>
7f1c5b
RH-MergeRequest: 136: vDPA ASID support in Qemu
7f1c5b
RH-Bugzilla: 2104412
7f1c5b
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
7f1c5b
RH-Acked-by: Cindy Lu <lulu@redhat.com>
7f1c5b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7f1c5b
RH-Commit: [6/13] 2a8ae2f46ae88f01c5535038f38cb7895098b610 (eperezmartin/qemu-kvm)
7f1c5b
7f1c5b
Currently iova range is requested once per queue pair in the case of
7f1c5b
net. Reduce the number of ioctls asking it once at initialization and
7f1c5b
reusing that value for each vhost_vdpa.
7f1c5b
7f1c5b
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
7f1c5b
Message-Id: <20221215113144.322011-7-eperezma@redhat.com>
7f1c5b
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
7f1c5b
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
7f1c5b
Acked-by: Jason Wang <jasonwang@redhat.com>
7f1c5b
(cherry picked from commit a585fad26b2e6ccca156d9e65158ad1c5efd268d)
7f1c5b
---
7f1c5b
 hw/virtio/vhost-vdpa.c | 15 ---------------
7f1c5b
 net/vhost-vdpa.c       | 27 ++++++++++++++-------------
7f1c5b
 2 files changed, 14 insertions(+), 28 deletions(-)
7f1c5b
7f1c5b
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
7f1c5b
index e65603022f..9e7cbf1776 100644
7f1c5b
--- a/hw/virtio/vhost-vdpa.c
7f1c5b
+++ b/hw/virtio/vhost-vdpa.c
7f1c5b
@@ -365,19 +365,6 @@ static int vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status)
7f1c5b
     return 0;
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v)
7f1c5b
-{
7f1c5b
-    int ret = vhost_vdpa_call(v->dev, VHOST_VDPA_GET_IOVA_RANGE,
7f1c5b
-                              &v->iova_range);
7f1c5b
-    if (ret != 0) {
7f1c5b
-        v->iova_range.first = 0;
7f1c5b
-        v->iova_range.last = UINT64_MAX;
7f1c5b
-    }
7f1c5b
-
7f1c5b
-    trace_vhost_vdpa_get_iova_range(v->dev, v->iova_range.first,
7f1c5b
-                                    v->iova_range.last);
7f1c5b
-}
7f1c5b
-
7f1c5b
 /*
7f1c5b
  * The use of this function is for requests that only need to be
7f1c5b
  * applied once. Typically such request occurs at the beginning
7f1c5b
@@ -465,8 +452,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void *opaque, Error **errp)
7f1c5b
         goto err;
7f1c5b
     }
7f1c5b
 
7f1c5b
-    vhost_vdpa_get_iova_range(v);
7f1c5b
-
7f1c5b
     if (!vhost_vdpa_first_dev(dev)) {
7f1c5b
         return 0;
7f1c5b
     }
7f1c5b
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
7f1c5b
index 16a5ebe2dd..8d3ed095d0 100644
7f1c5b
--- a/net/vhost-vdpa.c
7f1c5b
+++ b/net/vhost-vdpa.c
7f1c5b
@@ -549,14 +549,15 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_svq_ops = {
7f1c5b
 };
7f1c5b
 
7f1c5b
 static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
7f1c5b
-                                           const char *device,
7f1c5b
-                                           const char *name,
7f1c5b
-                                           int vdpa_device_fd,
7f1c5b
-                                           int queue_pair_index,
7f1c5b
-                                           int nvqs,
7f1c5b
-                                           bool is_datapath,
7f1c5b
-                                           bool svq,
7f1c5b
-                                           VhostIOVATree *iova_tree)
7f1c5b
+                                       const char *device,
7f1c5b
+                                       const char *name,
7f1c5b
+                                       int vdpa_device_fd,
7f1c5b
+                                       int queue_pair_index,
7f1c5b
+                                       int nvqs,
7f1c5b
+                                       bool is_datapath,
7f1c5b
+                                       bool svq,
7f1c5b
+                                       struct vhost_vdpa_iova_range iova_range,
7f1c5b
+                                       VhostIOVATree *iova_tree)
7f1c5b
 {
7f1c5b
     NetClientState *nc = NULL;
7f1c5b
     VhostVDPAState *s;
7f1c5b
@@ -575,6 +576,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
7f1c5b
     s->vhost_vdpa.device_fd = vdpa_device_fd;
7f1c5b
     s->vhost_vdpa.index = queue_pair_index;
7f1c5b
     s->vhost_vdpa.shadow_vqs_enabled = svq;
7f1c5b
+    s->vhost_vdpa.iova_range = iova_range;
7f1c5b
     s->vhost_vdpa.iova_tree = iova_tree;
7f1c5b
     if (!is_datapath) {
7f1c5b
         s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
7f1c5b
@@ -654,6 +656,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
7f1c5b
     int vdpa_device_fd;
7f1c5b
     g_autofree NetClientState **ncs = NULL;
7f1c5b
     g_autoptr(VhostIOVATree) iova_tree = NULL;
7f1c5b
+    struct vhost_vdpa_iova_range iova_range;
7f1c5b
     NetClientState *nc;
7f1c5b
     int queue_pairs, r, i = 0, has_cvq = 0;
7f1c5b
 
7f1c5b
@@ -697,14 +700,12 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
7f1c5b
         return queue_pairs;
7f1c5b
     }
7f1c5b
 
7f1c5b
+    vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
7f1c5b
     if (opts->x_svq) {
7f1c5b
-        struct vhost_vdpa_iova_range iova_range;
7f1c5b
-
7f1c5b
         if (!vhost_vdpa_net_valid_svq_features(features, errp)) {
7f1c5b
             goto err_svq;
7f1c5b
         }
7f1c5b
 
7f1c5b
-        vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
7f1c5b
         iova_tree = vhost_iova_tree_new(iova_range.first, iova_range.last);
7f1c5b
     }
7f1c5b
 
7f1c5b
@@ -713,7 +714,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
7f1c5b
     for (i = 0; i < queue_pairs; i++) {
7f1c5b
         ncs[i] = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
7f1c5b
                                      vdpa_device_fd, i, 2, true, opts->x_svq,
7f1c5b
-                                     iova_tree);
7f1c5b
+                                     iova_range, iova_tree);
7f1c5b
         if (!ncs[i])
7f1c5b
             goto err;
7f1c5b
     }
7f1c5b
@@ -721,7 +722,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
7f1c5b
     if (has_cvq) {
7f1c5b
         nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
7f1c5b
                                  vdpa_device_fd, i, 1, false,
7f1c5b
-                                 opts->x_svq, iova_tree);
7f1c5b
+                                 opts->x_svq, iova_range, iova_tree);
7f1c5b
         if (!nc)
7f1c5b
             goto err;
7f1c5b
     }
7f1c5b
-- 
7f1c5b
2.31.1
7f1c5b