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