To test a write command with the SSCH instruction we need a QEMU device, with control unit type 0xC0CA. The PONG device is such a device. This type of device responds to PONG_WRITE requests by incrementing an integer, stored as a string at offset 0 of the CCW data. Signed-off-by: Pierre Morel <pmorel@xxxxxxxxxxxxx> --- s390x/css.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/s390x/css.c b/s390x/css.c index c94a916..da80574 100644 --- a/s390x/css.c +++ b/s390x/css.c @@ -21,6 +21,12 @@ #include <css.h> #define PONG_CU_TYPE 0xc0ca +/* Channel Commands for PONG device */ +#define PONG_WRITE 0x21 /* Write */ +#define PONG_READ 0x22 /* Read buffer */ + +#define BUFSZ 9 +static char buffer[BUFSZ]; struct lowcore *lowcore = (void *)0x0; @@ -274,6 +280,53 @@ unreg_cb: unregister_io_int_func(irq_io); } +static void test_ping(void) +{ + int success, result; + int cnt = 0, max = 4; + + if (senseid.cu_type != PONG_CU) { + report_skip("Device is not a pong device."); + return; + } + + result = register_io_int_func(irq_io); + if (result) { + report(0, "Could not register IRQ handler"); + return; + } + + while (cnt++ < max) { + snprintf(buffer, BUFSZ, "%08x\n", cnt); + success = start_subchannel(PONG_WRITE, buffer, BUFSZ, 0); + if (!success) { + report(0, "start_subchannel failed"); + goto unreg_cb; + } + + wait_for_interrupt(PSW_MASK_IO); + + success = start_subchannel(PONG_READ, buffer, BUFSZ, 0); + if (!success) { + report(0, "start_subchannel failed"); + goto unreg_cb; + } + + wait_for_interrupt(PSW_MASK_IO); + + result = atol(buffer); + if (result != (cnt + 1)) { + report(0, "Bad answer from pong: %08x - %08x", + cnt, result); + goto unreg_cb; + } + } + report(1, "ping-pong count 0x%08x", cnt); + +unreg_cb: + unregister_io_int_func(irq_io); +} + static struct { const char *name; void (*func)(void); @@ -281,6 +334,7 @@ static struct { { "enumerate (stsch)", test_enumerate }, { "enable (msch)", test_enable }, { "sense (ssch/tsch)", test_sense }, + { "ping-pong (ssch/tsch)", test_ping }, { NULL, NULL } }; -- 2.25.1