diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/dvm/testmode.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/dvm/testmode.c | 778 |
1 files changed, 68 insertions, 710 deletions
diff --git a/drivers/net/wireless/iwlwifi/dvm/testmode.c b/drivers/net/wireless/iwlwifi/dvm/testmode.c index e08b1a383594..57b918ce3b5f 100644 --- a/drivers/net/wireless/iwlwifi/dvm/testmode.c +++ b/drivers/net/wireless/iwlwifi/dvm/testmode.c | |||
@@ -60,6 +60,7 @@ | |||
60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
61 | * | 61 | * |
62 | *****************************************************************************/ | 62 | *****************************************************************************/ |
63 | |||
63 | #include <linux/init.h> | 64 | #include <linux/init.h> |
64 | #include <linux/kernel.h> | 65 | #include <linux/kernel.h> |
65 | #include <linux/module.h> | 66 | #include <linux/module.h> |
@@ -69,354 +70,83 @@ | |||
69 | #include <net/cfg80211.h> | 70 | #include <net/cfg80211.h> |
70 | #include <net/mac80211.h> | 71 | #include <net/mac80211.h> |
71 | #include <net/netlink.h> | 72 | #include <net/netlink.h> |
73 | |||
72 | #include "iwl-debug.h" | 74 | #include "iwl-debug.h" |
73 | #include "iwl-io.h" | ||
74 | #include "iwl-trans.h" | 75 | #include "iwl-trans.h" |
75 | #include "iwl-fh.h" | ||
76 | #include "iwl-prph.h" | ||
77 | #include "dev.h" | 76 | #include "dev.h" |
78 | #include "agn.h" | 77 | #include "agn.h" |
79 | #include "testmode.h" | 78 | #include "iwl-test.h" |
80 | 79 | #include "iwl-testmode.h" | |
81 | |||
82 | /* Periphery registers absolute lower bound. This is used in order to | ||
83 | * differentiate registery access through HBUS_TARG_PRPH_* and | ||
84 | * HBUS_TARG_MEM_* accesses. | ||
85 | */ | ||
86 | #define IWL_TM_ABS_PRPH_START (0xA00000) | ||
87 | |||
88 | /* The TLVs used in the gnl message policy between the kernel module and | ||
89 | * user space application. iwl_testmode_gnl_msg_policy is to be carried | ||
90 | * through the NL80211_CMD_TESTMODE channel regulated by nl80211. | ||
91 | * See testmode.h | ||
92 | */ | ||
93 | static | ||
94 | struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { | ||
95 | [IWL_TM_ATTR_COMMAND] = { .type = NLA_U32, }, | ||
96 | |||
97 | [IWL_TM_ATTR_UCODE_CMD_ID] = { .type = NLA_U8, }, | ||
98 | [IWL_TM_ATTR_UCODE_CMD_DATA] = { .type = NLA_UNSPEC, }, | ||
99 | |||
100 | [IWL_TM_ATTR_REG_OFFSET] = { .type = NLA_U32, }, | ||
101 | [IWL_TM_ATTR_REG_VALUE8] = { .type = NLA_U8, }, | ||
102 | [IWL_TM_ATTR_REG_VALUE32] = { .type = NLA_U32, }, | ||
103 | |||
104 | [IWL_TM_ATTR_SYNC_RSP] = { .type = NLA_UNSPEC, }, | ||
105 | [IWL_TM_ATTR_UCODE_RX_PKT] = { .type = NLA_UNSPEC, }, | ||
106 | 80 | ||
107 | [IWL_TM_ATTR_EEPROM] = { .type = NLA_UNSPEC, }, | 81 | static int iwl_testmode_send_cmd(struct iwl_op_mode *op_mode, |
108 | 82 | struct iwl_host_cmd *cmd) | |
109 | [IWL_TM_ATTR_TRACE_ADDR] = { .type = NLA_UNSPEC, }, | ||
110 | [IWL_TM_ATTR_TRACE_DUMP] = { .type = NLA_UNSPEC, }, | ||
111 | [IWL_TM_ATTR_TRACE_SIZE] = { .type = NLA_U32, }, | ||
112 | |||
113 | [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, | ||
114 | |||
115 | [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, }, | ||
116 | |||
117 | [IWL_TM_ATTR_MEM_ADDR] = { .type = NLA_U32, }, | ||
118 | [IWL_TM_ATTR_BUFFER_SIZE] = { .type = NLA_U32, }, | ||
119 | [IWL_TM_ATTR_BUFFER_DUMP] = { .type = NLA_UNSPEC, }, | ||
120 | |||
121 | [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, }, | ||
122 | [IWL_TM_ATTR_DEVICE_ID] = { .type = NLA_U32, }, | ||
123 | [IWL_TM_ATTR_FW_TYPE] = { .type = NLA_U32, }, | ||
124 | [IWL_TM_ATTR_FW_INST_SIZE] = { .type = NLA_U32, }, | ||
125 | [IWL_TM_ATTR_FW_DATA_SIZE] = { .type = NLA_U32, }, | ||
126 | |||
127 | [IWL_TM_ATTR_ENABLE_NOTIFICATION] = {.type = NLA_FLAG, }, | ||
128 | }; | ||
129 | |||
130 | /* | ||
131 | * See the struct iwl_rx_packet in commands.h for the format of the | ||
132 | * received events from the device | ||
133 | */ | ||
134 | static inline int get_event_length(struct iwl_rx_cmd_buffer *rxb) | ||
135 | { | 83 | { |
136 | struct iwl_rx_packet *pkt = rxb_addr(rxb); | 84 | struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); |
137 | if (pkt) | 85 | return iwl_dvm_send_cmd(priv, cmd); |
138 | return le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; | ||
139 | else | ||
140 | return 0; | ||
141 | } | 86 | } |
142 | 87 | ||
143 | 88 | static bool iwl_testmode_valid_hw_addr(u32 addr) | |
144 | /* | ||
145 | * This function multicasts the spontaneous messages from the device to the | ||
146 | * user space. It is invoked whenever there is a received messages | ||
147 | * from the device. This function is called within the ISR of the rx handlers | ||
148 | * in iwlagn driver. | ||
149 | * | ||
150 | * The parsing of the message content is left to the user space application, | ||
151 | * The message content is treated as unattacked raw data and is encapsulated | ||
152 | * with IWL_TM_ATTR_UCODE_RX_PKT multicasting to the user space. | ||
153 | * | ||
154 | * @priv: the instance of iwlwifi device | ||
155 | * @rxb: pointer to rx data content received by the ISR | ||
156 | * | ||
157 | * See the message policies and TLVs in iwl_testmode_gnl_msg_policy[]. | ||
158 | * For the messages multicasting to the user application, the mandatory | ||
159 | * TLV fields are : | ||
160 | * IWL_TM_ATTR_COMMAND must be IWL_TM_CMD_DEV2APP_UCODE_RX_PKT | ||
161 | * IWL_TM_ATTR_UCODE_RX_PKT for carrying the message content | ||
162 | */ | ||
163 | |||
164 | static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv, | ||
165 | struct iwl_rx_cmd_buffer *rxb) | ||
166 | { | 89 | { |
167 | struct ieee80211_hw *hw = priv->hw; | 90 | if (iwlagn_hw_valid_rtc_data_addr(addr)) |
168 | struct sk_buff *skb; | 91 | return true; |
169 | void *data; | ||
170 | int length; | ||
171 | 92 | ||
172 | data = rxb_addr(rxb); | 93 | if (IWLAGN_RTC_INST_LOWER_BOUND <= addr && |
173 | length = get_event_length(rxb); | 94 | addr < IWLAGN_RTC_INST_UPPER_BOUND) |
95 | return true; | ||
174 | 96 | ||
175 | if (!data || length == 0) | 97 | return false; |
176 | return; | ||
177 | |||
178 | skb = cfg80211_testmode_alloc_event_skb(hw->wiphy, 20 + length, | ||
179 | GFP_ATOMIC); | ||
180 | if (skb == NULL) { | ||
181 | IWL_ERR(priv, | ||
182 | "Run out of memory for messages to user space ?\n"); | ||
183 | return; | ||
184 | } | ||
185 | if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT) || | ||
186 | /* the length doesn't include len_n_flags field, so add it manually */ | ||
187 | nla_put(skb, IWL_TM_ATTR_UCODE_RX_PKT, length + sizeof(__le32), data)) | ||
188 | goto nla_put_failure; | ||
189 | cfg80211_testmode_event(skb, GFP_ATOMIC); | ||
190 | return; | ||
191 | |||
192 | nla_put_failure: | ||
193 | kfree_skb(skb); | ||
194 | IWL_ERR(priv, "Ouch, overran buffer, check allocation!\n"); | ||
195 | } | 98 | } |
196 | 99 | ||
197 | void iwl_testmode_init(struct iwl_priv *priv) | 100 | static u32 iwl_testmode_get_fw_ver(struct iwl_op_mode *op_mode) |
198 | { | 101 | { |
199 | priv->pre_rx_handler = NULL; | 102 | struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); |
200 | priv->testmode_trace.trace_enabled = false; | 103 | return priv->fw->ucode_ver; |
201 | priv->testmode_mem.read_in_progress = false; | ||
202 | } | 104 | } |
203 | 105 | ||
204 | static void iwl_mem_cleanup(struct iwl_priv *priv) | 106 | static struct sk_buff* |
107 | iwl_testmode_alloc_reply(struct iwl_op_mode *op_mode, int len) | ||
205 | { | 108 | { |
206 | if (priv->testmode_mem.read_in_progress) { | 109 | struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); |
207 | kfree(priv->testmode_mem.buff_addr); | 110 | return cfg80211_testmode_alloc_reply_skb(priv->hw->wiphy, len); |
208 | priv->testmode_mem.buff_addr = NULL; | ||
209 | priv->testmode_mem.buff_size = 0; | ||
210 | priv->testmode_mem.num_chunks = 0; | ||
211 | priv->testmode_mem.read_in_progress = false; | ||
212 | } | ||
213 | } | 111 | } |
214 | 112 | ||
215 | static void iwl_trace_cleanup(struct iwl_priv *priv) | 113 | static int iwl_testmode_reply(struct iwl_op_mode *op_mode, struct sk_buff *skb) |
216 | { | 114 | { |
217 | if (priv->testmode_trace.trace_enabled) { | 115 | return cfg80211_testmode_reply(skb); |
218 | if (priv->testmode_trace.cpu_addr && | ||
219 | priv->testmode_trace.dma_addr) | ||
220 | dma_free_coherent(priv->trans->dev, | ||
221 | priv->testmode_trace.total_size, | ||
222 | priv->testmode_trace.cpu_addr, | ||
223 | priv->testmode_trace.dma_addr); | ||
224 | priv->testmode_trace.trace_enabled = false; | ||
225 | priv->testmode_trace.cpu_addr = NULL; | ||
226 | priv->testmode_trace.trace_addr = NULL; | ||
227 | priv->testmode_trace.dma_addr = 0; | ||
228 | priv->testmode_trace.buff_size = 0; | ||
229 | priv->testmode_trace.total_size = 0; | ||
230 | } | ||
231 | } | 116 | } |
232 | 117 | ||
233 | 118 | static struct sk_buff *iwl_testmode_alloc_event(struct iwl_op_mode *op_mode, | |
234 | void iwl_testmode_cleanup(struct iwl_priv *priv) | 119 | int len) |
235 | { | 120 | { |
236 | iwl_trace_cleanup(priv); | 121 | struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); |
237 | iwl_mem_cleanup(priv); | 122 | return cfg80211_testmode_alloc_event_skb(priv->hw->wiphy, len, |
123 | GFP_ATOMIC); | ||
238 | } | 124 | } |
239 | 125 | ||
240 | 126 | static void iwl_testmode_event(struct iwl_op_mode *op_mode, struct sk_buff *skb) | |
241 | /* | ||
242 | * This function handles the user application commands to the ucode. | ||
243 | * | ||
244 | * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_CMD_ID and | ||
245 | * IWL_TM_ATTR_UCODE_CMD_DATA and calls to the handler to send the | ||
246 | * host command to the ucode. | ||
247 | * | ||
248 | * If any mandatory field is missing, -ENOMSG is replied to the user space | ||
249 | * application; otherwise, waits for the host command to be sent and checks | ||
250 | * the return code. In case or error, it is returned, otherwise a reply is | ||
251 | * allocated and the reply RX packet | ||
252 | * is returned. | ||
253 | * | ||
254 | * @hw: ieee80211_hw object that represents the device | ||
255 | * @tb: gnl message fields from the user space | ||
256 | */ | ||
257 | static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) | ||
258 | { | 127 | { |
259 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | 128 | return cfg80211_testmode_event(skb, GFP_ATOMIC); |
260 | struct iwl_host_cmd cmd; | ||
261 | struct iwl_rx_packet *pkt; | ||
262 | struct sk_buff *skb; | ||
263 | void *reply_buf; | ||
264 | u32 reply_len; | ||
265 | int ret; | ||
266 | bool cmd_want_skb; | ||
267 | |||
268 | memset(&cmd, 0, sizeof(struct iwl_host_cmd)); | ||
269 | |||
270 | if (!tb[IWL_TM_ATTR_UCODE_CMD_ID] || | ||
271 | !tb[IWL_TM_ATTR_UCODE_CMD_DATA]) { | ||
272 | IWL_ERR(priv, "Missing ucode command mandatory fields\n"); | ||
273 | return -ENOMSG; | ||
274 | } | ||
275 | |||
276 | cmd.flags = CMD_ON_DEMAND | CMD_SYNC; | ||
277 | cmd_want_skb = nla_get_flag(tb[IWL_TM_ATTR_UCODE_CMD_SKB]); | ||
278 | if (cmd_want_skb) | ||
279 | cmd.flags |= CMD_WANT_SKB; | ||
280 | |||
281 | cmd.id = nla_get_u8(tb[IWL_TM_ATTR_UCODE_CMD_ID]); | ||
282 | cmd.data[0] = nla_data(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); | ||
283 | cmd.len[0] = nla_len(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); | ||
284 | cmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; | ||
285 | IWL_DEBUG_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x," | ||
286 | " len %d\n", cmd.id, cmd.flags, cmd.len[0]); | ||
287 | |||
288 | ret = iwl_dvm_send_cmd(priv, &cmd); | ||
289 | if (ret) { | ||
290 | IWL_ERR(priv, "Failed to send hcmd\n"); | ||
291 | return ret; | ||
292 | } | ||
293 | if (!cmd_want_skb) | ||
294 | return ret; | ||
295 | |||
296 | /* Handling return of SKB to the user */ | ||
297 | pkt = cmd.resp_pkt; | ||
298 | if (!pkt) { | ||
299 | IWL_ERR(priv, "HCMD received a null response packet\n"); | ||
300 | return ret; | ||
301 | } | ||
302 | |||
303 | reply_len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; | ||
304 | skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, reply_len + 20); | ||
305 | reply_buf = kmalloc(reply_len, GFP_KERNEL); | ||
306 | if (!skb || !reply_buf) { | ||
307 | kfree_skb(skb); | ||
308 | kfree(reply_buf); | ||
309 | return -ENOMEM; | ||
310 | } | ||
311 | |||
312 | /* The reply is in a page, that we cannot send to user space. */ | ||
313 | memcpy(reply_buf, &(pkt->hdr), reply_len); | ||
314 | iwl_free_resp(&cmd); | ||
315 | |||
316 | if (nla_put_u32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT) || | ||
317 | nla_put(skb, IWL_TM_ATTR_UCODE_RX_PKT, reply_len, reply_buf)) | ||
318 | goto nla_put_failure; | ||
319 | return cfg80211_testmode_reply(skb); | ||
320 | |||
321 | nla_put_failure: | ||
322 | IWL_DEBUG_INFO(priv, "Failed creating NL attributes\n"); | ||
323 | return -ENOMSG; | ||
324 | } | 129 | } |
325 | 130 | ||
131 | static struct iwl_test_ops tst_ops = { | ||
132 | .send_cmd = iwl_testmode_send_cmd, | ||
133 | .valid_hw_addr = iwl_testmode_valid_hw_addr, | ||
134 | .get_fw_ver = iwl_testmode_get_fw_ver, | ||
135 | .alloc_reply = iwl_testmode_alloc_reply, | ||
136 | .reply = iwl_testmode_reply, | ||
137 | .alloc_event = iwl_testmode_alloc_event, | ||
138 | .event = iwl_testmode_event, | ||
139 | }; | ||
326 | 140 | ||
327 | /* | 141 | void iwl_testmode_init(struct iwl_priv *priv) |
328 | * This function handles the user application commands for register access. | ||
329 | * | ||
330 | * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the | ||
331 | * handlers respectively. | ||
332 | * | ||
333 | * If it's an unknown commdn ID, -ENOSYS is returned; or -ENOMSG if the | ||
334 | * mandatory fields(IWL_TM_ATTR_REG_OFFSET,IWL_TM_ATTR_REG_VALUE32, | ||
335 | * IWL_TM_ATTR_REG_VALUE8) are missing; Otherwise 0 is replied indicating | ||
336 | * the success of the command execution. | ||
337 | * | ||
338 | * If IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_REG_READ32, the register read | ||
339 | * value is returned with IWL_TM_ATTR_REG_VALUE32. | ||
340 | * | ||
341 | * @hw: ieee80211_hw object that represents the device | ||
342 | * @tb: gnl message fields from the user space | ||
343 | */ | ||
344 | static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) | ||
345 | { | 142 | { |
346 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | 143 | iwl_test_init(&priv->tst, priv->trans, &tst_ops); |
347 | u32 ofs, val32, cmd; | ||
348 | u8 val8; | ||
349 | struct sk_buff *skb; | ||
350 | int status = 0; | ||
351 | |||
352 | if (!tb[IWL_TM_ATTR_REG_OFFSET]) { | ||
353 | IWL_ERR(priv, "Missing register offset\n"); | ||
354 | return -ENOMSG; | ||
355 | } | ||
356 | ofs = nla_get_u32(tb[IWL_TM_ATTR_REG_OFFSET]); | ||
357 | IWL_INFO(priv, "testmode register access command offset 0x%x\n", ofs); | ||
358 | |||
359 | /* Allow access only to FH/CSR/HBUS in direct mode. | ||
360 | Since we don't have the upper bounds for the CSR and HBUS segments, | ||
361 | we will use only the upper bound of FH for sanity check. */ | ||
362 | cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); | ||
363 | if ((cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32 || | ||
364 | cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32 || | ||
365 | cmd == IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8) && | ||
366 | (ofs >= FH_MEM_UPPER_BOUND)) { | ||
367 | IWL_ERR(priv, "offset out of segment (0x0 - 0x%x)\n", | ||
368 | FH_MEM_UPPER_BOUND); | ||
369 | return -EINVAL; | ||
370 | } | ||
371 | |||
372 | switch (cmd) { | ||
373 | case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: | ||
374 | val32 = iwl_read_direct32(priv->trans, ofs); | ||
375 | IWL_INFO(priv, "32bit value to read 0x%x\n", val32); | ||
376 | |||
377 | skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); | ||
378 | if (!skb) { | ||
379 | IWL_ERR(priv, "Memory allocation fail\n"); | ||
380 | return -ENOMEM; | ||
381 | } | ||
382 | if (nla_put_u32(skb, IWL_TM_ATTR_REG_VALUE32, val32)) | ||
383 | goto nla_put_failure; | ||
384 | status = cfg80211_testmode_reply(skb); | ||
385 | if (status < 0) | ||
386 | IWL_ERR(priv, "Error sending msg : %d\n", status); | ||
387 | break; | ||
388 | case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: | ||
389 | if (!tb[IWL_TM_ATTR_REG_VALUE32]) { | ||
390 | IWL_ERR(priv, "Missing value to write\n"); | ||
391 | return -ENOMSG; | ||
392 | } else { | ||
393 | val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); | ||
394 | IWL_INFO(priv, "32bit value to write 0x%x\n", val32); | ||
395 | iwl_write_direct32(priv->trans, ofs, val32); | ||
396 | } | ||
397 | break; | ||
398 | case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: | ||
399 | if (!tb[IWL_TM_ATTR_REG_VALUE8]) { | ||
400 | IWL_ERR(priv, "Missing value to write\n"); | ||
401 | return -ENOMSG; | ||
402 | } else { | ||
403 | val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]); | ||
404 | IWL_INFO(priv, "8bit value to write 0x%x\n", val8); | ||
405 | iwl_write8(priv->trans, ofs, val8); | ||
406 | } | ||
407 | break; | ||
408 | default: | ||
409 | IWL_ERR(priv, "Unknown testmode register command ID\n"); | ||
410 | return -ENOSYS; | ||
411 | } | ||
412 | |||
413 | return status; | ||
414 | |||
415 | nla_put_failure: | ||
416 | kfree_skb(skb); | ||
417 | return -EMSGSIZE; | ||
418 | } | 144 | } |
419 | 145 | ||
146 | void iwl_testmode_free(struct iwl_priv *priv) | ||
147 | { | ||
148 | iwl_test_free(&priv->tst); | ||
149 | } | ||
420 | 150 | ||
421 | static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) | 151 | static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) |
422 | { | 152 | { |
@@ -469,7 +199,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) | |||
469 | struct sk_buff *skb; | 199 | struct sk_buff *skb; |
470 | unsigned char *rsp_data_ptr = NULL; | 200 | unsigned char *rsp_data_ptr = NULL; |
471 | int status = 0, rsp_data_len = 0; | 201 | int status = 0, rsp_data_len = 0; |
472 | u32 devid, inst_size = 0, data_size = 0; | 202 | u32 inst_size = 0, data_size = 0; |
473 | const struct fw_img *img; | 203 | const struct fw_img *img; |
474 | 204 | ||
475 | switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { | 205 | switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { |
@@ -563,39 +293,6 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) | |||
563 | priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]); | 293 | priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]); |
564 | break; | 294 | break; |
565 | 295 | ||
566 | case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: | ||
567 | IWL_INFO(priv, "uCode version raw: 0x%x\n", | ||
568 | priv->fw->ucode_ver); | ||
569 | |||
570 | skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); | ||
571 | if (!skb) { | ||
572 | IWL_ERR(priv, "Memory allocation fail\n"); | ||
573 | return -ENOMEM; | ||
574 | } | ||
575 | if (nla_put_u32(skb, IWL_TM_ATTR_FW_VERSION, | ||
576 | priv->fw->ucode_ver)) | ||
577 | goto nla_put_failure; | ||
578 | status = cfg80211_testmode_reply(skb); | ||
579 | if (status < 0) | ||
580 | IWL_ERR(priv, "Error sending msg : %d\n", status); | ||
581 | break; | ||
582 | |||
583 | case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: | ||
584 | devid = priv->trans->hw_id; | ||
585 | IWL_INFO(priv, "hw version: 0x%x\n", devid); | ||
586 | |||
587 | skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); | ||
588 | if (!skb) { | ||
589 | IWL_ERR(priv, "Memory allocation fail\n"); | ||
590 | return -ENOMEM; | ||
591 | } | ||
592 | if (nla_put_u32(skb, IWL_TM_ATTR_DEVICE_ID, devid)) | ||
593 | goto nla_put_failure; | ||
594 | status = cfg80211_testmode_reply(skb); | ||
595 | if (status < 0) | ||
596 | IWL_ERR(priv, "Error sending msg : %d\n", status); | ||
597 | break; | ||
598 | |||
599 | case IWL_TM_CMD_APP2DEV_GET_FW_INFO: | 296 | case IWL_TM_CMD_APP2DEV_GET_FW_INFO: |
600 | skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8); | 297 | skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20 + 8); |
601 | if (!skb) { | 298 | if (!skb) { |
@@ -630,125 +327,6 @@ nla_put_failure: | |||
630 | return -EMSGSIZE; | 327 | return -EMSGSIZE; |
631 | } | 328 | } |
632 | 329 | ||
633 | |||
634 | /* | ||
635 | * This function handles the user application commands for uCode trace | ||
636 | * | ||
637 | * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the | ||
638 | * handlers respectively. | ||
639 | * | ||
640 | * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned | ||
641 | * value of the actual command execution is replied to the user application. | ||
642 | * | ||
643 | * @hw: ieee80211_hw object that represents the device | ||
644 | * @tb: gnl message fields from the user space | ||
645 | */ | ||
646 | static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) | ||
647 | { | ||
648 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | ||
649 | struct sk_buff *skb; | ||
650 | int status = 0; | ||
651 | struct device *dev = priv->trans->dev; | ||
652 | |||
653 | switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { | ||
654 | case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: | ||
655 | if (priv->testmode_trace.trace_enabled) | ||
656 | return -EBUSY; | ||
657 | |||
658 | if (!tb[IWL_TM_ATTR_TRACE_SIZE]) | ||
659 | priv->testmode_trace.buff_size = TRACE_BUFF_SIZE_DEF; | ||
660 | else | ||
661 | priv->testmode_trace.buff_size = | ||
662 | nla_get_u32(tb[IWL_TM_ATTR_TRACE_SIZE]); | ||
663 | if (!priv->testmode_trace.buff_size) | ||
664 | return -EINVAL; | ||
665 | if (priv->testmode_trace.buff_size < TRACE_BUFF_SIZE_MIN || | ||
666 | priv->testmode_trace.buff_size > TRACE_BUFF_SIZE_MAX) | ||
667 | return -EINVAL; | ||
668 | |||
669 | priv->testmode_trace.total_size = | ||
670 | priv->testmode_trace.buff_size + TRACE_BUFF_PADD; | ||
671 | priv->testmode_trace.cpu_addr = | ||
672 | dma_alloc_coherent(dev, | ||
673 | priv->testmode_trace.total_size, | ||
674 | &priv->testmode_trace.dma_addr, | ||
675 | GFP_KERNEL); | ||
676 | if (!priv->testmode_trace.cpu_addr) | ||
677 | return -ENOMEM; | ||
678 | priv->testmode_trace.trace_enabled = true; | ||
679 | priv->testmode_trace.trace_addr = (u8 *)PTR_ALIGN( | ||
680 | priv->testmode_trace.cpu_addr, 0x100); | ||
681 | memset(priv->testmode_trace.trace_addr, 0x03B, | ||
682 | priv->testmode_trace.buff_size); | ||
683 | skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, | ||
684 | sizeof(priv->testmode_trace.dma_addr) + 20); | ||
685 | if (!skb) { | ||
686 | IWL_ERR(priv, "Memory allocation fail\n"); | ||
687 | iwl_trace_cleanup(priv); | ||
688 | return -ENOMEM; | ||
689 | } | ||
690 | if (nla_put(skb, IWL_TM_ATTR_TRACE_ADDR, | ||
691 | sizeof(priv->testmode_trace.dma_addr), | ||
692 | (u64 *)&priv->testmode_trace.dma_addr)) | ||
693 | goto nla_put_failure; | ||
694 | status = cfg80211_testmode_reply(skb); | ||
695 | if (status < 0) { | ||
696 | IWL_ERR(priv, "Error sending msg : %d\n", status); | ||
697 | } | ||
698 | priv->testmode_trace.num_chunks = | ||
699 | DIV_ROUND_UP(priv->testmode_trace.buff_size, | ||
700 | DUMP_CHUNK_SIZE); | ||
701 | break; | ||
702 | |||
703 | case IWL_TM_CMD_APP2DEV_END_TRACE: | ||
704 | iwl_trace_cleanup(priv); | ||
705 | break; | ||
706 | default: | ||
707 | IWL_ERR(priv, "Unknown testmode mem command ID\n"); | ||
708 | return -ENOSYS; | ||
709 | } | ||
710 | return status; | ||
711 | |||
712 | nla_put_failure: | ||
713 | kfree_skb(skb); | ||
714 | if (nla_get_u32(tb[IWL_TM_ATTR_COMMAND]) == | ||
715 | IWL_TM_CMD_APP2DEV_BEGIN_TRACE) | ||
716 | iwl_trace_cleanup(priv); | ||
717 | return -EMSGSIZE; | ||
718 | } | ||
719 | |||
720 | static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, | ||
721 | struct sk_buff *skb, | ||
722 | struct netlink_callback *cb) | ||
723 | { | ||
724 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | ||
725 | int idx, length; | ||
726 | |||
727 | if (priv->testmode_trace.trace_enabled && | ||
728 | priv->testmode_trace.trace_addr) { | ||
729 | idx = cb->args[4]; | ||
730 | if (idx >= priv->testmode_trace.num_chunks) | ||
731 | return -ENOENT; | ||
732 | length = DUMP_CHUNK_SIZE; | ||
733 | if (((idx + 1) == priv->testmode_trace.num_chunks) && | ||
734 | (priv->testmode_trace.buff_size % DUMP_CHUNK_SIZE)) | ||
735 | length = priv->testmode_trace.buff_size % | ||
736 | DUMP_CHUNK_SIZE; | ||
737 | |||
738 | if (nla_put(skb, IWL_TM_ATTR_TRACE_DUMP, length, | ||
739 | priv->testmode_trace.trace_addr + | ||
740 | (DUMP_CHUNK_SIZE * idx))) | ||
741 | goto nla_put_failure; | ||
742 | idx++; | ||
743 | cb->args[4] = idx; | ||
744 | return 0; | ||
745 | } else | ||
746 | return -EFAULT; | ||
747 | |||
748 | nla_put_failure: | ||
749 | return -ENOBUFS; | ||
750 | } | ||
751 | |||
752 | /* | 330 | /* |
753 | * This function handles the user application switch ucode ownership. | 331 | * This function handles the user application switch ucode ownership. |
754 | * | 332 | * |
@@ -777,10 +355,10 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) | |||
777 | owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]); | 355 | owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]); |
778 | if (owner == IWL_OWNERSHIP_DRIVER) { | 356 | if (owner == IWL_OWNERSHIP_DRIVER) { |
779 | priv->ucode_owner = owner; | 357 | priv->ucode_owner = owner; |
780 | priv->pre_rx_handler = NULL; | 358 | iwl_test_enable_notifications(&priv->tst, false); |
781 | } else if (owner == IWL_OWNERSHIP_TM) { | 359 | } else if (owner == IWL_OWNERSHIP_TM) { |
782 | priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; | ||
783 | priv->ucode_owner = owner; | 360 | priv->ucode_owner = owner; |
361 | iwl_test_enable_notifications(&priv->tst, true); | ||
784 | } else { | 362 | } else { |
785 | IWL_ERR(priv, "Invalid owner\n"); | 363 | IWL_ERR(priv, "Invalid owner\n"); |
786 | return -EINVAL; | 364 | return -EINVAL; |
@@ -788,180 +366,6 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) | |||
788 | return 0; | 366 | return 0; |
789 | } | 367 | } |
790 | 368 | ||
791 | static int iwl_testmode_indirect_read(struct iwl_priv *priv, u32 addr, u32 size) | ||
792 | { | ||
793 | struct iwl_trans *trans = priv->trans; | ||
794 | unsigned long flags; | ||
795 | int i; | ||
796 | |||
797 | if (size & 0x3) | ||
798 | return -EINVAL; | ||
799 | priv->testmode_mem.buff_size = size; | ||
800 | priv->testmode_mem.buff_addr = | ||
801 | kmalloc(priv->testmode_mem.buff_size, GFP_KERNEL); | ||
802 | if (priv->testmode_mem.buff_addr == NULL) | ||
803 | return -ENOMEM; | ||
804 | |||
805 | /* Hard-coded periphery absolute address */ | ||
806 | if (IWL_TM_ABS_PRPH_START <= addr && | ||
807 | addr < IWL_TM_ABS_PRPH_START + PRPH_END) { | ||
808 | spin_lock_irqsave(&trans->reg_lock, flags); | ||
809 | iwl_grab_nic_access(trans); | ||
810 | iwl_write32(trans, HBUS_TARG_PRPH_RADDR, | ||
811 | addr | (3 << 24)); | ||
812 | for (i = 0; i < size; i += 4) | ||
813 | *(u32 *)(priv->testmode_mem.buff_addr + i) = | ||
814 | iwl_read32(trans, HBUS_TARG_PRPH_RDAT); | ||
815 | iwl_release_nic_access(trans); | ||
816 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
817 | } else { /* target memory (SRAM) */ | ||
818 | _iwl_read_targ_mem_words(trans, addr, | ||
819 | priv->testmode_mem.buff_addr, | ||
820 | priv->testmode_mem.buff_size / 4); | ||
821 | } | ||
822 | |||
823 | priv->testmode_mem.num_chunks = | ||
824 | DIV_ROUND_UP(priv->testmode_mem.buff_size, DUMP_CHUNK_SIZE); | ||
825 | priv->testmode_mem.read_in_progress = true; | ||
826 | return 0; | ||
827 | |||
828 | } | ||
829 | |||
830 | static int iwl_testmode_indirect_write(struct iwl_priv *priv, u32 addr, | ||
831 | u32 size, unsigned char *buf) | ||
832 | { | ||
833 | struct iwl_trans *trans = priv->trans; | ||
834 | u32 val, i; | ||
835 | unsigned long flags; | ||
836 | |||
837 | if (IWL_TM_ABS_PRPH_START <= addr && | ||
838 | addr < IWL_TM_ABS_PRPH_START + PRPH_END) { | ||
839 | /* Periphery writes can be 1-3 bytes long, or DWORDs */ | ||
840 | if (size < 4) { | ||
841 | memcpy(&val, buf, size); | ||
842 | spin_lock_irqsave(&trans->reg_lock, flags); | ||
843 | iwl_grab_nic_access(trans); | ||
844 | iwl_write32(trans, HBUS_TARG_PRPH_WADDR, | ||
845 | (addr & 0x0000FFFF) | | ||
846 | ((size - 1) << 24)); | ||
847 | iwl_write32(trans, HBUS_TARG_PRPH_WDAT, val); | ||
848 | iwl_release_nic_access(trans); | ||
849 | /* needed after consecutive writes w/o read */ | ||
850 | mmiowb(); | ||
851 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
852 | } else { | ||
853 | if (size % 4) | ||
854 | return -EINVAL; | ||
855 | for (i = 0; i < size; i += 4) | ||
856 | iwl_write_prph(trans, addr+i, | ||
857 | *(u32 *)(buf+i)); | ||
858 | } | ||
859 | } else if (iwlagn_hw_valid_rtc_data_addr(addr) || | ||
860 | (IWLAGN_RTC_INST_LOWER_BOUND <= addr && | ||
861 | addr < IWLAGN_RTC_INST_UPPER_BOUND)) { | ||
862 | _iwl_write_targ_mem_words(trans, addr, buf, size/4); | ||
863 | } else | ||
864 | return -EINVAL; | ||
865 | return 0; | ||
866 | } | ||
867 | |||
868 | /* | ||
869 | * This function handles the user application commands for SRAM data dump | ||
870 | * | ||
871 | * It retrieves the mandatory fields IWL_TM_ATTR_SRAM_ADDR and | ||
872 | * IWL_TM_ATTR_SRAM_SIZE to decide the memory area for SRAM data reading | ||
873 | * | ||
874 | * Several error will be retured, -EBUSY if the SRAM data retrieved by | ||
875 | * previous command has not been delivered to userspace, or -ENOMSG if | ||
876 | * the mandatory fields (IWL_TM_ATTR_SRAM_ADDR,IWL_TM_ATTR_SRAM_SIZE) | ||
877 | * are missing, or -ENOMEM if the buffer allocation fails. | ||
878 | * | ||
879 | * Otherwise 0 is replied indicating the success of the SRAM reading. | ||
880 | * | ||
881 | * @hw: ieee80211_hw object that represents the device | ||
882 | * @tb: gnl message fields from the user space | ||
883 | */ | ||
884 | static int iwl_testmode_indirect_mem(struct ieee80211_hw *hw, | ||
885 | struct nlattr **tb) | ||
886 | { | ||
887 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | ||
888 | u32 addr, size, cmd; | ||
889 | unsigned char *buf; | ||
890 | |||
891 | /* Both read and write should be blocked, for atomicity */ | ||
892 | if (priv->testmode_mem.read_in_progress) | ||
893 | return -EBUSY; | ||
894 | |||
895 | cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); | ||
896 | if (!tb[IWL_TM_ATTR_MEM_ADDR]) { | ||
897 | IWL_ERR(priv, "Error finding memory offset address\n"); | ||
898 | return -ENOMSG; | ||
899 | } | ||
900 | addr = nla_get_u32(tb[IWL_TM_ATTR_MEM_ADDR]); | ||
901 | if (!tb[IWL_TM_ATTR_BUFFER_SIZE]) { | ||
902 | IWL_ERR(priv, "Error finding size for memory reading\n"); | ||
903 | return -ENOMSG; | ||
904 | } | ||
905 | size = nla_get_u32(tb[IWL_TM_ATTR_BUFFER_SIZE]); | ||
906 | |||
907 | if (cmd == IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ) | ||
908 | return iwl_testmode_indirect_read(priv, addr, size); | ||
909 | else { | ||
910 | if (!tb[IWL_TM_ATTR_BUFFER_DUMP]) | ||
911 | return -EINVAL; | ||
912 | buf = (unsigned char *) nla_data(tb[IWL_TM_ATTR_BUFFER_DUMP]); | ||
913 | return iwl_testmode_indirect_write(priv, addr, size, buf); | ||
914 | } | ||
915 | } | ||
916 | |||
917 | static int iwl_testmode_buffer_dump(struct ieee80211_hw *hw, | ||
918 | struct sk_buff *skb, | ||
919 | struct netlink_callback *cb) | ||
920 | { | ||
921 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | ||
922 | int idx, length; | ||
923 | |||
924 | if (priv->testmode_mem.read_in_progress) { | ||
925 | idx = cb->args[4]; | ||
926 | if (idx >= priv->testmode_mem.num_chunks) { | ||
927 | iwl_mem_cleanup(priv); | ||
928 | return -ENOENT; | ||
929 | } | ||
930 | length = DUMP_CHUNK_SIZE; | ||
931 | if (((idx + 1) == priv->testmode_mem.num_chunks) && | ||
932 | (priv->testmode_mem.buff_size % DUMP_CHUNK_SIZE)) | ||
933 | length = priv->testmode_mem.buff_size % | ||
934 | DUMP_CHUNK_SIZE; | ||
935 | |||
936 | if (nla_put(skb, IWL_TM_ATTR_BUFFER_DUMP, length, | ||
937 | priv->testmode_mem.buff_addr + | ||
938 | (DUMP_CHUNK_SIZE * idx))) | ||
939 | goto nla_put_failure; | ||
940 | idx++; | ||
941 | cb->args[4] = idx; | ||
942 | return 0; | ||
943 | } else | ||
944 | return -EFAULT; | ||
945 | |||
946 | nla_put_failure: | ||
947 | return -ENOBUFS; | ||
948 | } | ||
949 | |||
950 | static int iwl_testmode_notifications(struct ieee80211_hw *hw, | ||
951 | struct nlattr **tb) | ||
952 | { | ||
953 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | ||
954 | bool enable; | ||
955 | |||
956 | enable = nla_get_flag(tb[IWL_TM_ATTR_ENABLE_NOTIFICATION]); | ||
957 | if (enable) | ||
958 | priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; | ||
959 | else | ||
960 | priv->pre_rx_handler = NULL; | ||
961 | return 0; | ||
962 | } | ||
963 | |||
964 | |||
965 | /* The testmode gnl message handler that takes the gnl message from the | 369 | /* The testmode gnl message handler that takes the gnl message from the |
966 | * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then | 370 | * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then |
967 | * invoke the corresponding handlers. | 371 | * invoke the corresponding handlers. |
@@ -987,32 +391,27 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) | |||
987 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | 391 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); |
988 | int result; | 392 | int result; |
989 | 393 | ||
990 | result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, | 394 | result = iwl_test_parse(&priv->tst, tb, data, len); |
991 | iwl_testmode_gnl_msg_policy); | 395 | if (result) |
992 | if (result != 0) { | ||
993 | IWL_ERR(priv, "Error parsing the gnl message : %d\n", result); | ||
994 | return result; | 396 | return result; |
995 | } | ||
996 | 397 | ||
997 | /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ | ||
998 | if (!tb[IWL_TM_ATTR_COMMAND]) { | ||
999 | IWL_ERR(priv, "Missing testmode command type\n"); | ||
1000 | return -ENOMSG; | ||
1001 | } | ||
1002 | /* in case multiple accesses to the device happens */ | 398 | /* in case multiple accesses to the device happens */ |
1003 | mutex_lock(&priv->mutex); | 399 | mutex_lock(&priv->mutex); |
1004 | |||
1005 | switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { | 400 | switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { |
1006 | case IWL_TM_CMD_APP2DEV_UCODE: | 401 | case IWL_TM_CMD_APP2DEV_UCODE: |
1007 | IWL_DEBUG_INFO(priv, "testmode cmd to uCode\n"); | ||
1008 | result = iwl_testmode_ucode(hw, tb); | ||
1009 | break; | ||
1010 | case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: | 402 | case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: |
1011 | case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: | 403 | case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: |
1012 | case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: | 404 | case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: |
1013 | IWL_DEBUG_INFO(priv, "testmode cmd to register\n"); | 405 | case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: |
1014 | result = iwl_testmode_reg(hw, tb); | 406 | case IWL_TM_CMD_APP2DEV_END_TRACE: |
407 | case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ: | ||
408 | case IWL_TM_CMD_APP2DEV_NOTIFICATIONS: | ||
409 | case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: | ||
410 | case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: | ||
411 | case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE: | ||
412 | result = iwl_test_handle_cmd(&priv->tst, tb); | ||
1015 | break; | 413 | break; |
414 | |||
1016 | case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: | 415 | case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: |
1017 | case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: | 416 | case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: |
1018 | case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: | 417 | case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: |
@@ -1020,45 +419,25 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) | |||
1020 | case IWL_TM_CMD_APP2DEV_GET_EEPROM: | 419 | case IWL_TM_CMD_APP2DEV_GET_EEPROM: |
1021 | case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: | 420 | case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: |
1022 | case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: | 421 | case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: |
1023 | case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: | ||
1024 | case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: | ||
1025 | case IWL_TM_CMD_APP2DEV_GET_FW_INFO: | 422 | case IWL_TM_CMD_APP2DEV_GET_FW_INFO: |
1026 | IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); | 423 | IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); |
1027 | result = iwl_testmode_driver(hw, tb); | 424 | result = iwl_testmode_driver(hw, tb); |
1028 | break; | 425 | break; |
1029 | 426 | ||
1030 | case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: | ||
1031 | case IWL_TM_CMD_APP2DEV_END_TRACE: | ||
1032 | case IWL_TM_CMD_APP2DEV_READ_TRACE: | ||
1033 | IWL_DEBUG_INFO(priv, "testmode uCode trace cmd to driver\n"); | ||
1034 | result = iwl_testmode_trace(hw, tb); | ||
1035 | break; | ||
1036 | |||
1037 | case IWL_TM_CMD_APP2DEV_OWNERSHIP: | 427 | case IWL_TM_CMD_APP2DEV_OWNERSHIP: |
1038 | IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n"); | 428 | IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n"); |
1039 | result = iwl_testmode_ownership(hw, tb); | 429 | result = iwl_testmode_ownership(hw, tb); |
1040 | break; | 430 | break; |
1041 | 431 | ||
1042 | case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_READ: | ||
1043 | case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_WRITE: | ||
1044 | IWL_DEBUG_INFO(priv, "testmode indirect memory cmd " | ||
1045 | "to driver\n"); | ||
1046 | result = iwl_testmode_indirect_mem(hw, tb); | ||
1047 | break; | ||
1048 | |||
1049 | case IWL_TM_CMD_APP2DEV_NOTIFICATIONS: | ||
1050 | IWL_DEBUG_INFO(priv, "testmode notifications cmd " | ||
1051 | "to driver\n"); | ||
1052 | result = iwl_testmode_notifications(hw, tb); | ||
1053 | break; | ||
1054 | |||
1055 | default: | 432 | default: |
1056 | IWL_ERR(priv, "Unknown testmode command\n"); | 433 | IWL_ERR(priv, "Unknown testmode command\n"); |
1057 | result = -ENOSYS; | 434 | result = -ENOSYS; |
1058 | break; | 435 | break; |
1059 | } | 436 | } |
1060 | |||
1061 | mutex_unlock(&priv->mutex); | 437 | mutex_unlock(&priv->mutex); |
438 | |||
439 | if (result) | ||
440 | IWL_ERR(priv, "Test cmd failed result=%d\n", result); | ||
1062 | return result; | 441 | return result; |
1063 | } | 442 | } |
1064 | 443 | ||
@@ -1066,7 +445,6 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1066 | struct netlink_callback *cb, | 445 | struct netlink_callback *cb, |
1067 | void *data, int len) | 446 | void *data, int len) |
1068 | { | 447 | { |
1069 | struct nlattr *tb[IWL_TM_ATTR_MAX]; | ||
1070 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); | 448 | struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); |
1071 | int result; | 449 | int result; |
1072 | u32 cmd; | 450 | u32 cmd; |
@@ -1075,39 +453,19 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1075 | /* offset by 1 since commands start at 0 */ | 453 | /* offset by 1 since commands start at 0 */ |
1076 | cmd = cb->args[3] - 1; | 454 | cmd = cb->args[3] - 1; |
1077 | } else { | 455 | } else { |
1078 | result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, | 456 | struct nlattr *tb[IWL_TM_ATTR_MAX]; |
1079 | iwl_testmode_gnl_msg_policy); | 457 | |
1080 | if (result) { | 458 | result = iwl_test_parse(&priv->tst, tb, data, len); |
1081 | IWL_ERR(priv, | 459 | if (result) |
1082 | "Error parsing the gnl message : %d\n", result); | ||
1083 | return result; | 460 | return result; |
1084 | } | ||
1085 | 461 | ||
1086 | /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ | ||
1087 | if (!tb[IWL_TM_ATTR_COMMAND]) { | ||
1088 | IWL_ERR(priv, "Missing testmode command type\n"); | ||
1089 | return -ENOMSG; | ||
1090 | } | ||
1091 | cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); | 462 | cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); |
1092 | cb->args[3] = cmd + 1; | 463 | cb->args[3] = cmd + 1; |
1093 | } | 464 | } |
1094 | 465 | ||
1095 | /* in case multiple accesses to the device happens */ | 466 | /* in case multiple accesses to the device happens */ |
1096 | mutex_lock(&priv->mutex); | 467 | mutex_lock(&priv->mutex); |
1097 | switch (cmd) { | 468 | result = iwl_test_dump(&priv->tst, cmd, skb, cb); |
1098 | case IWL_TM_CMD_APP2DEV_READ_TRACE: | ||
1099 | IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n"); | ||
1100 | result = iwl_testmode_trace_dump(hw, skb, cb); | ||
1101 | break; | ||
1102 | case IWL_TM_CMD_APP2DEV_INDIRECT_BUFFER_DUMP: | ||
1103 | IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n"); | ||
1104 | result = iwl_testmode_buffer_dump(hw, skb, cb); | ||
1105 | break; | ||
1106 | default: | ||
1107 | result = -EINVAL; | ||
1108 | break; | ||
1109 | } | ||
1110 | |||
1111 | mutex_unlock(&priv->mutex); | 469 | mutex_unlock(&priv->mutex); |
1112 | return result; | 470 | return result; |
1113 | } | 471 | } |