Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ISC */
0002 /*
0003  * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
0004  */
0005 
0006 #ifndef _COREDUMP_H_
0007 #define _COREDUMP_H_
0008 
0009 #include "core.h"
0010 
0011 #define ATH10K_FW_CRASH_DUMP_VERSION 1
0012 
0013 /**
0014  * enum ath10k_fw_crash_dump_type - types of data in the dump file
0015  * @ATH10K_FW_CRASH_DUMP_REGDUMP: Register crash dump in binary format
0016  */
0017 enum ath10k_fw_crash_dump_type {
0018     ATH10K_FW_CRASH_DUMP_REGISTERS = 0,
0019     ATH10K_FW_CRASH_DUMP_CE_DATA = 1,
0020 
0021     /* contains multiple struct ath10k_dump_ram_data_hdr */
0022     ATH10K_FW_CRASH_DUMP_RAM_DATA = 2,
0023 
0024     ATH10K_FW_CRASH_DUMP_MAX,
0025 };
0026 
0027 struct ath10k_tlv_dump_data {
0028     /* see ath10k_fw_crash_dump_type above */
0029     __le32 type;
0030 
0031     /* in bytes */
0032     __le32 tlv_len;
0033 
0034     /* pad to 32-bit boundaries as needed */
0035     u8 tlv_data[];
0036 } __packed;
0037 
0038 struct ath10k_dump_file_data {
0039     /* dump file information */
0040 
0041     /* "ATH10K-FW-DUMP" */
0042     char df_magic[16];
0043 
0044     __le32 len;
0045 
0046     /* file dump version */
0047     __le32 version;
0048 
0049     /* some info we can get from ath10k struct that might help */
0050 
0051     guid_t guid;
0052 
0053     __le32 chip_id;
0054 
0055     /* 0 for now, in place for later hardware */
0056     __le32 bus_type;
0057 
0058     __le32 target_version;
0059     __le32 fw_version_major;
0060     __le32 fw_version_minor;
0061     __le32 fw_version_release;
0062     __le32 fw_version_build;
0063     __le32 phy_capability;
0064     __le32 hw_min_tx_power;
0065     __le32 hw_max_tx_power;
0066     __le32 ht_cap_info;
0067     __le32 vht_cap_info;
0068     __le32 num_rf_chains;
0069 
0070     /* firmware version string */
0071     char fw_ver[ETHTOOL_FWVERS_LEN];
0072 
0073     /* Kernel related information */
0074 
0075     /* time-of-day stamp */
0076     __le64 tv_sec;
0077 
0078     /* time-of-day stamp, nano-seconds */
0079     __le64 tv_nsec;
0080 
0081     /* LINUX_VERSION_CODE */
0082     __le32 kernel_ver_code;
0083 
0084     /* VERMAGIC_STRING */
0085     char kernel_ver[64];
0086 
0087     /* room for growth w/out changing binary format */
0088     u8 unused[128];
0089 
0090     /* struct ath10k_tlv_dump_data + more */
0091     u8 data[];
0092 } __packed;
0093 
0094 struct ath10k_dump_ram_data_hdr {
0095     /* enum ath10k_mem_region_type */
0096     __le32 region_type;
0097 
0098     __le32 start;
0099 
0100     /* length of payload data, not including this header */
0101     __le32 length;
0102 
0103     u8 data[];
0104 };
0105 
0106 /* magic number to fill the holes not copied due to sections in regions */
0107 #define ATH10K_MAGIC_NOT_COPIED     0xAA
0108 
0109 /* part of user space ABI */
0110 enum ath10k_mem_region_type {
0111     ATH10K_MEM_REGION_TYPE_REG  = 1,
0112     ATH10K_MEM_REGION_TYPE_DRAM = 2,
0113     ATH10K_MEM_REGION_TYPE_AXI  = 3,
0114     ATH10K_MEM_REGION_TYPE_IRAM1    = 4,
0115     ATH10K_MEM_REGION_TYPE_IRAM2    = 5,
0116     ATH10K_MEM_REGION_TYPE_IOSRAM   = 6,
0117     ATH10K_MEM_REGION_TYPE_IOREG    = 7,
0118     ATH10K_MEM_REGION_TYPE_MSA  = 8,
0119 };
0120 
0121 /* Define a section of the region which should be copied. As not all parts
0122  * of the memory is possible to copy, for example some of the registers can
0123  * be like that, sections can be used to define what is safe to copy.
0124  *
0125  * To minimize the size of the array, the list must obey the format:
0126  * '{start0,stop0},{start1,stop1},{start2,stop2}....' The values below must
0127  * also obey to 'start0 < stop0 < start1 < stop1 < start2 < ...', otherwise
0128  * we may encouter error in the dump processing.
0129  */
0130 struct ath10k_mem_section {
0131     u32 start;
0132     u32 end;
0133 };
0134 
0135 /* One region of a memory layout. If the sections field is null entire
0136  * region is copied. If sections is non-null only the areas specified in
0137  * sections are copied and rest of the areas are filled with
0138  * ATH10K_MAGIC_NOT_COPIED.
0139  */
0140 struct ath10k_mem_region {
0141     enum ath10k_mem_region_type type;
0142     u32 start;
0143     u32 len;
0144 
0145     const char *name;
0146 
0147     struct {
0148         const struct ath10k_mem_section *sections;
0149         u32 size;
0150     } section_table;
0151 };
0152 
0153 /* Contains the memory layout of a hardware version identified with the
0154  * hardware id, split into regions.
0155  */
0156 struct ath10k_hw_mem_layout {
0157     u32 hw_id;
0158     u32 hw_rev;
0159     enum ath10k_bus bus;
0160 
0161     struct {
0162         const struct ath10k_mem_region *regions;
0163         int size;
0164     } region_table;
0165 };
0166 
0167 /* FIXME: where to put this? */
0168 extern unsigned long ath10k_coredump_mask;
0169 
0170 #ifdef CONFIG_DEV_COREDUMP
0171 
0172 int ath10k_coredump_submit(struct ath10k *ar);
0173 struct ath10k_fw_crash_data *ath10k_coredump_new(struct ath10k *ar);
0174 int ath10k_coredump_create(struct ath10k *ar);
0175 int ath10k_coredump_register(struct ath10k *ar);
0176 void ath10k_coredump_unregister(struct ath10k *ar);
0177 void ath10k_coredump_destroy(struct ath10k *ar);
0178 
0179 const struct ath10k_hw_mem_layout *_ath10k_coredump_get_mem_layout(struct ath10k *ar);
0180 const struct ath10k_hw_mem_layout *ath10k_coredump_get_mem_layout(struct ath10k *ar);
0181 
0182 #else /* CONFIG_DEV_COREDUMP */
0183 
0184 static inline int ath10k_coredump_submit(struct ath10k *ar)
0185 {
0186     return 0;
0187 }
0188 
0189 static inline struct ath10k_fw_crash_data *ath10k_coredump_new(struct ath10k *ar)
0190 {
0191     return NULL;
0192 }
0193 
0194 static inline int ath10k_coredump_create(struct ath10k *ar)
0195 {
0196     return 0;
0197 }
0198 
0199 static inline int ath10k_coredump_register(struct ath10k *ar)
0200 {
0201     return 0;
0202 }
0203 
0204 static inline void ath10k_coredump_unregister(struct ath10k *ar)
0205 {
0206 }
0207 
0208 static inline void ath10k_coredump_destroy(struct ath10k *ar)
0209 {
0210 }
0211 
0212 static inline const struct ath10k_hw_mem_layout *
0213 ath10k_coredump_get_mem_layout(struct ath10k *ar)
0214 {
0215     return NULL;
0216 }
0217 
0218 static inline const struct ath10k_hw_mem_layout *
0219 _ath10k_coredump_get_mem_layout(struct ath10k *ar)
0220 {
0221     return NULL;
0222 }
0223 
0224 #endif /* CONFIG_DEV_COREDUMP */
0225 
0226 #endif /* _COREDUMP_H_ */