qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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 <farman@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <20200505125757.98209-6-farman@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>

authored by

Eric Farman and committed by
Cornelia Huck
f6dde1b0 690e29b9

+30 -15
+29 -15
hw/s390x/css.c
··· 2170 2170 } 2171 2171 } 2172 2172 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) 2175 2174 { 2176 2175 CrwContainer *crw_cont; 2177 2176 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 + 2179 2182 /* TODO: Maybe use a static crw pool? */ 2180 2183 crw_cont = g_try_new0(CrwContainer, 1); 2181 2184 if (!crw_cont) { 2182 2185 channel_subsys.crws_lost = true; 2183 2186 return; 2184 2187 } 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; 2197 2190 2198 2191 QTAILQ_INSERT_TAIL(&channel_subsys.pending_crws, crw_cont, sibling); 2199 2192 ··· 2202 2195 /* Inject crw pending machine check. */ 2203 2196 s390_crw_mchk(); 2204 2197 } 2198 + } 2199 + 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); 2205 2219 } 2206 2220 2207 2221 void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,
+1
include/hw/s390x/css.h
··· 205 205 void css_inject_io_interrupt(SubchDev *sch); 206 206 void css_reset(void); 207 207 void css_reset_sch(SubchDev *sch); 208 + void css_crw_add_to_queue(CRW crw); 208 209 void css_queue_crw(uint8_t rsc, uint8_t erc, int solicited, 209 210 int chain, uint16_t rsid); 210 211 void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid,