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