{"id":816384,"url":"http://patchwork.ozlabs.org/api/patches/816384/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170920172314.102710-2-pasic@linux.vnet.ibm.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170920172314.102710-2-pasic@linux.vnet.ibm.com>","list_archive_url":null,"date":"2017-09-20T17:23:13","name":"[1/2] s390x/3270: IDA support for 3270 via CcwDataStream","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"85da8e281f4c9858f16bacb1aeb0a7b761dfa92c","submitter":{"id":68297,"url":"http://patchwork.ozlabs.org/api/people/68297/?format=json","name":"Halil Pasic","email":"pasic@linux.vnet.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170920172314.102710-2-pasic@linux.vnet.ibm.com/mbox/","series":[{"id":4185,"url":"http://patchwork.ozlabs.org/api/series/4185/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=4185","date":"2017-09-20T17:23:12","name":"3270 improvements","version":1,"mbox":"http://patchwork.ozlabs.org/series/4185/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816384/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816384/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xy69B2mC8z9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 21 Sep 2017 03:26:22 +1000 (AEST)","from localhost ([::1]:49919 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1duilQ-0006no-HG\n\tfor incoming@patchwork.ozlabs.org; Wed, 20 Sep 2017 13:26:20 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:51613)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <pasic@linux.vnet.ibm.com>) id 1duiit-000554-0j\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 13:23:44 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <pasic@linux.vnet.ibm.com>) id 1duiiq-0005yl-8X\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 13:23:43 -0400","from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39046\n\thelo=mx0a-001b2d01.pphosted.com)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <pasic@linux.vnet.ibm.com>)\n\tid 1duiiq-0005wt-3g\n\tfor qemu-devel@nongnu.org; Wed, 20 Sep 2017 13:23:40 -0400","from pps.filterd (m0098420.ppops.net [127.0.0.1])\n\tby mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8KHLtcj116757\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 13:23:37 -0400","from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108])\n\tby mx0b-001b2d01.pphosted.com with ESMTP id 2d3t8uhqfs-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <qemu-devel@nongnu.org>; Wed, 20 Sep 2017 13:23:37 -0400","from localhost\n\tby e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <qemu-devel@nongnu.org> from <pasic@linux.vnet.ibm.com>;\n\tWed, 20 Sep 2017 18:23:35 +0100","from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194)\n\tby e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP\n\tGateway: Authorized Use Only! Violators will be prosecuted; \n\tWed, 20 Sep 2017 18:23:33 +0100","from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com\n\t[9.149.105.58])\n\tby b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with\n\tESMTP id v8KHNXSw17367130; Wed, 20 Sep 2017 17:23:33 GMT","from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 150D94C046;\n\tWed, 20 Sep 2017 18:19:57 +0100 (BST)","from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id CBF2B4C044;\n\tWed, 20 Sep 2017 18:19:56 +0100 (BST)","from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9])\n\tby d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS;\n\tWed, 20 Sep 2017 18:19:56 +0100 (BST)"],"From":"Halil Pasic <pasic@linux.vnet.ibm.com>","To":"Cornelia Huck <cohuck@redhat.com>,\n\tChristian Borntraeger <borntraeger@de.ibm.com>","Date":"Wed, 20 Sep 2017 19:23:13 +0200","X-Mailer":"git-send-email 2.13.5","In-Reply-To":"<20170920172314.102710-1-pasic@linux.vnet.ibm.com>","References":"<20170920172314.102710-1-pasic@linux.vnet.ibm.com>","X-TM-AS-GCONF":"00","x-cbid":"17092017-0008-0000-0000-00000498BF36","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17092017-0009-0000-0000-00001E29F6F8","Message-Id":"<20170920172314.102710-2-pasic@linux.vnet.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-20_04:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709200234","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy]","X-Received-From":"148.163.158.5","Subject":"[Qemu-devel] [PATCH 1/2] s390x/3270: IDA support for 3270 via\n\tCcwDataStream","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Halil Pasic <pasic@linux.vnet.ibm.com>, qemu-devel@nongnu.org,\n\tAlexander Graf <agraf@suse.de>,\n\t\"Jason J . Herne\" <jjherne@linux.vnet.ibm.com>,\n\tDong Jia Shi <bjsdjshi@linux.vnet.ibm.com>,\n\tRichard Henderson <rth@twiddle.net>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"Let us convert the 3270 code so it uses the recently introduced\nCcwDataStream abstraction instead of blindly assuming direct data access.\n\nThis patch does not change behavior beyond introducing IDA support: for\ndirect data access CCWs everything stays as-is. (If there are bugs, they\nare also preserved).\n\nSigned-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>\nAcked-by: Christian Borntraeger <borntraeger@de.ibm.com>\nReviewed-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>\n---\n hw/char/terminal3270.c      | 18 +++++++++++-------\n hw/s390x/3270-ccw.c         |  4 ++--\n include/hw/s390x/3270-ccw.h |  5 ++---\n 3 files changed, 15 insertions(+), 12 deletions(-)","diff":"diff --git a/hw/char/terminal3270.c b/hw/char/terminal3270.c\nindex 28f599111d..c976a63cc2 100644\n--- a/hw/char/terminal3270.c\n+++ b/hw/char/terminal3270.c\n@@ -182,14 +182,18 @@ static void terminal_init(EmulatedCcw3270Device *dev, Error **errp)\n                              terminal_read, chr_event, NULL, t, NULL, true);\n }\n \n-static int read_payload_3270(EmulatedCcw3270Device *dev, uint32_t cda,\n-                             uint16_t count)\n+static inline CcwDataStream *get_cds(Terminal3270 *t)\n+{\n+    return &(CCW_DEVICE(&t->cdev)->sch->cds);\n+}\n+\n+static int read_payload_3270(EmulatedCcw3270Device *dev)\n {\n     Terminal3270 *t = TERMINAL_3270(dev);\n     int len;\n \n-    len = MIN(count, t->in_len);\n-    cpu_physical_memory_write(cda, t->inv, len);\n+    len = MIN(ccw_dstream_avail(get_cds(t)), t->in_len);\n+    ccw_dstream_write_buf(get_cds(t), t->inv, len);\n     t->in_len -= len;\n \n     return len;\n@@ -222,11 +226,11 @@ static int insert_IAC_escape_char(uint8_t *outv, int out_len)\n  * Write 3270 outbound to socket.\n  * Return the count of 3270 data field if succeeded, zero if failed.\n  */\n-static int write_payload_3270(EmulatedCcw3270Device *dev, uint8_t cmd,\n-                              uint32_t cda, uint16_t count)\n+static int write_payload_3270(EmulatedCcw3270Device *dev, uint8_t cmd)\n {\n     Terminal3270 *t = TERMINAL_3270(dev);\n     int retval = 0;\n+    int count = ccw_dstream_avail(get_cds(t));\n \n     assert(count <= (OUTPUT_BUFFER_SIZE - 3) / 2);\n \n@@ -244,7 +248,7 @@ static int write_payload_3270(EmulatedCcw3270Device *dev, uint8_t cmd,\n         return count;\n     }\n     t->outv[0] = cmd;\n-    cpu_physical_memory_read(cda, &t->outv[1], count);\n+    ccw_dstream_read_buf(get_cds(t), &t->outv[1], count);\n     t->out_len = count + 1;\n \n     t->out_len = insert_IAC_escape_char(t->outv, t->out_len);\ndiff --git a/hw/s390x/3270-ccw.c b/hw/s390x/3270-ccw.c\nindex 1554aa2484..eaca28e224 100644\n--- a/hw/s390x/3270-ccw.c\n+++ b/hw/s390x/3270-ccw.c\n@@ -28,7 +28,7 @@ static int handle_payload_3270_read(EmulatedCcw3270Device *dev, CCW1 *ccw)\n         return -EFAULT;\n     }\n \n-    len = ck->read_payload_3270(dev, ccw->cda, ccw->count);\n+    len = ck->read_payload_3270(dev);\n     ccw_dev->sch->curr_status.scsw.count = ccw->count - len;\n \n     return 0;\n@@ -45,7 +45,7 @@ static int handle_payload_3270_write(EmulatedCcw3270Device *dev, CCW1 *ccw)\n         return -EFAULT;\n     }\n \n-    len = ck->write_payload_3270(dev, ccw->cmd_code, ccw->cda, ccw->count);\n+    len = ck->write_payload_3270(dev, ccw->cmd_code);\n \n     if (len <= 0) {\n         return -EIO;\ndiff --git a/include/hw/s390x/3270-ccw.h b/include/hw/s390x/3270-ccw.h\nindex 46bee2533c..9d1d18e2bd 100644\n--- a/include/hw/s390x/3270-ccw.h\n+++ b/include/hw/s390x/3270-ccw.h\n@@ -45,9 +45,8 @@ typedef struct EmulatedCcw3270Class {\n     CCWDeviceClass parent_class;\n \n     void (*init)(EmulatedCcw3270Device *, Error **);\n-    int (*read_payload_3270)(EmulatedCcw3270Device *, uint32_t, uint16_t);\n-    int (*write_payload_3270)(EmulatedCcw3270Device *, uint8_t, uint32_t,\n-                              uint16_t);\n+    int (*read_payload_3270)(EmulatedCcw3270Device *);\n+    int (*write_payload_3270)(EmulatedCcw3270Device *, uint8_t);\n } EmulatedCcw3270Class;\n \n #endif\n","prefixes":["1/2"]}