0001
0002
0003
0004
0005
0006 #ifndef __iwl_fw_runtime_h__
0007 #define __iwl_fw_runtime_h__
0008
0009 #include "iwl-config.h"
0010 #include "iwl-trans.h"
0011 #include "img.h"
0012 #include "fw/api/debug.h"
0013 #include "fw/api/paging.h"
0014 #include "fw/api/power.h"
0015 #include "iwl-eeprom-parse.h"
0016 #include "fw/acpi.h"
0017
0018 struct iwl_fw_runtime_ops {
0019 void (*dump_start)(void *ctx);
0020 void (*dump_end)(void *ctx);
0021 bool (*fw_running)(void *ctx);
0022 int (*send_hcmd)(void *ctx, struct iwl_host_cmd *host_cmd);
0023 bool (*d3_debug_enable)(void *ctx);
0024 };
0025
0026 #define MAX_NUM_LMAC 2
0027 struct iwl_fwrt_shared_mem_cfg {
0028 int num_lmacs;
0029 int num_txfifo_entries;
0030 struct {
0031 u32 txfifo_size[TX_FIFO_MAX_NUM];
0032 u32 rxfifo1_size;
0033 } lmac[MAX_NUM_LMAC];
0034 u32 rxfifo2_size;
0035 u32 rxfifo2_control_size;
0036 u32 internal_txfifo_addr;
0037 u32 internal_txfifo_size[TX_FIFO_INTERNAL_MAX_NUM];
0038 };
0039
0040 #define IWL_FW_RUNTIME_DUMP_WK_NUM 5
0041
0042
0043
0044
0045
0046
0047 struct iwl_fwrt_dump_data {
0048 union {
0049 struct {
0050 struct iwl_fw_ini_trigger_tlv *trig;
0051 struct iwl_rx_packet *fw_pkt;
0052 };
0053 struct {
0054 const struct iwl_fw_dump_desc *desc;
0055 bool monitor_only;
0056 };
0057 };
0058 };
0059
0060
0061
0062
0063
0064
0065 struct iwl_fwrt_wk_data {
0066 u8 idx;
0067 struct delayed_work wk;
0068 struct iwl_fwrt_dump_data dump_data;
0069 };
0070
0071
0072
0073
0074
0075
0076
0077
0078 struct iwl_txf_iter_data {
0079 int fifo;
0080 int lmac;
0081 u32 fifo_size;
0082 u8 internal_txf;
0083 };
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 struct iwl_fw_runtime {
0101 struct iwl_trans *trans;
0102 const struct iwl_fw *fw;
0103 struct device *dev;
0104
0105 const struct iwl_fw_runtime_ops *ops;
0106 void *ops_ctx;
0107
0108 const struct iwl_dump_sanitize_ops *sanitize_ops;
0109 void *sanitize_ctx;
0110
0111
0112 struct iwl_fw_paging fw_paging_db[NUM_OF_FW_PAGING_BLOCKS];
0113 u16 num_of_paging_blk;
0114 u16 num_of_pages_in_last_blk;
0115
0116 enum iwl_ucode_type cur_fw_img;
0117
0118
0119 struct iwl_fwrt_shared_mem_cfg smem_cfg;
0120
0121
0122 struct {
0123 struct iwl_fwrt_wk_data wks[IWL_FW_RUNTIME_DUMP_WK_NUM];
0124 unsigned long active_wks;
0125
0126 u8 conf;
0127
0128
0129 unsigned long non_collect_ts_start[IWL_FW_INI_TIME_POINT_NUM];
0130 u32 *d3_debug_data;
0131 u32 lmac_err_id[MAX_NUM_LMAC];
0132 u32 umac_err_id;
0133
0134 struct iwl_txf_iter_data txf_iter_data;
0135
0136 struct {
0137 u8 type;
0138 u8 subtype;
0139 u32 lmac_major;
0140 u32 lmac_minor;
0141 u32 umac_major;
0142 u32 umac_minor;
0143 } fw_ver;
0144 } dump;
0145 #ifdef CONFIG_IWLWIFI_DEBUGFS
0146 struct {
0147 struct delayed_work wk;
0148 u32 delay;
0149 u64 seq;
0150 } timestamp;
0151 bool tpc_enabled;
0152 #endif
0153 #ifdef CONFIG_ACPI
0154 struct iwl_sar_profile sar_profiles[ACPI_SAR_PROFILE_NUM];
0155 u8 sar_chain_a_profile;
0156 u8 sar_chain_b_profile;
0157 struct iwl_geo_profile geo_profiles[ACPI_NUM_GEO_PROFILES_REV3];
0158 u32 geo_rev;
0159 u32 geo_num_profiles;
0160 bool geo_enabled;
0161 struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS];
0162 u32 ppag_flags;
0163 u32 ppag_ver;
0164 struct iwl_sar_offset_mapping_cmd sgom_table;
0165 bool sgom_enabled;
0166 u8 reduced_power_flags;
0167 #endif
0168 };
0169
0170 void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans,
0171 const struct iwl_fw *fw,
0172 const struct iwl_fw_runtime_ops *ops, void *ops_ctx,
0173 const struct iwl_dump_sanitize_ops *sanitize_ops,
0174 void *sanitize_ctx,
0175 struct dentry *dbgfs_dir);
0176
0177 static inline void iwl_fw_runtime_free(struct iwl_fw_runtime *fwrt)
0178 {
0179 int i;
0180
0181 kfree(fwrt->dump.d3_debug_data);
0182 fwrt->dump.d3_debug_data = NULL;
0183
0184 iwl_dbg_tlv_del_timers(fwrt->trans);
0185 for (i = 0; i < IWL_FW_RUNTIME_DUMP_WK_NUM; i++)
0186 cancel_delayed_work_sync(&fwrt->dump.wks[i].wk);
0187 }
0188
0189 void iwl_fw_runtime_suspend(struct iwl_fw_runtime *fwrt);
0190
0191 void iwl_fw_runtime_resume(struct iwl_fw_runtime *fwrt);
0192
0193 static inline void iwl_fw_set_current_image(struct iwl_fw_runtime *fwrt,
0194 enum iwl_ucode_type cur_fw_img)
0195 {
0196 fwrt->cur_fw_img = cur_fw_img;
0197 }
0198
0199 int iwl_init_paging(struct iwl_fw_runtime *fwrt, enum iwl_ucode_type type);
0200 void iwl_free_fw_paging(struct iwl_fw_runtime *fwrt);
0201
0202 void iwl_get_shared_mem_conf(struct iwl_fw_runtime *fwrt);
0203 int iwl_set_soc_latency(struct iwl_fw_runtime *fwrt);
0204 int iwl_configure_rxq(struct iwl_fw_runtime *fwrt);
0205
0206 #endif