1 /* SPDX-License-Identifier: GPL-2.0 */
3 * s390 diagnose functions
5 * Copyright IBM Corp. 2007
9 #ifndef _ASM_S390_DIAG_H
10 #define _ASM_S390_DIAG_H
12 #include <linux/if_ether.h>
13 #include <linux/percpu.h>
14 #include <asm/asm-extable.h>
46 void diag_stat_inc(enum diag_stat_enum nr);
47 void diag_stat_inc_norecursion(enum diag_stat_enum nr);
49 struct hypfs_diag0c_entry;
52 * Diagnose 0c: Pseudo Timer
54 void diag0c(struct hypfs_diag0c_entry *data);
57 * Diagnose 10: Release page range
59 static inline void diag10_range(unsigned long start_pfn, unsigned long num_pfn)
61 unsigned long start_addr, end_addr;
63 start_addr = pfn_to_phys(start_pfn);
64 end_addr = pfn_to_phys(start_pfn + num_pfn - 1);
66 diag_stat_inc(DIAG_STAT_X010);
68 "0: diag %0,%1,0x10\n"
72 : : "a" (start_addr), "a" (end_addr));
76 * Diagnose 14: Input spool file manipulation
78 extern int diag14(unsigned long rx, unsigned long ry1, unsigned long subcode);
81 * Diagnose 210: Get information about a virtual device
84 u16 vrdcdvno; /* device number (input) */
85 u16 vrdclen; /* data block length (input) */
86 u8 vrdcvcla; /* virtual device class (output) */
87 u8 vrdcvtyp; /* virtual device type (output) */
88 u8 vrdcvsta; /* virtual device status (output) */
89 u8 vrdcvfla; /* virtual device flags (output) */
90 u8 vrdcrccl; /* real device class (output) */
91 u8 vrdccrty; /* real device type (output) */
92 u8 vrdccrmd; /* real device model (output) */
93 u8 vrdccrft; /* real device feature (output) */
94 } __packed __aligned(4);
96 extern int diag210(struct diag210 *addr);
104 } __packed __aligned(4);
106 extern int diag8c(struct diag8c *out, struct ccw_dev_id *devno);
108 /* bit is set in flags, when physical cpu info is included in diag 204 data */
109 #define DIAG204_LPAR_PHYS_FLG 0x80
110 #define DIAG204_LPAR_NAME_LEN 8 /* lpar name len in diag 204 data */
111 #define DIAG204_CPU_NAME_LEN 16 /* type name len of cpus in diag224 name table */
113 /* diag 204 subcodes */
115 DIAG204_SUBC_STIB4 = 4,
116 DIAG204_SUBC_RSI = 5,
117 DIAG204_SUBC_STIB6 = 6,
118 DIAG204_SUBC_STIB7 = 7
121 #define DIAG204_SUBCODE_MASK 0xffff
122 #define DIAG204_BIF_BIT 0x80000000
123 #define DIAG204_BUSY_WAIT (HZ / 10)
125 /* The two available diag 204 data formats */
126 enum diag204_format {
127 DIAG204_INFO_SIMPLE = 0,
128 DIAG204_INFO_EXT = 0x00010000
131 enum diag204_cpu_flags {
132 DIAG204_CPU_ONLINE = 0x20,
133 DIAG204_CPU_CAPPED = 0x40,
136 struct diag204_info_blk_hdr {
145 struct diag204_x_info_blk_hdr {
156 struct diag204_part_hdr {
160 char part_name[DIAG204_LPAR_NAME_LEN];
163 struct diag204_x_part_hdr {
169 char part_name[DIAG204_LPAR_NAME_LEN];
180 char hardware_group_name[8];
184 struct diag204_cpu_info {
194 struct diag204_x_cpu_info {
211 __u32 group_cpu_type_cap;
215 struct diag204_phys_hdr {
222 struct diag204_x_phys_hdr {
230 struct diag204_phys_cpu {
239 struct diag204_x_phys_cpu {
249 struct diag204_x_part_block {
250 struct diag204_x_part_hdr hdr;
251 struct diag204_x_cpu_info cpus[];
254 struct diag204_x_phys_block {
255 struct diag204_x_phys_hdr hdr;
256 struct diag204_x_phys_cpu cpus[];
260 DIAG26C_PORT_VNIC = 0x00000024,
261 DIAG26C_MAC_SERVICES = 0x00000030
264 enum diag26c_version {
265 DIAG26C_VERSION2 = 0x00000002, /* z/VM 5.4.0 */
266 DIAG26C_VERSION6_VM65918 = 0x00020006 /* z/VM 6.4.0 + VM65918 */
269 #define DIAG26C_VNIC_INFO 0x0002
270 struct diag26c_vnic_req {
278 } __packed __aligned(8);
280 #define VNIC_INFO_PROT_L3 1
281 #define VNIC_INFO_PROT_L2 2
282 /* Note: this is the bare minimum, use it for uninitialized VNICs only. */
283 struct diag26c_vnic_resp {
303 /* 3x device info: */
307 } __packed __aligned(8);
309 #define DIAG26C_GET_MAC 0x0000
310 struct diag26c_mac_req {
318 struct diag26c_mac_resp {
324 #define CPNC_LINUX 0x4
328 unsigned long cpnc : 8;
329 unsigned long cpvc : 56;
333 static inline bool diag204_has_bif(void)
335 return sclp.has_diag204_bif;
338 int diag204(unsigned long subcode, unsigned long size, void *addr);
339 int diag224(void *ptr);
340 int diag26c(void *req, void *resp, enum diag26c_sc subcode);
342 struct hypfs_diag0c_entry;
345 * This structure must contain only pointers/references into
346 * the AMODE31 text section.
349 int (*diag210)(struct diag210 *addr);
350 int (*diag26c)(unsigned long rx, unsigned long rx1, enum diag26c_sc subcode);
351 int (*diag14)(unsigned long rx, unsigned long ry1, unsigned long subcode);
352 int (*diag8c)(struct diag8c *addr, struct ccw_dev_id *devno, size_t len);
353 void (*diag0c)(unsigned long rx);
354 void (*diag308_reset)(void);
357 extern struct diag_ops diag_amode31_ops;
358 extern struct diag210 *__diag210_tmp_amode31;
360 int _diag210_amode31(struct diag210 *addr);
361 int _diag26c_amode31(unsigned long rx, unsigned long rx1, enum diag26c_sc subcode);
362 int _diag14_amode31(unsigned long rx, unsigned long ry1, unsigned long subcode);
363 void _diag0c_amode31(unsigned long rx);
364 void _diag308_reset_amode31(void);
365 int _diag8c_amode31(struct diag8c *addr, struct ccw_dev_id *devno, size_t len);
367 /* diag 49c subcodes */
369 DIAG49C_SUBC_ACK = 0,
373 int diag49c(unsigned long subcode);
375 #endif /* _ASM_S390_DIAG_H */