diag.h 5.9 KB

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