From nobody Sun Feb 8 14:34:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1574940630; cv=none; d=zohomail.com; s=zohoarc; b=bIV2LeUJ1fshyyuzGl7Sa8lRXD5dv6n/g7oQtqk2+99FGzPDwsLhgyIUM+w8OUbGVFkjhNLF0OxJ2fcj4Ty2h7C4HlShCINq+0IIOk4S0CsURCAQ4I9w70vOsNKJf+Gl1ye0Qk/s9gpGSk9EXdYpOCryD2Ghnz39tdz/9O6uXdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574940630; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=G8oPwV9BO4XdckPixG/pq4QQD59tmDcissAiyzJKHzM=; b=nAsniqjIQUlbljthA02usoVCeJ0jaVFLKnY6SnmvG3e/BdNb5tOe+dXrz3l54lpF3loceU1Aej83wcSxwSiSN+3XTdJ3OkErghLo/zuEeL/WCuC+W3pMqgCB9YlVx6wvPOBquBkUJObhBzb+NJ0/DKwiEqr12SV9mWs1B9Z8sNA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574940630468283.1233685553576; Thu, 28 Nov 2019 03:30:30 -0800 (PST) Received: from localhost ([::1]:47904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iaI0C-00037L-Av for importer@patchew.org; Thu, 28 Nov 2019 06:30:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56721) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iaHjc-0001K1-Hg for qemu-devel@nongnu.org; Thu, 28 Nov 2019 06:13:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iaHXU-000450-VE for qemu-devel@nongnu.org; Thu, 28 Nov 2019 06:00:52 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:25222) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iaHXS-00041I-VK for qemu-devel@nongnu.org; Thu, 28 Nov 2019 06:00:48 -0500 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xASAvCn6003984 for ; Thu, 28 Nov 2019 06:00:46 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2whmt0j8mq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 28 Nov 2019 06:00:45 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Nov 2019 11:00:43 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 28 Nov 2019 11:00:41 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xASB0ddv50659456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Nov 2019 11:00:39 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A99D4C05E; Thu, 28 Nov 2019 11:00:39 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C8B04C04A; Thu, 28 Nov 2019 11:00:39 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.185.119]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 28 Nov 2019 11:00:39 +0000 (GMT) From: Pierre Morel To: qemu-s390x@nongnu.org Subject: [PATCH v2 1/1] s390x: css: pong, channel subsystem test device Date: Thu, 28 Nov 2019 12:00:37 +0100 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1574938837-21078-1-git-send-email-pmorel@linux.ibm.com> References: <1574938837-21078-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19112811-4275-0000-0000-000003877545 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19112811-4276-0000-0000-0000389B06C7 Message-Id: <1574938837-21078-2-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-28_01:2019-11-28,2019-11-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 bulkscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 spamscore=0 suspectscore=3 mlxscore=0 clxscore=1015 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911280095 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, qemu-devel@nongnu.org, pasic@linux.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is a test device for channel subsystem. Most of the CSS instructions are handled by the common code. The PONG_READ and PONG_WRITE CCW commands allow to test the SSCH instruction with both read and write commands. It is also possible to define the Control Unit type with the cu_type property. Currently only the kvm-unit-test css test uses the PONG device. Signed-off-by: Pierre Morel --- default-configs/s390x-softmmu.mak | 1 + hw/s390x/Kconfig | 3 + hw/s390x/Makefile.objs | 1 + hw/s390x/ccw-pong.c | 134 ++++++++++++++++++++++++++++++ include/hw/s390x/pong.h | 48 +++++++++++ 5 files changed, 187 insertions(+) create mode 100644 hw/s390x/ccw-pong.c create mode 100644 include/hw/s390x/pong.h diff --git a/default-configs/s390x-softmmu.mak b/default-configs/s390x-soft= mmu.mak index f2287a133f..72711912cd 100644 --- a/default-configs/s390x-softmmu.mak +++ b/default-configs/s390x-softmmu.mak @@ -7,6 +7,7 @@ #CONFIG_VFIO_CCW=3Dn #CONFIG_VIRTIO_PCI=3Dn #CONFIG_WDT_DIAG288=3Dn +#CONFIG_CCW_TESTDEV=3Dn =20 # Boards: # diff --git a/hw/s390x/Kconfig b/hw/s390x/Kconfig index 5e7d8a2bae..041ede333e 100644 --- a/hw/s390x/Kconfig +++ b/hw/s390x/Kconfig @@ -10,3 +10,6 @@ config S390_CCW_VIRTIO select SCLPCONSOLE select VIRTIO_CCW select MSI_NONBROKEN + +config CCW_TESTDEV + default y if TEST_DEVICES diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs index e02ed80b68..e74d0efd9d 100644 --- a/hw/s390x/Makefile.objs +++ b/hw/s390x/Makefile.objs @@ -34,3 +34,4 @@ obj-$(CONFIG_KVM) +=3D s390-stattrib-kvm.o obj-y +=3D s390-ccw.o obj-y +=3D ap-device.o obj-y +=3D ap-bridge.o +obj-y +=3D ccw-pong.o diff --git a/hw/s390x/ccw-pong.c b/hw/s390x/ccw-pong.c new file mode 100644 index 0000000000..ae09357f72 --- /dev/null +++ b/hw/s390x/ccw-pong.c @@ -0,0 +1,134 @@ +/* + * CCW PING-PONG + * + * Copyright 2019 IBM Corp. + * Author(s): Pierre Morel + * + * 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. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "cpu.h" +#include "exec/address-spaces.h" +#include "hw/s390x/css.h" +#include "hw/s390x/css-bridge.h" +#include "hw/qdev-properties.h" +#include "hw/s390x/pong.h" + +#define PONG_BUF_SIZE 0x1000 +static char buf[PONG_BUF_SIZE]; + +static int pong_ccw_cb(SubchDev *sch, CCW1 ccw) +{ + int rc =3D 0; + static int value; + int len; + + len =3D (ccw.count > PONG_BUF_SIZE) ? PONG_BUF_SIZE : ccw.count; + switch (ccw.cmd_code) { + case PONG_WRITE: + rc =3D ccw_dstream_read_buf(&sch->cds, buf, len); + value =3D atol(buf); + break; + case PONG_READ: + sprintf(buf, "%08x", value + 1); + rc =3D ccw_dstream_write_buf(&sch->cds, buf, len); + break; + default: + rc =3D -ENOSYS; + break; + } + + sch->curr_status.scsw.count =3D ccw_dstream_residual_count(&sch->cds); + + if (rc =3D=3D -EIO) { + /* I/O error, specific devices generate specific conditions */ + SCHIB *schib =3D &sch->curr_status; + + sch->curr_status.scsw.dstat =3D SCSW_DSTAT_UNIT_CHECK; + sch->sense_data[0] =3D 0x40; /* intervention-req */ + schib->scsw.ctrl &=3D ~SCSW_ACTL_START_PEND; + schib->scsw.ctrl &=3D ~SCSW_CTRL_MASK_STCTL; + schib->scsw.ctrl |=3D SCSW_STCTL_PRIMARY | SCSW_STCTL_SECONDARY | + SCSW_STCTL_ALERT | SCSW_STCTL_STATUS_PEND; + } + return rc; +} + +static void pong_ccw_realize(DeviceState *ds, Error **errp) +{ + uint16_t chpid; + CcwPONGDevice *dev =3D CCW_PONG(ds); + CcwDevice *cdev =3D CCW_DEVICE(ds); + CCWDeviceClass *cdk =3D CCW_DEVICE_GET_CLASS(cdev); + SubchDev *sch; + Error *err =3D NULL; + + sch =3D css_create_sch(cdev->devno, errp); + if (!sch) { + return; + } + + sch->driver_data =3D dev; + cdev->sch =3D sch; + chpid =3D css_find_free_chpid(sch->cssid); + + if (chpid > MAX_CHPID) { + error_setg(&err, "No available chpid to use."); + goto out_err; + } + + sch->id.reserved =3D 0xff; + sch->id.cu_type =3D dev->cu_type; + css_sch_build_virtual_schib(sch, (uint8_t)chpid, CCW_PONG_CHPID_TYPE); + sch->do_subchannel_work =3D do_subchannel_work_virtual; + sch->ccw_cb =3D pong_ccw_cb; + + cdk->realize(cdev, &err); + if (err) { + goto out_err; + } + + css_reset_sch(sch); + return; + +out_err: + error_propagate(errp, err); + css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL); + cdev->sch =3D NULL; + g_free(sch); +} + +static Property pong_ccw_properties[] =3D { + DEFINE_PROP_UINT16("cu_type", CcwPONGDevice, cu_type, CCW_PONG_CU_TYPE= ), + DEFINE_PROP_END_OF_LIST(), +}; + +static void pong_ccw_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->props =3D pong_ccw_properties; + dc->bus_type =3D TYPE_VIRTUAL_CSS_BUS; + dc->realize =3D pong_ccw_realize; + dc->hotpluggable =3D false; +} + +static const TypeInfo pong_ccw_info =3D { + .name =3D TYPE_CCW_PONG, + .parent =3D TYPE_CCW_DEVICE, + .instance_size =3D sizeof(CcwPONGDevice), + .class_init =3D pong_ccw_class_init, + .class_size =3D sizeof(CcwPONGClass), +}; + +static void pong_ccw_register(void) +{ + type_register_static(&pong_ccw_info); +} + +type_init(pong_ccw_register) diff --git a/include/hw/s390x/pong.h b/include/hw/s390x/pong.h new file mode 100644 index 0000000000..b14af7ca86 --- /dev/null +++ b/include/hw/s390x/pong.h @@ -0,0 +1,48 @@ +/* + * ccw-attached PONG definitions + * + * Copyright 2019 IBM Corp. + * Author(s): Pierre Morel + * + * 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 HW_S390X_PONG_CCW_H +#define HW_S390X_PONG_CCW_H + +#include "hw/sysbus.h" +#include "hw/s390x/css.h" +#include "hw/s390x/ccw-device.h" + +#define CCW_PONG_CU_TYPE 0xc0ca +#define CCW_PONG_CHPID_TYPE 0xd0 + +#define TYPE_CCW_PONG "ccw-pong" + +/* Local Channel Commands */ +#define PONG_WRITE 0x21 /* Write */ +#define PONG_READ 0x22 /* Read buffer */ + +#define CCW_PONG(obj) \ + OBJECT_CHECK(CcwPONGDevice, (obj), TYPE_CCW_PONG) +#define CCW_PONG_CLASS(klass) \ + OBJECT_CLASS_CHECK(CcwPONGClass, (klass), TYPE_CCW_PONG) +#define CCW_PONG_GET_CLASS(obj) \ + OBJECT_GET_CLASS(CcwPONGClass, (obj), TYPE_CCW_PONG) + +typedef struct CcwPONGDevice { + CcwDevice parent_obj; + uint16_t cu_type; +} CcwPONGDevice; + +typedef struct CcwPONGClass { + CCWDeviceClass parent_class; + + void (*init)(CcwPONGDevice *, Error **); + int (*read_payload)(CcwPONGDevice *); + int (*write_payload)(CcwPONGDevice *, uint8_t); +} CcwPONGClass; + +#endif --=20 2.17.0