Skip to contentSkip to conversation

s390x: ccw: A simple test device for virtio CCW

PATCH In review Pierre Morel 3 participants 7 messages Aug 27, 2021 – Sep 1, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover s390x: ccw: A simple test device for virtio CCW

Hello All,

This series presents a VIRTIO test device which receives data on its input channel and sends back a simple checksum for the data it received on its output channel.

The goal is to allow a simple VIRTIO device driver to check the VIRTIO initialization and various data transfer.

For this I introduced a new device ID for the device and having no Linux driver but a kvm-unit-test driver, I have the following questions:

Is there another way to advertise new VIRTIO IDs but Linux? If this QEMU test meet interest, should I write a Linux test program?

Regards,
Pierre

Pierre Morel (2):
virtio: Linux: Update of virtio_ids
s390x: ccw: A simple test device for virtio CCW

 hw/s390x/meson.build                        |   1 +
 hw/s390x/virtio-ccw-pong.c                  |  66 ++++++++
 hw/s390x/virtio-ccw.h                       |  13 ++
 hw/virtio/Kconfig                           |   5 +
 hw/virtio/meson.build                       |   1 +
 hw/virtio/virtio-pong.c                     | 161 ++++++++++++++++++++
 include/hw/virtio/virtio-pong.h             |  34 +++++
 include/standard-headers/linux/virtio_ids.h |   1 +
 8 files changed, 282 insertions(+)
 create mode 100644 hw/s390x/virtio-ccw-pong.c
 create mode 100644 hw/virtio/virtio-pong.c
 create mode 100644 include/hw/virtio/virtio-pong.h
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 virtio: Linux: Update of virtio_ids

The virtio IDs depends on Linux tree...

---
 include/standard-headers/linux/virtio_ids.h | 1 +
 1 file changed, 1 insertion(+)
include/standard-headers/linux/virtio_ids.h +1 -0
index 4fe842c3a3..bf61801eeb 100644
@@ -55,6 +55,7 @@
 #define VIRTIO_ID_FS			26 /* virtio filesystem */
 #define VIRTIO_ID_PMEM			27 /* virtio pmem */
 #define VIRTIO_ID_MAC80211_HWSIM	29 /* virtio mac80211-hwsim */
+#define VIRTIO_ID_PONG			30 /* virtio pong */
 #define VIRTIO_ID_BT			40 /* virtio bluetooth */
 
 #endif /* _LINUX_VIRTIO_IDS_H */
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/2 s390x: ccw: A simple test device for virtio CCW

In reply to Pierre Morel

This VIRTIO device receives data on its input channel and emit a simple checksum for these data on its output channel.

This allows a simple VIRTIO device driver to check the VIRTIO initialization and various data transfer.

---
 hw/s390x/meson.build            |   1 +
 hw/s390x/virtio-ccw-pong.c      |  66 +++++++++++++
 hw/s390x/virtio-ccw.h           |  13 +++
 hw/virtio/Kconfig               |   5 +
 hw/virtio/meson.build           |   1 +
 hw/virtio/virtio-pong.c         | 161 ++++++++++++++++++++++++++++++++
 include/hw/virtio/virtio-pong.h |  34 +++++++
 7 files changed, 281 insertions(+)
 create mode 100644 hw/s390x/virtio-ccw-pong.c
 create mode 100644 hw/virtio/virtio-pong.c
 create mode 100644 include/hw/virtio/virtio-pong.h
