[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 13/31] vhost: Add vhost_svq_ack_guest_features to shadow vq
From: |
Eugenio Pérez |
Subject: |
[PATCH 13/31] vhost: Add vhost_svq_ack_guest_features to shadow vq |
Date: |
Fri, 21 Jan 2022 21:27:15 +0100 |
This combines the previous two feature functions, forwarding the guest
ones to the device and setting the transport ones that the SVQ supports
with the device.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-shadow-virtqueue.h | 3 +++
hw/virtio/vhost-shadow-virtqueue.c | 31 ++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/hw/virtio/vhost-shadow-virtqueue.h
b/hw/virtio/vhost-shadow-virtqueue.h
index 1aae6a2297..af8f8264c0 100644
--- a/hw/virtio/vhost-shadow-virtqueue.h
+++ b/hw/virtio/vhost-shadow-virtqueue.h
@@ -17,6 +17,9 @@ typedef struct VhostShadowVirtqueue VhostShadowVirtqueue;
bool vhost_svq_valid_device_features(uint64_t *features);
bool vhost_svq_valid_guest_features(uint64_t *features);
+bool vhost_svq_ack_guest_features(uint64_t dev_features,
+ uint64_t guest_features,
+ uint64_t *acked_features);
void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd);
void vhost_svq_set_guest_call_notifier(VhostShadowVirtqueue *svq, int call_fd);
diff --git a/hw/virtio/vhost-shadow-virtqueue.c
b/hw/virtio/vhost-shadow-virtqueue.c
index f70160d7ca..a6fb7e3c8f 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -113,6 +113,37 @@ bool vhost_svq_valid_guest_features(uint64_t
*guest_features)
return !(guest_transport_features & (transport ^ valid));
}
+/**
+ * VirtIO features that SVQ must acknowledge to device.
+ *
+ * It combines the SVQ transport compatible features with the guest's device
+ * features.
+ *
+ * @dev_features The device offered features
+ * @guest_features The guest acknowledge features
+ * @acked_features The guest acknowledge features in the device side plus SVQ
+ * transport ones.
+ *
+ * Returns true if SVQ can work with this features, false otherwise
+ */
+bool vhost_svq_ack_guest_features(uint64_t dev_features,
+ uint64_t guest_features,
+ uint64_t *acked_features)
+{
+ static const uint64_t transport = MAKE_64BIT_MASK(VIRTIO_TRANSPORT_F_START,
+ VIRTIO_TRANSPORT_F_END - VIRTIO_TRANSPORT_F_START);
+
+ bool ok = vhost_svq_valid_device_features(&dev_features) &&
+ vhost_svq_valid_guest_features(&guest_features);
+ if (unlikely(!ok)) {
+ return false;
+ }
+
+ *acked_features = (dev_features & transport) |
+ (guest_features & ~transport);
+ return true;
+}
+
/* Forward guest notifications */
static void vhost_handle_guest_kick(EventNotifier *n)
{
--
2.27.0
- Re: [PATCH 07/31] vhost: dd vhost_svq_get_svq_call_notifier, (continued)
- [PATCH 08/31] vhost: Add vhost_svq_set_guest_call_notifier, Eugenio Pérez, 2022/01/21
- [PATCH 09/31] vhost-vdpa: Take into account SVQ in vhost_vdpa_set_vring_call, Eugenio Pérez, 2022/01/21
- [PATCH 10/31] vhost: Route host->guest notification through shadow virtqueue, Eugenio Pérez, 2022/01/21
- [PATCH 12/31] vhost: Add vhost_svq_valid_guest_features to shadow vq, Eugenio Pérez, 2022/01/21
- [PATCH 11/31] vhost: Add vhost_svq_valid_device_features to shadow vq, Eugenio Pérez, 2022/01/21
- [PATCH 13/31] vhost: Add vhost_svq_ack_guest_features to shadow vq,
Eugenio Pérez <=
- [PATCH 14/31] virtio: Add vhost_shadow_vq_get_vring_addr, Eugenio Pérez, 2022/01/21
- [PATCH 15/31] vdpa: Add vhost_svq_get_num, Eugenio Pérez, 2022/01/21
- [PATCH 16/31] vhost: pass queue index to vhost_vq_get_addr, Eugenio Pérez, 2022/01/21
- [PATCH 17/31] vdpa: adapt vhost_ops callbacks to svq, Eugenio Pérez, 2022/01/21