xref: /openbmc/linux/drivers/s390/cio/chsc.h (revision 2c684d89)
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_fmt1 {
25 	u8 flags;
26 	u8 lsn;
27 	u8 desc;
28 	u8 chpid;
29 	u32:24;
30 	u8 chpp;
31 	u32 unused[2];
32 	u16 chid;
33 	u32:16;
34 	u16 mdc;
35 	u16:13;
36 	u8 r:1;
37 	u8 s:1;
38 	u8 f:1;
39 	u32 zeros[2];
40 } __attribute__ ((packed));
41 
42 struct channel_path;
43 
44 struct css_chsc_char {
45 	u64 res;
46 	u64 : 20;
47 	u32 secm : 1; /* bit 84 */
48 	u32 : 1;
49 	u32 scmc : 1; /* bit 86 */
50 	u32 : 20;
51 	u32 scssc : 1;  /* bit 107 */
52 	u32 scsscf : 1; /* bit 108 */
53 	u32:7;
54 	u32 pnso:1; /* bit 116 */
55 	u32:11;
56 }__attribute__((packed));
57 
58 extern struct css_chsc_char css_chsc_characteristics;
59 
60 struct chsc_ssd_info {
61 	u8 path_mask;
62 	u8 fla_valid_mask;
63 	struct chp_id chpid[8];
64 	u16 fla[8];
65 };
66 
67 struct chsc_ssqd_area {
68 	struct chsc_header request;
69 	u16:10;
70 	u8 ssid:2;
71 	u8 fmt:4;
72 	u16 first_sch;
73 	u16:16;
74 	u16 last_sch;
75 	u32:32;
76 	struct chsc_header response;
77 	u32:32;
78 	struct qdio_ssqd_desc qdio_ssqd;
79 } __packed;
80 
81 struct chsc_scssc_area {
82 	struct chsc_header request;
83 	u16 operation_code;
84 	u16:16;
85 	u32:32;
86 	u32:32;
87 	u64 summary_indicator_addr;
88 	u64 subchannel_indicator_addr;
89 	u32 ks:4;
90 	u32 kc:4;
91 	u32:21;
92 	u32 isc:3;
93 	u32 word_with_d_bit;
94 	u32:32;
95 	struct subchannel_id schid;
96 	u32 reserved[1004];
97 	struct chsc_header response;
98 	u32:32;
99 } __packed;
100 
101 struct chsc_scpd {
102 	struct chsc_header request;
103 	u32:2;
104 	u32 m:1;
105 	u32 c:1;
106 	u32 fmt:4;
107 	u32 cssid:8;
108 	u32:4;
109 	u32 rfmt:4;
110 	u32 first_chpid:8;
111 	u32:24;
112 	u32 last_chpid:8;
113 	u32 zeroes1;
114 	struct chsc_header response;
115 	u8 data[PAGE_SIZE - 20];
116 } __attribute__ ((packed));
117 
118 struct chsc_sda_area {
119 	struct chsc_header request;
120 	u8 :4;
121 	u8 format:4;
122 	u8 :8;
123 	u16 operation_code;
124 	u32 :32;
125 	u32 :32;
126 	u32 operation_data_area[252];
127 	struct chsc_header response;
128 	u32 :4;
129 	u32 format2:4;
130 	u32 :24;
131 } __packed __aligned(PAGE_SIZE);
132 
133 extern int chsc_get_ssd_info(struct subchannel_id schid,
134 			     struct chsc_ssd_info *ssd);
135 extern int chsc_determine_css_characteristics(void);
136 extern int chsc_init(void);
137 extern void chsc_init_cleanup(void);
138 
139 int __chsc_enable_facility(struct chsc_sda_area *sda_area, int operation_code);
140 extern int chsc_enable_facility(int);
141 struct channel_subsystem;
142 extern int chsc_secm(struct channel_subsystem *, int);
143 int __chsc_do_secm(struct channel_subsystem *css, int enable);
144 
145 int chsc_chp_vary(struct chp_id chpid, int on);
146 int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
147 				     int c, int m, void *page);
148 int chsc_determine_base_channel_path_desc(struct chp_id chpid,
149 					  struct channel_path_desc *desc);
150 int chsc_determine_fmt1_channel_path_desc(struct chp_id chpid,
151 					  struct channel_path_desc_fmt1 *desc);
152 void chsc_chp_online(struct chp_id chpid);
153 void chsc_chp_offline(struct chp_id chpid);
154 int chsc_get_channel_measurement_chars(struct channel_path *chp);
155 int chsc_ssqd(struct subchannel_id schid, struct chsc_ssqd_area *ssqd);
156 int chsc_sadc(struct subchannel_id schid, struct chsc_scssc_area *scssc,
157 	      u64 summary_indicator_addr, u64 subchannel_indicator_addr);
158 int chsc_error_from_response(int response);
159 
160 int chsc_siosl(struct subchannel_id schid);
161 
162 /* Functions and definitions to query storage-class memory. */
163 struct sale {
164 	u64 sa;
165 	u32 p:4;
166 	u32 op_state:4;
167 	u32 data_state:4;
168 	u32 rank:4;
169 	u32 r:1;
170 	u32:7;
171 	u32 rid:8;
172 	u32:32;
173 } __packed;
174 
175 struct chsc_scm_info {
176 	struct chsc_header request;
177 	u32:32;
178 	u64 reqtok;
179 	u32 reserved1[4];
180 	struct chsc_header response;
181 	u64:56;
182 	u8 rq;
183 	u32 mbc;
184 	u64 msa;
185 	u16 is;
186 	u16 mmc;
187 	u32 mci;
188 	u64 nr_scm_ini;
189 	u64 nr_scm_unini;
190 	u32 reserved2[10];
191 	u64 restok;
192 	struct sale scmal[248];
193 } __packed;
194 
195 int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token);
196 
197 struct chsc_brinfo_resume_token {
198 	u64 t1;
199 	u64 t2;
200 } __packed;
201 
202 struct chsc_brinfo_naihdr {
203 	struct chsc_brinfo_resume_token resume_token;
204 	u32:32;
205 	u32 instance;
206 	u32:24;
207 	u8 naids;
208 	u32 reserved[3];
209 } __packed;
210 
211 struct chsc_pnso_area {
212 	struct chsc_header request;
213 	u8:2;
214 	u8 m:1;
215 	u8:5;
216 	u8:2;
217 	u8 ssid:2;
218 	u8 fmt:4;
219 	u16 sch;
220 	u8:8;
221 	u8 cssid;
222 	u16:16;
223 	u8 oc;
224 	u32:24;
225 	struct chsc_brinfo_resume_token resume_token;
226 	u32 n:1;
227 	u32:31;
228 	u32 reserved[3];
229 	struct chsc_header response;
230 	u32:32;
231 	struct chsc_brinfo_naihdr naihdr;
232 	union {
233 		struct qdio_brinfo_entry_l3_ipv6 l3_ipv6[0];
234 		struct qdio_brinfo_entry_l3_ipv4 l3_ipv4[0];
235 		struct qdio_brinfo_entry_l2	 l2[0];
236 	} entries;
237 } __packed;
238 
239 int chsc_pnso_brinfo(struct subchannel_id schid,
240 		struct chsc_pnso_area *brinfo_area,
241 		struct chsc_brinfo_resume_token resume_token,
242 		int cnc);
243 
244 #ifdef CONFIG_SCM_BUS
245 int scm_update_information(void);
246 int scm_process_availability_information(void);
247 #else /* CONFIG_SCM_BUS */
248 static inline int scm_update_information(void) { return 0; }
249 static inline int scm_process_availability_information(void) { return 0; }
250 #endif /* CONFIG_SCM_BUS */
251 
252 
253 #endif
254