hw/s390x/meson.build +1 -0
index 74678861cf..e9edf1d196 100644
@@ -18,6 +18,7 @@ s390x_ss.add(files(
   'sclpcpu.c',
   'sclpquiesce.c',
   'tod.c',
+  'virtio-ccw-pong.c',
 ))
 s390x_ss.add(when: 'CONFIG_KVM', if_true: files(
   'tod-kvm.c',
hw/s390x/virtio-ccw-pong.c new file +66 -0

66 lines not on this page · raw message

hw/s390x/virtio-ccw.h +13 -0
index 0168232e3b..f718ad32c2 100644
@@ -31,6 +31,8 @@
 #include "hw/virtio/virtio-gpu.h"
 #include "hw/virtio/virtio-input.h"
 
+#include "hw/virtio/virtio-pong.h"
+
 #include "hw/s390x/s390_flic.h"
 #include "hw/s390x/css.h"
 #include "ccw-device.h"
@@ -176,6 +178,17 @@ struct VirtIORNGCcw {
     VirtIORNG vdev;
 };
 
+/* virtio-pong-ccw */
+
+#define TYPE_VIRTIO_PONG_CCW "virtio-pong-ccw"
+#define VIRTIO_PONG_CCW(obj) \
+        OBJECT_CHECK(VirtIOPONGCcw, (obj), TYPE_VIRTIO_PONG_CCW)
+
+typedef struct VirtIOPONGCcw {
+    VirtioCcwDevice parent_obj;
+    VirtIOPONG vdev;
+} VirtIOPONGCcw;
+
 /* virtio-crypto-ccw */
 
 #define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw"
hw/virtio/Kconfig +5 -0
index 35ab45e209..f73c87d953 100644
@@ -4,6 +4,11 @@ config VHOST
 config VIRTIO
     bool
 
+config VIRTIO_PONG
+    bool
+    default y
+    depends on VIRTIO
+
 config VIRTIO_RNG
     bool
     default y
hw/virtio/meson.build +1 -0
index bc352a6009..1ba4dcc454 100644
@@ -6,6 +6,7 @@ softmmu_virtio_ss.add(when: 'CONFIG_VHOST', if_false: files('vhost-stub.c'))
 
 softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: softmmu_virtio_ss)
 softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-pong.c'))
 
 softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c'))
 
hw/virtio/virtio-pong.c new file +161 -0

161 lines not on this page · raw message

include/hw/virtio/virtio-pong.h new file +34 -0
new file mode 100644
index 0000000000..ff44f2fead
@@ -0,0 +1,34 @@
+/*
+ * Virtio PONG Support
+ *
+ * Copyright IBM 2020
+ * Copyright Pierre Morel <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or
+ * (at your option) any later version.  See the COPYING file in the
+ * top-level directory.
+ */
+
+#ifndef QEMU_VIRTIO_PONG_H
+#define QEMU_VIRTIO_PONG_H
+
+#include "hw/virtio/virtio.h"
+
+#define TYPE_VIRTIO_PONG "virtio-pong-device"
+#define VIRTIO_PONG(obj) \
+        OBJECT_CHECK(VirtIOPONG, (obj), TYPE_VIRTIO_PONG)
+#define VIRTIO_PONG_GET_PARENT_CLASS(obj) \
+        OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_PONG)
+
+typedef struct VirtIOPONG {
+    VirtIODevice parent_obj;
+    VirtQueue *vq_in;
+    VirtQueue *vq_out;
+    VMChangeStateEntry *vmstate;
+    uint64_t cksum;
+} VirtIOPONG;
+
+/* Feature bits */
+#define VIRTIO_PONG_F_CKSUM    1       /* Indicates pong using checksum */
+
+#endif
Signature · 1 line
2.25.1
#3 lore raw
In reply to Pierre Morel
Quoted 7 lines · Pierre Morel

Hello All,

This series presents a VIRTIO test device which receives data on its input channel and sends back a simple checksum for the data it received on its output channel.

Quoted 6 lines

The goal is to allow a simple VIRTIO device driver to check the VIRTIO initialization and various data transfer.

For this I introduced a new device ID for the device and having no Linux driver but a kvm-unit-test driver, I have the following questions:

I think we should reserve an ID in the official virtio spec then for such a device? Maybe also add mst for such things.

Quoted 24 lines

Is there another way to advertise new VIRTIO IDs but Linux? If this QEMU test meet interest, should I write a Linux test program?

Regards,
Pierre

Pierre Morel (2):
virtio: Linux: Update of virtio_ids
s390x: ccw: A simple test device for virtio CCW

  hw/s390x/meson.build                        |   1 +
  hw/s390x/virtio-ccw-pong.c                  |  66 ++++++++
  hw/s390x/virtio-ccw.h                       |  13 ++
  hw/virtio/Kconfig                           |   5 +
  hw/virtio/meson.build                       |   1 +
  hw/virtio/virtio-pong.c                     | 161 ++++++++++++++++++++
  include/hw/virtio/virtio-pong.h             |  34 +++++
  include/standard-headers/linux/virtio_ids.h |   1 +
  8 files changed, 282 insertions(+)

create mode 100644 hw/s390x/virtio-ccw-pong.c create mode 100644 hw/virtio/virtio-pong.c create mode 100644 include/hw/virtio/virtio-pong.h

#4 lore raw
Quoted 12 lines · Christian Borntraeger
Quoted 9 lines · Pierre Morel

Hello All,

This series presents a VIRTIO test device which receives data on its input channel and sends back a simple checksum for the data it received on its output channel.
The goal is to allow a simple VIRTIO device driver to check the VIRTIO initialization and various data transfer.

Quoted 5 lines
Quoted 3 lines

For this I introduced a new device ID for the device and having no Linux driver but a kvm-unit-test driver, I have the following questions:

I think we should reserve an ID in the official virtio spec then for such a device?

