1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright (C) 2017 Intel Deutschland GmbH
4 * Copyright (C) 2018-2020 Intel Corporation
6 #ifndef __iwl_fw_runtime_h__
7 #define __iwl_fw_runtime_h__
9 #include "iwl-config.h"
10 #include "iwl-trans.h"
12 #include "fw/api/debug.h"
13 #include "fw/api/paging.h"
14 #include "fw/api/power.h"
15 #include "iwl-eeprom-parse.h"
18 struct iwl_fw_runtime_ops
{
19 int (*dump_start
)(void *ctx
);
20 void (*dump_end
)(void *ctx
);
21 bool (*fw_running
)(void *ctx
);
22 int (*send_hcmd
)(void *ctx
, struct iwl_host_cmd
*host_cmd
);
23 bool (*d3_debug_enable
)(void *ctx
);
26 #define MAX_NUM_LMAC 2
27 struct iwl_fwrt_shared_mem_cfg
{
29 int num_txfifo_entries
;
31 u32 txfifo_size
[TX_FIFO_MAX_NUM
];
35 u32 rxfifo2_control_size
;
36 u32 internal_txfifo_addr
;
37 u32 internal_txfifo_size
[TX_FIFO_INTERNAL_MAX_NUM
];
40 #define IWL_FW_RUNTIME_DUMP_WK_NUM 5
43 * struct iwl_fwrt_dump_data - dump data
44 * @trig: trigger the worker was scheduled upon
45 * @fw_pkt: packet received from FW
47 struct iwl_fwrt_dump_data
{
50 struct iwl_fw_ini_trigger_tlv
*trig
;
51 struct iwl_rx_packet
*fw_pkt
;
54 const struct iwl_fw_dump_desc
*desc
;
61 * struct iwl_fwrt_wk_data - dump worker data struct
62 * @idx: index of the worker
65 struct iwl_fwrt_wk_data
{
67 struct delayed_work wk
;
68 struct iwl_fwrt_dump_data dump_data
;
72 * struct iwl_txf_iter_data - Tx fifo iterator data struct
75 * @fifo_size: fifo size
76 * @internal_txf: non zero if fifo is internal Tx fifo
78 struct iwl_txf_iter_data
{
86 * struct iwl_fw_runtime - runtime data for firmware
88 * @cfg: NIC configuration
89 * @dev: device pointer
91 * @ops_ctx: user ops context
92 * @fw_paging_db: paging database
93 * @num_of_paging_blk: number of paging blocks
94 * @num_of_pages_in_last_blk: number of pages in the last block
95 * @smem_cfg: saved firmware SMEM configuration
96 * @cur_fw_img: current firmware image, must be maintained by
97 * the driver by calling &iwl_fw_set_current_image()
98 * @dump: debug dump data
100 struct iwl_fw_runtime
{
101 struct iwl_trans
*trans
;
102 const struct iwl_fw
*fw
;
105 const struct iwl_fw_runtime_ops
*ops
;
109 struct iwl_fw_paging fw_paging_db
[NUM_OF_FW_PAGING_BLOCKS
];
110 u16 num_of_paging_blk
;
111 u16 num_of_pages_in_last_blk
;
113 enum iwl_ucode_type cur_fw_img
;
115 /* memory configuration */
116 struct iwl_fwrt_shared_mem_cfg smem_cfg
;
120 struct iwl_fwrt_wk_data wks
[IWL_FW_RUNTIME_DUMP_WK_NUM
];
121 unsigned long active_wks
;
125 /* ts of the beginning of a non-collect fw dbg data period */
126 unsigned long non_collect_ts_start
[IWL_FW_INI_TIME_POINT_NUM
];
128 u32 lmac_err_id
[MAX_NUM_LMAC
];
131 struct iwl_txf_iter_data txf_iter_data
;
142 #ifdef CONFIG_IWLWIFI_DEBUGFS
144 struct delayed_work wk
;
149 #endif /* CONFIG_IWLWIFI_DEBUGFS */
151 struct iwl_sar_profile sar_profiles
[ACPI_SAR_PROFILE_NUM
];
152 u8 sar_chain_a_profile
;
153 u8 sar_chain_b_profile
;
154 struct iwl_geo_profile geo_profiles
[ACPI_NUM_GEO_PROFILES
];
156 union iwl_ppag_table_cmd ppag_table
;
161 void iwl_fw_runtime_init(struct iwl_fw_runtime
*fwrt
, struct iwl_trans
*trans
,
162 const struct iwl_fw
*fw
,
163 const struct iwl_fw_runtime_ops
*ops
, void *ops_ctx
,
164 struct dentry
*dbgfs_dir
);
166 static inline void iwl_fw_runtime_free(struct iwl_fw_runtime
*fwrt
)
170 kfree(fwrt
->dump
.d3_debug_data
);
171 fwrt
->dump
.d3_debug_data
= NULL
;
173 iwl_dbg_tlv_del_timers(fwrt
->trans
);
174 for (i
= 0; i
< IWL_FW_RUNTIME_DUMP_WK_NUM
; i
++)
175 cancel_delayed_work_sync(&fwrt
->dump
.wks
[i
].wk
);
178 void iwl_fw_runtime_suspend(struct iwl_fw_runtime
*fwrt
);
180 void iwl_fw_runtime_resume(struct iwl_fw_runtime
*fwrt
);
182 static inline void iwl_fw_set_current_image(struct iwl_fw_runtime
*fwrt
,
183 enum iwl_ucode_type cur_fw_img
)
185 fwrt
->cur_fw_img
= cur_fw_img
;
188 int iwl_init_paging(struct iwl_fw_runtime
*fwrt
, enum iwl_ucode_type type
);
189 void iwl_free_fw_paging(struct iwl_fw_runtime
*fwrt
);
191 void iwl_get_shared_mem_conf(struct iwl_fw_runtime
*fwrt
);
192 int iwl_set_soc_latency(struct iwl_fw_runtime
*fwrt
);
194 #endif /* __iwl_fw_runtime_h__ */