This source file includes following definitions.
- iwl_dbg_tlv_ver_support
- iwl_dbg_tlv_alloc
- iwl_dbg_tlv_del_timers
- iwl_dbg_tlv_free
- iwl_dbg_tlv_parse_bin
- iwl_dbg_tlv_load_bin
- iwl_dbg_tlv_time_point
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 #include <linux/firmware.h>
63 #include "iwl-drv.h"
64 #include "iwl-trans.h"
65 #include "iwl-dbg-tlv.h"
66 #include "fw/dbg.h"
67 #include "fw/runtime.h"
68
69
70
71
72
73
74
75
76
77
78 enum iwl_dbg_tlv_type {
79 IWL_DBG_TLV_TYPE_DEBUG_INFO =
80 IWL_UCODE_TLV_TYPE_DEBUG_INFO - IWL_UCODE_TLV_DEBUG_BASE,
81 IWL_DBG_TLV_TYPE_BUF_ALLOC,
82 IWL_DBG_TLV_TYPE_HCMD,
83 IWL_DBG_TLV_TYPE_REGION,
84 IWL_DBG_TLV_TYPE_TRIGGER,
85 IWL_DBG_TLV_TYPE_NUM,
86 };
87
88
89
90
91
92
93 struct iwl_dbg_tlv_ver_data {
94 int min_ver;
95 int max_ver;
96 };
97
98 static const struct iwl_dbg_tlv_ver_data
99 dbg_ver_table[IWL_DBG_TLV_TYPE_NUM] = {
100 [IWL_DBG_TLV_TYPE_DEBUG_INFO] = {.min_ver = 1, .max_ver = 1,},
101 [IWL_DBG_TLV_TYPE_BUF_ALLOC] = {.min_ver = 1, .max_ver = 1,},
102 [IWL_DBG_TLV_TYPE_HCMD] = {.min_ver = 1, .max_ver = 1,},
103 [IWL_DBG_TLV_TYPE_REGION] = {.min_ver = 1, .max_ver = 1,},
104 [IWL_DBG_TLV_TYPE_TRIGGER] = {.min_ver = 1, .max_ver = 1,},
105 };
106
107 static bool iwl_dbg_tlv_ver_support(struct iwl_ucode_tlv *tlv)
108 {
109 struct iwl_fw_ini_header *hdr = (void *)&tlv->data[0];
110 u32 type = le32_to_cpu(tlv->type);
111 u32 tlv_idx = type - IWL_UCODE_TLV_DEBUG_BASE;
112 u32 ver = le32_to_cpu(hdr->tlv_version);
113
114 if (ver < dbg_ver_table[tlv_idx].min_ver ||
115 ver > dbg_ver_table[tlv_idx].max_ver)
116 return false;
117
118 return true;
119 }
120
121 void iwl_dbg_tlv_alloc(struct iwl_trans *trans, struct iwl_ucode_tlv *tlv,
122 bool ext)
123 {
124 struct iwl_fw_ini_header *hdr = (void *)&tlv->data[0];
125 u32 type = le32_to_cpu(tlv->type);
126 u32 pnt = le32_to_cpu(hdr->apply_point);
127 u32 tlv_idx = type - IWL_UCODE_TLV_DEBUG_BASE;
128 enum iwl_ini_cfg_state *cfg_state = ext ?
129 &trans->dbg.external_ini_cfg : &trans->dbg.internal_ini_cfg;
130
131 IWL_DEBUG_FW(trans, "WRT: read TLV 0x%x, apply point %d\n",
132 type, pnt);
133
134 if (tlv_idx >= IWL_DBG_TLV_TYPE_NUM) {
135 IWL_ERR(trans, "WRT: Unsupported TLV 0x%x\n", type);
136 goto out_err;
137 }
138
139 if (!iwl_dbg_tlv_ver_support(tlv)) {
140 IWL_ERR(trans, "WRT: Unsupported TLV 0x%x version %u\n", type,
141 le32_to_cpu(hdr->tlv_version));
142 goto out_err;
143 }
144
145 if (*cfg_state == IWL_INI_CFG_STATE_NOT_LOADED)
146 *cfg_state = IWL_INI_CFG_STATE_LOADED;
147
148 return;
149
150 out_err:
151 *cfg_state = IWL_INI_CFG_STATE_CORRUPTED;
152 }
153
154 void iwl_dbg_tlv_del_timers(struct iwl_trans *trans)
155 {
156
157 }
158 IWL_EXPORT_SYMBOL(iwl_dbg_tlv_del_timers);
159
160 void iwl_dbg_tlv_free(struct iwl_trans *trans)
161 {
162
163 }
164
165 static int iwl_dbg_tlv_parse_bin(struct iwl_trans *trans, const u8 *data,
166 size_t len)
167 {
168 struct iwl_ucode_tlv *tlv;
169 u32 tlv_len;
170
171 while (len >= sizeof(*tlv)) {
172 len -= sizeof(*tlv);
173 tlv = (void *)data;
174
175 tlv_len = le32_to_cpu(tlv->length);
176
177 if (len < tlv_len) {
178 IWL_ERR(trans, "invalid TLV len: %zd/%u\n",
179 len, tlv_len);
180 return -EINVAL;
181 }
182 len -= ALIGN(tlv_len, 4);
183 data += sizeof(*tlv) + ALIGN(tlv_len, 4);
184
185 iwl_dbg_tlv_alloc(trans, tlv, true);
186 }
187
188 return 0;
189 }
190
191 void iwl_dbg_tlv_load_bin(struct device *dev, struct iwl_trans *trans)
192 {
193 const struct firmware *fw;
194 int res;
195
196 if (!iwlwifi_mod_params.enable_ini)
197 return;
198
199 res = request_firmware(&fw, "iwl-dbg-tlv.ini", dev);
200 if (res)
201 return;
202
203 iwl_dbg_tlv_parse_bin(trans, fw->data, fw->size);
204
205 release_firmware(fw);
206 }
207
208 void iwl_dbg_tlv_time_point(struct iwl_fw_runtime *fwrt,
209 enum iwl_fw_ini_time_point tp_id,
210 union iwl_dbg_tlv_tp_data *tp_data)
211 {
212
213 }
214 IWL_EXPORT_SYMBOL(iwl_dbg_tlv_time_point);