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 #ifdef CONFIG_VHOST_SCSI 21 #include "hw/virtio/vhost-scsi.h" 22 #endif 23 #include "hw/virtio/virtio-balloon.h" 24 #include "hw/virtio/virtio-rng.h" 25 #include "hw/virtio/virtio-crypto.h" 26 #include "hw/virtio/virtio-bus.h" 27 #ifdef CONFIG_VHOST_VSOCK 28 #include "hw/virtio/vhost-vsock.h" 29 #endif /* CONFIG_VHOST_VSOCK */ 30 #include "hw/virtio/virtio-gpu.h" 31 #include "hw/virtio/virtio-input.h" 32 33 #include "hw/s390x/s390_flic.h" 34 #include "hw/s390x/css.h" 35 #include "ccw-device.h" 36 #include "hw/s390x/css-bridge.h" 37 38 #define VIRTIO_CCW_CU_TYPE 0x3832 39 #define VIRTIO_CCW_CHPID_TYPE 0x32 40 41 #define CCW_CMD_SET_VQ 0x13 42 #define CCW_CMD_VDEV_RESET 0x33 43 #define CCW_CMD_READ_FEAT 0x12 44 #define CCW_CMD_WRITE_FEAT 0x11 45 #define CCW_CMD_READ_CONF 0x22 46 #define CCW_CMD_WRITE_CONF 0x21 47 #define CCW_CMD_WRITE_STATUS 0x31 48 #define CCW_CMD_SET_IND 0x43 49 #define CCW_CMD_SET_CONF_IND 0x53 50 #define CCW_CMD_READ_VQ_CONF 0x32 51 #define CCW_CMD_READ_STATUS 0x72 52 #define CCW_CMD_SET_IND_ADAPTER 0x73 53 #define CCW_CMD_SET_VIRTIO_REV 0x83 54 55 #define TYPE_VIRTIO_CCW_DEVICE "virtio-ccw-device" 56 #define VIRTIO_CCW_DEVICE(obj) \ 57 OBJECT_CHECK(VirtioCcwDevice, (obj), TYPE_VIRTIO_CCW_DEVICE) 58 #define VIRTIO_CCW_DEVICE_CLASS(klass) \ 59 OBJECT_CLASS_CHECK(VirtIOCCWDeviceClass, (klass), TYPE_VIRTIO_CCW_DEVICE) 60 #define VIRTIO_CCW_DEVICE_GET_CLASS(obj) \ 61 OBJECT_GET_CLASS(VirtIOCCWDeviceClass, (obj), TYPE_VIRTIO_CCW_DEVICE) 62 63 typedef struct VirtioBusState VirtioCcwBusState; 64 typedef struct VirtioBusClass VirtioCcwBusClass; 65 66 #define TYPE_VIRTIO_CCW_BUS "virtio-ccw-bus" 67 #define VIRTIO_CCW_BUS(obj) \ 68 OBJECT_CHECK(VirtioCcwBus, (obj), TYPE_VIRTIO_CCW_BUS) 69 #define VIRTIO_CCW_BUS_GET_CLASS(obj) \ 70 OBJECT_CHECK(VirtioCcwBusState, (obj), TYPE_VIRTIO_CCW_BUS) 71 #define VIRTIO_CCW_BUS_CLASS(klass) \ 72 OBJECT_CLASS_CHECK(VirtioCcwBusClass, klass, TYPE_VIRTIO_CCW_BUS) 73 74 typedef struct VirtioCcwDevice VirtioCcwDevice; 75 76 typedef struct VirtIOCCWDeviceClass { 77 CCWDeviceClass parent_class; 78 void (*realize)(VirtioCcwDevice *dev, Error **errp); 79 void (*unrealize)(VirtioCcwDevice *dev, Error **errp); 80 } VirtIOCCWDeviceClass; 81 82 /* Performance improves when virtqueue kick processing is decoupled from the 83 * vcpu thread using ioeventfd for some devices. */ 84 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT 1 85 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD (1 << VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT) 86 87 struct VirtioCcwDevice { 88 CcwDevice parent_obj; 89 int revision; 90 uint32_t max_rev; 91 VirtioBusState bus; 92 uint32_t flags; 93 uint8_t thinint_isc; 94 AdapterRoutes routes; 95 /* Guest provided values: */ 96 IndAddr *indicators; 97 IndAddr *indicators2; 98 IndAddr *summary_indicator; 99 uint64_t ind_bit; 100 bool force_revision_1; 101 }; 102 103 /* The maximum virtio revision we support. */ 104 #define VIRTIO_CCW_MAX_REV 2 105 static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev) 106 { 107 return dev->max_rev; 108 } 109 110 /* virtio-scsi-ccw */ 111 112 #define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw" 113 #define VIRTIO_SCSI_CCW(obj) \ 114 OBJECT_CHECK(VirtIOSCSICcw, (obj), TYPE_VIRTIO_SCSI_CCW) 115 116 typedef struct VirtIOSCSICcw { 117 VirtioCcwDevice parent_obj; 118 VirtIOSCSI vdev; 119 } VirtIOSCSICcw; 120 121 #ifdef CONFIG_VHOST_SCSI 122 /* vhost-scsi-ccw */ 123 124 #define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw" 125 #define VHOST_SCSI_CCW(obj) \ 126 OBJECT_CHECK(VHostSCSICcw, (obj), TYPE_VHOST_SCSI_CCW) 127 128 typedef struct VHostSCSICcw { 129 VirtioCcwDevice parent_obj; 130 VHostSCSI vdev; 131 } VHostSCSICcw; 132 #endif 133 134 /* virtio-blk-ccw */ 135 136 #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw" 137 #define VIRTIO_BLK_CCW(obj) \ 138 OBJECT_CHECK(VirtIOBlkCcw, (obj), TYPE_VIRTIO_BLK_CCW) 139 140 typedef struct VirtIOBlkCcw { 141 VirtioCcwDevice parent_obj; 142 VirtIOBlock vdev; 143 } VirtIOBlkCcw; 144 145 /* virtio-balloon-ccw */ 146 147 #define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw" 148 #define VIRTIO_BALLOON_CCW(obj) \ 149 OBJECT_CHECK(VirtIOBalloonCcw, (obj), TYPE_VIRTIO_BALLOON_CCW) 150 151 typedef struct VirtIOBalloonCcw { 152 VirtioCcwDevice parent_obj; 153 VirtIOBalloon vdev; 154 } VirtIOBalloonCcw; 155 156 /* virtio-serial-ccw */ 157 158 #define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw" 159 #define VIRTIO_SERIAL_CCW(obj) \ 160 OBJECT_CHECK(VirtioSerialCcw, (obj), TYPE_VIRTIO_SERIAL_CCW) 161 162 typedef struct VirtioSerialCcw { 163 VirtioCcwDevice parent_obj; 164 VirtIOSerial vdev; 165 } VirtioSerialCcw; 166 167 /* virtio-net-ccw */ 168 169 #define TYPE_VIRTIO_NET_CCW "virtio-net-ccw" 170 #define VIRTIO_NET_CCW(obj) \ 171 OBJECT_CHECK(VirtIONetCcw, (obj), TYPE_VIRTIO_NET_CCW) 172 173 typedef struct VirtIONetCcw { 174 VirtioCcwDevice parent_obj; 175 VirtIONet vdev; 176 } VirtIONetCcw; 177 178 /* virtio-rng-ccw */ 179 180 #define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw" 181 #define VIRTIO_RNG_CCW(obj) \ 182 OBJECT_CHECK(VirtIORNGCcw, (obj), TYPE_VIRTIO_RNG_CCW) 183 184 typedef struct VirtIORNGCcw { 185 VirtioCcwDevice parent_obj; 186 VirtIORNG vdev; 187 } VirtIORNGCcw; 188 189 /* virtio-crypto-ccw */ 190 191 #define TYPE_VIRTIO_CRYPTO_CCW "virtio-crypto-ccw" 192 #define VIRTIO_CRYPTO_CCW(obj) \ 193 OBJECT_CHECK(VirtIOCryptoCcw, (obj), TYPE_VIRTIO_CRYPTO_CCW) 194 195 typedef struct VirtIOCryptoCcw { 196 VirtioCcwDevice parent_obj; 197 VirtIOCrypto vdev; 198 } VirtIOCryptoCcw; 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 #define VIRTIO_9P_CCW(obj) \ 207 OBJECT_CHECK(V9fsCCWState, (obj), TYPE_VIRTIO_9P_CCW) 208 209 typedef struct V9fsCCWState { 210 VirtioCcwDevice parent_obj; 211 V9fsVirtioState vdev; 212 } V9fsCCWState; 213 214 #endif /* CONFIG_VIRTFS */ 215 216 #ifdef CONFIG_VHOST_VSOCK 217 #define TYPE_VHOST_VSOCK_CCW "vhost-vsock-ccw" 218 #define VHOST_VSOCK_CCW(obj) \ 219 OBJECT_CHECK(VHostVSockCCWState, (obj), TYPE_VHOST_VSOCK_CCW) 220 221 typedef struct VHostVSockCCWState { 222 VirtioCcwDevice parent_obj; 223 VHostVSock vdev; 224 } VHostVSockCCWState; 225 226 #endif /* CONFIG_VHOST_VSOCK */ 227 228 #define TYPE_VIRTIO_GPU_CCW "virtio-gpu-ccw" 229 #define VIRTIO_GPU_CCW(obj) \ 230 OBJECT_CHECK(VirtIOGPUCcw, (obj), TYPE_VIRTIO_GPU_CCW) 231 232 typedef struct VirtIOGPUCcw { 233 VirtioCcwDevice parent_obj; 234 VirtIOGPU vdev; 235 } VirtIOGPUCcw; 236 237 #define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw" 238 #define VIRTIO_INPUT_CCW(obj) \ 239 OBJECT_CHECK(VirtIOInputCcw, (obj), TYPE_VIRTIO_INPUT_CCW) 240 241 typedef struct VirtIOInputCcw { 242 VirtioCcwDevice parent_obj; 243 VirtIOInput vdev; 244 } VirtIOInputCcw; 245 246 #define TYPE_VIRTIO_INPUT_HID_CCW "virtio-input-hid-ccw" 247 #define TYPE_VIRTIO_KEYBOARD_CCW "virtio-keyboard-ccw" 248 #define TYPE_VIRTIO_MOUSE_CCW "virtio-mouse-ccw" 249 #define TYPE_VIRTIO_TABLET_CCW "virtio-tablet-ccw" 250 #define VIRTIO_INPUT_HID_CCW(obj) \ 251 OBJECT_CHECK(VirtIOInputHIDCcw, (obj), TYPE_VIRTIO_INPUT_HID_CCW) 252 253 typedef struct VirtIOInputHIDCcw { 254 VirtioCcwDevice parent_obj; 255 VirtIOInputHID vdev; 256 } VirtIOInputHIDCcw; 257 258 #endif 259