coredump.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef _COREDUMP_H_
  17. #define _COREDUMP_H_
  18. #include "core.h"
  19. #define ATH10K_FW_CRASH_DUMP_VERSION 1
  20. /**
  21. * enum ath10k_fw_crash_dump_type - types of data in the dump file
  22. * @ATH10K_FW_CRASH_DUMP_REGDUMP: Register crash dump in binary format
  23. */
  24. enum ath10k_fw_crash_dump_type {
  25. ATH10K_FW_CRASH_DUMP_REGISTERS = 0,
  26. ATH10K_FW_CRASH_DUMP_CE_DATA = 1,
  27. /* contains multiple struct ath10k_dump_ram_data_hdr */
  28. ATH10K_FW_CRASH_DUMP_RAM_DATA = 2,
  29. ATH10K_FW_CRASH_DUMP_MAX,
  30. };
  31. struct ath10k_tlv_dump_data {
  32. /* see ath10k_fw_crash_dump_type above */
  33. __le32 type;
  34. /* in bytes */
  35. __le32 tlv_len;
  36. /* pad to 32-bit boundaries as needed */
  37. u8 tlv_data[];
  38. } __packed;
  39. struct ath10k_dump_file_data {
  40. /* dump file information */
  41. /* "ATH10K-FW-DUMP" */
  42. char df_magic[16];
  43. __le32 len;
  44. /* file dump version */
  45. __le32 version;
  46. /* some info we can get from ath10k struct that might help */
  47. guid_t guid;
  48. __le32 chip_id;
  49. /* 0 for now, in place for later hardware */
  50. __le32 bus_type;
  51. __le32 target_version;
  52. __le32 fw_version_major;
  53. __le32 fw_version_minor;
  54. __le32 fw_version_release;
  55. __le32 fw_version_build;
  56. __le32 phy_capability;
  57. __le32 hw_min_tx_power;
  58. __le32 hw_max_tx_power;
  59. __le32 ht_cap_info;
  60. __le32 vht_cap_info;
  61. __le32 num_rf_chains;
  62. /* firmware version string */
  63. char fw_ver[ETHTOOL_FWVERS_LEN];
  64. /* Kernel related information */
  65. /* time-of-day stamp */
  66. __le64 tv_sec;
  67. /* time-of-day stamp, nano-seconds */
  68. __le64 tv_nsec;
  69. /* LINUX_VERSION_CODE */
  70. __le32 kernel_ver_code;
  71. /* VERMAGIC_STRING */
  72. char kernel_ver[64];
  73. /* room for growth w/out changing binary format */
  74. u8 unused[128];
  75. /* struct ath10k_tlv_dump_data + more */
  76. u8 data[0];
  77. } __packed;
  78. struct ath10k_dump_ram_data_hdr {
  79. /* enum ath10k_mem_region_type */
  80. __le32 region_type;
  81. __le32 start;
  82. /* length of payload data, not including this header */
  83. __le32 length;
  84. u8 data[0];
  85. };
  86. /* magic number to fill the holes not copied due to sections in regions */
  87. #define ATH10K_MAGIC_NOT_COPIED 0xAA
  88. /* part of user space ABI */
  89. enum ath10k_mem_region_type {
  90. ATH10K_MEM_REGION_TYPE_REG = 1,
  91. ATH10K_MEM_REGION_TYPE_DRAM = 2,
  92. ATH10K_MEM_REGION_TYPE_AXI = 3,
  93. ATH10K_MEM_REGION_TYPE_IRAM1 = 4,
  94. ATH10K_MEM_REGION_TYPE_IRAM2 = 5,
  95. ATH10K_MEM_REGION_TYPE_IOSRAM = 6,
  96. ATH10K_MEM_REGION_TYPE_IOREG = 7,
  97. };
  98. /* Define a section of the region which should be copied. As not all parts
  99. * of the memory is possible to copy, for example some of the registers can
  100. * be like that, sections can be used to define what is safe to copy.
  101. *
  102. * To minimize the size of the array, the list must obey the format:
  103. * '{start0,stop0},{start1,stop1},{start2,stop2}....' The values below must
  104. * also obey to 'start0 < stop0 < start1 < stop1 < start2 < ...', otherwise
  105. * we may encouter error in the dump processing.
  106. */
  107. struct ath10k_mem_section {
  108. u32 start;
  109. u32 end;
  110. };
  111. /* One region of a memory layout. If the sections field is null entire
  112. * region is copied. If sections is non-null only the areas specified in
  113. * sections are copied and rest of the areas are filled with
  114. * ATH10K_MAGIC_NOT_COPIED.
  115. */
  116. struct ath10k_mem_region {
  117. enum ath10k_mem_region_type type;
  118. u32 start;
  119. u32 len;
  120. const char *name;
  121. struct {
  122. const struct ath10k_mem_section *sections;
  123. u32 size;
  124. } section_table;
  125. };
  126. /* Contains the memory layout of a hardware version identified with the
  127. * hardware id, split into regions.
  128. */
  129. struct ath10k_hw_mem_layout {
  130. u32 hw_id;
  131. struct {
  132. const struct ath10k_mem_region *regions;
  133. int size;
  134. } region_table;
  135. };
  136. /* FIXME: where to put this? */
  137. extern unsigned long ath10k_coredump_mask;
  138. #ifdef CONFIG_DEV_COREDUMP
  139. int ath10k_coredump_submit(struct ath10k *ar);
  140. struct ath10k_fw_crash_data *ath10k_coredump_new(struct ath10k *ar);
  141. int ath10k_coredump_create(struct ath10k *ar);
  142. int ath10k_coredump_register(struct ath10k *ar);
  143. void ath10k_coredump_unregister(struct ath10k *ar);
  144. void ath10k_coredump_destroy(struct ath10k *ar);
  145. const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout(struct ath10k *ar);
  146. #else /* CONFIG_DEV_COREDUMP */
  147. static inline int ath10k_coredump_submit(struct ath10k *ar)
  148. {
  149. return 0;
  150. }
  151. static inline struct ath10k_fw_crash_data *ath10k_coredump_new(struct ath10k *ar)
  152. {
  153. return NULL;
  154. }
  155. static inline int ath10k_coredump_create(struct ath10k *ar)
  156. {
  157. return 0;
  158. }
  159. static inline int ath10k_coredump_register(struct ath10k *ar)
  160. {
  161. return 0;
  162. }
  163. static inline void ath10k_coredump_unregister(struct ath10k *ar)
  164. {
  165. }
  166. static inline void ath10k_coredump_destroy(struct ath10k *ar)
  167. {
  168. }
  169. static inline const struct ath10k_hw_mem_layout *
  170. ath10k_coredump_get_mem_layout(struct ath10k *ar)
  171. {
  172. return NULL;
  173. }
  174. #endif /* CONFIG_DEV_COREDUMP */
  175. #endif /* _COREDUMP_H_ */