[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/68] vdpa: factor out vhost_vdpa_last_dev
From: |
Michael S. Tsirkin |
Subject: |
[PULL 02/68] vdpa: factor out vhost_vdpa_last_dev |
Date: |
Tue, 12 Mar 2024 18:25:35 -0400 |
From: Si-Wei Liu <si-wei.liu@oracle.com>
Generalize duplicated condition check for the last vq of vdpa
device to a common function.
Message-Id: <1707910082-10243-4-git-send-email-si-wei.liu@oracle.com>
Reviewed-by: Eugenio PĂ©rez <eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost-vdpa.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index ddae494ca8..8bd62e8dd2 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -555,6 +555,11 @@ static bool vhost_vdpa_first_dev(struct vhost_dev *dev)
return v->index == 0;
}
+static bool vhost_vdpa_last_dev(struct vhost_dev *dev)
+{
+ return dev->vq_index + dev->nvqs == dev->vq_index_end;
+}
+
static int vhost_vdpa_get_dev_features(struct vhost_dev *dev,
uint64_t *features)
{
@@ -1315,7 +1320,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *dev,
bool started)
vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs);
}
- if (dev->vq_index + dev->nvqs != dev->vq_index_end) {
+ if (!vhost_vdpa_last_dev(dev)) {
return 0;
}
@@ -1337,7 +1342,7 @@ static void vhost_vdpa_reset_status(struct vhost_dev *dev)
{
struct vhost_vdpa *v = dev->opaque;
- if (dev->vq_index + dev->nvqs != dev->vq_index_end) {
+ if (!vhost_vdpa_last_dev(dev)) {
return;
}
--
MST
- [PULL 00/68] virtio,pc,pci: features, cleanups, fixes, Michael S. Tsirkin, 2024/03/12
- [PULL 03/68] vdpa: factor out vhost_vdpa_net_get_nc_vdpa, Michael S. Tsirkin, 2024/03/12
- [PULL 02/68] vdpa: factor out vhost_vdpa_last_dev,
Michael S. Tsirkin <=
- [PULL 04/68] vdpa: add vhost_vdpa_set_address_space_id trace, Michael S. Tsirkin, 2024/03/12
- [PULL 08/68] vdpa: add trace event for vhost_vdpa_net_load_mq, Michael S. Tsirkin, 2024/03/12
- [PULL 05/68] vdpa: add vhost_vdpa_get_vring_base trace for svq mode, Michael S. Tsirkin, 2024/03/12
- [PULL 09/68] vdpa: define SVQ transitioning state for mode switching, Michael S. Tsirkin, 2024/03/12
- [PULL 10/68] vdpa: indicate transitional state for SVQ switching, Michael S. Tsirkin, 2024/03/12
- [PULL 06/68] vdpa: add vhost_vdpa_set_dev_vring_base trace for svq mode, Michael S. Tsirkin, 2024/03/12
- [PULL 07/68] vdpa: add trace events for vhost_vdpa_net_load_cmd, Michael S. Tsirkin, 2024/03/12
- [PULL 12/68] libvhost-user: Dynamically allocate memory for memory slots, Michael S. Tsirkin, 2024/03/12
- [PULL 01/68] vdpa: add back vhost_vdpa_net_first_nc_vdpa, Michael S. Tsirkin, 2024/03/12
- [PULL 11/68] vdpa: fix network breakage after cancelling migration, Michael S. Tsirkin, 2024/03/12