summaryrefslogtreecommitdiff
path: root/hw/s390x
diff options
context:
space:
mode:
authorJing Liu <liujbjl@linux.vnet.ibm.com>2016-09-19 09:10:43 +0200
committerCornelia Huck <cornelia.huck@de.ibm.com>2017-05-04 10:34:37 +0200
commit6c15e9bfb687f40cc92759536ef2a918fb04349b (patch)
treed64cdf7abcede90f1a5709122e0886400a9c85ed /hw/s390x
parentae92cbd542086a508343dd88fd3b980f3be1b3af (diff)
downloadqemu-6c15e9bfb687f40cc92759536ef2a918fb04349b.tar.gz
s390x/css: Add an algorithm to find a free chpid
This introduces a function named css_find_free_chpid() to find a free channel path. Because virtio-ccw device used zero as its channel path number, it would be sensible to skip the reserved one and search upwards. Signed-off-by: Jing Liu <liujbjl@linux.vnet.ibm.com> Reviewed-by: QingFeng Hao <haoqf@linux.vnet.ibm.com> Reviewed-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'hw/s390x')
-rw-r--r--hw/s390x/css.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index c03bb20bc9..d94498a97b 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -1302,6 +1302,27 @@ bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid)
(MAX_SCHID + 1) / sizeof(unsigned long));
}
+unsigned int css_find_free_chpid(uint8_t cssid)
+{
+ CssImage *css = channel_subsys.css[cssid];
+ unsigned int chpid;
+
+ if (!css) {
+ return MAX_CHPID + 1;
+ }
+
+ for (chpid = 0; chpid <= MAX_CHPID; chpid++) {
+ /* skip reserved chpid */
+ if (chpid == VIRTIO_CCW_CHPID) {
+ continue;
+ }
+ if (!css->chpids[chpid].in_use) {
+ return chpid;
+ }
+ }
+ return MAX_CHPID + 1;
+}
+
static int css_add_virtual_chpid(uint8_t cssid, uint8_t chpid, uint8_t type)
{
CssImage *css;