[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 2/8] s390x/css: Add an algorithm to find a free chpid
From: |
Cornelia Huck |
Subject: |
[Qemu-devel] [PULL 2/8] s390x/css: Add an algorithm to find a free chpid |
Date: |
Thu, 4 May 2017 12:48:00 +0200 |
From: Jing Liu <address@hidden>
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 <address@hidden>
Reviewed-by: QingFeng Hao <address@hidden>
Reviewed-by: Dong Jia Shi <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
hw/s390x/css.c | 21 +++++++++++++++++++++
include/hw/s390x/css.h | 2 ++
2 files changed, 23 insertions(+)
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;
diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h
index f1f0d7f07a..e61fa74d9b 100644
--- a/include/hw/s390x/css.h
+++ b/include/hw/s390x/css.h
@@ -28,6 +28,7 @@
#define MAX_CIWS 62
#define VIRTUAL_CSSID 0xfe
+#define VIRTIO_CCW_CHPID 0 /* used by convention */
typedef struct CIW {
uint8_t type;
@@ -115,6 +116,7 @@ bool css_devno_used(uint8_t cssid, uint8_t ssid, uint16_t
devno);
void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
uint16_t devno, SubchDev *sch);
void css_sch_build_virtual_schib(SubchDev *sch, uint8_t chpid, uint8_t type);
+unsigned int css_find_free_chpid(uint8_t cssid);
uint16_t css_build_subchannel_id(SubchDev *sch);
void css_reset(void);
void css_reset_sch(SubchDev *sch);
--
2.11.0
- [Qemu-devel] [PULL 0/8] s390x: basic 3270 support, Cornelia Huck, 2017/05/04
- [Qemu-devel] [PULL 2/8] s390x/css: Add an algorithm to find a free chpid,
Cornelia Huck <=
- [Qemu-devel] [PULL 1/8] chardev: Basic support for TN3270, Cornelia Huck, 2017/05/04
- [Qemu-devel] [PULL 3/8] s390x/3270: Add abstract emulated ccw-attached 3270 device, Cornelia Huck, 2017/05/04
- [Qemu-devel] [PULL 4/8] s390x/3270: Add emulated terminal3270 device, Cornelia Huck, 2017/05/04
- [Qemu-devel] [PULL 6/8] s390x/3270: Add the TCP socket events handler for 3270, Cornelia Huck, 2017/05/04
- [Qemu-devel] [PULL 8/8] s390x/3270: Mark non-migratable and enable the device, Cornelia Huck, 2017/05/04
- [Qemu-devel] [PULL 7/8] s390x/3270: Detect for continued presence of a 3270 client, Cornelia Huck, 2017/05/04
- [Qemu-devel] [PULL 5/8] s390x/3270: 3270 data stream handling, Cornelia Huck, 2017/05/04
- Re: [Qemu-devel] [PULL 0/8] s390x: basic 3270 support, Stefan Hajnoczi, 2017/05/05