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 typedef struct VirtIOCCWDeviceClass VirtIOCCWDeviceClass; 58 typedef struct VirtioCcwDevice VirtioCcwDevice; 59 DECLARE_OBJ_CHECKERS(VirtioCcwDevice, VirtIOCCWDeviceClass, 60 VIRTIO_CCW_DEVICE, TYPE_VIRTIO_CCW_DEVICE) 61 62 typedef struct VirtioBusState VirtioCcwBusState; 63 typedef struct VirtioBusClass VirtioCcwBusClass; 64 65 #define TYPE_VIRTIO_CCW_BUS "virtio-ccw-bus" 66 DECLARE_OBJ_CHECKERS(VirtioCcwBusState, VirtioCcwBusClass, 67 VIRTIO_CCW_BUS, TYPE_VIRTIO_CCW_BUS) 68 69 70 struct VirtIOCCWDeviceClass { 71 CCWDeviceClass parent_class; 72 void (*realize)(VirtioCcwDevice *dev, Error **errp); 73 void (*unrealize)(VirtioCcwDevice *dev); 74 void (*parent_reset)(DeviceState *dev); 75 }; 76 77 /* Performance improves when virtqueue kick processing is decoupled from the 78 * vcpu thread using ioeventfd for some devices. */ 79 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT 1 80 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD (1 << VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT) 81 82 struct VirtioCcwDevice { 83 CcwDevice parent_obj; 84 int revision; 85 uint32_t max_rev; 86 VirtioBusState bus; 87 uint32_t flags; 88 uint8_t thinint_isc; 89 AdapterRoutes routes; 90 /* Guest provided values: */ 91 IndAddr *indicators; 92 IndAddr *indicators2; 93 IndAddr *summary_indicator; 94 uint64_t ind_bit; 95 bool force_revision_1; 96 }; 97 98 /* The maximum virtio revision we support. */ 99 #define VIRTIO_CCW_MAX_REV 2 100 static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev) 101 { 102 return dev->max_rev; 103 } 104 105 /* virtio-scsi-ccw */ 106 107 #define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw" 108 typedef struct VirtIOSCSICcw VirtIOSCSICcw; 109 DECLARE_INSTANCE_CHECKER(VirtIOSCSICcw, VIRTIO_SCSI_CCW, 110 TYPE_VIRTIO_SCSI_CCW) 111 112 struct VirtIOSCSICcw { 113 VirtioCcwDevice parent_obj; 114 VirtIOSCSI vdev; 115 }; 116 117 #ifdef CONFIG_VHOST_SCSI 118 /* vhost-scsi-ccw */ 119 120 #define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw" 121 typedef struct VHostSCSICcw VHostSCSICcw; 122 DECLARE_INSTANCE_CHECKER(VHostSCSICcw, VHOST_SCSI_CCW, 123 TYPE_VHOST_SCSI_CCW) 124 125 struct VHostSCSICcw { 126 VirtioCcwDevice parent_obj; 127 VHostSCSI vdev; 128 }; 129 #endif 130 131 /* virtio-blk-ccw */ 132 133 #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw" 134 typedef struct VirtIOBlkCcw VirtIOBlkCcw; 135 DECLARE_INSTANCE_CHECKER(VirtIOBlkCcw, VIRTIO_BLK_CCW, 136 TYPE_VIRTIO_BLK_CCW) 137 138 struct VirtIOBlkCcw { 139 VirtioCcwDevice parent_obj; 140 VirtIOBlock vdev; 141 }; 142 143 /* virtio-balloon-ccw */ 144 145 #define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw" 146 typedef struct VirtIOBalloonCcw VirtIOBalloonCcw; 147 DECLARE_INSTANCE_CHECKER(VirtIOBalloonCcw, VIRTIO_BALLOON_CCW, 148 TYPE_VIRTIO_BALLOON_CCW) 149 150 struct VirtIOBalloonCcw { 151 VirtioCcwDevice parent_obj; 152 VirtIOBalloon vdev; 153 }; 154 155 /* virtio-serial-ccw */ 156 157 #define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw" 158 typedef struct VirtioSerialCcw VirtioSerialCcw; 159 DECLARE_INSTANCE_CHECKER(VirtioSerialCcw, VIRTIO_SERIAL_CCW, 160 TYPE_VIRTIO_SERIAL_CCW) 161 162 struct VirtioSerialCcw { 163 VirtioCcwDevice parent_obj; 164 VirtIOSerial vdev; 165 }; 166 167 /* virtio-net-ccw */ 168 169 #define TYPE_VIRTIO_NET_CCW "virtio-net-ccw" 170 typedef struct VirtIONetCcw VirtIONetCcw; 171 DECLARE_INSTANCE_CHECKER(VirtIONetCcw, VIRTIO_NET_CCW, 172 TYPE_VIRTIO_NET_CCW) 173 174 struct VirtIONetCcw { 175 VirtioCcwDevice parent_obj; 176 VirtIONet vdev; 177 }; 178 179 /* virtio-rng-ccw */ 180 181 #define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw" 182 typedef struct VirtIORNGCcw VirtIORNGCcw; 183 DECLARE_INSTANCE_CHECKER(VirtIORNGCcw, VIRTIO_RNG_CCW, 184 TYPE_VIRTIO_RNG_CCW) 185 186 struct VirtIORNGCcw { 187 VirtioCcwDevice parent_obj; 188 VirtIORNG vdev; 189 }; 190 191 /* virtio-crypto-ccw */ 192 193 #define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw" 194 typedef struct VirtIOCryptoCcw VirtIOCryptoCcw; 195 DECLARE_INSTANCE_CHECKER(VirtIOCryptoCcw, VIRTIO_CRYPTO_CCW, 196 TYPE_VIRTIO_CRYPTO_CCW) 197 198 struct VirtIOCryptoCcw { 199 VirtioCcwDevice parent_obj; 200 VirtIOCrypto vdev; 201 }; 202 203 VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch); 204 205 #ifdef CONFIG_VIRTFS 206 #include "hw/9pfs/virtio-9p.h" 207 208 #define TYPE_VIRTIO_9P_CCW "virtio-9p-ccw" 209 typedef struct V9fsCCWState V9fsCCWState; 210 DECLARE_INSTANCE_CHECKER(V9fsCCWState, VIRTIO_9P_CCW, 211 TYPE_VIRTIO_9P_CCW) 212 213 struct V9fsCCWState { 214 VirtioCcwDevice parent_obj; 215 V9fsVirtioState vdev; 216 }; 217 218 #endif /* CONFIG_VIRTFS */ 219 220 #ifdef CONFIG_VHOST_VSOCK 221 #define TYPE_VHOST_VSOCK_CCW "vhost-vsock-ccw" 222 typedef struct VHostVSockCCWState VHostVSockCCWState; 223 DECLARE_INSTANCE_CHECKER(VHostVSockCCWState, VHOST_VSOCK_CCW, 224 TYPE_VHOST_VSOCK_CCW) 225 226 struct VHostVSockCCWState { 227 VirtioCcwDevice parent_obj; 228 VHostVSock vdev; 229 }; 230 231 #endif /* CONFIG_VHOST_VSOCK */ 232 233 #define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw" 234 typedef struct VirtIOGPUCcw VirtIOGPUCcw; 235 DECLARE_INSTANCE_CHECKER(VirtIOGPUCcw, VIRTIO_GPU_CCW, 236 TYPE_VIRTIO_GPU_CCW) 237 238 struct VirtIOGPUCcw { 239 VirtioCcwDevice parent_obj; 240 VirtIOGPU vdev; 241 }; 242 243 #define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw" 244 typedef struct VirtIOInputCcw VirtIOInputCcw; 245 DECLARE_INSTANCE_CHECKER(VirtIOInputCcw, VIRTIO_INPUT_CCW, 246 TYPE_VIRTIO_INPUT_CCW) 247 248 struct VirtIOInputCcw { 249 VirtioCcwDevice parent_obj; 250 VirtIOInput vdev; 251 }; 252 253 #define TYPE_VIRTIO_INPUT_HID_CCW "virtio-input-hid-ccw" 254 #define TYPE_VIRTIO_KEYBOARD_CCW "virtio-keyboard-ccw" 255 #define TYPE_VIRTIO_MOUSE_CCW "virtio-mouse-ccw" 256 #define TYPE_VIRTIO_TABLET_CCW "virtio-tablet-ccw" 257 typedef struct VirtIOInputHIDCcw VirtIOInputHIDCcw; 258 DECLARE_INSTANCE_CHECKER(VirtIOInputHIDCcw, VIRTIO_INPUT_HID_CCW, 259 TYPE_VIRTIO_INPUT_HID_CCW) 260 261 struct VirtIOInputHIDCcw { 262 VirtioCcwDevice parent_obj; 263 VirtIOInputHID vdev; 264 }; 265 266 #endif 267