blob: 32fa7faa5bf69c8bd5b5de009d2f358f1dd7d687 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef S390_CHSC_H
3#define S390_CHSC_H
4
Peter Oberparleiterf86635f2007-04-27 16:01:26 +02005#include <linux/types.h>
6#include <linux/device.h>
Sebastian Ott382b7362012-08-28 16:43:36 +02007#include <asm/css_chars.h>
Peter Oberparleitere5854a52007-04-27 16:01:31 +02008#include <asm/chpid.h>
Cornelia Huck9d92a7e2008-07-14 09:59:05 +02009#include <asm/chsc.h>
10#include <asm/schid.h>
Sebastian Ottda5b6cb2013-06-05 18:58:35 +020011#include <asm/qdio.h>
Peter Oberparleiterf86635f2007-04-27 16:01:26 +020012
Cornelia Huckfb6958a2006-01-06 00:19:25 -080013#define CHSC_SDA_OC_MSS 0x2
14
Cornelia Huck495a5b42006-03-24 03:15:14 -080015#define NR_MEASUREMENT_CHARS 5
16struct cmg_chars {
17 u32 values[NR_MEASUREMENT_CHARS];
Sebastian Ottccaabee2018-06-25 14:25:59 +020018};
Cornelia Huck495a5b42006-03-24 03:15:14 -080019
20#define NR_MEASUREMENT_ENTRIES 8
21struct cmg_entry {
22 u32 values[NR_MEASUREMENT_ENTRIES];
Sebastian Ottccaabee2018-06-25 14:25:59 +020023};
Cornelia Huck495a5b42006-03-24 03:15:14 -080024
Sebastian Ottce322cc2011-01-05 12:47:56 +010025struct channel_path_desc_fmt1 {
26 u8 flags;
27 u8 lsn;
28 u8 desc;
29 u8 chpid;
Sebastian Ott8b8b09152020-10-08 15:13:27 +020030 u32:16;
31 u8 esc;
Sebastian Ottce322cc2011-01-05 12:47:56 +010032 u8 chpp;
Peter Oberparleiterba542292013-05-15 13:43:29 +020033 u32 unused[2];
34 u16 chid;
35 u32:16;
Sebastian Ottce322cc2011-01-05 12:47:56 +010036 u16 mdc;
37 u16:13;
38 u8 r:1;
39 u8 s:1;
40 u8 f:1;
41 u32 zeros[2];
Sebastian Ottccaabee2018-06-25 14:25:59 +020042};
Sebastian Ottce322cc2011-01-05 12:47:56 +010043
Sebastian Ottfcc6dd42016-06-22 19:42:40 +020044struct channel_path_desc_fmt3 {
45 struct channel_path_desc_fmt1 fmt1_desc;
46 u8 util_str[64];
47};
48
Peter Oberparleitere6b6e102007-04-27 16:01:28 +020049struct channel_path;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Linus Torvalds1da177e2005-04-16 15:20:36 -070051struct css_chsc_char {
52 u64 res;
Cornelia Huck495a5b42006-03-24 03:15:14 -080053 u64 : 20;
54 u32 secm : 1; /* bit 84 */
55 u32 : 1;
56 u32 scmc : 1; /* bit 86 */
57 u32 : 20;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 u32 scssc : 1; /* bit 107 */
59 u32 scsscf : 1; /* bit 108 */
Eugene Crosser1c59a862013-04-24 12:00:23 +020060 u32:7;
61 u32 pnso:1; /* bit 116 */
62 u32:11;
Sebastian Ottccaabee2018-06-25 14:25:59 +020063} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Linus Torvalds1da177e2005-04-16 15:20:36 -070065extern struct css_chsc_char css_chsc_characteristics;
66
Peter Oberparleiter7ad6a242007-04-27 16:01:35 +020067struct chsc_ssd_info {
68 u8 path_mask;
69 u8 fla_valid_mask;
70 struct chp_id chpid[8];
71 u16 fla[8];
72};
Sebastian Ott906c9762010-10-25 16:10:30 +020073
Sebastian Ottda5b6cb2013-06-05 18:58:35 +020074struct chsc_ssqd_area {
75 struct chsc_header request;
76 u16:10;
77 u8 ssid:2;
78 u8 fmt:4;
79 u16 first_sch;
80 u16:16;
81 u16 last_sch;
82 u32:32;
83 struct chsc_header response;
84 u32:32;
85 struct qdio_ssqd_desc qdio_ssqd;
Sebastian Ottccaabee2018-06-25 14:25:59 +020086} __packed __aligned(PAGE_SIZE);
Sebastian Ottda5b6cb2013-06-05 18:58:35 +020087
Sebastian Ottca4ba152013-06-05 18:59:22 +020088struct chsc_scssc_area {
89 struct chsc_header request;
90 u16 operation_code;
91 u16:16;
92 u32:32;
93 u32:32;
94 u64 summary_indicator_addr;
95 u64 subchannel_indicator_addr;
96 u32 ks:4;
97 u32 kc:4;
98 u32:21;
99 u32 isc:3;
100 u32 word_with_d_bit;
101 u32:32;
102 struct subchannel_id schid;
103 u32 reserved[1004];
104 struct chsc_header response;
105 u32:32;
Sebastian Ottccaabee2018-06-25 14:25:59 +0200106} __packed __aligned(PAGE_SIZE);
Sebastian Ottca4ba152013-06-05 18:59:22 +0200107
Sebastian Ott906c9762010-10-25 16:10:30 +0200108struct chsc_scpd {
109 struct chsc_header request;
110 u32:2;
111 u32 m:1;
112 u32 c:1;
113 u32 fmt:4;
114 u32 cssid:8;
115 u32:4;
116 u32 rfmt:4;
117 u32 first_chpid:8;
118 u32:24;
119 u32 last_chpid:8;
120 u32 zeroes1;
121 struct chsc_header response;
Sebastian Ott687cb7f2016-06-21 16:26:25 +0200122 u32:32;
123 u8 data[0];
Sebastian Ottccaabee2018-06-25 14:25:59 +0200124} __packed __aligned(PAGE_SIZE);
Sebastian Ott906c9762010-10-25 16:10:30 +0200125
Sebastian Ott18e22a12015-06-29 18:39:54 +0200126struct chsc_sda_area {
127 struct chsc_header request;
128 u8 :4;
129 u8 format:4;
130 u8 :8;
131 u16 operation_code;
132 u32 :32;
133 u32 :32;
134 u32 operation_data_area[252];
135 struct chsc_header response;
136 u32 :4;
137 u32 format2:4;
138 u32 :24;
139} __packed __aligned(PAGE_SIZE);
Sebastian Ott906c9762010-10-25 16:10:30 +0200140
Peter Oberparleiter7ad6a242007-04-27 16:01:35 +0200141extern int chsc_get_ssd_info(struct subchannel_id schid,
142 struct chsc_ssd_info *ssd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143extern int chsc_determine_css_characteristics(void);
Sebastian Ott34aec072010-10-25 16:10:28 +0200144extern int chsc_init(void);
145extern void chsc_init_cleanup(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Sebastian Ott18e22a12015-06-29 18:39:54 +0200147int __chsc_enable_facility(struct chsc_sda_area *sda_area, int operation_code);
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800148extern int chsc_enable_facility(int);
Cornelia Huck495a5b42006-03-24 03:15:14 -0800149struct channel_subsystem;
150extern int chsc_secm(struct channel_subsystem *, int);
Sebastian Ott34196f82010-10-25 16:10:29 +0200151int __chsc_do_secm(struct channel_subsystem *css, int enable);
Cornelia Huckfb6958a2006-01-06 00:19:25 -0800152
Peter Oberparleitere6b6e102007-04-27 16:01:28 +0200153int chsc_chp_vary(struct chp_id chpid, int on);
Cornelia Huck9d92a7e2008-07-14 09:59:05 +0200154int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt,
Sebastian Ott906c9762010-10-25 16:10:30 +0200155 int c, int m, void *page);
Sebastian Ottded27d82017-06-29 13:27:22 +0200156int chsc_determine_fmt0_channel_path_desc(struct chp_id chpid,
157 struct channel_path_desc_fmt0 *desc);
Sebastian Ottce322cc2011-01-05 12:47:56 +0100158int chsc_determine_fmt1_channel_path_desc(struct chp_id chpid,
159 struct channel_path_desc_fmt1 *desc);
Sebastian Ottfcc6dd42016-06-22 19:42:40 +0200160int chsc_determine_fmt3_channel_path_desc(struct chp_id chpid,
161 struct channel_path_desc_fmt3 *desc);
Peter Oberparleiter83b33702007-04-27 16:01:34 +0200162void chsc_chp_online(struct chp_id chpid);
Peter Oberparleitere6b6e102007-04-27 16:01:28 +0200163void chsc_chp_offline(struct chp_id chpid);
164int chsc_get_channel_measurement_chars(struct channel_path *chp);
Sebastian Ottda5b6cb2013-06-05 18:58:35 +0200165int chsc_ssqd(struct subchannel_id schid, struct chsc_ssqd_area *ssqd);
Sebastian Ottca4ba152013-06-05 18:59:22 +0200166int chsc_sadc(struct subchannel_id schid, struct chsc_scssc_area *scssc,
Julian Wiedmann92892242020-03-16 09:20:38 +0100167 u64 summary_indicator_addr, u64 subchannel_indicator_addr,
168 u8 isc);
Michael Mueller3dec1922019-01-31 09:52:39 +0100169int chsc_sgib(u32 origin);
Cornelia Huckdae39842008-07-17 17:16:47 +0200170int chsc_error_from_response(int response);
171
Michael Ernstfd0457a2010-08-09 18:12:50 +0200172int chsc_siosl(struct subchannel_id schid);
173
Sebastian Ott184b08a2012-08-28 16:45:42 +0200174/* Functions and definitions to query storage-class memory. */
175struct sale {
176 u64 sa;
177 u32 p:4;
178 u32 op_state:4;
179 u32 data_state:4;
180 u32 rank:4;
181 u32 r:1;
182 u32:7;
183 u32 rid:8;
184 u32:32;
185} __packed;
186
187struct chsc_scm_info {
188 struct chsc_header request;
189 u32:32;
190 u64 reqtok;
191 u32 reserved1[4];
192 struct chsc_header response;
193 u64:56;
194 u8 rq;
195 u32 mbc;
196 u64 msa;
197 u16 is;
198 u16 mmc;
199 u32 mci;
200 u64 nr_scm_ini;
201 u64 nr_scm_unini;
202 u32 reserved2[10];
203 u64 restok;
204 struct sale scmal[248];
Sebastian Ottccaabee2018-06-25 14:25:59 +0200205} __packed __aligned(PAGE_SIZE);
Sebastian Ott184b08a2012-08-28 16:45:42 +0200206
207int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token);
208
Alexandra Winter4fea49a2020-09-10 19:23:44 +0200209int chsc_pnso(struct subchannel_id schid, struct chsc_pnso_area *pnso_area,
210 u8 oc, struct chsc_pnso_resume_token resume_token, int cnc);
Eugene Crosser1c59a862013-04-24 12:00:23 +0200211
Alexandra Winterb983aa12020-09-10 19:23:45 +0200212int __init chsc_get_cssid_iid(int idx, u8 *cssid, u8 *iid);
Sebastian Otte2e0de92016-06-17 19:45:23 +0200213
Sebastian Ott40ff4cc2012-08-28 16:47:02 +0200214#ifdef CONFIG_SCM_BUS
215int scm_update_information(void);
Sebastian Ottaebfa662013-02-28 12:07:55 +0100216int scm_process_availability_information(void);
Sebastian Ott40ff4cc2012-08-28 16:47:02 +0200217#else /* CONFIG_SCM_BUS */
Sebastian Ott58fece72013-01-28 19:34:26 +0100218static inline int scm_update_information(void) { return 0; }
Sebastian Ottaebfa662013-02-28 12:07:55 +0100219static inline int scm_process_availability_information(void) { return 0; }
Sebastian Ott40ff4cc2012-08-28 16:47:02 +0200220#endif /* CONFIG_SCM_BUS */
221
222
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223#endif