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