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