2013-01-24 10:08:55 +04:00
|
|
|
/*
|
|
|
|
* virtio ccw target definitions
|
|
|
|
*
|
2015-05-27 14:11:59 +03:00
|
|
|
* Copyright 2012,2015 IBM Corp.
|
2013-01-24 10:08:55 +04:00
|
|
|
* Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
|
2015-05-27 14:11:59 +03:00
|
|
|
* Pierre Morel <pmorel@linux.vnet.ibm.com>
|
2013-01-24 10:08:55 +04:00
|
|
|
*
|
|
|
|
* 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_VIRTIO_CCW_H
|
|
|
|
#define HW_S390X_VIRTIO_CCW_H
|
|
|
|
|
2016-06-22 20:11:19 +03:00
|
|
|
#include "hw/virtio/virtio-blk.h"
|
|
|
|
#include "hw/virtio/virtio-net.h"
|
|
|
|
#include "hw/virtio/virtio-serial.h"
|
|
|
|
#include "hw/virtio/virtio-scsi.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2013-04-19 18:16:50 +04:00
|
|
|
#ifdef CONFIG_VHOST_SCSI
|
2016-06-22 20:11:19 +03:00
|
|
|
#include "hw/virtio/vhost-scsi.h"
|
2013-04-19 18:16:50 +04:00
|
|
|
#endif
|
2016-06-22 20:11:19 +03:00
|
|
|
#include "hw/virtio/virtio-balloon.h"
|
|
|
|
#include "hw/virtio/virtio-rng.h"
|
2016-11-03 15:39:15 +03:00
|
|
|
#include "hw/virtio/virtio-crypto.h"
|
2016-06-22 20:11:19 +03:00
|
|
|
#include "hw/virtio/virtio-bus.h"
|
2016-08-16 15:27:22 +03:00
|
|
|
#ifdef CONFIG_VHOST_VSOCK
|
|
|
|
#include "hw/virtio/vhost-vsock.h"
|
|
|
|
#endif /* CONFIG_VHOST_VSOCK */
|
2017-09-15 17:40:32 +03:00
|
|
|
#include "hw/virtio/virtio-gpu.h"
|
2017-10-09 17:01:50 +03:00
|
|
|
#include "hw/virtio/virtio-input.h"
|
2016-01-27 11:05:26 +03:00
|
|
|
|
2016-06-22 20:11:19 +03:00
|
|
|
#include "hw/s390x/s390_flic.h"
|
|
|
|
#include "hw/s390x/css.h"
|
2016-02-26 08:46:12 +03:00
|
|
|
#include "ccw-device.h"
|
|
|
|
#include "hw/s390x/css-bridge.h"
|
2013-01-24 10:08:55 +04:00
|
|
|
|
|
|
|
#define VIRTIO_CCW_CU_TYPE 0x3832
|
|
|
|
#define VIRTIO_CCW_CHPID_TYPE 0x32
|
|
|
|
|
|
|
|
#define CCW_CMD_SET_VQ 0x13
|
|
|
|
#define CCW_CMD_VDEV_RESET 0x33
|
|
|
|
#define CCW_CMD_READ_FEAT 0x12
|
|
|
|
#define CCW_CMD_WRITE_FEAT 0x11
|
|
|
|
#define CCW_CMD_READ_CONF 0x22
|
|
|
|
#define CCW_CMD_WRITE_CONF 0x21
|
|
|
|
#define CCW_CMD_WRITE_STATUS 0x31
|
|
|
|
#define CCW_CMD_SET_IND 0x43
|
|
|
|
#define CCW_CMD_SET_CONF_IND 0x53
|
|
|
|
#define CCW_CMD_READ_VQ_CONF 0x32
|
2016-09-07 13:58:40 +03:00
|
|
|
#define CCW_CMD_READ_STATUS 0x72
|
2013-02-06 13:31:37 +04:00
|
|
|
#define CCW_CMD_SET_IND_ADAPTER 0x73
|
2014-12-11 16:25:12 +03:00
|
|
|
#define CCW_CMD_SET_VIRTIO_REV 0x83
|
2013-01-24 10:08:55 +04:00
|
|
|
|
|
|
|
#define TYPE_VIRTIO_CCW_DEVICE "virtio-ccw-device"
|
2020-09-16 21:25:18 +03:00
|
|
|
OBJECT_DECLARE_TYPE(VirtioCcwDevice, VirtIOCCWDeviceClass, VIRTIO_CCW_DEVICE)
|
2013-01-24 10:08:55 +04:00
|
|
|
|
|
|
|
typedef struct VirtioBusState VirtioCcwBusState;
|
|
|
|
typedef struct VirtioBusClass VirtioCcwBusClass;
|
|
|
|
|
|
|
|
#define TYPE_VIRTIO_CCW_BUS "virtio-ccw-bus"
|
2020-09-01 00:07:33 +03:00
|
|
|
DECLARE_OBJ_CHECKERS(VirtioCcwBusState, VirtioCcwBusClass,
|
|
|
|
VIRTIO_CCW_BUS, TYPE_VIRTIO_CCW_BUS)
|
2013-01-24 10:08:55 +04:00
|
|
|
|
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtIOCCWDeviceClass {
|
2016-02-26 08:46:12 +03:00
|
|
|
CCWDeviceClass parent_class;
|
2015-02-27 16:53:39 +03:00
|
|
|
void (*realize)(VirtioCcwDevice *dev, Error **errp);
|
qdev: Unrealize must not fail
Devices may have component devices and buses.
Device realization may fail. Realization is recursive: a device's
realize() method realizes its components, and device_set_realized()
realizes its buses (which should in turn realize the devices on that
bus, except bus_set_realized() doesn't implement that, yet).
When realization of a component or bus fails, we need to roll back:
unrealize everything we realized so far. If any of these unrealizes
failed, the device would be left in an inconsistent state. Must not
happen.
device_set_realized() lets it happen: it ignores errors in the roll
back code starting at label child_realize_fail.
Since realization is recursive, unrealization must be recursive, too.
But how could a partly failed unrealize be rolled back? We'd have to
re-realize, which can fail. This design is fundamentally broken.
device_set_realized() does not roll back at all. Instead, it keeps
unrealizing, ignoring further errors.
It can screw up even for a device with no buses: if the lone
dc->unrealize() fails, it still unregisters vmstate, and calls
listeners' unrealize() callback.
bus_set_realized() does not roll back either. Instead, it stops
unrealizing.
Fortunately, no unrealize method can fail, as we'll see below.
To fix the design error, drop parameter @errp from all the unrealize
methods.
Any unrealize method that uses @errp now needs an update. This leads
us to unrealize() methods that can fail. Merely passing it to another
unrealize method cannot cause failure, though. Here are the ones that
do other things with @errp:
* virtio_serial_device_unrealize()
Fails when qbus_set_hotplug_handler() fails, but still does all the
other work. On failure, the device would stay realized with its
resources completely gone. Oops. Can't happen, because
qbus_set_hotplug_handler() can't actually fail here. Pass
&error_abort to qbus_set_hotplug_handler() instead.
* hw/ppc/spapr_drc.c's unrealize()
Fails when object_property_del() fails, but all the other work is
already done. On failure, the device would stay realized with its
vmstate registration gone. Oops. Can't happen, because
object_property_del() can't actually fail here. Pass &error_abort
to object_property_del() instead.
* spapr_phb_unrealize()
Fails and bails out when remove_drcs() fails, but other work is
already done. On failure, the device would stay realized with some
of its resources gone. Oops. remove_drcs() fails only when
chassis_from_bus()'s object_property_get_uint() fails, and it can't
here. Pass &error_abort to remove_drcs() instead.
Therefore, no unrealize method can fail before this patch.
device_set_realized()'s recursive unrealization via bus uses
object_property_set_bool(). Can't drop @errp there, so pass
&error_abort.
We similarly unrealize with object_property_set_bool() elsewhere,
always ignoring errors. Pass &error_abort instead.
Several unrealize methods no longer handle errors from other unrealize
methods: virtio_9p_device_unrealize(),
virtio_input_device_unrealize(), scsi_qdev_unrealize(), ...
Much of the deleted error handling looks wrong anyway.
One unrealize methods no longer ignore such errors:
usb_ehci_pci_exit().
Several realize methods no longer ignore errors when rolling back:
v9fs_device_realize_common(), pci_qdev_unrealize(),
spapr_phb_realize(), usb_qdev_realize(), vfio_ccw_realize(),
virtio_device_realize().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-17-armbru@redhat.com>
2020-05-05 18:29:24 +03:00
|
|
|
void (*unrealize)(VirtioCcwDevice *dev);
|
2018-05-07 16:27:57 +03:00
|
|
|
void (*parent_reset)(DeviceState *dev);
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2013-01-24 10:08:55 +04:00
|
|
|
|
2013-02-15 13:18:43 +04:00
|
|
|
/* Performance improves when virtqueue kick processing is decoupled from the
|
|
|
|
* vcpu thread using ioeventfd for some devices. */
|
|
|
|
#define VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT 1
|
|
|
|
#define VIRTIO_CCW_FLAG_USE_IOEVENTFD (1 << VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT)
|
|
|
|
|
2013-01-24 10:08:55 +04:00
|
|
|
struct VirtioCcwDevice {
|
2016-02-26 08:46:12 +03:00
|
|
|
CcwDevice parent_obj;
|
2014-12-11 16:25:12 +03:00
|
|
|
int revision;
|
2015-09-11 16:16:44 +03:00
|
|
|
uint32_t max_rev;
|
2013-01-24 10:08:55 +04:00
|
|
|
VirtioBusState bus;
|
2013-02-15 13:18:43 +04:00
|
|
|
uint32_t flags;
|
2013-02-06 13:31:37 +04:00
|
|
|
uint8_t thinint_isc;
|
2013-07-15 19:45:03 +04:00
|
|
|
AdapterRoutes routes;
|
2013-01-24 10:08:55 +04:00
|
|
|
/* Guest provided values: */
|
2013-08-01 19:27:00 +04:00
|
|
|
IndAddr *indicators;
|
|
|
|
IndAddr *indicators2;
|
|
|
|
IndAddr *summary_indicator;
|
2013-02-06 13:31:37 +04:00
|
|
|
uint64_t ind_bit;
|
2017-02-14 16:06:07 +03:00
|
|
|
bool force_revision_1;
|
2013-01-24 10:08:55 +04:00
|
|
|
};
|
|
|
|
|
2014-12-11 16:25:12 +03:00
|
|
|
/* The maximum virtio revision we support. */
|
2016-09-07 14:04:46 +03:00
|
|
|
#define VIRTIO_CCW_MAX_REV 2
|
2015-09-11 16:16:44 +03:00
|
|
|
static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev)
|
2014-12-11 16:25:12 +03:00
|
|
|
{
|
2015-09-11 16:16:44 +03:00
|
|
|
return dev->max_rev;
|
2014-12-11 16:25:12 +03:00
|
|
|
}
|
|
|
|
|
2013-03-21 18:15:17 +04:00
|
|
|
/* virtio-scsi-ccw */
|
|
|
|
|
|
|
|
#define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSCSICcw, VIRTIO_SCSI_CCW)
|
2013-03-21 18:15:17 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtIOSCSICcw {
|
2013-03-21 18:15:17 +04:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VirtIOSCSI vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2013-03-21 18:15:17 +04:00
|
|
|
|
2013-04-25 21:38:28 +04:00
|
|
|
#ifdef CONFIG_VHOST_SCSI
|
2013-04-19 18:16:50 +04:00
|
|
|
/* vhost-scsi-ccw */
|
|
|
|
|
|
|
|
#define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VHostSCSICcw, VHOST_SCSI_CCW)
|
2013-04-19 18:16:50 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VHostSCSICcw {
|
2013-04-19 18:16:50 +04:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VHostSCSI vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2013-04-25 21:38:28 +04:00
|
|
|
#endif
|
2013-04-19 18:16:50 +04:00
|
|
|
|
2013-03-18 20:37:25 +04:00
|
|
|
/* virtio-blk-ccw */
|
|
|
|
|
|
|
|
#define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBlkCcw, VIRTIO_BLK_CCW)
|
2013-03-18 20:37:25 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtIOBlkCcw {
|
2013-03-18 20:37:25 +04:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VirtIOBlock vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2013-03-18 20:37:25 +04:00
|
|
|
|
2013-03-27 13:49:12 +04:00
|
|
|
/* virtio-balloon-ccw */
|
|
|
|
|
|
|
|
#define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBalloonCcw, VIRTIO_BALLOON_CCW)
|
2013-03-27 13:49:12 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtIOBalloonCcw {
|
2013-03-27 13:49:12 +04:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VirtIOBalloon vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2013-03-18 20:37:25 +04:00
|
|
|
|
2013-04-09 16:53:33 +04:00
|
|
|
/* virtio-serial-ccw */
|
|
|
|
|
|
|
|
#define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtioSerialCcw, VIRTIO_SERIAL_CCW)
|
2013-04-09 16:53:33 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtioSerialCcw {
|
2013-04-09 16:53:33 +04:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VirtIOSerial vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2013-04-09 16:53:33 +04:00
|
|
|
|
2013-04-11 18:30:00 +04:00
|
|
|
/* virtio-net-ccw */
|
|
|
|
|
|
|
|
#define TYPE_VIRTIO_NET_CCW "virtio-net-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtIONetCcw, VIRTIO_NET_CCW)
|
2013-04-11 18:30:00 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtIONetCcw {
|
2013-04-11 18:30:00 +04:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VirtIONet vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2013-04-11 18:30:00 +04:00
|
|
|
|
2013-04-24 12:07:58 +04:00
|
|
|
/* virtio-rng-ccw */
|
|
|
|
|
|
|
|
#define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtIORNGCcw, VIRTIO_RNG_CCW)
|
2013-04-24 12:07:58 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtIORNGCcw {
|
2013-04-24 12:07:58 +04:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VirtIORNG vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2013-04-24 12:07:58 +04:00
|
|
|
|
2016-11-03 15:39:15 +03:00
|
|
|
/* virtio-crypto-ccw */
|
|
|
|
|
|
|
|
#define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOCryptoCcw, VIRTIO_CRYPTO_CCW)
|
2016-11-03 15:39:15 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtIOCryptoCcw {
|
2016-11-03 15:39:15 +03:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VirtIOCrypto vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2016-11-03 15:39:15 +03:00
|
|
|
|
2013-01-24 10:08:55 +04:00
|
|
|
VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch);
|
2015-05-27 14:11:59 +03:00
|
|
|
|
|
|
|
#ifdef CONFIG_VIRTFS
|
|
|
|
#include "hw/9pfs/virtio-9p.h"
|
|
|
|
|
|
|
|
#define TYPE_VIRTIO_9P_CCW "virtio-9p-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(V9fsCCWState, VIRTIO_9P_CCW)
|
2015-05-27 14:11:59 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct V9fsCCWState {
|
2015-05-27 14:11:59 +03:00
|
|
|
VirtioCcwDevice parent_obj;
|
2016-01-11 12:29:37 +03:00
|
|
|
V9fsVirtioState vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2015-05-27 14:11:59 +03:00
|
|
|
|
|
|
|
#endif /* CONFIG_VIRTFS */
|
|
|
|
|
2016-08-16 15:27:22 +03:00
|
|
|
#ifdef CONFIG_VHOST_VSOCK
|
|
|
|
#define TYPE_VHOST_VSOCK_CCW "vhost-vsock-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VHostVSockCCWState, VHOST_VSOCK_CCW)
|
2016-08-16 15:27:22 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VHostVSockCCWState {
|
2016-08-16 15:27:22 +03:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VHostVSock vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2016-08-16 15:27:22 +03:00
|
|
|
|
|
|
|
#endif /* CONFIG_VHOST_VSOCK */
|
|
|
|
|
2017-09-15 17:40:32 +03:00
|
|
|
#define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUCcw, VIRTIO_GPU_CCW)
|
2017-09-15 17:40:32 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtIOGPUCcw {
|
2017-09-15 17:40:32 +03:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VirtIOGPU vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2017-09-15 17:40:32 +03:00
|
|
|
|
2017-10-09 17:01:50 +03:00
|
|
|
#define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputCcw, VIRTIO_INPUT_CCW)
|
2017-10-09 17:01:50 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtIOInputCcw {
|
2017-10-09 17:01:50 +03:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VirtIOInput vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2017-10-09 17:01:50 +03:00
|
|
|
|
|
|
|
#define TYPE_VIRTIO_INPUT_HID_CCW "virtio-input-hid-ccw"
|
|
|
|
#define TYPE_VIRTIO_KEYBOARD_CCW "virtio-keyboard-ccw"
|
|
|
|
#define TYPE_VIRTIO_MOUSE_CCW "virtio-mouse-ccw"
|
|
|
|
#define TYPE_VIRTIO_TABLET_CCW "virtio-tablet-ccw"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHIDCcw, VIRTIO_INPUT_HID_CCW)
|
2017-10-09 17:01:50 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct VirtIOInputHIDCcw {
|
2017-10-09 17:01:50 +03:00
|
|
|
VirtioCcwDevice parent_obj;
|
|
|
|
VirtIOInputHID vdev;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2017-10-09 17:01:50 +03:00
|
|
|
|
2013-01-24 10:08:55 +04:00
|
|
|
#endif
|