Skip to content

Commit f6dde1b

Browse files
efarmancohuck
authored andcommitted
s390x/css: Refactor the css_queue_crw() routine
We have a use case (vfio-ccw) where a CRW is already built and ready to use. Rather than teasing out the components just to reassemble it later, let's rework this code so we can queue a fully-qualified CRW directly. Signed-off-by: Eric Farman <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Message-Id: <[email protected]> Signed-off-by: Cornelia Huck <[email protected]>
1 parent 690e29b commit f6dde1b

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

hw/s390x/css.c

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,30 +2170,23 @@ void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
21702170
}
21712171
}
21722172

2173-
void css_queue_crw(uint8_t rsc, uint8_t erc, int solicited,
2174-
int chain, uint16_t rsid)
2173+
void css_crw_add_to_queue(CRW crw)
21752174
{
21762175
CrwContainer *crw_cont;
21772176

2178-
trace_css_crw(rsc, erc, rsid, chain ? "(chained)" : "");
2177+
trace_css_crw((crw.flags & CRW_FLAGS_MASK_RSC) >> 8,
2178+
crw.flags & CRW_FLAGS_MASK_ERC,
2179+
crw.rsid,
2180+
(crw.flags & CRW_FLAGS_MASK_C) ? "(chained)" : "");
2181+
21792182
/* TODO: Maybe use a static crw pool? */
21802183
crw_cont = g_try_new0(CrwContainer, 1);
21812184
if (!crw_cont) {
21822185
channel_subsys.crws_lost = true;
21832186
return;
21842187
}
2185-
crw_cont->crw.flags = (rsc << 8) | erc;
2186-
if (solicited) {
2187-
crw_cont->crw.flags |= CRW_FLAGS_MASK_S;
2188-
}
2189-
if (chain) {
2190-
crw_cont->crw.flags |= CRW_FLAGS_MASK_C;
2191-
}
2192-
crw_cont->crw.rsid = rsid;
2193-
if (channel_subsys.crws_lost) {
2194-
crw_cont->crw.flags |= CRW_FLAGS_MASK_R;
2195-
channel_subsys.crws_lost = false;
2196-
}
2188+
2189+
crw_cont->crw = crw;
21972190

21982191
QTAILQ_INSERT_TAIL(&channel_subsys.pending_crws, crw_cont, sibling);
21992192

@@ -2204,6 +2197,27 @@ void css_queue_crw(uint8_t rsc, uint8_t erc, int solicited,
22042197
}
22052198
}
22062199

2200+
void css_queue_crw(uint8_t rsc, uint8_t erc, int solicited,
2201+
int chain, uint16_t rsid)
2202+
{
2203+
CRW crw;
2204+
2205+
crw.flags = (rsc << 8) | erc;
2206+
if (solicited) {
2207+
crw.flags |= CRW_FLAGS_MASK_S;
2208+
}
2209+
if (chain) {
2210+
crw.flags |= CRW_FLAGS_MASK_C;
2211+
}
2212+
crw.rsid = rsid;
2213+
if (channel_subsys.crws_lost) {
2214+
crw.flags |= CRW_FLAGS_MASK_R;
2215+
channel_subsys.crws_lost = false;
2216+
}
2217+
2218+
css_crw_add_to_queue(crw);
2219+
}
2220+
22072221
void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
22082222
int hotplugged, int add)
22092223
{

include/hw/s390x/css.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ void copy_scsw_to_guest(SCSW *dest, const SCSW *src);
205205
void css_inject_io_interrupt(SubchDev *sch);
206206
void css_reset(void);
207207
void css_reset_sch(SubchDev *sch);
208+
void css_crw_add_to_queue(CRW crw);
208209
void css_queue_crw(uint8_t rsc, uint8_t erc, int solicited,
209210
int chain, uint16_t rsid);
210211
void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,

0 commit comments

Comments
 (0)