Skip to contentSkip to conversation

Add SCMI vhost-user VIRTIO device

PATCH New Milan Zamazal 1 participant 4 messages Jun 28, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v3 cover Add SCMI vhost-user VIRTIO device

This patch series adds a vhost-user VIRTIO device for SCMI. It's similar to other similar vhost-user VIRTIO devices.

I'm aware of the work in progress by Alex Bennée to simplify similar devices and avoid excessive code duplication. I think the SCMI device support doesn't bring anything special and it can be rebased on the given work if/once it is merged.

The device has been tested with a prototype rust-vmm based vhost-user-scmi daemon emulating a sensor device and a Linux guest OS (the production version of the vhost-user daemon is developed at
https://github.com/mz-pdm/vhost-device/tree/scmi).

v3:
- Rebased on master after one of the patches had been merged.
v2:
- A missing trailing space additionally added in the comment typo fix.
- A note about testing added above.

Milan Zamazal (3):
hw/virtio: Add boilerplate for vhost-user-scmi device hw/virtio: Add vhost-user-scmi-pci boilerplate tests/qtest: enable tests for virtio-scmi

 MAINTAINERS                         |   7 +
 hw/virtio/Kconfig                   |   5 +
 hw/virtio/meson.build               |   2 +
 hw/virtio/vhost-user-scmi-pci.c     |  68 +++++++
 hw/virtio/vhost-user-scmi.c         | 306 ++++++++++++++++++++++++++++
 include/hw/virtio/vhost-user-scmi.h |  30 +++
 tests/qtest/libqos/meson.build      |   1 +
 tests/qtest/libqos/virtio-scmi.c    | 174 ++++++++++++++++
 tests/qtest/libqos/virtio-scmi.h    |  34 ++++
 tests/qtest/vhost-user-test.c       |  44 ++++
 10 files changed, 671 insertions(+)
 create mode 100644 hw/virtio/vhost-user-scmi-pci.c
 create mode 100644 hw/virtio/vhost-user-scmi.c
 create mode 100644 include/hw/virtio/vhost-user-scmi.h
 create mode 100644 tests/qtest/libqos/virtio-scmi.c
 create mode 100644 tests/qtest/libqos/virtio-scmi.h
Signature · 1 line
2.40.1
#1 lore raw

PATCH v3 1/3 hw/virtio: Add boilerplate for vhost-user-scmi device

This creates the QEMU side of the vhost-user-scmi device which connects to the remote daemon. It is based on code of similar vhost-user devices.

---
 MAINTAINERS                         |   6 +
 hw/virtio/Kconfig                   |   5 +
 hw/virtio/meson.build               |   1 +
 hw/virtio/vhost-user-scmi.c         | 306 ++++++++++++++++++++++++++++
 include/hw/virtio/vhost-user-scmi.h |  30 +++
 5 files changed, 348 insertions(+)
 create mode 100644 hw/virtio/vhost-user-scmi.c
 create mode 100644 include/hw/virtio/vhost-user-scmi.h
MAINTAINERS +6 -0
index e07746ac7d..7ddb8268fe 100644
@@ -2210,6 +2210,12 @@ F: hw/virtio/vhost-user-gpio*
 F: include/hw/virtio/vhost-user-gpio.h
 F: tests/qtest/libqos/virtio-gpio.*
 
+vhost-user-scmi
+R: [email protected]
+S: Supported
+F: hw/virtio/vhost-user-scmi*
+F: include/hw/virtio/vhost-user-scmi.h
+
 virtio-crypto
 M: Gonglei <[email protected]>
 S: Supported
hw/virtio/Kconfig +5 -0
index de7a35429a..a9ee09062f 100644
@@ -96,3 +96,8 @@ config VHOST_VDPA_DEV
     bool
     default y
     depends on VIRTIO && VHOST_VDPA && LINUX
+
+config VHOST_USER_SCMI
+    bool
+    default y
+    depends on VIRTIO && VHOST_USER
hw/virtio/meson.build +1 -0
index f32b22f61b..4a4d7e1c27 100644
@@ -35,6 +35,7 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c'))
 specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c'))
+specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c'))
 
 virtio_pci_ss = ss.source_set()
 virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
hw/virtio/vhost-user-scmi.c new file +306 -0

306 lines not on this page · raw message

include/hw/virtio/vhost-user-scmi.h new file +30 -0
new file mode 100644
index 0000000000..6175a74ebd
@@ -0,0 +1,30 @@
+/*
+ * Vhost-user SCMI virtio device
+ *
+ * Copyright (c) 2023 Red Hat, Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef _QEMU_VHOST_USER_SCMI_H
+#define _QEMU_VHOST_USER_SCMI_H
+
+#include "hw/virtio/virtio.h"
+#include "hw/virtio/vhost.h"
+#include "hw/virtio/vhost-user.h"
+
+#define TYPE_VHOST_USER_SCMI "vhost-user-scmi"
+OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSCMI, VHOST_USER_SCMI);
+
+struct VHostUserSCMI {
+    VirtIODevice parent;
+    CharBackend chardev;
+    struct vhost_virtqueue *vhost_vqs;
+    struct vhost_dev vhost_dev;
+    VhostUserState vhost_user;
+    VirtQueue *cmd_vq;
+    VirtQueue *event_vq;
+    bool connected;
+};
+
+#endif /* _QEMU_VHOST_USER_SCMI_H */
Signature · 1 line
2.40.1
#2 lore raw

PATCH v3 2/3 hw/virtio: Add vhost-user-scmi-pci boilerplate

In reply to Milan Zamazal

This allows is to instantiate a vhost-user-scmi device as part of a PCI bus. It is mostly boilerplate similar to the other vhost-user-*-pci boilerplates of similar devices.

---
 hw/virtio/meson.build           |  1 +
 hw/virtio/vhost-user-scmi-pci.c | 68 +++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)
 create mode 100644 hw/virtio/vhost-user-scmi-pci.c
