public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: qemu-devel <qemu-devel@nongnu.org>, KVM <kvm@vger.kernel.org>,
	linux-s390 <linux-s390@vger.kernel.org>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Gleb Natapov <gleb@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Carsten Otte <cotte@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>
Subject: Re: [PATCH 2/8] s390: Channel I/O basic defintions.
Date: Mon, 10 Dec 2012 09:07:57 +0100	[thread overview]
Message-ID: <413896B0-480D-4113-99FC-6432847ADD9F@suse.de> (raw)
In-Reply-To: <1354884626-15060-3-git-send-email-cornelia.huck@de.ibm.com>


On 07.12.2012, at 13:50, Cornelia Huck wrote:

> Basic channel I/O structures and helper function.
> 
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> ---
> target-s390x/Makefile.objs |   2 +-
> target-s390x/ioinst.c      |  46 ++++++++++
> target-s390x/ioinst.h      | 207 +++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 254 insertions(+), 1 deletion(-)
> create mode 100644 target-s390x/ioinst.c
> create mode 100644 target-s390x/ioinst.h
> 
> diff --git a/target-s390x/Makefile.objs b/target-s390x/Makefile.objs
> index e728abf..3afb0b7 100644
> --- a/target-s390x/Makefile.objs
> +++ b/target-s390x/Makefile.objs
> @@ -1,4 +1,4 @@
> obj-y += translate.o helper.o cpu.o interrupt.o
> obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o
> -obj-$(CONFIG_SOFTMMU) += machine.o
> +obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o
> obj-$(CONFIG_KVM) += kvm.o
> diff --git a/target-s390x/ioinst.c b/target-s390x/ioinst.c
> new file mode 100644
> index 0000000..8577b2c
> --- /dev/null
> +++ b/target-s390x/ioinst.c
> @@ -0,0 +1,46 @@
> +/*
> + * I/O instructions for S/390
> + *
> + * Copyright 2012 IBM Corp.
> + * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or (at
> + * your option) any later version. See the COPYING file in the top-level
> + * directory.
> + */
> +
> +#include <sys/types.h>
> +#include <sys/ioctl.h>
> +#include <sys/mman.h>
> +
> +#include "cpu.h"
> +#include "ioinst.h"
> +
> +#ifdef DEBUG_IOINST
> +#define dprintf(fmt, ...) \
> +    do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
> +#else
> +#define dprintf(fmt, ...) \
> +    do { } while (0)
> +#endif
> +
> +int ioinst_disassemble_sch_ident(uint32_t value, int *m, int *cssid, int *ssid,
> +                                 int *schid)
> +{
> +    if (!(value & IOINST_SCHID_ONE)) {
> +        return -EINVAL;
> +    }
> +    if (!(value & IOINST_SCHID_M)) {
> +        if (value & IOINST_SCHID_CSSID) {
> +            return -EINVAL;
> +        }
> +        *cssid = 0;
> +        *m = 0;
> +    } else {
> +        *cssid = (value & IOINST_SCHID_CSSID) >> 24;

(value & IOINST_SCHID_CSSID_MASK) >> IOINST_SCHID_CSSID_SHIFT


Alex

> +        *m = 1;
> +    }
> +    *ssid = (value & IOINST_SCHID_SSID) >> 17;
> +    *schid = value & IOINST_SCHID_NR;
> +    return 0;
> +}
> diff --git a/target-s390x/ioinst.h b/target-s390x/ioinst.h
> new file mode 100644
> index 0000000..b5b4a03
> --- /dev/null
> +++ b/target-s390x/ioinst.h
> @@ -0,0 +1,207 @@
> +/*
> + * S/390 channel I/O instructions
> + *
> + * Copyright 2012 IBM Corp.
> + * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or (at
> + * your option) any later version. See the COPYING file in the top-level
> + * directory.
> +*/
> +
> +#ifndef IOINST_S390X_H
> +#define IOINST_S390X_H
> +/*
> + * Channel I/O related definitions, as defined in the Principles
> + * Of Operation (and taken from the Linux implementation).
> + */
> +
> +/* subchannel status word (command mode only) */
> +typedef struct SCSW {
> +    uint16_t flags;
> +    uint16_t ctrl;
> +    uint32_t cpa;
> +    uint8_t dstat;
> +    uint8_t cstat;
> +    uint16_t count;
> +} QEMU_PACKED SCSW;
> +
> +#define SCSW_FLAGS_MASK_KEY 0xf000
> +#define SCSW_FLAGS_MASK_SCTL 0x0800
> +#define SCSW_FLAGS_MASK_ESWF 0x0400
> +#define SCSW_FLAGS_MASK_CC 0x0300
> +#define SCSW_FLAGS_MASK_FMT 0x0080
> +#define SCSW_FLAGS_MASK_PFCH 0x0040
> +#define SCSW_FLAGS_MASK_ISIC 0x0020
> +#define SCSW_FLAGS_MASK_ALCC 0x0010
> +#define SCSW_FLAGS_MASK_SSI 0x0008
> +#define SCSW_FLAGS_MASK_ZCC 0x0004
> +#define SCSW_FLAGS_MASK_ECTL 0x0002
> +#define SCSW_FLAGS_MASK_PNO 0x0001
> +
> +#define SCSW_CTRL_MASK_FCTL 0x7000
> +#define SCSW_CTRL_MASK_ACTL 0x0fe0
> +#define SCSW_CTRL_MASK_STCTL 0x001f
> +
> +#define SCSW_FCTL_CLEAR_FUNC 0x1000
> +#define SCSW_FCTL_HALT_FUNC 0x2000
> +#define SCSW_FCTL_START_FUNC 0x4000
> +
> +#define SCSW_ACTL_SUSP 0x0020
> +#define SCSW_ACTL_DEVICE_ACTIVE 0x0040
> +#define SCSW_ACTL_SUBCH_ACTIVE 0x0080
> +#define SCSW_ACTL_CLEAR_PEND 0x0100
> +#define SCSW_ACTL_HALT_PEND  0x0200
> +#define SCSW_ACTL_START_PEND 0x0400
> +#define SCSW_ACTL_RESUME_PEND 0x0800
> +
> +#define SCSW_STCTL_STATUS_PEND 0x0001
> +#define SCSW_STCTL_SECONDARY 0x0002
> +#define SCSW_STCTL_PRIMARY 0x0004
> +#define SCSW_STCTL_INTERMEDIATE 0x0008
> +#define SCSW_STCTL_ALERT 0x0010
> +
> +#define SCSW_DSTAT_ATTENTION     0x80
> +#define SCSW_DSTAT_STAT_MOD      0x40
> +#define SCSW_DSTAT_CU_END        0x20
> +#define SCSW_DSTAT_BUSY          0x10
> +#define SCSW_DSTAT_CHANNEL_END   0x08
> +#define SCSW_DSTAT_DEVICE_END    0x04
> +#define SCSW_DSTAT_UNIT_CHECK    0x02
> +#define SCSW_DSTAT_UNIT_EXCEP    0x01
> +
> +#define SCSW_CSTAT_PCI           0x80
> +#define SCSW_CSTAT_INCORR_LEN    0x40
> +#define SCSW_CSTAT_PROG_CHECK    0x20
> +#define SCSW_CSTAT_PROT_CHECK    0x10
> +#define SCSW_CSTAT_DATA_CHECK    0x08
> +#define SCSW_CSTAT_CHN_CTRL_CHK  0x04
> +#define SCSW_CSTAT_INTF_CTRL_CHK 0x02
> +#define SCSW_CSTAT_CHAIN_CHECK   0x01
> +
> +/* path management control word */
> +typedef struct PMCW {
> +    uint32_t intparm;
> +    uint16_t flags;
> +    uint16_t devno;
> +    uint8_t  lpm;
> +    uint8_t  pnom;
> +    uint8_t  lpum;
> +    uint8_t  pim;
> +    uint16_t mbi;
> +    uint8_t  pom;
> +    uint8_t  pam;
> +    uint8_t  chpid[8];
> +    uint32_t chars;
> +} QEMU_PACKED PMCW;
> +
> +#define PMCW_FLAGS_MASK_QF 0x8000
> +#define PMCW_FLAGS_MASK_W 0x4000
> +#define PMCW_FLAGS_MASK_ISC 0x3800
> +#define PMCW_FLAGS_MASK_ENA 0x0080
> +#define PMCW_FLAGS_MASK_LM 0x0060
> +#define PMCW_FLAGS_MASK_MME 0x0018
> +#define PMCW_FLAGS_MASK_MP 0x0004
> +#define PMCW_FLAGS_MASK_TF 0x0002
> +#define PMCW_FLAGS_MASK_DNV 0x0001
> +#define PMCW_FLAGS_MASK_INVALID 0x0700
> +
> +#define PMCW_CHARS_MASK_ST 0x00e00000
> +#define PMCW_CHARS_MASK_MBFC 0x00000004
> +#define PMCW_CHARS_MASK_XMWME 0x00000002
> +#define PMCW_CHARS_MASK_CSENSE 0x00000001
> +#define PMCW_CHARS_MASK_INVALID 0xff1ffff8
> +
> +/* subchannel information block */
> +struct SCHIB {
> +    PMCW pmcw;
> +    SCSW scsw;
> +    uint64_t mba;
> +    uint8_t mda[4];
> +} QEMU_PACKED;
> +
> +/* interruption response block */
> +typedef struct IRB {
> +    SCSW scsw;
> +    uint32_t esw[5];
> +    uint32_t ecw[8];
> +    uint32_t emw[8];
> +} QEMU_PACKED IRB;
> +
> +/* operation request block */
> +struct ORB {
> +    uint32_t intparm;
> +    uint16_t ctrl0;
> +    uint8_t lpm;
> +    uint8_t ctrl1;
> +    uint32_t cpa;
> +} QEMU_PACKED;
> +
> +#define ORB_CTRL0_MASK_KEY 0xf000
> +#define ORB_CTRL0_MASK_SPND 0x0800
> +#define ORB_CTRL0_MASK_STR 0x0400
> +#define ORB_CTRL0_MASK_MOD 0x0200
> +#define ORB_CTRL0_MASK_SYNC 0x0100
> +#define ORB_CTRL0_MASK_FMT 0x0080
> +#define ORB_CTRL0_MASK_PFCH 0x0040
> +#define ORB_CTRL0_MASK_ISIC 0x0020
> +#define ORB_CTRL0_MASK_ALCC 0x0010
> +#define ORB_CTRL0_MASK_SSIC 0x0008
> +#define ORB_CTRL0_MASK_C64 0x0002
> +#define ORB_CTRL0_MASK_I2K 0x0001
> +#define ORB_CTRL0_MASK_INVALID 0x0004
> +
> +#define ORB_CTRL1_MASK_ILS 0x80
> +#define ORB_CTRL1_MASK_MIDAW 0x40
> +#define ORB_CTRL1_MASK_ORBX 0x01
> +#define ORB_CTRL1_MASK_INVALID 0x3e
> +
> +/* channel command word (type 1) */
> +typedef struct CCW1 {
> +    uint8_t cmd_code;
> +    uint8_t flags;
> +    uint16_t count;
> +    uint32_t cda;
> +} QEMU_PACKED CCW1;
> +
> +#define CCW_FLAG_DC              0x80
> +#define CCW_FLAG_CC              0x40
> +#define CCW_FLAG_SLI             0x20
> +#define CCW_FLAG_SKIP            0x10
> +#define CCW_FLAG_PCI             0x08
> +#define CCW_FLAG_IDA             0x04
> +#define CCW_FLAG_SUSPEND         0x02
> +
> +#define CCW_CMD_NOOP             0x03
> +#define CCW_CMD_BASIC_SENSE      0x04
> +#define CCW_CMD_TIC              0x08
> +#define CCW_CMD_SENSE_ID         0xe4
> +
> +typedef struct CRW {
> +    uint16_t flags;
> +    uint16_t rsid;
> +} QEMU_PACKED CRW;
> +
> +#define CRW_FLAGS_MASK_S 0x4000
> +#define CRW_FLAGS_MASK_R 0x2000
> +#define CRW_FLAGS_MASK_C 0x1000
> +#define CRW_FLAGS_MASK_RSC 0x0f00
> +#define CRW_FLAGS_MASK_A 0x0080
> +#define CRW_FLAGS_MASK_ERC 0x003f
> +
> +#define CRW_ERC_INIT 0x02
> +#define CRW_ERC_IPI  0x04
> +
> +#define CRW_RSC_SUBCH 0x3
> +#define CRW_RSC_CHP   0x4
> +
> +/* schid disintegration */
> +#define IOINST_SCHID_ONE   0x00010000
> +#define IOINST_SCHID_M     0x00080000
> +#define IOINST_SCHID_CSSID 0xff000000
> +#define IOINST_SCHID_SSID  0x00060000
> +#define IOINST_SCHID_NR    0x0000ffff
> +
> +int ioinst_disassemble_sch_ident(uint32_t value, int *m, int *cssid, int *ssid,
> +                                 int *schid);
> +#endif
> -- 
> 1.7.12.4
> 

  reply	other threads:[~2012-12-10  8:07 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07 12:50 [RFC PATCH v4 0/8] s390: channel I/O support in qemu Cornelia Huck
2012-12-07 12:50 ` [PATCH 1/8] Update linux headers Cornelia Huck
2012-12-07 13:01   ` [Qemu-devel] " Peter Maydell
2012-12-07 14:08     ` Cornelia Huck
2012-12-07 12:50 ` [PATCH 2/8] s390: Channel I/O basic defintions Cornelia Huck
2012-12-10  8:07   ` Alexander Graf [this message]
2012-12-10 10:18     ` Cornelia Huck
2012-12-11 10:27       ` Alexander Graf
2012-12-11 12:48         ` Cornelia Huck
2012-12-07 12:50 ` [PATCH 3/8] s390: I/O interrupt and machine check injection Cornelia Huck
2012-12-10  8:20   ` Alexander Graf
2012-12-10 10:27     ` Cornelia Huck
2012-12-11  0:26       ` Rob Landley
2012-12-11 12:17         ` [Qemu-devel] " Cornelia Huck
2012-12-11 10:29       ` Alexander Graf
2012-12-11 12:50         ` Cornelia Huck
2012-12-07 12:50 ` [PATCH 4/8] s390: Add channel I/O instructions Cornelia Huck
2012-12-10  9:00   ` Alexander Graf
2012-12-10  9:18     ` Cornelia Huck
2012-12-11 10:18       ` Alexander Graf
2012-12-11 12:53         ` Cornelia Huck
2012-12-07 12:50 ` [PATCH 5/8] s390: Virtual channel subsystem support Cornelia Huck
2012-12-07 12:50 ` [PATCH 6/8] s390: Wire up channel I/O in kvm Cornelia Huck
2012-12-10  9:40   ` Alexander Graf
2012-12-10 10:29     ` Cornelia Huck
2012-12-07 12:50 ` [PATCH 7/8] s390-virtio: Factor out some initialization code Cornelia Huck
2012-12-07 12:50 ` [PATCH 8/8] s390: Add new channel I/O based virtio transport Cornelia Huck
2012-12-11 10:53   ` Alexander Graf
2012-12-11 12:06     ` Christian Borntraeger
2012-12-12  0:38       ` Alexander Graf
2012-12-11 13:03     ` Cornelia Huck
2012-12-12  0:39       ` Alexander Graf
2013-01-16 13:24   ` Alexander Graf
2013-01-16 13:53     ` [Qemu-devel] " Alexander Graf
2013-01-16 13:58       ` Cornelia Huck
2013-01-16 16:46     ` Richard Henderson
2013-01-16 17:05       ` Alexander Graf
2012-12-10  8:02 ` [RFC PATCH v4 0/8] s390: channel I/O support in qemu Alexander Graf
2012-12-10 10:34   ` Cornelia Huck

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=413896B0-480D-4113-99FC-6432847ADD9F@suse.de \
    --to=agraf@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=cotte@de.ibm.com \
    --cc=gleb@redhat.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=sebott@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