18e99ea8dSJohannes Berg /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
28e99ea8dSJohannes Berg /*
3568db7fdSJohannes Berg * Copyright (C) 2005-2014, 2018-2019, 2021-2023 Intel Corporation
48e99ea8dSJohannes Berg * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
58e99ea8dSJohannes Berg * Copyright (C) 2015-2017 Intel Deutschland GmbH
68e99ea8dSJohannes Berg */
77174beb6SJohannes Berg #ifndef __iwl_fw_dbg_h__
87174beb6SJohannes Berg #define __iwl_fw_dbg_h__
97174beb6SJohannes Berg #include <linux/workqueue.h>
107174beb6SJohannes Berg #include <net/cfg80211.h>
117174beb6SJohannes Berg #include "runtime.h"
121efc3843SGolan Ben Ami #include "iwl-prph.h"
131efc3843SGolan Ben Ami #include "iwl-io.h"
147174beb6SJohannes Berg #include "file.h"
157174beb6SJohannes Berg #include "error-dump.h"
165cfe79c8SSara Sharon #include "api/commands.h"
17d47902f9SSara Sharon #include "api/dbg-tlv.h"
180a3a3e9eSShahar S Matityahu #include "api/alive.h"
197174beb6SJohannes Berg
207174beb6SJohannes Berg /**
217174beb6SJohannes Berg * struct iwl_fw_dump_desc - describes the dump
227174beb6SJohannes Berg * @len: length of trig_desc->data
237174beb6SJohannes Berg * @trig_desc: the description of the dump
247174beb6SJohannes Berg */
257174beb6SJohannes Berg struct iwl_fw_dump_desc {
267174beb6SJohannes Berg size_t len;
277174beb6SJohannes Berg /* must be last */
287174beb6SJohannes Berg struct iwl_fw_error_dump_trigger_desc trig_desc;
297174beb6SJohannes Berg };
307174beb6SJohannes Berg
31d25eec30SSara Sharon /**
32d25eec30SSara Sharon * struct iwl_fw_dbg_params - register values to restore
33d25eec30SSara Sharon * @in_sample: DBGC_IN_SAMPLE value
34d25eec30SSara Sharon * @out_ctrl: DBGC_OUT_CTRL value
35d25eec30SSara Sharon */
36d25eec30SSara Sharon struct iwl_fw_dbg_params {
37d25eec30SSara Sharon u32 in_sample;
38d25eec30SSara Sharon u32 out_ctrl;
39d25eec30SSara Sharon };
40d25eec30SSara Sharon
417174beb6SJohannes Berg extern const struct iwl_fw_dump_desc iwl_dump_desc_assert;
427174beb6SJohannes Berg
437174beb6SJohannes Berg int iwl_fw_dbg_collect_desc(struct iwl_fw_runtime *fwrt,
447174beb6SJohannes Berg const struct iwl_fw_dump_desc *desc,
45124e0ebaSSara Sharon bool monitor_only, unsigned int delay);
46700b3799SShahar S Matityahu int iwl_fw_dbg_error_collect(struct iwl_fw_runtime *fwrt,
47700b3799SShahar S Matityahu enum iwl_fw_dbg_trigger trig_type);
483b589d56SShahar S Matityahu int iwl_fw_dbg_ini_collect(struct iwl_fw_runtime *fwrt,
49b8221b0fSJohannes Berg struct iwl_fwrt_dump_data *dump_data,
50b8221b0fSJohannes Berg bool sync);
51fe1b7d6cSSara Sharon int iwl_fw_dbg_collect(struct iwl_fw_runtime *fwrt,
524b49e34eSShahar S Matityahu enum iwl_fw_dbg_trigger trig, const char *str,
534b49e34eSShahar S Matityahu size_t len, struct iwl_fw_dbg_trigger_tlv *trigger);
547174beb6SJohannes Berg int iwl_fw_dbg_collect_trig(struct iwl_fw_runtime *fwrt,
557174beb6SJohannes Berg struct iwl_fw_dbg_trigger_tlv *trigger,
567174beb6SJohannes Berg const char *fmt, ...) __printf(3, 4);
577174beb6SJohannes Berg int iwl_fw_start_dbg_conf(struct iwl_fw_runtime *fwrt, u8 id);
587174beb6SJohannes Berg
597174beb6SJohannes Berg #define iwl_fw_dbg_trigger_enabled(fw, id) ({ \
6017b809c9SSara Sharon void *__dbg_trigger = (fw)->dbg.trigger_tlv[(id)]; \
617174beb6SJohannes Berg unlikely(__dbg_trigger); \
627174beb6SJohannes Berg })
637174beb6SJohannes Berg
647174beb6SJohannes Berg static inline struct iwl_fw_dbg_trigger_tlv*
_iwl_fw_dbg_get_trigger(const struct iwl_fw * fw,enum iwl_fw_dbg_trigger id)657174beb6SJohannes Berg _iwl_fw_dbg_get_trigger(const struct iwl_fw *fw, enum iwl_fw_dbg_trigger id)
667174beb6SJohannes Berg {
6717b809c9SSara Sharon return fw->dbg.trigger_tlv[id];
687174beb6SJohannes Berg }
697174beb6SJohannes Berg
707174beb6SJohannes Berg #define iwl_fw_dbg_get_trigger(fw, id) ({ \
717174beb6SJohannes Berg BUILD_BUG_ON(!__builtin_constant_p(id)); \
727174beb6SJohannes Berg BUILD_BUG_ON((id) >= FW_DBG_TRIGGER_MAX); \
737174beb6SJohannes Berg _iwl_fw_dbg_get_trigger((fw), (id)); \
747174beb6SJohannes Berg })
757174beb6SJohannes Berg
767174beb6SJohannes Berg static inline bool
iwl_fw_dbg_trigger_vif_match(struct iwl_fw_dbg_trigger_tlv * trig,struct wireless_dev * wdev)777174beb6SJohannes Berg iwl_fw_dbg_trigger_vif_match(struct iwl_fw_dbg_trigger_tlv *trig,
787174beb6SJohannes Berg struct wireless_dev *wdev)
797174beb6SJohannes Berg {
807174beb6SJohannes Berg u32 trig_vif = le32_to_cpu(trig->vif_type);
817174beb6SJohannes Berg
827174beb6SJohannes Berg return trig_vif == IWL_FW_DBG_CONF_VIF_ANY ||
837174beb6SJohannes Berg wdev->iftype == trig_vif;
847174beb6SJohannes Berg }
857174beb6SJohannes Berg
867174beb6SJohannes Berg static inline bool
iwl_fw_dbg_trigger_stop_conf_match(struct iwl_fw_runtime * fwrt,struct iwl_fw_dbg_trigger_tlv * trig)877174beb6SJohannes Berg iwl_fw_dbg_trigger_stop_conf_match(struct iwl_fw_runtime *fwrt,
887174beb6SJohannes Berg struct iwl_fw_dbg_trigger_tlv *trig)
897174beb6SJohannes Berg {
907174beb6SJohannes Berg return ((trig->mode & IWL_FW_DBG_TRIGGER_STOP) &&
917174beb6SJohannes Berg (fwrt->dump.conf == FW_DBG_INVALID ||
927174beb6SJohannes Berg (BIT(fwrt->dump.conf) & le32_to_cpu(trig->stop_conf_ids))));
937174beb6SJohannes Berg }
947174beb6SJohannes Berg
957174beb6SJohannes Berg static inline bool
iwl_fw_dbg_no_trig_window(struct iwl_fw_runtime * fwrt,u32 id,u32 dis_usec)9646c7c982SShahar S Matityahu iwl_fw_dbg_no_trig_window(struct iwl_fw_runtime *fwrt, u32 id, u32 dis_usec)
977174beb6SJohannes Berg {
9846c7c982SShahar S Matityahu unsigned long wind_jiff = usecs_to_jiffies(dis_usec);
997174beb6SJohannes Berg
1007174beb6SJohannes Berg /* If this is the first event checked, jump to update start ts */
1017174beb6SJohannes Berg if (fwrt->dump.non_collect_ts_start[id] &&
1027174beb6SJohannes Berg (time_after(fwrt->dump.non_collect_ts_start[id] + wind_jiff,
1037174beb6SJohannes Berg jiffies)))
1047174beb6SJohannes Berg return true;
1057174beb6SJohannes Berg
1067174beb6SJohannes Berg fwrt->dump.non_collect_ts_start[id] = jiffies;
1077174beb6SJohannes Berg return false;
1087174beb6SJohannes Berg }
1097174beb6SJohannes Berg
1107174beb6SJohannes Berg static inline bool
iwl_fw_dbg_trigger_check_stop(struct iwl_fw_runtime * fwrt,struct wireless_dev * wdev,struct iwl_fw_dbg_trigger_tlv * trig)1117174beb6SJohannes Berg iwl_fw_dbg_trigger_check_stop(struct iwl_fw_runtime *fwrt,
1127174beb6SJohannes Berg struct wireless_dev *wdev,
1137174beb6SJohannes Berg struct iwl_fw_dbg_trigger_tlv *trig)
1147174beb6SJohannes Berg {
11546c7c982SShahar S Matityahu u32 usec = le16_to_cpu(trig->trig_dis_ms) * USEC_PER_MSEC;
11646c7c982SShahar S Matityahu
1177174beb6SJohannes Berg if (wdev && !iwl_fw_dbg_trigger_vif_match(trig, wdev))
1187174beb6SJohannes Berg return false;
1197174beb6SJohannes Berg
12046c7c982SShahar S Matityahu if (iwl_fw_dbg_no_trig_window(fwrt, le32_to_cpu(trig->id), usec)) {
1217174beb6SJohannes Berg IWL_WARN(fwrt, "Trigger %d occurred while no-collect window.\n",
1227174beb6SJohannes Berg trig->id);
1237174beb6SJohannes Berg return false;
1247174beb6SJohannes Berg }
1257174beb6SJohannes Berg
1267174beb6SJohannes Berg return iwl_fw_dbg_trigger_stop_conf_match(fwrt, trig);
1277174beb6SJohannes Berg }
1287174beb6SJohannes Berg
1296c042d75SSara Sharon static inline struct iwl_fw_dbg_trigger_tlv*
_iwl_fw_dbg_trigger_on(struct iwl_fw_runtime * fwrt,struct wireless_dev * wdev,const enum iwl_fw_dbg_trigger id)1306c042d75SSara Sharon _iwl_fw_dbg_trigger_on(struct iwl_fw_runtime *fwrt,
1316c042d75SSara Sharon struct wireless_dev *wdev,
1326c042d75SSara Sharon const enum iwl_fw_dbg_trigger id)
1336c042d75SSara Sharon {
1346c042d75SSara Sharon struct iwl_fw_dbg_trigger_tlv *trig;
1356c042d75SSara Sharon
136a1af4c48SShahar S Matityahu if (iwl_trans_dbg_ini_valid(fwrt->trans))
13774374223SSara Sharon return NULL;
13874374223SSara Sharon
1396c042d75SSara Sharon if (!iwl_fw_dbg_trigger_enabled(fwrt->fw, id))
1406c042d75SSara Sharon return NULL;
1416c042d75SSara Sharon
1426c042d75SSara Sharon trig = _iwl_fw_dbg_get_trigger(fwrt->fw, id);
1436c042d75SSara Sharon
1446c042d75SSara Sharon if (!iwl_fw_dbg_trigger_check_stop(fwrt, wdev, trig))
1456c042d75SSara Sharon return NULL;
1466c042d75SSara Sharon
1476c042d75SSara Sharon return trig;
1486c042d75SSara Sharon }
1496c042d75SSara Sharon
1506c042d75SSara Sharon #define iwl_fw_dbg_trigger_on(fwrt, wdev, id) ({ \
1516c042d75SSara Sharon BUILD_BUG_ON(!__builtin_constant_p(id)); \
1526c042d75SSara Sharon BUILD_BUG_ON((id) >= FW_DBG_TRIGGER_MAX); \
1536c042d75SSara Sharon _iwl_fw_dbg_trigger_on((fwrt), (wdev), (id)); \
1546c042d75SSara Sharon })
1556c042d75SSara Sharon
1567174beb6SJohannes Berg static inline void
_iwl_fw_dbg_trigger_simple_stop(struct iwl_fw_runtime * fwrt,struct wireless_dev * wdev,struct iwl_fw_dbg_trigger_tlv * trigger)1577174beb6SJohannes Berg _iwl_fw_dbg_trigger_simple_stop(struct iwl_fw_runtime *fwrt,
1587174beb6SJohannes Berg struct wireless_dev *wdev,
1597174beb6SJohannes Berg struct iwl_fw_dbg_trigger_tlv *trigger)
1607174beb6SJohannes Berg {
1617174beb6SJohannes Berg if (!trigger)
1627174beb6SJohannes Berg return;
1637174beb6SJohannes Berg
1647174beb6SJohannes Berg if (!iwl_fw_dbg_trigger_check_stop(fwrt, wdev, trigger))
1657174beb6SJohannes Berg return;
1667174beb6SJohannes Berg
1677174beb6SJohannes Berg iwl_fw_dbg_collect_trig(fwrt, trigger, NULL);
1687174beb6SJohannes Berg }
1697174beb6SJohannes Berg
1707174beb6SJohannes Berg #define iwl_fw_dbg_trigger_simple_stop(fwrt, wdev, trig) \
1717174beb6SJohannes Berg _iwl_fw_dbg_trigger_simple_stop((fwrt), (wdev), \
1727174beb6SJohannes Berg iwl_fw_dbg_get_trigger((fwrt)->fw,\
1737174beb6SJohannes Berg (trig)))
174699b760bSLuca Coelho void iwl_fw_dbg_stop_restart_recording(struct iwl_fw_runtime *fwrt,
17557605833SShahar S Matityahu struct iwl_fw_dbg_params *params,
17657605833SShahar S Matityahu bool stop);
1771efc3843SGolan Ben Ami
178f7805b33SLior Cohen #ifdef CONFIG_IWLWIFI_DEBUGFS
iwl_fw_set_dbg_rec_on(struct iwl_fw_runtime * fwrt)179f7805b33SLior Cohen static inline void iwl_fw_set_dbg_rec_on(struct iwl_fw_runtime *fwrt)
180f7805b33SLior Cohen {
181029c25f3SShahar S Matityahu if (fwrt->cur_fw_img == IWL_UCODE_REGULAR &&
182029c25f3SShahar S Matityahu (fwrt->fw->dbg.dest_tlv ||
183029c25f3SShahar S Matityahu fwrt->trans->dbg.ini_dest != IWL_FW_INI_LOCATION_INVALID))
18491c28b83SShahar S Matityahu fwrt->trans->dbg.rec_on = true;
185f7805b33SLior Cohen }
186f7805b33SLior Cohen #endif
187f7805b33SLior Cohen
iwl_fw_dump_conf_clear(struct iwl_fw_runtime * fwrt)1887174beb6SJohannes Berg static inline void iwl_fw_dump_conf_clear(struct iwl_fw_runtime *fwrt)
1897174beb6SJohannes Berg {
1907174beb6SJohannes Berg fwrt->dump.conf = FW_DBG_INVALID;
1917174beb6SJohannes Berg }
1927174beb6SJohannes Berg
1937174beb6SJohannes Berg void iwl_fw_error_dump_wk(struct work_struct *work);
1947174beb6SJohannes Berg
iwl_fw_dbg_type_on(struct iwl_fw_runtime * fwrt,u32 type)195e488e593SSara Sharon static inline bool iwl_fw_dbg_type_on(struct iwl_fw_runtime *fwrt, u32 type)
196e488e593SSara Sharon {
1971d45a700SShahar S Matityahu return (fwrt->fw->dbg.dump_mask & BIT(type));
198e488e593SSara Sharon }
199e488e593SSara Sharon
iwl_fw_dbg_is_d3_debug_enabled(struct iwl_fw_runtime * fwrt)2002d8c2615SShahar S Matityahu static inline bool iwl_fw_dbg_is_d3_debug_enabled(struct iwl_fw_runtime *fwrt)
2012d8c2615SShahar S Matityahu {
2022d8c2615SShahar S Matityahu return fw_has_capa(&fwrt->fw->ucode_capa,
2032d8c2615SShahar S Matityahu IWL_UCODE_TLV_CAPA_D3_DEBUG) &&
204971377e6SShahar S Matityahu fwrt->trans->cfg->d3_debug_data_length && fwrt->ops &&
205971377e6SShahar S Matityahu fwrt->ops->d3_debug_enable &&
206971377e6SShahar S Matityahu fwrt->ops->d3_debug_enable(fwrt->ops_ctx) &&
207e488e593SSara Sharon iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_D3_DEBUG_DATA);
2082d8c2615SShahar S Matityahu }
2092d8c2615SShahar S Matityahu
iwl_fw_dbg_is_paging_enabled(struct iwl_fw_runtime * fwrt)21056b657f7SSara Sharon static inline bool iwl_fw_dbg_is_paging_enabled(struct iwl_fw_runtime *fwrt)
21156b657f7SSara Sharon {
21256b657f7SSara Sharon return iwl_fw_dbg_type_on(fwrt, IWL_FW_ERROR_DUMP_PAGING) &&
213286ca8ebSLuca Coelho !fwrt->trans->trans_cfg->gen2 &&
2149adcc117SLuca Coelho fwrt->cur_fw_img < IWL_UCODE_TYPE_MAX &&
21556b657f7SSara Sharon fwrt->fw->img[fwrt->cur_fw_img].paging_mem_size &&
21656b657f7SSara Sharon fwrt->fw_paging_db[0].fw_paging_block;
21756b657f7SSara Sharon }
21856b657f7SSara Sharon
2192d8c2615SShahar S Matityahu void iwl_fw_dbg_read_d3_debug_data(struct iwl_fw_runtime *fwrt);
2202d8c2615SShahar S Matityahu
iwl_fw_flush_dumps(struct iwl_fw_runtime * fwrt)221c7ab138eSShahar S Matityahu static inline void iwl_fw_flush_dumps(struct iwl_fw_runtime *fwrt)
2227174beb6SJohannes Berg {
223c7ab138eSShahar S Matityahu int i;
224c7ab138eSShahar S Matityahu
2259b1bcfccSShahar S Matityahu iwl_dbg_tlv_del_timers(fwrt->trans);
2263b589d56SShahar S Matityahu for (i = 0; i < IWL_FW_RUNTIME_DUMP_WK_NUM; i++)
227c7ab138eSShahar S Matityahu flush_delayed_work(&fwrt->dump.wks[i].wk);
2287174beb6SJohannes Berg }
2297174beb6SJohannes Berg
230*eeef0168SMiri Korenblit int iwl_fw_send_timestamp_marker_cmd(struct iwl_fw_runtime *fwrt);
231*eeef0168SMiri Korenblit
232422b5dd4SHaim Dreyfuss #ifdef CONFIG_IWLWIFI_DEBUGFS
iwl_fw_cancel_timestamp(struct iwl_fw_runtime * fwrt)233422b5dd4SHaim Dreyfuss static inline void iwl_fw_cancel_timestamp(struct iwl_fw_runtime *fwrt)
234422b5dd4SHaim Dreyfuss {
235422b5dd4SHaim Dreyfuss fwrt->timestamp.delay = 0;
236422b5dd4SHaim Dreyfuss cancel_delayed_work_sync(&fwrt->timestamp.wk);
237422b5dd4SHaim Dreyfuss }
238422b5dd4SHaim Dreyfuss
239422b5dd4SHaim Dreyfuss void iwl_fw_trigger_timestamp(struct iwl_fw_runtime *fwrt, u32 delay);
240422b5dd4SHaim Dreyfuss
iwl_fw_suspend_timestamp(struct iwl_fw_runtime * fwrt)241422b5dd4SHaim Dreyfuss static inline void iwl_fw_suspend_timestamp(struct iwl_fw_runtime *fwrt)
242422b5dd4SHaim Dreyfuss {
243422b5dd4SHaim Dreyfuss cancel_delayed_work_sync(&fwrt->timestamp.wk);
244422b5dd4SHaim Dreyfuss }
245422b5dd4SHaim Dreyfuss
iwl_fw_resume_timestamp(struct iwl_fw_runtime * fwrt)246422b5dd4SHaim Dreyfuss static inline void iwl_fw_resume_timestamp(struct iwl_fw_runtime *fwrt)
247422b5dd4SHaim Dreyfuss {
248422b5dd4SHaim Dreyfuss if (!fwrt->timestamp.delay)
249422b5dd4SHaim Dreyfuss return;
250422b5dd4SHaim Dreyfuss
251422b5dd4SHaim Dreyfuss schedule_delayed_work(&fwrt->timestamp.wk,
252422b5dd4SHaim Dreyfuss round_jiffies_relative(fwrt->timestamp.delay));
253422b5dd4SHaim Dreyfuss }
254422b5dd4SHaim Dreyfuss
255422b5dd4SHaim Dreyfuss #else
256422b5dd4SHaim Dreyfuss
iwl_fw_cancel_timestamp(struct iwl_fw_runtime * fwrt)257422b5dd4SHaim Dreyfuss static inline void iwl_fw_cancel_timestamp(struct iwl_fw_runtime *fwrt) {}
258422b5dd4SHaim Dreyfuss
iwl_fw_trigger_timestamp(struct iwl_fw_runtime * fwrt,u32 delay)259422b5dd4SHaim Dreyfuss static inline void iwl_fw_trigger_timestamp(struct iwl_fw_runtime *fwrt,
260422b5dd4SHaim Dreyfuss u32 delay) {}
261422b5dd4SHaim Dreyfuss
iwl_fw_suspend_timestamp(struct iwl_fw_runtime * fwrt)262422b5dd4SHaim Dreyfuss static inline void iwl_fw_suspend_timestamp(struct iwl_fw_runtime *fwrt) {}
263422b5dd4SHaim Dreyfuss
iwl_fw_resume_timestamp(struct iwl_fw_runtime * fwrt)264422b5dd4SHaim Dreyfuss static inline void iwl_fw_resume_timestamp(struct iwl_fw_runtime *fwrt) {}
265422b5dd4SHaim Dreyfuss
266422b5dd4SHaim Dreyfuss #endif /* CONFIG_IWLWIFI_DEBUGFS */
267422b5dd4SHaim Dreyfuss
268203c83d3SShahar S Matityahu void iwl_fw_dbg_stop_sync(struct iwl_fw_runtime *fwrt);
2698d534e96SShahar S Matityahu
iwl_fw_lmac1_set_alive_err_table(struct iwl_trans * trans,u32 lmac_error_event_table)27022463857SShahar S Matityahu static inline void iwl_fw_lmac1_set_alive_err_table(struct iwl_trans *trans,
27122463857SShahar S Matityahu u32 lmac_error_event_table)
27222463857SShahar S Matityahu {
27391c28b83SShahar S Matityahu if (!(trans->dbg.error_event_table_tlv_status &
27422463857SShahar S Matityahu IWL_ERROR_EVENT_TABLE_LMAC1) ||
27591c28b83SShahar S Matityahu WARN_ON(trans->dbg.lmac_error_event_table[0] !=
27622463857SShahar S Matityahu lmac_error_event_table))
27791c28b83SShahar S Matityahu trans->dbg.lmac_error_event_table[0] = lmac_error_event_table;
27822463857SShahar S Matityahu }
27922463857SShahar S Matityahu
iwl_fw_umac_set_alive_err_table(struct iwl_trans * trans,u32 umac_error_event_table)28022463857SShahar S Matityahu static inline void iwl_fw_umac_set_alive_err_table(struct iwl_trans *trans,
28122463857SShahar S Matityahu u32 umac_error_event_table)
28222463857SShahar S Matityahu {
28391c28b83SShahar S Matityahu if (!(trans->dbg.error_event_table_tlv_status &
28422463857SShahar S Matityahu IWL_ERROR_EVENT_TABLE_UMAC) ||
28591c28b83SShahar S Matityahu WARN_ON(trans->dbg.umac_error_event_table !=
28622463857SShahar S Matityahu umac_error_event_table))
28791c28b83SShahar S Matityahu trans->dbg.umac_error_event_table = umac_error_event_table;
28822463857SShahar S Matityahu }
28922463857SShahar S Matityahu
iwl_fw_error_collect(struct iwl_fw_runtime * fwrt,bool sync)290b8221b0fSJohannes Berg static inline void iwl_fw_error_collect(struct iwl_fw_runtime *fwrt, bool sync)
2914b1831e4SShahar S Matityahu {
2923b589d56SShahar S Matityahu enum iwl_fw_ini_time_point tp_id;
2933b589d56SShahar S Matityahu
2943b589d56SShahar S Matityahu if (!iwl_trans_dbg_ini_valid(fwrt->trans)) {
2953b589d56SShahar S Matityahu iwl_fw_dbg_collect_desc(fwrt, &iwl_dump_desc_assert, false, 0);
2963b589d56SShahar S Matityahu return;
2973b589d56SShahar S Matityahu }
2983b589d56SShahar S Matityahu
2993b589d56SShahar S Matityahu if (fwrt->trans->dbg.hw_error) {
3003b589d56SShahar S Matityahu tp_id = IWL_FW_INI_TIME_POINT_FW_HW_ERROR;
30191c28b83SShahar S Matityahu fwrt->trans->dbg.hw_error = false;
3024b1831e4SShahar S Matityahu } else {
3033b589d56SShahar S Matityahu tp_id = IWL_FW_INI_TIME_POINT_FW_ASSERT;
3044b1831e4SShahar S Matityahu }
3053b589d56SShahar S Matityahu
306b8221b0fSJohannes Berg _iwl_dbg_tlv_time_point(fwrt, tp_id, NULL, sync);
3074b1831e4SShahar S Matityahu }
3084b1831e4SShahar S Matityahu
309cc5470dfSShahar S Matityahu void iwl_fw_error_print_fseq_regs(struct iwl_fw_runtime *fwrt);
3100a3a3e9eSShahar S Matityahu
iwl_fwrt_update_fw_versions(struct iwl_fw_runtime * fwrt,struct iwl_lmac_alive * lmac,struct iwl_umac_alive * umac)3110a3a3e9eSShahar S Matityahu static inline void iwl_fwrt_update_fw_versions(struct iwl_fw_runtime *fwrt,
3120a3a3e9eSShahar S Matityahu struct iwl_lmac_alive *lmac,
3130a3a3e9eSShahar S Matityahu struct iwl_umac_alive *umac)
3140a3a3e9eSShahar S Matityahu {
3150a3a3e9eSShahar S Matityahu if (lmac) {
3160a3a3e9eSShahar S Matityahu fwrt->dump.fw_ver.type = lmac->ver_type;
3170a3a3e9eSShahar S Matityahu fwrt->dump.fw_ver.subtype = lmac->ver_subtype;
3180a3a3e9eSShahar S Matityahu fwrt->dump.fw_ver.lmac_major = le32_to_cpu(lmac->ucode_major);
3190a3a3e9eSShahar S Matityahu fwrt->dump.fw_ver.lmac_minor = le32_to_cpu(lmac->ucode_minor);
3200a3a3e9eSShahar S Matityahu }
3210a3a3e9eSShahar S Matityahu
3220a3a3e9eSShahar S Matityahu if (umac) {
3230a3a3e9eSShahar S Matityahu fwrt->dump.fw_ver.umac_major = le32_to_cpu(umac->umac_major);
3240a3a3e9eSShahar S Matityahu fwrt->dump.fw_ver.umac_minor = le32_to_cpu(umac->umac_minor);
3250a3a3e9eSShahar S Matityahu }
3260a3a3e9eSShahar S Matityahu }
3274db7cf1eSJohannes Berg
3284db7cf1eSJohannes Berg void iwl_fwrt_dump_error_logs(struct iwl_fw_runtime *fwrt);
3290eb50c67SMukesh Sisodiya void iwl_send_dbg_dump_complete_cmd(struct iwl_fw_runtime *fwrt,
3300eb50c67SMukesh Sisodiya u32 timepoint,
3310eb50c67SMukesh Sisodiya u32 timepoint_data);
332568db7fdSJohannes Berg
333568db7fdSJohannes Berg #define IWL_FW_CHECK_FAILED(_obj, _fmt, ...) \
334568db7fdSJohannes Berg IWL_ERR_LIMIT(_obj, _fmt, __VA_ARGS__)
335568db7fdSJohannes Berg
336568db7fdSJohannes Berg #define IWL_FW_CHECK(_obj, _cond, _fmt, ...) \
337568db7fdSJohannes Berg ({ \
338568db7fdSJohannes Berg bool __cond = (_cond); \
339568db7fdSJohannes Berg \
340568db7fdSJohannes Berg if (unlikely(__cond)) \
341568db7fdSJohannes Berg IWL_FW_CHECK_FAILED(_obj, _fmt, __VA_ARGS__); \
342568db7fdSJohannes Berg \
343568db7fdSJohannes Berg unlikely(__cond); \
344568db7fdSJohannes Berg })
345568db7fdSJohannes Berg
3467174beb6SJohannes Berg #endif /* __iwl_fw_dbg_h__ */
347