On 2/4/19 5:26 AM, Cornelia Huck wrote:
On Tue, 29 Jan 2019 08:29:08 -0500
"Jason J. Herne" <jjhe...@linux.ibm.com> wrote:
Add bootindex property and iplb data for vfio-ccw devices. This allows us to
forward boot information into the bios for vfio-ccw devices.
Signed-off-by: Jason J. Herne <jjhe...@linux.ibm.com>
Acked-by: Halil Pasic <pa...@linux.vnet.ibm.com>
---
hw/s390x/ipl.c | 14 ++++++++++++++
hw/s390x/s390-ccw.c | 9 +++++++++
hw/vfio/ccw.c | 13 +------------
include/hw/s390x/s390-ccw.h | 1 +
include/hw/s390x/vfio-ccw.h | 38 ++++++++++++++++++++++++++++++++++++++
5 files changed, 63 insertions(+), 12 deletions(-)
create mode 100644 include/hw/s390x/vfio-ccw.h
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 21f64ad..a993f65 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -19,6 +19,7 @@
#include "hw/loader.h"
#include "hw/boards.h"
#include "hw/s390x/virtio-ccw.h"
+#include "hw/s390x/vfio-ccw.h"
#include "hw/s390x/css.h"
#include "hw/s390x/ebcdic.h"
#include "ipl.h"
@@ -311,8 +312,12 @@ static CcwDevice *s390_get_ccw_device(DeviceState *dev_st)
VirtioCcwDevice *virtio_ccw_dev = (VirtioCcwDevice *)
object_dynamic_cast(OBJECT(qdev_get_parent_bus(dev_st)->parent),
TYPE_VIRTIO_CCW_DEVICE);
+ VFIOCCWDevice *vfio_ccw_dev = (VFIOCCWDevice *)
+ object_dynamic_cast(OBJECT(dev_st), TYPE_VFIO_CCW);
if (virtio_ccw_dev) {
ccw_dev = CCW_DEVICE(virtio_ccw_dev);
+ } else if (vfio_ccw_dev) {
+ ccw_dev = CCW_DEVICE(vfio_ccw_dev);
} else {
SCSIDevice *sd = (SCSIDevice *)
object_dynamic_cast(OBJECT(dev_st),
@@ -347,6 +352,8 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)
if (ccw_dev) {
SCSIDevice *sd = (SCSIDevice *) object_dynamic_cast(OBJECT(dev_st),
TYPE_SCSI_DEVICE);
+ VFIOCCWDevice *vc = (VFIOCCWDevice *)
+ object_dynamic_cast(OBJECT(dev_st), TYPE_VFIO_CCW);
if (sd) {
ipl->iplb.len = cpu_to_be32(S390_IPLB_MIN_QEMU_SCSI_LEN);
@@ -358,6 +365,13 @@ static bool s390_gen_initial_iplb(S390IPLState *ipl)
ipl->iplb.scsi.channel = cpu_to_be16(sd->channel);
ipl->iplb.scsi.devno = cpu_to_be16(ccw_dev->sch->devno);
ipl->iplb.scsi.ssid = ccw_dev->sch->ssid & 3;
+ } else if (vc) {
+ CcwDevice *ccw_dev = CCW_DEVICE(vc);
+
+ ipl->iplb.len = cpu_to_be32(S390_IPLB_MIN_CCW_LEN);
+ ipl->iplb.pbt = S390_IPL_TYPE_CCW;
+ ipl->iplb.ccw.devno = cpu_to_be16(ccw_dev->sch->devno);
+ ipl->iplb.ccw.ssid = ccw_dev->sch->ssid & 3;
} else {
VirtIONet *vn = (VirtIONet *) object_dynamic_cast(OBJECT(dev_st),
TYPE_VIRTIO_NET);
Hm, I think that this find-out-the-boot-type-and-set-up-the-right-thing
mechanism is getting a bit unwieldy. Basically, we
- call s390_get_ccw_device() to find out the device type via a bunch of
casts and return a pointer to a CcwDevice if it's a supported type
- do a bunch of casts here *again* to find out what we have and fill
out the iplb, while we really only need to do grab a non-CcwDevice
for the scsi case
Should maybe s390_get_ccw_device() give us an ipl type in addition to
the pointer to the CcwDevice, so we can use a switch/case statement to
fill out the iplb here?
I think this idea makes sense. s390_ipl_reset_request also calls s390_get_ccw_device but
does not care bout the device type, so how about a separate function instead of
integrating it with s390_get_ccw_device? Maybe s390_get_ccw_device_type?
Is there any easy way to grab the type or are we just hiding the ugly casting inside our
helper function?
--
-- Jason J. Herne (jjhe...@linux.ibm.com)