From: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
To: kvm@vger.kernel.org, linux-s390@vger.kernel.org, qemu-devel@nongnu.org
Cc: bjsdjshi@linux.vnet.ibm.com, renxiaof@linux.vnet.ibm.com,
cornelia.huck@de.ibm.com, borntraeger@de.ibm.com, agraf@suse.com,
alex.williamson@redhat.com, pmorel@linux.vnet.ibm.com,
pasic@linux.vnet.ibm.com, wkywang@linux.vnet.ibm.com
Subject: [PATCH RFC v2 05/12] s390x/css: realize css_create_sch
Date: Thu, 12 Jan 2017 08:25:06 +0100 [thread overview]
Message-ID: <20170112072513.98411-6-bjsdjshi@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170112072513.98411-1-bjsdjshi@linux.vnet.ibm.com>
The S390 virtual css support already has a mechanism to create a
virtual subchannel and provide it to the guest. However, to
pass-through subchannels to a guest, we need to introduce a new
mechanism to create the subchannel according to the real device
information. Thus we realize a new css_create_sch function to
allocate and initialize the subchannel according to the real
device information.
Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
---
hw/s390x/css.c | 39 +++++++++++++++++++++++++++++++++++++++
include/hw/s390x/css.h | 15 +++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index 8703bc3..67fe468 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -1486,6 +1486,19 @@ bool css_devno_used(uint8_t cssid, uint8_t ssid, uint16_t devno)
channel_subsys.css[cssid]->sch_set[ssid]->devnos_used);
}
+bool css_schid_used(uint8_t cssid, uint8_t ssid, uint16_t schid)
+{
+ if (!channel_subsys.css[cssid]) {
+ return false;
+ }
+ if (!channel_subsys.css[cssid]->sch_set[ssid]) {
+ return false;
+ }
+
+ return !!test_bit(schid,
+ channel_subsys.css[cssid]->sch_set[ssid]->schids_used);
+}
+
void css_subch_assign(uint8_t cssid, uint8_t ssid, uint16_t schid,
uint16_t devno, SubchDev *sch)
{
@@ -1911,6 +1924,32 @@ SubchDev *css_create_virtual_sch(CssDevId bus_id, Error **errp)
return sch;
}
+SubchDev *css_create_sch(CssDevId bus_id, Error **errp)
+{
+ uint32_t devno;
+ SubchDev *sch;
+
+ if (css_schid_used(bus_id.cssid, bus_id.ssid, bus_id.devid)) {
+ error_setg(errp, "Subchannel %x.%x.%04x already exists",
+ bus_id.cssid, bus_id.ssid, bus_id.devid);
+ return NULL;
+ }
+
+ devno = css_find_free_devno(bus_id.cssid, bus_id.ssid, bus_id.devid);
+ if (devno > MAX_DEVNO) {
+ error_setg(errp, "No free devno found");
+ return NULL;
+ }
+
+ sch = g_malloc0(sizeof(*sch));
+ sch->cssid = bus_id.cssid;
+ sch->ssid = bus_id.ssid;
+ sch->devno = devno;
+ sch->schid = bus_id.devid;
+ css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, sch);
+ return sch;
+}
+
static int css_sch_get_chpids(SubchDev *sch, CssDevId *dev_id)
{
char *fid_path;
diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h
index 648ea2f..c92f624 100644
--- a/include/hw/s390x/css.h
+++ b/include/hw/s390x/css.h
@@ -128,6 +128,7 @@ void subch_device_save(SubchDev *s, QEMUFile *f);
int subch_device_load(SubchDev *s, QEMUFile *f);
int css_create_css_image(uint8_t cssid, bool default_image);
bool css_devno_used(uint8_t cssid, uint8_t ssid, uint16_t devno);
+bool css_schid_used(uint8_t cssid, uint8_t ssid, uint16_t schid);
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);
@@ -189,4 +190,18 @@ bool css_present(uint8_t cssid);
* is responsible for unregistering and freeing it.
*/
SubchDev *css_create_virtual_sch(CssDevId bus_id, Error **errp);
+
+/**
+ * Create a subchannel for the given bus id.
+ *
+ * If @p bus_id is valid, verify that it is not already in use, and find
+ * a free devno for it.
+ * Allocate a subchannel structure, initialise it with the bus id,
+ * subchannel id and device number, register it with the CSS and return
+ * it. Otherwise return NULL.
+ *
+ * The caller becomes owner of the returned subchannel structure and
+ * is responsible for unregistering and freeing it.
+ */
+SubchDev *css_create_sch(CssDevId bus_id, Error **errp);
#endif
--
2.8.4
next prev parent reply other threads:[~2017-01-12 7:25 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-12 7:25 [PATCH RFC v2 00/12] basic channel IO passthrough infrastructure based on vfio Dong Jia Shi
2017-01-12 7:25 ` [PATCH RFC v2 01/12] update-linux-headers: add asm-s390/vfio_ccw.h Dong Jia Shi
2017-01-12 7:25 ` [PATCH RFC v2 02/12] vfio: linux-headers update for vfio-ccw Dong Jia Shi
2017-01-17 21:51 ` Alex Williamson
2017-01-18 2:51 ` Dong Jia Shi
[not found] ` <20170118025117.GN30301@bjsdjshi@linux.vnet.ibm.com>
2017-01-18 12:41 ` Cornelia Huck
2017-01-18 20:43 ` Alex Williamson
2017-01-19 1:54 ` Dong Jia Shi
2017-01-12 7:25 ` [PATCH RFC v2 03/12] s390x/css: add s390-map-css machine option Dong Jia Shi
2017-02-17 2:08 ` Dong Jia Shi
2017-01-12 7:25 ` [PATCH RFC v2 04/12] s390x/css: realize css_sch_build_schib Dong Jia Shi
2017-01-12 7:25 ` Dong Jia Shi [this message]
2017-01-12 7:25 ` [PATCH RFC v2 06/12] s390x/css: device support for s390-ccw passthrough Dong Jia Shi
2017-01-12 7:25 ` [PATCH RFC v2 07/12] vfio/ccw: vfio based subchannel passthrough driver Dong Jia Shi
2017-01-17 22:49 ` Alex Williamson
2017-01-18 3:22 ` Dong Jia Shi
2017-01-12 7:25 ` [PATCH RFC v2 08/12] vfio/ccw: get io region info Dong Jia Shi
2017-01-17 22:49 ` Alex Williamson
2017-01-18 5:22 ` Dong Jia Shi
[not found] ` <20170118052256.GP30301@bjsdjshi@linux.vnet.ibm.com>
2017-01-18 5:51 ` Dong Jia Shi
2017-01-12 7:25 ` [PATCH RFC v2 09/12] vfio/ccw: get irqs info and set the eventfd fd Dong Jia Shi
2017-01-17 22:53 ` Alex Williamson
2017-01-18 5:55 ` Dong Jia Shi
2017-01-12 7:25 ` [PATCH RFC v2 10/12] s390x/css: introduce and realize ccw-request callback Dong Jia Shi
2017-01-12 7:25 ` [PATCH RFC v2 11/12] s390x/css: ccws translation infrastructure Dong Jia Shi
2017-01-12 7:25 ` [PATCH RFC v2 12/12] vfio/ccw: update sense data if a unit check is pending Dong Jia Shi
2017-01-12 8:00 ` [Qemu-devel] [PATCH RFC v2 00/12] basic channel IO passthrough infrastructure based on vfio no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170112072513.98411-6-bjsdjshi@linux.vnet.ibm.com \
--to=bjsdjshi@linux.vnet.ibm.com \
--cc=agraf@suse.com \
--cc=alex.williamson@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@linux.vnet.ibm.com \
--cc=pmorel@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=renxiaof@linux.vnet.ibm.com \
--cc=wkywang@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox