xref: /openbmc/linux/arch/s390/include/asm/diag.h (revision 8730046c)
1 /*
2  * s390 diagnose functions
3  *
4  * Copyright IBM Corp. 2007
5  * Author(s): Michael Holzheu <holzheu@de.ibm.com>
6  */
7 
8 #ifndef _ASM_S390_DIAG_H
9 #define _ASM_S390_DIAG_H
10 
11 #include <linux/percpu.h>
12 
13 enum diag_stat_enum {
14 	DIAG_STAT_X008,
15 	DIAG_STAT_X00C,
16 	DIAG_STAT_X010,
17 	DIAG_STAT_X014,
18 	DIAG_STAT_X044,
19 	DIAG_STAT_X064,
20 	DIAG_STAT_X09C,
21 	DIAG_STAT_X0DC,
22 	DIAG_STAT_X204,
23 	DIAG_STAT_X210,
24 	DIAG_STAT_X224,
25 	DIAG_STAT_X250,
26 	DIAG_STAT_X258,
27 	DIAG_STAT_X288,
28 	DIAG_STAT_X2C4,
29 	DIAG_STAT_X2FC,
30 	DIAG_STAT_X304,
31 	DIAG_STAT_X308,
32 	DIAG_STAT_X500,
33 	NR_DIAG_STAT
34 };
35 
36 void diag_stat_inc(enum diag_stat_enum nr);
37 void diag_stat_inc_norecursion(enum diag_stat_enum nr);
38 
39 /*
40  * Diagnose 10: Release page range
41  */
42 static inline void diag10_range(unsigned long start_pfn, unsigned long num_pfn)
43 {
44 	unsigned long start_addr, end_addr;
45 
46 	start_addr = start_pfn << PAGE_SHIFT;
47 	end_addr = (start_pfn + num_pfn - 1) << PAGE_SHIFT;
48 
49 	diag_stat_inc(DIAG_STAT_X010);
50 	asm volatile(
51 		"0:	diag	%0,%1,0x10\n"
52 		"1:	nopr	%%r7\n"
53 		EX_TABLE(0b, 1b)
54 		EX_TABLE(1b, 1b)
55 		: : "a" (start_addr), "a" (end_addr));
56 }
57 
58 /*
59  * Diagnose 14: Input spool file manipulation
60  */
61 extern int diag14(unsigned long rx, unsigned long ry1, unsigned long subcode);
62 
63 /*
64  * Diagnose 210: Get information about a virtual device
65  */
66 struct diag210 {
67 	u16 vrdcdvno;	/* device number (input) */
68 	u16 vrdclen;	/* data block length (input) */
69 	u8 vrdcvcla;	/* virtual device class (output) */
70 	u8 vrdcvtyp;	/* virtual device type (output) */
71 	u8 vrdcvsta;	/* virtual device status (output) */
72 	u8 vrdcvfla;	/* virtual device flags (output) */
73 	u8 vrdcrccl;	/* real device class (output) */
74 	u8 vrdccrty;	/* real device type (output) */
75 	u8 vrdccrmd;	/* real device model (output) */
76 	u8 vrdccrft;	/* real device feature (output) */
77 } __attribute__((packed, aligned(4)));
78 
79 extern int diag210(struct diag210 *addr);
80 
81 /* bit is set in flags, when physical cpu info is included in diag 204 data */
82 #define DIAG204_LPAR_PHYS_FLG 0x80
83 #define DIAG204_LPAR_NAME_LEN 8		/* lpar name len in diag 204 data */
84 #define DIAG204_CPU_NAME_LEN 16		/* type name len of cpus in diag224 name table */
85 
86 /* diag 204 subcodes */
87 enum diag204_sc {
88 	DIAG204_SUBC_STIB4 = 4,
89 	DIAG204_SUBC_RSI = 5,
90 	DIAG204_SUBC_STIB6 = 6,
91 	DIAG204_SUBC_STIB7 = 7
92 };
93 
94 /* The two available diag 204 data formats */
95 enum diag204_format {
96 	DIAG204_INFO_SIMPLE = 0,
97 	DIAG204_INFO_EXT = 0x00010000
98 };
99 
100 enum diag204_cpu_flags {
101 	DIAG204_CPU_ONLINE = 0x20,
102 	DIAG204_CPU_CAPPED = 0x40,
103 };
104 
105 struct diag204_info_blk_hdr {
106 	__u8  npar;
107 	__u8  flags;
108 	__u16 tslice;
109 	__u16 phys_cpus;
110 	__u16 this_part;
111 	__u64 curtod;
112 } __packed;
113 
114 struct diag204_x_info_blk_hdr {
115 	__u8  npar;
116 	__u8  flags;
117 	__u16 tslice;
118 	__u16 phys_cpus;
119 	__u16 this_part;
120 	__u64 curtod1;
121 	__u64 curtod2;
122 	char reserved[40];
123 } __packed;
124 
125 struct diag204_part_hdr {
126 	__u8 pn;
127 	__u8 cpus;
128 	char reserved[6];
129 	char part_name[DIAG204_LPAR_NAME_LEN];
130 } __packed;
131 
132 struct diag204_x_part_hdr {
133 	__u8  pn;
134 	__u8  cpus;
135 	__u8  rcpus;
136 	__u8  pflag;
137 	__u32 mlu;
138 	char  part_name[DIAG204_LPAR_NAME_LEN];
139 	char  lpc_name[8];
140 	char  os_name[8];
141 	__u64 online_cs;
142 	__u64 online_es;
143 	__u8  upid;
144 	__u8  reserved:3;
145 	__u8  mtid:5;
146 	char  reserved1[2];
147 	__u32 group_mlu;
148 	char  group_name[8];
149 	char  hardware_group_name[8];
150 	char  reserved2[24];
151 } __packed;
152 
153 struct diag204_cpu_info {
154 	__u16 cpu_addr;
155 	char  reserved1[2];
156 	__u8  ctidx;
157 	__u8  cflag;
158 	__u16 weight;
159 	__u64 acc_time;
160 	__u64 lp_time;
161 } __packed;
162 
163 struct diag204_x_cpu_info {
164 	__u16 cpu_addr;
165 	char  reserved1[2];
166 	__u8  ctidx;
167 	__u8  cflag;
168 	__u16 weight;
169 	__u64 acc_time;
170 	__u64 lp_time;
171 	__u16 min_weight;
172 	__u16 cur_weight;
173 	__u16 max_weight;
174 	char  reseved2[2];
175 	__u64 online_time;
176 	__u64 wait_time;
177 	__u32 pma_weight;
178 	__u32 polar_weight;
179 	__u32 cpu_type_cap;
180 	__u32 group_cpu_type_cap;
181 	char  reserved3[32];
182 } __packed;
183 
184 struct diag204_phys_hdr {
185 	char reserved1[1];
186 	__u8 cpus;
187 	char reserved2[6];
188 	char mgm_name[8];
189 } __packed;
190 
191 struct diag204_x_phys_hdr {
192 	char reserved1[1];
193 	__u8 cpus;
194 	char reserved2[6];
195 	char mgm_name[8];
196 	char reserved3[80];
197 } __packed;
198 
199 struct diag204_phys_cpu {
200 	__u16 cpu_addr;
201 	char  reserved1[2];
202 	__u8  ctidx;
203 	char  reserved2[3];
204 	__u64 mgm_time;
205 	char  reserved3[8];
206 } __packed;
207 
208 struct diag204_x_phys_cpu {
209 	__u16 cpu_addr;
210 	char  reserved1[2];
211 	__u8  ctidx;
212 	char  reserved2[1];
213 	__u16 weight;
214 	__u64 mgm_time;
215 	char  reserved3[80];
216 } __packed;
217 
218 struct diag204_x_part_block {
219 	struct diag204_x_part_hdr hdr;
220 	struct diag204_x_cpu_info cpus[];
221 } __packed;
222 
223 struct diag204_x_phys_block {
224 	struct diag204_x_phys_hdr hdr;
225 	struct diag204_x_phys_cpu cpus[];
226 } __packed;
227 
228 int diag204(unsigned long subcode, unsigned long size, void *addr);
229 int diag224(void *ptr);
230 #endif /* _ASM_S390_DIAG_H */
231