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:16; 31 u8 esc; 32 u8 chpp; 33 u32 unused[2]; 34 u16 chid; 35 u32:16; 36 u16 mdc; 37 u16:13; 38 u8 r:1; 39 u8 s:1; 40 u8 f:1; 41 u32 zeros[2]; 42 }; 43 44 struct channel_path_desc_fmt3 { 45 struct channel_path_desc_fmt1 fmt1_desc; 46 u8 util_str[64]; 47 }; 48 49 struct channel_path; 50 51 struct css_chsc_char { 52 u64 res; 53 u64 : 20; 54 u32 secm : 1; /* bit 84 */ 55 u32 : 1; 56 u32 scmc : 1; /* bit 86 */ 57 u32 : 20; 58 u32 scssc : 1; /* bit 107 */ 59 u32 scsscf : 1; /* bit 108 */ 60 u32:7; 61 u32 pnso:1; /* bit 116 */ 62 u32:11; 63 } __packed; 64 65 extern struct css_chsc_char css_chsc_characteristics; 66 67 struct chsc_ssd_info { 68 u8 path_mask; 69 u8 fla_valid_mask; 70 struct chp_id chpid[8]; 71 u16 fla[8]; 72 }; 73 74 struct 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; 86 } __packed __aligned(PAGE_SIZE); 87 88 struct 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; 106 } __packed __aligned(PAGE_SIZE); 107 108 struct 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; 122 u32:32; 123 u8 data[0]; 124 } __packed __aligned(PAGE_SIZE); 125 126 struct 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); 140 141 extern int chsc_get_ssd_info(struct subchannel_id schid, 142 struct chsc_ssd_info *ssd); 143 extern int chsc_determine_css_characteristics(void); 144 extern int chsc_init(void); 145 extern void chsc_init_cleanup(void); 146 147 int __chsc_enable_facility(struct chsc_sda_area *sda_area, int operation_code); 148 extern int chsc_enable_facility(int); 149 struct channel_subsystem; 150 extern int chsc_secm(struct channel_subsystem *, int); 151 int __chsc_do_secm(struct channel_subsystem *css, int enable); 152 153 int chsc_chp_vary(struct chp_id chpid, int on); 154 int chsc_determine_channel_path_desc(struct chp_id chpid, int fmt, int rfmt, 155 int c, int m, void *page); 156 int chsc_determine_fmt0_channel_path_desc(struct chp_id chpid, 157 struct channel_path_desc_fmt0 *desc); 158 int chsc_determine_fmt1_channel_path_desc(struct chp_id chpid, 159 struct channel_path_desc_fmt1 *desc); 160 int chsc_determine_fmt3_channel_path_desc(struct chp_id chpid, 161 struct channel_path_desc_fmt3 *desc); 162 void chsc_chp_online(struct chp_id chpid); 163 void chsc_chp_offline(struct chp_id chpid); 164 int chsc_get_channel_measurement_chars(struct channel_path *chp); 165 int chsc_ssqd(struct subchannel_id schid, struct chsc_ssqd_area *ssqd); 166 int chsc_sadc(struct subchannel_id schid, struct chsc_scssc_area *scssc, 167 u64 summary_indicator_addr, u64 subchannel_indicator_addr, 168 u8 isc); 169 int chsc_sgib(u32 origin); 170 int chsc_error_from_response(int response); 171 172 int chsc_siosl(struct subchannel_id schid); 173 174 /* Functions and definitions to query storage-class memory. */ 175 struct 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 187 struct 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]; 205 } __packed __aligned(PAGE_SIZE); 206 207 int chsc_scm_info(struct chsc_scm_info *scm_area, u64 token); 208 209 int chsc_pnso(struct subchannel_id schid, struct chsc_pnso_area *pnso_area, 210 u8 oc, struct chsc_pnso_resume_token resume_token, int cnc); 211 212 int __init chsc_get_cssid_iid(int idx, u8 *cssid, u8 *iid); 213 214 #ifdef CONFIG_SCM_BUS 215 int scm_update_information(void); 216 int scm_process_availability_information(void); 217 #else /* CONFIG_SCM_BUS */ 218 static inline int scm_update_information(void) { return 0; } 219 static inline int scm_process_availability_information(void) { return 0; } 220 #endif /* CONFIG_SCM_BUS */ 221 222 223 #endif 224