11da177e4SLinus Torvalds #ifndef S390_CIO_H 21da177e4SLinus Torvalds #define S390_CIO_H 31da177e4SLinus Torvalds 46ab4879aSCornelia Huck #include <linux/mutex.h> 5e5854a58SPeter Oberparleiter #include <linux/device.h> 67e9db9eaSCornelia Huck #include <linux/mod_devicetable.h> 77ad6a249SPeter Oberparleiter #include <asm/chpid.h> 883262d63SPeter Oberparleiter #include <asm/cio.h> 983262d63SPeter Oberparleiter #include <asm/fcx.h> 109d92a7e1SCornelia Huck #include <asm/schid.h> 117ad6a249SPeter Oberparleiter #include "chsc.h" 121da177e4SLinus Torvalds 131da177e4SLinus Torvalds /* 141da177e4SLinus Torvalds * path management control word 151da177e4SLinus Torvalds */ 161da177e4SLinus Torvalds struct pmcw { 17cd6b4f27SCornelia Huck u32 intparm; /* interruption parameter */ 18cd6b4f27SCornelia Huck u32 qf : 1; /* qdio facility */ 19b3a686f4SCornelia Huck u32 w : 1; 20cd6b4f27SCornelia Huck u32 isc : 3; /* interruption sublass */ 21cd6b4f27SCornelia Huck u32 res5 : 3; /* reserved zeros */ 22cd6b4f27SCornelia Huck u32 ena : 1; /* enabled */ 23cd6b4f27SCornelia Huck u32 lm : 2; /* limit mode */ 24cd6b4f27SCornelia Huck u32 mme : 2; /* measurement-mode enable */ 25cd6b4f27SCornelia Huck u32 mp : 1; /* multipath mode */ 26cd6b4f27SCornelia Huck u32 tf : 1; /* timing facility */ 27cd6b4f27SCornelia Huck u32 dnv : 1; /* device number valid */ 28cd6b4f27SCornelia Huck u32 dev : 16; /* device number */ 29cd6b4f27SCornelia Huck u8 lpm; /* logical path mask */ 30cd6b4f27SCornelia Huck u8 pnom; /* path not operational mask */ 31cd6b4f27SCornelia Huck u8 lpum; /* last path used mask */ 32cd6b4f27SCornelia Huck u8 pim; /* path installed mask */ 33cd6b4f27SCornelia Huck u16 mbi; /* measurement-block index */ 34cd6b4f27SCornelia Huck u8 pom; /* path operational mask */ 35cd6b4f27SCornelia Huck u8 pam; /* path available mask */ 36cd6b4f27SCornelia Huck u8 chpid[8]; /* CHPID 0-7 (if available) */ 37cd6b4f27SCornelia Huck u32 unused1 : 8; /* reserved zeros */ 38cd6b4f27SCornelia Huck u32 st : 3; /* subchannel type */ 39cd6b4f27SCornelia Huck u32 unused2 : 18; /* reserved zeros */ 40cd6b4f27SCornelia Huck u32 mbfc : 1; /* measurement block format control */ 41cd6b4f27SCornelia Huck u32 xmwme : 1; /* extended measurement word mode enable */ 42cd6b4f27SCornelia Huck u32 csense : 1; /* concurrent sense; can be enabled ...*/ 431da177e4SLinus Torvalds /* ... per MSCH, however, if facility */ 441da177e4SLinus Torvalds /* ... is not installed, this results */ 451da177e4SLinus Torvalds /* ... in an operand exception. */ 461da177e4SLinus Torvalds } __attribute__ ((packed)); 471da177e4SLinus Torvalds 482ab59de7SPeter Oberparleiter /* I/O-Interruption Code as stored by TEST PENDING INTERRUPTION (TPI). */ 492ab59de7SPeter Oberparleiter struct tpi_info { 502ab59de7SPeter Oberparleiter struct subchannel_id schid; 512ab59de7SPeter Oberparleiter u32 intparm; 522ab59de7SPeter Oberparleiter u32 adapter_IO:1; 532ab59de7SPeter Oberparleiter u32 :1; 542ab59de7SPeter Oberparleiter u32 isc:3; 552ab59de7SPeter Oberparleiter u32 :27; 562ab59de7SPeter Oberparleiter u32 type:3; 572ab59de7SPeter Oberparleiter u32 :12; 582ab59de7SPeter Oberparleiter } __packed __aligned(4); 592ab59de7SPeter Oberparleiter 6013952ec1SSebastian Ott /* Target SCHIB configuration. */ 6113952ec1SSebastian Ott struct schib_config { 6213952ec1SSebastian Ott u64 mba; 6313952ec1SSebastian Ott u32 intparm; 6413952ec1SSebastian Ott u16 mbi; 6513952ec1SSebastian Ott u32 isc:3; 6613952ec1SSebastian Ott u32 ena:1; 6713952ec1SSebastian Ott u32 mme:2; 6813952ec1SSebastian Ott u32 mp:1; 6913952ec1SSebastian Ott u32 csense:1; 7013952ec1SSebastian Ott u32 mbfc:1; 7113952ec1SSebastian Ott } __attribute__ ((packed)); 7213952ec1SSebastian Ott 731da177e4SLinus Torvalds /* 741da177e4SLinus Torvalds * subchannel information block 751da177e4SLinus Torvalds */ 761da177e4SLinus Torvalds struct schib { 771da177e4SLinus Torvalds struct pmcw pmcw; /* path management control word */ 7823d805b6SPeter Oberparleiter union scsw scsw; /* subchannel status word */ 791da177e4SLinus Torvalds __u64 mba; /* measurement block address */ 801da177e4SLinus Torvalds __u8 mda[4]; /* model dependent area */ 811da177e4SLinus Torvalds } __attribute__ ((packed,aligned(4))); 821da177e4SLinus Torvalds 83817e5000SSebastian Ott /* 84817e5000SSebastian Ott * When rescheduled, todo's with higher values will overwrite those 85817e5000SSebastian Ott * with lower values. 86817e5000SSebastian Ott */ 87390935acSPeter Oberparleiter enum sch_todo { 88390935acSPeter Oberparleiter SCH_TODO_NOTHING, 89817e5000SSebastian Ott SCH_TODO_EVAL, 90390935acSPeter Oberparleiter SCH_TODO_UNREG, 91390935acSPeter Oberparleiter }; 92390935acSPeter Oberparleiter 931da177e4SLinus Torvalds /* subchannel data structure used by I/O subroutines */ 941da177e4SLinus Torvalds struct subchannel { 95a8237fc4SCornelia Huck struct subchannel_id schid; 962ec22984SCornelia Huck spinlock_t *lock; /* subchannel lock */ 976ab4879aSCornelia Huck struct mutex reg_mutex; 981da177e4SLinus Torvalds enum { 991da177e4SLinus Torvalds SUBCHANNEL_TYPE_IO = 0, 1001da177e4SLinus Torvalds SUBCHANNEL_TYPE_CHSC = 1, 101b279a4f5SCornelia Huck SUBCHANNEL_TYPE_MSG = 2, 1021da177e4SLinus Torvalds SUBCHANNEL_TYPE_ADM = 3, 1031da177e4SLinus Torvalds } st; /* subchannel type */ 1041da177e4SLinus Torvalds __u8 vpm; /* verified path mask */ 1051da177e4SLinus Torvalds __u8 lpm; /* logical path mask */ 1061da177e4SLinus Torvalds __u8 opm; /* operational path mask */ 1071da177e4SLinus Torvalds struct schib schib; /* subchannel information block */ 108edf22096SCornelia Huck int isc; /* desired interruption subclass */ 1097ad6a249SPeter Oberparleiter struct chsc_ssd_info ssd_info; /* subchannel description */ 1101da177e4SLinus Torvalds struct device dev; /* entry in device tree */ 1111da177e4SLinus Torvalds struct css_driver *driver; 112390935acSPeter Oberparleiter enum sch_todo todo; 113390935acSPeter Oberparleiter struct work_struct todo_work; 11413952ec1SSebastian Ott struct schib_config config; 1151da177e4SLinus Torvalds } __attribute__ ((aligned(8))); 1161da177e4SLinus Torvalds 11763aef00bSMartin Schwidefsky DECLARE_PER_CPU(struct irb, cio_irb); 11863aef00bSMartin Schwidefsky 1191da177e4SLinus Torvalds #define to_subchannel(n) container_of(n, struct subchannel, dev) 1201da177e4SLinus Torvalds 121a8237fc4SCornelia Huck extern int cio_validate_subchannel (struct subchannel *, struct subchannel_id); 122edf22096SCornelia Huck extern int cio_enable_subchannel(struct subchannel *, u32); 1231da177e4SLinus Torvalds extern int cio_disable_subchannel (struct subchannel *); 1241da177e4SLinus Torvalds extern int cio_cancel (struct subchannel *); 1251da177e4SLinus Torvalds extern int cio_clear (struct subchannel *); 126*5434da4dSDong Jia Shi extern int cio_cancel_halt_clear(struct subchannel *, int *); 1271da177e4SLinus Torvalds extern int cio_resume (struct subchannel *); 1281da177e4SLinus Torvalds extern int cio_halt (struct subchannel *); 1291da177e4SLinus Torvalds extern int cio_start (struct subchannel *, struct ccw1 *, __u8); 1301da177e4SLinus Torvalds extern int cio_start_key (struct subchannel *, struct ccw1 *, __u8, __u8); 1311da177e4SLinus Torvalds extern int cio_set_options (struct subchannel *, int); 132cdb912a4SSebastian Ott extern int cio_update_schib(struct subchannel *sch); 13313952ec1SSebastian Ott extern int cio_commit_config(struct subchannel *sch); 134a8237fc4SCornelia Huck 13583262d63SPeter Oberparleiter int cio_tm_start_key(struct subchannel *sch, struct tcw *tcw, u8 lpm, u8 key); 13683262d63SPeter Oberparleiter int cio_tm_intrg(struct subchannel *sch); 13783262d63SPeter Oberparleiter 1381da177e4SLinus Torvalds /* Use with care. */ 1391da177e4SLinus Torvalds #ifdef CONFIG_CCW_CONSOLE 1401da177e4SLinus Torvalds extern struct subchannel *cio_probe_console(void); 141a8237fc4SCornelia Huck extern int cio_is_console(struct subchannel_id); 14214556b33SSebastian Ott extern void cio_register_early_subchannels(void); 143188561a4SSebastian Ott extern void cio_tsch(struct subchannel *sch); 1441da177e4SLinus Torvalds #else 145a8237fc4SCornelia Huck #define cio_is_console(schid) 0 14614556b33SSebastian Ott static inline void cio_register_early_subchannels(void) {} 1471da177e4SLinus Torvalds #endif 1481da177e4SLinus Torvalds 1491da177e4SLinus Torvalds #endif 150