1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66#ifndef __mvm_fw_dbg_h__
67#define __mvm_fw_dbg_h__
68#include "iwl-fw-file.h"
69#include "iwl-fw-error-dump.h"
70#include "mvm.h"
71
72void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm);
73void iwl_mvm_free_fw_dump_desc(struct iwl_mvm *mvm);
74int iwl_mvm_fw_dbg_collect_desc(struct iwl_mvm *mvm,
75 const struct iwl_mvm_dump_desc *desc,
76 const struct iwl_fw_dbg_trigger_tlv *trigger);
77int iwl_mvm_fw_dbg_collect(struct iwl_mvm *mvm, enum iwl_fw_dbg_trigger trig,
78 const char *str, size_t len,
79 const struct iwl_fw_dbg_trigger_tlv *trigger);
80int iwl_mvm_fw_dbg_collect_trig(struct iwl_mvm *mvm,
81 struct iwl_fw_dbg_trigger_tlv *trigger,
82 const char *fmt, ...) __printf(3, 4);
83int iwl_mvm_start_fw_dbg_conf(struct iwl_mvm *mvm, u8 id);
84
85#define iwl_fw_dbg_trigger_enabled(fw, id) ({ \
86 void *__dbg_trigger = (fw)->dbg_trigger_tlv[(id)]; \
87 unlikely(__dbg_trigger); \
88})
89
90static inline struct iwl_fw_dbg_trigger_tlv*
91_iwl_fw_dbg_get_trigger(const struct iwl_fw *fw, enum iwl_fw_dbg_trigger id)
92{
93 return fw->dbg_trigger_tlv[id];
94}
95
96#define iwl_fw_dbg_get_trigger(fw, id) ({ \
97 BUILD_BUG_ON(!__builtin_constant_p(id)); \
98 BUILD_BUG_ON((id) >= FW_DBG_TRIGGER_MAX); \
99 _iwl_fw_dbg_get_trigger((fw), (id)); \
100})
101
102static inline bool
103iwl_fw_dbg_trigger_vif_match(struct iwl_fw_dbg_trigger_tlv *trig,
104 struct ieee80211_vif *vif)
105{
106 u32 trig_vif = le32_to_cpu(trig->vif_type);
107
108 return trig_vif == IWL_FW_DBG_CONF_VIF_ANY || vif->type == trig_vif;
109}
110
111static inline bool
112iwl_fw_dbg_trigger_stop_conf_match(struct iwl_mvm *mvm,
113 struct iwl_fw_dbg_trigger_tlv *trig)
114{
115 return ((trig->mode & IWL_FW_DBG_TRIGGER_STOP) &&
116 (mvm->fw_dbg_conf == FW_DBG_INVALID ||
117 (BIT(mvm->fw_dbg_conf) & le32_to_cpu(trig->stop_conf_ids))));
118}
119
120static inline bool
121iwl_fw_dbg_no_trig_window(struct iwl_mvm *mvm,
122 struct iwl_fw_dbg_trigger_tlv *trig)
123{
124 unsigned long wind_jiff =
125 msecs_to_jiffies(le16_to_cpu(trig->trig_dis_ms));
126 u32 id = le32_to_cpu(trig->id);
127
128
129 if (mvm->fw_dbg_non_collect_ts_start[id] &&
130 (time_after(mvm->fw_dbg_non_collect_ts_start[id] + wind_jiff,
131 jiffies)))
132 return true;
133
134 mvm->fw_dbg_non_collect_ts_start[id] = jiffies;
135 return false;
136}
137
138static inline bool
139iwl_fw_dbg_trigger_check_stop(struct iwl_mvm *mvm,
140 struct ieee80211_vif *vif,
141 struct iwl_fw_dbg_trigger_tlv *trig)
142{
143 if (vif && !iwl_fw_dbg_trigger_vif_match(trig, vif))
144 return false;
145
146 if (iwl_fw_dbg_no_trig_window(mvm, trig)) {
147 IWL_WARN(mvm, "Trigger %d occurred while no-collect window.\n",
148 trig->id);
149 return false;
150 }
151
152 return iwl_fw_dbg_trigger_stop_conf_match(mvm, trig);
153}
154
155static inline void
156_iwl_fw_dbg_trigger_simple_stop(struct iwl_mvm *mvm,
157 struct ieee80211_vif *vif,
158 struct iwl_fw_dbg_trigger_tlv *trigger)
159{
160 if (!trigger)
161 return;
162
163 if (!iwl_fw_dbg_trigger_check_stop(mvm, vif, trigger))
164 return;
165
166 iwl_mvm_fw_dbg_collect_trig(mvm, trigger, NULL);
167}
168
169#define iwl_fw_dbg_trigger_simple_stop(mvm, vif, trig) \
170 _iwl_fw_dbg_trigger_simple_stop((mvm), (vif), \
171 iwl_fw_dbg_get_trigger((mvm)->fw,\
172 (trig)))
173
174#endif
175