[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 8/9] s390x/css: introduce and realize ccw-reques
From: |
Xiao Feng Ren |
Subject: |
[Qemu-devel] [PATCH RFC 8/9] s390x/css: introduce and realize ccw-request callback |
Date: |
Fri, 29 Apr 2016 14:13:22 +0200 |
Introduce a new callback on ccw device to handle ccw-request.
Realize the callback in vfio-ccw device.
Signed-off-by: Xiao Feng Ren <address@hidden>
---
hw/s390x/s390-ccw.h | 1 +
hw/vfio/ccw.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/hw/s390x/s390-ccw.h b/hw/s390x/s390-ccw.h
index a3cd9df..92d076d 100644
--- a/hw/s390x/s390-ccw.h
+++ b/hw/s390x/s390-ccw.h
@@ -29,6 +29,7 @@ typedef struct S390CCWDevice {
unsigned int hcssid;
unsigned int hssid;
unsigned int hdevno;
+ int (*handle_request) (ORB *, IRB *, SCSW *, void *);
} S390CCWDevice;
typedef struct S390CCWDeviceClass {
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index 501a0e8..6b23291 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -20,12 +20,52 @@
#include "hw/vfio/vfio.h"
#include "hw/vfio/vfio-common.h"
#include "hw/s390x/s390-ccw.h"
+#include "hw/s390x/s390-ccwchain.h"
typedef struct VFIOCCWDevice {
S390CCWDevice cdev;
VFIODevice vdev;
} VFIOCCWDevice;
+static int vfio_ccw_handle_request(ORB *orb, IRB *irb, SCSW *scsw, void *data)
+{
+ struct vfio_ccw_cmd cmd_data;
+ int ret;
+ TransChainData trans_data;
+ S390CCWDevice *cdev = data;
+ VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev);
+
+ QEMU_BUILD_BUG_ON(sizeof(cmd_data.orb_area) != sizeof(ORB));
+ QEMU_BUILD_BUG_ON(sizeof(cmd_data.scsw_area) != sizeof(SCSW));
+ QEMU_BUILD_BUG_ON(sizeof(cmd_data.irb_area) != sizeof(IRB));
+
+ trans_data.cpa_gpa = orb->cpa;
+ ret = ccwchain_translate_to_userspace(&trans_data);
+ if (ret) {
+ return ret;
+ }
+ cmd_data.argsz = sizeof(cmd_data);
+ cmd_data.cssid = cdev->hcssid;
+ cmd_data.ssid = cdev->hssid;
+ cmd_data.devno = cdev->hdevno;
+ cmd_data.ccwchain_nr = trans_data.ccwchain_nr;
+ cmd_data.ccwchain_buf = trans_data.ccwchain_buf;
+
+ memcpy(cmd_data.orb_area, orb, sizeof(ORB));
+ memcpy(cmd_data.scsw_area, scsw, sizeof(SCSW));
+
+ if (ioctl(vcdev->vdev.fd, VFIO_DEVICE_CCW_CMD_REQUEST, &cmd_data) == -1) {
+ ccwchain_list_free(&trans_data);
+ return -errno;
+ }
+
+ memcpy(irb, cmd_data.irb_area, sizeof(IRB));
+ ccwchain_update_scsw(&(irb->scsw), &trans_data);
+ ccwchain_list_free(&trans_data);
+
+ return 0;
+}
+
static void vfio_ccw_compute_needs_reset(VFIODevice *vdev)
{
vdev->needs_reset = true;
@@ -75,6 +115,8 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
GError *gerror;
/* Call the class init function for ccw device. */
+ cdev->handle_request = vfio_ccw_handle_request;
+
if (cdc->realize) {
cdc->realize(cdev, errp);
if (*errp) {
--
2.6.6
- [Qemu-devel] [PATCH RFC 0/9] basic channel IO passthrough infrastructure based on vfio, Xiao Feng Ren, 2016/04/29
- [Qemu-devel] [PATCH RFC 2/9] vfio: No-IOMMU mode support, Xiao Feng Ren, 2016/04/29
- [Qemu-devel] [PATCH RFC 3/9] s390x/css: introduce ccw chain interfaces, Xiao Feng Ren, 2016/04/29
- [Qemu-devel] [PATCH RFC 1/9] vfio: linux-headers update for vfio-ccw, Xiao Feng Ren, 2016/04/29
- [Qemu-devel] [PATCH RFC 5/9] s390x/css: realize css_sch_build_schib, Xiao Feng Ren, 2016/04/29
- [Qemu-devel] [PATCH RFC 7/9] vfio/ccw: vfio based ccw passthrough driver, Xiao Feng Ren, 2016/04/29
- [Qemu-devel] [PATCH RFC 4/9] s390x/css: add s390-map-css machine option, Xiao Feng Ren, 2016/04/29
- [Qemu-devel] [PATCH RFC 8/9] s390x/css: introduce and realize ccw-request callback,
Xiao Feng Ren <=
- [Qemu-devel] [PATCH RFC 9/9] s390x/css: ccws translation infrastructure, Xiao Feng Ren, 2016/04/29
- [Qemu-devel] [PATCH RFC 6/9] s390x/css: device and bus support for s390-ccw passthrough, Xiao Feng Ren, 2016/04/29