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