1 /* 2 * virtio ccw target definitions 3 * 4 * Copyright 2012,2015 IBM Corp. 5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> 6 * Pierre Morel <pmorel@linux.vnet.ibm.com> 7 * 8 * This work is licensed under the terms of the GNU GPL, version 2 or (at 9 * your option) any later version. See the COPYING file in the top-level 10 * directory. 11 */ 12 13 #ifndef HW_S390X_VIRTIO_CCW_H 14 #define HW_S390X_VIRTIO_CCW_H 15 16 #include "hw/virtio/virtio-blk.h" 17 #include "hw/virtio/virtio-net.h" 18 #include "hw/virtio/virtio-serial.h" 19 #include "hw/virtio/virtio-scsi.h" 20 #include "qom/object.h" 21 #ifdef CONFIG_VHOST_SCSI 22 #include "hw/virtio/vhost-scsi.h" 23 #endif 24 #include "hw/virtio/virtio-balloon.h" 25 #include "hw/virtio/virtio-rng.h" 26 #include "hw/virtio/virtio-crypto.h" 27 #include "hw/virtio/virtio-bus.h" 28 #ifdef CONFIG_VHOST_VSOCK 29 #include "hw/virtio/vhost-vsock.h" 30 #endif /* CONFIG_VHOST_VSOCK */ 31 #include "hw/virtio/virtio-gpu.h" 32 #include "hw/virtio/virtio-input.h" 33 34 #include "hw/s390x/s390_flic.h" 35 #include "hw/s390x/css.h" 36 #include "ccw-device.h" 37 #include "hw/s390x/css-bridge.h" 38 39 #define VIRTIO_CCW_CU_TYPE 0x3832 40 #define VIRTIO_CCW_CHPID_TYPE 0x32 41 42 #define CCW_CMD_SET_VQ 0x13 43 #define CCW_CMD_VDEV_RESET 0x33 44 #define CCW_CMD_READ_FEAT 0x12 45 #define CCW_CMD_WRITE_FEAT 0x11 46 #define CCW_CMD_READ_CONF 0x22 47 #define CCW_CMD_WRITE_CONF 0x21 48 #define CCW_CMD_WRITE_STATUS 0x31 49 #define CCW_CMD_SET_IND 0x43 50 #define CCW_CMD_SET_CONF_IND 0x53 51 #define CCW_CMD_READ_VQ_CONF 0x32 52 #define CCW_CMD_READ_STATUS 0x72 53 #define CCW_CMD_SET_IND_ADAPTER 0x73 54 #define CCW_CMD_SET_VIRTIO_REV 0x83 55 56 #define TYPE_VIRTIO_CCW_DEVICE "virtio-ccw-device" 57 OBJECT_DECLARE_TYPE(VirtioCcwDevice, VirtIOCCWDeviceClass, VIRTIO_CCW_DEVICE) 58 59 typedef struct VirtioBusState VirtioCcwBusState; 60 typedef struct VirtioBusClass VirtioCcwBusClass; 61 62 #define TYPE_VIRTIO_CCW_BUS "virtio-ccw-bus" 63 DECLARE_OBJ_CHECKERS(VirtioCcwBusState, VirtioCcwBusClass, 64 VIRTIO_CCW_BUS, TYPE_VIRTIO_CCW_BUS) 65 66 67 struct VirtIOCCWDeviceClass { 68 CCWDeviceClass parent_class; 69 void (*realize)(VirtioCcwDevice *dev, Error **errp); 70 void (*unrealize)(VirtioCcwDevice *dev); 71 void (*parent_reset)(DeviceState *dev); 72 }; 73 74 /* Performance improves when virtqueue kick processing is decoupled from the 75 * vcpu thread using ioeventfd for some devices. */ 76 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT 1 77 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD (1 << VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT) 78 79 struct VirtioCcwDevice { 80 CcwDevice parent_obj; 81 int revision; 82 uint32_t max_rev; 83 VirtioBusState bus; 84 uint32_t flags; 85 uint8_t thinint_isc; 86 AdapterRoutes routes; 87 /* Guest provided values: */ 88 IndAddr *indicators; 89 IndAddr *indicators2; 90 IndAddr *summary_indicator; 91 uint64_t ind_bit; 92 bool force_revision_1; 93 }; 94 95 /* The maximum virtio revision we support. */ 96 #define VIRTIO_CCW_MAX_REV 2 97 static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev) 98 { 99 return dev->max_rev; 100 } 101 102 /* virtio-scsi-ccw */ 103 104 #define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw" 105 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSCSICcw, VIRTIO_SCSI_CCW) 106 107 struct VirtIOSCSICcw { 108 VirtioCcwDevice parent_obj; 109 VirtIOSCSI vdev; 110 }; 111 112 #ifdef CONFIG_VHOST_SCSI 113 /* vhost-scsi-ccw */ 114 115 #define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw" 116 OBJECT_DECLARE_SIMPLE_TYPE(VHostSCSICcw, VHOST_SCSI_CCW) 117 118 struct VHostSCSICcw { 119 VirtioCcwDevice parent_obj; 120 VHostSCSI vdev; 121 }; 122 #endif 123 124 /* virtio-blk-ccw */ 125 126 #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw" 127 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBlkCcw, VIRTIO_BLK_CCW) 128 129 struct VirtIOBlkCcw { 130 VirtioCcwDevice parent_obj; 131 VirtIOBlock vdev; 132 }; 133 134 /* virtio-balloon-ccw */ 135 136 #define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw" 137 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBalloonCcw, VIRTIO_BALLOON_CCW) 138 139 struct VirtIOBalloonCcw { 140 VirtioCcwDevice parent_obj; 141 VirtIOBalloon vdev; 142 }; 143 144 /* virtio-serial-ccw */ 145 146 #define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw" 147 OBJECT_DECLARE_SIMPLE_TYPE(VirtioSerialCcw, VIRTIO_SERIAL_CCW) 148 149 struct VirtioSerialCcw { 150 VirtioCcwDevice parent_obj; 151 VirtIOSerial vdev; 152 }; 153 154 /* virtio-net-ccw */ 155 156 #define TYPE_VIRTIO_NET_CCW "virtio-net-ccw" 157 OBJECT_DECLARE_SIMPLE_TYPE(VirtIONetCcw, VIRTIO_NET_CCW) 158 159 struct VirtIONetCcw { 160 VirtioCcwDevice parent_obj; 161 VirtIONet vdev; 162 }; 163 164 /* virtio-rng-ccw */ 165 166 #define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw" 167 OBJECT_DECLARE_SIMPLE_TYPE(VirtIORNGCcw, VIRTIO_RNG_CCW) 168 169 struct VirtIORNGCcw { 170 VirtioCcwDevice parent_obj; 171 VirtIORNG vdev; 172 }; 173 174 /* virtio-crypto-ccw */ 175 176 #define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw" 177 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOCryptoCcw, VIRTIO_CRYPTO_CCW) 178 179 struct VirtIOCryptoCcw { 180 VirtioCcwDevice parent_obj; 181 VirtIOCrypto vdev; 182 }; 183 184 VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch); 185 186 #ifdef CONFIG_VIRTFS 187 #include "hw/9pfs/virtio-9p.h" 188 189 #define TYPE_VIRTIO_9P_CCW "virtio-9p-ccw" 190 OBJECT_DECLARE_SIMPLE_TYPE(V9fsCCWState, VIRTIO_9P_CCW) 191 192 struct V9fsCCWState { 193 VirtioCcwDevice parent_obj; 194 V9fsVirtioState vdev; 195 }; 196 197 #endif /* CONFIG_VIRTFS */ 198 199 #ifdef CONFIG_VHOST_VSOCK 200 #define TYPE_VHOST_VSOCK_CCW "vhost-vsock-ccw" 201 OBJECT_DECLARE_SIMPLE_TYPE(VHostVSockCCWState, VHOST_VSOCK_CCW) 202 203 struct VHostVSockCCWState { 204 VirtioCcwDevice parent_obj; 205 VHostVSock vdev; 206 }; 207 208 #endif /* CONFIG_VHOST_VSOCK */ 209 210 #define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw" 211 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUCcw, VIRTIO_GPU_CCW) 212 213 struct VirtIOGPUCcw { 214 VirtioCcwDevice parent_obj; 215 VirtIOGPU vdev; 216 }; 217 218 #define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw" 219 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputCcw, VIRTIO_INPUT_CCW) 220 221 struct VirtIOInputCcw { 222 VirtioCcwDevice parent_obj; 223 VirtIOInput vdev; 224 }; 225 226 #define TYPE_VIRTIO_INPUT_HID_CCW "virtio-input-hid-ccw" 227 #define TYPE_VIRTIO_KEYBOARD_CCW "virtio-keyboard-ccw" 228 #define TYPE_VIRTIO_MOUSE_CCW "virtio-mouse-ccw" 229 #define TYPE_VIRTIO_TABLET_CCW "virtio-tablet-ccw" 230 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHIDCcw, VIRTIO_INPUT_HID_CCW) 231 232 struct VirtIOInputHIDCcw { 233 VirtioCcwDevice parent_obj; 234 VirtIOInputHID vdev; 235 }; 236 237 #endif 238