From patchwork Fri Apr 29 12:13:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Feng Ren X-Patchwork-Id: 8982441 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 604569F46D for ; Fri, 29 Apr 2016 13:38:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B2BA620212 for ; Fri, 29 Apr 2016 13:38:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6B79201DD for ; Fri, 29 Apr 2016 13:38:22 +0000 (UTC) Received: from localhost ([::1]:54487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aw8cd-00059s-0B for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Apr 2016 09:38:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aw7Jh-0003bh-B2 for qemu-devel@nongnu.org; Fri, 29 Apr 2016 08:14:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aw7JV-0003SC-4y for qemu-devel@nongnu.org; Fri, 29 Apr 2016 08:14:35 -0400 Received: from e38.co.us.ibm.com ([32.97.110.159]:41585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aw7JU-0003Hg-VK for qemu-devel@nongnu.org; Fri, 29 Apr 2016 08:14:29 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 29 Apr 2016 06:13:51 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 29 Apr 2016 06:13:49 -0600 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: renxiaof@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org; alex.williamson@redhat.com; agraf@suse.com; kvm@vger.kernel.org; linux-s390@vger.kernel.org Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id E46CF19D8041; Fri, 29 Apr 2016 06:13:32 -0600 (MDT) Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u3TCDlIt37290068; Fri, 29 Apr 2016 12:13:47 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F372124035; Fri, 29 Apr 2016 13:12:15 -0400 (EDT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 1E3D8124037; Fri, 29 Apr 2016 13:12:14 -0400 (EDT) From: Xiao Feng Ren To: kvm@vger.kernel.org, linux-s390@vger.kernel.org, qemu-devel@nongnu.org Date: Fri, 29 Apr 2016 14:13:22 +0200 Message-Id: <1461932003-23830-9-git-send-email-renxiaof@linux.vnet.ibm.com> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1461932003-23830-1-git-send-email-renxiaof@linux.vnet.ibm.com> References: <1461932003-23830-1-git-send-email-renxiaof@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16042912-0029-0000-0000-0000271F20F1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.110.159 X-Mailman-Approved-At: Fri, 29 Apr 2016 09:31:35 -0400 Subject: [Qemu-devel] [PATCH RFC 8/9] s390x/css: introduce and realize ccw-request callback X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: borntraeger@de.ibm.com, alex.williamson@redhat.com, renxiaof@linux.vnet.ibm.com, cornelia.huck@de.ibm.com, bjsdjshi@linux.vnet.ibm.com, agraf@suse.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new callback on ccw device to handle ccw-request. Realize the callback in vfio-ccw device. Signed-off-by: Xiao Feng Ren --- 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) {