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