hw/virtio/meson.build +1 -0
index 4a4d7e1c27..c4f4fe05fa 100644
@@ -36,6 +36,7 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c'))
 specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c'))
+specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.c'))
 
 virtio_pci_ss = ss.source_set()
 virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
hw/virtio/vhost-user-scmi-pci.c new file +68 -0

68 lines not on this page · raw message

Signature · 1 line
2.40.1
#3 lore raw

PATCH v3 3/3 tests/qtest: enable tests for virtio-scmi

In reply to Milan Zamazal

We don't have a virtio-scmi implementation in QEMU and only support a vhost-user backend. This is very similar to virtio-gpio and we add the same set of tests, just passing some vhost-user messages over the control socket.

---
 MAINTAINERS                      |   1 +
 tests/qtest/libqos/meson.build   |   1 +
 tests/qtest/libqos/virtio-scmi.c | 174 +++++++++++++++++++++++++++++++
 tests/qtest/libqos/virtio-scmi.h |  34 ++++++
 tests/qtest/vhost-user-test.c    |  44 ++++++++
 5 files changed, 254 insertions(+)
 create mode 100644 tests/qtest/libqos/virtio-scmi.c
 create mode 100644 tests/qtest/libqos/virtio-scmi.h
MAINTAINERS +1 -0
index 7ddb8268fe..ad58de4df9 100644
@@ -2215,6 +2215,7 @@ R: [email protected]
 S: Supported
 F: hw/virtio/vhost-user-scmi*
 F: include/hw/virtio/vhost-user-scmi.h
+F: tests/qtest/libqos/virtio-scmi.*
 
 virtio-crypto
 M: Gonglei <[email protected]>
tests/qtest/libqos/meson.build +1 -0
index cc209a8de5..90aae42a22 100644
@@ -46,6 +46,7 @@ libqos_srcs = files(
         'virtio-serial.c',
         'virtio-iommu.c',
         'virtio-gpio.c',
+        'virtio-scmi.c',
         'generic-pcihost.c',
 
         # qgraph machines:
tests/qtest/libqos/virtio-scmi.c new file +174 -0

174 lines not on this page · raw message

tests/qtest/libqos/virtio-scmi.h new file +34 -0
new file mode 100644
index 0000000000..cb5670da6e
@@ -0,0 +1,34 @@
+/*
+ * virtio-scmi structures
+ *
+ * SPDX-FileCopyrightText: Red Hat, Inc.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef TESTS_LIBQOS_VIRTIO_SCMI_H
+#define TESTS_LIBQOS_VIRTIO_SCMI_H
+
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
+
+typedef struct QVhostUserSCMI QVhostUserSCMI;
+typedef struct QVhostUserSCMIPCI QVhostUserSCMIPCI;
+typedef struct QVhostUserSCMIDevice QVhostUserSCMIDevice;
+
+struct QVhostUserSCMI {
+    QVirtioDevice *vdev;
+    QVirtQueue **queues;
+};
+
+struct QVhostUserSCMIPCI {
+    QVirtioPCIDevice pci_vdev;
+    QVhostUserSCMI scmi;
+};
+
+struct QVhostUserSCMIDevice {
+    QOSGraphObject obj;
+    QVhostUserSCMI scmi;
+};
+
+#endif
tests/qtest/vhost-user-test.c +44 -0

59 lines not on this page · raw message

Signature · 1 line
2.40.1