Yes, you are right, I think we should.

Quoted 1 line

Maybe also add mst for such things.

Yes, I did.

Thanks,
Pierre

Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen
#5 lore raw
In reply to Christian Borntraeger
Quoted 10 lines · On Mon, 30 Aug 2021 11:51:51 +0200 Christian Borntraeger…
Quoted 9 lines · Pierre Morel

Hello All,

This series presents a VIRTIO test device which receives data on its input channel and sends back a simple checksum for the data it received on its output channel.

The goal is to allow a simple VIRTIO device driver to check the VIRTIO initialization and various data transfer.

Can you please elaborate a little on the objectives.

Quoted 7 lines
Quoted 4 lines

For this I introduced a new device ID for the device and having no Linux driver but a kvm-unit-test driver, I have the following questions:

I think we should reserve an ID in the official virtio spec then for such a device? Maybe also add mst for such things.

I agree having ID reserved is a good idea. But then if we are going to introduce an official test device, I believe we should write a specification for it as well. Yes having the guarantee that test devices and real devices won't mix is a value in itself, but if we had a standardized test device, whoever does work with it would not have to ask themselves is this test device compatible with this test device driver.

Quoted 5 lines
Quoted 5 lines

Is there another way to advertise new VIRTIO IDs but Linux? If this QEMU test meet interest, should I write a Linux test program?

You may not simply claim and advertise a VIRTIO ID. The virtio ids are allocated by the virtio standardisation body, and the list of the IDs reserved in the v1.1-cs01 incarnation of the spec can be found here:
https://docs.oasis-open.org/virtio/virtio/v1.1/cs01/virtio-v1.1-cs01.html#x1-1930005

For how to contribute to the virtio specification please take look at this:
https://github.com/oasis-tcs/virtio-admin/blob/master/README.md

Quoted 21 lines
Quoted 21 lines

Regards,
Pierre

Pierre Morel (2):
virtio: Linux: Update of virtio_ids
s390x: ccw: A simple test device for virtio CCW

  hw/s390x/meson.build                        |   1 +
  hw/s390x/virtio-ccw-pong.c                  |  66 ++++++++
  hw/s390x/virtio-ccw.h                       |  13 ++
  hw/virtio/Kconfig                           |   5 +
  hw/virtio/meson.build                       |   1 +
  hw/virtio/virtio-pong.c                     | 161 ++++++++++++++++++++
  include/hw/virtio/virtio-pong.h             |  34 +++++
  include/standard-headers/linux/virtio_ids.h |   1 +
  8 files changed, 282 insertions(+)

create mode 100644 hw/s390x/virtio-ccw-pong.c create mode 100644 hw/virtio/virtio-pong.c create mode 100644 include/hw/virtio/virtio-pong.h

#6 lore raw
Quoted 7 lines · Halil Pasic
Quoted 4 lines · On Mon, 30 Aug 2021 11:51:51 +0200 Christian Borntraeger…
Quoted 3 lines · Pierre Morel

Hello All,

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

This series presents a VIRTIO test device which receives data on its input channel and sends back a simple checksum for the data it received on its output channel.

The goal is to allow a simple VIRTIO device driver to check the VIRTIO initialization and various data transfer.

Can you please elaborate a little on the objectives.

Yes I will, but I must think a lot more about it, I think doing the specifications you speak about later in this response is the right way to do it.

Quoted 9 lines
Quoted 8 lines
Quoted 5 lines

For this I introduced a new device ID for the device and having no Linux driver but a kvm-unit-test driver, I have the following questions:

I think we should reserve an ID in the official virtio spec then for such a device? Maybe also add mst for such things.

Quoted 7 lines

I agree having ID reserved is a good idea. But then if we are going to introduce an official test device, I believe we should write a specification for it as well. Yes having the guarantee that test devices and real devices won't mix is a value in itself, but if we had a standardized test device, whoever does work with it would not have to ask themselves is this test device compatible with this test device driver.

Yes right.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

Is there another way to advertise new VIRTIO IDs but Linux? If this QEMU test meet interest, should I write a Linux test program?

Quoted 8 lines

You may not simply claim and advertise a VIRTIO ID. The virtio ids are allocated by the virtio standardisation body, and the list of the IDs reserved in the v1.1-cs01 incarnation of the spec can be found here:
https://docs.oasis-open.org/virtio/virtio/v1.1/cs01/virtio-v1.1-cs01.html#x1-1930005

For how to contribute to the virtio specification please take look at this:
https://github.com/oasis-tcs/virtio-admin/blob/master/README.md

Thanks, I will go this way.

Thanks for these constructive answers,

Regards,
Pierre

Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen