xref: /openbmc/qemu/hw/s390x/virtio-ccw.h (revision f0984d40)
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 "qom/object.h"
17 #include "hw/virtio/virtio-bus.h"
18 #include "hw/s390x/s390_flic.h"
19 #include "hw/s390x/css.h"
20 #include "ccw-device.h"
21 #include "hw/s390x/css-bridge.h"
22 
23 #define VIRTIO_CCW_CU_TYPE 0x3832
24 #define VIRTIO_CCW_CHPID_TYPE 0x32
25 
26 #define CCW_CMD_SET_VQ       0x13
27 #define CCW_CMD_VDEV_RESET   0x33
28 #define CCW_CMD_READ_FEAT    0x12
29 #define CCW_CMD_WRITE_FEAT   0x11
30 #define CCW_CMD_READ_CONF    0x22
31 #define CCW_CMD_WRITE_CONF   0x21
32 #define CCW_CMD_WRITE_STATUS 0x31
33 #define CCW_CMD_SET_IND      0x43
34 #define CCW_CMD_SET_CONF_IND 0x53
35 #define CCW_CMD_READ_VQ_CONF 0x32
36 #define CCW_CMD_READ_STATUS  0x72
37 #define CCW_CMD_SET_IND_ADAPTER 0x73
38 #define CCW_CMD_SET_VIRTIO_REV 0x83
39 
40 #define TYPE_VIRTIO_CCW_DEVICE "virtio-ccw-device"
41 OBJECT_DECLARE_TYPE(VirtioCcwDevice, VirtIOCCWDeviceClass, VIRTIO_CCW_DEVICE)
42 
43 typedef struct VirtioBusState VirtioCcwBusState;
44 typedef struct VirtioBusClass VirtioCcwBusClass;
45 
46 #define TYPE_VIRTIO_CCW_BUS "virtio-ccw-bus"
47 DECLARE_OBJ_CHECKERS(VirtioCcwBusState, VirtioCcwBusClass,
48                      VIRTIO_CCW_BUS, TYPE_VIRTIO_CCW_BUS)
49 
50 /*
51  * modules can reference this symbol to avoid being loaded
52  * into system emulators without ccw support
53  */
54 extern bool have_virtio_ccw;
55 
56 struct VirtIOCCWDeviceClass {
57     CCWDeviceClass parent_class;
58     void (*realize)(VirtioCcwDevice *dev, Error **errp);
59     void (*unrealize)(VirtioCcwDevice *dev);
60     void (*parent_reset)(DeviceState *dev);
61 };
62 
63 /* Performance improves when virtqueue kick processing is decoupled from the
64  * vcpu thread using ioeventfd for some devices. */
65 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT 1
66 #define VIRTIO_CCW_FLAG_USE_IOEVENTFD   (1 << VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT)
67 
68 struct VirtioCcwDevice {
69     CcwDevice parent_obj;
70     int revision;
71     uint32_t max_rev;
72     VirtioBusState bus;
73     uint32_t flags;
74     uint8_t thinint_isc;
75     AdapterRoutes routes;
76     /* Guest provided values: */
77     IndAddr *indicators;
78     IndAddr *indicators2;
79     IndAddr *summary_indicator;
80     uint64_t ind_bit;
81     bool force_revision_1;
82 };
83 
84 /* The maximum virtio revision we support. */
85 #define VIRTIO_CCW_MAX_REV 2
86 static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev)
87 {
88     return dev->max_rev;
89 }
90 
91 VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch);
92 
93 #endif
94