xref: /openbmc/linux/drivers/s390/cio/chsc.h (revision 8851b9f1)
1 #ifndef S390_CHSC_H
2 #define S390_CHSC_H
3 
4 #include <linux/types.h>
5 #include <linux/device.h>
6 #include <asm/css_chars.h>
7 #include <asm/chpid.h>
8 #include <asm/chsc.h>
9 #include <asm/schid.h>
10 #include <asm/qdio.h>
11 
12 #define CHSC_SDA_OC_MSS   0x2
13 
14 #define NR_MEASUREMENT_CHARS 5
15 struct cmg_chars {
16 	u32 values[NR_MEASUREMENT_CHARS];
17 } __attribute__ ((packed));
18 
19 #define NR_MEASUREMENT_ENTRIES 8
20 struct cmg_entry {
21 	u32 values[NR_MEASUREMENT_ENTRIES];
22 } __attribute__ ((packed));
23 
24 struct channel_path_desc {
25 	u8 flags;
26 	u8 lsn;
27 	u8 desc;
28 	u8 chpid;
29 	u8 swla;
30 	u8 zeroes;
31 	u8 chla;
32 	u8 chpp;
33 } __attribute__ ((packed));
34 
35 struct channel_path_desc_fmt1 {
36 	u8 flags;
37 	u8 lsn;
38 	u8 desc;
39 	u8 chpid;
40 	u32:24;
41 	u8 chpp;
42 	u32 unused[2];
43 	u16 chid;
44 	u32:16;
45 	u16 mdc;
46 	u16:13;
47 	u8 r:1;
48 	u8 s:1;
49 	u8 f:1;
50 	u32 zeros[2];
51 } __attribute__ ((packed));
52 
53 struct channel_path;
54 
55 struct css_chsc_char {
56 	u64 res;
57 	u64 : 20;
58 	u32 secm : 1; /* bit 84 */
59 	u32 : 1;
60 	u32 scmc : 1; /* bit 86 */
61 	u32 : 20;
62 	u32 scssc : 1;  /* bit 107 */
63 	u32 scsscf : 1; /* bit 108 */
64 	u32 : 19;
65 }__attribute__((packed));
66 
67 extern struct css_chsc_char css_chsc_characteristics;
68 
69 struct chsc_ssd_info {
70 	u8 path_mask;
71 	u8 fla_valid_mask;
72 	struct chp_id chpid[8];
73 	u16 fla[8];
74 };
75 
76 struct chsc_ssqd_area {
77 	struct chsc_header request;
78 	u16:10;
79 	u8 ssid:2;
80 	u8 fmt:4;
81 	u16 first_sch;
82 	u16:16;
83 	u16 last_sch;
84 	u32:32;
85 	struct chsc_header response;
86 	u32:32;
87 	struct qdio_ssqd_desc qdio_ssqd;
88 } __packed;
89 
90 struct chsc_scssc_area {
91 	struct chsc_header request;
92 	u16 operation_code;
93 	u16:16;
94 	u32:32;
95 	u32:32;
96 	u64 summary_indicator_addr;
97 	u64 subchannel_indicator_addr;
98 	u32 ks:4;
99 	u32 kc:4;
100 	u32:21;
101 	u32 isc:3;
102 	u32 word_with_d_bit;
103 	u32:32;
104 	struct subchannel_id schid;
105 	u32 reserved[1004];
106 	struct chsc_header response;
107 	u32:32;
108 } __packed;
109 
110 struct chsc_scpd {
111 	struct chsc_header request;
112 	u32:2;
113 	u32 m:1;
114 	u32 c:1;
115 	u32 fmt:4;
116 	u32 cssid:8;
117 	u32:4;
118 	u32 rfmt:4;
119 	u32 first_chpid:8;
120 	u32:24;
121 	u32 last_chpid:8;
122 	u32 zeroes1;
123 	struct chsc_header response;
124 	u8 data[PAGE_SIZE - 20];
125 } __attribute__ ((packed));
126 
127 
128 extern int chsc_get_ssd_info(struct subchannel_id schid,
129 			     struct chsc_ssd_info *ssd);
130 extern int chsc_determine_css_characteristics(void);
131 extern int chsc_init(void);
132 extern void chsc_init_cleanup(void);
133 
134 extern int chsc_enable_facility(int);
135 struct channel_subsystem;
136 extern int chsc_secm(struct channel_subsystem *, int);
137 int __chsc_do_secm(struct channel_subsystem *css, int enable);
138 
139 int chsc_chp_vary(struct chp_id chpid, int on);
140 int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
141 				     int c, int m, void *page);
142 int chsc_determine_base_channel_path_desc(struct chp_id chpid,
143 					  struct channel_path_desc *desc);
144 int chsc_determine_fmt1_channel_path_desc(struct chp_id chpid,
145 					  struct channel_path_desc_fmt1 *desc);
146 void chsc_chp_online(struct chp_id chpid);
147 void chsc_chp_offline(struct chp_id chpid);
148 int chsc_get_channel_measurement_chars(struct channel_path *chp);
149 int chsc_ssqd(struct subchannel_id schid, struct chsc_ssqd_area *ssqd);
150 int chsc_sadc(struct subchannel_id schid, struct chsc_scssc_area *scssc,
151 	      u64 summary_indicator_addr, u64 subchannel_indicator_addr);
152 int chsc_error_from_response(int response);
153 
154 int chsc_siosl(struct subchannel_id schid);
155 
156 /* Functions and definitions to query storage-class memory. */
157 struct sale {
158 	u64 sa;
159 	u32 p:4;
160 	u32 op_state:4;
161 	u32 data_state:4;
162 	u32 rank:4;
163 	u32 r:1;
164 	u32:7;
165 	u32 rid:8;
166 	u32:32;
167 } __packed;
168 
169 struct chsc_scm_info {
170 	struct chsc_header request;
171 	u32:32;
172 	u64 reqtok;
173 	u32 reserved1[4];
174 	struct chsc_header response;
175 	u64:56;
176 	u8 rq;
177 	u32 mbc;
178 	u64 msa;
179 	u16 is;
180 	u16 mmc;
181 	u32 mci;
182 	u64 nr_scm_ini;
183 	u64 nr_scm_unini;
184 	u32 reserved2[10];
185 	u64 restok;
186 	struct sale scmal[248];
187 } __packed;
188 
189 int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token);
190 
191 #ifdef CONFIG_SCM_BUS
192 int scm_update_information(void);
193 int scm_process_availability_information(void);
194 #else /* CONFIG_SCM_BUS */
195 static inline int scm_update_information(void) { return 0; }
196 static inline int scm_process_availability_information(void) { return 0; }
197 #endif /* CONFIG_SCM_BUS */
198 
199 
200 #endif
201