From nobody Thu Nov 6 06:39:50 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536783263177451.0307439412379; Wed, 12 Sep 2018 13:14:23 -0700 (PDT) Received: from localhost ([::1]:38254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0BWn-0001ui-7N for importer@patchew.org; Wed, 12 Sep 2018 16:14:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0BRZ-0006mv-PS for qemu-devel@nongnu.org; Wed, 12 Sep 2018 16:08:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0BRV-0002EI-0c for qemu-devel@nongnu.org; Wed, 12 Sep 2018 16:08:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g0BRU-0002Df-LE for qemu-devel@nongnu.org; Wed, 12 Sep 2018 16:08:52 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8CJwkwQ112667 for ; Wed, 12 Sep 2018 16:08:51 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mf8bmk475-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 12 Sep 2018 16:08:50 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 12 Sep 2018 14:08:50 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 12 Sep 2018 14:08:45 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8CK8grI24707134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Sep 2018 13:08:42 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 050F46E052; Wed, 12 Sep 2018 14:08:42 -0600 (MDT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 119D36E04E; Wed, 12 Sep 2018 14:08:39 -0600 (MDT) Received: from localhost.localdomain (unknown [9.80.213.181]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTPS; Wed, 12 Sep 2018 14:08:38 -0600 (MDT) From: Tony Krowiak To: qemu-devel@nongnu.org Date: Wed, 12 Sep 2018 16:08:18 -0400 X-Mailer: git-send-email 1.7.1 In-Reply-To: <1536782900-17656-1-git-send-email-akrowiak@linux.vnet.ibm.com> References: <1536782900-17656-1-git-send-email-akrowiak@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18091220-0020-0000-0000-00000E64106D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009709; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01087379; UDB=6.00561493; IPR=6.00867391; MB=3.00023257; MTD=3.00000008; XFM=3.00000015; UTC=2018-09-12 20:08:48 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091220-0021-0000-0000-0000630144B6 Message-Id: <1536782900-17656-5-git-send-email-akrowiak@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-09-12_10:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120198 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v8 4/6] s390x/ap: base Adjunct Processor (AP) object model X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, akrowiak@linux.vnet.ibm.com, cohuck@redhat.com, david@redhat.com, pmorel@linux.vnet.ibm.com, fiuczy@linux.ibm.com, eskultet@redhat.com, agraf@suse.de, borntraeger@de.ibm.com, jjherne@linux.vnet.ibm.com, mimu@linux.ibm.com, Tony Krowiak , heiko.carstens@de.ibm.com, eric.auger@redhat.com, alex.williamson@redhat.com, bjsdjshi@linux.vnet.ibm.com, rth@twiddle.net, mjrosato@linux.vnet.ibm.com, pasic@linux.vnet.ibm.com, alifm@linux.vnet.ibm.com, qemu-s390x@nongnu.org, schwidefsky@de.ibm.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Tony Krowiak Introduces the base object model for virtualizing AP devices. Signed-off-by: Tony Krowiak --- MAINTAINERS | 12 +++++++ hw/s390x/Makefile.objs | 2 + hw/s390x/ap-bridge.c | 76 ++++++++++++++++++++++++++++++++++++++= ++++ hw/s390x/ap-device.c | 39 +++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 4 ++ include/hw/s390x/ap-bridge.h | 37 ++++++++++++++++++++ include/hw/s390x/ap-device.h | 38 +++++++++++++++++++++ 7 files changed, 208 insertions(+), 0 deletions(-) create mode 100644 hw/s390x/ap-bridge.c create mode 100644 hw/s390x/ap-device.c create mode 100644 include/hw/s390x/ap-bridge.h create mode 100644 include/hw/s390x/ap-device.h diff --git a/MAINTAINERS b/MAINTAINERS index d12518c..97e8ed8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1199,6 +1199,18 @@ F: include/hw/s390x/s390-ccw.h T: git git://github.com/cohuck/qemu.git s390-next L: qemu-s390x@nongnu.org =20 +vfio-ap +M: Christian Borntraeger +M: Tony Krowiak +M: Halil Pasic +M: Pierre Morel +S: Supported +F: hw/s390x/ap-device.c +F: hw/s390x/ap-bridge.c +F: include/hw/s390x/ap-device.h +F: include/hw/s390x/ap-bridge.h +L: qemu-s390x@nongnu.org + vhost M: Michael S. Tsirkin S: Supported diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs index 93282f7..add89b1 100644 --- a/hw/s390x/Makefile.objs +++ b/hw/s390x/Makefile.objs @@ -20,3 +20,5 @@ obj-$(CONFIG_TCG) +=3D tod-qemu.o obj-$(CONFIG_KVM) +=3D s390-skeys-kvm.o 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 diff --git a/hw/s390x/ap-bridge.c b/hw/s390x/ap-bridge.c new file mode 100644 index 0000000..4f10425 --- /dev/null +++ b/hw/s390x/ap-bridge.c @@ -0,0 +1,76 @@ +/* + * ap bridge + * + * Copyright 2018 IBM Corp. + * Author(s): Halil Pasic + * + * 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 "hw/sysbus.h" +#include "qemu/bitops.h" +#include "hw/s390x/ap-bridge.h" +#include "cpu.h" + +static char *vfio_ap_bus_get_dev_path(DeviceState *dev) +{ + /* at most one */ + return g_strdup_printf("/1"); +} + +static void vfio_ap_bus_class_init(ObjectClass *klass, void *data) +{ + BusClass *k =3D BUS_CLASS(klass); + + k->get_dev_path =3D vfio_ap_bus_get_dev_path; + /* More than one vfio-ap device does not make sense */ + k->max_dev =3D 1; +} + +static const TypeInfo vfio_ap_bus_info =3D { + .name =3D TYPE_VFIO_AP_BUS, + .parent =3D TYPE_BUS, + .instance_size =3D sizeof(VFIOAPBus), + .class_init =3D vfio_ap_bus_class_init, +}; + +void s390_init_ap(void) +{ + DeviceState *dev; + + /* Create bridge device */ + dev =3D qdev_create(NULL, TYPE_AP_BRIDGE); + object_property_add_child(qdev_get_machine(), TYPE_AP_BRIDGE, + OBJECT(dev), NULL); + qdev_init_nofail(dev); + + /* Create bus on bridge device */ + qbus_create(TYPE_VFIO_AP_BUS, dev, TYPE_VFIO_AP_BUS); + } + + + +static void ap_bridge_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); +} + +static const TypeInfo ap_bridge_info =3D { + .name =3D TYPE_AP_BRIDGE, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(APBridge), + .class_init =3D ap_bridge_class_init, +}; + +static void ap_register(void) +{ + type_register_static(&ap_bridge_info); + type_register_static(&vfio_ap_bus_info); +} + +type_init(ap_register) diff --git a/hw/s390x/ap-device.c b/hw/s390x/ap-device.c new file mode 100644 index 0000000..3cd4bae --- /dev/null +++ b/hw/s390x/ap-device.c @@ -0,0 +1,39 @@ +/* + * Adjunct Processor (AP) matrix device + * + * Copyright 2018 IBM Corp. + * Author(s): Tony Krowiak + * + * 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 "qemu/module.h" +#include "qapi/error.h" +#include "hw/qdev.h" +#include "hw/s390x/ap-device.h" + +static void ap_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->desc =3D "AP device class"; + dc->hotpluggable =3D false; +} + +static const TypeInfo ap_device_info =3D { + .name =3D AP_DEVICE_TYPE, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(APDevice), + .class_size =3D sizeof(APDeviceClass), + .class_init =3D ap_class_init, + .abstract =3D true, +}; + +static void ap_device_register(void) +{ + type_register_static(&ap_device_info); +} + +type_init(ap_device_register) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index f0f7fdc..3c100c2 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -32,6 +32,7 @@ #include "ipl.h" #include "hw/s390x/s390-virtio-ccw.h" #include "hw/s390x/css-bridge.h" +#include "hw/s390x/ap-bridge.h" #include "migration/register.h" #include "cpu_models.h" #include "hw/nmi.h" @@ -263,6 +264,9 @@ static void ccw_init(MachineState *machine) /* init the SIGP facility */ s390_init_sigp(); =20 + /* create AP bridge and bus(es) */ + s390_init_ap(); + /* get a BUS */ css_bus =3D virtual_css_bus_init(); s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline, diff --git a/include/hw/s390x/ap-bridge.h b/include/hw/s390x/ap-bridge.h new file mode 100644 index 0000000..7841ec2 --- /dev/null +++ b/include/hw/s390x/ap-bridge.h @@ -0,0 +1,37 @@ +/* + * ap bridge + * + * Copyright 2018 IBM Corp. + * Author(s): Halil Pasic + * + * 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_AP_BRIDGE_H +#define HW_S390X_AP_BRIDGE_H +#include "qom/object.h" +#include "hw/qdev-core.h" +#include "hw/sysbus.h" + +typedef struct APBridge { + SysBusDevice sysbus_dev; + bool css_dev_path; +} APBridge; + +#define TYPE_AP_BRIDGE "ap-bridge" +#define AP_BRIDGE(obj) \ + OBJECT_CHECK(APBridge, (obj), TYPE_AP_BRIDGE) + +typedef struct VFIOAPBus { + BusState parent_obj; +} VFIOAPBus; + +#define TYPE_VFIO_AP_BUS "vfio-ap-bus" +#define VFIO_AP_BUS(obj) \ + OBJECT_CHECK(VFIOAPBus, (obj), TYPE_VFIO_AP_BUS) + +void s390_init_ap(void); + +#endif diff --git a/include/hw/s390x/ap-device.h b/include/hw/s390x/ap-device.h new file mode 100644 index 0000000..693df90 --- /dev/null +++ b/include/hw/s390x/ap-device.h @@ -0,0 +1,38 @@ +/* + * Adjunct Processor (AP) matrix device interfaces + * + * Copyright 2018 IBM Corp. + * Author(s): Tony Krowiak + * + * 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_AP_DEVICE_H +#define HW_S390X_AP_DEVICE_H + +#define AP_DEVICE_TYPE "ap-device" + +typedef struct APDevice { + DeviceState parent_obj; +} APDevice; + +typedef struct APDeviceClass { + DeviceClass parent_class; +} APDeviceClass; + +static inline APDevice *to_ap_dev(DeviceState *dev) +{ + return container_of(dev, APDevice, parent_obj); +} + +#define AP_DEVICE(obj) \ + OBJECT_CHECK(APDevice, (obj), AP_DEVICE_TYPE) + +#define AP_DEVICE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(APDeviceClass, (obj), AP_DEVICE_TYPE) + +#define AP_DEVICE_CLASS(klass) \ + OBJECT_CLASS_CHECK(APDeviceClass, (klass), AP_DEVICE_TYPE) + +#endif /* HW_S390X_AP_DEVICE_H */ --=20 1.7.1