Commit 9d92a7e1 authored by Cornelia Huck's avatar Cornelia Huck Committed by Heiko Carstens

[S390] cio: Add chsc subchannel driver.

This patch adds a driver for subchannels of type chsc.

A device /dev/chsc is created which may be used to issue ioctls to:
- obtain information about the machine's I/O configuration
- dynamically change the machine's I/O configuration via
  asynchronous chsc commands
Signed-off-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
parent 683c5418
...@@ -117,6 +117,7 @@ Code Seq# Include File Comments ...@@ -117,6 +117,7 @@ Code Seq# Include File Comments
<mailto:natalia@nikhefk.nikhef.nl> <mailto:natalia@nikhefk.nikhef.nl>
'c' 00-7F linux/comstats.h conflict! 'c' 00-7F linux/comstats.h conflict!
'c' 00-7F linux/coda.h conflict! 'c' 00-7F linux/coda.h conflict!
'c' 80-9F asm-s390/chsc.h
'd' 00-FF linux/char/drm/drm/h conflict! 'd' 00-FF linux/char/drm/drm/h conflict!
'd' 00-DF linux/video_decoder.h conflict! 'd' 00-DF linux/video_decoder.h conflict!
'd' F0-FF linux/digi1.h 'd' F0-FF linux/digi1.h
......
...@@ -345,6 +345,22 @@ config QDIO_DEBUG ...@@ -345,6 +345,22 @@ config QDIO_DEBUG
If unsure, say N. If unsure, say N.
config CHSC_SCH
tristate "Support for CHSC subchannels"
help
This driver allows usage of CHSC subchannels. A CHSC subchannel
is usually present on LPAR only.
The driver creates a device /dev/chsc, which may be used to
obtain I/O configuration information about the machine and
to issue asynchronous chsc commands (DANGEROUS).
You will usually only want to use this interface on a special
LPAR designated for system management.
To compile this driver as a module, choose M here: the
module will be called chsc_sch.
If unsure, say N.
comment "Misc" comment "Misc"
config IPL config IPL
......
...@@ -7,5 +7,6 @@ obj-y += airq.o blacklist.o chsc.o cio.o css.o chp.o idset.o isc.o scsw.o \ ...@@ -7,5 +7,6 @@ obj-y += airq.o blacklist.o chsc.o cio.o css.o chp.o idset.o isc.o scsw.o \
ccw_device-objs += device.o device_fsm.o device_ops.o ccw_device-objs += device.o device_fsm.o device_ops.o
ccw_device-objs += device_id.o device_pgid.o device_status.o ccw_device-objs += device_id.o device_pgid.o device_status.o
obj-y += ccw_device.o cmf.o obj-y += ccw_device.o cmf.o
obj-$(CONFIG_CHSC_SCH) += chsc_sch.o
obj-$(CONFIG_CCWGROUP) += ccwgroup.o obj-$(CONFIG_CCWGROUP) += ccwgroup.o
obj-$(CONFIG_QDIO) += qdio.o obj-$(CONFIG_QDIO) += qdio.o
...@@ -407,7 +407,7 @@ int chp_new(struct chp_id chpid) ...@@ -407,7 +407,7 @@ int chp_new(struct chp_id chpid)
chpid.id); chpid.id);
/* Obtain channel path description and fill it in. */ /* Obtain channel path description and fill it in. */
ret = chsc_determine_channel_path_description(chpid, &chp->desc); ret = chsc_determine_base_channel_path_desc(chpid, &chp->desc);
if (ret) if (ret)
goto out_free; goto out_free;
if ((chp->desc.flags & 0x80) == 0) { if ((chp->desc.flags & 0x80) == 0) {
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <asm/cio.h> #include <asm/cio.h>
#include <asm/chpid.h> #include <asm/chpid.h>
#include <asm/chsc.h>
#include "../s390mach.h" #include "../s390mach.h"
#include "css.h" #include "css.h"
...@@ -627,23 +628,33 @@ chsc_secm(struct channel_subsystem *css, int enable) ...@@ -627,23 +628,33 @@ chsc_secm(struct channel_subsystem *css, int enable)
return ret; return ret;
} }
int chsc_determine_channel_path_description(struct chp_id chpid, int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
struct channel_path_desc *desc) int c, int m,
struct chsc_response_struct *resp)
{ {
int ccode, ret; int ccode, ret;
struct { struct {
struct chsc_header request; struct chsc_header request;
u32 : 24; u32 : 2;
u32 m : 1;
u32 c : 1;
u32 fmt : 4;
u32 cssid : 8;
u32 : 4;
u32 rfmt : 4;
u32 first_chpid : 8; u32 first_chpid : 8;
u32 : 24; u32 : 24;
u32 last_chpid : 8; u32 last_chpid : 8;
u32 zeroes1; u32 zeroes1;
struct chsc_header response; struct chsc_header response;
u32 zeroes2; u8 data[PAGE_SIZE - 20];
struct channel_path_desc desc;
} __attribute__ ((packed)) *scpd_area; } __attribute__ ((packed)) *scpd_area;
if ((rfmt == 1) && !css_general_characteristics.fcs)
return -EINVAL;
if ((rfmt == 2) && !css_general_characteristics.cib)
return -EINVAL;
scpd_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); scpd_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
if (!scpd_area) if (!scpd_area)
return -ENOMEM; return -ENOMEM;
...@@ -651,8 +662,13 @@ int chsc_determine_channel_path_description(struct chp_id chpid, ...@@ -651,8 +662,13 @@ int chsc_determine_channel_path_description(struct chp_id chpid,
scpd_area->request.length = 0x0010; scpd_area->request.length = 0x0010;
scpd_area->request.code = 0x0002; scpd_area->request.code = 0x0002;
scpd_area->cssid = chpid.cssid;
scpd_area->first_chpid = chpid.id; scpd_area->first_chpid = chpid.id;
scpd_area->last_chpid = chpid.id; scpd_area->last_chpid = chpid.id;
scpd_area->m = m;
scpd_area->c = c;
scpd_area->fmt = fmt;
scpd_area->rfmt = rfmt;
ccode = chsc(scpd_area); ccode = chsc(scpd_area);
if (ccode > 0) { if (ccode > 0) {
...@@ -663,8 +679,7 @@ int chsc_determine_channel_path_description(struct chp_id chpid, ...@@ -663,8 +679,7 @@ int chsc_determine_channel_path_description(struct chp_id chpid,
ret = chsc_error_from_response(scpd_area->response.code); ret = chsc_error_from_response(scpd_area->response.code);
if (ret == 0) if (ret == 0)
/* Success. */ /* Success. */
memcpy(desc, &scpd_area->desc, memcpy(resp, &scpd_area->response, scpd_area->response.length);
sizeof(struct channel_path_desc));
else else
CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n", CIO_CRW_EVENT(2, "chsc: scpd failed (rc=%04x)\n",
scpd_area->response.code); scpd_area->response.code);
...@@ -672,6 +687,25 @@ out: ...@@ -672,6 +687,25 @@ out:
free_page((unsigned long)scpd_area); free_page((unsigned long)scpd_area);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(chsc_determine_channel_path_desc);
int chsc_determine_base_channel_path_desc(struct chp_id chpid,
struct channel_path_desc *desc)
{
struct chsc_response_struct *chsc_resp;
int ret;
chsc_resp = kzalloc(sizeof(*chsc_resp), GFP_KERNEL);
if (!chsc_resp)
return -ENOMEM;
ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, chsc_resp);
if (ret)
goto out_free;
memcpy(desc, &chsc_resp->data, chsc_resp->length);
out_free:
kfree(chsc_resp);
return ret;
}
static void static void
chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv, chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv,
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/device.h> #include <linux/device.h>
#include <asm/chpid.h> #include <asm/chpid.h>
#include "schid.h" #include <asm/chsc.h>
#include <asm/schid.h>
#define CHSC_SDA_OC_MSS 0x2 #define CHSC_SDA_OC_MSS 0x2
...@@ -37,11 +38,14 @@ struct channel_path_desc { ...@@ -37,11 +38,14 @@ struct channel_path_desc {
struct channel_path; struct channel_path;
struct css_general_char { struct css_general_char {
u64 : 41; u64 : 12;
u32 dynio : 1; /* bit 12 */
u32 : 28;
u32 aif : 1; /* bit 41 */ u32 aif : 1; /* bit 41 */
u32 : 3; u32 : 3;
u32 mcss : 1; /* bit 45 */ u32 mcss : 1; /* bit 45 */
u32 : 2; u32 fcs : 1; /* bit 46 */
u32 : 1;
u32 ext_mb : 1; /* bit 48 */ u32 ext_mb : 1; /* bit 48 */
u32 : 7; u32 : 7;
u32 aif_tdd : 1; /* bit 56 */ u32 aif_tdd : 1; /* bit 56 */
...@@ -49,7 +53,9 @@ struct css_general_char { ...@@ -49,7 +53,9 @@ struct css_general_char {
u32 qebsm : 1; /* bit 58 */ u32 qebsm : 1; /* bit 58 */
u32 : 8; u32 : 8;
u32 aif_osa : 1; /* bit 67 */ u32 aif_osa : 1; /* bit 67 */
u32 : 20; u32 : 14;
u32 cib : 1; /* bit 82 */
u32 : 5;
u32 fcx : 1; /* bit 88 */ u32 fcx : 1; /* bit 88 */
u32 : 7; u32 : 7;
}__attribute__((packed)); }__attribute__((packed));
...@@ -86,8 +92,11 @@ struct channel_subsystem; ...@@ -86,8 +92,11 @@ struct channel_subsystem;
extern int chsc_secm(struct channel_subsystem *, int); extern int chsc_secm(struct channel_subsystem *, int);
int chsc_chp_vary(struct chp_id chpid, int on); int chsc_chp_vary(struct chp_id chpid, int on);
int chsc_determine_channel_path_description(struct chp_id chpid, int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
struct channel_path_desc *desc); int c, int m,
struct chsc_response_struct *resp);
int chsc_determine_base_channel_path_desc(struct chp_id chpid,
struct channel_path_desc *desc);
void chsc_chp_online(struct chp_id chpid); void chsc_chp_online(struct chp_id chpid);
void chsc_chp_offline(struct chp_id chpid); void chsc_chp_offline(struct chp_id chpid);
int chsc_get_channel_measurement_chars(struct channel_path *chp); int chsc_get_channel_measurement_chars(struct channel_path *chp);
......
This diff is collapsed.
#ifndef _CHSC_SCH_H
#define _CHSC_SCH_H
struct chsc_request {
struct completion completion;
struct irb irb;
};
struct chsc_private {
struct chsc_request *request;
};
#endif
...@@ -877,6 +877,12 @@ __clear_io_subchannel_easy(struct subchannel_id schid) ...@@ -877,6 +877,12 @@ __clear_io_subchannel_easy(struct subchannel_id schid)
return -EBUSY; return -EBUSY;
} }
static void __clear_chsc_subchannel_easy(void)
{
/* It seems we can only wait for a bit here :/ */
udelay_reset(100);
}
static int pgm_check_occured; static int pgm_check_occured;
static void cio_reset_pgm_check_handler(void) static void cio_reset_pgm_check_handler(void)
...@@ -920,6 +926,9 @@ static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data) ...@@ -920,6 +926,9 @@ static int __shutdown_subchannel_easy(struct subchannel_id schid, void *data)
if (__clear_io_subchannel_easy(schid)) if (__clear_io_subchannel_easy(schid))
goto out; /* give up... */ goto out; /* give up... */
break; break;
case SUBCHANNEL_TYPE_CHSC:
__clear_chsc_subchannel_easy();
break;
default: default:
/* No default clear strategy */ /* No default clear strategy */
break; break;
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include <asm/chpid.h> #include <asm/chpid.h>
#include <asm/cio.h> #include <asm/cio.h>
#include <asm/fcx.h> #include <asm/fcx.h>
#include <asm/schid.h>
#include "chsc.h" #include "chsc.h"
#include "schid.h"
/* /*
* path management control word * path management control word
......
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
#include <asm/cio.h> #include <asm/cio.h>
#include <asm/chpid.h> #include <asm/chpid.h>
#include <asm/schid.h>
#include "schid.h"
/* /*
* path grouping stuff * path grouping stuff
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#ifndef S390_IDSET_H #ifndef S390_IDSET_H
#define S390_IDSET_H S390_IDSET_H #define S390_IDSET_H S390_IDSET_H
#include "schid.h" #include <asm/schid.h>
struct idset; struct idset;
......
#ifndef S390_IO_SCH_H #ifndef S390_IO_SCH_H
#define S390_IO_SCH_H #define S390_IO_SCH_H
#include "schid.h" #include <asm/schid.h>
/* /*
* command-mode operation request block * command-mode operation request block
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define S390_CIO_IOASM_H #define S390_CIO_IOASM_H
#include <asm/chpid.h> #include <asm/chpid.h>
#include "schid.h" #include <asm/schid.h>
/* /*
* TPI info structure * TPI info structure
......
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
#include <asm/page.h> #include <asm/page.h>
#include <asm/isc.h> #include <asm/isc.h>
#include <asm/schid.h>
#include "schid.h"
#ifdef CONFIG_QDIO_DEBUG #ifdef CONFIG_QDIO_DEBUG
#define QDIO_VERBOSE_LEVEL 9 #define QDIO_VERBOSE_LEVEL 9
......
...@@ -8,6 +8,9 @@ header-y += ucontext.h ...@@ -8,6 +8,9 @@ header-y += ucontext.h
header-y += vtoc.h header-y += vtoc.h
header-y += zcrypt.h header-y += zcrypt.h
header-y += kvm.h header-y += kvm.h
header-y += schid.h
header-y += chsc.h
unifdef-y += cmb.h unifdef-y += cmb.h
unifdef-y += debug.h unifdef-y += debug.h
unifdef-y += chpid.h
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <linux/string.h> #include <linux/string.h>
#include <asm/types.h> #include <asm/types.h>
#include <asm/cio.h>
#define __MAX_CHPID 255 #define __MAX_CHPID 255
...@@ -41,6 +40,9 @@ static inline void chp_id_next(struct chp_id *chpid) ...@@ -41,6 +40,9 @@ static inline void chp_id_next(struct chp_id *chpid)
} }
} }
#ifdef __KERNEL__
#include <asm/cio.h>
static inline int chp_id_is_valid(struct chp_id *chpid) static inline int chp_id_is_valid(struct chp_id *chpid)
{ {
return (chpid->cssid <= __MAX_CSSID); return (chpid->cssid <= __MAX_CSSID);
...@@ -49,5 +51,6 @@ static inline int chp_id_is_valid(struct chp_id *chpid) ...@@ -49,5 +51,6 @@ static inline int chp_id_is_valid(struct chp_id *chpid)
#define chp_id_for_each(c) \ #define chp_id_for_each(c) \
for (chp_id_init(c); chp_id_is_valid(c); chp_id_next(c)) for (chp_id_init(c); chp_id_is_valid(c); chp_id_next(c))
#endif /* __KERNEL */
#endif /* _ASM_S390_CHPID_H */ #endif /* _ASM_S390_CHPID_H */
/*
* ioctl interface for /dev/chsc
*
* Copyright 2008 IBM Corp.
* Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
*/
#ifndef _ASM_CHSC_H
#define _ASM_CHSC_H
#include <asm/chpid.h>
#include <asm/schid.h>
struct chsc_async_header {
__u16 length;
__u16 code;
__u32 cmd_dependend;
__u32 key : 4;
__u32 : 28;
struct subchannel_id sid;
} __attribute__ ((packed));
struct chsc_async_area {
struct chsc_async_header header;
__u8 data[PAGE_SIZE - 16 /* size of chsc_async_header */];
} __attribute__ ((packed));
struct chsc_response_struct {
__u16 length;
__u16 code;
__u32 parms;
__u8 data[PAGE_SIZE - 8];
} __attribute__ ((packed));
struct chsc_chp_cd {
struct chp_id chpid;
int m;
int fmt;
struct chsc_response_struct cpcb;
};
struct chsc_cu_cd {
__u16 cun;
__u8 cssid;
int m;
int fmt;
struct chsc_response_struct cucb;
};
struct chsc_sch_cud {
struct subchannel_id schid;
int fmt;
struct chsc_response_struct scub;
};
struct conf_id {
int m;
__u8 cssid;
__u8 ssid;
};
struct chsc_conf_info {
struct conf_id id;
int fmt;
struct chsc_response_struct scid;
};
struct ccl_parm_chpid {
int m;
struct chp_id chp;
};
struct ccl_parm_cssids {
__u8 f_cssid;
__u8 l_cssid;
};
struct chsc_comp_list {
struct {
enum {
CCL_CU_ON_CHP = 1,
CCL_CHP_TYPE_CAP = 2,
CCL_CSS_IMG = 4,
CCL_CSS_IMG_CONF_CHAR = 5,
CCL_IOP_CHP = 6,
} ctype;
int fmt;
struct ccl_parm_chpid chpid;
struct ccl_parm_cssids cssids;
} req;
struct chsc_response_struct sccl;
};
struct chsc_dcal {
struct {
enum {
DCAL_CSS_IID_PN = 4,
} atype;
__u32 list_parm[2];
int fmt;
} req;
struct chsc_response_struct sdcal;
};
struct chsc_cpd_info {
struct chp_id chpid;
int m;
int fmt;
int rfmt;
int c;
struct chsc_response_struct chpdb;
};
#define CHSC_IOCTL_MAGIC 'c'
#define CHSC_START _IOWR(CHSC_IOCTL_MAGIC, 0x81, struct chsc_async_area)
#define CHSC_INFO_CHANNEL_PATH _IOWR(CHSC_IOCTL_MAGIC, 0x82, \
struct chsc_chp_cd)
#define CHSC_INFO_CU _IOWR(CHSC_IOCTL_MAGIC, 0x83, struct chsc_cu_cd)
#define CHSC_INFO_SCH_CU _IOWR(CHSC_IOCTL_MAGIC, 0x84, struct chsc_sch_cud)
#define CHSC_INFO_CI _IOWR(CHSC_IOCTL_MAGIC, 0x85, struct chsc_conf_info)
#define CHSC_INFO_CCL _IOWR(CHSC_IOCTL_MAGIC, 0x86, struct chsc_comp_list)
#define CHSC_INFO_CPD _IOWR(CHSC_IOCTL_MAGIC, 0x87, struct chsc_cpd_info)
#define CHSC_INFO_DCAL _IOWR(CHSC_IOCTL_MAGIC, 0x88, struct chsc_dcal)
#endif
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
/* Regular I/O interrupts. */ /* Regular I/O interrupts. */
#define IO_SCH_ISC 3 /* regular I/O subchannels */ #define IO_SCH_ISC 3 /* regular I/O subchannels */
#define CONSOLE_ISC 1 /* console I/O subchannel */ #define CONSOLE_ISC 1 /* console I/O subchannel */
#define CHSC_SCH_ISC 7 /* CHSC subchannels */
/* Adapter interrupts. */ /* Adapter interrupts. */
#define QDIO_AIRQ_ISC IO_SCH_ISC /* I/O subchannel in qdio mode */ #define QDIO_AIRQ_ISC IO_SCH_ISC /* I/O subchannel in qdio mode */
......
#ifndef S390_SCHID_H #ifndef ASM_SCHID_H
#define S390_SCHID_H #define ASM_SCHID_H
struct subchannel_id { struct subchannel_id {
__u32 reserved:13; __u32 cssid : 8;
__u32 ssid:2; __u32 : 4;
__u32 one:1; __u32 m : 1;
__u32 sch_no:16; __u32 ssid : 2;
} __attribute__ ((packed,aligned(4))); __u32 one : 1;
__u32 sch_no : 16;
} __attribute__ ((packed, aligned(4)));
/* Helper function for sane state of pre-allocated subchannel_id. */ /* Helper function for sane state of pre-allocated subchannel_id. */
...@@ -23,4 +25,4 @@ schid_equal(struct subchannel_id *schid1, struct subchannel_id *schid2) ...@@ -23,4 +25,4 @@ schid_equal(struct subchannel_id *schid1, struct subchannel_id *schid2)
return !memcmp(schid1, schid2, sizeof(struct subchannel_id)); return !memcmp(schid1, schid2, sizeof(struct subchannel_id));
} }
#endif /* S390_SCHID_H */ #endif /* ASM_SCHID_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment