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 typedef struct VirtIOSCSICcw VirtIOSCSICcw; 106 DECLARE_INSTANCE_CHECKER(VirtIOSCSICcw, VIRTIO_SCSI_CCW, 107 TYPE_VIRTIO_SCSI_CCW) 108 109 struct VirtIOSCSICcw { 110 VirtioCcwDevice parent_obj; 111 VirtIOSCSI vdev; 112 }; 113 114 #ifdef CONFIG_VHOST_SCSI 115 /* vhost-scsi-ccw */ 116 117 #define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw" 118 typedef struct VHostSCSICcw VHostSCSICcw; 119 DECLARE_INSTANCE_CHECKER(VHostSCSICcw, VHOST_SCSI_CCW, 120 TYPE_VHOST_SCSI_CCW) 121 122 struct VHostSCSICcw { 123 VirtioCcwDevice parent_obj; 124 VHostSCSI vdev; 125 }; 126 #endif 127 128 /* virtio-blk-ccw */ 129 130 #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw" 131 typedef struct VirtIOBlkCcw VirtIOBlkCcw; 132 DECLARE_INSTANCE_CHECKER(VirtIOBlkCcw, VIRTIO_BLK_CCW, 133 TYPE_VIRTIO_BLK_CCW) 134 135 struct VirtIOBlkCcw { 136 VirtioCcwDevice parent_obj; 137 VirtIOBlock vdev; 138 }; 139 140 /* virtio-balloon-ccw */ 141 142 #define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw" 143 typedef struct VirtIOBalloonCcw VirtIOBalloonCcw; 144 DECLARE_INSTANCE_CHECKER(VirtIOBalloonCcw, VIRTIO_BALLOON_CCW, 145 TYPE_VIRTIO_BALLOON_CCW) 146 147 struct VirtIOBalloonCcw { 148 VirtioCcwDevice parent_obj; 149 VirtIOBalloon vdev; 150 }; 151 152 /* virtio-serial-ccw */ 153 154 #define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw" 155 typedef struct VirtioSerialCcw VirtioSerialCcw; 156 DECLARE_INSTANCE_CHECKER(VirtioSerialCcw, VIRTIO_SERIAL_CCW, 157 TYPE_VIRTIO_SERIAL_CCW) 158 159 struct VirtioSerialCcw { 160 VirtioCcwDevice parent_obj; 161 VirtIOSerial vdev; 162 }; 163 164 /* virtio-net-ccw */ 165 166 #define TYPE_VIRTIO_NET_CCW "virtio-net-ccw" 167 typedef struct VirtIONetCcw VirtIONetCcw; 168 DECLARE_INSTANCE_CHECKER(VirtIONetCcw, VIRTIO_NET_CCW, 169 TYPE_VIRTIO_NET_CCW) 170 171 struct VirtIONetCcw { 172 VirtioCcwDevice parent_obj; 173 VirtIONet vdev; 174 }; 175 176 /* virtio-rng-ccw */ 177 178 #define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw" 179 typedef struct VirtIORNGCcw VirtIORNGCcw; 180 DECLARE_INSTANCE_CHECKER(VirtIORNGCcw, VIRTIO_RNG_CCW, 181 TYPE_VIRTIO_RNG_CCW) 182 183 struct VirtIORNGCcw { 184 VirtioCcwDevice parent_obj; 185 VirtIORNG vdev; 186 }; 187 188 /* virtio-crypto-ccw */ 189 190 #define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw" 191 typedef struct VirtIOCryptoCcw VirtIOCryptoCcw; 192 DECLARE_INSTANCE_CHECKER(VirtIOCryptoCcw, VIRTIO_CRYPTO_CCW, 193 TYPE_VIRTIO_CRYPTO_CCW) 194 195 struct VirtIOCryptoCcw { 196 VirtioCcwDevice parent_obj; 197 VirtIOCrypto vdev; 198 }; 199 200 VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch); 201 202 #ifdef CONFIG_VIRTFS 203 #include "hw/9pfs/virtio-9p.h" 204 205 #define TYPE_VIRTIO_9P_CCW "virtio-9p-ccw" 206 typedef struct V9fsCCWState V9fsCCWState; 207 DECLARE_INSTANCE_CHECKER(V9fsCCWState, VIRTIO_9P_CCW, 208 TYPE_VIRTIO_9P_CCW) 209 210 struct V9fsCCWState { 211 VirtioCcwDevice parent_obj; 212 V9fsVirtioState vdev; 213 }; 214 215 #endif /* CONFIG_VIRTFS */ 216 217 #ifdef CONFIG_VHOST_VSOCK 218 #define TYPE_VHOST_VSOCK_CCW "vhost-vsock-ccw" 219 typedef struct VHostVSockCCWState VHostVSockCCWState; 220 DECLARE_INSTANCE_CHECKER(VHostVSockCCWState, VHOST_VSOCK_CCW, 221 TYPE_VHOST_VSOCK_CCW) 222 223 struct VHostVSockCCWState { 224 VirtioCcwDevice parent_obj; 225 VHostVSock vdev; 226 }; 227 228 #endif /* CONFIG_VHOST_VSOCK */ 229 230 #define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw" 231 typedef struct VirtIOGPUCcw VirtIOGPUCcw; 232 DECLARE_INSTANCE_CHECKER(VirtIOGPUCcw, VIRTIO_GPU_CCW, 233 TYPE_VIRTIO_GPU_CCW) 234 235 struct VirtIOGPUCcw { 236 VirtioCcwDevice parent_obj; 237 VirtIOGPU vdev; 238 }; 239 240 #define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw" 241 typedef struct VirtIOInputCcw VirtIOInputCcw; 242 DECLARE_INSTANCE_CHECKER(VirtIOInputCcw, VIRTIO_INPUT_CCW, 243 TYPE_VIRTIO_INPUT_CCW) 244 245 struct VirtIOInputCcw { 246 VirtioCcwDevice parent_obj; 247 VirtIOInput vdev; 248 }; 249 250 #define TYPE_VIRTIO_INPUT_HID_CCW "virtio-input-hid-ccw" 251 #define TYPE_VIRTIO_KEYBOARD_CCW "virtio-keyboard-ccw" 252 #define TYPE_VIRTIO_MOUSE_CCW "virtio-mouse-ccw" 253 #define TYPE_VIRTIO_TABLET_CCW "virtio-tablet-ccw" 254 typedef struct VirtIOInputHIDCcw VirtIOInputHIDCcw; 255 DECLARE_INSTANCE_CHECKER(VirtIOInputHIDCcw, VIRTIO_INPUT_HID_CCW, 256 TYPE_VIRTIO_INPUT_HID_CCW) 257 258 struct VirtIOInputHIDCcw { 259 VirtioCcwDevice parent_obj; 260 VirtIOInputHID vdev; 261 }; 262 263 #endif 264