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