1 /* 2 * virtio ccw target definitions 3 * 4 * Copyright 2012 IBM Corp. 5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> 6 * 7 * This work is licensed under the terms of the GNU GPL, version 2 or (at 8 * your option) any later version. See the COPYING file in the top-level 9 * directory. 10 */ 11 12 #ifndef HW_S390X_VIRTIO_CCW_H 13 #define HW_S390X_VIRTIO_CCW_H 14 15 #include <hw/virtio/virtio-blk.h> 16 #include <hw/virtio/virtio-net.h> 17 #include <hw/virtio/virtio-serial.h> 18 #include <hw/virtio/virtio-scsi.h> 19 #ifdef CONFIG_VHOST_SCSI 20 #include <hw/virtio/vhost-scsi.h> 21 #endif 22 #include <hw/virtio/virtio-balloon.h> 23 #include <hw/virtio/virtio-rng.h> 24 #include <hw/virtio/virtio-bus.h> 25 #include <hw/s390x/s390_flic.h> 26 27 #define VIRTUAL_CSSID 0xfe 28 29 #define VIRTIO_CCW_CU_TYPE 0x3832 30 #define VIRTIO_CCW_CHPID_TYPE 0x32 31 32 #define CCW_CMD_SET_VQ 0x13 33 #define CCW_CMD_VDEV_RESET 0x33 34 #define CCW_CMD_READ_FEAT 0x12 35 #define CCW_CMD_WRITE_FEAT 0x11 36 #define CCW_CMD_READ_CONF 0x22 37 #define CCW_CMD_WRITE_CONF 0x21 38 #define CCW_CMD_WRITE_STATUS 0x31 39 #define CCW_CMD_SET_IND 0x43 40 #define CCW_CMD_SET_CONF_IND 0x53 41 #define CCW_CMD_READ_VQ_CONF 0x32 42 #define CCW_CMD_SET_IND_ADAPTER 0x73 43 44 #define TYPE_VIRTIO_CCW_DEVICE "virtio-ccw-device" 45 #define VIRTIO_CCW_DEVICE(obj) \ 46 OBJECT_CHECK(VirtioCcwDevice, (obj), TYPE_VIRTIO_CCW_DEVICE) 47 #define VIRTIO_CCW_DEVICE_CLASS(klass) \ 48 OBJECT_CLASS_CHECK(VirtIOCCWDeviceClass, (klass), TYPE_VIRTIO_CCW_DEVICE) 49 #define VIRTIO_CCW_DEVICE_GET_CLASS(obj) \ 50 OBJECT_GET_CLASS(VirtIOCCWDeviceClass, (obj), TYPE_VIRTIO_CCW_DEVICE) 51 52 typedef struct VirtioBusState VirtioCcwBusState; 53 typedef struct VirtioBusClass VirtioCcwBusClass; 54 55 #define TYPE_VIRTIO_CCW_BUS "virtio-ccw-bus" 56 #define VIRTIO_CCW_BUS(obj) \ 57 OBJECT_CHECK(VirtioCcwBus, (obj), TYPE_VIRTIO_CCW_BUS) 58 #define VIRTIO_CCW_BUS_GET_CLASS(obj) \ 59 OBJECT_CHECK(VirtioCcwBusState, (obj), TYPE_VIRTIO_CCW_BUS) 60 #define VIRTIO_CCW_BUS_CLASS(klass) \ 61 OBJECT_CLASS_CHECK(VirtioCcwBusClass, klass, TYPE_VIRTIO_CCW_BUS) 62 63 typedef struct VirtioCcwDevice VirtioCcwDevice; 64 65 typedef struct VirtIOCCWDeviceClass { 66 DeviceClass parent_class; 67 int (*init)(VirtioCcwDevice *dev); 68 int (*exit)(VirtioCcwDevice *dev); 69 } VirtIOCCWDeviceClass; 70 71 /* Change here if we want to support more feature bits. */ 72 #define VIRTIO_CCW_FEATURE_SIZE 1 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 typedef struct IndAddr { 80 hwaddr addr; 81 uint64_t map; 82 unsigned long refcnt; 83 int len; 84 QTAILQ_ENTRY(IndAddr) sibling; 85 } IndAddr; 86 87 struct VirtioCcwDevice { 88 DeviceState parent_obj; 89 SubchDev *sch; 90 char *bus_id; 91 uint32_t host_features[VIRTIO_CCW_FEATURE_SIZE]; 92 VirtioBusState bus; 93 bool ioeventfd_started; 94 bool ioeventfd_disabled; 95 uint32_t flags; 96 uint8_t thinint_isc; 97 AdapterRoutes routes; 98 /* Guest provided values: */ 99 IndAddr *indicators; 100 IndAddr *indicators2; 101 IndAddr *summary_indicator; 102 uint64_t ind_bit; 103 }; 104 105 /* virtual css bus type */ 106 typedef struct VirtualCssBus { 107 BusState parent_obj; 108 } VirtualCssBus; 109 110 #define TYPE_VIRTUAL_CSS_BUS "virtual-css-bus" 111 #define VIRTUAL_CSS_BUS(obj) \ 112 OBJECT_CHECK(VirtualCssBus, (obj), TYPE_VIRTUAL_CSS_BUS) 113 114 /* virtio-scsi-ccw */ 115 116 #define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw" 117 #define VIRTIO_SCSI_CCW(obj) \ 118 OBJECT_CHECK(VirtIOSCSICcw, (obj), TYPE_VIRTIO_SCSI_CCW) 119 120 typedef struct VirtIOSCSICcw { 121 VirtioCcwDevice parent_obj; 122 VirtIOSCSI vdev; 123 } VirtIOSCSICcw; 124 125 #ifdef CONFIG_VHOST_SCSI 126 /* vhost-scsi-ccw */ 127 128 #define TYPE_VHOST_SCSI_CCW "vhost-scsi-ccw" 129 #define VHOST_SCSI_CCW(obj) \ 130 OBJECT_CHECK(VHostSCSICcw, (obj), TYPE_VHOST_SCSI_CCW) 131 132 typedef struct VHostSCSICcw { 133 VirtioCcwDevice parent_obj; 134 VHostSCSI vdev; 135 } VHostSCSICcw; 136 #endif 137 138 /* virtio-blk-ccw */ 139 140 #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw" 141 #define VIRTIO_BLK_CCW(obj) \ 142 OBJECT_CHECK(VirtIOBlkCcw, (obj), TYPE_VIRTIO_BLK_CCW) 143 144 typedef struct VirtIOBlkCcw { 145 VirtioCcwDevice parent_obj; 146 VirtIOBlock vdev; 147 } VirtIOBlkCcw; 148 149 /* virtio-balloon-ccw */ 150 151 #define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw" 152 #define VIRTIO_BALLOON_CCW(obj) \ 153 OBJECT_CHECK(VirtIOBalloonCcw, (obj), TYPE_VIRTIO_BALLOON_CCW) 154 155 typedef struct VirtIOBalloonCcw { 156 VirtioCcwDevice parent_obj; 157 VirtIOBalloon vdev; 158 } VirtIOBalloonCcw; 159 160 /* virtio-serial-ccw */ 161 162 #define TYPE_VIRTIO_SERIAL_CCW "virtio-serial-ccw" 163 #define VIRTIO_SERIAL_CCW(obj) \ 164 OBJECT_CHECK(VirtioSerialCcw, (obj), TYPE_VIRTIO_SERIAL_CCW) 165 166 typedef struct VirtioSerialCcw { 167 VirtioCcwDevice parent_obj; 168 VirtIOSerial vdev; 169 } VirtioSerialCcw; 170 171 /* virtio-net-ccw */ 172 173 #define TYPE_VIRTIO_NET_CCW "virtio-net-ccw" 174 #define VIRTIO_NET_CCW(obj) \ 175 OBJECT_CHECK(VirtIONetCcw, (obj), TYPE_VIRTIO_NET_CCW) 176 177 typedef struct VirtIONetCcw { 178 VirtioCcwDevice parent_obj; 179 VirtIONet vdev; 180 } VirtIONetCcw; 181 182 /* virtio-rng-ccw */ 183 184 #define TYPE_VIRTIO_RNG_CCW "virtio-rng-ccw" 185 #define VIRTIO_RNG_CCW(obj) \ 186 OBJECT_CHECK(VirtIORNGCcw, (obj), TYPE_VIRTIO_RNG_CCW) 187 188 typedef struct VirtIORNGCcw { 189 VirtioCcwDevice parent_obj; 190 VirtIORNG vdev; 191 } VirtIORNGCcw; 192 193 VirtualCssBus *virtual_css_bus_init(void); 194 void virtio_ccw_device_update_status(SubchDev *sch); 195 VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch); 196 #endif 197