]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/s390x/css.h
s390x/css: consolidate the devno property for ccw devices
[mirror_qemu.git] / include / hw / s390x / css.h
CommitLineData
df1fe5bb
CH
1/*
2 * Channel subsystem structures and 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 CSS_H
13#define CSS_H
14
a28d8391
YMZ
15#include "hw/s390x/adapter.h"
16#include "hw/s390x/s390_flic.h"
bd3f16ac 17#include "hw/s390x/ioinst.h"
df1fe5bb
CH
18
19/* Channel subsystem constants. */
cf249935 20#define MAX_DEVNO 65535
df1fe5bb
CH
21#define MAX_SCHID 65535
22#define MAX_SSID 3
882b3b97 23#define MAX_CSSID 255
df1fe5bb
CH
24#define MAX_CHPID 255
25
26#define MAX_CIWS 62
27
cf249935
SS
28#define VIRTUAL_CSSID 0xfe
29
df1fe5bb
CH
30typedef struct CIW {
31 uint8_t type;
32 uint8_t command;
33 uint16_t count;
34} QEMU_PACKED CIW;
35
36typedef struct SenseId {
37 /* common part */
38 uint8_t reserved; /* always 0x'FF' */
39 uint16_t cu_type; /* control unit type */
40 uint8_t cu_model; /* control unit model */
41 uint16_t dev_type; /* device type */
42 uint8_t dev_model; /* device model */
43 uint8_t unused; /* padding byte */
44 /* extended part */
45 CIW ciw[MAX_CIWS]; /* variable # of CIWs */
46} QEMU_PACKED SenseId;
47
48/* Channel measurements, from linux/drivers/s390/cio/cmf.c. */
49typedef struct CMB {
50 uint16_t ssch_rsch_count;
51 uint16_t sample_count;
52 uint32_t device_connect_time;
53 uint32_t function_pending_time;
54 uint32_t device_disconnect_time;
55 uint32_t control_unit_queuing_time;
56 uint32_t device_active_only_time;
57 uint32_t reserved[2];
58} QEMU_PACKED CMB;
59
60typedef struct CMBE {
61 uint32_t ssch_rsch_count;
62 uint32_t sample_count;
63 uint32_t device_connect_time;
64 uint32_t function_pending_time;
65 uint32_t device_disconnect_time;
66 uint32_t control_unit_queuing_time;
67 uint32_t device_active_only_time;
68 uint32_t device_busy_time;
69 uint32_t initial_command_response_time;
70 uint32_t reserved[7];
71} QEMU_PACKED CMBE;
72
bd3f16ac 73typedef struct SubchDev SubchDev;
df1fe5bb
CH
74struct SubchDev {
75 /* channel-subsystem related things: */
76 uint8_t cssid;
77 uint8_t ssid;
78 uint16_t schid;
79 uint16_t devno;
80 SCHIB curr_status;
81 uint8_t sense_data[32];
82 hwaddr channel_prog;
83 CCW1 last_cmd;
84 bool last_cmd_valid;
a327c921 85 bool ccw_fmt_1;
7e749462 86 bool thinint_active;
e8601dd5 87 uint8_t ccw_no_data_cnt;
df1fe5bb
CH
88 /* transport-provided data: */
89 int (*ccw_cb) (SubchDev *, CCW1);
62ac4a52 90 void (*disable_cb)(SubchDev *);
df1fe5bb
CH
91 SenseId id;
92 void *driver_data;
93};
94
a28d8391
YMZ
95typedef struct IndAddr {
96 hwaddr addr;
97 uint64_t map;
98 unsigned long refcnt;
99 int len;
100 QTAILQ_ENTRY(IndAddr) sibling;
101} IndAddr;
102
103IndAddr *get_indicator(hwaddr ind_addr, int len);
104void release_indicator(AdapterInfo *adapter, IndAddr *indicator);
105int map_indicator(AdapterInfo *adapter, IndAddr *indicator);
106
df1fe5bb
CH
107typedef SubchDev *(*css_subch_cb_func)(uint8_t m, uint8_t cssid, uint8_t ssid,
108 uint16_t schid);
bcb2b582
JF
109void subch_device_save(SubchDev *s, QEMUFile *f);
110int subch_device_load(SubchDev *s, QEMUFile *f);
df1fe5bb
CH
111int css_create_css_image(uint8_t cssid, bool default_image);
112bool css_devno_used(uint8_t cssid, uint8_t ssid, uint16_t devno);
113void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
114 uint16_t devno, SubchDev *sch);
115void css_sch_build_virtual_schib(SubchDev *sch, uint8_t chpid, uint8_t type);
b4436a0b 116uint16_t css_build_subchannel_id(SubchDev *sch);
df1fe5bb
CH
117void css_reset(void);
118void css_reset_sch(SubchDev *sch);
119void css_queue_crw(uint8_t rsc, uint8_t erc, int chain, uint16_t rsid);
120void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
121 int hotplugged, int add);
122void css_generate_chp_crws(uint8_t cssid, uint8_t chpid);
8cba80c3 123void css_generate_css_crws(uint8_t cssid);
c81b4f89 124void css_clear_sei_pending(void);
7e749462 125void css_adapter_interrupt(uint8_t isc);
03cf077a
CH
126
127#define CSS_IO_ADAPTER_VIRTIO 1
128int css_register_io_adapter(uint8_t type, uint8_t isc, bool swap,
129 bool maskable, uint32_t *id);
bd3f16ac
PB
130
131#ifndef CONFIG_USER_ONLY
132SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint8_t ssid,
133 uint16_t schid);
134bool css_subch_visible(SubchDev *sch);
135void css_conditional_io_interrupt(SubchDev *sch);
136int css_do_stsch(SubchDev *sch, SCHIB *schib);
137bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid);
138int css_do_msch(SubchDev *sch, const SCHIB *schib);
139int css_do_xsch(SubchDev *sch);
140int css_do_csch(SubchDev *sch);
141int css_do_hsch(SubchDev *sch);
142int css_do_ssch(SubchDev *sch, ORB *orb);
143int css_do_tsch_get_irb(SubchDev *sch, IRB *irb, int *irb_len);
144void css_do_tsch_update_subch(SubchDev *sch);
145int css_do_stcrw(CRW *crw);
146void css_undo_stcrw(CRW *crw);
147int css_do_tpi(IOIntCode *int_code, int lowcore);
148int css_collect_chp_desc(int m, uint8_t cssid, uint8_t f_chpid, uint8_t l_chpid,
149 int rfmt, void *buf);
150void css_do_schm(uint8_t mbk, int update, int dct, uint64_t mbo);
151int css_enable_mcsse(void);
152int css_enable_mss(void);
153int css_do_rsch(SubchDev *sch);
154int css_do_rchp(uint8_t cssid, uint8_t chpid);
155bool css_present(uint8_t cssid);
156#endif
06e686ea
CH
157/*
158 * Identify a device within the channel subsystem.
159 * Note that this can be used to identify either the subchannel or
160 * the attached I/O device, as there's always one I/O device per
161 * subchannel.
162 */
163typedef struct CssDevId {
164 uint8_t cssid;
165 uint8_t ssid;
166 uint16_t devid;
167 bool valid;
168} CssDevId;
169
170extern PropertyInfo css_devid_propinfo;
171
172#define DEFINE_PROP_CSS_DEV_ID(_n, _s, _f) \
173 DEFINE_PROP(_n, _s, _f, css_devid_propinfo, CssDevId)
bd3f16ac 174
c35fc6aa
DJS
175extern PropertyInfo css_devid_ro_propinfo;
176
177#define DEFINE_PROP_CSS_DEV_ID_RO(_n, _s, _f) \
178 DEFINE_PROP(_n, _s, _f, css_devid_ro_propinfo, CssDevId)
179
cf249935
SS
180/**
181 * Create a subchannel for the given bus id.
182 *
183 * If @p bus_id is valid, verify that it uses the virtual channel
184 * subsystem id and is not already in use, and find a free subchannel
185 * id for it. If @p bus_id is not valid, find a free subchannel id and
186 * device number across all subchannel sets. If either of the former
187 * actions succeed, allocate a subchannel structure, initialise it
188 * with the bus id, subchannel id and device number, register it with
189 * the CSS and return it. Otherwise return NULL.
190 *
191 * The caller becomes owner of the returned subchannel structure and
192 * is responsible for unregistering and freeing it.
193 */
194SubchDev *css_create_virtual_sch(CssDevId bus_id, Error **errp);
df1fe5bb 195#endif