1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef S390_CIO_H
3 #define S390_CIO_H
4
5 #include <linux/mutex.h>
6 #include <linux/device.h>
7 #include <linux/mod_devicetable.h>
8 #include <asm/chpid.h>
9 #include <asm/cio.h>
10 #include <asm/dma-types.h>
11 #include <asm/fcx.h>
12 #include <asm/schid.h>
13 #include <asm/tpi.h>
14 #include "chsc.h"
15
16 /*
17 * path management control word
18 */
19 struct pmcw {
20 u32 intparm; /* interruption parameter */
21 u32 qf : 1; /* qdio facility */
22 u32 w : 1;
23 u32 isc : 3; /* interruption subclass */
24 u32 res5 : 3; /* reserved zeros */
25 u32 ena : 1; /* enabled */
26 u32 lm : 2; /* limit mode */
27 u32 mme : 2; /* measurement-mode enable */
28 u32 mp : 1; /* multipath mode */
29 u32 tf : 1; /* timing facility */
30 u32 dnv : 1; /* device number valid */
31 u32 dev : 16; /* device number */
32 u8 lpm; /* logical path mask */
33 u8 pnom; /* path not operational mask */
34 u8 lpum; /* last path used mask */
35 u8 pim; /* path installed mask */
36 u16 mbi; /* measurement-block index */
37 u8 pom; /* path operational mask */
38 u8 pam; /* path available mask */
39 u8 chpid[8]; /* CHPID 0-7 (if available) */
40 u32 unused1 : 8; /* reserved zeros */
41 u32 st : 3; /* subchannel type */
42 u32 unused2 : 18; /* reserved zeros */
43 u32 mbfc : 1; /* measurement block format control */
44 u32 xmwme : 1; /* extended measurement word mode enable */
45 u32 csense : 1; /* concurrent sense; can be enabled ...*/
46 /* ... per MSCH, however, if facility */
47 /* ... is not installed, this results */
48 /* ... in an operand exception. */
49 } __attribute__ ((packed));
50
51 /* Target SCHIB configuration. */
52 struct schib_config {
53 dma64_t mba;
54 u32 intparm;
55 u16 mbi;
56 u32 isc:3;
57 u32 ena:1;
58 u32 mme:2;
59 u32 mp:1;
60 u32 csense:1;
61 u32 mbfc:1;
62 } __attribute__ ((packed));
63
64 /*
65 * subchannel information block
66 */
67 struct schib {
68 struct pmcw pmcw; /* path management control word */
69 union scsw scsw; /* subchannel status word */
70 dma64_t mba; /* measurement block address */
71 __u8 mda[4]; /* model dependent area */
72 } __attribute__ ((packed,aligned(4)));
73
74 /*
75 * When rescheduled, todo's with higher values will overwrite those
76 * with lower values.
77 */
78 enum sch_todo {
79 SCH_TODO_NOTHING,
80 SCH_TODO_EVAL,
81 SCH_TODO_UNREG,
82 };
83
84 /* subchannel data structure used by I/O subroutines */
85 struct subchannel {
86 struct subchannel_id schid;
87 spinlock_t lock; /* subchannel lock */
88 struct mutex reg_mutex;
89 enum {
90 SUBCHANNEL_TYPE_IO = 0,
91 SUBCHANNEL_TYPE_CHSC = 1,
92 SUBCHANNEL_TYPE_MSG = 2,
93 SUBCHANNEL_TYPE_ADM = 3,
94 } st; /* subchannel type */
95 __u8 vpm; /* verified path mask */
96 __u8 lpm; /* logical path mask */
97 __u8 opm; /* operational path mask */
98 struct schib schib; /* subchannel information block */
99 int isc; /* desired interruption subclass */
100 struct chsc_ssd_info ssd_info; /* subchannel description */
101 struct device dev; /* entry in device tree */
102 struct css_driver *driver;
103 enum sch_todo todo;
104 struct work_struct todo_work;
105 struct schib_config config;
106 u64 dma_mask;
107 } __attribute__ ((aligned(8)));
108
109 DECLARE_PER_CPU_ALIGNED(struct irb, cio_irb);
110
111 #define to_subchannel(n) container_of(n, struct subchannel, dev)
112
113 extern int cio_enable_subchannel(struct subchannel *, u32);
114 extern int cio_disable_subchannel (struct subchannel *);
115 extern int cio_cancel (struct subchannel *);
116 extern int cio_clear (struct subchannel *);
117 extern int cio_cancel_halt_clear(struct subchannel *, int *);
118 extern int cio_resume (struct subchannel *);
119 extern int cio_halt (struct subchannel *);
120 extern int cio_start (struct subchannel *, struct ccw1 *, __u8);
121 extern int cio_start_key (struct subchannel *, struct ccw1 *, __u8, __u8);
122 extern int cio_set_options (struct subchannel *, int);
123 extern int cio_update_schib(struct subchannel *sch);
124 extern int cio_commit_config(struct subchannel *sch);
125
126 int cio_tm_start_key(struct subchannel *sch, struct tcw *tcw, u8 lpm, u8 key);
127 int cio_tm_intrg(struct subchannel *sch);
128
129 extern int __init airq_init(void);
130
131 /* Use with care. */
132 #ifdef CONFIG_CCW_CONSOLE
133 extern struct subchannel *cio_probe_console(void);
134 extern int cio_is_console(struct subchannel_id);
135 extern void cio_register_early_subchannels(void);
136 extern void cio_tsch(struct subchannel *sch);
137 #else
138 #define cio_is_console(schid) 0
cio_register_early_subchannels(void)139 static inline void cio_register_early_subchannels(void) {}
140 #endif
141
142 #endif
143