[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/41] vdpa: request iova_range only once
From: |
Michael S. Tsirkin |
Subject: |
[PULL 17/41] vdpa: request iova_range only once |
Date: |
Wed, 21 Dec 2022 08:05:21 -0500 |
From: Eugenio Pérez <eperezma@redhat.com>
Currently iova range is requested once per queue pair in the case of
net. Reduce the number of ioctls asking it once at initialization and
reusing that value for each vhost_vdpa.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Message-Id: <20221215113144.322011-7-eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasonwang@redhat.com>
---
hw/virtio/vhost-vdpa.c | 15 ---------------
net/vhost-vdpa.c | 27 ++++++++++++++-------------
2 files changed, 14 insertions(+), 28 deletions(-)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 014c69a475..7f6bfd961c 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -365,19 +365,6 @@ static int vhost_vdpa_add_status(struct vhost_dev *dev,
uint8_t status)
return 0;
}
-static void vhost_vdpa_get_iova_range(struct vhost_vdpa *v)
-{
- int ret = vhost_vdpa_call(v->dev, VHOST_VDPA_GET_IOVA_RANGE,
- &v->iova_range);
- if (ret != 0) {
- v->iova_range.first = 0;
- v->iova_range.last = UINT64_MAX;
- }
-
- trace_vhost_vdpa_get_iova_range(v->dev, v->iova_range.first,
- v->iova_range.last);
-}
-
/*
* The use of this function is for requests that only need to be
* applied once. Typically such request occurs at the beginning
@@ -465,8 +452,6 @@ static int vhost_vdpa_init(struct vhost_dev *dev, void
*opaque, Error **errp)
goto err;
}
- vhost_vdpa_get_iova_range(v);
-
if (!vhost_vdpa_first_dev(dev)) {
return 0;
}
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 2c0ff6d7b0..b6462f0192 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -541,14 +541,15 @@ static const VhostShadowVirtqueueOps
vhost_vdpa_net_svq_ops = {
};
static NetClientState *net_vhost_vdpa_init(NetClientState *peer,
- const char *device,
- const char *name,
- int vdpa_device_fd,
- int queue_pair_index,
- int nvqs,
- bool is_datapath,
- bool svq,
- VhostIOVATree *iova_tree)
+ const char *device,
+ const char *name,
+ int vdpa_device_fd,
+ int queue_pair_index,
+ int nvqs,
+ bool is_datapath,
+ bool svq,
+ struct vhost_vdpa_iova_range iova_range,
+ VhostIOVATree *iova_tree)
{
NetClientState *nc = NULL;
VhostVDPAState *s;
@@ -567,6 +568,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientState
*peer,
s->vhost_vdpa.device_fd = vdpa_device_fd;
s->vhost_vdpa.index = queue_pair_index;
s->vhost_vdpa.shadow_vqs_enabled = svq;
+ s->vhost_vdpa.iova_range = iova_range;
s->vhost_vdpa.iova_tree = iova_tree;
if (!is_datapath) {
s->cvq_cmd_out_buffer = qemu_memalign(qemu_real_host_page_size(),
@@ -646,6 +648,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char
*name,
int vdpa_device_fd;
g_autofree NetClientState **ncs = NULL;
g_autoptr(VhostIOVATree) iova_tree = NULL;
+ struct vhost_vdpa_iova_range iova_range;
NetClientState *nc;
int queue_pairs, r, i = 0, has_cvq = 0;
@@ -689,14 +692,12 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char
*name,
return queue_pairs;
}
+ vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
if (opts->x_svq) {
- struct vhost_vdpa_iova_range iova_range;
-
if (!vhost_vdpa_net_valid_svq_features(features, errp)) {
goto err_svq;
}
- vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
iova_tree = vhost_iova_tree_new(iova_range.first, iova_range.last);
}
@@ -705,7 +706,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char
*name,
for (i = 0; i < queue_pairs; i++) {
ncs[i] = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
vdpa_device_fd, i, 2, true, opts->x_svq,
- iova_tree);
+ iova_range, iova_tree);
if (!ncs[i])
goto err;
}
@@ -713,7 +714,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char
*name,
if (has_cvq) {
nc = net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name,
vdpa_device_fd, i, 1, false,
- opts->x_svq, iova_tree);
+ opts->x_svq, iova_range, iova_tree);
if (!nc)
goto err;
}
--
MST
- [PULL 07/41] ich9: honour 'enable_tco' property, (continued)
- [PULL 07/41] ich9: honour 'enable_tco' property, Michael S. Tsirkin, 2022/12/21
- [PULL 08/41] virtio: get class_id and pci device id by the virtio id, Michael S. Tsirkin, 2022/12/21
- [PULL 09/41] vdpa: add vdpa-dev support, Michael S. Tsirkin, 2022/12/21
- [PULL 12/41] vdpa: use v->shadow_vqs_enabled in vhost_vdpa_svqs_start & stop, Michael S. Tsirkin, 2022/12/21
- [PULL 11/41] vdpa-dev: mark the device as unmigratable, Michael S. Tsirkin, 2022/12/21
- [PULL 13/41] vhost: set SVQ device call handler at SVQ start, Michael S. Tsirkin, 2022/12/21
- [PULL 14/41] vhost: allocate SVQ device file descriptors at device start, Michael S. Tsirkin, 2022/12/21
- [PULL 10/41] vdpa: add vdpa-dev-pci support, Michael S. Tsirkin, 2022/12/21
- [PULL 15/41] vhost: move iova_tree set to vhost_svq_start, Michael S. Tsirkin, 2022/12/21
- [PULL 16/41] vdpa: add vhost_vdpa_net_valid_svq_features, Michael S. Tsirkin, 2022/12/21
- [PULL 17/41] vdpa: request iova_range only once,
Michael S. Tsirkin <=
- [PULL 18/41] vdpa: move SVQ vring features check to net/, Michael S. Tsirkin, 2022/12/21
- [PULL 20/41] vdpa: add asid parameter to vhost_vdpa_dma_map/unmap, Michael S. Tsirkin, 2022/12/21
- [PULL 24/41] vhost-user: send set log base message only once, Michael S. Tsirkin, 2022/12/21
- [PULL 26/41] acpi/tests/avocado/bits: add SPDX license identifiers for bios bits tests, Michael S. Tsirkin, 2022/12/21
- [PULL 21/41] vdpa: store x-svq parameter in VhostVDPAState, Michael S. Tsirkin, 2022/12/21
- [PULL 22/41] vdpa: add shadow_data to vhost_vdpa, Michael S. Tsirkin, 2022/12/21
- [PULL 25/41] include/hw: attempt to document VirtIO feature variables, Michael S. Tsirkin, 2022/12/21
- [PULL 23/41] vdpa: always start CVQ in SVQ mode if possible, Michael S. Tsirkin, 2022/12/21
- [PULL 19/41] vdpa: allocate SVQ array unconditionally, Michael S. Tsirkin, 2022/12/21
- [PULL 27/41] vhost: fix vq dirty bitmap syncing when vIOMMU is enabled, Michael S. Tsirkin, 2022/12/21